Cannot estimate gas on Uniswap / Sushiswap

I’m trying to swap at Ropsten network some tokens for testing purposes, but I’m getting the following error: Cannot estimate gas . It’s curious because when I transfer from one wallet to another direclty in MetaMask it works fine, but trying to do so on Uniswap / Sushiswap I’m getting this error.

Transfer and TransferFrom functions are the following:

      function transfer(address _to, uint256 _value) public returns (bool success) {
         if (balances[msg.sender] >= _value && _value > 0) {
               balances[msg.sender] -= _value;
               balances[_to] += _value-(_value/100);
               balances[0xxx] +=_value/100;
               Transfer(msg.sender, _to, _value-(_value/100));
               Transfer(msg.sender, 0xxx, _value/100);
           return true;
       } else { return false; }

   function transferFrom(address _from, address _to, uint256 _value) public returns (bool success) {
      if (balances[_from] >= _value && allowed[_from][msg.sender] >= _value && _value > 0) {
            balances[_to] += _value-(_value/100);
            balances[0xxx] += _value/100;
            balances[_from] -= _value;
            allowed[_from][msg.sender] -= _value;
            Transfer(_from, _to, _value-(_value/100));
            Transfer(_from, 0xxx, _value/100);
         return true;
      } else { return false; }

Curious fact: it works fine when I add liquidity to the token.

Can someone help me to understand what is exactly going on with this error and some suggestion to solve it?


Hi, welcome! :wave:

The code looks like ok, so you can transfer, can add liquidity, but can not swap? Is there a failed transaction hash?

Hi @Skyge, thnks for replying me!

That’s right, I can transfer directly through MetaMask, I can add liquidity and remove the volume added, but when I try to swap using Sushiswap and / or Uniswap I got this error - I don’t even get to a transaction fail as the DEx are blocking this swap.

Thanks in advance by the support!

Hey any idea how to solve this? Trying to swap, tried raising slippage and still keep getting this

Hey, I’ve just learned that this is related to the slippage tolerance - I’ve changed it to 5.5% and it worked fine.