Query editor
withpool AS (SELECT block, feeFROM ((SELECT call_block_number AS block, output_0 AS feeFROM aerodrome_base.CLFactory_call_getSwapFeeWHERE pool = {{pool}}ORDER BY 1 DESCLIMIT 1)UNION(SELECT call_block_number AS block, output_0 AS feeFROM aerodrome_base.PoolFactory_call_getFeeWHERE pool = {{pool}}ORDER BY 1 DESCLIMIT 1))ORDER BY block DESCLIMIT 1),sources AS (SELECT tx_to, route, COUNT(tx_to) AS total_count, SUM(pool_volume_usd) AS volume_usdFROM "query_4286648(pool='{{pool}}', date_from='{{date_from}}', date_to='{{date_to}}')"GROUP BY 1,2ORDER BY 3 DESC),aggregate AS (SELECTtx_to, route, total_count, volume_usd, pool_fee,(volume_usd * pool_fee) AS fee_usd,(SELECT SUM(total_count) FROM sources) AS total_swaps,(SELECT SUM(volume_usd) FROM sources) AS total_volume_usdFROM (SELECTtx_to, route, total_count, volume_usd,(SELECT fee FROM pool) / 10000.00 / 100.00 AS pool_feeFROM sources)),query AS (SELECTtx_to, route, total_count, volume_usd, (volume_usd / total_volume_usd) AS volume_pct, pool_fee, fee_usd, total_swaps,total_volume_usd, (SELECT SUM(fee_usd) FROM aggregate) AS total_fee_usdFROM aggregate)SELECT *FROM queryORDER BY volume_usd DESC