[pull] main from MetaMask:main#88
Merged
Merged
Conversation
<!-- Please submit this PR as a draft initially. Do not mark it as "Ready for review" until the template has been completely filled out, and PR status checks have passed at least once. --> ## **Description** This PR addresses the first batch of critical UX issues identified during Android testing of the Perps (perpetual futures) trading interface. The changes focus on improving the trading experience by fixing order entry, position display, and market overview issues that were preventing users from effectively trading with their full margin and understanding their positions. **Reason for changes:** 1. Users couldn't trade with 100% of their available margin due to incorrect leverage calculations 2. Position cards showed inverted PnL colors (red for profit, green for loss) causing confusion 3. Market overview was unsorted and showed misleading $0 volumes for assets with missing data **Improvements implemented:** 1. **Order Entry**: Fixed leverage calculations affecting max order size, improved slider responsiveness with real-time updates 2. **Position Cards**: - Corrected PnL colors (green for profit, red for loss) - Added live price subscriptions - Fixed decimal formatting to show exactly 2 decimals for all monetary values - Corrected "Liquidity Price" typo to "Liquidation Price" - Replaced PnL percentage with ROE (Return on Equity) display - Fixed margin display to show 2 decimals 3. **Market Overview**: Implemented volume-based sorting, fixed missing data display ($-- instead of $0), added asset icon support via RemoteImage 4. **Close Position Sheet**: - Fixed all values to display with 2 decimal formatting - Removed "(Hyperliquid USDC)" from "You'll receive" text - Fixed PnL color display with explicit sign indicators 5. **Limit Price Sheet**: Reverted unnecessary UI additions while keeping live price updates 6. Added volume filtering to out markets with no volume or $0 volume (like MATIC) These fixes are based on comprehensive testing feedback documented in https://docs.google.com/document/d/1c0TqMmeO5l65sKuCGNAl7UMeqOjbTCkni5X6j3U1LbI/edit?tab=t.0 from Aug 19, 2025 (Android device, Build 7.55). ## **Changelog** CHANGELOG entry: Fixed critical UX issues in Perps trading including incorrect leverage calculations, PnL color inversion, missing live prices, ROE display, 2-decimal formatting consistency, and improved market data display with proper volume sorting and asset icons ## **Related issues** Fixes: Internal testing issues documented in [`qa doc` ](https://docs.google.com/document/d/1c0TqMmeO5l65sKuCGNAl7UMeqOjbTCkni5X6j3U1LbI/edit?tab=t.0) ## **Manual testing steps** ```gherkin Feature: Perps Order Entry Scenario: User can trade with 100% of available margin using leverage Given user has 100 USDC available margin And user selects 10x leverage on BTC market When user taps "max" button in order form Then order size should show ~1000 USDC worth of BTC (not 100 USDC) And slider should update in real-time as user drags And order value should update without releasing slider Feature: Perps Position Display Scenario: Position card shows correct PnL colors and live prices Given user has an open BTC long position with positive PnL When user views position card on home screen Then PnL should display in green (not red) And market price should show current live price (not "--") And all prices should display with exactly 2 decimals And liquidation price label should show "Liquidation Price" (not "Liquidity Price") And ROE (Return on Equity) should display instead of PnL percentage And margin should display with 2 decimal places Feature: Perps Market Overview Scenario: Markets display sorted by volume with proper formatting Given user opens Perps markets overview screen When user views the market list Then markets should be sorted by 24h volume (highest first) And volume should display without decimals (e.g., "$123M" not "$123.4M") And markets with missing data should show "$--" (not "$0") And all token logos should have consistent 32x32 circular design ``` ## **Screenshots/Recordings** ### **Before** - Max button showed 100 USDC instead of 1000 USDC with 10x leverage - PnL showed red when positive, green when negative - Market price displayed as "--" permanently - MATIC and other markets showed "$0" volume when data was missing - Markets were not sorted by volume - Volume displayed with decimals ("$123.4M") - Position card showed PnL percentage instead of ROE - Margin and other monetary values had inconsistent decimal places - Close position sheet showed inconsistent formatting ### **After** - Max button correctly calculates leveraged position size - PnL colors corrected: green for profit, red for loss - Market price shows live updates with 2 decimal precision - Missing volume data shows "$--" for clarity - Markets sorted by 24h volume descending - Volume displays without decimals ("$123M") - Position card displays ROE (Return on Equity) with correct calculations - All monetary values consistently show 2 decimal places - Close position sheet has proper formatting and clearer copy ## **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. --------- Co-authored-by: Claude <noreply@anthropic.com>
…staking volume (#18544) <!-- Please submit this PR as a draft initially. Do not mark it as "Ready for review" until the template has been completely filled out, and PR status checks have passed at least once. --> ## **Description** <!-- Write a short description of the changes included in this pull request, also include relevant motivation and context. Have in mind the following questions: 1. What is the reason for the change? 2. What is the improvement/solution? --> This PR improves fee estimation accuracy for perpetual trading by implementing user-specific fee rates based on trading volume and staking tiers. **Reason for change:** - Currently, all users see the same base fee rates (0.045% taker, 0.015% maker) regardless of their trading volume or HYPE staking status - HyperLiquid offers significant fee discounts based on 14-day rolling volume (up to 47% discount) and HYPE staking (up to 40% discount) - Users with high volume or staking were seeing inaccurate fee estimates that were higher than their actual fees **Improvement/Solution:** - Integrated HyperLiquid SDK's `userFees` API to fetch actual user-specific fee rates - Implemented smart caching with 5-minute TTL to reduce API calls while maintaining accuracy - Provider-agnostic implementation keeps the UI layer clean and allows other providers to implement their own fee logic - Graceful fallback to base rates when API is unavailable or user is not connected ## **Changelog** <!-- If this PR is not End-User-Facing and should not show up in the CHANGELOG, you can choose to either: 1. Write `CHANGELOG entry: null` 2. Label with `no-changelog` If this PR is End-User-Facing, please write a short User-Facing description in the past tense like: `CHANGELOG entry: Added a new tab for users to see their NFTs` `CHANGELOG entry: Fixed a bug that was causing some NFTs to flicker` (This helps the Release Engineer do their job more quickly and accurately) --> CHANGELOG entry: Improved perpetual trading fee estimation to show personalized rates based on user's trading volume and staking status ## **Related issues** Fixes: #[issue-number] ## **Manual testing steps** ```gherkin Feature: User-specific fee estimation for perpetual trading Scenario: User sees base fee rates when not connected Given the user is on the Perps order screen And the user's wallet is not connected to HyperLiquid When user enters an order amount Then the fee estimate shows base rates (0.045% for market orders) Scenario: User sees discounted fee rates based on their tier Given the user is on the Perps order screen And the user has a connected wallet with trading history When user enters an order amount Then the fee estimate shows their personalized rate with discounts applied And the rate is cached for 5 minutes to avoid excessive API calls Scenario: Fee estimation falls back gracefully on API failure Given the user is on the Perps order screen And the HyperLiquid API is temporarily unavailable When user enters an order amount Then the fee estimate shows base rates as fallback And no error is shown to the user ``` ## **Screenshots/Recordings** <!-- If applicable, add screenshots and/or recordings to visualize the before and after of your change. --> ### **Before** <!-- - All users see the same fee rates (0.045% taker, 0.015% maker) - No consideration for volume tier or staking discounts --> ### **After** <!-- - Users with volume/staking discounts see their actual lower fee rates - Fee rates are cached for 5 minutes to optimize performance - Base rates still shown as fallback when API unavailable --> ## **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. --- ## Additional Technical Details for Reviewers ### Implementation Highlights: - **Caching Strategy**: 5-minute TTL balances accuracy with API efficiency - **Provider-Agnostic**: Changes are isolated to HyperLiquidProvider, maintaining clean architecture - **Test Coverage**: Added comprehensive test cases for user-specific fees, caching, and fallback scenarios - **Performance**: Minimal impact - API call only made once per 5 minutes per user ### Files Changed: - `app/components/UI/Perps/controllers/providers/HyperLiquidProvider.ts` - Added fee caching and user-specific rate fetching - `app/components/UI/Perps/controllers/providers/HyperLiquidProvider.test.ts` - Added test coverage for new functionality ### Testing Evidence: - All 2297 tests passing in the Perps module - ESLint checks passing with no errors - Fee calculation accurately reflects HyperLiquid's tier structure
…andling (#18546) <!-- Please submit this PR as a draft initially. Do not mark it as "Ready for review" until the template has been completely filled out, and PR status checks have passed at least once. --> ## **Description** This PR fixes the Perps tab infinite loading issue and migrates the Perps components to use the new multichain account architecture from PR #18407. The Perps tab now works seamlessly with the multichain account system, automatically using the appropriate EVM account even when a non-EVM account (like Solana) is selected. ### Key improvements: 1. **Multichain account support**: Migrated from `AccountsController` to `AccountTreeController` using BIP-44 account addresses with the new `selectSelectedInternalAccountByScope` selector 2. **Smart account handling**: When a Solana account is selected, Perps automatically uses the last active EVM account from the account group, ensuring continuous functionality 3. **Proper error recovery**: Connection failures now show an error state with a retry button instead of infinite loading 4. **Fixed infinite loading**: Resolved the issue where the Perps tab would show an infinite skeleton loader when switching accounts ## **Changelog** CHANGELOG entry: Fixed Perps tab infinite loading issue and improved multichain account support ## **Related issues** Fixes: https://consensyssoftware.atlassian.net/jira/software/c/projects/TAT/boards/1563/backlog?assignee=62440610247a4b00691c743a ## **Manual testing steps** ```gherkin Feature: Perps Tab Multichain Account Support Scenario: User selects a Solana account Given the user has both EVM and Solana accounts in their wallet And the user is on the wallet main screen And an EVM account is currently selected When user switches to a Solana account And navigates to the Perps tab Then the Perps tab loads successfully And Perps continues to work with the last used EVM account And no infinite loading skeleton is displayed Scenario: User switches between different account types Given the user has multiple account types (EVM, Solana, Bitcoin) And the Perps tab is open When user switches between different account types Then the Perps tab maintains functionality And always uses the appropriate EVM account from the account group And no loading issues occur Scenario: Connection failure with retry Given the user has an EVM account selected And there is a network connection issue When user navigates to the Perps tab And the connection fails Then user sees a "Connection Failed" error message And user sees a "Retry" button And clicking "Retry" attempts to reconnect Scenario: Normal operation with EVM account Given the user has an EVM account selected And network connection is stable When user navigates to the Perps tab Then the Perps tab loads successfully And user can see their positions or first-time user screen And no error messages are displayed ``` ## **Screenshots/Recordings** ### **Before** - When switching accounts, the Perps tab would show an infinite loading skeleton - The tab would fail to load properly when account changes occurred - Used the deprecated `AccountsController` which didn't support multichain accounts properly https://github.com/user-attachments/assets/99c2db16-9aa6-476c-8df2-70f3df7af44c ### **After** - Perps tab seamlessly works with multichain accounts - When a Solana account is selected, Perps automatically uses the appropriate EVM account from the same account group - Proper error handling for connection failures with retry functionality - Smooth transitions when switching between account types - Uses the new `AccountTreeController` with BIP-44 account addresses https://github.com/user-attachments/assets/f66e3b4e-c005-4c3f-b4b7-6d2e245bdc35 ## **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.
<!-- Please submit this PR as a draft initially. Do not mark it as "Ready for review" until the template has been completely filled out, and PR status checks have passed at least once. --> ## **Description** Adds an E2E test for the getFile example Snap which tests the `snap_getFile` API. This PR also bumps the Snaps packages to include a bugfix for this feature on React Native. Closes MetaMask/snaps#3484
## **Description** Include quote gas cost in `Network fee` in Perps deposit confirmation. Show spinner in row while quotes are loading. ## **Changelog** CHANGELOG entry: null ## **Related issues** Fixes: [#5612](MetaMask/MetaMask-planning#5612) ## **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.
## **Description** Update the design of the `Pay with` row, currently used in the Perps deposit confirmation. Specifically: - Add `PayTokenAmount` component to display equivalent token amount in payment token. - Add `TokenIcon` component to display token icon including network badge. - Include all token properties in `payToken` returned from `useTransactionPayToken` hook. - Remove `TokenAmountNative` component. - Remove `PayTokenBalance` component. - Remove `TokenPill` component. ## **Changelog** CHANGELOG entry: null ## **Related issues** Fixes: [#5592](MetaMask/MetaMask-planning#5592) [#5602](MetaMask/MetaMask-planning#5602) ## **Manual testing steps** ## **Screenshots/Recordings** ### **Before** ### **After** <img width="350" alt="New Deposit" src="https://github.com/user-attachments/assets/5885bc7d-6f87-4fac-be09-956e2d2e33df" /> <img width="350" alt="New Deposit No Keybord" src="https://github.com/user-attachments/assets/50a1e496-e5f0-4e4e-9203-63a3365aa6a2" /> ## **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.
<!-- Please submit this PR as a draft initially. Do not mark it as "Ready for review" until the template has been completely filled out, and PR status checks have passed at least once. --> ## **Description** <!-- Write a short description of the changes included in this pull request, also include relevant motivation and context. Have in mind the following questions: 1. What is the reason for the change? 2. What is the improvement/solution? --> Switching basic functionality on or off was introduced on [#9208](#9208). However, it seems that the send flow with a custom RPC endpoint (for local nodes) wasn't properly tested. When the transaction reaches `addTransaction` function in the transaction controller, `updateGasProperties` is eventually called, inside which `updateGasFees` is called, inside which `getSuggestedGasFees` is called, inside which `getGasFeeEstimates` which comes from the gas fees controller is called. This function calls `fetchGasFeeEstimates` inside the Gas Fee controller, and calls `_fetchGasFeeEstimateData`, which calls `determineGasFeeCalculations` which calls `getEstimatesUsingFallbacks` which calls `getEstimatesUsingFeeMarketEndpoint` which calls `fetchGasEstimates`, which calls `handleFetch` from the controller utils. However, in `app/store/sagas/xmlHttpRequestOverride.ts`, `handleError` is called inside the `global.XMLHttpRequest.prototype.send` override, and the request is blocked. This makes it so the `getGasFeeEstimates` call on `getSuggestedGasFees` never resolves or rejects, causing the execution of `addTransaction` in the transaction controller to hang indefinetely. In other words, the override is blocking and returning early without signaling an error to consumers, so promises originating from fetch never settled and `addTransaction` hangs. The fix is to update the XHR override so that when a URL is blocked it triggers `onerror`/`abort`/`onloadend` on the `XMLHttpRequest` instance. That makes fetch reject quickly and allows the gas-fee controller to proceed to its fallbacks, unblocking `addTransaction` even when 3rd party requests are blocked. ## **Changelog** <!-- If this PR is not End-User-Facing and should not show up in the CHANGELOG, you can choose to either: 1. Write `CHANGELOG entry: null` 2. Label with `no-changelog` If this PR is End-User-Facing, please write a short User-Facing description in the past tense like: `CHANGELOG entry: Added a new tab for users to see their NFTs` `CHANGELOG entry: Fixed a bug that was causing some NFTs to flicker` (This helps the Release Engineer do their job more quickly and accurately) --> CHANGELOG entry: ## **Related issues** Fixes: #17800 ## **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.
## **Description** Bump Bitcoin Snap to latest ## **Changelog** CHANGELOG entry: bump Bitcoin to v0.19.0 ## **Related issues** Fixes: https://consensyssoftware.atlassian.net/browse/NWNT-460 ## **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.
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
See Commits and Changes for more details.
Created by
pull[bot] (v2.0.0-alpha.3)
Can you help keep this open source service alive? 💖 Please sponsor : )