Conversation
|
Review the following changes in direct dependencies. Learn more about Socket for GitHub.
|
|
Caution MetaMask internal reviewing guidelines:
|
| export function pickBestFiatQuote( | ||
| quotes: RampsQuotesResponse, | ||
| ): RampsQuote | undefined { | ||
| return quotes.success?.find( | ||
| // TODO: Implement provider selection logic; force Transak staging for now. | ||
| (quote) => quote.provider === '/providers/transak-native-staging', | ||
| ); | ||
| } |
There was a problem hiding this comment.
This currently blocks the PR and will change once we define together with Ramps team.
FiatStrategy and getQuotes functionalityFiatStrategy and getQuotes functionality
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.
| .plus(adjustedAmountFiat) | ||
| .multipliedBy(100) | ||
| .dividedBy(10_000); | ||
| } |
There was a problem hiding this comment.
MetaMask fee double-counts base fiat amount
High Severity
getMetaMaskFee computes (amountFiat + adjustedAmountFiat) * 100 / 10_000, but adjustedAmountFiat is already defined as amountFiat + relayTotalFeeUsd. This makes the effective formula (2 * amountFiat + relayTotalFeeUsd) * 0.01, double-counting amountFiat. The stated intent is "100 bps" but the effective rate on the user's base amount is significantly higher. Likely the fee base intended here is just adjustedAmountFiat alone (or just amountFiat alone), not their sum.


Explanation
This PR introduces
FiatStrategy:TransactionPayStrategy.Fiatand registersFiatStrategyin strategy resolution.MMPAY_FIAT_ASSET_ID_BY_TX_TYPE).fiat-quotes.tswith relay-first estimation:fiatPayment.amountFiat+ selected payment methodstrategy: fiatquotefees.provider= relay provider/swap feefees.fiatProvider= ramps provider/network feefees.metaMask= MM fee (100 bps overamountFiat + adjustedAmountFiat)metamaskPay.bridgeFeeFiatwhen fiat provider fee exists.References
Checklist
Note
Medium Risk
Introduces a new payment strategy and fee bucket that changes quote selection and total/metrics calculations; incorrect mapping or fee aggregation could affect displayed costs and downstream analytics.
Overview
Adds a new
TransactionPayStrategy.Fiatwith aFiatStrategyimplementation that fetches quotes by first estimating a synthetic Relay quote, then requestingRampsController:getQuoteswith an adjusted fiat amount and returning a single combined quote.Extends transaction-pay state/types to support per-transaction
fiatPaymentinputs and a newfees.fiatProviderbucket, updates totals calculation andmetamaskPay.bridgeFeeFiatmetric aggregation to include fiat-provider fees when present, and wires in@metamask/ramps-controller(deps/tsconfig) plus unit tests for the new flow.Written by Cursor Bugbot for commit 23e8bab. This will update automatically on new commits. Configure here.