TWAP Orders
Overview
Time-Weighted Average Price (TWAP) orders split large trades into smaller parts executed at regular intervals, reducing price impact and helping achieve better average execution prices.Installation
Creating TWAP Orders
Basic Implementation
Core Parameters
Optional Parameters
Start Time Options:AT_MINING_TIME(default): Begins when transaction minesAT_EPOCH: Begins at specific timestamp
AUTO(default): Each part valid for entire intervalLIMIT_DURATION: Each part expires after specified duration
Advanced Configuration
Custom Start Time
Limited Part Duration
Validation
- InvalidSameToken
- InvalidToken
- InvalidSellAmount
- InvalidMinBuyAmount
- InvalidStartTime
- InvalidNumParts
- InvalidFrequency
- InvalidSpan
- InvalidData
Complete Setup Example
Order Lifecycle
- Creation: Configure TWAP parameters
- Merkle Root: Set root on ComposableCoW contract
- Proof Storage: Store proofs off-chain for watchtowers
- Monitoring: Watchtowers monitor execution conditions
- Part Execution: Each part executes at scheduled time
- Completion: All parts execute or order expires
Monitoring TWAP Progress
Serialization
Best Practices
Interval Selection: ChoosetimeBetweenParts based on liquidity, volatility, and execution timeline. Common intervals: 5 minutes (300s), 15 minutes (900s), 1 hour (3600s), 1 day (86400s).
Part Count: Usually 10-50 parts depending on total amount balances efficiency with complexity.
Duration Strategy: Use AUTO for flexibility or LIMIT_DURATION set to 50-80% of interval for safety.
Execution Tracking: Monitor parts executed, average price, slippage per part, and failed orders.