Afonso_Diaz2023-09-25 09:51 PM
Updated 2023-09-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
t as (
select
hour::date as date,
symbol,
avg(price) as price_usd
from ethereum.price.ez_hourly_token_prices
where symbol in ('SOL', 'WETH')
group by 1, 2
),
t3 as (
select
tx_hash,
block_timestamp,
origin_from_address as user,
iff(token_in = '0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48', amount_in, amount_out) as amount_usd,
tx_fee * price_usd as tx_fee_usd
from ethereum.defi.ez_dex_swaps
join ethereum.core.fact_transactions
using(tx_hash)
join t on date = block_timestamp::date and t.symbol = 'WETH'
where '0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48' in (token_in, token_out)
and block_timestamp::date >= current_date - interval '{{ days }} days'
)
select
count(distinct tx_hash) as swaps,
count(distinct user) as users,
sum(amount_usd) as volume_usd,
avg(amount_usd) as average_volume_usd,
median(amount_usd) as median_volume_usd,
sum(tx_fee_usd) as total_fee_usd,
avg(tx_fee_usd) as average_fee_usd,
median(tx_fee_usd) as median_fee_usd
Run a query to Download Data