Skip to content

fix: Remove incorrect amount propagation in exact output swaps #433

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

VolodymyrBg
Copy link

Related Issue

Which issue does this pull request resolve?
This PR fixes a critical issue in the V4Router's _swapExactOutput function
where amounts were incorrectly propagated in multi-hop trades

Description of changes

The bug was
caused by unnecessarily setting amountOut = amountIn in each iteration, which
led to incorrect calculations for subsequent hops.

  • Removed the line amountOut = amountIn from the _swapExactOutput function
  • Maintains correct output amount throughout the path traversal
  • Ensures accurate input amount calculations for each hop

This fix prevents:

  • Incorrect slippage calculations in multi-hop trades
  • Potential trade failures due to amount mismatches
  • Inaccurate price impact calculations

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant