cypherETH mainnet vs Optimism
    Updated 2022-06-24
    with optimism_swaps as (
    select *,
    block_timestamp as time,
    tx_hash as hash,
    origin_from_address as from_address,
    event_inputs:amount0 as amount0,
    event_inputs:amount1 as amount1
    from optimism.core.fact_event_logs
    where origin_to_address = lower('0xe592427a0aece92de3edee1f18e0157c05861564')
    and event_name = 'Swap'
    ),

    trace_transactions as (
    select tx_hash, identifier, to_address from optimism.core.fact_traces
    where tx_hash in (select hash from optimism_swaps)
    and (identifier = 'CALL_0_0' or identifier = 'CALL_0_2_0')),

    joined as (select
    s.*,
    (select t.to_address from trace_transactions t, optimism_swaps s where t.identifier = 'CALL_0_0' and s.hash = t.tx_hash) as token1_id,
    (select t.to_address from trace_transactions t, optimism_swaps s where t.identifier = 'CALL_0_2_0' and s.hash = t.tx_hash) as token2_id
    from optimism_swaps s, trace_transactions t
    )

    select * from joined




    -- select * from optimism.core.fact_traces
    -- where block_number = 12915918
    -- and tx_hash = '0x449df8c90ce96fb2435ac9aa425ec1211eded53f0f93b0a0b0eeb69a93f7484f'
    -- and (identifier = 'CALL_0_0' or identifier = 'CALL_0_2_0')
    Run a query to Download Data