Query editor
-- Multi-token weekly inflow/outflow/net for the Extended exchange + treasury, USD.-- Each transfer is priced at its day's USD price, then aggregated per-- (week_start, counterparty). Internal flows between exchange/treasury and the-- XVS vault (0x062e091…) are excluded.WITH tokens AS (SELECT token_address, decimals, symbol FROM (VALUES(0x053c91253bc9682c04929ca02ed00b3e423f6710d2ee7e0d5ebb06f3ecf368a8, 6, 'USDC'),(0x033068f6539f8e6e6b131e6b2b814e6c34a5224bc66947c47dab9dfee93b35fb, 6, 'USDC'),(0x049d36570d4e46f48e99674bd3fcc84644ddd6b96f7c741b1562b82f9e004dc7, 18, 'ETH'),(0x03fe2b97c1fd336e750087d68b9b867997fd64a2661ff3ca5a7c771641e8e7ac, 8, 'WBTC'),(0x068f5c6a61780768455de69077e07e89787839bf8166decfbf92b645209c0fb8, 6, 'USDT'),(0x03a37a5469012cd1f3f69de2b174dd77abac6b360a0989ea573d9b41c5c2eae8, 6, 'EURC')) AS t(token_address, decimals, symbol)),custody AS (SELECT addr FROM (VALUES(0x062da0780fae50d68cecaa5a051606dc21217ba290969b302db4dd99d2e9b470),(0x060c0f8cdfa28e8a3f719d1e2def2599785d7557a5650794c150d9b557603e48)) AS t(addr)),internal_addresses AS (-- Internal counterparties to exclude from user inflow/outflow.SELECT addr FROM custodyUNIONSELECT 0x062e091dca6016fe01d94f3b2e12eac8b1a9256db2cbba8e7995a366867450ad -- XVS vault),transfers AS (-- data length >= 3, incoming: sender = data[1], recipient = data[2]SELECT date_trunc('day', e.block_time) AS day,e.from_address AS token_address,e.data[1] AS counterparty,varbinary_to_uint256(e.data[3]) AS amount_raw,1 AS signFROM starknet.events eWHERE e.block_date >= DATE '2025-07-01'AND cardinality(e.keys) >= 1AND e.keys[1] = 0x0099cd8bde557814842a3121e8ddfd433a539b8c9f14bf31ebf108d12e6196e9AND cardinality(e.data) >= 3AND e.from_address IN (SELECT token_address FROM tokens)AND e.data[2] IN (SELECT addr FROM custody)AND e.data[1] NOT IN (SELECT addr FROM internal_addresses)UNION ALL-- data length >= 3, outgoingSELECT date_trunc('day', e.block_time),e.from_address,e.data[2],varbinary_to_uint256(e.data[3]),-1FROM starknet.events eWHERE e.block_date >= DATE '2025-07-01'AND cardinality(e.keys) >= 1AND e.keys[1] = 0x0099cd8bde557814842a3121e8ddfd433a539b8c9f14bf31ebf108d12e6196e9AND cardinality(e.data) >= 3AND e.from_address IN (SELECT token_address FROM tokens)AND e.data[1] IN (SELECT addr FROM custody)AND e.data[2] NOT IN (SELECT addr FROM internal_addresses)UNION ALL-- data length = 2, incoming