chore: support V1 and V2 quotes when calculating swap metadata - #9727
Open
micaelae wants to merge 6 commits into
Open
chore: support V1 and V2 quotes when calculating swap metadata#9727micaelae wants to merge 6 commits into
micaelae wants to merge 6 commits into
Conversation
infiniteflower
approved these changes
Aug 3, 2026
micaelae
marked this pull request as ready for review
August 3, 2026 23:50
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 displayed swap amounts, fees, and price impact are derived for v2 quotes, which can affect quote sorting and user-facing numbers; scope is limited to metadata calculation with broad test updates.
Overview
calcQuoteMetadatanow accepts both QuoteResponse v1 and v2. V2 inputs are detected withQuoteResponseSchemaV2, normalized viatoQuoteResponseV1, and calculated with the existing v1 helpers so swap/bridge UI metadata stays on the legacy shape.Sent amount and fees change for v2:
calcSentAmounttakes anisQuoteV2flag so v2srcTokenAmountis treated like intent quotes (total commitment, no extrafeeDataon top).calcRelayerFeenow uses a precomputedsentAmountinstead of recomputing it.minDestTokenAmountfalls back todestTokenAmountwhen missing.Metadata output is tighter:
calcPriceImpactreturnsundefinedwhen fiat/USD deltas are missing; optional fields (cost,adjustedReturn,priceImpact, etc.) are only attached when at least one value is present.sumAmountsinnumber-formatterscan sum additional v2 fee keys (normalizedAmount,minAmountUsd, etc.).Tests and mocks were updated (selector/calculator specs drive expectations through
calcQuoteMetadata/toQuoteMetadataV1, EVM vs Solana trade shapes, renamedgetMockBridgeQuotes*V1helpers).Reviewed by Cursor Bugbot for commit 6644859. Bugbot is set up for automated code reviews on this repo. Configure here.