sarathsushi_uni 8
    Updated 2022-10-17

    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