John_Galtedge stuff - pluna
Updated 2022-07-07
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 table1 as (select
date_trunc('hour', block_timestamp) as day_hour,
sum(event_attributes:"0_amount") / pow(10, 6) as deposit_amount
from terra.msg_events
where date(block_timestamp) > '2022-02-01'
and event_attributes:"0_contract_address" = 'terra1pcxwtrxppj9xj7pq3k95wm2zztfr9kwfkcgq0w' ---genesis pool
and event_attributes:"2_contract_address" = 'terra1e4hwdnvxxrwg2lpt9hg3a97q3hc2nrgl4y044y' ----epluna
and event_attributes:"0_action" = 'deposit'
and event_index = 3
group by day_hour
),
table2 as (select
date_trunc('hour', block_timestamp) as day_hour, ----this is messed up. these are withdraws when people are borrowing, not taking off the platform
sum(event_attributes:"0_amount") / pow(10, 6) as withdraw_amount
from terra.msg_events
where date(block_timestamp) > '2022-02-01'
and event_attributes:"0_contract_address" = 'terra1pcxwtrxppj9xj7pq3k95wm2zztfr9kwfkcgq0w' ---genesis pool
and event_attributes:etoken = 'terra1e4hwdnvxxrwg2lpt9hg3a97q3hc2nrgl4y044y' ----epluna contract
and event_attributes:"0_action" = 'withdraw'
and event_index = 3
group by day_hour
),
table3 as (select distinct
date_trunc('hour', block_timestamp) as day_hour
from terra.msg_events
where day_hour > '2022-03-28 15:00:00.000'
),
lent_final as (select table3.day_hour as day_hour, table1.deposit_amount as deposit, table2.withdraw_amount as withdraw,
coalesce(deposit, 0) - coalesce(withdraw, 0) as net_daily_deposit,
sum(net_daily_deposit) over (order by table3.day_hour) as total_lent
from table3
left outer join table1 on table3.day_hour = table1.day_hour
left outer join table2 on table3.day_hour = table2.day_hour
Run a query to Download Data