SV3 logo

validateState

Check that linear-curve coefficients form a legal v1 engine.

Returns true when floor, slope, ramp, and continuity constraints hold. Snapshots loaded by the SDK are already revision-gated with assertMathRevision. Call this when you built an engine yourself (tests, charts of launchPreset()).

Import

import { validateState } from "@repo/contract-client/math";

Usage

import { launchPreset, validateState } from "@repo/contract-client/math";

validateState(launchPreset());
validateState(snapshot.engine);

Checks include: schemaVersion === 1, positive floor and main slope, ramp scalar > 1 WAD, rampWidth ≤ rampEnd, piecewise continuity at x2, and positive price samples.

Return Value

booleantrue if the state is legal. Does not throw on an illegal state.

Parameters

state

  • Type: { schemaVersion, floorPriceWad, rampEndSupplyWad, rampWidthWad, rampScalarWad, mainSlopeWad }

The decoded engine. LinearCurveState (branded bigints) is accepted.

validateState(snapshot.engine);

Error

None. Price helpers throw InvalidAmountError if they still run against a bad state.