Skip to content

feat: use QuoteResponse V2 in bridge-controller - #9726

Merged
micaelae merged 69 commits into
mainfrom
swaps4546-v2-controller-update
Aug 4, 2026
Merged

feat: use QuoteResponse V2 in bridge-controller#9726
micaelae merged 69 commits into
mainfrom
swaps4546-v2-controller-update

Conversation

@micaelae

@micaelae micaelae commented Jul 31, 2026

Copy link
Copy Markdown
Member

Explanation

Store and consume QuoteResponse v2 in the bridge-controller. Implements v1<>v2 coercers and metadata merge logic for client and controller compatibility during migration. See changelogs for more details

Draft client PRs

References

Checklist

  • I've updated the test suite for new or updated code as appropriate
  • I've updated documentation (JSDoc, Markdown, etc.) for new or updated code as appropriate
  • I've communicated my changes to consumers by updating changelogs for packages I've changed
  • I've introduced breaking changes in this PR and have prepared draft pull requests for clients and consumer packages to resolve them

Note

High Risk
Large breaking API and quote-shape change across swap/bridge/batch-sell paths; incorrect coercion or fee/sorting regressions would affect quote display, fees, and transaction submission.

Overview
BREAKING: QuoteResponse in @metamask/bridge-controller now means V2; V1 remains as QuoteResponseV1. Controller quotes state, SSE quote streaming, and batch-sell paths coerce incoming payloads with toQuoteResponseV2 and validate against the V2 shape (quote.src / quote.dest, fee arrays, etc.).

Quote sorting and batch-sell aggregates move to V2 fields—e.g. default ordering uses priceData.priceImpact and quote.dest.amount, and selectBatchSellQuotes sums destination amounts via sumAmounts instead of legacy metadata keys. appendFeesToQuotes now requires a CAIP chainId and skips fee enrichment when multiple source chains appear in one batch.

fetchBatchSellTrades still posts V1 bodies (toQuoteResponseV1) for backend compatibility while accepting V2 quotes from callers. Metrics helpers read gas/return/symbols from the nested V2 quote structure.

@metamask/bridge-status-controller: submitTx, submitIntent, and submitBatchSell accept V2 quotes from clients but normalize to V1 + metadata before existing submission/history logic runs.

Reviewed by Cursor Bugbot for commit cf1a542. Bugbot is set up for automated code reviews on this repo. Configure here.

@micaelae
micaelae changed the base branch from swaps4546-v2-coercers to swaps4546-v2-metadata July 31, 2026 04:06
@micaelae

micaelae commented Aug 3, 2026

Copy link
Copy Markdown
Member Author

@metamaskbot publish-preview

Comment thread packages/bridge-controller/src/index.ts Outdated

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

There are 2 total unresolved issues (including 1 from previous review).

Fix All in Cursor

❌ 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 a5a6e0d. Configure here.

Comment thread packages/bridge-controller/src/utils/fetch.ts
Comment thread packages/bridge-controller/src/utils/metrics/properties.ts Outdated
Base automatically changed from swaps4546-v2-metadata to main August 4, 2026 18:13
@micaelae

micaelae commented Aug 4, 2026

Copy link
Copy Markdown
Member Author

@metamaskbot publish-preview

@github-actions

github-actions Bot commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

Preview builds have been published. Learn how to use preview builds in other projects.

Expand for full list of packages and versions.
@metamask-previews/account-tree-controller@7.6.0-preview-426400357
@metamask-previews/accounts-controller@39.0.6-preview-426400357
@metamask-previews/address-book-controller@7.1.2-preview-426400357
@metamask-previews/ai-controllers@0.8.0-preview-426400357
@metamask-previews/analytics-controller@2.0.0-preview-426400357
@metamask-previews/analytics-data-regulation-controller@0.0.0-preview-426400357
@metamask-previews/announcement-controller@8.1.0-preview-426400357
@metamask-previews/app-metadata-controller@2.0.1-preview-426400357
@metamask-previews/approval-controller@9.0.2-preview-426400357
@metamask-previews/assets-controller@13.1.0-preview-426400357
@metamask-previews/assets-controllers@110.1.1-preview-426400357
@metamask-previews/authenticated-user-storage@3.0.1-preview-426400357
@metamask-previews/base-controller@9.1.0-preview-426400357
@metamask-previews/base-data-service@0.1.3-preview-426400357
@metamask-previews/bitcoin-regtest-up@1.0.0-preview-426400357
@metamask-previews/bridge-controller@78.1.0-preview-426400357
@metamask-previews/bridge-status-controller@74.6.2-preview-426400357
@metamask-previews/build-utils@3.0.4-preview-426400357
@metamask-previews/chain-agnostic-permission@1.7.0-preview-426400357
@metamask-previews/chomp-api-service@4.0.0-preview-426400357
@metamask-previews/claims-controller@0.5.4-preview-426400357
@metamask-previews/client-controller@1.0.1-preview-426400357
@metamask-previews/client-utils@2.0.0-preview-426400357
@metamask-previews/compliance-controller@2.1.0-preview-426400357
@metamask-previews/composable-controller@12.0.1-preview-426400357
@metamask-previews/config-registry-controller@2.0.1-preview-426400357
@metamask-previews/connectivity-controller@0.3.0-preview-426400357
@metamask-previews/controller-utils@12.3.0-preview-426400357
@metamask-previews/core-backend@8.1.1-preview-426400357
@metamask-previews/delegation-controller@3.0.2-preview-426400357
@metamask-previews/earn-controller@12.2.3-preview-426400357
@metamask-previews/eip-5792-middleware@3.0.5-preview-426400357
@metamask-previews/eip-7702-internal-rpc-middleware@0.1.1-preview-426400357
@metamask-previews/eip1193-permission-middleware@2.0.1-preview-426400357
@metamask-previews/ens-controller@19.1.6-preview-426400357
@metamask-previews/eth-block-tracker@15.0.1-preview-426400357
@metamask-previews/eth-json-rpc-middleware@24.0.0-preview-426400357
@metamask-previews/eth-json-rpc-provider@6.0.1-preview-426400357
@metamask-previews/foundryup@1.0.1-preview-426400357
@metamask-previews/gas-fee-controller@26.3.1-preview-426400357
@metamask-previews/gator-permissions-controller@5.0.1-preview-426400357
@metamask-previews/geolocation-controller@1.0.0-preview-426400357
@metamask-previews/java-tron-up@1.0.0-preview-426400357
@metamask-previews/json-rpc-engine@10.5.0-preview-426400357
@metamask-previews/json-rpc-middleware-stream@8.0.8-preview-426400357
@metamask-previews/keyring-controller@27.1.0-preview-426400357
@metamask-previews/local-node-utils@1.0.0-preview-426400357
@metamask-previews/logging-controller@8.0.2-preview-426400357
@metamask-previews/message-manager@14.1.2-preview-426400357
@metamask-previews/messenger@2.0.0-preview-426400357
@metamask-previews/messenger-cli@0.2.0-preview-426400357
@metamask-previews/money-account-api-data-service@0.4.0-preview-426400357
@metamask-previews/money-account-balance-service@2.4.1-preview-426400357
@metamask-previews/money-account-controller@0.3.3-preview-426400357
@metamask-previews/money-account-upgrade-controller@3.0.1-preview-426400357
@metamask-previews/money-account-utils@1.1.0-preview-426400357
@metamask-previews/multichain-account-service@13.0.0-preview-426400357
@metamask-previews/multichain-api-middleware@4.0.2-preview-426400357
@metamask-previews/multichain-network-controller@3.2.2-preview-426400357
@metamask-previews/multichain-transactions-controller@7.1.1-preview-426400357
@metamask-previews/name-controller@9.1.2-preview-426400357
@metamask-previews/network-connection-banner-controller@0.1.2-preview-426400357
@metamask-previews/network-controller@35.0.1-preview-426400357
@metamask-previews/network-enablement-controller@6.0.2-preview-426400357
@metamask-previews/notification-services-controller@26.0.1-preview-426400357
@metamask-previews/passkey-controller@3.0.0-preview-426400357
@metamask-previews/permission-controller@13.1.1-preview-426400357
@metamask-previews/permission-log-controller@5.1.0-preview-426400357
@metamask-previews/perps-controller@10.0.0-preview-426400357
@metamask-previews/phishing-controller@17.3.1-preview-426400357
@metamask-previews/platform-api-docs@0.0.0-preview-426400357
@metamask-previews/polling-controller@16.0.9-preview-426400357
@metamask-previews/preferences-controller@23.1.0-preview-426400357
@metamask-previews/profile-metrics-controller@4.0.3-preview-426400357
@metamask-previews/profile-sync-controller@29.0.0-preview-426400357
@metamask-previews/ramps-controller@20.0.0-preview-426400357
@metamask-previews/rate-limit-controller@7.0.1-preview-426400357
@metamask-previews/react-data-query@0.2.2-preview-426400357
@metamask-previews/remote-feature-flag-controller@5.0.0-preview-426400357
@metamask-previews/sample-controllers@5.0.4-preview-426400357
@metamask-previews/seedless-onboarding-controller@10.1.1-preview-426400357
@metamask-previews/selected-network-controller@26.1.6-preview-426400357
@metamask-previews/sentinel-api-service@1.0.0-preview-426400357
@metamask-previews/shield-controller@5.1.3-preview-426400357
@metamask-previews/signature-controller@39.2.9-preview-426400357
@metamask-previews/smart-transactions-controller@25.0.3-preview-426400357
@metamask-previews/snap-account-service@2.1.1-preview-426400357
@metamask-previews/social-controllers@2.7.1-preview-426400357
@metamask-previews/solana-test-validator-up@1.0.0-preview-426400357
@metamask-previews/stellar-quickstart-up@0.0.0-preview-426400357
@metamask-previews/storage-service@1.0.2-preview-426400357
@metamask-previews/subscription-controller@6.2.2-preview-426400357
@metamask-previews/transaction-controller@69.5.0-preview-426400357
@metamask-previews/transaction-pay-controller@26.2.2-preview-426400357
@metamask-previews/user-operation-controller@41.2.8-preview-426400357
@metamask-previews/wallet@9.0.0-preview-426400357
@metamask-previews/wallet-cli@0.0.0-preview-426400357

// Client can render special UI or skip the quote card row for quotes with missing fee data
console.error(
`Failed to compute non-EVM fees for quote ${quote.requestId}:`,
`Failed to compute non-EVM fees for quote in ${chainId}:`,

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.

Does this change limit our ability to look these errors up in some way?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

We used to log the requestId, which is not a valid lookup key. But this is a good call, I'll log the quoteId instead since we can actually use it

@micaelae
micaelae added this pull request to the merge queue Aug 4, 2026
Merged via the queue into main with commit c2d2945 Aug 4, 2026
50 checks passed
@micaelae
micaelae deleted the swaps4546-v2-controller-update branch August 4, 2026 21:48
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.

2 participants