Using the uniswap router contract swapExactTokensForTokensSupportingfeesOnTransfer to swap from the contract token to USDT.
A liquidity pool (and therefore an LP pair) exists for the token-USDT pair therefore I’m using the path address(this), USDT address. If I set the “to” to be address(this) I get an INVALID_TO error response, if I set it to another address the function works as expected. I can see in the pair.swap function in the uniswap contracts that this error is called when you’re trying to send to one of the parts of the pair, however this doesn’t get returned when you do the same with a WETH pair, using swapExactTokensForEthSupportingFeeOnTransferTokens, which calls the same swap function.
Why is this and is there any way round it other than to deliver the funds to a separate address and deal with them from there?
Re-read the uniswap functions a bit more carefully. SwapTokensForTokens functions have a different path to swapping for Eth, which is why when doing the same swap with Eth I don't get the error.
Still unsure why you're not allowed to send the results of a swap to one of the tokens in the pair contract: I just got around it using a child contract to manage the swaps.
Actually, I also got this error. What I plan to do is send the tokens to other wallet and then I will allow current contract to transfer tokens from wallet to current contract. Then we can proceed as we want.