MasiUntitled Query
    Updated 2022-08-04
    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