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
I have question does UniswapV2 swapExactTokensForTokens function charge fees ? And if yes does expected amount input should be like this Expected price after fee subtraction?
The text was updated successfully, but these errors were encountered:
Yes, UniswapV2's swapExactTokensForTokens function does charge fees. The fee is approx 0.3% of the transaction amount and it's automatically deducted from the amount of output tokens. Therefore, the expected amount input should be the expected price after fee subtraction.
When you use the swapExactTokensForTokens function, you specify the exact amount of input tokens you are willing to spend, and the minimum amount of output tokens you expect to receive. The function will revert (fail) if the amount of output tokens is less than the minimum specified due to price changes or fees.
As an example, if you're swapping 100 tokens A for tokens B, and the current price of token A in terms of token B is 1 (1 token A = 1 token B), you would expect to receive 100 tokens B. However, Uniswap will charge a 0.3% fee, so you will actually receive 99.7 tokens B.
If you want to ensure that you receive at least 99 tokens B, you would set your amountOutMin parameter to 99. If the actual amount of tokens B you would receive after fees is less than this (due to price changes or fees), the transaction will revert.
In summary, when using swapExactTokensForTokens, you provide the exact input amount and specify the minimum acceptable output amount, and the Uniswap contract handles the fee calculation during the swap.
I have question does UniswapV2 swapExactTokensForTokens function charge fees ? And if yes does expected amount input should be like this Expected price after fee subtraction?
The text was updated successfully, but these errors were encountered: