Skip to content

fix: fiat strategy submit flow and totals calculation#8726

Merged
OGPoyraz merged 5 commits into
mainfrom
ogp/fiat-strategy-fixes
May 11, 2026
Merged

fix: fiat strategy submit flow and totals calculation#8726
OGPoyraz merged 5 commits into
mainfrom
ogp/fiat-strategy-fixes

Conversation

@OGPoyraz
Copy link
Copy Markdown
Member

@OGPoyraz OGPoyraz commented May 6, 2026

Explanation

The fiat strategy had three issues that prevented correct end-to-end behavior:

  1. Provider code extraction: The submit flow was parsing the provider code from the order ID string (/providers/{provider}/orders/{orderCode}), but the order ID format no longer contains the provider prefix. Now extracts the provider code directly from the stored rampsQuote.provider field and passes the raw order ID as orderCode.

  2. Fiat asset tracking: Instead of calling RampsController:setSelectedToken (which could silently fail if tokens weren't loaded), the fiat asset's caipAssetId is now stored directly on the fiatPayment state when the payment method changes.

  3. Totals calculation: When a fiat strategy quote is present, the totals pipeline should use targetAmount (the actual bridged output) rather than amountFiat/amountUsd from token metadata — same behavior already applied for isMaxAmount transactions.

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 modify the fiat strategy execution path and totals computation, which can affect order polling, relay submission, and user-visible pricing. Risk is mitigated by updated unit tests but touches core payment flow state and calculations.

Overview
Fixes the fiat strategy end-to-end flow by deriving the on-ramp provider code from the stored rampsQuote.provider (instead of parsing the orderId) and passing the raw orderId through as the orderCode when polling RampsController:getOrder.

When the fiat payment method changes, the controller now persists the derived fiat on-ramp asset as fiatPayment.caipAssetId (new field) rather than calling RampsController:setSelectedToken.

Updates totals so that when any quote uses TransactionPayStrategy.Fiat, totals use quote.targetAmount (matching max-amount behavior) instead of summing token fiat/USD amounts.

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

@OGPoyraz OGPoyraz requested review from a team as code owners May 6, 2026 14:24
Comment on lines +290 to +292
if (data.fiatPayment) {
data.fiatPayment.caipAssetId = fiatAsset.caipAssetId;
}
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 need caipAssetId in UI to trigger headless flow, it appears RampsController:setSelectedToken is not enough anymore.

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.

Changes here were needed because headless ramps now returns raw orderId

@OGPoyraz OGPoyraz force-pushed the ogp/fiat-strategy-fixes branch from ba1242b to 1ae09f9 Compare May 6, 2026 14:28
Copy link
Copy Markdown

@cursor cursor Bot left a comment

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 5b43908. Configure here.

Comment thread packages/transaction-pay-controller/src/TransactionPayController.ts Outdated
@OGPoyraz OGPoyraz requested a review from vinistevam May 11, 2026 07:30
@OGPoyraz OGPoyraz added this pull request to the merge queue May 11, 2026
Merged via the queue into main with commit 3e626d1 May 11, 2026
366 checks passed
@OGPoyraz OGPoyraz deleted the ogp/fiat-strategy-fixes branch May 11, 2026 07:35
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