Updated 2023-03-27
    with lp_ltv as (
    select
    pool_name,
    avg(token0_balance_usd + token1_balance_usd) as tvl
    from uniswapv3.pool_stats
    where token0_balance_usd is not null and token1_balance_usd is not null
    and pool_name is not null
    group by pool_name
    order by tvl desc
    limit 20
    ),
    swaps as (
    select
    pool_name,
    count(distinct(tx_id)) as n_swaps,
    count(distinct(sender)) as n_wallets
    from uniswapv3.swaps
    group by pool_name
    )

    select
    l.pool_name,
    l.tvl,
    s.n_swaps,
    s.n_wallets,
    (select count(distinct pool_name) from ethereum.uniswapv3.ez_pools) as n_pools
    from swaps s
    join lp_ltv l on s.pool_name = l.pool_name
    order by l.tvl desc
    Run a query to Download Data