API ReferenceReact provider and hooksType Alias
RiskFactorStatus
type RiskFactorStatus = 'ready' | 'incomplete' | 'loading' | 'unavailable';Why a risk factor is not a number, when it is not one.
incomplete and unavailable are different facts about different actors: incomplete is waiting
on the caller, unavailable is waiting on the chain. Collapsing them renders an untouched form as
though something had gone wrong. Both still block a decision — only what a UI should say differs.
ready—riskFactorBasisPointsholds a computed score.incomplete— inputs are insufficient; nothing is wrong yet.loading— inputs are complete and the first chain read is in flight.unavailable— inputs are complete but the pair configuration or the price could not be read. Never a fallback to a healthy-looking value.
The two legs do not carry the same freshness guarantee, and the difference is deliberate. The
pair configuration is fail-closed: it is read through
useCollateralFactor, and once past that hook’s bound — or if
its refresh fails — this hook reports unavailable rather than scoring against a threshold it can
no longer confirm. The price is not: useTokenPairPrice sets only staleTime/refetchInterval, so
after one successful read a later failed refresh keeps TanStack’s retained value and the hook stays
ready on a stale price. A price that was never read does report unavailable.
That asymmetry is parity with the web fork this hook replaced. Giving the price the same maxAgeMs
treatment without also changing its interval would reintroduce the flicker that
bound-equals-interval caused for the collateral factor, across every price consumer rather than just
this one.