feat(money-account-utils): add money account transaction batch builders - #9680
Open
Jwhiles wants to merge 2 commits into
Open
feat(money-account-utils): add money account transaction batch builders#9680Jwhiles wants to merge 2 commits into
Jwhiles wants to merge 2 commits into
Conversation
Jwhiles
force-pushed
the
feat/money-account-utils-package
branch
3 times, most recently
from
July 30, 2026 12:51
bc4b92b to
d90583a
Compare
Ports the Money Account deposit and withdrawal batch builders from metamask-mobile (`app/components/UI/Money/utils/moneyAccountTransactions.ts`) so both clients encode the vault calls identically. The client-resident wrappers around these builders stay in mobile: they read vault config, provider and recipient from Redux/Engine singletons, which do not belong in a shared package. Everything below that — ABIs, calldata encoding, slippage and share arithmetic, and the two `previewDeposit`/`getRate` reads — moves here, keeping the existing signatures so call sites only change their import path. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.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
Stacked on #9397.
Ports the Money Account deposit and withdrawal transaction batch builders from metamask-mobile (
app/components/UI/Money/utils/moneyAccountTransactions.ts) into this package, so mobile and extension encode the vault calls identically rather than each keeping its own copy.What moved: the ABIs, the calldata encoders, the slippage and share arithmetic, the mUSD deposit-asset resolution, and the two contract reads (
previewDepositon the lens,getRateon the accountant).What deliberately did not move: the four client wrappers (
updateMoneyAccountDepositTokenAmount,updateMoneyAccountWithdrawTokenAmount,getMoneyAccountDepositTransactionsData,getMoneyAccountWithdrawTransactionsData). Those read vault config, provider and recipient from mobile's Redux/Engine singletons and return a Confirmations-owned type, so they stay in the client and delegate to these builders.Signatures are unchanged from mobile, including the injected
provider, so client call sites only change their import path.@ethersproject/{abi,abstract-provider,contracts}v5 is used directly rather than theethersumbrella, matching the convention already established bymoney-account-balance-service(which reads the same lens and accountant contracts).References
N/A
Checklist
🤖 Generated with Claude Code
Note
Medium Risk
Changes how on-chain deposit/withdraw batches are encoded and rounded; mistakes could cause failed txs or incorrect minima, though behavior is aligned with the prior mobile implementation and heavily tested.
Overview
Centralizes Money Account deposit and withdraw transaction encoding in
@metamask/money-account-utils(ported from MetaMask Mobile) so clients share one implementation instead of duplicating vault calldata.buildMoneyAccountDepositBatchreturns an mUSDapprove+ tellerdepositpair: it readspreviewDepositon the lens, setsminimumMintwith 0.2% slippage, and can omit calldata viainitialiseWithoutDataor skip RPC for zero-amount placeholders.buildMoneyAccountWithdrawBatchreturns tellerwithdraw(to the money account) plus mUSDtransferto the recipient, usinggetRateandgetSharesForWithdrawalwith ceiling division (plusminimumAssets = amount - 1) to avoidMinimumAssetsNotMetreverts from rounding.Also exports helpers (
applySlippage, deposit asset address/id resolution,TELLER_ABI, batch types) and adds@ethersprojectcontract dependencies with Jest coverage.Reviewed by Cursor Bugbot for commit 061c619. Bugbot is set up for automated code reviews on this repo. Configure here.