Available Order Types
TWAP (Time-Weighted Average Price)
Split a large order into smaller parts executed at fixed intervals to minimize price impact and achieve better average execution prices.TWAP Orders
Execute orders in scheduled parts over a specified time period
- Large trades that need to be split over time
- Reducing price impact on low-liquidity pairs
- Dollar-cost averaging strategies
Stop Loss
Automatically trigger a sell order when the price of a token falls below a specified threshold, protecting against further losses.Stop Loss Orders
Protect positions with oracle-based price triggers
- Risk management and loss prevention
- Automated exit strategies
- Portfolio protection during volatile markets
Good After Time
Schedule orders to become valid only after a specific timestamp, with optional price validation using Milkman price checkers.Good After Time Orders
Delay order execution until a specified time
- Time-locked trading strategies
- Scheduled rebalancing
- Post-event trading (e.g., after token unlocks)
Perpetual Stable Swap
Maintain a balanced position between two stablecoins by automatically trading whichever token has the higher balance back to the other.Perpetual Stable Swap
Automatically rebalance between two stablecoins
- Liquidity provision with rebalancing
- Earning spread on stablecoin pairs
- Maintaining balanced dual-token positions
Trade Above Threshold
Automatically sell tokens whenever your balance exceeds a specified threshold, useful for regular conversions or yield harvesting.Trade Above Threshold
Execute trades when token balance exceeds a limit
- Automated yield harvesting
- Regular conversions of earned tokens
- Threshold-based portfolio management
Order Type Characteristics
| Order Type | Repeatable | Requires Oracle | Partial Fill Support |
|---|---|---|---|
| TWAP | Yes (multiple parts) | No | No |
| Stop Loss | No (one-time) | Yes (Chainlink) | Optional |
| Good After Time | Yes (via buyAmount) | Optional (Milkman) | Optional |
| Perpetual Stable Swap | Yes (continuous) | No | No |
| Trade Above Threshold | Yes (continuous) | No | No |
Implementation
All order types inherit fromBaseConditionalOrder and implement the getTradeableOrder function:
Parameters
The address that owns the conditional order
The address that triggered the order (often unused)
Context hash for the order (used for state management)
ABI-encoded order parameters specific to each order type
Dynamic data provided by off-chain watchers (optional, order-type dependent)
Error Handling
Conditional orders can revert with specific errors to indicate order status:OrderNotValid(string)- Order conditions are not met and will never be validPollTryNextBlock(string)- Order is temporarily invalid, try again in the next blockPollTryAtEpoch(uint256, string)- Order will be valid at a specific timestamp
Each order type has its own set of validation rules and error messages. See individual order type pages for details.