select
date_trunc('day', block_timestamp) as date,
case when action='Delegate' then 'Stake'
when action ='Undelegate' then 'Unstake'
END as type,
COUNT(DISTINCT DELEGATOR_ADDRESS) as "Number of Delegators",
count(tx_id) as "Number of Stakings",
sum(AMOUNT) as "Volume"
from terra.core.ez_staking
where block_timestamp >= current_date - INTERVAL '60 days'
and TX_SUCCEEDED='True'
and ACTION in ('Delegate', 'Undelegate')
group by 1, 2
order by 1