- Notifications
You must be signed in to change notification settings - Fork386
How to tell if token requires fee on transfer?#162
-
Hi, is there a way for me to determine if a swap requires fee on transfer tokens before calling the make_trade method? Most tokens use |
BetaWas this translation helpful?Give feedback.
All reactions
Replies: 1 comment 2 replies
-
BetaWas this translation helpful?Give feedback.
All reactions
-
Yes, that is exactly what must be done assuming we know token requires fee. However, it doesn't help much if the trade goes through anyways. If we use the following code with a token the requires fee, the transaction will go through anyways. qty_token=uniswap.get_token_balance(token_w)print(qty_token) Once we inspect the transaction on the blockchain we see that it effectively failed and are returned initial funds minus the gas fees. I would have expected this to raise an error so that we could easily use the proper parameters uniswap.make_trade(token_w,wbnb_w,qty_token,fee_on_transfer=True)#HAVE TO WORK |
BetaWas this translation helpful?Give feedback.
All reactions
-
OK, let's take a look. There are couple of ways to check that. You can parse previous swaps in this pool; you can analyze revert reason from router; you can inspect contract's code at last. IMO second method can be implemented in this project but I doubt it's way more effective than manual check. Basically, revert message in this case is "error: [router name]: K" |
BetaWas this translation helpful?Give feedback.