SV3 logo

Math

Pure bigint quotes and curve helpers. No RPC. Pass a MarketSnapshot.

@repo/contract-client/math is a TypeScript port of the on-chain integer rules. It never takes a PublicClient. Unknown curve revisions throw instead of reusing v1 math.

Load state once with getTradeContext, then call these while the user types.

Each function has its own page in this section (same shape as viem action docs: Import, Usage, Return Value, Parameters, Error).

Amounts are branded bigints. Parse UI strings with parseUsdc / parseAvm. Do not pass JavaScript numbers.

Trades

Positions

Curve

Backing, fees, units

Client vs /math

sv3.quote.buyExactReserveIn({ market, amount }) calls the same function after loading a snapshot if you passed an address. For a slider, load once and import from /math.