Conversation
There was a problem hiding this comment.
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
RainbowRouterV2ABI. - Extend
QuotewithrouterVersionandswapId, 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 swapId→bytes16 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.
There was a problem hiding this comment.
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.
fringlesinthestreet
left a comment
There was a problem hiding this comment.
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
| 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) { |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
fringlesinthestreet
left a comment
There was a problem hiding this comment.
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
fringlesinthestreet
left a comment
There was a problem hiding this comment.
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.
blewater
left a comment
There was a problem hiding this comment.
LGTM the approach, but update the test address to the latest in go-util-libs 0x00000000503417aB25A8AD65E1D9E25078F40696 and thanks for the approval :)
| * @param {number} params.slippage | ||
| * @returns {string} | ||
| */ | ||
| export const buildRainbowQuoteUrl = ({ |
There was a problem hiding this comment.
We need also the session-id that the client apps will send.
Adds Rainbow Router v2 support to the swaps SDK.