Query editor
-- Phoenix perps market config, fetched live from Phoenix's public API (no key needed) with DuneSQL LiveFetch.-- tickSize = quote lots per base lot per tick; baseLotsDecimals = base-lot decimal exponent; quote lot = 1e-6 USD (PhUSD).-- Materialized daily as dune.ilanhz.result_decrypt_ix_phoenix_markets. Each refresh keeps markets from the previous-- snapshot that are no longer listed (e.g. delisted), so historical orders keep their conversion.-- If the API call fails, the refresh fails and the previous snapshot stays in place.WITH live AS (SELECTjson_extract_scalar(m, '$.marketPubkey') AS orderbook,json_extract_scalar(m, '$.symbol') AS symbol,json_extract_scalar(m, '$.metadata.name') AS name,json_extract_scalar(m, '$.marketStatus') AS market_status,CAST(json_extract_scalar(m, '$.tickSize') AS bigint) AS tick_size,CAST(json_extract_scalar(m, '$.baseLotsDecimals') AS integer) AS base_lots_decimals,CAST(json_extract_scalar(m, '$.assetId') AS integer) AS asset_idFROM UNNEST(CAST(json_parse(http_get('https://perp-api.phoenix.trade/v1/view/exchange/markets')) AS array(json))) AS t(m))SELECT * FROM liveUNION ALLSELECT p.orderbook, p.symbol, p.name, 'not listed' AS market_status, p.tick_size, p.base_lots_decimals, p.asset_idFROM dune.ilanhz.result_decrypt_ix_phoenix_markets pWHERE p.orderbook NOT IN (SELECT orderbook FROM live)