kidaUnstakerss By Date
Updated 2022-08-03Copy 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 unstake_amounts AS (
SELECT
c.block_timestamp::date as date,
tx_receiver as governor,
tx_signer as unstaker,
c.tx_hash,
PARSE_JSON(args):amount::int as unstake_amount,
FALSE as is_unstake_all
FROM near.core.fact_actions_events_function_call c
JOIN near.core.fact_transactions t
ON c.tx_hash = t.tx_hash
WHERE method_name = 'unstake' AND TRY_PARSE_JSON(args) is not null AND TRY_CAST(TRY_PARSE_JSON(args):amount::string AS INT) is not null
UNION
SELECT
c.block_timestamp::date as date,
tx_receiver as governor,
tx_signer as unstaker,
c.tx_hash,
REPLACE(REPLACE(REGEXP_SUBSTR(tx::string, 'Total \\d+ unstaked'), 'Total ') , ' unstaked')::int as unstake_amount,
TRUE as is_unstake_all
FROM near.core.fact_actions_events_function_call c
JOIN near.core.fact_transactions t
ON c.tx_hash = t.tx_hash
WHERE method_name = 'unstake_all'
)
SELECT
date,
COUNT(DISTINCT unstaker) as number_of_unstakers,
COUNT_IF(is_unstake_all) as number_of_unstake_alls,
COUNT(DISTINCT tx_hash) as number_of_unstake_txs,
(number_of_unstake_alls / number_of_unstake_txs) * 100 as pct_unstake_all
FROM
unstake_amounts
Run a query to Download Data