Skip to content

feat: add transaction logic for veda depost and withdrawal#28658

Merged
MoMannn merged 15 commits into
mainfrom
MUSD-593-crypto-deposits
Apr 24, 2026
Merged

feat: add transaction logic for veda depost and withdrawal#28658
MoMannn merged 15 commits into
mainfrom
MUSD-593-crypto-deposits

Conversation

@MoMannn

@MoMannn MoMannn commented Apr 10, 2026

Copy link
Copy Markdown
Member

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

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

Before

After

Pre-merge author checklist

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.

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).

Reviewed by Cursor Bugbot for commit 46369dc. Bugbot is set up for automated code reviews on this repo. Configure here.

@MoMannn MoMannn requested a review from a team as a code owner April 10, 2026 12:54
@metamaskbot metamaskbot added the team-delegation MetaMask Delegation Team label Apr 10, 2026
@github-actions github-actions Bot added size-M risk-low Low testing needed · Low bug introduction risk labels Apr 10, 2026
Comment thread app/components/UI/Money/utils/moneyAccountTransactions.ts
Comment thread app/components/UI/Money/Views/MoneyHomeView/MoneyHomeView.tsx Outdated
@MoMannn MoMannn marked this pull request as draft April 10, 2026 13:05
@MoMannn MoMannn force-pushed the MUSD-593-crypto-deposits branch from d5fdb3e to 26725b6 Compare April 13, 2026 13:25
Comment thread app/components/UI/Money/hooks/useMoneyAccount.ts Outdated
@github-actions github-actions Bot added size-L and removed size-M labels Apr 14, 2026
@github-actions github-actions Bot added size-XL and removed size-L labels Apr 14, 2026
@github-actions

Copy link
Copy Markdown
Contributor

E2E Fixture Validation — Schema is up to date
12 value mismatches detected (expected — fixture represents an existing user).
View details

@MoMannn MoMannn marked this pull request as ready for review April 23, 2026 06:31
@MoMannn MoMannn requested a review from a team as a code owner April 23, 2026 06:31
@github-actions github-actions Bot added the risk:high AI analysis: high risk label Apr 23, 2026
Comment thread tests/feature-flags/feature-flag-registry.ts Outdated
Comment thread tests/feature-flags/feature-flag-registry.ts Outdated
Comment thread app/selectors/featureFlagController/moneyAccount/index.ts Outdated
@shane-t

shane-t commented Apr 23, 2026

Copy link
Copy Markdown
Member

@MoMannn Suggested edits to the feature flag name to conform to the one in LD

MoMannn and others added 4 commits April 23, 2026 14:17

@cursor cursor Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ 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 247c748. Configure here.

Comment thread app/components/UI/Money/Views/MoneyHomeView/MoneyHomeView.tsx
@github-actions

Copy link
Copy Markdown
Contributor

AI PR Analysis

🚫 Merge safe: false | 🟠 Risk: high

Merge decision: AI analysis did not complete — manual review required before merging.

AI analysis did not complete. Manual review recommended.

View run

@github-actions

Copy link
Copy Markdown
Contributor

🔍 Smart E2E Test Selection

  • Selected E2E tags: None (no tests recommended)
  • Selected Performance tags: None (no tests recommended)
  • Risk Level: low
  • AI Confidence: 82%
click to see 🤖 AI reasoning details

E2E Test Selection:
The changes in this PR are focused on the Money Account (MM Pay/Cash) feature, which is a new feature not yet in production (feature flag inProd: false). Here's the breakdown:

  1. New selector (selectMoneyAccountVaultConfig): Adds a new Redux selector for vault configuration. This doesn't modify any existing selectors or shared state.

  2. New hooks (useMoneyAccountDeposit, useMoneyAccountWithdrawal): Brand new hooks for deposit/withdrawal transaction flows. These use existing patterns (addTransactionBatch, addTransaction, navigateToConfirmation) but don't modify those shared utilities.

  3. New transaction utilities (moneyAccountTransactions.ts): Pure utility functions for building ERC-20 approve + vault deposit/withdrawal transactions. No side effects on existing code.

  4. MoneyHomeView change: Minimal - imports the new hook (commented out) and adds a comment. No functional change to the UI.

  5. Feature flag registry: Adds moneyAccountVaultConfig entry with inProd: false - not active in production.

  6. babel.config.tests.js: Minor addition of new files to test babel config overrides - no impact on E2E test execution.

Why no E2E tags are needed:

  • The Money Account feature is behind a feature flag that is NOT in production (inProd: false)
  • No existing E2E tests cover Money Account deposit/withdrawal flows
  • The changes don't modify any shared components (TabBar, navigation, modals, confirmations UI) that could break existing tests
  • The MoneyHomeView change is purely cosmetic (commented-out import)
  • All changes are additive (new files/functions) with no modifications to existing code paths
  • The confirmations system integration uses existing TransactionType.moneyAccountDeposit/Withdraw types that were already registered

No existing E2E test flows are at risk from these changes.

Performance Test Selection:
The changes are additive new hooks and utilities for the Money Account feature (not yet in production). They don't affect UI rendering performance, account/network list components, app startup, or any critical user flows that are currently active. No performance tests are warranted.

View GitHub Actions results

@sonarqubecloud

Copy link
Copy Markdown

@chrisleewilcox chrisleewilcox self-requested a review April 23, 2026 19:58
@MoMannn MoMannn added this pull request to the merge queue Apr 24, 2026
@github-merge-queue github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Apr 24, 2026
@MoMannn MoMannn added this pull request to the merge queue Apr 24, 2026
Merged via the queue into main with commit c2be0e3 Apr 24, 2026
62 of 64 checks passed
@MoMannn MoMannn deleted the MUSD-593-crypto-deposits branch April 24, 2026 07:35
@github-actions github-actions Bot locked and limited conversation to collaborators Apr 24, 2026
@metamaskbotv2 metamaskbotv2 Bot added the release-7.76.0 Issue or pull request that will be included in release 7.76.0 label Apr 24, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

release-7.76.0 Issue or pull request that will be included in release 7.76.0 risk:high AI analysis: high risk risk-low Low testing needed · Low bug introduction risk size-XL team-delegation MetaMask Delegation Team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants