kidaNear Governance Compiled
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 stake_amounts AS (
SELECT
c.block_timestamp::date as date,
tx_receiver as governor,
tx_signer as staker,
c.tx_hash,
tx:actions[0]:FunctionCall:deposit::int as stake_amount
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 = 'deposit_and_stake' AND NOT CONTAINS(tx::string, 'Smart contract panicked')
),
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 AND NOT CONTAINS(tx::string, 'Smart contract panicked')
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
Run a query to Download Data