IMarket
Overview
Section titled “Overview”Generic single-market proxy roll-up. Specific market flavors implement this interface.
IMarket
Section titled “IMarket”Composes the four caller-permission slices for a single market: - IMarketActions: permissionless spot trading (buy, sell, redeem, exercise) and donate. - IMarketLeverageActions: permissionless collateral, debt, and atomic expand/shrink flows. - IMarketGroupAdmin: market-group-admin operations (flags, floor raises, group revenue). - IMarketViews: read-only views (also extends ERC-165). Proxy model: OpenZeppelin BeaconProxy per market, sharing logic via the directory’s single market beacon.Storage initialization is intentionally NOT part of this public surface. It is the private factory↔market contract IMarketInitializer, defined inside avm-program.
Functions
Section titled “Functions”balances
Section titled “balances”Inherited from IMarketViews.
function balances() returns (struct MarketBalances) viewReturns
borrow
Section titled “borrow”Inherited from IMarketLeverageActions.
Draw a reserve-token cash advance against the caller’s collateral.
@grossDebtIncrease — Gross reserve-token debt to add. Borrow fees are withheld from proceeds.
function borrow(RawTokenQuantity grossDebtIncrease) nonpayableParameters
grossDebtIncrease— RawTokenQuantity
buyWithExactAvmTokensOut
Section titled “buyWithExactAvmTokensOut”Inherited from IMarketActions.
Buy an exact AVM token output amount.
@avmTokensOut — Exact AVM tokens to receive.
@maxReserveTokensIn — Slippage ceiling on gross reserve tokens spent before buy fees are removed.
@receiver — Receiver of minted AVM tokens.
function buyWithExactAvmTokensOut(RawTokenQuantity avmTokensOut, RawTokenQuantity maxReserveTokensIn, address receiver) nonpayableParameters
avmTokensOut— RawTokenQuantitymaxReserveTokensIn— RawTokenQuantityreceiver—address
buyWithExactReserveTokensIn
Section titled “buyWithExactReserveTokensIn”Inherited from IMarketActions.
Buy using an exact reserve-token input amount.
@grossReserveTokensIn — Exact reserve tokens the caller will spend before buy fees are removed.
@minAvmTokensOut — Slippage floor on AVM tokens received.
@receiver — Receiver of minted AVM tokens.
function buyWithExactReserveTokensIn(RawTokenQuantity grossReserveTokensIn, RawTokenQuantity minAvmTokensOut, address receiver) nonpayableParameters
grossReserveTokensIn— RawTokenQuantityminAvmTokensOut— RawTokenQuantityreceiver—address
collectGroupRevenue
Section titled “collectGroupRevenue”Inherited from IMarketGroupAdmin.
function collectGroupRevenue(RawTokenQuantity amount, address recipient) returns (RawTokenQuantity) nonpayableParameters
amount— RawTokenQuantityrecipient—address
Returns
collected— RawTokenQuantity
depositCollateral
Section titled “depositCollateral”Inherited from IMarketLeverageActions.
Pledge AVM tokens as collateral to a position keyed by onBehalfOf.
@amount — AVM tokens to pledge.
@onBehalfOf — Position holder being credited; may differ from the caller.
function depositCollateral(RawTokenQuantity amount, address onBehalfOf) nonpayableParameters
amount— RawTokenQuantityonBehalfOf—address
directory
Section titled “directory”Inherited from IMarketViews.
function directory() returns (address) viewReturns
address
donateLiquidity
Section titled “donateLiquidity”Inherited from IMarketActions.
Donate reserve tokens into the market’s internally accounted reserve.
This is a benign, permissionless reserve top-up. It does not mint AVM, create a position, change engineState, or raise the floor. The market has reserve surplus when its accounted reserve plus outstanding debt exceeds the current total area under the curve. That surplus may later be consumed by a separate floor raise from excess liquidity, but donation itself only stores the liquidity.
@amount — Reserve-token amount to transfer into the market reserve.
function donateLiquidity(RawTokenQuantity amount) nonpayableParameters
amount— RawTokenQuantity
engine
Section titled “engine”Inherited from IMarketViews.
Current pricing engine resolved through the directory for marketKind().
function engine() returns (address) viewReturns
address
engineState
Section titled “engineState”Inherited from IMarketViews.
Opaque, engine-defined state for the current engine().
The encoding is private to the engine. Bytes returned here MUST NOT be passed to a different engine route unless that engine explicitly supports the same encoding.
function engineState() returns (bytes) viewReturns
bytes
exerciseOptionTokens
Section titled “exerciseOptionTokens”Inherited from IMarketActions.
Burn option tokens at the floor price and mint matching AVM to receiver.
function exerciseOptionTokens(RawTokenQuantity optionTokenAmount, RawTokenQuantity maxReserveTokensIn, address receiver) nonpayableParameters
optionTokenAmount— RawTokenQuantitymaxReserveTokensIn— RawTokenQuantityreceiver—address
expandWithExactAvmOut
Section titled “expandWithExactAvmOut”Inherited from ILeveragedPositionManagement.
Buy and collateralize exact AVM using newly opened debt plus caller wallet reserve.
@avmCollateralAdded — Exact AVM collateral added to the caller’s position.
@grossDebtIncrease — Exact gross reserve-token debt added to the caller’s position.
@maxReserveFromUser — Slippage ceiling on reserve tokens pulled from the caller’s wallet.
function expandWithExactAvmOut(RawTokenQuantity avmCollateralAdded, RawTokenQuantity grossDebtIncrease, RawTokenQuantity maxReserveFromUser) nonpayableParameters
avmCollateralAdded— RawTokenQuantitygrossDebtIncrease— RawTokenQuantitymaxReserveFromUser— RawTokenQuantity
expandWithExactReserveIn
Section titled “expandWithExactReserveIn”Inherited from ILeveragedPositionManagement.
Spend exact wallet reserve plus exact newly opened debt to buy and collateralize AVM.
@grossDebtIncrease — Exact gross reserve-token debt added to the caller’s position.
@minAvmCollateral — Slippage floor on AVM collateral added to the position.
@reserveFromUser — Exact reserve tokens pulled from the caller’s wallet.
function expandWithExactReserveIn(RawTokenQuantity reserveFromUser, RawTokenQuantity grossDebtIncrease, RawTokenQuantity minAvmCollateral) nonpayableParameters
reserveFromUser— RawTokenQuantitygrossDebtIncrease— RawTokenQuantityminAvmCollateral— RawTokenQuantity
Inherited from IMarketViews.
function flags() returns (struct MarketFlags) viewReturns
getPosition
Section titled “getPosition”Inherited from IMarketViews.
function getPosition(address holder) returns (struct DataTypes.PersonalPosition) viewParameters
holder—address
Returns
position— DataTypes.PersonalPosition
groupId
Section titled “groupId”Inherited from IMarketViews.
function groupId() returns (GroupId) viewReturns
marketId
Section titled “marketId”Inherited from IMarketViews.
function marketId() returns (MarketId) viewReturns
marketKind
Section titled “marketKind”Inherited from IMarketViews.
function marketKind() returns (MarketKind) viewReturns
netIssuedSupply
Section titled “netIssuedSupply”Inherited from IMarketViews.
Net-issued supply: the portion of AVM supply issued along the trading curve, in raw token units.
Reverts with Errors.NegativeNetIssuedSupply if the offset exceeds total supply, which indicates corrupted accounting.
function netIssuedSupply() returns (RawTokenQuantity) viewReturns
raiseFloorFromExcessLiquidity
Section titled “raiseFloorFromExcessLiquidity”Inherited from IMarketGroupAdmin.
Raise floor using surplus reserve liquidity already held by the market.
This is the separate operation that may consume surplus created by donateLiquidity; donation itself does not raise the floor.
@newFloorPrice — Target floor price as an unsigned Fixed18 exchange rate (reserve token per AVM token).
function raiseFloorFromExcessLiquidity(ExchangeRate newFloorPrice) nonpayableParameters
newFloorPrice— ExchangeRate
raiseFloorPreserveArea
Section titled “raiseFloorPreserveArea”Inherited from IMarketGroupAdmin.
Raise floor while preserving curve area by explicitly choosing the new ramp end.
@newFloorPrice — Target floor price as an unsigned Fixed18 exchange rate (reserve token per AVM token).
@newRampEndSupply — Target ramp-end x-value as an unscaled raw count of the AVM token’s smallest unit.
function raiseFloorPreserveArea(RawTokenQuantity newRampEndSupply, ExchangeRate newFloorPrice) nonpayableParameters
newRampEndSupply— RawTokenQuantitynewFloorPrice— ExchangeRate
redeemAtFloorWithExactAvmTokensIn
Section titled “redeemAtFloorWithExactAvmTokensIn”Inherited from IMarketActions.
Redeem an exact AVM token amount at the current floor price.
Floor redemption is a permissionless constant-price sell. It burns exact AVM input, applies the normal sell fee to the gross floor-price reserve output, and commits the engine’s floor-redemption state transition. No slippage bound is required because the floor price is guaranteed not to decrease.
@avmTokensIn — Exact AVM tokens to redeem and burn.
@receiver — Receiver of net reserve-token proceeds.
function redeemAtFloorWithExactAvmTokensIn(RawTokenQuantity avmTokensIn, address receiver) nonpayableParameters
avmTokensIn— RawTokenQuantityreceiver—address
Inherited from IMarketLeverageActions.
Repay an outstanding cash advance on a position keyed by onBehalfOf.
@amount — Reserve tokens to repay (capped at outstanding debt).
@onBehalfOf — Position holder whose debt is being reduced.
function repay(RawTokenQuantity amount, address onBehalfOf) nonpayableParameters
amount— RawTokenQuantityonBehalfOf—address
sellWithExactAvmTokensIn
Section titled “sellWithExactAvmTokensIn”Inherited from IMarketActions.
Sell using an exact AVM token input amount.
@avmTokensIn — Exact AVM tokens to sell.
@minReserveTokensOut — Slippage floor on net reserve tokens received after sell fees.
@receiver — Receiver of reserve-token proceeds.
function sellWithExactAvmTokensIn(RawTokenQuantity avmTokensIn, RawTokenQuantity minReserveTokensOut, address receiver) nonpayableParameters
avmTokensIn— RawTokenQuantityminReserveTokensOut— RawTokenQuantityreceiver—address
sellWithExactReserveTokensOut
Section titled “sellWithExactReserveTokensOut”Inherited from IMarketActions.
Sell for an exact reserve-token output amount after fees.
@maxAvmTokensIn — Slippage ceiling on AVM tokens sold.
@netReserveTokensOut — Exact reserve tokens the receiver gets after sell fees.
@receiver — Receiver of reserve-token proceeds.
function sellWithExactReserveTokensOut(RawTokenQuantity netReserveTokensOut, RawTokenQuantity maxAvmTokensIn, address receiver) nonpayableParameters
netReserveTokensOut— RawTokenQuantitymaxAvmTokensIn— RawTokenQuantityreceiver—address
setMarketFlags
Section titled “setMarketFlags”Inherited from IMarketGroupAdmin.
function setMarketFlags(struct MarketFlags newFlags) nonpayableParameters
newFlags— MarketFlags
shrinkWithExactAvmIn
Section titled “shrinkWithExactAvmIn”Inherited from ILeveragedPositionManagement.
Sell exact AVM collateral, repay exact debt, and send residual reserve to the caller.
@avmCollateralRemoved — Exact AVM collateral removed from the caller’s position and sold.
@debtDecrease — Exact reserve-token debt repaid from the sell proceeds.
@minReserveTokensToUser — Slippage floor on actual reserve tokens sent to the caller after fees and repayment.
function shrinkWithExactAvmIn(RawTokenQuantity avmCollateralRemoved, RawTokenQuantity debtDecrease, RawTokenQuantity minReserveTokensToUser) nonpayableParameters
avmCollateralRemoved— RawTokenQuantitydebtDecrease— RawTokenQuantityminReserveTokensToUser— RawTokenQuantity
shrinkWithExactReserveOut
Section titled “shrinkWithExactReserveOut”Inherited from ILeveragedPositionManagement.
Sell enough AVM collateral to repay exact debt and send exact reserve tokens to the caller.
@debtDecrease — Exact reserve-token debt repaid from the sell proceeds.
@maxAvmCollateralRemoved — Slippage ceiling on AVM collateral removed and sold.
@netReserveTokensToUser — Exact reserve tokens sent to the caller after sell fees and debt repayment.
function shrinkWithExactReserveOut(RawTokenQuantity netReserveTokensToUser, RawTokenQuantity debtDecrease, RawTokenQuantity maxAvmCollateralRemoved) nonpayableParameters
netReserveTokensToUser— RawTokenQuantitydebtDecrease— RawTokenQuantitymaxAvmCollateralRemoved— RawTokenQuantity
snapshot
Section titled “snapshot”Inherited from IMarketViews.
function snapshot() returns (struct DataTypes.MarketStateSnapshot) viewReturns
Inherited from IMarketViews.
State of the market, with no derived values.
function state() returns (struct MarketState) viewReturns
supplyOffset
Section titled “supplyOffset”Inherited from IMarketViews.
Signed count of AVM tokens (raw units) that exist off the trading curve: option exercises add to it, floor redemptions subtract.
Net-issued (curve) supply is totalSupply() - supplyOffset(); the market prices every trade at net-issued supply, never total supply.
function supplyOffset() returns (int256) viewReturns
int256
supportsInterface
Section titled “supportsInterface”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) viewParameters
interfaceId—bytes4
Returns
bool
tenantId
Section titled “tenantId”Inherited from IMarketViews.
Tenant that owns this market’s group.
Resolved dynamically through IAvmDirectoryViews.getMarketGroup. A group’s tenant is fixed at group creation, so this value is stable for the market’s lifetime.
function tenantId() returns (TenantId) viewReturns
tokens
Section titled “tokens”Inherited from IMarketViews.
function tokens() returns (struct TokenSet) viewReturns
withdrawCollateral
Section titled “withdrawCollateral”Inherited from IMarketLeverageActions.
Reclaim pledged AVM collateral. Always flows to the caller’s own position.
@amount — AVM tokens to withdraw.
function withdrawCollateral(RawTokenQuantity amount) nonpayableParameters
amount— RawTokenQuantity