Skip to main content

Market contract

MarketContract holds one netted position per account and side. It owns margin, order escrow, credit, and the market's risk configuration.

The paired strategy vault holds liquidity. Each market has one immutable feed_id. Its constructor binds the vault, settlement token, oracle, treasury, and owner.

The owner can upgrade market code while retaining the market address and its authority over the paired vault. The vault has no upgrade entry, so its fixed code still trusts the registered market's current behavior.

Orders and positions​

ReferenceWhat it defines
Orderscreate_order, cancel_order, execute_order, get_order, get_order_counter, and all six order kinds.
Position lifecycleget_position, position fields, increases, decreases, size locks, and full-close sweeps.
Margin and leverageMargin requirements, maintenance equity, and position validation.
Profit and lossPrice marks, rounding, profit caps, and aggregate vault marks.
Pricingaccrue, price selection, cache behavior, and the position price floor.
Fees and settlementTrade and impact fees, escrowed execution fees, settlement legs, and payout fallback.
Funding rateFunding accrual, claim_credit, get_claimable_credit, and the credit pool.
Borrowing rateUtilization, the borrowing curve, and side reserves.

Forced closes and liquidity​

ReferenceWhat it defines
Liquidationexecute_liquidation, eligibility, fees, bad debt, and delist deadlines.
Auto-deleveragingget_adl, update_adl_state, execute_adl, side flags, and forced profit realization.
Vault orderscreate_vault_order, cancel_vault_order, execute_vault_order, get_vault_order, minimum output, and redeem locks.

Administration and shared references​

ReferenceWhat it defines
Constructor and dependencies__constructor, dependency views, ownership, and upgrade.
Configurationset_config, get_config, field units, validation bounds, and constants.
Market statusset_status, get_status, set_terminal_price, get_retirement, transitions, and entry gates.
StorageEvery key, record, and storage time-to-live rule.
EventsTopics, data fields, and receipt ordering.
ErrorsMarket and ownership error codes.
Units and scalesInteger precision and rounding conventions.

User actions authorize creation, cancellation, and credit claims. Price-bearing keeper entries are permissionless. A keeper argument names the reward recipient.

The transaction reference covers batch composition, fee forwarding, and session authorization. Live addresses and parameters appear in Deployments.