Query editor
-- Title: "Mark vs Index Divergence Extended"-- Description: "Percent difference between mark and index prices per market with open interest and daily volume (latest snapshot per chain)."SELECTt.market AS "Market",t.chain AS "Chain",t.fetched_at AS "Snapshot",ROUND(CAST(t.markprice AS DOUBLE), 8) AS "Mark Price",ROUND(CAST(t.indexprice AS DOUBLE), 8) AS "Index Price",ROUND((CAST(t.markprice AS DOUBLE) / NULLIF(CAST(t.indexprice AS DOUBLE), 0) - 1) * 100, 4) AS "Pct Diff (%)",ROUND(CAST(t.dailyVolume AS DOUBLE), 2) AS "Daily Volume",ROUND(CAST(t.openInterest AS DOUBLE), 2) AS "Open Interest",CASEWHEN ABS((CAST(t.markprice AS DOUBLE) / NULLIF(CAST(t.indexprice AS DOUBLE), 0) - 1) * 100) >= 10 THEN 'Anomaly'WHEN ABS((CAST(t.markprice AS DOUBLE) / NULLIF(CAST(t.indexprice AS DOUBLE), 0) - 1) * 100) >= 0.15 THEN 'Alert ♨︎'WHEN ABS((CAST(t.markprice AS DOUBLE) / NULLIF(CAST(t.indexprice AS DOUBLE), 0) - 1) * 100) >= 0.08 THEN 'Watch ⚠︎'ELSE 'OK ✔'END AS "Status"FROM dune.vadymdi.dataset_extended_markets_data tJOIN (SELECT chain, MAX(fetched_at) AS fetched_atFROM dune.vadymdi.dataset_extended_markets_dataGROUP BY chain) latestON t.chain = latest.chainAND t.fetched_at = latest.fetched_atWHERE CAST(t.markprice AS DOUBLE) > 0AND CAST(t.indexprice AS DOUBLE) > 0AND CAST(t.openInterest AS DOUBLE) > 0AND CAST(t.dailyVolume AS DOUBLE) > 0ORDER BY ABS("Pct Diff (%)") DESCLIMIT 500;