MasiUntitled Query
Updated 2022-08-04Copy Reference Fork
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 swap_tx as ( select tx_hash
from optimism.core.fact_event_logs
where event_name = 'Swap')
,
from_token as ( select
trunc(block_timestamp,'day') as day,
tx_hash,
ORIGIN_FROM_ADDRESS,
ORIGIN_TO_ADDRESS,
contract_address,
raw_amount
from optimism.core.fact_token_transfers
where tx_hash in ( select tx_hash from swap_tx) and ORIGIN_FROM_ADDRESS = FROM_ADDRESS)
,
to_token as ( select
trunc(block_timestamp,'day') as day,
tx_hash,
ORIGIN_FROM_ADDRESS,
ORIGIN_TO_ADDRESS,
contract_address,
raw_amount
from optimism.core.fact_token_transfers
where tx_hash in ( select tx_hash from swap_tx) and ORIGIN_FROM_ADDRESS = to_address)
,
labels_in as ( select
'IN' as status,
day,
tx_hash,
ORIGIN_FROM_ADDRESS,
ORIGIN_TO_ADDRESS,
symbol as token_in,
raw_amount
from from_token a join optimism.core.dim_contracts b on a.contract_address = b.address)
,
label_out as ( select
'out' as status,
Run a query to Download Data