boomer77luart luna vs ust currency
Updated 2022-02-14
99
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
›
⌄
with luart as (select block_timestamp, tx_id, event_attributes:nft_contract_address::string as NFTs, event_attributes:"1_token_id" as NFT_ID,
event_attributes:price/1e6 as Price,
event_attributes:denom::string as currency, case
when currency = 'uluna' then 'LUNA'
when currency = 'uusd' then 'UST'
else null end as currencies
from terra.msg_events
where event_type = 'wasm' and event_attributes:"1_sender"::string = 'terra1fj44gmt0rtphu623zxge7u3t85qy0jg6p5ucnk' and tx_status = 'SUCCEEDED'
and event_attributes:method::string = 'execute_order'),
luna_p as (select date_trunc('day', block_timestamp) as dt, symbol, avg(price_usd) as price
from terra.oracle_prices
where symbol in ('LUNA', 'UST')
group by 1,2),
sales as (select date_trunc('day', block_timestamp) as dt, currencies, count(distinct tx_id) as tx_count, sum(price) as vol
from luart
group by 1,2)
select a.dt, a.currencies, a.tx_count, a.vol, b.price, (a.vol*b.price) as "Volume in USD"
from sales a
left join luna_p b on a.dt = b.dt and a.currencies = b.symbol
Run a query to Download Data