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
If your slippage is set too high, then you may get less tokens than expected when swapping. For example, if your slippage is set to 25%, then you may receive 25% less than the expected swap outcome (tokens) that is shown to you in the swap preview.
This confirms how slippage should be calculated. However, this is not the case in the current Uniswap app and Uniswap widget. What actually happens is that the app calculates 25% of the execution price instead of the expected price.
@mazurroman After some digging, the issue resides in the @uniswap/router-sdk. The issue is that the math, is supposed to be "outputAmount * (1 - slippageTolerance)" However, it is "1 + slippageTolerance / 1 * outputAmount" which is producing the wrong amount.
Bug Description
From the Uniswap's docs:
This confirms how slippage should be calculated. However, this is not the case in the current Uniswap app and Uniswap widget. What actually happens is that the app calculates 25% of the execution price instead of the expected price.
Steps to Reproduce
1000 USDC
to1000 DAI
and set slippage to25%
800 DAI
, which is20%
less than expected priceExpected Behavior
1000 USDC
to1000 DAI
and set slippage to25%
750 DAI
, which is25%
less than expected priceAdditional Context
The text was updated successfully, but these errors were encountered: