fix: enable EXACT_INPUT Max for Money Account Send to Perps - #33974
fix: enable EXACT_INPUT Max for Money Account Send to Perps#33974jpuri wants to merge 3 commits into
Conversation
Deposits funded from the Money account (e.g. Send to Perps) were setting isMaxAmount=true on Max, causing TPC's calculatePostQuoteSourceAmounts to substitute the pay token's raw balance (bare mUSD on Monad) as the source amount. This collapsed Max to the un-vaulted mUSD portion instead of the full withdrawable balance (mUSD + vmUSD), so a $4.70 balance showed $0.62. Exclude the money-account payment override from shouldSetMax so these deposits keep isMaxAmount=false and route the typed amount through as token.amountRaw, matching money-account withdraw behavior. The withdrawableFiatRaw balance source is unchanged.
|
CLA Signature Action: All authors have signed the CLA. You may need to manually re-run the blocking PR check if it doesn't pass in a few minutes. |
PR template — items to address before "Ready for review"Warnings — informational, address before merging:
See docs/readme/ready-for-review.md for the full Definition of Ready for Review. |
|
🧪 Flaky unit test detectionRun history flaky detectionHistorical failure rate is a hint, not proof — review each suggestion in context. See the flaky-test-detection skill for the full pattern reference and manual audit workflow. Failures / runs sampled per window:
AI-detected flaky patterns
|
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>
🔍 Smart E2E Test Selection
click to see 🤖 AI reasoning detailsE2E Test Selection:
Since the only functional change is a new unit test (no app logic changed, no UI changed, no E2E flows affected), no E2E smoke tags are warranted. Performance Test Selection: |



Description
Send to Perps Max (funded from Money account) needs
isMaxAmount=trueso TPC quotes useEXACT_INPUTand fees come out of the full withdrawable balance. That was previously unsafe because TPC substituted the pay token's bare on-chain mUSD balance for Max.Depends on: MetaMask/core#9707 — TPC uses the typed required amount for Money Account max instead of on-chain mUSD.
This PR:
withdrawableFiatRaw(mUSD + vmUSD) — already presentisMaxAmount=trueon Max for Money Account–funded deposits (Send to Perps) so quotes areEXACT_INPUTWithout core#9707, re-enabling
isMaxAmountwould collapse Max back to un-vaulted mUSD. Do not merge until that TPC change is available in mobile.Changelog
CHANGELOG entry: Fixed Max Send to Perps from Money account so the full withdrawable balance can be sent after fees
Related issues
Refs: MetaMask/core#9707
Manual testing steps
Screenshots/Recordings
N/A — follow-up to prior Max amount fix; verify against Insufficient funds screenshot from Max + fees.
Pre-merge author checklist
Performance checks (if applicable)
Pre-merge reviewer checklist