Skip to content

feat: read swap cost priceData from bridge-api response - #10012

Merged
micaelae merged 6 commits into
mainfrom
swap-cost-metadata
Aug 31, 2026
Merged

feat: read swap cost priceData from bridge-api response#10012
micaelae merged 6 commits into
mainfrom
swap-cost-metadata

Conversation

@micaelae

@micaelae micaelae commented Aug 28, 2026

Copy link
Copy Markdown
Member

Explanation

This change reads the cost metadata provided by the backend and uses it to sort quotes:

{
  quote: {
    priceData: {
      cost: {
        usd: "1.53252"
      }
    }
  }
}

Other changes

  • priceImpact is no longer used as the quote cost
  • sort quotes by cost if it exists, use priceImpact as a fallback

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

Medium Risk
Changes recommended-quote selection and displayed cost metadata in swap/bridge flows; incorrect backend cost data could surface the wrong quote, but scope is limited to quote presentation and sorting.

Overview
Bridge quotes now consume priceData.cost from the bridge API instead of treating priceImpact as cost. Quote validation, fiat conversion (toCurrencyValues), and V1/V2 metadata mappers were updated so cost is a distinct field on priceData and on merged quote metadata.

Default quote ordering prefers ascending priceData.cost.valueInCurrency when every quote has it; otherwise it keeps the existing fallbacks (priceImpact.amount, then priceImpact.valueInCurrency, then destination amount). That changes which quote is recommended when the API sends cost.

Tests and snapshots were extended for the new sort priority, Phase 1.5 fallbacks, and related selector edge cases.

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

@micaelae
micaelae force-pushed the swap-cost-metadata branch from 2904447 to abc8c12 Compare August 31, 2026 18:21
@micaelae
micaelae marked this pull request as ready for review August 31, 2026 18:52
@micaelae
micaelae requested review from a team as code owners August 31, 2026 18:52
@micaelae
micaelae deployed to default-branch August 31, 2026 18:52 — with GitHub Actions Active
@micaelae
micaelae enabled auto-merge August 31, 2026 18:55
Comment thread packages/bridge-controller/src/selectors.ts
@micaelae
micaelae disabled auto-merge August 31, 2026 18:58
@cursor
cursor Bot requested review from bfullam and infiniteflower August 31, 2026 18:59

@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 639e999. Configure here.

@micaelae
micaelae force-pushed the swap-cost-metadata branch from 639e999 to d6091c6 Compare August 31, 2026 19:04
@micaelae
micaelae enabled auto-merge August 31, 2026 19:07
@micaelae
micaelae added this pull request to the merge queue Aug 31, 2026
Merged via the queue into main with commit 20bd45b Aug 31, 2026
51 checks passed
@micaelae
micaelae deleted the swap-cost-metadata branch August 31, 2026 19:09
@cursor cursor Bot mentioned this pull request Aug 31, 2026
4 tasks
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