Skip to content

refactor: bridge QuoteMetadata read/write#9507

Open
micaelae wants to merge 8 commits into
mainfrom
swaps4546-refactor-quote-metadata
Open

refactor: bridge QuoteMetadata read/write#9507
micaelae wants to merge 8 commits into
mainfrom
swaps4546-refactor-quote-metadata

Conversation

@micaelae

@micaelae micaelae commented Jul 14, 2026

Copy link
Copy Markdown
Member

Explanation

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
Declared breaking API and behavior changes to fee/metadata shapes affect swap/bridge quote display, sorting, balance checks, and analytics; clients must upgrade optional access patterns.

Overview
BREAKING: QuoteMetadata and nested TokenAmountValues are now DeepPartial, and fee helpers stop coercing missing inputs to "0" or null—undefined fields stay undefined. Consumers must use optional chaining (as in bridge-status-controller) and may see different UI when gas or rate data is incomplete.

Quote metadata logic moves out of selectors.ts into utils/quote-metadata.ts (calcQuoteMetadata, mergeQuoteMetadata). selectBridgeQuotesWithMetadata calls those instead of inlining calculations; QuoteMetadata / TokenAmountValues are exported from the new module rather than types.ts. Sorting and metrics paths use safer access (e.g. quote?.cost?.valueInCurrency).

bridge-status-controller tests and utils adopt mergeQuoteMetadata to attach metadata to quote fixtures and align history/metrics/snaps with optional metadata fields.

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

@micaelae micaelae requested review from a team as code owners July 14, 2026 18:22
@micaelae micaelae temporarily deployed to default-branch July 14, 2026 18:23 — with GitHub Actions Inactive
Comment thread packages/bridge-controller/src/utils/quote.ts Outdated
Comment thread packages/bridge-controller/src/utils/quote.ts
@micaelae micaelae enabled auto-merge July 14, 2026 19:10

@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.

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 9afe7b6. Configure here.

const l1GasFeesInDecGWei = weiHexToGweiDec(toHex(l1GasFeesInHexWei ?? '0'));
const gasFeesInDecGwei = totalGasLimitInDec
.times(feePerGasInDecGwei ?? '0')
?.times(feePerGasInDecGwei ?? '0')

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Missing trade gas crashes fee

High Severity

When tradeGasLimit is missing or zero, calcTotalGasFee leaves totalGasLimitInDec undefined, then optional chaining on times yields undefined and the following .plus(l1GasFeesInDecGWei) runs on undefined, which throws. Approval-only gas and L1 fees are also skipped instead of being summed like before.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 9afe7b6. Configure here.

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.

1 participant