This template is for getting started with attack PoCs which use flash loans. The flash loan template supports flash loans from the following protocols/chains:
Network | Protocol | Library |
---|---|---|
Ethereum | AAVEV1 | AAVEV1FlashLoan |
Ethereum | AAVEV2 | AAVEV2FlashLoan |
Ethereum | AAVEV3 | AAVEV3FlashLoan |
Ethereum | Euler | EulerFlashLoan |
Ethereum | Balancer | BalancerFlashLoan |
Ethereum | MakerDAO | MakerDAOFlashLoan |
Ethereum | UniswapV2 | UniswapV2FlashLoan |
Ethereum | UniswapV3 | UniswapV3FlashLoan |
Network | Protocol | Library |
---|---|---|
Gnosis | UNISWAPV2 | UniswapV2FlashLoan |
Network | Protocol | Library |
---|---|---|
Optimism | AAVEV3 | AAVEV3FlashLoan |
Network | Protocol | Library |
---|---|---|
Arbitrum | AAVEV3 | AAVEV3FlashLoan |
Network | Protocol | Library |
---|---|---|
Polygon | AAVEV2 | AAVEV2FlashLoan |
Polygon | AAVEV3 | AAVEV3FlashLoan |
Network | Protocol | Library |
---|---|---|
Fantom | AAVEV3 | AAVEV3FlashLoan |
Network | Protocol | Library |
---|---|---|
Avalanche | AAVEV2 | AAVEV2FlashLoan |
Avalanche | AAVEV3 | AAVEV3FlashLoan |
The following attack contract demonstrate simple flash loan usage.
Extend the FlashLoan contract and implement the following functions:
contract Attack is FlashLoan {
function initiateAttack() external { }
function _executeAttack() internal override { }
function _completeAttack() internal override { }
}
Call takeFlashLoan(FlashLoanProviders flp, address token, uint256 amount)
in initiateAttack()
to trigger your attack.
The following attack contract demonstrate multi provider flash loan usage.
Each time a flash loan is taken, the _executeAttack()
function is called when the provider calls the flash loan callback. The context of the current execution call can be determined by calling currentProvider()
, which returns the Flash Loan Provider which initiated the callback. This can be used as a state machine to execute stages of an attack. See the example for more. Flash loan repayment is handled automatically by the flash loan _fallback()
handler.
🚨 Multiple flash loans cannot be taken from the same provider due to reentrancy protections. If you need to flash loan multiple tokens, you will have to use multiple providers unless the provider specifically supports multi-token flash loans.