Overview
TheFlashLoanRouter is a solver contract that coordinates flash loans with CoW Protocol settlements. It serves as the central entry point for requesting flash loans and executing settlements atomically.
The router manages three primary actors:
- Solvers: Initiate settlements with flash loan specifications
- Borrower contracts: Adapt protocol-specific flash loan mechanics
- Settlement contract: Executes the final CoW Protocol settlement
Contract Details
- Source:
src/FlashLoanRouter.sol - License: GPL-3.0-or-later
- Solidity: ^0.8.28
- Address:
0x9da8B48441583a2b93e2eF8213aAD0EC0b392C69(all networks)
State Variables
Immutable
Transient Storage
Functions
flashLoanAndSettle
loans: Array of flash loan specifications (amount, token, lender, borrower)settlement: ABI-encoded call data forsettle()on the CoW Settlement contract
- Caller must be a registered solver
- No other settlement can be in progress
- Settlement data must encode a valid
settle()call
Settlement(address solver)
borrowerCallBack
loansWithSettlement: Encoded remaining loans and settlement data (must match stored hash)
- Caller must be the expected pending borrower
- Data hash must match the stored
pendingDataHash
settlementContract (view)
settlementAuthentication (view)
Events
Settlement
Modifiers
onlySolver
Restricts function access to registered CoW Protocol solvers verified through the settlement authenticator.onlyPendingBorrower
Restricts callback access to the borrower contract that the router is currently expecting a callback from.Security
- Reentrancy prevention:
pendingBorrowertransient storage prevents concurrent settlements - Data integrity: Hash comparison validates callback data has not been tampered with
- Settlement validation: Only the
settle()function selector is allowed - Sequential processing: Loans must be processed in the specified order
Integration
Solvers integrating with the FlashLoanRouter must:- Be registered in the settlement authenticator
- Encode settlement data as a valid
settle()call - Specify correct loan parameters (lender, borrower, token, amount)
- Ensure settlement logic includes repayment of all borrowed amounts plus fees
Next Steps
AaveBorrower
Aave flash loan adapter
ERC3156Borrower
ERC-3156 flash loan adapter