For the complete documentation index, see llms.txt. This page is also available as Markdown.

Order Matching

AFX uses a central limit order book (CLOB) matching engine with on-chain verifiable settlement.

Matching Rules

Orders are matched using price-time priority:

  1. Price priority — The best priced orders are matched first. Buy orders at higher prices and sell orders at lower prices have priority.

  2. Time priority — Among orders at the same price, earlier orders are matched first.

When a buy price ≥ sell price, the orders are matched. The trade executes at the maker's price (the price of the resting order in the book).

Last Traded Price

The Last Price is determined by the first trade in the order book — the intersection of the highest buy price and the lowest sell price.

Self-Trade Prevention (STP)

AFX implements platform-level self-trade prevention. Self-trades are detected and blocked automatically.

Detection criteria:

  • Both orders originate from the same user's contract address.

  • A new taker order enters at a price that would match against the user's own resting maker order.

Handling: Cancel Newest — The incoming taker order is rejected (not matched) if it would result in a self-trade. The existing maker order in the book remains unchanged. This approach maintains order book stability and is compatible with on-chain verification.

Last updated