areaAtSupply
Integral of the linear curve from 0 to a supply, in WAD.
Certified area under the price curve. Rounding 'up' or 'down' is explicit — backing uses the conservative pair (area up, floor value down).
The USDC (6dp) form is areaAtSupplyRaw(snapshot, supply, rounding) on the same module.
Import
import { areaAtSupply } from "@repo/contract-client/math";
Usage
const areaUp = areaAtSupply(snapshot.engine, snapshot.curveSupply, "up");
const areaDown = areaAtSupply(snapshot.engine, snapshot.curveSupply, "down");
Return Value
Wad — 18-decimal USDC·AVM area. Convert to reserve units with wadToRaw.
Parameters
state
- Type:
LinearCurveState
areaAtSupply(snapshot.engine, snapshot.curveSupply, "up");
supply
- Type:
AvmAtoms
Upper bound of the integral (from 0).
rounding
- Type:
'up' | 'down'
There is no default. Callers must pick.
areaAtSupply(snapshot.engine, supply, "down");
Error
InvalidAmountError on negative supply or a state that fails validateState.
Tips
- requiredBacking is
floorLiability + (areaUp(curveSupply) − floorValueDown(curveSupply)).