CryptoIcicleUntitled Query
Updated 2022-08-03
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 contracts as (
(select * from optimism.core.dim_contracts)
union ( select
'0x1318811b1c6aed9c48623adb1ee22f81c6c6f876' as address,
'DC Token' as symbol,
'0' as decimals
)
union ( select
'0xe649951f6e18492fca574d6113bbf446269312ee' as address,
'US Token' as symbol,
'0' as decimals
)
),
token_price as (
select
date_trunc('day', hour) as date,
token_address,
symbol,
decimals,
avg(price) as price
from optimism.core.fact_hourly_token_prices
where 1 = 1 and hour >= CURRENT_DATE - {{n_days}}
group by date, symbol, decimals, token_address
),
txns_base as (
select
rank() over (partition by e1.tx_hash order by e1.event_index desc ) as rank,
e1.*
from optimism.core.fact_event_logs e1
where 1=1
and (
e1.origin_to_address = lower('0xE592427A0AEce92De3Edee1F18E0157C05861564') -- Uniswap V3: Router
or e1.origin_to_address = lower('0x68b3465833fb72A70ecDF485E0e4C7bD8665Fc45') -- Uniswap V3: Router 2
)
and e1.event_name = 'Swap'
and e1.block_timestamp >= CURRENT_DATE - {{n_days}}
Run a query to Download Data