mehdimarjanUntitled Query
Updated 2022-07-17Copy Reference Fork
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 lending as (
select
symbol,
coalesce(sum(AMOUNT_USD),0) as LogAddAsset
from ethereum.sushi.ez_lending
where
LENDING_POOL like '%km%'
-- and LENDING_POOL like '%/%-%'
-- and symbol in ('USDC','USDT','UST','DAI')
and action = 'Deposit'
group by symbol
),
unlending as (
select
symbol,
coalesce(sum(AMOUNT_USD),0) as LogRemoveAsset
from ethereum.sushi.ez_lending
where
LENDING_POOL like '%km%'
-- and LENDING_POOL like '%/%-%'
-- and symbol in ('USDC','USDT','UST','DAI')
and action = 'Withdraw'
group by symbol
)
select
tbl1.symbol,
ifnull(LogAddAsset, 0) as LogAddAsset,
ifnull(LogRemoveAsset, 0) as LogRemoveAsset,
LogAddAsset - LogRemoveAsset as TVL
from lending tbl1
left join unlending tbl2
on tbl1.symbol = tbl2.symbol
order by 4 desc
Run a query to Download Data