0xHaM-dAverage Staking
Updated 2023-04-14Copy Reference Fork
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
26
27
28
29
30
31
32
33
34
35
36
›
⌄
with createTb as (
select
signer_id,
min(block_timestamp)::date as creation_date
from near.social.fact_profile_changes
join near.core.fact_transactions using(tx_hash)
where tx_status = 'Success'
group by signer_id
)
, monthTb as (
SELECT
signer_id,
monthname(creation_date) as months
FROM createTb
WHERE months in ('{{Birthday_Month}}') -- Jan, Feb, Mar, Apr, May, Jun, Jul, Aug, Sep, Oct, Nov, Dec
)
, stakinTb as (
SELECT
TX_SIGNER,
count(distinct TX_HASH) as tx_cnt,
sum(STAKE_AMOUNT/1e24) as stake_vol
FROM near.core.dim_staking_actions JOIN monthTb on TX_SIGNER = signer_id
WHERE ACTION in ('Stake')
GROUP by 1
)
SELECT
count(distinct TX_SIGNER) as staker_cnt,
round(avg(tx_cnt), 2) as avg_num_times_staking,
round(avg(stake_vol), 2) as avg_amt_staked,
round(median(stake_vol), 2) as med_amt_staked,
round(min(stake_vol), 2) as min_amt_staked,
round(max(stake_vol), 2) as max_amt_staked
FROM stakinTb
Run a query to Download Data