feyikemiVertex Stake Over_Time
    Updated 2024-05-14
    select
    date,
    sum(amount) as total_staked ,
    sum(total_staked) over (order by date) as cum_staked
    from (
    select
    date_trunc('day', block_timestamp) as date,
    sum(amount) as amount
    from arbitrum.core.ez_token_transfers
    where to_address = '0x5be754ad77766089c4284d914f0cc37e8e3f669a'
    and contract_address = '0x95146881b86b3ee99e63705ec87afe29fcc044d9'
    group by 1
    union all
    select
    date_trunc('day', block_timestamp) as date,
    sum(-amount) as amount
    from (
    select
    input,
    block_timestamp,
    substring(input, 1 , 10) as method_id,
    substring(input, 11, 64) as data_a,
    livequery.utils.udf_hex_to_int(substring(input,11, 64)) :: int / pow(10, 18) as amount
    from arbitrum.core.fact_traces
    where to_address = '0x5be754ad77766089c4284d914f0cc37e8e3f669a'
    and type = 'CALL'

    )
    where method_id = '0x2e1a7d4d'
    group by 1
    )
    group by 1
    order by 1 desc



    QueryRunArchived: QueryRun has been archived