SELECT
date_trunc('month',block_timestamp) as date,
case
when action in ('TokensCommitted', 'DelegatorTokensCommitted') then 'Stake'
when action in ('DelegatorUnstakedTokensWithdrawn', 'UnstakedTokensWithdrawn') then 'Unstake'
when action in ('RewardTokensWithdrawn', 'DelegatorRewardTokensWithdrawn') then 'Claim Reward'
end as type,
count(distinct delegator) as users,
count(distinct tx_id) as tx_count,
sum(amount) as amount
from flow.core.ez_staking_actions
where TX_SUCCEEDED = 'TRUE'
group by 1,2