Query editor
/* ============================================================================CADC · Aerodrome pool-level volume — reconciliation query----------------------------------------------------------------------------WHY THIS EXISTS: @mrfrost931's two Aerodrome pools show ~400M (CADC/USDCcl-10) + ~80M (CADC/WETH) = ~480M CADC cumulative. My 02_dex_volume.sql,built on the curated dex.trades spellbook, reports only 293.85M for theWHOLE of Base. Two pools cannot exceed the whole chain, so one of the twois wrong.Leading hypothesis: dex.trades does not fully ingest Aerodrome Slipstream(concentrated-liquidity) pools. This query bypasses the spellbook entirelyand reads the decoded pool events directly, so it is immune to that gap.METHOD: rather than decode token0/token1 ordering per pool (fragile), takethe CADC transfer legs that touch a pool address in a tx that emitted a swapevent. A swap moves CADC across the pool boundary exactly once, so summingthose legs counts each swap once. Joining on the swap event is what excludesLP add/remove — those transfer CADC to the pool too, but emit Mint/Burn, notSwap.NOTE: this is DEX volume, a subset. It is not the headline transfer metric.Aerodrome CL swaps are already inside 01's 885.8M Base gross figure, becausetokens.transfers sees every ERC-20 Transfer whether or not the pool isdecoded.========================================================================= */WITHcadc AS (SELECT t.tx_hash, t.block_date, t."from" AS from_addr, t."to" AS to_addr, t.amountFROM tokens.transfers AS tWHERE t.blockchain = 'base'AND t.contract_address = 0x043eb4b75d0805c43d7c834902e335621983cf03AND t.block_month >= DATE '2025-01-01'AND t.amount > 0),/* Distinct (pool, tx) pairs that emitted a swap. Both Slipstream CL pools andthe older constant-product pools. */swaps AS (SELECT DISTINCT contract_address AS pool, evt_tx_hash AS tx_hashFROM aerodrome_base.clpool_evt_swapWHERE evt_block_date >= DATE '2025-01-01'UNIONSELECT DISTINCT contract_address, evt_tx_hashFROM aerodrome_base.pool_evt_swapWHERE evt_block_date >= DATE '2025-01-01'),pool_leg AS (SELECT s.pool, c.block_date, c.amountFROM cadc AS cINNER JOIN swaps AS sON s.tx_hash = c.tx_hashAND (s.pool = c.from_addr OR s.pool = c.to_addr)),weekly AS (SELECT pool,DATE_TRUNC('week', block_date) AS week,