feat: Enable max-amount and Perps/Predict withdraw flows for Money Account vault deposit via post-Relay path#9404
feat: Enable max-amount and Perps/Predict withdraw flows for Money Account vault deposit via post-Relay path#9404OGPoyraz wants to merge 9 commits into
Conversation
MoneyAccountDepositThere was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 2 potential issues.
❌ 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 1a997ab. Configure here.
| log( | ||
| 'Money Account vault deposit: submitting Relay bridge only; vault deposit runs post-completion', | ||
| ); | ||
| } else if (quote.request.paymentOverride) { |
There was a problem hiding this comment.
Post-relay skips post-quote prepend
High Severity
When isPostRelayMoneyAccountVaultDeposit is true, submitTransactions only logs and skips the paymentOverride and post-quote branches that prepend required transactions to the Relay batch. Predict withdrawals to mUSD on Monad still need the original post-quote transaction executed before Relay can spend source funds, so submission can proceed without unlocking tokens.
Reviewed by Cursor Bugbot for commit 1a997ab. Configure here.
| log( | ||
| 'Money Account vault deposit: skipping atomic embedding; mUSD settles to the Money Account for a post-Relay vault deposit', | ||
| ); | ||
| } else if (shouldProcessTransactions) { |
There was a problem hiding this comment.
Post-relay drops Predict refundTo
Medium Severity
For post-Relay Money Account vault quotes, getSingleQuote logs and skips the later branches that set body.refundTo from request.refundTo. Predict withdrawals to mUSD on Monad use that refund address so failed Relay attempts return funds to the Safe proxy instead of the EOA.
Reviewed by Cursor Bugbot for commit 1a997ab. Configure here.


Explanation
Previously, Money Account vault deposits were always embedded atomically in the Relay batch as a fixed-amount
EXACT_OUTPUTcall. This breaks for two cases:MoneyAccountDeposit— the exact mUSD amount settled by Relay is only known after the bridge completes, so the vault deposit amount cannot be predetermined at quote time.EXACT_INPUTflows where the settled amount is likewise only available after Relay completes.This PR introduces a post-Relay vault deposit path: for these cases, Relay bridges mUSD directly to the Money Account (redirecting the recipient to
transaction.txParams.from), and once Relay settles successfully a separate sponsored vault deposit is submitted with the actual on-chain settled amount.Changes
transaction-pay-controllerisPerpsWithdrawTransactionutility (mirrors existingisPredictWithdrawTransaction) to detect perps withdrawals by top-level or nested transaction type.isPostRelayMoneyAccountVaultDepositpredicate inrelay-post-ma-vault— returnstruefor max-amount MA deposits and for Perps/Predict withdrawals targeting mUSD on Monad.relay-quotes(getSingleQuote): when the predicate is true, overriderequest.recipienttotxParams.fromso Relay delivers mUSD to the Money Account, and skip atomic embedding of the vault deposit.relay-submit(executeSingleQuote): after a successful Relay completion, callsubmitPostRelayVaultDepositto deposit the settled mUSD into the vault. Skip thepaymentOverridebatch-prepend path for these flows.References
Checklist
Note
Medium Risk
Touches core Relay quote/submit and fund routing (recipient override, skipping atomic vault and paymentOverride); incorrect predicate or amount resolution could mis-route mUSD or under-deposit to the vault.
Overview
Adds a post-Relay vault deposit path when the settled mUSD amount is unknown at quote time: Relay delivers mUSD to the Money Account first, then a separate sponsored vault deposit runs after completion.
Detection: New
isPerpsWithdrawTransaction(nested-aware, like Predict) and exportedisPostRelayMoneyAccountVaultDeposit— true for max-amount Money Account deposits and for Perps/Predict withdrawals whose target is mUSD on Monad.Quote (
relay-quotes): When the predicate matches, Relayrecipientis set totransaction.txParams.fromand atomic vault embedding is skipped (bridge-only quote).Submit (
relay-submit): On successful Relay completion, calls existingsubmitPostRelayVaultDepositand returns its hash (fallback to Relay target hash). Skips thepaymentOverridebatch-prepend path for these flows.Tests and changelog updated; no new public API beyond the new utilities/predicate.
Reviewed by Cursor Bugbot for commit 1a997ab. Bugbot is set up for automated code reviews on this repo. Configure here.