Query editor
with v as (select * from query_9191012 where pool_mk_coverage >= 0.5),p as (select blockchain, pool, arbitrary(asset_class) as asset_class, arbitrary(curator) as curator,sum(tvl_usd_avg) as tds, sum(vol_usd) as vol,sum(fee_lp_usd) as fee_lp, sum(fee_platform_usd) as fee_plat,sum(mk_vol) as mk_vol, sum(pnl_10) as pnl_10, sum(mk_fee_platform) as mk_fee_platfrom v group by 1, 2),b as (select *,fee_plat / nullif(fee_lp + fee_plat, 0) as plat_share,case when fee_plat / nullif(fee_lp + fee_plat, 0) < 0.155 then 'a) 15% (no curator fee)'when fee_plat / nullif(fee_lp + fee_plat, 0) < 0.205 then 'b) over 15% to 20%'when fee_plat / nullif(fee_lp + fee_plat, 0) < 0.305 then 'c) over 20% to 30%'when fee_plat / nullif(fee_lp + fee_plat, 0) >= 0.305 then 'd) over 30%'else 'e) no fees recorded' end as bucketfrom p),g as (select s.scope, b.bucket,count(*) as pools, count(distinct b.curator) as curators,sum(b.tds) as tds, sum(b.vol) as vol,sum(b.fee_lp) as fee_lp, sum(b.fee_plat) as fee_plat,sum(b.mk_vol) as mk_vol, sum(b.pnl_10) as pnl_10, sum(b.mk_fee_plat) as mk_fee_platfrom bcross join unnest(array['0 All pools with a reference',case b.asset_class when 'Majors (ETH/BTC/BNB)' then '1 Majors' when 'Stable-stable' then '2 Stables' when 'Tokenized stocks & RWA' then '3 Stocks' else '4 Other' end]) as s(scope)where b.bucket <> 'e) no fees recorded'group by 1, 2)select scope || ' | ' || bucket as "group", scope, bucket as platform_cut,case scope when '0 All pools with a reference' then 'All' when '1 Majors' then 'Majors' when '2 Stables' then 'Stables' when '3 Stocks' then 'Stocks' else 'Other' end|| ' ' ||case bucket when 'a) 15% (no curator fee)' then '15%' when 'b) over 15% to 20%' then '15-20%' when 'c) over 20% to 30%' then '20-30%' else '>30%' end as chart_label,pools, curators,tds / 70e0 as avg_tvl_usd, vol as vol_usd,vol / sum(vol) over (partition by scope) as vol_share_in_scope,fee_plat / nullif(fee_lp + fee_plat, 0) as platform_share,1e4 * (fee_lp + fee_plat) / nullif(vol, 0) as fee_bps,1e4 * fee_lp / nullif(vol, 0) as lp_fee_bps,mk_vol as scored_vol_usd,1e4 * pnl_10 / nullif(mk_vol, 0) as mk10_bps,1e4 * (pnl_10 - mk_fee_plat) / nullif(mk_vol, 0) as lp_only_mk10_bps,pnl_10 as pnl10_usd, pnl_10 - mk_fee_plat as lp_only_pnl10_usd,365e0 * (pnl_10 - mk_fee_plat) / nullif(tds, 0) as lp_only_return_on_tvl_ann,trim(case when mk_vol < 2e7 then 'Scored volume under $20M: too small to conclude. ' else '' end ||case when tds / 70e0 < 1e5 then 'Avg TVL under $100k: return on TVL not meaningful. ' else '' end ||case when curators <= 2 then 'One or two curators only. ' else '' end) as note,-- chart: majors and stable pairs only, groups with at least $20M of scored volumecase when mk_vol >= 2e7 and scope in ('1 Majors', '2 Stables') then 1e4 * (fee_lp + fee_plat) / nullif(vol, 0) end as fee_bps_chart,case when mk_vol >= 2e7 and scope in ('1 Majors', '2 Stables') then 1e4 * pnl_10 / mk_vol end as mk10_bps_chart,case when mk_vol >= 2e7 and scope in ('1 Majors', '2 Stables') then 1e4 * (pnl_10 - mk_fee_plat) / mk_vol end as lp_only_mk10_bps_chartfrom gorder by 1