Moetp pair
    Updated 2024-04-24
    -- forked from PEPE pair @ https://flipsidecrypto.xyz/edit/queries/8a8ff102-4c42-4502-b932-39d2c8cfca5a

    with price as (
    select
    HOUR :: Date as day,
    avg(PRICE) as price,
    token_address
    from
    ethereum.price.ez_hourly_token_prices
    group by
    1,
    token_address
    ),
    mid as (
    select
    a.*,
    case
    when amount_in_usd is null then amount_in * b.price
    else amount_in_usd
    end as sell_usd,
    case
    when amount_out_usd is null then amount_out * c.price
    else amount_out_usd
    end as buy_usd
    from
    ethereum.defi.ez_dex_swaps a
    left outer join price b on a.BLOCK_TIMESTAMP :: date = b.day
    and a.token_in = b.token_address
    left outer join price c on a.BLOCK_TIMESTAMP :: date = c.day
    and a.token_out = c.token_address
    where
    amount_out_usd is not null
    and amount_out_usd > 0
    and amount_in_usd is not null
    and amount_in_usd > 0
    ),
    QueryRunArchived: QueryRun has been archived