You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Fail with error 'Pancake: K' on FeeOnTransfer token #130
First, it would be nice if you close issue that has been solved already.
Regarding your problem, it is BSC. This network has technical issues, sad but true. Pancakeswap is uniswapV2's clone so the library itself works totally fine. Your problem isn't about slippage implementation in this project, it is about BSC network organization. I'd consider picking suitable slippage value. I have to note that default_slippage=.5 means 50% slippage and I doubt it's OK. Also you can try to swap just some part of the token's balance not the exactly whole one.
Okay, I apologize. I have now closed the other issue.
Ok, thanks for your explanation.
Actually, I had tried 1%, 5%, 12%, 20% and 50% but it always gave me back the same error.
I also tried to swap less token balance, but it works only if I swap "1 digit" of the token (1 to 9 tokens), from 10 tokens the error occurs.
I got it. Token you're going to swap has fees on transfer. It requires swapExactTokensForETHSupportingFeeOnTransferTokens() or swapExactTokensForTokensSupportingFeeOnTransferTokens() to be implemented. When you're trying to swap extra small amounts there are just no fees. So swapExactTokensForETH() works fine and fails otherwise. Usual tokens should swap correctly. Can't promise but I'm going to add that in few days OR you can add it yourself. In before "how do I determine if contract has these fees": this "swap: K" error might be caused by inappropriate contract calls too.
Activity
liquid-8 commentedon Jul 3, 2021
First, it would be nice if you close issue that has been solved already.
Regarding your problem, it is BSC. This network has technical issues, sad but true. Pancakeswap is uniswapV2's clone so the library itself works totally fine. Your problem isn't about slippage implementation in this project, it is about BSC network organization. I'd consider picking suitable slippage value. I have to note that default_slippage=.5 means 50% slippage and I doubt it's OK. Also you can try to swap just some part of the token's balance not the exactly whole one.
LucaZanatta commentedon Jul 3, 2021
Okay, I apologize. I have now closed the other issue.
Ok, thanks for your explanation.
Actually, I had tried 1%, 5%, 12%, 20% and 50% but it always gave me back the same error.
I also tried to swap less token balance, but it works only if I swap "1 digit" of the token (1 to 9 tokens), from 10 tokens the error occurs.
liquid-8 commentedon Jul 4, 2021
I got it. Token you're going to swap has fees on transfer. It requires swapExactTokensForETHSupportingFeeOnTransferTokens() or swapExactTokensForTokensSupportingFeeOnTransferTokens() to be implemented. When you're trying to swap extra small amounts there are just no fees. So swapExactTokensForETH() works fine and fails otherwise. Usual tokens should swap correctly. Can't promise but I'm going to add that in few days OR you can add it yourself. In before "how do I determine if contract has these fees": this "swap: K" error might be caused by inappropriate contract calls too.
LucaZanatta commentedon Jul 5, 2021
Sorry, but I don't know python well enough, so if you were to do this, you'd be doing me a huge favour. Should I close the issue?
liquid-8 commentedon Jul 5, 2021
Still not, I'd pushed PR for this issue. I'll let you know what to do after merge.
ErikBjare commentedon Jul 7, 2021
Implemented in #132. Will be in the next release.
[-]Fail with error 'Pancake: K'[/-][+]Fail with error 'Pancake: K' on FeeOnTransfer token[/+]liquid-8 commentedon Jul 8, 2021
@LucaZanatta
So, just update uniswap-python and then this part of code should be
Feel free to ask questions if something go wrong.
LucaZanatta commentedon Jul 8, 2021
It works fine! Thanks :)