shenronpct borrowed over time
Updated 2021-11-11
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 deposits AS (
SELECT SUBSTR(block_timestamp,1,10) AS ds
, supplier
, SUM(supplied_base_asset_usd) AS deposits
FROM compound.deposits
GROUP BY 1,2
HAVING SUM(supplied_base_asset_usd) > 0
)
, borrows AS (
SELECT SUBSTR(block_timestamp,1,10) AS ds
, borrower
, SUM(loan_amount_usd) AS loans
FROM compound.borrows
GROUP BY 1,2
)
, cumsum AS (
SELECT d.ds
, supplier
, SUM(deposits) OVER (partition by supplier order by d.ds rows between unbounded preceding and current row) AS deposits
, SUM(loans) OVER (partition by supplier order by d.ds rows between unbounded preceding and current row) AS loans
FROM deposits d FULL OUTER JOIN borrows b ON d.supplier = b.borrower AND d.ds = b.ds
)
, ratio as (SELECT ds
, supplier
Run a query to Download Data