shreexoooo
    Updated 2022-12-21
    with s1 as (select
    date_trunc('day',block_timestamp) as date,
    sum(amount_in) as volume
    from near.core.ez_dex_swaps where token_in_contract='token.sweat'
    GROUP BY date
    ORDER BY date
    )
    ,
    s2 as (
    select
    date_trunc('day',block_timestamp) as date,
    sum(amount_out) as volume
    from near.core.ez_dex_swaps where token_out_contract='token.sweat'
    GROUP BY date
    ORDER BY date
    ),
    prices as (
    select
    hour::date as day,
    avg(price) as price
    from ethereum.core.fact_hourly_token_prices where token_address='0xb4b9dc1c77bdbb135ea907fd5a08094d98883a35'
    GROUP BY day
    )
    select
    s1.date,
    s1.volume+s2.volume as total_swap_volume,
    total_swap_volume*price as volume_usd,
    s1.volume as swap_in,
    s2.volume as swap_out,
    price
    from s1 left join s2 on s1.date=s2.date left join prices on s1.date=day
    where s1.date >= current_date - 30
    order by s1.date

    Run a query to Download Data