---
title: priceAtSupply
description: Spot price on the linear curve at a given curve supply.
---

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

Evaluates the piecewise curve: flat floor through `x1`, ramp through `x2`, then the main slope. Result is WAD USDC per AVM (18 decimals).

Pass `snapshot.engine` and `snapshot.curveSupply` for the live spot. Sampling many supplies is [sampleCurve](/developers/math/sample-curve).

## Import

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

## Usage

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

const spot = priceAtSupply(snapshot.engine, snapshot.curveSupply);
// equals snapshot.spotPriceWad when the snapshot is consistent
```

## Return Value

`Wad` — USDC per AVM, 18-decimal fixed point.

## Parameters

### state

- **Type:** `LinearCurveState`

Decoded engine (`snapshot.engine`): `floorPriceWad`, `rampEndSupplyWad`, `rampWidthWad`, `rampScalarWad`, `mainSlopeWad`.

```ts
priceAtSupply(snapshot.engine, snapshot.curveSupply);
```

### supply

- **Type:** `AvmAtoms`

**Curve** supply, not necessarily ERC-20 `totalSupply` (offset can differ).

```ts
priceAtSupply(snapshot.engine, asAvmAtoms(0n)); // floor
```

## Error

`InvalidAmountError` if supply is negative or the evaluated price is non-positive.

## Tips

- v1 launch preset starts at `0.0001` USDC/token (`PRESET_FLOOR_WAD`).
- Inverse: [supplyForPrice](/developers/math/supply-for-price).
