Skip to content

Georlav/back 2458/swaps sdk router v2 support#147

Open
georlav wants to merge 16 commits intomainfrom
georlav/BACK-2458/swaps-sdk-router-v2-support
Open

Georlav/back 2458/swaps sdk router v2 support#147
georlav wants to merge 16 commits intomainfrom
georlav/BACK-2458/swaps-sdk-router-v2-support

Conversation

@georlav
Copy link
Copy Markdown

@georlav georlav commented Mar 27, 2026

Adds Rainbow Router v2 support to the swaps SDK.

@linear
Copy link
Copy Markdown

linear Bot commented Mar 27, 2026

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds Rainbow Router v2 support to the swaps SDK by introducing v2 router addresses/ABI and extending quote execution logic to handle v2-specific calldata (including a swapId).

Changes:

  • Add Router v2 contract address constants (Mainnet/Base) and a new RainbowRouterV2 ABI.
  • Extend Quote with routerVersion and swapId, and update quote execution/preparation to select v1 vs v2 router + calldata.
  • Add unit tests for v2 swapId UUID validation and v2 router allowlisting.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
sdk/src/utils/constants.ts Introduces Router v2 address constants for Mainnet/Base.
sdk/src/types/index.ts Extends Quote response shape with routerVersion and swapId.
sdk/src/quotes.ts Adds router-version-aware address selection, v2 ABI usage, and swapIdbytes16 encoding for v2 calldata.
sdk/src/quotes.test.ts Adds coverage for invalid v2 swapId UUID and v2 router allowlisting on Base.
sdk/src/abi/RainbowRouterV2.json Adds ABI definition for Router v2 contract methods/events.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread sdk/src/utils/constants.ts Outdated
Comment thread sdk/src/quotes.ts
Comment thread sdk/src/quotes.ts Outdated
Comment thread sdk/src/quotes.ts Outdated
@georlav georlav requested a review from Copilot March 27, 2026 13:05
@georlav georlav marked this pull request as ready for review March 27, 2026 13:07
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread sdk/src/types/index.ts
Comment thread sdk/src/quotes.test.ts
Comment thread sdk/src/quotes.ts Outdated
Copy link
Copy Markdown
Contributor

@fringlesinthestreet fringlesinthestreet left a comment

Choose a reason for hiding this comment

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

Will make a small PR on swap API for the specific use case of swap initiator!=receiver -> will be forcing the v1 so v2 flows can be cleaner

Comment thread sdk/src/quotes.ts Outdated
Comment thread sdk/src/quotes.ts Outdated
Comment thread sdk/src/quotes.ts Outdated
if (quote.fallback) {
// TODO: Router v2 quotes don't currently support fallback routing.
// Remove this once router v2 supports fallback routing.
if (quote.routerVersion !== 'v2' && quote.fallback) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

There are still usecases using this: swap receiver != swap initiator

Although we can just force the API flow to choose the v1+fallback flow IMO

Comment thread sdk/src/types/index.ts
Comment thread sdk/src/quotes.ts
Comment thread sdk/src/quotes.ts Outdated
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread sdk/src/quotes.ts Outdated
Comment thread sdk/src/quotes.ts
Copy link
Copy Markdown
Contributor

@fringlesinthestreet fringlesinthestreet left a comment

Choose a reason for hiding this comment

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

Most of the changes look good! I'd suggest one change as I believe the router version should be something encapsulated on this SDK's responsibility and not leak that to the clients

Comment thread sdk/src/quotes.ts Outdated
Copy link
Copy Markdown
Contributor

@fringlesinthestreet fringlesinthestreet left a comment

Choose a reason for hiding this comment

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

Btw it needs a version bump on package.json.

As discussed, let's hold the PR open until he have the production addresses for v2 router.

Copy link
Copy Markdown
Member

@blewater blewater left a comment

Choose a reason for hiding this comment

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

LGTM the approach, but update the test address to the latest in go-util-libs 0x00000000503417aB25A8AD65E1D9E25078F40696 and thanks for the approval :)

Comment thread sdk/src/utils/constants.ts Outdated
Copy link
Copy Markdown
Member

@blewater blewater left a comment

Choose a reason for hiding this comment

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

@georlav The sdk will need to pass the client session ID to the backend.

Comment thread sdk/src/quotes.ts
* @param {number} params.slippage
* @returns {string}
*/
export const buildRainbowQuoteUrl = ({
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

We need also the session-id that the client apps will send.

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.

4 participants