MrftiOverview of Top Delegators copy
    Updated 2024-10-07
    -- forked from hess / Overview of Top Delegators @ https://flipsidecrypto.xyz/hess/q/JXWVmhGfJjUO/overview-of-top-delegators

    with queue as (select block_timestamp,
    tx_hash,
    data,
    '0x' || SUBSTR(topics[1]::STRING, 27) AS delegator,
    '0x' || SUBSTR(topics[2]::STRING, 27) AS validator_address,
    ltrim(data, '0x') as decoded,
    livequery.utils.udf_hex_to_int(decoded)/pow(10,18) as amount
    from berachain.testnet.fact_event_logs
    where TOPICS[0] = '0x110aaf2f67d6465fc043087acff06b302e8db1b6b9157d72ee4d4cc5c96bcb9d'
    and CONTRACT_ADDRESS = '0xbda130737bdd9618301681329bf2e46a016ff9ad'
    and ORIGIN_TO_ADDRESS = '0xbda130737bdd9618301681329bf2e46a016ff9ad'
    and tx_hash not in (select tx_hash from berachain.testnet.fact_event_logs
    where origin_function_signature = '0xc2ca9c3a')
    )
    ,
    undelegate as (select block_timestamp,
    tx_hash,
    data,
    '0x' || SUBSTR(topics[1]::STRING, 27) AS undelegator,
    '0x' || SUBSTR(topics[2]::STRING, 27) AS validator_address,
    ltrim(data, '0x') as decoded,
    livequery.utils.udf_hex_to_int(decoded)/pow(10,18) as amount
    from berachain.testnet.fact_event_logs
    where TOPICS[0] = '0xdc232a1d360a44eb299ff026b5f6badfe40d17f95b96da5db7168e88662e9a2c'
    and CONTRACT_ADDRESS = '0xbda130737bdd9618301681329bf2e46a016ff9ad'
    and ORIGIN_TO_ADDRESS = '0xbda130737bdd9618301681329bf2e46a016ff9ad')
    ,
    active as (select block_timestamp,
    tx_hash,
    data,
    '0x' || SUBSTR(topics[1]::STRING, 27) AS delegator,
    '0x' || SUBSTR(topics[2]::STRING, 27) AS validator_address,
    ltrim(data, '0x') as decoded,
    livequery.utils.udf_hex_to_int(decoded)/pow(10,18) as amount
    QueryRunArchived: QueryRun has been archived