Query editor
WITH protocol_data AS (SELECTproject,blockchain,-- Volume in USDSUM(amount_usd) AS total_volume,-- Estimated revenue (using protocol defaults)SUM(CASEWHEN project = 'uniswap' THEN amount_usd * 0.003WHEN project = 'curve' THEN amount_usd * 0.0004WHEN project = 'aerodrome' THEN amount_usd * 0.002WHEN project = 'pancakeswap' THEN amount_usd * 0.0025WHEN project = 'mento' THEN amount_usd * 0.0005ELSE amount_usd * 0.003END) AS estimated_trading_fees,-- User metricsCOUNT(DISTINCT tx_from) AS active_users,COUNT(*) AS total_tradesFROM dex.tradesWHERE block_time >= CURRENT_DATE - INTERVAL '90' dayGROUP BY 1, 2)SELECTproject,blockchain,-- VolumeROUND(total_volume / 1000000, 2) AS volume_millions,-- Estimated revenueROUND(estimated_trading_fees / 1000000, 2) AS trading_fees_millions,-- Usersactive_users,-- Key metricsROUND(estimated_trading_fees * 1000000 /NULLIF(active_users, 0), 2) AS trading_fees_per_user,ROUND(estimated_trading_fees /NULLIF(total_volume, 0) * 100, 3) AS effective_fee_pctFROM protocol_dataWHERE total_volume > 1000000 -- Min $1M volumeORDER BY trading_fees_millions DESCLIMIT 20