Query editor
WITH excluded_addresses AS (-- Rule A: Comprehensive and less restrictive.SELECT address FROM labels.bridgeUNION ALLSELECT address FROM cex_evms.addressesUNION ALLSELECT dao AS address FROM dao.addressesUNION ALLSELECT address FROM labels.system_addressesUNION ALLSELECT address FROM labels.addressesWHERE blockchain = 'base'AND (category IN ('Rollup', 'contracts', 'dao', 'institution', 'bridge', 'infrastructure','safe', 'likely bots', 'cex users', 'ofac_sanction', 'project wallet', 'dex')OR 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 ALLSELECT address FROM base.contracts),live_addresses AS (-- Rule D: Finds all addresses that have been active in the last 500 days.SELECT address FROM (SELECT "from" AS address, block_time FROM base.transactionsUNION ALLSELECT "to" AS address, block_time FROM base.transactions)WHERE block_time >= NOW() - interval '500' dayGROUP BY address -- Grouping makes them distinct for the CTE's output),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:%'