MLDZMNdux8
    Updated 2022-10-26
    with tb1 as (select
    *
    from optimism.core.fact_token_transfers
    where ORIGIN_TO_ADDRESS='0x7af14adc8aea70f063c7ea3b2c1ad0d7a59c4bff' and ORIGIN_FUNCTION_SIGNATURE='0xf10f1f58'
    -- and ADDRESS_NAME='rubicon: rubicon router'
    ),

    tb2 as (select
    tx_hash,
    BLOCK_TIMESTAMP,
    y.SYMBOL as token_from,
    RAW_AMOUNT/pow(10,y.DECIMALS) as amount_from,
    amount_from*price as usd_from
    from tb1 x
    join optimism.core.dim_contracts y on x.CONTRACT_ADDRESS=y.ADDRESS
    left join optimism.core.fact_hourly_token_prices b on y.symbol=b.symbol and x.BLOCK_TIMESTAMP::date=b.HOUR
    where ORIGIN_FROM_ADDRESS=FROM_ADDRESS),

    tb3 as (select
    tx_hash,
    BLOCK_TIMESTAMP,
    ORIGIN_FROM_ADDRESS,
    y.SYMBOL as token_to,
    RAW_AMOUNT/pow(10,y.DECIMALS) as amount_to,
    amount_to*price as usd_to
    from tb1 x
    join optimism.core.dim_contracts y on x.CONTRACT_ADDRESS=y.ADDRESS
    left join optimism.core.fact_hourly_token_prices b on y.symbol=b.symbol and x.BLOCK_TIMESTAMP::date=b.HOUR
    where ORIGIN_FROM_ADDRESS=TO_ADDRESS
    ),

    ez_swaps_Rubicon as (select
    tb3.BLOCK_TIMESTAMP,
    tb3.ORIGIN_FROM_ADDRESS,
    tb3.tx_hash,
    Run a query to Download Data