SalehPleasure to Burn-compare
Updated 2022-02-27Copy 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
›
⌄
with Luna_burned as (
select
block_timestamp::date as DAY ,
sum(token_0_amount) as Luna_burned
from terra.swaps
where block_timestamp::date>=CURRENT_DATE-30
and ask_currency = 'UST'
and offer_currency = 'LUNA'
and tx_status = 'SUCCEEDED'
group by 1
order by 1
)
, lst_UST as (
select DATE as day
,sum(BALANCE) as sum_usd
from terra.daily_balances
where BALANCE_TYPE='liquid'
and CURRENCY='UST'
and BALANCE>0
and date>=CURRENT_DATE-30
group by 1
order by 1
)
,lst_all as (
select 'luna' as action,DAY,Luna_burned from Luna_burned
union all select 'ust' as action,day,sum_usd from lst_UST
)
select day
,sum(iff(action='luna',Luna_burned,0)) as sum_Luna_burned
,sum(iff(action='ust',Luna_burned,0)) as sum_ust
from lst_all
group by 1
order by 1
Run a query to Download Data