Popex404#5 Avalanche Defi - Distribution of LPs
    Updated 2023-08-20
    with cte as (
    SELECT
    "Token",
    count(distinct pool_address) as "LPs"
    from (
    SELECT
    tokens:token0 as "Token",
    pool_address
    from avalanche.defi.dim_dex_liquidity_pools
    union all
    select
    tokens:token1 as "Token",
    pool_address
    from avalanche.defi.dim_dex_liquidity_pools)
    where "Token" is not null
    group by 1 order by 2 desc)

    select
    case
    when "LPs" = 1 then 'a) 1 LP'
    when "LPs" < 6 then 'b) 2-5 LPs'
    when "LPs" < 11 then 'c) 6-10 LPs'
    when "LPs" < 21 then 'd) 11-20 LPs'
    else 'e) >21 LPs' end as "LPs Amount",
    count(distinct "Token") as "Tokens",
    sum("LPs") as "Liquidity Pools"
    from cte
    group by 1 order by 1

    Run a query to Download Data