Query editor
-- Save as: dune.rig_ef.result_base_mev_bots_jul25_feb26WITH aggs AS (SELECT DISTINCT project_contract_address AS tx_toFROM dex_aggregator.tradesWHERE blockchain = 'base'AND project_contract_address IS NOT NULLUNIONSELECT DISTINCT address AS tx_toFROM dex.addressesWHERE blockchain = 'base')SELECT DISTINCT tx_to AS mev_botFROM (SELECT tx_hash, tx_to,map_filter(map_zip_with(multimap_agg(token_sold_address, -token_sold_amount),multimap_agg(token_bought_address, token_bought_amount),(k, v1, v2) -> reduce(coalesce(v1, array[]), 0, (s, x) -> s + coalesce(x, 0), s -> s)+ reduce(coalesce(v2, array[]), 0, (s, x) -> s + coalesce(x, 0), s -> s)),(k, v) -> v <> 0) AS balance_changesFROM dex.tradesWHERE blockchain = 'base'AND block_date >= date('2025-07-01')AND block_date < date('2026-02-01')AND tx_to NOT IN (SELECT tx_to FROM aggs)GROUP BY 1, 2HAVING regexp_like(ARRAY_JOIN(ARRAY_AGG(CONCAT(to_hex(token_sold_address), ',', to_hex(token_bought_address))ORDER BY evt_index), ','),'^([^,]+),(?:(?:([^,]+),\2,))+\1$'))WHERE all_match(map_values(balance_changes), v -> v > 0)AND cardinality(balance_changes) > 0AND tx_to NOT IN (SELECT DISTINCT tx_toFROM dex.trades dINNER JOIN ens.reverse_latest erON er.address = d.tx_fromAND er.name LIKE '%.base.eth'WHERE d.blockchain = 'base')AND tx_to NOT IN (0x3fc91a3afd70395cd496c647d5a6cc9d4b2b7fad,0x4752ba5dbc23f44d87826276bf6fd6b1c372ad24,0x5ff137d4b0fdcd49dca30c7cf57e578a026d2789,0x1231deb6f5749ef6ce6943a275a1d3e7486f4eae,0x6b2c0c7be2048daa9b5527982c29f48062b34d58,0x6cb442acf35158d5eda88fe602221b67b400be3e,0x0000000000001ff3684f28c67538d4d072c22734,0x743f2f29cdd66242fb27d292ab2cc92f45674635,0xecb03b9a0e7f7b5e261d3ef752865af6621a54fe,0x03a520b32c04bf3beef7beb72e919cf822ed34f1,