forgashUST On-chain Peg from Swaps [1]
Updated 2023-04-13
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
›
⌄
with ust_swaps as (
select
block_id,
case
when token_0_currency = 'UST' then price0_usd
else price1_usd
end as ust_price
from terra.classic.ez_swaps
where ask_currency = 'UST' or offer_currency = 'UST'
-- and block_timestamp > current_date - 3
and block_id >= 7536784 -- first block on 5/7
and price0_usd is not null
and price1_usd is not null
)
select
floor(block_id, -3) as block_group,
avg(ust_price) as avg_peg
from ust_swaps
where block_id >= 7536784 -- first block on 5/7 UTC
-- and block_id <= 7562591 -- last block on 5/8 UTC
and block_id <= 7700000
group by 1
order by 1
Run a query to Download Data