feat(router-sdk): add maxHopSlippage to Trade.swaps#529
Draft
kristiehuang wants to merge 1 commit intomainfrom
Draft
feat(router-sdk): add maxHopSlippage to Trade.swaps#529kristiehuang wants to merge 1 commit intomainfrom
kristiehuang wants to merge 1 commit intomainfrom
Conversation
717b997 to
88ab699
Compare
Collaborator
Author
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Description
For maxHopSlippage, a partial implementation exists for multi-hop V4-only routes in UR-sdk, but it is incorrect:
SwapOptions-- A singlemaxHopSlippage?: BigNumber[]onSwapOptionscannot correctly map values to specific routes in a split-route trade (e.g. 40% Route A with 3 hops, 60% Route B with 2 hops).addMixedSwap, the entireoptions.maxHopSlippagearray is passed to V4 sections without slicing; V2/V3 sections get nothing.We need to ensure that per-hop slippage is saved per route data model, not per trade (i.e. for split route trades)
This PR adds
maxHopSlippagesupport to theTrade.swapsobject in router-sdk, enabling per-hop slippage protection for multi-hop swaps across all route types (V2, V3, V4, and mixed routes)How Has This Been Tested?
[e.g. Manually, E2E tests, unit tests, Storybook]
Are there any breaking changes?
Purely additive, no breaking changes, no existing code uses the new field yet. Can merge independently.
Follow Ups
✨ Claude-Generated Content
Summary
Adds
maxHopSlippagesupport to theTradeclass in router-sdk, enabling per-hop slippage protection for multi-hop swaps across all route types (V2, V3, V4, and mixed routes).Changes
maxHopSlippage?: bigint[]field to theswapsarray type inTradeclassmaxHopSlippageparametermaxHopSlippagethrough the constructor for all route typesfromRoutes()static method to passmaxHopSlippagethrough populated routesHow Has This Been Tested?
This is a type extension.
Are there any breaking changes?
No -
maxHopSlippageis an optional parameter with no changes to existing behavior.