Updated 2023-06-16
    SELECT
    time_slice(block_timestamp, 15, 'MINUTE') as time,
    count(distinct(tx_hash)) as n_swaps,
    avg(price_per_weth) as twap_eth from (
    select
    block_timestamp, tx_hash,
    case when token_out = lower('{{token}}')
    then amount_in / amount_out
    else amount_out / amount_in end as price_per_weth
    from
    ethereum.core.ez_dex_swaps swaps
    where (
    swaps.token_in = lower('{{token}}')
    or swaps.token_out = lower('{{token}}')
    )
    and block_timestamp > current_date - 2)
    group by 1;

    Run a query to Download Data