Query editor
-- =====================================================================-- KAMINO WEEKLY NET FLOW: WoW TVL change by partner (safe flow proxy)-- =====================================================================-- Prefer this over raw action usd_amount for dollar flows.-- =====================================================================WITH m AS (SELECTCAST(event_date AS DATE) AS day,partner,SUM(CAST(usd_amount AS DOUBLE)) AS tvl_usdFROM dune.yieldxyz.dataset_kamino_tvlWHERE CAST(is_partner_facing AS VARCHAR) IN ('true', 't', '1', 'TRUE')GROUP BY 1, 2),with_prev AS (SELECTday,partner,tvl_usd,LAG(tvl_usd) OVER (PARTITION BY partner ORDER BY day) AS prev_tvl_usdFROM m)SELECTday,partner,ROUND(tvl_usd, 2) AS tvl_usd,ROUND(prev_tvl_usd, 2) AS prev_tvl_usd,ROUND(tvl_usd - COALESCE(prev_tvl_usd, tvl_usd), 2) AS net_flow_usdFROM with_prevWHERE prev_tvl_usd IS NOT NULLORDER BY day, net_flow_usd DESC