SpiltadavidDaily Functions' Count
    Updated 2023-02-02
    with chat1 as (select count(distinct TX_HASH) , METHOD_NAME ,case
    when METHOD_NAME in ('deposit_and_stake' , 'stake' , 'stake_all') then 'STAKING'
    when METHOD_NAME in ('unstake' , 'unstake_all') then 'UNSTAKING' end as functions
    from near.core.fact_actions_events_function_call
    where METHOD_NAME in ('deposit_and_stake','stake','stake_all','unstake','unstake_all')
    and BLOCK_TIMESTAMP::date > CURRENT_DATE - interval '3 month'
    group by 2,3)
    , chat2 as (select block_timestamp::date , count(distinct TX_HASH) ,case
    when METHOD_NAME in ('deposit_and_stake' , 'stake' , 'stake_all') then 'STAKING'
    when METHOD_NAME in ('unstake' , 'unstake_all') then 'UNSTAKING' end as functions
    from near.core.fact_actions_events_function_call
    where METHOD_NAME in ('deposit_and_stake','stake','stake_all','unstake','unstake_all')
    and BLOCK_TIMESTAMP::date > CURRENT_DATE - interval '3 month'
    group by 1,3)

    , chart3 as ( select block_timestamp::date as dt , count(distinct TX_HASH) as swaps , count(distinct TRADER) as wallets ,count(distinct POOL_ID) as pools,
    sum(swaps) over (order by dt) as cum_swaps,sum(wallets) over (order by dt) as cum_wallets
    from near.core.ez_dex_swaps
    where platform = 'v2.ref-finance.near'
    and BLOCK_TIMESTAMP::date > CURRENT_DATE - interval '3 month'
    group by 1)

    select * from chat2
    Run a query to Download Data