---
title: validateState
description: Check that linear-curve coefficients form a legal v1 engine.
---

> **For AI agents:** the complete documentation index is at [llms.txt](/llms.txt). Append `.md` to any page URL for its markdown version.

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

## Import

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

## Usage

```ts
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

`boolean` — `true` 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.

```ts
validateState(snapshot.engine);
```

## Error

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