forked from immunefi-team/forge-poc-templates
-
Notifications
You must be signed in to change notification settings - Fork 3
/
FlashLoanExample.sol
36 lines (30 loc) · 1.25 KB
/
FlashLoanExample.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
28
29
30
31
32
33
34
35
36
pragma solidity ^0.8.0;
import "../FlashLoan.sol";
import "../../tokens/Tokens.sol";
import "forge-std/console.sol";
contract FlashLoanExample is FlashLoan, Tokens {
FlashLoanProviders internal _flp;
function initiateAttack(FlashLoanProviders flp) external {
_flp = flp;
uint256 fee;
if (flp == FlashLoanProviders.AAVEV1 || flp == FlashLoanProviders.AAVEV3) {
fee = 900000000000000;
} else if (flp == FlashLoanProviders.UNISWAPV2) {
fee = 3009027081243732;
} else if (flp == FlashLoanProviders.UNISWAPV3) {
fee = 500000000000000 + 1;
}
deal(EthereumTokens.DAI, address(this), fee);
console.log("DAI BALANCE BEFORE:", EthereumTokens.DAI.balanceOf(address(this)));
takeFlashLoan(flp, address(EthereumTokens.DAI), 1 ether);
}
function _executeAttack() internal override {
console.log("DAI BALANCE DURING:", EthereumTokens.DAI.balanceOf(address(this)));
if (currentFlashLoanProvider() == FlashLoanProviders.AAVEV1) {
// Execute attack with funds from AAVEV1
}
}
function _completeAttack() internal override {
console.log("DAI BALANCE AFTER :", EthereumTokens.DAI.balanceOf(address(this)));
}
}