Orders

All trading on Margin Trade happens through a central limit order book (CLOB). Orders are matched by price-time priority and settled onchain.

This page covers order entry, execution instructions, and matching. For margin checks, see Margin. For price bands, mark price, and after-hours guardrails, see Price Feeds.


Before you place an order

Before an order can enter the book:

  • Your account must have enough available margin

  • Price and size must follow the market’s price step and amount step

  • Some orders may be constrained by mark-price bands or after-hours taker guardrails

Use Markets for per-market increments and limits.


Order Types

Market Order

Executes immediately at the best available market price. Market orders prioritize speed of execution over price precision and will match against existing resting limit orders in the book.

Use when: You need immediate execution and accept minor slippage.


Limit Order

Places an order to buy or sell at a specific price or better. If the market doesn’t reach your limit price, the order remains resting on the order book until filled or canceled.

Use when: You want precise control over execution price.

circle-info

Order validation may reference the mark price. For equity markets during oracle-unavailable periods, only taker execution is clamp-constrained.


Triggered Orders (coming soon)

Stop Market Order

A market order that activates once the market reaches your specified stop price. Commonly used as a stop loss or take profit trigger to protect against large losses or lock in gains.

Use when: You want automatic execution once a price threshold is hit.

Stop Limit Order

A limit order that becomes active once the stop price is reached. Once triggered, it will execute at your chosen limit price or better — not worse.

Use when: You want to limit losses or capture profits but control the worst price you receive.

Take Profit / Stop Loss

Position-linked trigger orders that execute when a target or risk threshold is reached.

  • TP triggers when your profit target is reached

  • SL triggers when your loss threshold is reached

Both can be configured with a trigger price and position size.


Execution Algorithms (coming soon)

Scale Order

Places multiple limit orders across a set price range to build or unwind a position gradually. Useful for layering entries or exits to average into volatile markets.

TWAP (Time-Weighted Average Price) Order

Executes a large order over time by splitting it into smaller suborders. Each suborder executes every 30 seconds, targeting an even distribution of execution. Suborders have a maximum slippage limit of 3%.

TWAP Logic:

  • Execution target = (elapsed time ÷ total time) × total size

  • If a suborder doesn’t fill (due to spread or low liquidity), later suborders increase in size — up to the normal suborder amount.

  • TWAPs aim to minimize market impact and slippage during execution.

Use when: You need to execute large trades discreetly or avoid moving the market.


Execution Instructions (coming soon)

Reduce Only

Ensures the order can only reduce or close an existing position. If placing the order would open a position in the opposite direction, it will be rejected.

Good-Til-Cancel (GTC)

The default resting order type. Remains active until it’s fully filled or manually canceled.

Immediate or Cancel (IOC)

Executes all or part of an order immediately; any unfilled portion is canceled. Useful for quick fills without resting on the book.

Post Only (Add Liquidity Only, ALO)

Adds liquidity to the order book but does not execute immediately. If the order would fill instantly, it is automatically canceled.


Matching and Settlement

The order book works like a traditional exchange, but settlement is fully onchain.

Orders are matched and prioritized as follows:

  1. Price Priority: Best price executes first (highest bid, lowest ask).

  2. Time Priority: Among orders at the same price, the earliest placed order executes first.

All prices and quantities must conform to the asset’s tick size.


Matching Process

Each order passes a margin check before placement. When a trade occurs:

  • Both maker and taker margins are verified in real-time.

  • The clearing engine updates account balances, positions, and unrealized PnL instantly.

  • Funding payments and fees are applied automatically at the next settlement interval.

  • If both sides belong to the same address, self-trade prevention cancels the resting order instead of producing a fill. See Self-trade Prevention.

This ensures consistent margining and settlement even during high volatility or rapid order flow.


Execution Flow

  1. Orders are submitted and validated.

  2. Margin is checked for sufficient collateral.

  3. Orders enter the book and are sorted by price-time priority.

  4. Matches are executed atomically.

  5. Results are final — all trades are settled onchain with deterministic finality within the same transaction.

Last updated