Afonso_Diaz2023-05-11 03:06 PM
Updated 2023-05-11
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 t0 as (
select
hour::date as date,
symbol,
token_address,
avg(price) as price_usd
from optimism.core.fact_hourly_token_prices
group by 1, 2, 3
),
t as (
select
origin_from_address,
min(block_timestamp)::date as min_date
from optimism.core.ez_dex_swaps
where platform like 'uniswap%'
group by 1
),
t2 as (
select
date_trunc('month', min_date)::date as month,
count(distinct origin_from_address) as new_users
from t
where min_date > current_date - interval '12 months'
group by 1
),
t3 as (
select
date_trunc('month', block_timestamp)::date as month,
count(distinct tx_hash) as swaps,
count(distinct origin_from_address) as users,
sum(iff(amount_in_usd is not null, amount_in_usd, nvl(amount_in * price_usd, 0))) as volume_usd,
avg(iff(amount_in_usd is not null, amount_in_usd, nvl(amount_in * price_usd, 0))) as average_volume_usd
from optimism.core.ez_dex_swaps
Run a query to Download Data