Moe6* gran bor
Updated 2023-03-07Copy Reference Fork
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 prices as (
select
hour::date as days,
SYMBOL,token_ADDRESS,DECIMALS,
avg(PRICE) as price
from
optimism.core.fact_hourly_token_prices
group by 1,2,3,4
)
,base as (select
SYMBOL,price*RAW_AMOUNT/pow(10,decimals) as usd_amount,x.*
from
optimism.core.fact_token_transfers x
join prices y on x.CONTRACT_ADDRESS=y.token_ADDRESS
where
ORIGIN_TO_ADDRESS = '0x8fd4af47e4e63d1d2d45582c3286b4bd9bb95dfe'
and ORIGIN_FUNCTION_SIGNATURE='0xa415bcad' -- 'Borrow'
)
select
count(distinct tx_hash) as txs_count,
count(distinct origin_from_address) as users,
avg(USD_AMOUNT) as avg_USD_AMOUNT,
median(USD_AMOUNT) as median_USD_AMOUNT,
sum(USD_AMOUNT) as tot_USD_AMOUNT,
tot_USD_AMOUNT/users as amount_p_user,
txs_count/users as txs_count_p_user,
tot_USD_AMOUNT/{{days_back}} as usd_p_day,
users/{{days_back}} as users_p_day,
txs_count/{{days_back}} as txs_count_p_day
Run a query to Download Data