Agara

Self-Trade Prevention

How the engine prevents an account from matching against its own resting orders.

The matching engine rejects any fill where the maker and taker would be the same account. This is enforced unconditionally — no opt-in or opt-out.

What happens on a self-match

When an incoming taker order would match a resting maker order owned by the same account:

  1. The maker order is cancelled (the resting order is removed from the book).
  2. A cancelled BUY releases its reserved buying capacity; a cancelled SELL unlocks its outcome tokens.
  3. An account stream order_cancelled event is emitted with reason SELF_TRADE_PREVENTION.
  4. The taker order continues matching against the next eligible resting order, if any. It is not itself cancelled.

This means a taker order that would have matched only your own resting orders effectively cancels those resting orders and then rests on the book (if the time-in-force allows) or expires.

A FOK order is checked against non-self liquidity before the book changes. If there is not enough to fill the complete order, the FOK is rejected and your resting orders remain in place.

Implications

  • You will never pay a fee to yourself.
  • A self-match never produces a fill — it never appears in your trade history and never contributes to trading-volume metrics.
  • If you maintain orders on both sides of the book at overlapping prices, an aggressive order from your account will cancel the resting side first before reaching the rest of the book.

How to detect it programmatically

The order_cancelled event on the account stream carries reason = "SELF_TRADE_PREVENTION". Treat this the same as any other cancellation: the resting order is gone, and you may re-place it if needed.

On this page