Skip to content

fix: MM pay request amount used when both paymentProvider and isPostQuote is defined#9070

Merged
jpuri merged 10 commits into
mainfrom
perps_withdraw_fix
Jun 10, 2026
Merged

fix: MM pay request amount used when both paymentProvider and isPostQuote is defined#9070
jpuri merged 10 commits into
mainfrom
perps_withdraw_fix

Conversation

@jpuri

@jpuri jpuri commented Jun 9, 2026

Copy link
Copy Markdown
Contributor

Explanation

Fix MM pay request amount used when both paymentOverride and isPostQuote is defined.

References

Related to https://consensyssoftware.atlassian.net/browse/CONF-1520

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 payment quote amounts sent to the relay API for a specific MM Pay path; wrong amounts could affect funding quotes, though scope is narrow and well-tested.

Overview
Fixes MetaMask Pay relay quote bodies when paymentOverride is Money Account and isPostQuote is true: the relay request amount for EXACT_OUTPUT now comes from transactionData.tokens[0].amountRaw instead of request.sourceTokenAmount, so the quoted output matches the destination token’s units when decimals differ.

Missing token data falls back to '0'. Tests cover the new amount source, decimal mismatch, and empty/missing transactionData; the package changelog records the fix.

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

@jpuri jpuri marked this pull request as ready for review June 10, 2026 02:14
@jpuri jpuri requested review from a team as code owners June 10, 2026 02:14
@jpuri jpuri enabled auto-merge June 10, 2026 02:33
requestBody.authorizationList = normalizeAuthorizationList(authorizationList);
requestBody.tradeType = 'EXACT_OUTPUT';
requestBody.amount = request.sourceTokenAmount;
requestBody.amount = transactionData?.tokens?.[0]?.amountRaw ?? '0';

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

request.sourceTokenAmount is raw value of source token and transactionData?.tokens?.[0]?.amountRaw is value in destination token which we need.

Using request.sourceTokenAmount is breaking perps withdraw as USDC has 8 decimal places but mUSD has 6 and relay expect mUSD value here so it result in 100X value of token and hence perps withdraw to Money Balance is failing in latest code.

matthewwalsh0
matthewwalsh0 previously approved these changes Jun 10, 2026
@jpuri jpuri requested a review from a team as a code owner June 10, 2026 09:50
matthewwalsh0
matthewwalsh0 previously approved these changes Jun 10, 2026
@jpuri jpuri added this pull request to the merge queue Jun 10, 2026
@github-merge-queue github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Jun 10, 2026
@jpuri jpuri added this pull request to the merge queue Jun 10, 2026
Merged via the queue into main with commit e30b500 Jun 10, 2026
370 checks passed
@jpuri jpuri deleted the perps_withdraw_fix branch June 10, 2026 10:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants