nitsNET THOR staked
Updated 2022-05-25
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 a AS (
SELECT DISTINCT tx_id
FROM ethereum.events_emitted
WHERE contract_address = LOWER('0xa5f2211B9b8170F694421f2046281775E8468044')
), b AS (
SELECT *
FROM ethereum.events_emitted e
JOIN a ON a.tx_id = e.tx_id
WHERE tx_to_address = LOWER('0x815c23eca83261b6ec689b60cc4a58b54bc24d8d')
AND event_name = 'Deposit'
),
a_ AS (
SELECT DISTINCT tx_id
FROM ethereum.events_emitted
WHERE contract_address = LOWER('0xa5f2211B9b8170F694421f2046281775E8468044')
), b_ AS (
SELECT *
FROM ethereum.events_emitted e
JOIN a_ ON a_.tx_id = e.tx_id
WHERE tx_to_address = LOWER('0x815c23eca83261b6ec689b60cc4a58b54bc24d8d')
AND event_name = 'Withdraw'
),
staked_data as
(SELECT date(block_timestamp) as day, sum(event_inputs:value)/pow(10,18) as amt, count(*) as total_txs, 'staked' as action_type,
sum(total_txs) over (order by day) as cumulative_total_txs,
sum(amt) over (order by day) as cumulative_amt from b
GROUP by 1 ),
unstaked_amt as
(SELECT date(block_timestamp) as day, sum(event_inputs:amount)*(-1)/pow(10,18) as amt, count(*) as total_txs, 'unstaked' as action_type,
sum(total_txs) over (order by day) as cumulative_total_txs,
sum(amt) over (order by day) as cumulative_amt from b_
GROUP by 1)
SELECT day, sum(amt) as net_thor, sum(total_txs) as total_tx, sum(net_thor) over (order by day) as net_thor_staked,
sum(total_tx) over (ORDER by day) as cumulative_tx
from
Run a query to Download Data