Skip to main content

Function: optionState()

function optionState(
details,
totals,
now?): "pending" | "exercisable" | "redeemable" | "finished";

Defined in: packages/overcast-core/src/curation/lifecycle.ts:53

Derive an option's OptionState from its window and its running OptionTotals. now is unix seconds — the same unit as OptionDetails.startTimestamp / endTimestamp — and defaults to the local clock.

The thresholds mirror the on-chain guards: exercise_option requires start <= now <= end and burns exercise claims from a supply that starts at collateralAmount; redeem_option requires expiry or a fully exercised option, and burns collateral-return claims from a second supply of the same size. Both instructions additionally require the option's borrowed collateral to be repaid, which this state deliberately ignores — it is derived from the window and the totals alone — so an option with an outstanding borrow reads as exercisable / redeemable here even though the program will reject the call until the borrow is settled. Callers that need to gate on it should check MarketOption.borrowedCollateral alongside the state.

Parameters​

ParameterType
detailsOptionDetails
totalsOptionTotals
nownumber

Returns​

"pending" | "exercisable" | "redeemable" | "finished"