Overview
TheERC3156Borrower contract enables the FlashLoanRouter to request flash loans from any lender implementing the ERC-3156 standard. It provides a universal interface for flash loan providers that follow the standard, including Maker’s Flash Mint Module.
Contract Details
- Source:
src/ERC3156Borrower.sol - License: GPL-3.0-or-later
- Solidity: ^0.8.28
- Address:
0x47d71b4B3336AB2729436186C216955F3C27cD04(all networks) - Inherits:
Borrower,IERC3156FlashBorrower
Compatible Lenders
The ERC3156Borrower works with any lender implementing the ERC-3156 standard, including:- Maker’s Flash Mint Module
- Yield Protocol
- Euler Finance
- Any other ERC-3156 compliant lender
Functions
flashLoanAndCallBack
lender: Address of the ERC-3156 flash loan providertoken: ERC-20 token to borrowamount: Amount of tokens to borrowcallBackData: Data to pass back to the router unchanged
onFlashLoan
initiator: Address that initiated the flash loantoken: Address of the borrowed tokenamount: Amount borrowedfee: Fee charged by the lenderdata: Encoded callback data (passed through unchanged)
keccak256("ERC3156FlashBorrower.onFlashLoan") — the ERC-3156 success constant
approve
triggerFlashLoan (internal)
IERC3156FlashLender.flashLoan() and validates the result.
Execution Flow
- Router calls
flashLoanAndCallBack()on the ERC3156Borrower - ERC3156Borrower calls
IERC3156FlashLender.flashLoan()on the lender - Lender transfers the requested tokens to the ERC3156Borrower
- Lender invokes
onFlashLoan()on the ERC3156Borrower - ERC3156Borrower calls
router.borrowerCallBack()to continue execution - ERC3156Borrower returns the success constant to the lender
- During settlement, the settlement contract calls
approve()for lender repayment - Lender pulls the borrowed amount plus fee via
transferFrom()
Success Constant
The ERC-3156 standard requires the borrower to return a specific constant fromonFlashLoan():
Security
flashLoanAndCallBack(): Only callable by the registered routerapprove(): Only callable by the settlement contractonFlashLoan(): Called by the lender within the flash loan flow- Validates flash loan success before proceeding
- Immutable router and settlement contract references
Integration Notes
- Fees vary by lender and asset — query
flashFee()before constructing settlements - Maximum loan amounts can be checked via
maxFlashLoan() - Some lenders may have specific token restrictions
- The settlement must include an interaction to approve the lender for repayment (principal + fee)
Next Steps
AaveBorrower
Aave flash loan adapter
Borrower Base
Abstract base contract