Query editor
-- 4.2 Isolate swaps initiated by known arbitrage bots or MEV searchers-- Pool: wNXM/ETH 0.3% | 0xC02D0fA00C0bEC48186026c71da2E54Ebf680139WITH all_swaps AS (SELECTDATE_TRUNC('day', t.block_time) AS day,t.tx_hash,t.tx_from AS initiator,-- ETH volume:CASEWHEN t.token_bought_address = 0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2 THEN ABS(t.token_bought_amount)WHEN t.token_sold_address = 0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2 THEN ABS(t.token_sold_amount)ELSE 0END AS eth_volume,-- Signal 1: multiple swaps in same tx = structural arb/sandwich footprintCOUNT(*) OVER (PARTITION BY t.tx_hash) AS swaps_in_tx-- Signal 2 (contract check) removed: ethereum.contracts JOIN is expensive-- and overlaps heavily with Signal 1 + labels. Dropped for performance.FROM dex.trades tWHEREt.project = 'uniswap'AND t.version = '3'AND t.blockchain = 'ethereum'AND t.project_contract_address = 0xc02d0fa00c0bec48186026c71da2e54ebf680139AND t.block_time >= NOW() - INTERVAL '90' DAY),mev_flagged AS (SELECTs.day,s.tx_hash,s.initiator,s.eth_volume,s.swaps_in_tx,-- Signal 2: Dune community MEV labelsCASE WHEN l.address IS NOT NULL THEN TRUE ELSE FALSE END AS is_labeled_mevFROM all_swaps sLEFT JOIN labels.addresses lON s.initiator = l.addressAND l.blockchain = 'ethereum'AND l.label_type IN ('mev_bot', 'arbitrage', 'sandwich_bot')),mev_swaps AS (SELECT *FROM mev_flaggedWHEREswaps_in_tx > 1 -- Signal 1: multi-swap tx patternOR is_labeled_mev = TRUE -- Signal 2: known MEV label)SELECTday,COUNT(DISTINCT tx_hash) AS mev_tx_count,COUNT(*) AS mev_swap_count,