boomer77deposit n borrow anc
Updated 2021-11-24
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
›
⌄
with genesis as
(select distinct tx_id, *
from terra.msgs
where msg_module = 'wasm'
and msg_value:contract = 'terra1sepfj7s0aeg5967uxnfk4thzlerrsktkpelm5s'),
deposit as
(select msg_value:execute_msg::string as deposit,
sum(msg_value:coins[0]:amount/1e6) as amount_depo,
date_trunc('day', block_timestamp) as day1
from genesis
where msg_value:coins[0]:denom = 'uusd'
and deposit like '%deposit%'
and tx_status = 'SUCCEEDED' and block_timestamp >= CURRENT_DATE - 89
group by 1,3),
borrow as
(select 'borrow' as borrow,
sum(msg_value:execute_msg:borrow_stable:borrow_amount/1e6) as amount_bor,
date_trunc('day', block_timestamp) as day3
from genesis
where borrow like '%borrow%'
and tx_status = 'SUCCEEDED'
and msg_value like '%borrow%' and block_timestamp >= CURRENT_DATE - 89
group by 1,3)
select a.day1, a.amount_depo, sum(a.amount_depo) OVER(order by a.day1 asc ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) as Deposits,
b.amount_bor, sum(b.amount_bor) OVER(order by a.day1 asc ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) as Borrows
from deposit a
join borrow b on a.day1 = b.day3
Run a query to Download Data