TWAP Orders
TWAP (Time-Weighted Average Price) orders enable splitting large trades into multiple smaller executions at fixed intervals, helping reduce price impact and achieve better average prices.
Core Structure
The TWAP mechanism divides a total trade into n equal parts executing every t seconds, with each part having a validity window defined by the span parameter.
Key Parameters
Validation Requirements
Orders must satisfy:
- Different sell and buy tokens
- Non-zero addresses
partSellAmount > 0
minPartLimit > 0
n between 2 and type(uint32).max
t between 1 and 365 days
span must be less than or equal to t
Validity Window Calculation
With span = 0, each part remains valid until the next part begins. When span > 0, validity is restricted to that duration. This ensures unique order identifiers preventing duplicate executions.
Error Conditions
Implementation
The contract resides at /src/types/twap/TWAP.sol. Key functions include:
getTradeableOrder() - Retrieves the current executable part
orderFor() - Constructs the CoW Protocol order with calculated validity timestamps
Last modified on March 4, 2026