scottincryptoFrequency of Compound Flash Loans
Updated 2021-06-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 borrow_query as (
SELECT
block_id,
block_timestamp,
borrower,
ctoken_symbol,
borrows_contract_symbol,
loan_amount_usd,
tx_id
from compound.borrows
where block_timestamp > getdate() - interval'3 month'
),
repay_query as(
select
block_id,
borrower,
payer,
ctoken_symbol,
repay_contract_symbol,
repayed_amount_usd
from compound.repayments
where block_timestamp > getdate() - interval'3 month'
),
flashloan_query as(
SELECT
date_trunc('day', b.block_timestamp) as date,
count(b.tx_id) as flashloan_count,
sum(b.loan_amount_usd) as flashloan_value,
avg(b.loan_amount_usd) as flashloan_av_value
from borrow_query b inner join repay_query r on (b.block_id = r.block_id and b.borrower = r.borrower)
group by 1
),
std_loan_query as(
Run a query to Download Data