feat: define swap QuoteResponse V2 schema validators - #9724
Merged
Conversation
This reverts commit 158b79f.
schema
micaelae
marked this pull request as ready for review
July 31, 2026 04:36
micaelae
enabled auto-merge
July 31, 2026 04:36
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 e9fc1d7. Configure here.
infiniteflower
approved these changes
Aug 3, 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
Implements schema definitions and validators based on this ADR: https://github.com/MetaMask/decisions/blob/main/decisions/trading/0057-swap-bridge-quote-metadata-migration.md
References
Implements https://consensyssoftware.atlassian.net/browse/SWAPS-4546
Checklist
Note
Medium Risk
Touches core bridge quote/trade validation shapes that downstream clients will adopt; changes are mostly additive but incorrect v2 parsing could affect migration consumers.
Overview
Adds QuoteResponse v2 validation (
validateQuoteResponse,QuoteSchemaV2) aligned with the swap/bridge quote metadata migration: quotes usesrc/destamount + asset blocks (AmountsAndAsset+BridgeAssetV2), array-basedfeeData(includingnetwork/relayer), richerpriceData, andStepSchemaV2. Trade/approval shapes are validated per CAIP namespace (EVM, Solana, Tron, Bitcoin, Stellar) derived from the source asset’sassetId.Introduces
BridgeAssetV2/MinimalAsset(CAIPassetId, optional security metadata) andvalidateBridgeAssetV2, while keeping v1BridgeAssetinbridge-asset.ts(deprecated) and re-exporting validators/types from the package entry.NumberStringSchemais renamed toPositiveNumberStringSchemawhere used (e.g. batch-sell fees, tx fee gas limits).Runtime quote fetching in this package still uses v1 (
validateQuoteResponseV1); v2 is exported for consumers/migration. Test fixtures/snapshots normalize EVM addresses to lowercase.Reviewed by Cursor Bugbot for commit e8b7fa7. Bugbot is set up for automated code reviews on this repo. Configure here.