Skip to content

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