Skip to main content

Data Structures

  • Order{ address owner, uint96 size, uint40 prev, uint40 next, uint40 flippedId, uint32 price, uint32 flippedPrice, bool isBuy }
  • PricePoint{ uint40 head, uint40 tail }
  • TreeUint24 — Tree structure for active price points

Core Functions

Order Placement

Places limit buy/sell orders. Matches against resting orders first. If _postOnly is true, reverts if any portion matches immediately.

Flip Orders

Places flip orders that create opposite-side orders on fill. _flippedPrice must be better than _price. If _provisionOrRevert is false, reverts if best price equals current book best.

Market Orders

Executes market orders against resting liquidity. Supports ERC20–ERC20, NATIVE–ERC20, and ERC20–NATIVE pairs. _isFOK enforces fill-or-kill behavior.

Cancellation

Batch cancels regular or flip orders. Idempotent—safe to call multiple times.

Liquidity Provision

Adds liquidity to the AMM vault. addPairedLiquidity sets bid/ask prices and sizes. Batch function allows provisioning multiple price points at once.

View Functions

Returns best bid/ask prices, L2 order book depth, and market configuration parameters.

Market States

  • ACTIVE — Full operations enabled
  • SOFT_PAUSED — Only cancels, deposits, withdrawals allowed
  • HARD_PAUSED — All operations halted

Order Types

Events

OrderCreated

Emitted when a new limit order is placed on the order book.

FlipOrderCreated

Emitted when a flip order is created. flippedId is the order ID that will be created on the opposite side when this order fills.

Trade

Emitted for each order fill. updatedSize is the remaining size after fill. origin is the original transaction sender (supports meta-transactions).

OrderCanceled

Emitted when an order is successfully canceled. Returns the full order size before cancellation.

MarketStateUpdated

Emitted when market state changes (ACTIVE, SOFT_PAUSED, or HARD_PAUSED).