Documentation Index
Fetch the complete documentation index at: https://mintlify.com/cowprotocol/flash-loan-router/llms.txt
Use this file to discover all available pages before exploring further.
Security Principles
The Flash-Loan Router is designed with security as the primary concern. The architecture ensures that solvers maintain complete control over settlement execution while preventing unauthorized access and malicious interference.Solver Control
Only registered solvers can execute settlements
Data Integrity
Settlement data cannot be tampered with during execution
Execution Guarantees
One call results in exactly one settlement
Reentrancy Protection
State management prevents concurrent execution
Router Security
Solver Authentication
Only registered CoW Protocol solvers can use the router:src/FlashLoanRouter.sol
Authentication Source: The router queries the same authentication contract used by the CoW Settlement contract, ensuring consistency across the protocol.
Authentication Properties
Solver registry is managed by CoW Protocol governance
Router cannot authenticate itself as a solver
Authentication is checked before any state changes
Failed authentication reverts immediately
Execution Control
The router guarantees strict execution properties:src/FlashLoanRouter.sol
Key Guarantees
Single Settlement Per Call
Single Settlement Per Call
Each call to The
flashLoanAndSettle results in exactly one call to settle():SETTLING state is only reachable through the settlement path, and the final check verifies it was reached.Immutable Settlement Data
Immutable Settlement Data
Settlement call data cannot be modified after Any tampering causes immediate revert.
flashLoanAndSettle is called:src/FlashLoanRouter.sol
Sequential Loan Processing
Sequential Loan Processing
Loans are processed in the exact order specified:Out-of-order execution is impossible and causes transaction revert.
src/FlashLoanRouter.sol
Settlement Function Validation
Settlement Function Validation
Only the Attempts to call other functions are rejected.
settle() function can be called:src/FlashLoanRouter.sol
Reentrancy Protection
The router uses state-based reentrancy protection:src/FlashLoanRouter.sol
Protection Mechanism
Borrower Security
Access Control
Borrowers enforce strict access control:Fund Protection
Borrowers protect borrowed funds through controlled access:src/mixin/Borrower.sol
Fund Security: The only way to access funds in a borrower is through ERC-20 approvals, which can only be set by the settlement contract during authorized execution.
Security Properties
External callers cannot set approvals
Funds cannot be transferred without settlement approval
Approvals can only be set during active settlement
Unused approvals don’t pose security risks
Unauthorized Access Impact
Borrowers are designed to be resilient against unauthorized access:No Impact on Adapter Functionality
Unauthorized external calls to borrowers cannot:
- Impair their ability to act as adapters
- Modify expected contract behavior
- Access or steal borrowed funds
- Disrupt the router’s execution flow
Threat Model
Protected Against
The system provides strong protection against:Unauthorized Settlement Execution
Unauthorized Settlement Execution
Settlement Data Tampering
Settlement Data Tampering
Threat: Malicious borrowers or lenders modifying settlement dataProtection: Hash verification at each callbackResult: Any data modification causes transaction revert
Reentrancy Attacks
Reentrancy Attacks
Threat: Malicious contracts attempting nested settlementsProtection: State-based execution control via
pendingBorrowerResult: Reentrancy attempts fail the READY checkOut-of-Order Execution
Out-of-Order Execution
Threat: Borrowers calling back in wrong orderProtection:
onlyPendingBorrower modifierResult: Only expected borrower can call back at each stepUnauthorized Fund Access
Unauthorized Fund Access
Multiple Settlement Calls
Multiple Settlement Calls
Threat: Single call attempting multiple settlementsProtection: State transitions and final state verificationResult: Exactly one settlement per call, enforced by state machine
Risk Factors
While user funds remain secure, solvers face risks from malicious participants:Risk Mitigation: Assuming trusted tokens, lenders, and borrowers, risks are comparable to normal settlement execution. Solvers should:
- Only use reputable flash loan providers
- Verify borrower contract implementations
- Use appropriate slippage protections
- Monitor for abnormal provider behavior
Trust Assumptions
The security model makes explicit trust assumptions:Trusted Components
CoW Protocol
- Settlement contract
- Authentication contract
- Solver registry
Router System
- FlashLoanRouter contract
- Borrower adapter contracts
- Deployment addresses
External Components
The following are external and require solver due diligence:Security Best Practices
For solvers using the router:Verify Contract Addresses
Always use official deployment addresses:
- FlashLoanRouter:
0x9da8B48441583a2b93e2eF8213aAD0EC0b392C69 - AaveBorrower:
0x7d9C4DeE56933151Bc5C909cfe09DEf0d315CB4A - ERC3156Borrower:
0x47d71b4B3336AB2729436186C216955F3C27cD04
Use Reputable Providers
Only request flash loans from well-known, audited providers like Aave and Maker
Implement Slippage Protection
Include appropriate slippage checks in settlement logic to protect against state manipulation
Maintain Approvals
Set unlimited approvals once for settlement contract to borrowers, reducing per-transaction gas costs
Audit Status
The Flash-Loan Router contracts have been designed with security as the primary focus:For the latest audit reports and security updates, refer to the CoW Protocol documentation and GitHub repository.
Next Steps
Router Design
Understand the execution flow
Quick Start
Start building with the router