purifoBERO usage from claimers
    Updated 2024-12-14
    with plugins as (select concat('0x',substr(TOPICS[1], 27,64)) as plugin, concat('0x',substr(TOPICS[2], 27,64)) as gauge from berachain.testnet.fact_event_logs
    where (ORIGIN_TO_ADDRESS=lower('0x580ABF764405aA82dC96788b356435474c5956A7') or ORIGIN_TO_ADDRESS=lower('0x2363BB86cD2ABF89cc059A654f89f11bCceffcA9')
    or ORIGIN_TO_ADDRESS=lower('0x1f9505Ae18755915DcD2a95f38c7560Cab149d9C'))
    and ORIGIN_FUNCTION_SIGNATURE='0xd8867fc8'
    and topics[0]='0xb920b936f556d443772609e0cc06a72c3bb67fc606de10dcdd51323d1ddbc7fc'),
    farm_reward_claim as (
    select user, sum(amount) as amount from (
    select concat('0x',substr(TOPICS[1], 27,64)) as user, concat('0x',substr(TOPICS[2], 27,64)) as token,(utils.udf_hex_to_int(substr(data,3,66))::int)/1e18 as amount from berachain.testnet.fact_event_logs
    where ORIGIN_TO_ADDRESS in (select gauge from plugins)
    and ORIGIN_FUNCTION_SIGNATURE='0xc00007b0'
    and topics[0]='0x773189df03a25c28916cd3a8c2609c1c3d8c0386d0fe0958aa3f62c888bac6aa'
    )
    where token=lower('0x7629668774f918c00Eb4b03AdF5C4e2E53d45f0b')
    group by 1
    order by amount desc
    ),
    exercise as (
    select user, sum(amount) as exercised from (
    select concat('0x',substr(TOPICS[1], 27,64)) as user,(utils.udf_hex_to_int(substr(data,3,66))::int)/1e18 as amount
    from berachain.testnet.fact_event_logs
    where contract_address=lower('0xB5A27c33bA2ADEcee8CdBE94cEF5576E2F364A8f')
    and origin_to_address=lower('0xB5A27c33bA2ADEcee8CdBE94cEF5576E2F364A8f')
    and ORIGIN_FUNCTION_SIGNATURE='0x1b6b7298'
    and TOPICS[0]='0x199b105faa55cbba66c6c51adb78bf93238b4ad0cfadd14c986af220da77e7c8')
    group by 1
    ),
    burned as (
    select user, sum(burned) as burned 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
    ),
    claimed_from_staking as (
    QueryRunArchived: QueryRun has been archived