Query editor
-- DeFa pass 3a (narrowed): measured USDC/USDT flow for the only stablecoin-payment-- companies Dune labels. 6 months, 5 major EVM chains.-- Caveat: a transfer between two addresses of the SAME company lands in both that-- company's inflow and outflow, so these are GROSS flows, not net-of-internal.WITH co AS (SELECT d.name, a.blockchain, a.addressFROM labels.owner_details dJOIN labels.owner_addresses a ON a.owner_key = d.owner_keyWHERE d.name IN ('Bitso', 'Lemon Cash', 'Straitsx', 'Zero Hash')AND a.blockchain IN ('ethereum','polygon','base','arbitrum','optimism')),t AS (SELECT blockchain, "from", "to", amount_usdFROM tokens.transfersWHERE block_month >= DATE '2026-05-01'AND blockchain IN ('ethereum','polygon','base','arbitrum','optimism')AND symbol IN ('USDC','USDT')AND amount_usd IS NOT NULLAND ("to" IN (SELECT address FROM co) OR "from" IN (SELECT address FROM co)))SELECT c.name AS company,SUM(CASE WHEN t."to" = c.address THEN t.amount_usd ELSE 0 END) AS inflow_usd,SUM(CASE WHEN t."from" = c.address THEN t.amount_usd ELSE 0 END) AS outflow_usd,COUNT(*) AS transfers,COUNT(DISTINCT t.blockchain) AS chainsFROM t JOIN co c ON c.blockchain = t.blockchain AND (c.address = t."to" OR c.address = t."from")GROUP BY 1 ORDER BY 2 DESC