fix: use typed amount for Money Account max source calculations - #9707
Merged
Conversation
jpuri
added a commit
to MetaMask/metamask-mobile
that referenced
this pull request
Jul 30, 2026
With MetaMask/core#9707, TPC uses the typed required amount for Money Account max instead of bare on-chain mUSD. Re-enable isMaxAmount on Max for deposits funded from the money account so quotes use EXACT_INPUT and fees are taken from the full withdrawable balance. Co-authored-by: Cursor <cursoragent@cursor.com>
11 tasks
jpuri
marked this pull request as draft
July 30, 2026 11:33
isMaxAmount was substituting the pay token on-chain balance, which for Money Account is only un-vaulted mUSD. Use the typed required amount instead so Max deposits (e.g. Send to Perps) keep the full withdrawable total and can use EXACT_INPUT. Co-authored-by: Cursor <cursoragent@cursor.com>
jpuri
force-pushed
the
fix/tpc-money-account-max-exact-input
branch
from
July 30, 2026 11:45
f2d6d1c to
f37ea5d
Compare
jpuri
added a commit
to MetaMask/metamask-mobile
that referenced
this pull request
Jul 30, 2026
With MetaMask/core#9707, TPC uses the typed required amount for Money Account max instead of bare on-chain mUSD. Set isMaxAmount on Max for deposits funded from the money account so quotes use EXACT_INPUT and fees are taken from the full withdrawable balance. Co-authored-by: Cursor <cursoragent@cursor.com>
jpuri
added a commit
to MetaMask/metamask-mobile
that referenced
this pull request
Jul 30, 2026
With MetaMask/core#9707, TPC uses the typed required amount for Money Account max instead of bare on-chain mUSD. Set isMaxAmount on Max for deposits funded from the money account so quotes use EXACT_INPUT and fees are taken from the full withdrawable balance. Co-authored-by: Cursor <cursoragent@cursor.com>
jpuri
marked this pull request as ready for review
August 3, 2026 06:23
jpuri
enabled auto-merge
August 3, 2026 06:23
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.
Reviewed by Cursor Bugbot for commit 9ae8ee3. Configure here.
The merge from main left the #9707 entry under [26.1.0], which failed the PR changelog check.
pedronfigueiredo
approved these changes
Aug 3, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Explanation
When
isMaxAmountis true,calculateSourceAmountsubstitutes the pay token's on-chainbalanceRawas the quote source. For deposits funded from the Money account (e.g. Send to Perps), that balance is only un-vaulted mUSD, not the full withdrawable total (mUSD + vmUSD). Clients were forced to keepisMaxAmount=falseto avoid collapsing Max, which also forcedEXPECTED_OUTPUTquotes and caused Max amount + fees to exceed balance ("Insufficient funds" / "Add less or use a different payment method").This change skips the on-chain balance substitution when
paymentOverride === MoneyAccount, so Max continues to use the typed required amount (already set from the full withdrawable total). Clients can then setisMaxAmount=trueagain and getEXACT_INPUTfee-aware Max quotes.References
Checklist
Made with Cursor