DataTypes
Public structs shared by AVM control-plane, market, engine, and emitter interfaces.
Unit-typing convention. External market entry points use the branded aliases
RawTokenQuantity and ExchangeRate in place of bare uint256 whenever a
parameter’s unit is load-bearing — most importantly when two adjacent
arguments carry different units. RawTokenQuantity is an unscaled integer
count of a token’s smallest unit; it makes no assumption about decimal
precision. The engine boundary (IPricingCurve) uses Fixed18Value /
SignedFixed18Value for curve coordinates, token amounts, and ratios in
18-decimal fixed-point form; markets convert RawTokenQuantity to
Fixed18Value on the way in and back out. ExchangeRate is always an
unsigned Fixed18 ratio and is never a raw token quantity.
Token-denominated fields on the structs below are typed RawTokenQuantity:
raw integer counts in the relevant token’s native decimals, with no implicit
rescaling. Where two such fields refer to different tokens (for example AVM
collateral vs. reserve-token debt), the per-field NatSpec names the token.
CreateMarketParams
Section titled “CreateMarketParams”Public inputs to IAvmFactory.createMarket — everything a group
admin supplies to create a market in one call. The factory lowers
this into the private MarketInitConfig (after deploying the token
set) before committing storage on the market.
struct DataTypes.CreateMarketParams
| Field | Type |
|---|---|
kind | MarketKind Flavor of market being deployed. |
marketId | MarketId Stable market identifier used by off-chain systems. |
groupId | GroupId Parent market group identifier. |
reserveToken | addressReserve asset address for issuance, redemption, and debt. |
engineInitData | bytesFlavor-specific initialization payload for the engine. |
flags | MarketFlags Initial per-market operation flags. |
dutchAuctionConfig | DutchAuctionConfig Optional launch pricing boost configuration. |
avmTokenName | stringERC-20 name for the AVM token. |
avmTokenSymbol | stringERC-20 symbol for the AVM token. |
optionTokenName | stringERC-20 name for the option token. |
optionTokenSymbol | stringERC-20 symbol for the option token. |
EngineBuyExactInQuote
Section titled “EngineBuyExactInQuote”Engine response for an exact-input reserve buy quote.
All amounts are 18-decimal fixed-point values at the engine boundary.
struct DataTypes.EngineBuyExactInQuote
| Field | Type |
|---|---|
chargedReserveTokensIn | Fixed18Value Certified-HIGH curve cost of avmTokensOut; at or below the |
offered reserve input. Markets may charge the full offered amount
and retain the residual as extra backing, but MUST use this value
for quoting/eventing accuracy. |
| avmTokensOut | Fixed18Value
AVM tokens minted from the provided reserve input. |
| nextEngineState | bytes
Engine state to commit if the market executes this quote.
Zero-length means “state unchanged” — skip the storage write. |
EngineBuyExactOutQuote
Section titled “EngineBuyExactOutQuote”Engine response for an exact-output AVM buy quote.
All amounts are 18-decimal fixed-point values at the engine boundary.
struct DataTypes.EngineBuyExactOutQuote
| Field | Type |
|---|---|
avmTokensOut | Fixed18Value Requested AVM tokens to issue. |
netCurveReserveCost | Fixed18Value Certified-HIGH net reserve-token curve cost, before market-level |
buy fees are grossed up. |
| nextEngineState | bytes
Engine state to commit if the market executes this quote.
Zero-length means “state unchanged” — skip the storage write. |
EngineSellExactInQuote
Section titled “EngineSellExactInQuote”Engine response for an exact-input AVM sell quote.
All amounts are 18-decimal fixed-point values at the engine boundary.
struct DataTypes.EngineSellExactInQuote
| Field | Type |
|---|---|
avmTokensIn | Fixed18Value AVM tokens to burn from the seller. |
grossReserveTokensOut | Fixed18Value Certified-LOW gross reserve-token output before market-level fees. |
nextEngineState | bytesEngine state to commit if the market executes this quote. |
Zero-length means “state unchanged” — skip the storage write. |
EngineSellExactOutQuote
Section titled “EngineSellExactOutQuote”Engine response for an exact-output reserve sell quote.
All amounts are 18-decimal fixed-point values at the engine boundary.
struct DataTypes.EngineSellExactOutQuote
| Field | Type |
|---|---|
reserveTokensOut | Fixed18Value Requested reserve-token output before market-level fee handling. |
avmTokensIn | Fixed18Value Certified-HIGH AVM tokens required to fund the reserve output. |
nextEngineState | bytesEngine state to commit if the market executes this quote. |
Zero-length means “state unchanged” — skip the storage write. |
FeeAwareBorrowQuote
Section titled “FeeAwareBorrowQuote”Fee-aware quote for a reserve-token cash advance (borrow).
A borrow never touches the pricing curve: grossDebtIncrease is the
caller’s exact new liability, the origination fee is carved out of it
(rounding UP, favoring the pool), and the borrower receives the net.
net + platform + group == grossDebtIncrease holds in atoms.
struct DataTypes.FeeAwareBorrowQuote
| Field | Type |
|---|---|
grossDebtIncrease | RawTokenQuantity Gross reserve-token debt the borrow opens (echoed exact input). |
netBorrowReserveProceeds | RawTokenQuantity Net reserve tokens paid to the borrower after the origination fee. |
fees | FeeDistributionBreakdown Reserve-token origination-fee distribution carved from the gross debt. |
FeeAwareBuyExactAvmOutQuote
Section titled “FeeAwareBuyExactAvmOutQuote”Fee-aware quote for buying exact AVM-token output.
struct DataTypes.FeeAwareBuyExactAvmOutQuote
| Field | Type |
|---|---|
avmTokensOut | RawTokenQuantity AVM tokens minted to user. |
netCurveReserveCost | RawTokenQuantity Net reserve-token cost the curve must receive. |
grossReserveTokensIn | RawTokenQuantity Gross reserve tokens pulled from user before buy fees are removed. |
fees | FeeDistributionBreakdown Reserve-token fee distribution removed from grossReserveTokensIn. |
nextEngineState | bytesEngine state preview after applying this quote. |
FeeAwareBuyExactReserveInQuote
Section titled “FeeAwareBuyExactReserveInQuote”Fee-aware quote for buying with exact reserve-token input.
struct DataTypes.FeeAwareBuyExactReserveInQuote
| Field | Type |
|---|---|
grossReserveTokensIn | RawTokenQuantity Gross reserve tokens pulled from user before buy fees are removed. |
avmTokensOut | RawTokenQuantity AVM tokens minted to user. |
netCurveReserveTokensIn | RawTokenQuantity Net reserve tokens delivered to the curve after buy fees are removed. |
fees | FeeDistributionBreakdown Reserve-token fee distribution removed from gross input. |
nextEngineState | bytesEngine state preview after applying this quote. |
FeeAwareExerciseOptionQuote
Section titled “FeeAwareExerciseOptionQuote”Fee-aware quote for exercising call options struck at the floor.
Market-level arithmetic against the floor (strike) and the current
marginal price (premium); never changes engine state. The exerciser
pays grossReserveTokensIn = strike + fee; only the strike
(netFloorReserveTokensIn) enters market liquidity to back the
minted shares at the floor, and the fee — charged on the option
premium (current_price - floor), so zero at the floor — is
escrowed. optionTokensIn AVM tokens are minted 1:1.
struct DataTypes.FeeAwareExerciseOptionQuote
| Field | Type |
|---|---|
optionTokensIn | RawTokenQuantity Option tokens exercised (burned); AVM minted 1:1. |
grossReserveTokensIn | RawTokenQuantity Total reserve the exerciser pays (strike + fee), rounds up. |
netFloorReserveTokensIn | RawTokenQuantity Strike entering market liquidity at the floor (the fee-free net). |
fees | FeeDistributionBreakdown Reserve-token fee distribution: the premium fee escrowed. |
FeeAwareRedeemAtFloorExactAvmInQuote
Section titled “FeeAwareRedeemAtFloorExactAvmInQuote”Fee-aware quote for redeeming exact AVM-token input at the floor.
Floor redemption is market-level arithmetic against the floor price
and the market’s supply offset; it never changes engine state.
struct DataTypes.FeeAwareRedeemAtFloorExactAvmInQuote
| Field | Type |
|---|---|
avmTokensIn | RawTokenQuantity AVM tokens burned from user. |
grossReserveTokensOut | RawTokenQuantity Gross floor-price reserve output before fee deduction (rounds down). |
netReserveTokensOut | RawTokenQuantity Net reserve output sent to user after normal sell fees. |
fees | FeeDistributionBreakdown Reserve-token fee distribution from gross output. |
FeeAwareSellExactAvmInQuote
Section titled “FeeAwareSellExactAvmInQuote”Fee-aware quote for selling exact AVM-token input.
struct DataTypes.FeeAwareSellExactAvmInQuote
| Field | Type |
|---|---|
avmTokensIn | RawTokenQuantity AVM tokens burned from user. |
grossReserveTokensOut | RawTokenQuantity Gross reserve output before fee deduction. |
netReserveTokensOut | RawTokenQuantity Net reserve output sent to user after fees. |
fees | FeeDistributionBreakdown Reserve-token fee distribution from gross output. |
nextEngineState | bytesEngine state preview after applying this quote. |
FeeAwareSellExactReserveOutQuote
Section titled “FeeAwareSellExactReserveOutQuote”Fee-aware quote for selling for exact reserve-token output target.
struct DataTypes.FeeAwareSellExactReserveOutQuote
| Field | Type |
|---|---|
avmTokensIn | RawTokenQuantity AVM tokens burned from user. |
grossReserveTokensOut | RawTokenQuantity Gross reserve output before fee deduction. |
netReserveTokensOut | RawTokenQuantity Exact net reserve output sent to user after fees. |
fees | FeeDistributionBreakdown Reserve-token fee distribution from gross output. |
nextEngineState | bytesEngine state preview after applying this quote. |
FeeDistributionBreakdown
Section titled “FeeDistributionBreakdown”Fee distribution breakdown applied by the market after an operation is quoted.
All fields are raw integer counts in the same token’s native decimals
and always refer to reserve tokens.
struct DataTypes.FeeDistributionBreakdown
| Field | Type |
|---|---|
platformReserveFee | RawTokenQuantity Platform fee allocation. |
marketGroupReserveFee | RawTokenQuantity Market-group fee allocation. |
Fixed18Value
Section titled “Fixed18Value”Explicit 18-decimal unsigned fixed-point transport wrapper.
Use for typed math boundaries where values are 18-decimal fixed-point
scalars rather than raw token units.
struct DataTypes.Fixed18Value
| Field | Type |
|---|---|
raw | uint256 |
FloorRaiseKind
Section titled “FloorRaiseKind”Which floor-raise transition a FloorRaiseParams payload requests.
Enum DataTypes.FloorRaiseKind.
ExcessLiquidity— Consume reserve surplus: the floor rises and the total-area
requirement is allowed to grow up to the market-verified backing.
PreserveArea— Reshape the schedule without new liquidity: the floor rises while
total area (under defensive rounding) does not increase.
FloorRaiseOutcome
Section titled “FloorRaiseOutcome”Typed engine outcome of a floor raise, for events and quoters.
struct DataTypes.FloorRaiseOutcome
| Field | Type |
|---|---|
previousFloorPrice | Fixed18Value Floor price before the change, as an unsigned Fixed18 y-value ratio. |
newFloorPrice | Fixed18Value Floor price after the change, as an unsigned Fixed18 y-value ratio. |
previousTotalAreaInReserveToken | Fixed18Value Certified-HIGH total area on [0, netSupply] before the raise. |
totalAreaInReserveToken | Fixed18Value Certified-HIGH total area on [0, netSupply] after the raise. |
FloorRaiseParams
Section titled “FloorRaiseParams”Canonical abi.encode payload for IPricingCurve.raiseFloor’s
bytes params argument.
The interface keeps params opaque so engine families can extend the
encoding; this struct is the encoding used by the built-in market
admin surface and quoter.
struct DataTypes.FloorRaiseParams
| Field | Type |
|---|---|
kind | FloorRaiseKind Which raise flavor is requested. |
newFloorPrice | Fixed18Value Target floor price; must strictly exceed the current floor. |
newRampEndSupply | Fixed18Value Target ramp-end supply for PreserveArea; ignored (pass zero) for |
ExcessLiquidity. |
GroupFees
Section titled “GroupFees”Fee schedule applied to market operations within a group.
struct DataTypes.GroupFees
| Field | Type |
|---|---|
buy | MicroBps Fee on AVM buys, charged on gross reserve-token input. Capped by |
FeePolicy.MAX_GROUP_FEE_MICRO_BPS. |
| sell | MicroBps
Fee on AVM sells, charged on gross reserve-token output. Capped by
FeePolicy.MAX_GROUP_FEE_MICRO_BPS. |
| borrow | MicroBps
Fee when reserve debt is opened, charged on gross debt increase.
Capped by FeePolicy.MAX_GROUP_FEE_MICRO_BPS. |
| exerciseOption | MicroBps
Fee when option tokens are exercised, charged on gross reserve in.
Capped by FeePolicy.MAX_GROUP_FEE_MICRO_BPS. |
linearCurveMarketKind
Section titled “linearCurveMarketKind”function linearCurveMarketKind() returns (MarketKind) pureMARKET_KIND_LINEAR_CURVE_RAW
Section titled “MARKET_KIND_LINEAR_CURVE_RAW”Built-in market kind for the linear-characteristic AVM engine.
bytes32 internal constant MARKET_KIND_LINEAR_CURVE_RAWMarketGroup
Section titled “MarketGroup”Permission and fee namespace shared by a set of markets.
struct DataTypes.MarketGroup
| Field | Type |
|---|---|
tenantId | TenantId Parent tenant namespace. |
admin | addressCurrent group admin. |
proposedAdmin | addressPending group admin for two-step admin transfer. |
fees | GroupFees Fees inherited by markets in this group. |
MarketStateSnapshot
Section titled “MarketStateSnapshot”Post-action market runtime state suitable for logs, indexers, and UI snapshots.
This is intentionally the market’s “DNA” at the moment an event is emitted:
mutable policy, routing pointers, token supplies, accounting balances,
actual custody balances, curve state, and the full opaque engine state
that produced the derived prices/area.
struct DataTypes.MarketStateSnapshot
| Field | Type |
|---|---|
marketKind | MarketKind Market kind resolved through the directory to choose engine. |
groupId | GroupId Parent market group whose policy is active for this market. |
tenantId | TenantId Parent tenant whose platform fee is active for this market. |
flags | MarketFlags Per-market operation flags active when the action completed. |
tenantAdmin | addressCurrent tenant admin when the action completed. |
proposedTenantAdmin | addressPending tenant admin when the action completed. |
platformFee | MicroBps Tenant platform fee active when the action completed. |
groupAdmin | addressCurrent market-group admin when the action completed. |
proposedGroupAdmin | addressPending market-group admin when the action completed. |
groupFees | GroupFees Market-group fee schedule active when the action completed. |
directory | addressDirectory that controlled runtime pointers when the action completed. |
eventEmitter | addressEvent emitter proxy active when the action completed. |
marketBeacon | addressShared market beacon address active when the action completed. |
marketImplementation | addressImplementation address behind marketBeacon when the action completed. |
marketActionsImpl | addressMarket-actions implementation pointer used for delegated permissionless actions. |
marketLeverageActionsImpl | addressMarket-leverage-actions implementation pointer used for delegated leverage actions. |
engine | addressPricing engine proxy resolved for marketKind when the action completed. |
avmPriceInReserveToken | ExchangeRate Current marginal AVM price in reserve tokens, as an 18-decimal exchange rate. |
floorPriceInReserveToken | ExchangeRate Current floor price in reserve tokens, as an 18-decimal exchange rate. |
avmTokenSupply | RawTokenQuantity Total issued AVM supply (raw AVM-token count). |
optionTokenSupply | RawTokenQuantity Total issued option-token supply (raw option-token count). |
totalDebtInReserveToken | RawTokenQuantity Total open reserve-token debt (raw reserve-token count). |
totalCollateralInAvmToken | RawTokenQuantity Total AVM collateral deposited (raw AVM-token count). |
reserveTokenBalance | RawTokenQuantity Market-owned reserve-token liquidity balance, using the market’s |
internal reserve accounting rather than raw ERC-20 balance
(raw reserve-token count). |
| groupRevenueEscrowInReserveToken | RawTokenQuantity
Group revenue escrow balance (raw reserve-token count). |
| platformRevenueEscrowInReserveToken | RawTokenQuantity
Platform revenue escrow balance (raw reserve-token count). |
| actualReserveTokenBalance | RawTokenQuantity
Actual reserve-token ERC-20 balance held by the market address. |
| actualAvmTokenBalance | RawTokenQuantity
Actual AVM-token ERC-20 balance held by the market address. |
| actualOptionTokenBalance | RawTokenQuantity
Actual option-token ERC-20 balance held by the market address. |
| totalAreaInReserveToken | RawTokenQuantity
Total area under the active engine curve from zero to current supply,
denominated as a reserve-token integer count. Reserve surplus is the
positive excess of
reserveTokenBalance + totalDebtInReserveToken - totalAreaInReserveToken. |
| engineStateHash | bytes32keccak256 of the opaque engine state bytes used to compute this snapshot. |
| engineState | bytes
Full opaque engine state bytes used to compute this snapshot. |
MarketTypeConfig
Section titled “MarketTypeConfig”Directory routing record for one market kind.
kind is the stable semantic identifier; engine is the current
engine proxy every market of that kind should call.
struct DataTypes.MarketTypeConfig
| Field | Type |
|---|---|
kind | MarketKind The market kind this config applies to. |
engine | addressCurrent pricing-engine proxy for this kind. |
PersonalPosition
Section titled “PersonalPosition”One user’s collateralized position in a market.
Ownership is immutable: the address keying the position storage IS the
owner. The owner field doubles as a lazy-init sentinel (zero means
uninitialized) and is set once on first interaction.
struct DataTypes.PersonalPosition
| Field | Type |
|---|---|
owner | addressPosition owner. Set once on lazy creation; never reassigned. |
collateralBalance | RawTokenQuantity AVM collateral balance. |
debtBalance | RawTokenQuantity Reserve-token debt balance. |
RevenueKind
Section titled “RevenueKind”Which revenue bucket a collection event refers to.
Enum DataTypes.RevenueKind.
PlatformGroup
SignedFixed18Value
Section titled “SignedFixed18Value”Explicit 18-decimal signed fixed-point transport wrapper.
Use for typed math boundaries where values may be negative. Linear
curve y-intercepts (b1, b2) commonly become negative after floor
raises or contractions.
struct DataTypes.SignedFixed18Value
| Field | Type |
|---|---|
raw | int256 |
Tenant
Section titled “Tenant”Top-level admin namespace for one tenant’s market groups.
struct DataTypes.Tenant
| Field | Type |
|---|---|
admin | addressCurrent tenant admin. |
proposedAdmin | addressPending tenant admin for two-step admin transfer. |
platformFee | MicroBps Platform fee share on group-fee revenue for this tenant’s markets, |
expressed in MicroBps where 100_000_000 is 100%. The platform
take is a slice of group-fee revenue, not an additive surcharge on
the group fee charged to users. Capped by
FeePolicy.MAX_PLATFORM_FEE_MICRO_BPS. |
ExchangeRate
Section titled “ExchangeRate”Unsigned 18-decimal Fixed18 y-value ratio, such as reserve tokens per AVM
token. Exchange rates (prices, floor levels, price deltas) are ratios, not
raw token amounts and not token-decimal-scaled quantities. This type
ABI-encodes as uint256; the integer is the Fixed18 value itself.
User-defined value type ExchangeRate wrapping uint256.
GroupId
Section titled “GroupId”Branded identifier for a market group namespace.
User-defined value type GroupId wrapping bytes32.
MarketId
Section titled “MarketId”Branded identifier for a market namespace.
User-defined value type MarketId wrapping bytes32.
MarketKind
Section titled “MarketKind”Stable semantic identifier for an AVM market flavor. This is not an
engine address: the directory maps each kind to the current engine proxy.
User-defined value type MarketKind wrapping bytes32.
MicroBps
Section titled “MicroBps”Raw integer count of micro basis points. The integer 1_00_000_000 (1e8)
represents 100%; 1_000_000 represents 1%; 1 represents one micro basis
point. Stored as a plain integer, not a fractional value.
User-defined value type MicroBps wrapping uint64.
RawTokenQuantity
Section titled “RawTokenQuantity”Raw integer count of a token’s smallest indivisible unit. Carries no
assumption about how many decimal places the token uses — values
are interpreted in the token’s own decimals (which may be 6, 8, 18, or any
other value), and there is no implicit scale to 18 decimals. Used at the
external market boundary in place of bare uint256 whenever a parameter or
return value is a raw token amount. Markets convert these values to
Fixed18Value before calling an engine and convert engine results back to
raw token units before exposing them externally.
User-defined value type RawTokenQuantity wrapping uint256.
Seconds
Section titled “Seconds”Raw integer count of seconds, used for both durations and Unix timestamps.
User-defined value type Seconds wrapping uint48.
TenantId
Section titled “TenantId”Branded identifier for a tenant namespace.
User-defined value type TenantId wrapping bytes32.