walemathsTokens: Weekly Bias
    Updated 2024-08-07
    -- forked from Masi / Weekly @ https://flipsidecrypto.xyz/Masi/q/iFw2K3bOVDdS/weekly

    with tb1 as ( select trunc(block_timestamp,'hour') as hourly,
    platform,
    tx_hash,
    trader,
    amount_in_usd,
    amount_out_usd,
    SYMBOL_OUT,
    amount_in,
    amount_out,
    symbol_in,
    TOKEN_OUT_CONTRACT,
    TOKEN_IN_CONTRACT,
    case when amount_in_usd is null then amount_out_usd else amount_in_usd end as vol
    from near.defi.ez_dex_swaps
    where block_timestamp::date >= '2023-01-01'
    )
    ,
    tb2 as ( select hour,
    token_address,
    symbol,
    avg(price) as avg_price
    from crosschain.price.ez_prices_hourly
    where blockchain = 'near'
    group by 1,2,3
    UNION
    select HOUR,
    'wrap.near' as token_address,
    'wNEAR' as symbol,
    avg(price) as avg_price
    from near.price.ez_prices_hourly
    where symbol = 'WNEAR'
    group by 1,2,3 )
    ,
    tb3 as ( select hourly::date as date,
    QueryRunArchived: QueryRun has been archived