sagharkariAverage Daily Flow Staking Actions Stats
    Updated 2023-05-11
    with maintable as (
    select date_trunc (day,block_timestamp) as date,
    case when action in ('DelegatorTokensCommitted','TokensCommitted') then 'Stake'
    when action in ('DelegatorUnstakedTokensWithdrawn','UnstakedTokensWithdrawn') then 'Unstake'
    when action in ('DelegatorRewardTokensWithdrawn','RewardTokensWithdrawn') then 'Claim Reward' end as action_type,
    count (distinct tx_id) as TX_Count,
    count (distinct delegator) as Users_Count,
    sum (amount) as Total_Volume,
    avg (amount) as Average_Volume,
    median (amount) as Median_Volume,
    min (amount) as Min_Volume,
    max (amount) as Max_Volume,
    sum (TX_Count) over (partition by action_type order by date) as Cumulative_TX_Count,
    sum (Total_Volume) over (partition by action_type order by date) as Cumulative_Volume
    from flow.core.ez_staking_actions
    where tx_succeeded = 'TRUE'
    group by 1,2)

    select action_type,
    avg (Tx_count) as Average_TX_Count,
    avg (users_count) as Average_Users_Count,
    avg (total_volume) as Average_Volume
    from maintable
    group by 1
    order by 2 desc
    Run a query to Download Data