Skip to content

feat(v4-sdk): add max hop slippage support for multi-hop swaps#499

Open
Ayoakala wants to merge 1 commit intomainfrom
revert-470-siyujiang/revert-max-hop-slippage
Open

feat(v4-sdk): add max hop slippage support for multi-hop swaps#499
Ayoakala wants to merge 1 commit intomainfrom
revert-470-siyujiang/revert-max-hop-slippage

Conversation

@Ayoakala
Copy link
Contributor

@Ayoakala Ayoakala commented Jan 28, 2026

Description

[Summary of the change, motivation, and context]

How Has This Been Tested?

[e.g. Manually, E2E tests, unit tests, Storybook]

Are there any breaking changes?

[e.g. Type definitions, API definitions]

If there are breaking changes, please ensure you bump the major version Bump the major version (by using the title feat(breaking): ...), post a notice in #eng-sdks, and explicitly notify all Uniswap Labs consumers of the SDK.

(Optional) Feedback Focus

[Specific parts of this PR you'd like feedback on, or that reviewers should pay closer attention to]

(Optional) Follow Ups

[Things that weren't addressed in this PR, ways you plan to build on this work, or other ways this work could be extended]


✨ Claude-Generated Content

Description

Re-adds the max hop slippage feature to the v4-sdk. This allows specifying per-hop slippage limits for multi-hop swaps, enabling finer-grained slippage control on each step of a swap route.
This PR reverts the previous revert (#470) to restore the max hop slippage functionality.

Changes

  • Added maxHopSlippage optional parameter to V4Planner.addTrade() method accepting BigNumber[]
  • Added maxHopSlippage: readonly string[] field to SwapExactIn and SwapExactOut types in v4BaseActionsParser.ts
  • Updated SWAP_EXACT_IN_STRUCT and SWAP_EXACT_OUT_STRUCT ABI definitions to include uint256[] maxHopSlippage
  • Updated parseV4ExactIn() and parseV4ExactOut() parser functions to decode the new field
  • Added unit tests for per-hop slippage limits in both exactIn and exactOut scenarios
  • Updated existing tests to include maxHopSlippage: [] in expected outputs

How Has This Been Tested?

Unit tests added covering:

  • exactIn 2-hop swap with per-hop slippage limits
  • exactOut 2-hop swap with per-hop slippage limits
  • addAction with per-hop slippage limits
  • Default empty maxHopSlippage when not provided

Are there any breaking changes?

No - maxHopSlippage is an optional parameter that defaults to an empty array when not provided, maintaining backward compatibility.

@Ayoakala Ayoakala requested a review from a team as a code owner January 28, 2026 05:46
@Ayoakala Ayoakala closed this Jan 28, 2026
@github-actions
Copy link
Contributor

github-actions bot commented Jan 28, 2026

🤖 Claude Code Review

Review complete

Summary

This PR re-introduces the maxHopSlippage feature for V4 multi-hop swaps, allowing per-hop slippage limits. This was previously reverted and is now being re-added.

Changes:

  • Adds maxHopSlippage: uint256[] field to SWAP_EXACT_IN_STRUCT and SWAP_EXACT_OUT_STRUCT ABI definitions
  • Updates addTrade() method to accept optional maxHopSlippage?: BigNumber[] parameter
  • Updates parser to extract maxHopSlippage from decoded calldata
  • Adds type definitions for the new field
  • Comprehensive tests for per-hop slippage functionality

Technical Notes:

  • The ABI struct field order (currencyIn/Out, path, maxHopSlippage, amount...) is consistent between encoder and parser
  • Defaults to empty array when not provided, maintaining backward compatibility for callers
  • The addTrade() signature change is backward-compatible (new parameter is optional)

The implementation is clean and follows existing patterns in the codebase.


💡 Want a fresh review? Add a comment containing @request-claude-review to trigger a new review at any time.

@Ayoakala Ayoakala reopened this Jan 28, 2026
@github-actions github-actions bot changed the title Revert "feat(v4-sdk): Revert Add max hop slippage" feat(v4-sdk): add max hop slippage support for multi-hop swaps Jan 28, 2026
Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📋 Review verdict: APPROVE

👆 The main review comment above is the source of truth for this PR review. It is automatically updated on each review cycle, so always refer to it for the most current feedback.

This formal review submission is for the verdict only.

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