purifyeeters
    Updated 2024-09-29
    with yeeters as (
    select address, sum(pot_after-pot_before) as yeet_amount from (
    select concat('0x',substr(TOPICS[1], 27,64)) as address,
    utils.udf_hex_to_int(substr(substr(data, 0,66),3,66)) as timestamp,
    (utils.udf_hex_to_int(substr(data,67,64))::int)/1e18 as pot_before,
    (utils.udf_hex_to_int(substr(data,131,64))::int)/1e18 as pot_after,
    from berachain.testnet.fact_event_logs
    where ORIGIN_TO_ADDRESS=LOWER('0x14D65204c710997F595F4663f0451b66d3532f53')
    and ORIGIN_FUNCTION_SIGNATURE='0x8bbefe4b'
    and topics[0]='0x67e0e8435cacda8ca6cf3a8f63b166cdb95dc96e7d1c6e068009b117d47e1ac6'
    )
    group by 1
    ),
    stakers as (
    select address, sum(amount) as staked from (
    select concat('0x',substr(TOPICS[1], 27,64)) as address,(utils.udf_hex_to_int(substr(data,3,66))::int)/1e18 as amount
    from berachain.testnet.fact_event_logs
    where ORIGIN_TO_ADDRESS=LOWER('0xd98c56EBbb46aA3a85Cc488c6b24E0d486624D9F')
    and ORIGIN_FUNCTION_SIGNATURE='0xa694fc3a'
    and topics[0]='0xebedb8b3c678666e7f36970bc8f57abf6d8fa2e828c0da91ea5b75bf68ed101a'
    union all
    select concat('0x',substr(TOPICS[1], 27,64)) as address,-1.0*(utils.udf_hex_to_int(substr(data,3,64))::int)/1e18 as amount,
    from berachain.testnet.fact_event_logs
    where ORIGIN_TO_ADDRESS=LOWER('0xd98c56EBbb46aA3a85Cc488c6b24E0d486624D9F')
    and ORIGIN_FUNCTION_SIGNATURE='0x2e17de78'
    and topics[0]='0xf960dbf9e5d0682f7a298ed974e33a28b4464914b7a2bfac12ae419a9afeb280'
    )
    group by 1
    ),
    bonders as (select distinct origin_from_address as address from berachain.testnet.fact_event_logs
    where topics[0]='0x3ae5efadaccde413bdfcb3a4626babecd844c502ee4c2c9b340f28cd9d552732'
    and contract_address=lower('0x007f774351e541b8bc720018de0796c4bf5afe3d')
    )
    select DISTINCT address from (
    select distinct address from yeeters
    union
    QueryRunArchived: QueryRun has been archived