Moe0* sh vs un
    Updated 2022-10-16
    (with tb1 as (select
    *
    from polygon.core.fact_token_transfers
    where
    ORIGIN_TO_ADDRESS='0xe592427a0aece92de3edee1f18e0157c05861564'
    OR
    ORIGIN_TO_ADDRESS ilike'0x68b3465833fb72A70ecDF485E0e4C7bD8665Fc45'

    ),

    prices as (select
    HOUR::date as days,
    TOKEN_ADDRESS,
    avg(price) as price,
    decimals
    from optimism.core.fact_hourly_token_prices
    group by 1,2,4
    ),

    tb2 as (select
    BLOCK_TIMESTAMP,TX_HASH,ORIGIN_FROM_ADDRESS,ORIGIN_TO_ADDRESS,CONTRACT_ADDRESS,SYMBOL as token1,
    FROM_ADDRESS,TO_ADDRESS,RAW_AMOUNT
    from tb1 x
    join optimism.core.dim_contracts y on x.CONTRACT_ADDRESS=y.ADDRESS
    where ORIGIN_FROM_ADDRESS=FROM_ADDRESS
    ),


    tot as (select
    *,RAW_AMOUNT/pow(10,decimals) as usd_amount
    from
    tb2 s , prices p where s.block_timestamp::date = p.days and CONTRACT_ADDRESS = TOKEN_ADDRESS


    Run a query to Download Data