Skip to main content

Overview

Limit orders let you specify both the sell and buy amounts, creating an order that only executes at your desired price or better. Unlike the swap_tokens function which gets a market quote, limit orders give you precise control over the exchange rate.
Limit orders remain in the order book until filled, cancelled, or expired. Set valid_to to control how long the order stays active.

Prerequisites

Before creating limit orders, ensure you have:

Basic Limit Order

To create a limit order, construct an Order with explicit sell_amount and buy_amount, sign it, and submit it to the OrderBook API:

Calculating Limit Prices

The limit price is determined by the ratio of sell_amount to buy_amount. You specify both amounts explicitly:
Price calculation:
  • Limit price = buyAmount / sellAmount (in token units, adjusted for decimals)
  • The order fills only when the market reaches your price or better

Order Kinds

Sell orders guarantee you receive at least the specified buy_amount for your sell_amount:
Use case: “I want to sell 1 WETH and receive at least 3000 USDC”

Using a Quote as Price Reference

You can fetch a market quote first and adjust the price to set your limit:

Partially Fillable Orders

For large orders, enable partial fills to allow incremental execution:
Partially fillable orders may execute in multiple transactions over time. Use the OrderBookApi to track fill progress.

When Will My Order Fill?

Limit orders fill when the market price reaches your specified rate or better. Unlike swap_tokens which executes immediately at the current market price, limit orders may take hours, days, or never fill if the market doesn’t reach your target. Behind the scenes, solvers continuously check whether your order is profitable to execute. Once the on-chain price moves to meet (or beat) your limit, a solver will include your order in a batch and settle it.
Fetch a market quote with api.post_quote() to see the current price before placing your limit order. This helps you set a realistic limit relative to where the market is right now. See Using a Quote as Price Reference above.

Monitoring Your Order

After submitting a limit order, you can check its status at any time:
The status field will be one of:
  • open — the order is active and waiting to be filled
  • fulfilled — the order has been completely filled
  • cancelled — the order was cancelled by the owner
  • expired — the order passed its valid_to timestamp without being filled
For partially fillable orders, inspect executedSellAmount and executedBuyAmount to see how much has been filled so far:
To cancel an open order:
For the full set of order management operations, see Managing Orders.

Custom App Data

Add metadata to identify your application or configure partner fees:
See the App Data guide for advanced metadata options including partner fees and order class configuration.

Comparing Swap vs Limit Orders

Best Practices

  1. Set realistic prices — orders too far from market may never fill
  2. Use valid_to wisely — set appropriate expiration for your strategy
  3. Consider partial fills — for large orders, partial fills improve execution
  4. Monitor order status — check if your order has been filled or partially filled using Managing Orders
  5. Token approvals — ensure the Vault Relayer has sufficient allowance before submitting

Troubleshooting

Next Steps

  • Learn about Managing Orders to track and cancel limit orders
  • Explore TWAP Orders for time-weighted average price execution
  • See App Data for custom metadata and partner fees
Last modified on March 17, 2026