Uniswap / Uniswap/interface

Incorrect calculation of "Minimum received after slippage"

Open
#6,206 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
TypeScript
Stars
5.5k
Forks
5.4k
PR merge metrics
No merged PRs in 30d

Description

Bug Description
From the Uniswap's docs:

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.

Steps to Reproduce

  1. Go to uniswap.exchange
  2. Input swap from 1000 USDC to 1000 DAI and set slippage to 25%
  3. Notice the minimum amount out is 800 DAI, which is 20% less than expected price

Expected Behavior

  1. Go to uniswap.exchange
  2. Input 1000 USDC to 1000 DAI and set slippage to 25%
  3. Notice the minimum amount out is 750 DAI, which is 25% less than expected price

Additional Context
uniswap-slippage-bug

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in the Uniswap app and widget swap flow described in the reproduction steps, tracing how the expected output and slippage setting produce the minimum amount out. Compare the calculation with the documented 25% reduction from the expected price; done means 1,000 USDC to 1,000 DAI at 25% slippage shows 750 DAI as the minimum amount out.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
blockchain, frontend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.