Skip to content

Conversation

runway-github[bot]
Copy link
Contributor

@runway-github runway-github bot commented Oct 17, 2025

Description

Add a Max button to the Perps deposit confirmation, which
automatically subtracts the appropriate buffers from the token amount
based on the MetaMask Pay feature flags and if the token is native.

Changelog

CHANGELOG entry: Add max button to Perps deposit

Related issues

Fixes:
#5947

Manual testing steps

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

Replaces the 90% button with a Max (100%) option and updates custom amount logic to apply buffer-based reductions (and native-token buffer) with round-down, adding tests and bumping transaction-controller.

  • Perps Deposit UI:
    • Replace 90% button with Max (100%) in app/components/Views/confirmations/components/deposit-keyboard/deposit-keyboard.tsx.
  • Amount Calculation (useTransactionCustomAmount):
    • Add useMaxPercentage to adjust 100% by buffers from feature flags and required tokens; adds extra buffer if pay token is native.
    • Change rounding to 2 decimals with round-down; wire up required tokens, feature flags, and native token detection.
  • Tests:
    • Extend tests to cover buffered 100% scenarios (required tokens, native token, skipIfBalance) and updated pay token mocks.
  • Dependencies:
    • Bump @metamask/transaction-controller to ^60.9.0.

Written by Cursor Bugbot for commit fc919ae. This will update automatically on new commits. Configure here.

0fad96b

#21257)

## **Description**

Add a `Max` button to the Perps deposit confirmation, which
automatically subtracts the appropriate buffers from the token amount
based on the MetaMask Pay feature flags and if the token is native.

## **Changelog**

CHANGELOG entry: Add max button to Perps deposit

## **Related issues**

Fixes:
[#5947](MetaMask/MetaMask-planning#5947)

## **Manual testing steps**

## **Screenshots/Recordings**

### **Before**

### **After**

## **Pre-merge author checklist**

- [x] 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).
- [x] I've completed the PR template to the best of my ability
- [x] I’ve included tests if applicable
- [x] I’ve documented my code using [JSDoc](https://jsdoc.app/) format
if applicable
- [x] 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]
> Adds a Max button for Perps deposit that sets amount to 100% minus
dynamic buffers (feature flags, required tokens, native token), updates
rounding, adds tests, and bumps transaction-controller.
> 
> - **Perps Deposit UI**:
> - Replace `90%` quick action with **`Max` (100%)** in
`deposit-keyboard.tsx`.
> - **Amount Logic** (`useTransactionCustomAmount`):
> - Introduce `useMaxPercentage` to compute effective max based on
`selectMetaMaskPayFlags`, `useTransactionRequiredTokens`, and native
token detection.
> - For `100%`, subtract buffers (initial/subsequent; extra if pay token
is native); skip buffers if pay token matches required token or required
tokens have sufficient balance with `skipIfBalance`.
> - Change percentage rounding to `ROUND_DOWN` and use computed max
percentage.
> - **Tests**:
> - Expand `useTransactionCustomAmount.test.ts` to cover buffered `100%`
cases, native token, matching required token, and `skipIfBalance`;
update mocks accordingly.
> - **Dependencies**:
>   - Bump `@metamask/transaction-controller` to `^60.9.0`.
> 
> <sup>Written by [Cursor
Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit
ca20bbd. This will update automatically
on new commits. Configure
[here](https://cursor.com/dashboard?tab=bugbot).</sup>
<!-- /CURSOR_SUMMARY -->
@runway-github runway-github bot requested a review from a team as a code owner October 17, 2025 15:39
@metamaskbot metamaskbot added the team-bots Bot team (for MetaMask Bot, Runway Bot, etc.) label Oct 17, 2025
Copy link

Review the following changes in direct dependencies. Learn more about Socket for GitHub.

Diff Package Supply Chain
Security
Vulnerability Quality Maintenance License
Updatednpm/​@​metamask/​transaction-controller@​60.7.0 ⏵ 60.9.09810081 +198 +1100

View full report

Copy link

Copy link
Contributor

@Cal-L Cal-L left a comment

Choose a reason for hiding this comment

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

LGTM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size-M team-bots Bot team (for MetaMask Bot, Runway Bot, etc.)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants