SV3 logo

supplyForPrice

Curve supply at which the linear curve reaches a target spot price.

Inverse of priceAtSupply. Returns the supply on the piecewise line whose price equals price (or the boundary of that region).

Import

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

Usage

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

const supply = supplyForPrice(snapshot.engine, parsePrice("0.001"));

Return Value

AvmAtoms — curve supply, 18 decimals.

Parameters

state

  • Type: LinearCurveState
supplyForPrice(snapshot.engine, snapshot.spotPriceWad);

price

  • Type: Wad

Target USDC per AVM. Below floor returns 0. Far above the line returns the region's end.

supplyForPrice(snapshot.engine, asWad(10n ** 15n));

Error

InvalidAmountError if price is not positive or the state is invalid.