binhachonUntitled Query
Updated 2022-03-20
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
›
⌄
with yield_reserve_balance as (
select
date,
balance
from terra.daily_balances
where address = 'terra1tmnqgvg567ypvsvk6rwsga3srp7e3lg6u0elp8'
and currency = 'UST'
),
date_list as (
select
date_trunc('month', date) as time,
max(date) as max_date,
min(date) as min_date
from yield_reserve_balance
group by time
),
yield_reserve_inflow as (
select
date_trunc('month', block_timestamp) as block_timestamp,
amount as inflow
from terra.transfer_events
where recipient = 'terra1tmnqgvg567ypvsvk6rwsga3srp7e3lg6u0elp8'
and sender in ('terra13h0qevzm8r5q0yknaamlq6m3k8kuluce7yf5lj', 'terra1dp0taj85ruc299rkdvzp4z5pfg6z6swaed74e6')
),
yield_reserve_changes as (
select
time,
max.balance - min.balance - coalesce(inflow, 0) as monthly_change,
monthly_change / min.balance * 100 as percent_change,
3 as threshold,
1.5 as range,
case
when percent_change <= - threshold - range then -range
when - threshold - range < percent_change <= - threshold then percent_change + threshold
when threshold < percent_change < threshold + range then percent_change - threshold
when percent_change > threshold + range then range
Run a query to Download Data