select block_timestamp::date as date,
stake_pool_name,
count (distinct tx_id) as TX_Count,
count (distinct address) as Users_Count,
sum (amount/1e9) as Total_Volume,
avg ((amount/1e9)) as Average_Volume,
sum (TX_Count) over (partition by stake_pool_name order by date) as Cumulative_TX_Count,
sum (Total_Volume) over (partition by stake_pool_name order by date) as Cumulative_Volume
from solana.core.fact_stake_pool_actions
where succeeded = 'TRUE'
and block_timestamp >= CURRENT_DATE - 7
and (action ilike '%withdraw%' or action ilike '%unstake%')
group by 1,2
order by 1