Afonso_Diaz2023-03-28 03:12 AM
Updated 2023-03-27
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,
token_address,
avg(price) as price_usd
from optimism.core.fact_hourly_token_prices
group by 1, 2, 3
),
t2 as (
select
symbol_in as symbol,
tx_hash,
origin_from_address as swapper,
amount_in * price_usd as amount_usd
from optimism.core.ez_dex_swaps
join t
on date = block_timestamp::date and token_in = token_address
where block_timestamp > current_date - 90
and platform = '{{ platform }}'
union
select
symbol_out as symbol,
tx_hash,
origin_from_address as swapper,
amount_out * price_usd as amount_usd
from optimism.core.ez_dex_swaps
join t
on date = block_timestamp::date and token_out = token_address
where block_timestamp > current_date - 90
and platform = '{{ platform }}'
)
Run a query to Download Data