Bera TeamTotal and New Delegators
    Updated 2025-01-31
    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')
    )
    ,
    min as ( select min(block_timestamp::date) as day,
    delegator
    from queue
    group by 2)
    ,
    final as (select day,
    count(DISTINCT delegator) as "New Delegators"
    from min
    where day >= '2024-01-01'
    group by 1)

    select sum("New Delegators") as total,
    avg("New Delegators") as avg_daily
    from final
    where day >= current_date - 7

    QueryRunArchived: QueryRun has been archived