Skip to content

feat(router-sdk): add maxHopSlippage to Trade.swaps#529

Draft
kristiehuang wants to merge 1 commit intomainfrom
03-02-feat_router-sdk_add_maxhopslippage_to_trade.swaps
Draft

feat(router-sdk): add maxHopSlippage to Trade.swaps#529
kristiehuang wants to merge 1 commit intomainfrom
03-02-feat_router-sdk_add_maxhopslippage_to_trade.swaps

Conversation

@kristiehuang
Copy link
Collaborator

@kristiehuang kristiehuang commented Mar 2, 2026

Description

For maxHopSlippage, a partial implementation exists for multi-hop V4-only routes in UR-sdk, but it is incorrect:

  1. Flat array on SwapOptions -- A single maxHopSlippage?: BigNumber[] on SwapOptions cannot 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).
  2. Mixed routes pass the full array -- In addMixedSwap, the entire options.maxHopSlippage array 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 maxHopSlippage support to the Trade.swaps object 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

  • in order to be used in UR-sdk, need to publish minor version bump to router-sdk

✨ Claude-Generated Content

Summary

Adds maxHopSlippage support to the Trade class in router-sdk, enabling per-hop slippage protection for multi-hop swaps across all route types (V2, V3, V4, and mixed routes).

Changes

  • Added optional maxHopSlippage?: bigint[] field to the swaps array type in Trade class
  • Extended route input types for V2, V3, V4, and mixed routes to accept maxHopSlippage parameter
  • Propagated maxHopSlippage through the constructor for all route types
  • Extended fromRoutes() static method to pass maxHopSlippage through populated routes

How Has This Been Tested?

This is a type extension.

Are there any breaking changes?

No - maxHopSlippage is an optional parameter with no changes to existing behavior.

@kristiehuang kristiehuang force-pushed the 03-02-feat_router-sdk_add_maxhopslippage_to_trade.swaps branch from 717b997 to 88ab699 Compare March 2, 2026 21:24
Copy link
Collaborator Author

kristiehuang commented Mar 2, 2026

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