MLDZMNebr1
Updated 2023-05-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
›
⌄
-- forked from br2 @ https://flipsidecrypto.xyz/edit/queries/e072e453-67fd-4afc-954e-30362e05147a
with t1 as ( select
hour::date as day,
avg(price) as avg_price
from ethereum.core.fact_hourly_token_prices
where symbol = 'WETH'
group by 1)
select
count(distinct s.ORIGIN_FROM_ADDRESS) as borrowers,
count(distinct a.tx_hash) as no_borrow,
sum(tx_fee) as paid_fee,
sum(tx_fee*avg_price) as paid_fee_usd,
sum(ETH_VALUE*avg_price) as volume_usd,
avg(ETH_VALUE*avg_price) as avg_volume_usd,
sum(ethereum.public.udf_hex_to_int(substring(INPUT_DATA, 188, 15))::float/1e18) as volume_borrow,
sum((ethereum.public.udf_hex_to_int(substring(INPUT_DATA, 188, 15))::float/1e18)*avg_price) as volume_borrow_usd,
avg((ethereum.public.udf_hex_to_int(substring(INPUT_DATA, 188, 15))::float/1e18)*avg_price) as avg_borrow_usd,
volume_usd/borrowers as avg_borrow_user
from ethereum.core.fact_event_logs s
left join ethereum.core.fact_transactions a on s.tx_hash=a.tx_hash
left join t1 on s.block_timestamp::date=t1.day
where s.CONTRACT_ADDRESS=lower('0xfb3330531E3f98671296f905cd82CC407d90CE97')
and s.ORIGIN_FUNCTION_SIGNATURE='0xfbf37739'
Run a query to Download Data