John_GaltNebula LBP Buy Vol, Sell Vol, Price
Updated 2022-05-06
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
›
⌄
with table1 as (select
date_trunc('hour', block_timestamp) as date,
event_attributes:ask_asset as ask,
event_attributes:offer_amount / pow(10, 6) as offer,
event_attributes:return_amount / pow(10, 6) as returnn,
case
when ask = 'uusd' then returnn
else 0
end as ust_from_sold_neb,
case
when ask = 'terra1mpq5zkkm39nmjrjg9raknpfrfmcfwv0nh0whvn' then offer
else 0
end as ust_to_buy_neb,
case
when ask = 'terra1mpq5zkkm39nmjrjg9raknpfrfmcfwv0nh0whvn' then returnn
else 0
end as bought_neb,
ust_to_buy_neb / nullif(bought_neb, 0) as neb_price
from terra.msg_events
where date(block_timestamp) > '2022-04-24'
and (event_attributes:ask_asset = 'terra1mpq5zkkm39nmjrjg9raknpfrfmcfwv0nh0whvn' or event_attributes:ask_asset = 'uusd')
and (event_attributes:"0_contract_address" = 'terra152wlyd53nfcltuwcje9ale8qv3hpyna4sv9mvg'
or event_attributes:"1_contract_address" = 'terra152wlyd53nfcltuwcje9ale8qv3hpyna4sv9mvg')
and event_index = 3
),
table2 as (select date, sum(ust_from_sold_neb) as sell, sum(ust_to_buy_neb) as buy, avg(neb_price) as neb_price
from table1
group by date
order by date
)
select * from table2
Run a query to Download Data