Query editor
-- Daily net deposits per HIP-3 builder DEX. Self-contained.---- SCOPE, two exclusions:-- 1. Bridge-level deposits/withdrawals (scope='ecosystem', no dex) are-- Hyperliquid-wide capital movement, not capital arriving at a builder DEX.-- 2. Transfers BETWEEN two HIP-3 DEXs (scope='internal') are internal rotation.-- They are real for a single DEX -- xyz losing $1M to io is a genuine-- outflow for xyz -- so they are KEPT in the per-DEX rows below, but they-- must not count as new capital entering HIP-3 as a whole. Query 32 and the-- data-quality total therefore sum only scope='external'.---- Emitting scope here lets the dashboard show per-DEX truth and an honest-- ecosystem-level total from the same table.SELECTday,dex,scope,SUM(CASE WHEN direction = 'in' THEN usd_value ELSE 0 END) AS inflow_usd,SUM(CASE WHEN direction = 'out' THEN usd_value ELSE 0 END) AS outflow_usd,SUM(CASE WHEN direction = 'in' THEN usd_value ELSE -usd_value END) AS net_usd,-- Convenience column so a chart can plot new capital without a scope filter:-- internal rotation contributes 0, external contributes its net.SUM(CASE WHEN scope = 'external'THEN (CASE WHEN direction = 'in' THEN usd_value ELSE -usd_value END)ELSE 0 END) AS net_external_usdFROM (SELECTCAST(DATE_TRUNC('day', CAST(REPLACE(SUBSTR(CAST(block_time AS VARCHAR), 1, 19), 'T', ' ') AS TIMESTAMP)) AS DATE) AS day,LOWER(TRIM(CAST(dex AS VARCHAR))) AS dex,LOWER(CAST(direction AS VARCHAR)) AS direction,LOWER(TRIM(CAST(scope AS VARCHAR))) AS scope,COALESCE(TRY_CAST(usdc_value AS DOUBLE), TRY_CAST(amount_usd AS DOUBLE)) AS usd_valueFROM dune.asdfw123453216.dataset_hip3_flows_masterWHERE dex IS NOT NULLAND TRIM(CAST(dex AS VARCHAR)) <> ''AND COALESCE(TRY_CAST(usdc_value AS DOUBLE), TRY_CAST(amount_usd AS DOUBLE)) > 0)GROUP BY day, dex, scopeORDER BY day, dex, scope