CryptoLionuniswap v3 swap volume
    Updated 2021-09-01
    with pools as (
    select distinct
    -- date_trunc('week',block_timestamp) as time,
    pool_address,
    pool_name,
    last_value(token0_balance_usd) over (partition by pool_name order by block_timestamp) as one,
    last_value(token1_balance_usd) over (partition by pool_name order by block_timestamp) as two,
    one+two as tvl
    from uniswapv3.pool_stats
    where block_timestamp >= getdate() - interval '2 days'
    and token0_balance_usd is not null
    and token1_balance_usd is not null
    order by tvl desc
    limit 5)

    select
    date_trunc('hour',block_timestamp) as time,
    p.pool_name,
    sum(abs(amount0_usd)) as volume,
    sum(volume) over (partition by p.pool_name order by time ) as agg_volume
    from uniswapv3.swaps
    inner join pools p on p.pool_name = uniswapv3.swaps.pool_name
    where blocK_timestamp >= getdate() - interval '3 months'
    group by 1,2
    order by 1 desc
    Run a query to Download Data