sampleCurve
Price and certified area at many curve supplies from one snapshot.
Maps each supply to { priceWad, areaUpRaw, areaDownRaw }. Use this for a chart; do not call priceAtSupply in a loop from UI without need — this keeps rounding consistent with backing.
Import
import { sampleCurve } from "@repo/contract-client/math";
Usage
import { asAvmAtoms } from "@repo/contract-client/types";
import { sampleCurve } from "@repo/contract-client/math";
const points = sampleCurve(snapshot, [
asAvmAtoms(0n),
snapshot.curveSupply,
asAvmAtoms(snapshot.curveSupply * 2n),
]);
points[1].priceWad;
points[1].areaUpRaw;
points[1].areaDownRaw;
Return Value
readonly { supply, priceWad, areaUpRaw, areaDownRaw }[]
area*Raw are 6-decimal USDC, already passed through wadToRaw with matching ceil/floor.
Parameters
snapshot
- Type:
MarketSnapshot
Provides the engine and revision check.
sampleCurve(snapshot, supplies);
supplies
- Type:
readonly AvmAtoms[]
Any order; results are 1:1 with the input.
Error
UnsupportedCurveRevisionError. Nested InvalidAmountError for a bad supply.