Owentell2. Visualize governance staking of $MINE over time(2)
Updated 2021-11-12Copy 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
›
⌄
WITH amount_staked AS (SELECT DATE_TRUNC('day',block_timestamp) as day,
SUM((CASE
WHEN action = 'delegate' THEN
event_amount
ELSE
0
END)) as amount_staked,
SUM((CASE
WHEN action = 'undelegate'
THEN
event_amount
ELSE
0
END)) as amount_unstaked
FROM terra.staking
GROUP BY day),
luna_price AS (SELECT DATE_TRUNC('DAY', block_timestamp) as day, AVG(price_usd) as luna_price_usd
FROM terra.oracle_prices
WHERE symbol = 'LUNA'
GROUP BY day)
SELECT amount_staked.day, amount_staked - amount_unstaked as amount_staked_unstaked, luna_price_usd
FROM amount_staked INNER JOIN luna_price ON amount_staked.day = luna_price.day
Run a query to Download Data