Updated 2022-08-21
    With T1 as (select --deposit
    block_timestamp,
    tx_hash,
    origin_from_address,
    contract_address,
    raw_amount,
    symbol,
    decimals,
    raw_amount / POW(10, decimals) as adjusted_amount
    from optimism.core.fact_token_transfers
    left join optimism.core.dim_contracts ON address = contract_address
    where
    origin_to_address = '0x170a5714112daeff20e798b6e92e25b86ea603c1' AND
    origin_from_address = from_address AND
    origin_to_address = to_address AND
    block_timestamp::date >= CURRENT_DATE - 14
    having symbol is not null --eliminate tx that receiving token from overmarket address '0x170a5714112daeff20e798b6e92e25b86ea603c1'
    --tx_hash = '0x2072d57af9eb255993f0307d9713a2518ba7686cee15a47d6af1ba07031fa865' buy transaction
    --tx_hash = '0x8b161de5b1324512f3530a33226fd71c0f74b042390175c07114d32a3a64eb4f' sale transaction

    UNION ALL

    select --payout
    block_timestamp,
    tx_hash,
    origin_from_address,
    contract_address,
    raw_amount,
    symbol,
    decimals,
    raw_amount / POW(10, decimals) as adjusted_amount
    from optimism.core.fact_token_transfers
    left join optimism.core.dim_contracts ON address = contract_address
    where
    origin_from_address = '0x170a5714112daeff20e798b6e92e25b86ea603c1' AND
    origin_from_address = from_address AND