# Exchange Trading Features

## Spot Markets

### Market Creation and Instant Launch

* **Governance Creation:** Curated listings deployed via a formal `MsgCreateSpotMarket` proposal.
* **Instant Launch:** A permissionless pathway (`MsgInstantSpotMarketLaunch`) where users can pay a configured network listing fee to instantly activate a market.

### Order Execution and Time-in-Force Semantics

* **Market Orders:** Execute immediately against the best available liquidity. Require a user-defined "worst price" bound to protect against unbounded slippage.
* **Limit Orders:** Support explicit `TimeInForce` parameters:
  * **GTC (Good-Till-Cancelled):** The order rests on the orderbook until completely filled or manually cancelled.
  * **IOC (Immediate-Or-Cancel):** The order matches immediately; any unfilled remaining quantity is instantly cancelled.
  * **FOK (Fill-Or-Kill):** The entire quantity must be filled at the limit price or better, or the entire order is rejected.

### Maker Protection (Post-Only Enforcement)

A per-order `is_post_only` flag guarantees the order will only add liquidity to the book. A market-level `enforce_post_only` mode can be toggled by governance to strictly disallow market orders. Post-only flags are mutually exclusive with IOC/FOK instructions.

### Conditional Order Engine

Advanced trading primitives — including `STOP_LOSS`, `TAKE_PROFIT`, `STOP_LIMIT`, and `TRAILING_STOP` — are evaluated deterministically at the start of every block during the `BeginBlocker` phase.

## Derivatives Markets

### Margin Accounting and Risk Limits

Derivative order placement enforces strict margin requirements prior to execution. Positions are tracked deterministically per `(subaccount_id, market_id)`. The protocol enforces critical risk limits during order creation, including open notional caps and market-wide open interest checks. The `reduce_only` flag guarantees an order can only decrease or close an existing position.

### Perpetual Funding Rate Mechanism

$$Premium = \frac{MarkPrice - IndexPrice}{IndexPrice}$$

The final calculated rate is strictly clamped to a bounded range defined by the market parameters before being applied to all active positions.

### Automated Liquidation Engine

When a position's margin falls below the maintenance threshold, the automated liquidation engine (executed during the `EndBlocker`) uses a risk-index candidate selection approach, processing only the most critical underwater positions within a strict per-block budget.

### TWAP-Based Settlement for Expiry Futures

Once an Expiry Future market reaches its predefined `expiry_timestamp`, settlement is triggered during the `BeginBlocker`. The primary settlement price is resolved via an Oracle TWAP taken over an immutable settlement window. Upon successful settlement, the market transitions permanently to a `DEMOLISHED` state.

## Binary Options

Binary Options represent event-driven, probability-based markets where traders speculate on specific, bounded outcomes.

### Margin Requirements

Because binary options have absolute bounded payouts, the protocol enforces a strict pricing invariant where *P ∈ \[0, 1]*:

* **Long (YES) Margin:** *Margin = P × Q*
* **Short (NO) Margin:** *Margin = (1 − P) × Q*

### Lifecycle State Machine

Binary markets follow a strict state machine processed during the `BeginBlocker`:

1. **Trading (ACTIVE):** Orders are matched and positions are accumulated.
2. **Expiration (PAUSED):** Triggered when the current block time exceeds `expiration_timestamp`. Trading is instantly halted and all resting orders are cancelled.
3. **Settlement (DEMOLISHED):** Triggered when the `settlement_timestamp` is reached. The protocol retrieves the Oracle outcome, resolving the market to a definitive 0 or 1. Payouts are distributed and the market is closed.


---

# 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://uniocean.gitbook.io/uniocean-docs/exchange-trading-features.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.
