market method

Future<MarketSummary?> market({
  1. required String underlying,
  2. required Object expiryMs,
})

A resolved live market's on-chain state summary, or null when no market exists for the coordinates. Deliberately re-queries and overwrites the cache instead of reading through it: this read must return live state (nav, mintPaused), and refreshing the cache on the way keeps later tx builds consistent.

Implementation

Future<MarketSummary?> market(
    {required String underlying, required Object expiryMs}) async {
  final expiry = PredictClient._expiryOf(expiryMs);
  final u = _c._underlying(underlying);
  final id =
      await markets_reads.expiryMarketId(_c._client, _c._config, u, expiry);
  if (id == null) return null;
  final state = await markets_reads.marketState(_c._client, _c._config, id);
  _c._marketCache['$underlying:$expiry'] =
      _ResolvedMarket(id: id, state: state);
  final navRaw =
      await markets_reads.currentNav(_c._client, _c._config, id, u);
  return MarketSummary(
    id: id,
    expiryMs: state.expiryMs,
    tickSize: fromRaw(state.tickSizeRaw, 9), // strike/price scale
    admissionTickSize: fromRaw(state.admissionTickSizeRaw, 9),
    mintPaused: state.mintPaused,
    nav: rawToUsdc(navRaw),
    referencePrice: PredictClient._referencePriceOf(state),
  );
}