messaritesting - luna rewards(05-04-22)
Updated 2022-05-04
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
›
⌄
-- Tarik - query from by 0xFrank https://app.flipsidecrypto.com/dashboard/terra-reward-analysis-pKMRCm
select
date_trunc('hour', t.block_timestamp) as date,
sum(fl.value:amount / pow(10,6)) as event_amount,
fl.value:denom::string as event_currency
-- event_attributes:validator::string as validator
from terra.transitions t
, lateral flatten(input => event_attributes:amount) fl
where t.transition_type = 'begin_block'
and t.event = 'rewards'
group by 1,3
order by date desc
limit 20
--------------------
-- Part 2
-- issue: before oct 30 the event attributes only have luna, and after 10/30 they have various currencies
-- it seems like each event attribute post 10/30
SELECT * FROM terra.transitions
where transition_type = 'end_block'
and event = 'rewards'
and chain_id = 'columbus-5'
AND block_timestamp > CURRENT_DATE - 150
limit 50
----------------------------------------------------
-- Final query:
with prices as (
select date_trunc('hour', block_timestamp) as date,
symbol,
currency,
avg(price_usd) as price
from terra.oracle_prices
group by 1,2,3
),
Run a query to Download Data