wanlinUST On Chain Swaps [2] copy
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
›
⌄
-- forked from forgash / UST On Chain Swaps [2] @ https://flipsidecrypto.xyz/forgash/q/untitled-query-6zsD_b
with
ust_ask as (
select
block_timestamp,
offer_amount,
offer_currency,
token_1_amount, -- token 1 is ask
(token_0_amount * price0_usd) / token_1_amount as ust_p,
token_0_amount, -- token 0 is offer
price0_usd,
price1_usd as ust_oracle
from terra.swaps
where ask_currency = 'UST'
and price0_usd is not null
and offer_currency = 'LUNA'
),
ask_agg as (
select
-- time_slice(block_timestamp, 10, 'minute') as _date,
date_trunc('m', block_timestamp) as _date,
avg(ust_p) as ust_ask_swap_price,
avg(ust_oracle) as avg_ust_oracle
from ust_ask
where block_timestamp >= '2022-05-07'
group by 1
),
ust_offer as (
select
block_timestamp,
ask_currency,
token_1_amount, -- token 1 is ask
Run a query to Download Data