0xHaM-dBorrowed, Repaid or Liquidated
Updated 2022-09-06
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 borrower as (
SELECT
BLOCK_TIMESTAMP,
'BORROWER' as status,
TX_HASH,
BORROWER,
AMOUNT_LOANED as amount
FROM ethereum.maker.ez_flash_loans
WHERE TX_STATUS = 'SUCCESS'
)
,repay as (
SELECT
a.BLOCK_TIMESTAMP,
'PAYER' as status,
a.TX_HASH,
PAYER,
AMOUNT_PAID as amount
FROM ethereum.maker.ez_repayments a join borrower b on PAYER = BORROWER and a.BLOCK_TIMESTAMP > b.BLOCK_TIMESTAMP
WHERE TX_STATUS = 'SUCCESS'
)
, LIQUIDATED as (
SELECT
a.BLOCK_TIMESTAMP,
'LIQUIDATED WALLET' as status,
a.TX_HASH,
LIQUIDATED_WALLET,
COLLATERAL_BALANCE as amount
FROM ethereum.maker.ez_liquidations a join borrower b on LIQUIDATED_WALLET = BORROWER and a.BLOCK_TIMESTAMP > b.BLOCK_TIMESTAMP
WHERE TX_STATUS = 'SUCCESS'
)
SELECT
date_trunc('{{interval}}', block_timestamp) as date,
status,
COUNT(DISTINCT TX_HASH) as tx_cnt,
COUNT(DISTINCT BORROWER) as user_cnt,
Run a query to Download Data