Security & Deployment
Security Considerations
Access Control
Critical functions are restricted to specific roles (Owner, Maintainer) to prevent unauthorized changes to system parameters.
Attack Mitigation
- Reentrancy: Both contracts use OpenZeppelin’s
ReentrancyGuardmodifier on all state-changing external functions to prevent reentrancy via token callbacks. - Price Manipulation:
- Slippage Protection: User-specified
minAmountOutprevents execution at unfavorable prices. - Price Verification: Limit price is validated against actual execution price after fees.
- Slippage Protection: User-specified
- Fee Underflow Prevention: Total fees (protocol + bot) are capped at 100% (10,000 basis points).
- Adapter Validation: All adapters are validated through a whitelist before any interaction.
Emergency Procedures
The LimitOrderEscrow contract includes emergency pause functionality:
pause(): Immediately stops all order creation and execution.unpause(): Resumes normal operations.
Order cancellation remains available during pause to allow users to withdraw their funds.
Deployment Guide
Router Deployment
Requires setting up the initial owner and maintainer addresses.
Limit Order Deployment
Requires the address of the deployed Router and Fee Collector addresses.
Post-Deployment Configuration
- Configure Stable Tokens: Call
addStableTokens()onLimitOrderEscrowwith stablecoin addresses. - Authorize Initial Bots: Call
authorizeBot()for each bot address that will execute orders. - Verify Fee Collectors: Ensure
feeCollectorandbotCollectoraddresses are correctly configured.
Gas Optimization
- Dust Handling: Last hop/split receives remaining amount to avoid precision loss.
- O(1) Lookups:
isTrustedAdapterandauthorizedBotsmappings provide constant-time validation. - Immutable Variables: Used for addresses that never change to save gas.