Create a DCA order
Order Parameters
Detailed explanation of all DCA order parameters and their validation rules
Order Parameters
Understanding order parameters is crucial for creating effective DCA strategies. This guide covers all parameters, their ranges, and best practices.
Required Parameters
Token Parameters
tokenIn
- Type: Address
- Description: The token you're selling/spending
- Special Value:
address(0)for native ETH (use withcreateOrderNative) - Validation: Must be active in protocol
tokenOut
- Type: Address
- Description: The token you're buying/accumulating
- Validation: Must be active and different from tokenIn
recipient
- Type: Address
- Description: Beneficiary who can claim funds from the vault
- Note: Can be different from order creator
- Rights:
- Can withdraw/claim tokenOut from vault anytime
- Receives remaining tokenIn on cancellation
- Receives accumulated tokenOut on cancellation
- Benefits from all earned yield
- Is the beneficial owner of all order funds
Economic Parameters
spendAmount
- Type: uint256
- Description: Amount of tokenIn to spend per execution
- Minimum: Must meet minimum execution value (~$1 USD)
- Total Deposit:
spendAmount × repeats - Example: 100 USDC =
100000000(6 decimals)
repeats
- Type: uint256
- Description: Number of times to execute the order
- Minimum: 1
- Maximum: No limit (practical limit based on total deposit)
- Behavior: Decrements with each fill, order completes at 0
slippage
- Type: uint256
- Description: Maximum acceptable price deviation in basis points
- Range: Protocol defined (0-2500 BP)
- Example: 100 = 1% slippage
- Impact: Higher slippage = better chance of fills
Timing Parameters
freqInterval
- Type: uint256
- Description: Time between order executions (seconds)
- Minimum: Protocol defined (typically 30 seconds)
scalingInterval
- Type: uint256
- Description: Time window for Dutch auction price improvement
- Formula:
scalingInterval <= min(freqInterval / 2, maxScalingInterval) - Protocol Maximum: 300 seconds (5 minutes) - configured at deployment
firstExecution
- Type: uint256
- Description: Delay before first execution (seconds)
- Behavior:
0: First execution atblock.timestamp + freqInterval> 0: First execution atblock.timestamp + firstExecution
- Use Case: Schedule future start times
Yield Parameters
stakeAssetIn
- Type: bool
- Description: Whether to stake input tokens in Aave
- Requirements: Token must be Aave reserve
- Benefits: Earn yield on unspent funds
- Considerations: Respects Aave supply caps
stakeAssetOut
- Type: bool
- Description: Whether to stake output tokens in Aave
- Requirements: Token must be Aave reserve
- Benefits: Compound returns on accumulated tokens
- Considerations: May affect liquidity
The Scaling Factor Mechanism
The scaling mechanism creates a Dutch auction for order execution:
Time Since Executable → Asset Ratio → Filler Incentive
0 seconds → TokenIn +X% above market → Worst for filler
T/2 seconds → TokenIn at market price → Fair execution
T seconds → TokenIn -X% below market → Best for filler
Where X = slippage percentage and T = scalingIntervalHow It Works
// Price adjustment formula
adjustedTokenInPrice = tokenInPrice * (BASIS_POINTS + slippage - scalingFactor) / BASIS_POINTS
// scalingFactor increases linearly from 0 to (2 × slippage) over scalingIntervalThis mechanism:
- Starts expensive for fillers (protecting users from MEV)
- Gradually improves for fillers over time
- Ensures competitive execution near market rates
Next Steps
- Ready to create an order? See Creating Your First Order
- Review the API Reference for integration
- Check the Core Concepts for deeper understanding