feat: resolve swap quote metadata by migration phase - #9744
Conversation
This reverts commit aa5c5d2.
|
@metamaskbot publish-preview |
|
Preview builds have been published. Learn how to use preview builds in other projects. Expand for full list of packages and versions. |
363f891 to
8257447
Compare
cb46f5f to
3885f72
Compare
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 3885f72. Configure here.
| priceImpact: toTokenAmountValues(priceData?.priceImpact), | ||
| // Use priceImpact as cost | ||
| cost: toTokenAmountValues(priceData?.priceImpact), | ||
| }), |
There was a problem hiding this comment.
Wrong cost from price impact
Medium Severity
In the V2 metadata path, cost is copied from priceImpact instead of being derived from sentAmount and adjustedReturn. Under V2WithV1Fallback, that value is merged over the correct legacy cost, so submit/history metrics can store an understated cost when network fees differ from price impact.
Additional Locations (1)
Reviewed by Cursor Bugbot for commit 3885f72. Configure here.


Explanation
Draft client PRs
References
Checklist
Note
High Risk
Breaking selector and
mergeQuoteMetadataAPIs plus phase-dependent fee/amount shaping can change what users see and what metrics receive if clients pass the wrong phase or lag on adoption.Overview
Introduces a phased migration from client-calculated legacy quote metadata to V2 nested metadata from the bridge API, controlled by a new
migrationPhaseparameter.bridge-controller: Clients must pass optional
migrationPhaseon quote selectors (defaults to Phase 1). ExportedQuoteMetadataMigrationPhasedefinesV1Data(legacycalcQuoteMetadataonly),V2WithV1Fallback(prefer API V2 + fiat derived fromusd, fall back to legacy), andV2Only(no legacy top-level fields).mergeQuoteMetadatais breaking: V1 quote support removed; signature now includesmigrationPhaseand optional V2currencyValuesfrom newtoCurrencyValues.toQuoteMetadataV1is phase-aware so submission/history can rebuild legacy-shaped fields from V2 when needed.bridge-status-controller:
submitTx,submitIntent, andsubmitBatchSellacceptmigrationPhaseand use it when coercing V2 quotes to V1 for metrics/history (spread merge instead ofmergeQuoteMetadatain tests).Consumers (extension/mobile draft PRs) must adopt the new selector param and align phase with their rollout.
Reviewed by Cursor Bugbot for commit 3885f72. Bugbot is set up for automated code reviews on this repo. Configure here.