0

Either in Web3 or Sol. Before trading tokens I am trying to determine what the exact amount will be which I will receive given slippage, and also to understand how many tokens I would receive if I was to then trade back immidiately after. I am trying to know roughly what the token price would need to increase to to recover any fees from buying and selling. Some tokens I have seen take slippage fee for burns, liquidity, auto distribution etc. Also, when using Metamask, if I don't set slippage high enough Metamask will error before the tx is sent so no GWEI is spent. How can I acheive something similar where I can determine how much slippage is needed?

Thanks

0

This is sort of a tough question to answer , that solely falls down to the fact that its hard to automatically get the fees for a certain token. Manually however , I imagine with your expertise in coding you can read that easily through the contract.

However I have two plausible solutions here.

  1. some contracts have their read fees as a public function meaning you can acquire how much they take for fees via a function call as you may suspect however this presents a lot of problems most notably not every contract has these , and also the read function's name to get fees inflicted changes from contract to another

  2. Recommended way but also hard: you can technically take the contract's address and its ABI and deploy it on a local testing blockchain like ganache and initiate a a swap to that contract (You would also need to fork uniswap on your local blockchain) and from there you can calculate how many tokens you lost as a roundtrip all automatically for example if you simulated a buy of 500 tokens and you came out with 400 tokens then the buy tax is 20%. you can do the same thing for the sell and find out that tax on sells. I understand this is a complicated and hard way to find out fees on tokens but this is the only 100% guaranteed way of doing it.

a third solution but not so automatic , is to manually put in the fees for that contract after reading the smart contract yourself

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.