Skip to content

Latest commit

 

History

History
112 lines (83 loc) · 3.93 KB

README.md

File metadata and controls

112 lines (83 loc) · 3.93 KB

Vulnerability Type

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:

Ethereum

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

Gnosis

Network Protocol Library
Gnosis UNISWAPV2 UniswapV2FlashLoan

Optimism

Network Protocol Library
Optimism AAVEV3 AAVEV3FlashLoan

Arbitrum

Network Protocol Library
Arbitrum AAVEV3 AAVEV3FlashLoan

Polygon

Network Protocol Library
Polygon AAVEV2 AAVEV2FlashLoan
Polygon AAVEV3 AAVEV3FlashLoan

Fantom

Network Protocol Library
Fantom AAVEV3 AAVEV3FlashLoan

Avalanche

Network Protocol Library
Avalanche AAVEV2 AAVEV2FlashLoan
Avalanche AAVEV3 AAVEV3FlashLoan

Usage

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.