shenronCopy of Repayment rate by whale addresses
Updated 2021-05-03
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 loans_summary AS (
SELECT borrower AS borrower_address
, block_timestamp AS ts
, borrows_contract_symbol AS symbol
, loan_amount_usd AS token_amt
, 'loan' AS event_type
FROM compound.borrows
UNION ALL
SELECT borrower AS borrower_address
, block_timestamp AS ts
, repay_contract_symbol AS symbol
, -repayed_amount_usd AS token_amt
, 'repayment' AS event_type
FROM compound.repayments
UNION ALL
SELECT borrower AS borrower_address
, block_timestamp AS ts
, liquidation_contract_symbol AS symbol
, -liquidation_amount_usd AS token_amt
, 'liquidation' AS event_type
FROM compound.liquidations
)
, whales_aggregation AS (
SELECT SUBSTR(ts,1,10) AS ds
, SUM(CASE WHEN event_type = 'loan' THEN token_amt ELSE 0 END) AS loan_amount
, SUM(CASE WHEN event_type != 'loan' THEN -token_amt ELSE 0 END) AS repayment_amount
Run a query to Download Data