Skip to main content

TWAP API

TWAP (Time-Weighted Average Price) orders split transactions into multiple parts executed at regular intervals, helping traders achieve better average prices.

Key Parameters

ParameterTypeDescription
sellTokenIERC20Token being sold
buyTokenIERC20Token being purchased
receiveraddressRecipient of bought tokens
partSellAmountuint256Amount per execution part
minPartLimituint256Minimum buy amount per part
t0uint256Start timestamp (0 for dynamic from cabinet)
nuint256Number of parts
tuint256Interval between parts (seconds)
spanuint256Validity window per part
appDatabytes32IPFS metadata hash

Core Function

The getTradeableOrder() function returns the currently executable order portion. It:
  1. Decodes input data
  2. Retrieves the start time if needed from protocol storage
  3. Generates the appropriate order for the present moment
  4. Confirms it remains within valid timeframes

Validation Requirements

Orders fail validation when:
  • Tokens are identical
  • Either token is zero-addressed
  • Sell amounts equal zero
  • Price limits are zero
  • Timing parameters exceed allowed ranges
  • span exceeds interval frequency
  • Execution windows have expired
The system ensures each order segment has a unique identifier, preventing accidental duplicate settlements.

Technical Notes

  • TWAP orders function as non-partial sells with zero fees
  • The protocol itself manages fee distribution
  • Each execution segment receives its own expiration timestamp, creating distinct order identifiers across the entire sequence
Last modified on March 4, 2026