1 min read

Self-trade prevention

Self-trade prevention stops your own orders from matching against each other. It mostly matters for market makers who keep both bids and offers on the same book.

Why it matters

If your own buy order matched your own sell order, you'd pay fees on both sides for moving USDC from one pocket to the other. The result is a real on-chain trade with no economic value to you and a real fee charged by the platform.

How it works

Self-trade prevention is always on and applies to every order, from the web panel or the API. When your new order would match one of your own resting orders (same wallet, or another wallet linked to the same account), the matcher skips that resting order and keeps matching against everyone else's. Neither order is cancelled.

API orders (for bots and market makers)

There is no mode to choose. A non-empty stp_mode on an API order is rejected. Designated market makers quoting both sides of a book use an API key with the allow_self_trade flag, which turns the skip off.

See the API reference for order types for the exact request schema.

Negative cases

  • Different accounts - STP only triggers when both orders are on the same account. If you trade from two different addresses, they're separate accounts as far as STP is concerned.
  • Different markets - STP is per-market. A buy on market A and a sell on market B never cross.

Was this article helpful?

Your feedback helps us improve our docs.