-
Notifications
You must be signed in to change notification settings - Fork 4
/
DemoFlashLoanReceiver.sol
66 lines (40 loc) · 1.35 KB
/
DemoFlashLoanReceiver.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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
pragma solidity 0.7.4;
interface IFlashLoanReceiver {
function executeOperation(
address[] calldata assets,
uint256[] calldata amounts,
uint256[] calldata premiums,
address initiator,
bytes calldata params
) external returns (bool);
}
interface IArbitrageStrategy {
function arbitrage() external payable;
}
interface IWETH {
function deposit() external payable;
function withdraw(uint256) external;
function approve(address guy, uint256 wad) external returns (bool);
function transferFrom(
address src,
address dst,
uint256 wad
) external returns (bool);
}
contract DemoFlashloanReceiver is IFlashLoanReceiver {
address constant LENDING_POOL = 0x7d2768dE32b0b80b7a3454c06BdAc94A69DDc7A9;
IWETH constant WETH = IWETH(0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2);
IArbitrageStrategy constant STRATEGY = IArbitrageStrategy(0x8F1034CBE5827b381067fCEfA727C069c26270c4);
function executeOperation(
address[] calldata assets,
uint256[] calldata amounts,
uint256[] calldata premiums,
address initiator,
bytes calldata params
) external override returns (bool) {
require(assets[0] == address(WETH), "Invalid asset");
require(amounts[0] < 0.01 ether, "Invalid amount");
//insert the code to invoke FakeArbitrageStrategy here
return true;
}
}