purifberadrome Voting power holders
    Updated 2024-12-14
    with staking as (
    select user, sum(staked) as staked from (
    select concat('0x',substr(TOPICS[1], 27,64)) as user, (utils.udf_hex_to_int(substr(data,3,66))::int)/1e18 as staked
    from berachain.testnet.fact_event_logs
    where CONTRACT_ADDRESS=lower('0x2B4141f98B8cD2a03F58bD722D4E8916d2106504')
    and ORIGIN_FUNCTION_SIGNATURE='0xb6b55f25'
    and TOPICS[0]='0xdceb62ada4e4ec63db2fb9ed65e38a56764ba06e1346b9aebc081ead867fa5a3')
    group by 1
    ),
    unstaking as (
    select user, sum(unstaked) as unstaked from (
    select concat('0x',substr(TOPICS[1], 27,64)) as user, (utils.udf_hex_to_int(substr(data,3,66))::int)/1e18 as unstaked
    from berachain.testnet.fact_event_logs
    where CONTRACT_ADDRESS=lower('0x2B4141f98B8cD2a03F58bD722D4E8916d2106504')
    and ORIGIN_FUNCTION_SIGNATURE='0x2e1a7d4d'
    and TOPICS[0]='0x6d8fccb210175d9b6d8a076e606aebf0e5f57d186e5d48e8cc5d431a88e5ae6b')
    group by 1
    ),
    burned as (
    select user, sum(burned) as burn from (
    select concat('0x',substr(TOPICS[1], 27,64)) as user, (utils.udf_hex_to_int(substr(data,3,66))::int)/1e18 as burned
    from berachain.testnet.fact_event_logs
    where CONTRACT_ADDRESS=lower('0x2B4141f98B8cD2a03F58bD722D4E8916d2106504')
    and ORIGIN_FUNCTION_SIGNATURE='0x1dd319cb'
    and TOPICS[0]='0x9c6f79d7f1057ffac5eaa31065872a36975bcc08ad7bd9119d6f703795660f77')
    group by 1
    )

    select user, stake, burn, stake+burn as total_voting_power from (
    select coalesce(s.user, b.user) as user, coalesce(staked,0)-coalesce(unstaked,0) as stake, coalesce(burn,0) as burn from staking s
    left join unstaking u on u.user=s.user
    full join burned b on b.user=s.user)
    where user!='0x19858f6c29ea886853dc97d1a68abf8d4cb07712'
    order by total_voting_power desc

    QueryRunArchived: QueryRun has been archived