Order Types
Understanding CoW Protocol order kinds and execution modesOverview
CoW Protocol supports different order types to accommodate various trading strategies. Understanding these types is essential for building effective trading applications.Order Kind
Every order has akind that determines whether you’re specifying the exact sell or buy amount:
SELL Orders
A sell order specifies the exact amount of tokens you want to sell.sellAmountis the exact amount you’re sellingbuyAmountis the minimum amount you’ll accept- The actual execution may give you more than
buyAmount(positive slippage)
BUY Orders
A buy order specifies the exact amount of tokens you want to receive.buyAmountis the exact amount you’re buyingsellAmountis the maximum amount you’ll spend- The actual execution may cost less than
sellAmount(positive slippage)
Execution Modes
Orders can be configured as either fill-or-kill or partially fillable:Fill-or-Kill Orders
A fill-or-kill order must be executed entirely in a single settlement or not at all.- You need the entire order executed atomically
- Trading smaller amounts where partial fills aren’t practical
- You want predictable, all-or-nothing execution
Partially Fillable Orders
A partially fillable order can be executed across multiple settlements until the full amount is filled or the order expires.- Trading large amounts that might be hard to fill at once
- You want to capture liquidity as it becomes available
- Building limit orders that execute over time
Swap Orders vs Limit Orders
Swap Orders (Market Orders)
Swap orders execute immediately at the best available price with slippage protection.- Execute at current market conditions
- Have slippage tolerance (e.g., 0.5%)
- Typically fill-or-kill
- Short validity period (e.g., 20 minutes)
- Class:
"market"
Limit Orders
Limit orders execute only when your specified price is met or exceeded.- Execute at your specified limit price or better
- No slippage tolerance
- Can be partially fillable
- Longer validity period (hours to days)
- Class:
"limit"
Order Parameters
All orders share these core parameters:| Parameter | Type | Required | Description |
|---|---|---|---|
sellToken | string | Yes | Address of the token being sold |
buyToken | string | Yes | Address of the token being bought |
sellAmount | string | Yes | Amount of sell token (in wei/smallest unit) |
buyAmount | string | Yes | Amount of buy token (in wei/smallest unit) |
validTo | number | Yes | Unix timestamp when the order expires |
appData | string | Yes | 32-byte hash of order metadata. See App Data |
feeAmount | string | Yes | Protocol fee amount in sell token |
kind | OrderKind | Yes | Order kind: OrderKind.SELL or OrderKind.BUY |
partiallyFillable | boolean | Yes | Whether the order can be partially filled |
receiver | string | No | Address to receive the bought tokens (defaults to order owner) |
sellTokenBalance | OrderBalance | No | How to withdraw sell tokens: erc20, external, or internal (Balancer Vault) |
buyTokenBalance | OrderBalance | No | How to receive buy tokens: erc20 or internal (Balancer Vault) |
Token Balance Sources
Orders can interact with different token balance sources:ERC20 Balance (Default)
Balancer Vault Balances
For advanced use cases with Balancer Vault integration:Most applications use the default
ERC20 balance mode. Balancer Vault integration is for advanced scenarios.Order Lifecycle
Practical Examples
Best Practices
Use SELL for Market Orders
Most users know how much they want to sell. Use
OrderKind.SELL for simpler UX.Set Reasonable Validity
Market orders: 10-30 minutes. Limit orders: hours to days based on volatility.
Partial Fills for Large Orders
Enable
partiallyFillable: true for large orders to improve fill rates.Monitor Order Status
Poll the OrderBook API to track order status and fills over time.