sepehrmhz8Untitled Query
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
›
⌄
WITH lendings as (
select
date(block_timestamp) as date,
count(distinct ORIGIN_FROM_ADDRESS) as lenders,
case when sum(amount) is null then 0 else sum(AMOUNT_USD) end as volume_lending
from ethereum.sushi.ez_lending
where ethereum.sushi.ez_lending.action = 'Deposit'
group by 1
),
borrowings as (
select
date(block_timestamp) as date,
count(distinct ORIGIN_FROM_ADDRESS) as borrowers,
sum(AMOUNT_USD) as volume_borrowing
from ethereum.sushi.ez_borrowing
where ethereum.sushi.ez_borrowing.action = 'Borrow'
group by 1
)
SELECT
ln.date,
lenders,
borrowers,
lenders + borrowers as lendander_brrowers,
volume_lending,
volume_borrowing,
volume_lending + volume_borrowing as avg_volume_both
from borrowings bw
left join lendings ln on bw.date = ln.date
order by 1 asc