Commit c2be0e3
feat: add transaction logic for veda depost and withdrawal (#28658)
## **Description**
Adds the on-chain transaction layer for Money Account crypto deposits
and withdrawals (MUSD-593).
**What changed:**
- Added `buildMoneyAccountDepositBatch` and `buildMoneyAccountWithdraw`
utility functions (`moneyAccountTransactions.ts`) that encode the
approve + deposit / withdraw calldata against the Veda vault contracts
(Teller, Accountant, Lens).
- Added `useMoneyAccountDeposit` and `useMoneyAccountWithdrawal` hooks
(`useMoneyAccount.ts`) that read vault configuration from remote feature
flags, derive the provider from the active network client, and submit
the transactions via `addTransactionBatch` / `addTransaction`.
- Added `selectMoneyAccountVaultConfig` selector and the
`moneyAccountDepositConfig` remote feature flag registry entry, which
holds chain ID and contract addresses for the vault.
- Temporarily wired the "Add" button in `MoneyHomeView` to
`initiateDeposit` with a hardcoded amount as a dev integration test;
this will be replaced once the amount entry UI is built.
**Deposit flow:** `approve(boringVault, amount)` + `deposit(asset,
amount, minimumMint, 0x0)` submitted as an atomic batch. A 0.1% slippage
tolerance is applied to the `previewDeposit` quote.
**Withdrawal flow:** `getRate` → convert asset amount to vault shares →
`withdraw(asset, shares, minimumAssets, to)`.
## **Changelog**
CHANGELOG entry: null
## **TODO**
Note that the code has 2 todos that should be address seperatly:
- adding hook to get amount from MM pay
- updating addresses for mUSD and veda vault once we have a testing one
ready on monad
## **Related issues**
Fixes:
## **Manual testing steps**
```gherkin
Feature: my feature name
Scenario: user [verb for user action]
Given [describe expected initial app state]
When user [verb for user action]
Then [describe expected outcome]
```
## **Screenshots/Recordings**
<!-- If applicable, add screenshots and/or recordings to visualize the
before and after of your change. -->
### **Before**
<!-- [screenshots/recordings] -->
### **After**
<!-- [screenshots/recordings] -->
## **Pre-merge author checklist**
- [ ] I've followed [MetaMask Contributor
Docs](https://github.com/MetaMask/contributor-docs) and [MetaMask Mobile
Coding
Standards](https://github.com/MetaMask/metamask-mobile/blob/main/.github/guidelines/CODING_GUIDELINES.md).
- [ ] I've completed the PR template to the best of my ability
- [ ] I've included tests if applicable
- [ ] I've documented my code using [JSDoc](https://jsdoc.app/) format
if applicable
- [ ] I've applied the right labels on the PR (see [labeling
guidelines](https://github.com/MetaMask/metamask-mobile/blob/main/.github/guidelines/LABELING_GUIDELINES.md)).
Not required for external contributors.
## **Pre-merge reviewer checklist**
- [ ] I've manually tested the PR (e.g. pull and build branch, run the
app, test code being changed).
- [ ] I confirm that this PR addresses all acceptance criteria described
in the ticket it closes and includes the necessary testing evidence such
as recordings and or screenshots.
<!-- CURSOR_SUMMARY -->
---
> [!NOTE]
> **Medium Risk**
> Introduces new transaction-construction and submission code paths that
interact with wallet confirmations and remote-configured contract
addresses; mistakes could cause failed or incorrect on-chain calls. Risk
is reduced by added unit tests and feature-flag gating, but still
impacts critical transaction flow.
>
> **Overview**
> Adds the on-chain transaction building/submission layer for Money
Account deposits and withdrawals.
>
> Introduces `buildMoneyAccountDepositBatch` (approve + deposit batch
with preview+slippage) and `buildMoneyAccountWithdraw` (rate-based share
conversion + slippage) utilities, plus
`useMoneyAccountDeposit`/`useMoneyAccountWithdrawal` hooks that fetch
vault addresses from remote feature flags, resolve provider/network
client, navigate to confirmations, and submit via
`addTransactionBatch`/`addTransaction` with error logging.
>
> Adds a new `moneyAccountVaultConfig` remote flag (with a dev fallback
gated by `MM_MONEY_DEPOSIT_CONFIG_DEV_ENABLED`) and corresponding
selector/tests; updates test babel config to avoid inlining env vars for
those selector files. The Money home view only adds an import and TODO
scaffolding for wiring deposits later (no behavior change).
>
> <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit
46369dc. Bugbot is set up for automated
code reviews on this repo. Configure
[here](https://www.cursor.com/dashboard/bugbot).</sup>
<!-- /CURSOR_SUMMARY -->
---------
Co-authored-by: Shane T <muldots@gmail.com>1 parent dd60e41 commit c2be0e3
9 files changed
Lines changed: 1190 additions & 0 deletions
File tree
- app
- components/UI/Money
- Views/MoneyHomeView
- hooks
- utils
- selectors/featureFlagController/moneyAccount
- tests/feature-flags
Lines changed: 4 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
| 2 | + | |
2 | 3 | | |
3 | 4 | | |
4 | 5 | | |
| |||
45 | 46 | | |
46 | 47 | | |
47 | 48 | | |
| 49 | + | |
| 50 | + | |
48 | 51 | | |
49 | 52 | | |
50 | 53 | | |
| |||
62 | 65 | | |
63 | 66 | | |
64 | 67 | | |
| 68 | + | |
65 | 69 | | |
66 | 70 | | |
67 | 71 | | |
| |||
0 commit comments