Query editor
-- Polymarket daily top-up & cashout stats-- Covers BOTH wallet types: Safe proxies (3.58M) + Deposit wallets (885K)-- Tracks USDC (native + bridged) flowing in/out of user wallets-- Excludes internal Polymarket contract transfers (exchange, pUSD wrapper, factories)WITH all_polymarket_wallets AS (-- Safe proxy wallets (legacy): address is in data bytes 13-32SELECT bytearray_substring(data, 13, 20) AS wallet, 'safe' AS wallet_typeFROM polygon.logsWHERE contract_address = 0xaacfeea03eb1561c4e67d661e40682bd20e3541bAND topic0 = 0x4f51faf6c4561ff95f067657e43439f0f856d97c04d9ec9070a6199ad418e235AND block_date > DATE('2026-01-01') AND block_date < DATE('2026-02-01')UNION ALL-- Deposit wallets (newer ERC-1967 proxies): address is in topic1 bytes 13-32SELECT bytearray_substring(topic1, 13, 20) AS wallet, 'deposit' AS wallet_typeFROM polygon.logsWHERE contract_address = 0x00000000000Fb5C9ADea0298D729A0CB3823Cc07AND topic0 = 0x7441de0ad639fe5d2bf1c22447715a0528b682385736bb40ae8dd92555eb8276AND block_date > DATE('2026-01-01') AND block_date < DATE('2026-06-01')),polymarket_internal(address) AS (VALUES(0x4bfb41d5b3570defd03c39a9a4d8de6bd8b8982e), -- CTF Exchange(0xC5d563A36AE78145C45a50134d48A1215220f80a), -- NegRisk CTF Exchange(0x4D97DCd97eC945f40cF65F87097ACe5EA0476045), -- NegRisk Adapter(0xc011a7e12a19f7b1f670d46f03b03f3342e82dfb), -- pUSD wrapper (USDC<>pUSD conversion)(0xaB45c5A4B0c941a2F231C04C3f49182E1A254052), -- Proxy Factory (Magic)(0xaacfeea03eb1561c4e67d661e40682bd20e3541b), -- Safe Proxy Factory(0x00000000000Fb5C9ADea0298D729A0CB3823Cc07) -- Deposit Wallet Factory),topups AS (SELECTDATE_TRUNC('day', t.evt_block_time) AS day,w.wallet_type,t."to" AS user_wallet,t.value / 1e6 AS amount_usdcFROM erc20_polygon.evt_Transfer tINNER JOIN all_polymarket_wallets w ON t."to" = w.walletLEFT JOIN all_polymarket_wallets w2 ON t."from" = w2.walletLEFT JOIN polymarket_internal c ON t."from" = c.addressWHERE t.contract_address IN (0x2791Bca1f2de4661ED88A30C99A7a9449Aa84174, -- USDC.e (bridged)0x3c499c542cEF5E3811e1192ce70d8cC03d5c3359 -- USDC (native))AND t.evt_block_time >= NOW() - INTERVAL '7' DAYAND w2.wallet IS NULL -- not from another polymarket walletAND c.address IS NULL -- not from internal contract),cashouts AS (SELECTDATE_TRUNC('day', t.evt_block_time) AS day,w.wallet_type,t."from" AS user_wallet,t.value / 1e6 AS amount_usdc