boomer77mars borrow
Updated 2022-04-05
99
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
›
⌄
with borrow as (select date_trunc('day', block_timestamp) as dt, count (distinct msg_value:sender::string) as sender, msg_value:execute_msg:borrow:asset:native:denom::string as denom,
sum(msg_value:execute_msg:borrow:amount/1e6) as amount, 'BORROW' as act
from terra.msgs
where msg_value:contract::string = 'terra19dtgj9j5j7kyf3pmejqv8vzfpxtejaypgzkz5u' and msg_value:execute_msg:borrow::string is not null
group by 1,3),
price as (select date_trunc('day', block_timestamp) as dt, currency, avg(price_usd) as price
from terra.oracle_prices
where year(block_timestamp) = '2022'
group by 1,2),
lastt as (select * from borrow)
select a.dt, a.sender, a.denom, a.amount, a.act, b.price, (a.amount*b.price) as volume_usd
from lastt a
left join price b on a.dt = b.dt and a.denom = b.currency
Run a query to Download Data