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_from, caller, COUNT(tx) AS transactions, COUNT(DISTINCT route) AS routes, SUM(pool_volume_usd) AS volume_usdFROM "query_4286648(pool='{{pool}}', date_from='{{date_from}}', date_to='{{date_to}}')"GROUP BY 1, 2),aggregate AS (SELECTtx_from, caller, transactions, routes, volume_usd, pool_fee,(volume_usd * pool_fee) AS fee_usd,(SELECT SUM(volume_usd) FROM sources) AS total_volume_usdFROM (SELECTtx_from, caller, transactions, routes, volume_usd,(SELECT fee FROM pool) / 10000.00 / 100.00 AS pool_feeFROM sources)),query AS (SELECTtx_from, caller, transactions, routes, volume_usd, total_volume_usd,(volume_usd / total_volume_usd) AS pct_volume,pool_fee, fee_usdFROM aggregate)SELECT *FROM queryORDER BY volume_usd DESC