TheLaughingManStakers by Stake Duration copy
Updated 2025-01-21
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
›
⌄
-- forked from Masi / Stakers by Stake Duration @ https://flipsidecrypto.xyz/Masi/q/xmEvAP_209pn/stakers-by-stake-duration
WITH tb1 AS (
SELECT
block_timestamp,
ACTION_DATA:args:"amount" / POW(10, 18) AS amount,
ACTION_DATA:args:"duration" / 86400 AS days,
TX_SIGNER,
tx_hash
FROM near.core.ez_actions
WHERE action_data:method_name::STRING = 'account_stake_booster'
AND TX_RECEIVER = 'contract.main.burrow.near'
AND tx_succeeded = TRUE
),
tb2 AS (
SELECT
block_timestamp,
PARSE_JSON(SUBSTR(LOGS[0], 12))['data'][0]['total_booster_amount'] / POW(10, 18) AS amount,
tx_hash,
signer_id
FROM near.core.fact_actions_events_function_call
WHERE receiver_id = 'contract.main.burrow.near'
AND METHOD_NAME = 'account_unstake_booster'
),
tb3 as ( SELECT
days,
COUNT(DISTINCT tx_signer) AS stakers,
COUNT(DISTINCT tx_hash) AS stakes,
SUM(amount) AS stake_amount,
avg(amount) as avg_stake_amount
FROM tb1
group by 1)
-- select case when days = '30' then 'a. 1 Month'
-- when days = '60' then 'b. 2 Months'
-- when days = '90' then 'c. 3 Months'