chore: support V1 and V2 quotes when calculating swap metadata - #9727
Merged
Conversation
infiniteflower
previously approved these changes
Aug 3, 2026
micaelae
marked this pull request as ready for review
August 3, 2026 23:50
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 8b8ca16. Configure here.
micaelae
enabled auto-merge
August 4, 2026 17:57
infiniteflower
approved these changes
Aug 4, 2026
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.

Explanation
Update
calcQuoteMetadatautil to handle both V1 and V2 quotes. Legacy metadata calculators continue to use the V1 schema but are able to read V2 quotesReferences
Implements https://consensyssoftware.atlassian.net/browse/SWAPS-4546
Checklist
Note
Medium Risk
Changes how sent amounts, relayer fees, and optional metadata are derived for quotes shown in swap/bridge flows; incorrect V2 handling could misstate costs or sorting, though coverage is expanded in calculator and selector tests.
Overview
calcQuoteMetadatanow accepts V1 or V2QuoteResponsevalues: V2 inputs are detected and coerced throughtoQuoteResponseV1before the existing calculators run, so swap/bridge UI metadata keeps using the legacy V1 shape.V2-specific behavior is layered on top of that path.
calcSentAmounttakes anisQuoteV2flag so source fees infeeDataare not added on top ofsrcTokenAmount(same idea as intent-based quotes, avoiding double-count).calcRelayerFeenow receives the precomputedsentAmountinstead of recomputing it.calcPriceImpactreturnsundefinedwhen fiat inputs are missing, and optional metadata fields (cost,priceImpact, etc.) are only attached when at least one value is present.sumAmountsinnumber-formatterscan aggregate additional V2 fee fields (normalizedAmount,minAmount, and related fiat keys).Tests and mocks were updated (factory helpers, selector expectations, EVM vs non-EVM trade shapes) to exercise V2 quotes end-to-end.
Reviewed by Cursor Bugbot for commit 21a8c36. Bugbot is set up for automated code reviews on this repo. Configure here.