theericstoneaUST / UST Over Time
Updated 2022-06-04
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
›
⌄
--this uses the deposits and withdrawals of aUST from the Anchor Earn product
--to derive the effective exchange rate between aUST and UST over time
with ust_aust_desposit_data as (
SELECT
block_id,
sum(m.event_attributes:deposit_amount) as deposit_amount_uust,
sum(m.event_attributes:mint_amount) as mint_amount_uaust
FROM terra.msg_events m
WHERE m.event_attributes:deposit_amount is not null
AND m.event_attributes:mint_amount is not null
AND m.tx_status = 'SUCCEEDED'
group by 1
order by 1),
ust_aust_redemption_data as (
SELECT
block_id,
block_timestamp,
sum(m.event_attributes:redeem_amount) as redemption_amount_uust,
sum(m.event_attributes:burn_amount) as burn_amount_uaust
FROM terra.msg_events m
WHERE m.event_attributes:redeem_amount is not null
AND m.event_attributes:burn_amount is not null
AND tx_status = 'SUCCEEDED'
group by 1,2
order by 1
),
aust_deposit_value as (
SELECT
d.block_id,
d.deposit_amount_uust / d.mint_amount_uaust as aust_value
FROM ust_aust_desposit_data d
),
aust_redemption_value as (
SELECT
r.block_timestamp,
Run a query to Download Data