Query editor
WITH excluded_addresses AS (-- Rule A: Comprehensive and less restrictive.SELECT address FROM labels.bridgeUNIONSELECT address FROM cex_evms.addresses -- Covers exchange, exchange_deposit, and custodiansUNIONSELECT dao AS address FROM dao.addresses -- Covers foundation/treasuryUNIONSELECT address FROM labels.system_addresses -- Covers MEV and system addressesUNIONSELECT address FROM labels.addressesWHERE blockchain = 'base'AND (category IN ('Rollup', 'contracts', 'dao', 'institution', 'bridge', 'infrastructure','safe', 'likely bots', 'cex users', 'ofac_sanction', 'project wallet', 'Bridge', 'dex')-- Exchange/Hot wallet name patternsOR LOWER(name) LIKE '%binance%'OR LOWER(name) LIKE '%coinbase%'OR LOWER(name) LIKE '%kraken%'OR LOWER(name) LIKE '%okx%'OR LOWER(name) LIKE '%bybit%'OR LOWER(name) LIKE '%kucoin%'OR LOWER(name) LIKE '%gate%'OR LOWER(name) LIKE '%huobi%'OR LOWER(name) LIKE '%bitfinex%'OR LOWER(name) LIKE '%gemini%'OR LOWER(name) LIKE '%hot%wallet%'OR LOWER(name) LIKE '%deposit%'OR LOWER(name) LIKE '%withdrawal%'OR LOWER(name) LIKE '%exchange%'OR LOWER(name) LIKE '%cex%')--UNION--SELECT address FROM base.contracts -- Exclude all contracts on Base),live_addresses AS (-- Rule D: Finds all addresses that have been active in the last 500 days.SELECT "from" AS address FROM base.transactions WHERE block_time >= NOW() - interval '500' dayUNIONSELECT "to" AS address FROM base.transactions WHERE block_time >= NOW() - interval '500' day),behaviorally_qualified_addresses AS (-- Rule C: Behavior constraint (last 90 days): <= 2 protocol families touched.-- Simple DEX swaps and other non-protocol interactions are permitted and ignored.WITH protocol_families_categorized AS (-- Step 1: Categorize all labeled contracts into the specified families.SELECTaddress,CASE-- DEX/AMM (Ignored for counting)WHEN LOWER(name) LIKE 'uniswap_v2:%'OR LOWER(name) LIKE 'uniswap_v3:%'OR LOWER(name) LIKE 'sushiswap:%'OR LOWER(name) LIKE 'curve:%'OR LOWER(name) LIKE 'balancer:%'OR LOWER(name) LIKE 'aerodrome:%'OR LOWER(name) LIKE 'baseswap:%'OR LOWER(name) LIKE '%swap:%'