# Integrating the f(x) limit orders

For users of the f(x) protocol, **Limit Orders** are a critical feature. By allowing position management at a fixed rate, limit orders eliminate slippage and reduce exposure to market-price uncertainty — a benefit that is especially valuable for large-size orders and systematic strategy executors. In addition, the introduction of **take-profit / stop-loss** orders enables the reliable automation of many trading strategies that would otherwise be impractical on an entirely market-priced execution model.

### 1. Components

#### 1.1 Smart contracts

We introduce the `LimitOrderManager` family of smart contracts to implement limit-order functionality. These contracts allow orders to be filled on-chain while simultaneously operating the corresponding position (open/close/adjust), ensuring atomic and auditable execution.\
\
For more details, please read the [LimitOrder contracts](https://fxprotocol.gitbook.io/fx-docs/developers/integrating-the-f-x-limit-orders/limitordermanager-contracts) section.

#### 1.2 Limit order API services

A dedicated API/relayer service is provided to help users broadcast and discover signed orders. Users sign orders off-chain and submit the order plus signature to the API, which acts as an order-relay and discovery layer for counterparties.

For more details, please read the [LimitOrder APIs](https://fxprotocol.gitbook.io/fx-docs/developers/integrating-the-f-x-limit-orders/limit-order-apis) section.

#### 1.3 Front-end

For retail or non-technical users, the standard f(x) front-end provides UI flows to create, submit and monitor limit orders and TP/SL orders, abstracting away the underlying contract interactions and relayer details.

### 2. Integration flow (high level)

1. **Maker** creates and signs an order off-chain (locally).
2. The maker submits the signed order to the Limit Order API / relayer (optional).
3. A **Taker** discovers the order (via the API or other discovery means) and fills it on-chain by calling `LimitOrderManager`. The on-chain fill is executed atomically and operates the associated position.

{% hint style="info" %}
Note: The API/relayer is optional — it's allowed to call the `LimitOrderManager` directly to fill orders on-chain.
{% endhint %}

{% hint style="info" %}
⚠️ **Note:** Once an order is signed, it can only be canceled on-chain (by sending an on-chain cancel transaction) to prevent it from being filled.
{% endhint %}

***
