Skip to content

feat: Implement FiatStrategy and getQuotes functionality#8121

Open
OGPoyraz wants to merge 3 commits intomainfrom
ogp/7069
Open

feat: Implement FiatStrategy and getQuotes functionality#8121
OGPoyraz wants to merge 3 commits intomainfrom
ogp/7069

Conversation

@OGPoyraz
Copy link
Member

@OGPoyraz OGPoyraz commented Mar 5, 2026

Explanation

This PR introduces FiatStrategy:

  • Adds TransactionPayStrategy.Fiat and registers FiatStrategy in strategy resolution.
  • Adds Fiat asset mapping by tx type in constants (MMPAY_FIAT_ASSET_ID_BY_TX_TYPE).
  • Implements Fiat quote flow in fiat-quotes.ts with relay-first estimation:
    • reads fiatPayment.amountFiat + selected payment method
    • estimates relay fees first
    • requests ramps quotes with adjusted fiat amount
    • returns one combined strategy: fiat quote
  • Splits fees in the combined quote:
    • fees.provider = relay provider/swap fee
    • fees.fiatProvider = ramps provider/network fee
    • fees.metaMask = MM fee (100 bps over amountFiat + adjustedAmountFiat)
  • Updates totals/metadata sync so fee aggregation stays consistent, including combined metamaskPay.bridgeFeeFiat when fiat provider fee exists.
  • Adds package wiring for ramps types/dependency and updates changelog.

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
Adds a new Fiat payment strategy that combines Relay fee estimation with Ramps quote retrieval and introduces a new fee bucket (fees.fiatProvider), which can affect totals and transaction metadata calculations.

Overview
Adds a new MM Pay FiatStrategy and wiring (TransactionPayStrategy.Fiat) to generate quotes by first estimating fees via Relay, then requesting Ramps quotes using an adjusted fiat amount (user amount + estimated relay fees), returning a single combined quote.

Introduces TransactionPayFiatAsset + tx-type-to-fiat-asset mapping, adds RampsController:getQuotes to messenger AllowedActions, and updates fee/totals plumbing to support a separate fees.fiatProvider bucket (including aggregating it into totals and metamaskPay.bridgeFeeFiat).

Includes new unit tests for the fiat quote flow/utilities and adds @metamask/ramps-controller dependency/build references; fiat execute is currently a placeholder returning no tx hash.

Written by Cursor Bugbot for commit ee58873. This will update automatically on new commits. Configure here.

@OGPoyraz OGPoyraz requested review from a team as code owners March 5, 2026 14:56
@socket-security
Copy link

socket-security bot commented Mar 5, 2026

No dependency changes detected. Learn more about Socket for GitHub.

👍 No dependency changes detected in pull request

@OGPoyraz OGPoyraz changed the title feat: Implement FiatStrategy and getQuotes functionality [DONT MERGE] feat: Implement FiatStrategy and getQuotes functionality Mar 5, 2026
@OGPoyraz OGPoyraz changed the title [DONT MERGE] feat: Implement FiatStrategy and getQuotes functionality feat: Implement FiatStrategy and getQuotes functionality Mar 17, 2026
@OGPoyraz
Copy link
Member Author

@SocketSecurity ignore npm/@metamask/ramps-controller@12.0.0

Copy link

@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 2 potential issues.

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.

amount: adjustedAmount,
paymentMethods: [selectedPaymentMethodId],
walletAddress,
});
Copy link

Choose a reason for hiding this comment

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

Missing assetId in ramps getQuotes call

High Severity

The RampsController:getQuotes call is missing the assetId parameter. The fiatAsset object (derived from deriveFiatAssetForFiatPayment) contains a caipAssetId field that was clearly intended to be passed as assetId, but it's never included in the call. The RampsController.getQuotes method validates that assetId is present and throws "assetId is required." if neither the parameter nor this.state.tokens.selected?.assetId is available. This causes the fiat quote flow to either silently fail (caught by try-catch, returning []) or use an unrelated asset from ramps controller state.

Additional Locations (1)
Fix in Cursor Fix in Web

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