Afonso_Diaz2023-08-25 08:15 PM
Updated 2023-08-25
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
pricet as (
select
hour::date as date,
token_address,
avg(price) as usdprice
from ethereum.core.fact_hourly_token_prices
group by 1,2
)
,
main as (
select
tX_hash,
block_timestamp,
symbol,
amount_loaned*usdprice as usd_amount,
borrower as user,
lender
from ethereum.maker.ez_flash_loans
join pricet on trunc(block_timestamp,'day')=pricet.date and token_loaned=token_address
where TX_STATUS = 'SUCCESS'
),
total as (
select
date_trunc('month', block_timestamp) as month,
count(distinct tx_hash) as txns,
sum(usd_amount) as volume_usd,
avg(usd_amount) as average_usd_amount,
median(usd_amount) as median_usd_amount,
count(distinct user) as users
from main
group by 1
)
Run a query to Download Data