> For the complete documentation index, see [llms.txt](https://baseperp.gitbook.io/baseperp-whitepaper/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://baseperp.gitbook.io/baseperp-whitepaper/technical-architecture/market-structure-and-order-execution.md).

# 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.
