Query editor
WITH contracts AS (SELECT address, name, chain, close_date FROM (VALUES-- Ethereum(0xf292b79d462f9F787a6fA42BAf54E0E5e8C47B7a, 'Pulse', 'ethereum', TIMESTAMP '2024-12-16'),(0x97802F38A37E1D789eba194513E3Eb7E918d34Df, 'FUEL', 'ethereum', TIMESTAMP '2024-12-18'),(0x448537DB42ee64146b67A71E3f9cE835E2d08f30, 'Silencio', 'ethereum', TIMESTAMP '2025-01-11'),(0x2c0637A66a5031acC0e4cc1CbCD5a4fB9335BF60, '=nil;', 'ethereum', TIMESTAMP '2025-03-02'),(0x771895523D41840B3AF6d0ea36be79128F080D52, 'Giza', 'ethereum', TIMESTAMP '2025-03-16'),(0x053D22B589890d8b54Ad20fc65f833D8cDbb1FdC, 'Electron', 'ethereum', TIMESTAMP '2025-03-17'),(0xee6deedb6c1535E4912eE5db48E08b36FD2fAA8f, 'Resolv', 'ethereum', TIMESTAMP '2025-04-24'),(0x81A00dA473D1BfF1D1b894c8a9b4C88464F15F9D, 'Intuition (Round 1)', 'ethereum', TIMESTAMP '2025-06-13'),(0x81eE48c2bb20B21bB20C95B24a36010f1DD9BCe7, 'Intuition (Round 2)', 'ethereum', TIMESTAMP '2025-06-18'),(0x02DA99C3A3c362be8358990119027CA502de07B1, 'Almanak (Community)', 'ethereum', TIMESTAMP '2025-09-01'),(0x730E7279D579C56417A0456b428eE90eA97cb5f9, 'Almanak (Public)', 'ethereum', TIMESTAMP '2025-12-31'),-- Arbitrum(0x4A71DA922CF31Fa0c68052ea658A4c1FafF8F588, 'Almanak (Old)', 'arbitrum', TIMESTAMP '2025-01-02'),(0x350DA9C5C01b4115bC37180554A90ad6A4D0cd67, 'Enclave', 'arbitrum', TIMESTAMP '2025-01-24'),(0xEFdAd5fA5502Ea38aDB8846A56DF9268F031F513, 'Corn', 'arbitrum', TIMESTAMP '2025-02-03'),(0xd4f787FC73cB2d12559D0A3158Cb8B4d491Fbe7A, 'Skate', 'arbitrum', TIMESTAMP '2025-04-04'),(0xDB0a5509318614CfFe600BcEa9bC6C001c28C270, 'Lit Protocol (Round 1)', 'arbitrum', TIMESTAMP '2025-04-13'),(0x9A3475824A15933c207Dd8B661b9488169B25947, 'Lit Protocol (Round 3)', 'arbitrum', TIMESTAMP '2025-04-15'),(0x543Eb0BFB29803C28eC0A0Ed181683c915F44ED2, 'Session (Round 1)', 'arbitrum', TIMESTAMP '2025-05-12'),(0xD3472eD0F891ee9279ADFFC7e147bFCF8E72C790, 'Session (Round 2)', 'arbitrum', TIMESTAMP '2025-05-13')) AS t(address, name, chain, close_date)),-- Shared contract: 0x81A00dA473D1BfF1D1b894c8a9b4C88464F15F9D is Intuition on ETH, Lit Protocol on ARB-- Handle by joining on chain as welleth_contracts AS (SELECT address FROM contracts WHERE chain = 'ethereum'),arb_contracts AS (SELECT address FROM contracts WHERE chain = 'arbitrum'),raw_flows AS (SELECT 'ethereum' AS chain, "to" AS receiver, "from" AS sender,CAST(value AS DOUBLE)/1e6 AS amount, evt_block_time, evt_tx_hashFROM erc20_ethereum.evt_TransferWHERE contract_address = 0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48AND evt_block_time >= TIMESTAMP '2024-11-01'AND ("to" IN (SELECT address FROM eth_contracts)OR "from" IN (SELECT address FROM eth_contracts))UNION ALLSELECT 'arbitrum', "to", "from",CAST(value AS DOUBLE)/1e6, evt_block_time, evt_tx_hashFROM erc20_arbitrum.evt_TransferWHERE contract_address = 0xaf88d065e77c8cc2239327c5edb3a432268e5831AND evt_block_time >= TIMESTAMP '2024-11-01'AND ("to" IN (SELECT address FROM arb_contracts)OR "from" IN (SELECT address FROM arb_contracts))),-- Identify depositors (users who sent USDC to a sale contract)depositors AS (SELECT DISTINCT f.sender, f.receiver AS contract, f.chainFROM raw_flows fINNER JOIN contracts c ON f.receiver = c.address AND f.chain = c.chain),