Skip to content

ILinearCurveEngine

The linear curve engine’s specific surface on top of the generic {IPricingCurve}: decoding its own opaque engine-state bytes.

Keeps the linear state representation and its typed decoder owned by the engine rather than in a shared data-types library.

Version-tagged wire encoding of the linear curve engine’s opaque

state bytes.

abi.encode(LinearCurveState). The schema version leads so a future

revision can dispatch decoders; all other fields are Fixed18 raw

values matching SegmentedScheduleLinear.State exactly — stored coordinates

only, never rounded derived quantities. This representation is owned by

the linear engine, not shared: engine state is private to each curve.

struct LinearCurveState

FieldType
schemaVersionuint32
Must equal LinearCurveEngine.STATE_SCHEMA_V1.
floorPriceuint256
Floor price; unsigned Fixed18 y-value ratio, strictly positive.
rampEndSupplyuint256
Ramp-end supply coordinate x2.
rampWidthuint256
Ramp width x2 - x1; at most rampEndSupply.
rampScalaruint256
Ramp vertical scale s; strictly greater than 1e18.
slopeuint256
Characteristic slope m; strictly positive.

Inherited from IPricingCurve.

Upper-bound area under the curve on [0, netSupply], in reserve-token Fixed18.

Certified HIGH: the returned value is at or above the exact integral, so a reserve balance that covers it provably covers the curve. Use for solvency/backing checks; never treat it as an exact value or compare it for equality.

function areaUnder(bytes engineState, struct DataTypes.Fixed18Value netSupply) returns (struct DataTypes.Fixed18Value) pure

Parameters

Returns

Decode a market’s opaque engine-state bytes as this engine’s state.

Reverts with UnsupportedEngineStateSchema if the schema version is not one this engine revision writes.

@engineState — The opaque bytes a market stores for this engine.

@return state — The decoded, version-checked linear curve state.

function decodeState(bytes engineState) returns (struct LinearCurveState) pure

Parameters

  • engineStatebytes

Returns

Inherited from IPricingCurve.

Return the floor price as a non-negative Fixed18 y-value ratio.

function floorPrice(bytes engineState) returns (struct DataTypes.Fixed18Value) pure

Parameters

  • engineStatebytes

Returns

Inherited from IPricingCurve.

The schedule’s marginal price y(netSupply) — reserve-token per AVM token — at the given supply, as a non-negative Fixed18 y-value.

Certified HIGH: at or above the exact price, so a premium priced off it (e.g. an option exercise fee on price - floor) is never understated. When netSupply sits on the floor segment the returned value is EXACTLY the floor, so an at-the-floor premium is exactly zero regardless of fee rate. Never compare it for equality above the floor; never treat it as an exact value.

function priceAtSupply(bytes engineState, struct DataTypes.Fixed18Value netSupply) returns (struct DataTypes.Fixed18Value) pure

Parameters

Returns

Inherited from IPricingCurve.

Quote the reserve cost of an exact AVM-token output.

quote.netCurveReserveCost is certified HIGH: at or above the exact curve cost.

function quoteBuyWithExactAvmTokensOut(bytes engineState, struct DataTypes.Fixed18Value avmTokensOut, struct DataTypes.Fixed18Value netSupply) returns (struct DataTypes.EngineBuyExactOutQuote) pure

Parameters

Returns

Inherited from IPricingCurve.

Quote a buy funded by an exact reserve-token budget.

quote.chargedReserveTokensIn is the certified-HIGH cost of quote.avmTokensOut and is guaranteed at or below reserveTokensIn — the buyer is never charged more than offered, and the charged amount never undercuts the curve.

function quoteBuyWithExactReserveTokensIn(bytes engineState, struct DataTypes.Fixed18Value reserveTokensIn, struct DataTypes.Fixed18Value netSupply) returns (struct DataTypes.EngineBuyExactInQuote) pure

Parameters

Returns

Inherited from IPricingCurve.

Quote a sell of an exact AVM-token input.

quote.grossReserveTokensOut is certified LOW: at or below the exact curve value of the surrendered tokens.

function quoteSellWithExactAvmTokensIn(bytes engineState, struct DataTypes.Fixed18Value avmTokensIn, struct DataTypes.Fixed18Value netSupply) returns (struct DataTypes.EngineSellExactInQuote) pure

Parameters

Returns

Inherited from IPricingCurve.

Quote the AVM-token input needed for an exact reserve-token output.

quote.avmTokensIn is certified HIGH: the burned amount is always worth at least the requested payout on the curve.

function quoteSellWithExactReserveTokensOut(bytes engineState, struct DataTypes.Fixed18Value reserveTokensOut, struct DataTypes.Fixed18Value netSupply) returns (struct DataTypes.EngineSellExactOutQuote) pure

Parameters

Returns

Inherited from IPricingCurve.

Compute a floor-raise transition.

Engine-specific transition parameters ride in params, mirroring how state already works; DataTypes.FloorRaiseParams is the canonical encoding shared by the built-in market admin surface. Legality checks are engine-defined, MUST be one-sided (for the area-preserving flavor: new area at or below old area under defensive rounding), and MUST reject any raise that does not strictly increase the floor. The outcome’s area fields are certified HIGH so the market can run its reserve-backing check directly.

function raiseFloor(bytes engineState, bytes params, struct DataTypes.Fixed18Value netSupply) returns (struct DataTypes.FloorRaiseOutcome, bytes) pure

Parameters

Returns

Returns true if this contract implements the interface defined by interfaceId. See the corresponding https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[ERC section] to learn more about how these ids are created. This function call must use less than 30 000 gas.

function supportsInterface(bytes4 interfaceId) returns (bool) view

Parameters

  • interfaceIdbytes4

Returns

  • bool

Inherited from IPricingCurve.

Validate that engineState is decodable and satisfies engine-specific invariants.

Intentionally pure: validity must depend only on the bytes being proposed, not on market storage or other mutable chain state. Implementations SHOULD revert with engine-specific errors on malformed or invalid state and return true for valid state. Markets call this during initialization (and state hotfixes) before committing opaque bytes. Quote methods MUST still validate their engineState input; this hook is not a substitute for local safety checks.

function validateEngineState(bytes engineState) returns (bool) pure

Parameters

  • engineStatebytes

Returns

  • validbool