forked from immunefi-team/forge-poc-templates
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMultiProviderFlashLoanExample.sol
27 lines (22 loc) · 1.06 KB
/
MultiProviderFlashLoanExample.sol
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
pragma solidity ^0.8.0;
import "../FlashLoan.sol";
import "../../tokens/Tokens.sol";
import "forge-std/console.sol";
contract MultiProviderFlashLoanExample is FlashLoan, Tokens {
function initiateAttack() external {
deal(EthereumTokens.DAI, address(this), 1 ether);
console.log("DAI BALANCE BEFORE:", EthereumTokens.DAI.balanceOf(address(this)));
takeFlashLoan(FlashLoanProviders.UNISWAPV3, address(EthereumTokens.DAI), 1 ether);
}
function _executeAttack() internal override {
console.log("DAI BALANCE DURING:", EthereumTokens.DAI.balanceOf(address(this)));
if (currentFlashLoanProvider() == FlashLoanProviders.UNISWAPV3) {
takeFlashLoan(FlashLoanProviders.AAVEV1, address(EthereumTokens.DAI), 1 ether);
} else if (currentFlashLoanProvider() == FlashLoanProviders.AAVEV1) {
// Execute attack with funds from UNISWAPV3 and AAVE
}
}
function _completeAttack() internal override {
console.log("DAI BALANCE AFTER :", EthereumTokens.DAI.balanceOf(address(this)));
}
}