Query editor
with cls as (select mint, cls, issuer from query_9221018),tr as (select block_date d, project, version, amount_usd, trader_id, fee_tier,token_bought_mint_address bm, token_sold_mint_address sm, token_bought_vault bv, token_sold_vault sv,token_bought_amount ba, token_sold_amount safrom dex_solana.tradeswhere block_month = date '2026-11-01' and block_date between date '2026-11-10' and date '2026-11-23'and project in ('meteora','whirlpool','raydium','pumpswap','pancakeswap','byreal','stabble') and not (project='meteora' and version=4)),px as (select d, mint, approx_percentile(p, 0.5) price from (select d, bm mint, amount_usd/ba p from tr where ba > 0 and amount_usd > 0union all select d, sm, amount_usd/sa from tr where sa > 0 and amount_usd > 0) group by 1,2),pools as (select d, case project when 'whirlpool' then 'orca' else project end dex,case when project='raydium' then (case version when 3 then 'CLMM' when 4 then 'AMM v4' when 5 then 'CPMM' else cast(version as varchar) end)when project='meteora' then (case version when 1 then 'DAMM v1' when 2 then 'DLMM' when 3 then 'DAMM v2' else cast(version as varchar) end)else '' end sub,least(bv, sv) v1, greatest(bv, sv) v2,max(case when bv < sv then bm else sm end) m1, max(case when bv < sv then sm else bm end) m2,sum(amount_usd) vol, count(distinct trader_id) traders, max(fee_tier) feefrom tr group by 1,2,3,4,5),vaults as (select v1 v from pools where v1 is not null union select v2 from pools where v2 is not null),bal as (select a.block_date d, a.address, max_by(a.post_token_balance, (a.block_slot, a.tx_index)) balfrom solana.account_activity a join vaults on a.address = vaults.vwhere a.block_date between date '2026-11-10' and date '2026-11-23' and a.tx_success and a.token_mint_address is not nullgroup by 1,2),p2 as (select p.*, c1.cls c1, c2.cls c2, c1.issuer i1, c2.issuer i2,cast(b1.bal as double) * x1.price a, cast(b2.bal as double) * x2.price bfrom pools pleft join cls c1 on c1.mint = p.m1 left join cls c2 on c2.mint = p.m2left join bal b1 on b1.address = p.v1 and b1.d = p.d left join bal b2 on b2.address = p.v2 and b2.d = p.dleft join px x1 on x1.mint = p.m1 and x1.d = p.d left join px x2 on x2.mint = p.m2 and x2.d = p.d),p3 as (select *,case when c1 is null or c2 is null then 'meme'when 'rwa' in (c1, c2) then (case when i1 is not null and i2 is not null and i1 <> i2 then 'rwa_both' when coalesce(i1, i2) = 'xStocks' then 'rwa_x' else 'rwa_b' end)when 'main' in (c1, c2) then 'main' else 'stable' end typ,case when c1 is not null and c2 is not null then coalesce(a,0) + coalesce(b,0)when c1 is not null then coalesce(a,0) + least(coalesce(b,a,0), coalesce(a,0))when c2 is not null then coalesce(b,0) + least(coalesce(a,b,0), coalesce(b,0))else 0 end tvl,coalesce(a,0) + coalesce(b,0) tvl_rawfrom p2)select d, case when dex='raydium' then 'Raydium' when dex='meteora' then concat('Meteora ', sub) when dex='orca' then 'Orca' when dex='pumpswap' then 'PumpSwap' when dex='pancakeswap' then 'PancakeSwap' else 'Other' end proto,typ,case when dex='raydium' and sub='CLMM' then tvl_raw > 10000when dex='orca' then (tvl_raw > 10000 or coalesce(fee,0) > 0.001)when dex='pumpswap' then (tvl_raw >= 5000 and traders >= 50)when dex='meteora' and sub='DAMM v2' then not coalesce(tvl < 1000000 and vol > 10 * tvl, false)else true end keep,sum(vol) vol, count(*) poolsfrom p3 group by 1,2,3,4