Updated 2022-12-07
    with a as

    (

    with base as (
    select block_timestamp,
    'Sushiswap' as platform ,
    tx_hash ,
    origin_from_address swapper,
    (amount_in_usd) as AMOUNT_IN_USD
    from optimism.sushi.ez_swaps
    where block_timestamp >= '2022-01-01'
    -- and token_in = '0x4200000000000000000000000000000000000042' or token_out = '0x4200000000000000000000000000000000000042'

    union all

    select block_timestamp,
    'Uniswap' as platform,
    a.tx_hash,
    a.origin_from_address swapper,
    ((c.price * b.raw_amount)/pow(10, c.decimals)) as AMOUNT_IN_USD
    from optimism.core.fact_event_logs a
    join optimism.core.fact_token_transfers b using(tx_hash)
    join optimism.core.fact_hourly_token_prices c on c.token_address = b.contract_address and date_trunc('hour', b.block_timestamp) = c.hour
    where a.event_name = 'Swap'
    and a.origin_to_address in ('0x68b3465833fb72a70ecdf485e0e4c7bd8665fc45','0xe592427a0aece92de3edee1f18e0157c05861564')
    and a.tx_status ='SUCCESS' and a.block_timestamp >= '2022-01-01' --and token_address = '0x4200000000000000000000000000000000000042'
    union all

    select
    block_timestamp,
    'Velodrome' as platform,
    tx_hash,
    Run a query to Download Data