fix: use typed amount for Money Account max source calculations - #9707
Draft
jpuri wants to merge 1 commit into
Draft
fix: use typed amount for Money Account max source calculations#9707jpuri wants to merge 1 commit into
jpuri wants to merge 1 commit into
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>
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