Is it possible to do swapbacks/buybacks on buy transactions?
Normally the collected Taxes of a coin are always sold/swapped back on a sell transaction, whenever someone sells their tokens.
function swapBack(uint _amount) internal { address[] memory path = new address[](2); path[0] = address(this); path[1] = router.WETH(); router.swapExactTokensForETHSupportingFeeOnTransferTokens( _amount, 0, path, address(this), block.timestamp ); }
This is done by usually checking if it’s a buy or sell transaction. If the transaction is a sell, it does the swapback:
function shouldSwapBackTokens() internal view returns (bool) { return msg.sender != pair && !inSwap && tradingEnabled && _balances[address(this)] > 0; }
For my purpose I would need that on a buy transaction as well. However, whatever I’ve tried so far, every time I enable it for buy transactions one way or another, the CA is always broken afterwards.
Now I was wondering if that’s a thing that is just not possible to do in solidity, or if it needs another approach?