Query editor
-- OWB — Holders + Win Rate + Dormancy (lightweight)-- Single scan of evt_Transfer → balance, last_active, first_receive_day-- Win rate: first-receive-day price vs current price (1 join per holder)WITH-- ============================================================-- 1. Single scan: balance + last activity + first receive day-- ============================================================wallet_stats AS (SELECTaddress,SUM(net_amount) AS balance,MAX(last_seen) AS last_active,MIN(first_recv_day) AS first_receive_dayFROM (-- Inbound transfersSELECT"to" AS address,CAST(value AS INT256) AS net_amount,evt_block_time AS last_seen,DATE_TRUNC('day', evt_block_time) AS first_recv_dayFROM erc20_base.evt_TransferWHERE contract_address = 0xEF5997c2cf2f6c138196f8a6203afc335206b3c1UNION ALL-- Outbound transfers (negative amount, no first_recv_day)SELECT"from" AS address,-CAST(value AS INT256) AS net_amount,evt_block_time AS last_seen,CAST(NULL AS DATE) AS first_recv_dayFROM erc20_base.evt_TransferWHERE contract_address = 0xEF5997c2cf2f6c138196f8a6203afc335206b3c1) tGROUP BY 1HAVING SUM(net_amount) > 0AND address != 0x0000000000000000000000000000000000000000),-- ============================================================-- 2. Total holders (from wallet_stats — no extra scan)-- ============================================================holder_count AS (SELECT COUNT(*) AS total_holders FROM wallet_stats),-- ============================================================-- 3. Daily average price (one scan of dex.trades)-- ============================================================daily_price AS (SELECTDATE_TRUNC('day', block_time) AS day,AVG(CASEWHEN token_bought_address = 0xEF5997c2cf2f6c138196f8a6203afc335206b3c1THEN amount_usd / NULLIF(token_bought_amount, 0)ELSE amount_usd / NULLIF(token_sold_amount, 0)END