sarathsushi_uni 8
Updated 2022-10-17Copy Reference Fork
999
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 t1 as ( select tx_hash
from optimism.core.fact_event_logs
where event_name = 'Swap')
,
t2 as ( select
date(block_timestamp) as date,
tx_hash,
ORIGIN_FROM_ADDRESS,
ORIGIN_TO_ADDRESS,
contract_address as swap_from,
raw_amount as swap_from_volume
from optimism.core.fact_token_transfers
where ORIGIN_FROM_ADDRESS = FROM_ADDRESS and tx_hash in ( select tx_hash from t1)),
t3 as ( select
date(block_timestamp) as date,
tx_hash,
ORIGIN_FROM_ADDRESS,
ORIGIN_TO_ADDRESS,
contract_address as swap_to,
raw_amount as swap_to_volume
from optimism.core.fact_token_transfers
where ORIGIN_FROM_ADDRESS = to_address and tx_hash in ( select tx_hash from t1)),
t4 as ( select
DISTINCT a.tx_hash ,
a.date ,
a.ORIGIN_FROM_ADDRESS as wallet,
'Opti-Uniswap' as platform ,
swap_from,
swap_to,
swap_from_volume,
swap_to_volume
from t2 a left outer join t3 b on a.tx_hash = b.tx_hash and a.date = b.date
where a.origin_to_address in (select address
Run a query to Download Data