mehrancrypto-dxoepqQ69-2
Updated 2022-10-19
99
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
›
⌄
with tab1 as
(
SELECT BLOCK_TIMESTAMP::date as daily ,count(DISTINCT TX_SIGNER) as stakers , SUM(STAKE_AMOUNT)*power(10,-24) as staked
from near.core.dim_staking_actions
where ACTION = 'Stake'
GROUP by 1
)
,
tab2 as (
SELECT BLOCK_TIMESTAMP::date as daily ,count(DISTINCT TX_SIGNER) as unstakers , SUM(STAKE_AMOUNT)*power(10,-24) as unstaked
from near.core.dim_staking_actions
where ACTION = 'Unstake'
GROUP by 1
)
SELECT A.daily , unstakers , stakers , staked , -unstaked , staked-unstaked as net_staked ,
sum(net_staked) over(order by A.daily) as cumulative_net_staked ,
sum(staked) over(order by A.daily) as cumulative_staked ,
-sum(unstaked) over(order by A.daily) as cumulative_unstaked ,
case
when A.daily >= CURRENT_DATE - 90 then 'Past 90 days'
else 'Earlier'
end as type
from tab1 A , tab2 B
where A.daily = B.daily
Run a query to Download Data