# Market Structure & Order Execution

<figure><img src="/files/fM1Z3qs5iX3nS3vUJ8aM" alt=""><figcaption></figcaption></figure>

BasePerp executes orders at an oracle-referenced price and applies capacity/safety checks that protect both users and the unified stablecoin vault. This section explains how orders behave on-chain, how prices are validated, and how operational costs are handled.

### 3.1 Order Types

Order types are scoped to cover common workflows without expanding risk unintentionally. Each type respects margin rules and enforcement via CHR.

1. **Market.** Executes immediately at the oracle price provided that the deviationGuard condition holds and per-market capacity is available.
2. **Limit**. Triggers when the oracle crosses the limit level; supports reduce-only to avoid increasing exposure.
3. **Stop-Market**. Becomes a market order once the stop is reached; typically used for SL or momentum entries.
4. **Take-Profit**. Closes part or all of a position at a target; can be combined with reduce-only.
5. **Partial fills & TIF**. Orders may fill in tranches; unfilled remainders expire after a market-specific time-in-force.

### 3.2 Oracle-Based Pricing & Deviation Guards

Execution references a primary oracle price that must be consistent with an independent secondary feed. If the relative difference breaches deviationGuard, the transaction reverts; if feeds are stale, new executions pause while cancels/withdrawals remain available.

* **Execution rule**. Use the primary price only when the relative deviation to the secondary feed is within the configured deviationGuard band.
* **Per-asset tuning**. Markets define their own deviationGuard and heartbeat thresholds; ranges can widen/narrow via time-boxed, rule-based schedules.
* Volatility & liveness failsafes. On stale, missing, or out-of-band data, trading actions that add risk pause; safe actions (cancel, withdraw) continue.

### 3.3 Keeper Fees & Gas Abstraction

Operational work (upkeeps, liquidations) is performed by permissionless keepers so that response times remain competitive without embedding gas risk in trading fees.

* **Open keeper set**. Any actor can run keepers; competition improves execution latency and availability.
* **Dynamic keeper fee**. A small fee covers gas and scales with network conditions; parameters are disclosed per market.
* **Interaction with ZFC**. Under Zero Fixed Commissions, traders pay no fixed open/close fees; only a profitFeeRate applies on profitable closes, plus the minimal keeper fee.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://baseperp.gitbook.io/baseperp-whitepaper/technical-architecture/market-structure-and-order-execution.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
