Nige7777comp work
Updated 2021-08-19
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
›
⌄
with cte_borrow as (
SELECT
--date_trunc('day', block_timestamp) as date,
borrower as UserAdd,
borrows_contract_symbol AS underlying_symbol,
sum(loan_amount) AS token_amount,
sum(loan_amount_usd) AS amount_in_usd,
sum(sum(loan_amount_usd)) OVER (PARTITION BY borrower ORDER BY borrower ) as Total,
'Borrow' as UserAction
FROM compound.borrows
WHERE block_timestamp >= CURRENT_DATE -30
GROUP BY UserAdd,
borrows_contract_symbol, UserAction
order by Total desc
)
,
cte_lend as (
SELECT
--date_trunc('day', block_timestamp) as date,
supplier as UserAdd ,
supplied_symbol AS underlying_symbol,
sum(supplied_base_asset) AS token_amount,
sum(supplied_base_asset_usd) AS amount_in_usd,
sum(sum(supplied_base_asset_usd)) OVER (PARTITION BY supplier ORDER BY supplier ) as Total,
'Supply' AS UserAction
FROM compound.deposits
WHERE block_timestamp >= CURRENT_DATE -30
GROUP BY UserAdd,
underlying_symbol, UserAction
order by Total desc
)
select * from cte_lend
union all
select * from cte_borrow
Run a query to Download Data