Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

How to tell if token requires fee on transfer?#162

Unanswered
ChristianPerez34 asked this question inQ&A
Discussion options

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 useswapExactETHForTokens when swapping ETH, but, most of the new tokens now useswapExactETHForTokensSupportingFeeOnTransferTokens

You must be logged in to vote

Replies: 1 comment 2 replies

Comment options

#130 (comment)

You must be logged in to vote
2 replies
@ChristianPerez34
Comment options

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
@liquid-8
Comment options

OK, let's take a look.
Here are tokens
https://etherscan.io/address/0x4f3afec4e5a3f2a6a1a411def7d7dfe50ee057bf
and
https://etherscan.io/address/0xc40af1e4fecfa05ce6bab79dcd8b373d2e436c4e
Both have fees on transfer. If you inspect their ABIs you'll notice that they have no specific method to quickly identify this token as FoT. Of course, we can check if contract has method AAA or method BBB or ... etc etc but this is kinda ridiculous.

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"

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Category
Q&A
Labels
None yet
2 participants
@ChristianPerez34@liquid-8

[8]ページ先頭

©2009-2025 Movatter.jp