Guys i am facing a problem with autoSwap function to proceed fees from contract, can anyone please help?
When the function is called inside the _transfer() function to proceed the accumulated fees, transaction fails and contract is broken (users cant buy or sell). But when the SAME function is called externally to manually swap the fees, transaction succeeds. Why this behavior is observed in the same functionallity?
Any help is appreciated!

modifier swaping {
inSwap = true;
_;
inSwap = false;
}

function swapTokensForBNB() private swaping {

uint256 contractTokenBalance = balanceOf(address(this));

if(contractTokenBalance < 1 ) {
return;
}

address[] memory path = new address[](2);
path[0] = address(this);
path[1] = pancakeSwapV2Router.WETH();
_approve(address(this), address(pancakeSwapV2Router), contractTokenBalance);
pancakeSwapV2Router.swapExactTokensForETHSupportingFeeOnTransferTokens(
contractTokenBalance,
0,
path,
address(this),
block.timestamp
);
}

Aug 10, 2022, 9:43 AM
read uniswap contracts
Aug 10, 2022, 11:00 AM
i am using pancake and have read them, but cannot see what i am doing wrong
Aug 10, 2022, 11:00 AM
swaping stuff
block the swap
Aug 10, 2022, 11:01 AM
what do you mean exactly?
the modifier?
Aug 10, 2022, 11:02 AM
something like this
blocks your swap
Aug 10, 2022, 11:02 AM
modifier swaping {
inSwap = true;
_;
inSwap = false;
}
i call the exact same function externally with onlyOwner and swaping modifier and it works
and internally in the transfer with only swaping modifier it dont works
Aug 10, 2022, 11:03 AM
yeah of course
Aug 10, 2022, 11:03 AM
can you please ellaborate, why this is happening and how can i manage it to autoswap when users make transfer instead of swapping fees manually?
Aug 10, 2022, 11:04 AM
because it's already being used
re read it
Aug 10, 2022, 11:06 AM
its is not being used, it is required to be false to initiate the swapTokensForBNB() function in the transfer() function and when this happens transaction fails
Aug 10, 2022, 11:17 AM

© 2024 Draquery.com All rights reserved.