Afonso_Diaz2023-03-28 03:12 AM
    Updated 2023-03-27
    with t as (
    select
    hour::date as date,
    symbol,
    token_address,
    avg(price) as price_usd
    from optimism.core.fact_hourly_token_prices
    group by 1, 2, 3
    ),

    t2 as (
    select
    symbol_in as symbol,
    tx_hash,
    origin_from_address as swapper,
    amount_in * price_usd as amount_usd
    from optimism.core.ez_dex_swaps
    join t
    on date = block_timestamp::date and token_in = token_address
    where block_timestamp > current_date - 90
    and platform = '{{ platform }}'

    union


    select
    symbol_out as symbol,
    tx_hash,
    origin_from_address as swapper,
    amount_out * price_usd as amount_usd
    from optimism.core.ez_dex_swaps
    join t
    on date = block_timestamp::date and token_out = token_address
    where block_timestamp > current_date - 90
    and platform = '{{ platform }}'
    )
    Run a query to Download Data