Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function testSandwich(address investor, uint256 amount, uint256 mul) external {
- _prepareAddress(investor);
- amount = bound(amount, 1 ether, 10_000 ether);
- mul = bound(mul, 2, 5000);
- _disableWhitelist();
- address attacker = delta;
- uint256 attacker_amount = amount * mul;
- vm.deal(investor, amount);
- vm.deal(attacker, attacker_amount);
- uint256 attacker_balance_b = attacker.balance;
- _deposit(attacker_amount, attacker, alpha);
- _deposit(amount, investor, beta);
- _withdraw(attacker);
- uint256 attacker_balance_a = attacker.balance;
- uint256 profits = attacker_balance_a > attacker_balance_b ? attacker_balance_a - attacker_balance_b : 0;
- assertEq(profits, 0, "Sandwich profit should be zero."); // there is profit from the attack, therefore sandwich is possible to steal significant value from buyers
- }
Advertisement
Add Comment
Please, Sign In to add comment