oc · docs
docs / documentation

@orangecheck/design


@orangecheck/design / useSpotPrice

Function: useSpotPrice()

function useSpotPrice(opts?: UseSpotPriceOptions): SpotPrice;

Defined in: format/use-spot-price.ts:73

Hook · returns the latest BTC/USD spot rate from endpoint.

Behaviour:

  • First mount: synchronous return of REFERENCE_BTC_USD (no NaN), then an async fetch updates state.
  • Every intervalMs thereafter, a background fetch keeps the rate fresh while the tab is alive.
  • Network blips keep the last-good value — no flash to fallback.
  • Unmount cancels both the in-flight read (cancelled flag) and the interval timer.

Parameters

ParameterType
optsUseSpotPriceOptions

Returns

SpotPrice