Overview
TheAaveBorrower contract serves as a protocol adapter between the FlashLoanRouter’s generic interface and Aave V3’s specific flash loan mechanism. It implements Aave’s flash loan receiver interface while maintaining the router’s standardized borrowing pattern.
Contract Details
- Source:
src/AaveBorrower.sol - License: GPL-3.0-or-later
- Solidity: ^0.8.28
- Address:
0x7d9C4DeE56933151Bc5C909cfe09DEf0d315CB4A(all networks) - Inherits:
Borrower,IAaveFlashLoanReceiver
Functions
flashLoanAndCallBack
lender: Address of the Aave V3 Pool contracttoken: ERC-20 token to borrowamount: Amount of tokens to borrowcallBackData: Data to pass back to the router unchanged
executeOperation
borrowerCallBack().
Parameters:
assets: Array of borrowed token addressesamounts: Array of borrowed amountspremiums: Array of flash loan feesinitiator: Address that initiated the flash loanparams: Encoded callback data (passed through unchanged)
true to indicate successful execution
approve
triggerFlashLoan (internal)
IAavePool.flashLoan().
Key implementation details:
- Interest rate mode is set to
0(no debt position, must repay in same transaction) - Referral code is set to
0(Aave’s referral program is currently inactive) - Assets and amounts are wrapped in single-element arrays
Execution Flow
- Router calls
flashLoanAndCallBack()on the AaveBorrower - AaveBorrower calls
IAavePool.flashLoan()on the Aave V3 pool - Aave transfers the requested tokens to the AaveBorrower
- Aave invokes
executeOperation()on the AaveBorrower - AaveBorrower calls
router.borrowerCallBack()to continue execution - During settlement, the settlement contract calls
approve()to authorize Aave pool repayment - After settlement, Aave pulls the borrowed amount plus premium via
transferFrom()
Repayment Model
Aave uses a “pull” repayment model:- Settlement approves the Aave pool to spend the borrower’s tokens
- Aave’s flash loan mechanism calls
transferFrom()to reclaim the principal plus premium - If the approval is insufficient or the borrower lacks funds, the transaction reverts
Integration Notes
- Flash loan premiums on Aave are typically 0.05%-0.09% depending on the asset
- Premiums may vary by network and pool configuration
- Solvers must account for premiums when calculating settlement profitability
- The settlement must include an interaction to approve the Aave pool for repayment
Security
flashLoanAndCallBack(): Only callable by the registered routerapprove(): Only callable by the settlement contractexecuteOperation(): Called by Aave within the flash loan flow- Immutable router and settlement contract references prevent manipulation
Next Steps
ERC3156Borrower
ERC-3156 flash loan adapter
Borrower Base
Abstract base contract