> For the complete documentation index, see [llms.txt](https://world-book.gitbook.io/worldbook/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://world-book.gitbook.io/worldbook/spot-trading/self-trade-prevention.md).

# Self-trade Prevention

Self-trade protection (STP) prevents you from trading against your own orders, helping you avoid unnecessary fees and maintain your position in the order book.

## Why Use Self-Trade Protection?

Without STP, you might accidentally:

* Match your own orders and pay fees on both sides
* Lose your queue priority in the order book
* Create wash trades that don't represent real market activity
* Waste gas on trades that don't change your net position

## STP Modes

### 🚫 NONE

* **Behavior**: Allows self-trades without any restrictions
* **Use case**: When you specifically want to allow trading against your own orders
* **Effect**: Orders from the same address can match against each other

### ⚠️ EXPIRE\_MAKER (default)

* **Behavior**: Cancels your resting maker order when a self-trade would occur
* **Use case**: When you want your new taker order to have priority
* **Effect**:
  * Your existing maker order is cancelled and remaining collateral is refunded (for buy orders, remaining quote refund is derived from filled×price rather than any persisted quote-filled tracker)
  * Your new taker order continues to match against other orders in the book
  * You avoid paying fees on self-trades

### ⏭️ SKIP

* **Behavior**: Skips over your own orders during matching
* **Use case**: When you want to preserve all your orders in the book
* **Effect**:
  * Both orders remain active
  * The matching engine skips your own orders and continues to the next best price
  * You maintain your queue position for both orders

## How It Works

When you place an order, the matching engine checks if any potential matches are from the same address. Based on your STP setting:

1. **NONE**: Proceeds with the match normally
2. **EXPIRE\_MAKER**: Removes your maker order and continues matching
3. **SKIP**: Ignores your order and looks for the next best match
