Urgent Help needed regarding ERC20

So I have this contract here: https://pastebin.com/2U0B3gUN

Everything works but the bug is occurring when the minimumContractBalanceToSwap is hit at L310, buys and sells in uniswap stop working for everyone except the ower().

I have been trying to figure this out for 3 days now. I am simply stunned. Any ideas as to why this is? I even tried isolating the swapTokensForEth(contractTokenBalance.div(2)); and swapAndLiquify(contractTokenBalance.div(2)); with no success.

I am out of ideas. Any help would be really appreciated and thank you in advance!

Could you provide the contract address or the code?

1 Like

It’s the link at the top of the post: https://pastebin.com/2U0B3gUN

Sorry, missed that completely.

Row: 364
IUniswapV2Router02 _uniswapV2Router = IUniswapV2Router02(0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D); // CHANGEIT to nominal router.

Do you have the correct router?

Hehe no problem :slight_smile: Yes that is just my notes. I am testing it fine on rinkeby with no problem. Everything works but the bug is occurring when the minimumContractBalanceToSwap is hit at L310, buys and sells in uniswap stop working for everyone except the ower() .

This is why I was asking about the router:

1 Like

I see. But it never happens until I am trying to swapTokensForEth(contractTokenBalance.div(2)); and swapAndLiquify(contractTokenBalance.div(2));.

If I remove that block it never happens. Let me see the video first and I’ll come back cuz it 20m :slight_smile:

Edit: so yeah I watched the video. I don’t think this is the what causes my problem. :confused:

well from the code it seems that first is called the swap, so at the end of the swap there aren’t ETH remaining to allow sendETHToFee

The sendETH part is never called until there is ETH in the contract. If I understood correctly the part you are referring to!

if (contractETHBalance >= 3 * 10**16) {
     sendETHToFee(contractETHBalance);
} 

But when I am swapping I divide by 2 for the swapAndLiquify and then I divide by 2 again in the respective function.

1 Like

yes sorry I didn’t see.

1 Like

Anyway in your code I saw this:

if (!inSwap && swapEnabled && from != uniswapV2Pair) { // Selling

It doesn’t represent a sale. To check that it is a sale you must use to == uniswapV2Pair

from != uniswapV2Pair means it’s not a buy, right? I might have confused it then. But everything is blocked both sells and buys. The problematic code doesn’t check for buys or sell. That’s why I am so confused.

Yes but it could me a normal transfer too if you not check that the recipient is the pair.

Correct. I checked with that condition removed and still failed. The problem is in this block:

so you tried without this block and you don’t get error?

Yes. Once I stop trying to swapAndLiquify and the rest in that block there is no problem.

Ok did you tried with only the liquidity part?

Yes. Failing. That’s why I suspect something with the swaps is causing it.

Can you share a transaction failed?
Also I get this error. You don’t?

Well that’s the thing. Is not failing the transaction. Once the minimum amount is reached and it has to execute swaps, uniswap doesn’t even issue the transaction. It’s just pops with a message of invalid output or something.