Skip to content

Conversation

@runway-github
Copy link
Contributor

@runway-github runway-github bot commented Nov 25, 2025

Description

  1. What is the reason for the change?
    There is a bug where we are not able to see the correct staked ethereum
    balance when there are multiple accounts with staked ethereum. There is
    also a bug where we are not able to see the APR and Earn History for a
    user with 0 staked ethereum balance.

  2. What is the improvement/solution?

  • Ensure that the native asset is not set isStaked true, as the Staked
    Ethereum asset is the one which should be set isStaked true.
  • Add accountId to filtering of token data in assets list selector to
    ensure we have correct balances across multiple accounts for staked
    ethereum.
  • Allow zero value staked ethereum in the allTokens selector, but limit
    to supported staking chains to lessen amount of tokens returned.

Changelog

CHANGELOG entry: null

Related issues

Fixes: https://consensyssoftware.atlassian.net/browse/MUSD-114
Fixes: https://consensyssoftware.atlassian.net/browse/MUSD-112
Fixes: #23259
Fixes: #23260

Manual testing steps

Feature: fix staked eth balances across multiple accounts and apr / earn history for zero balance staked eth
  Scenario: user has multiple accounts with ETH
    Given user stakes ETH on all accounts

    When user views the token list
    Then the Staked Ethereum balance should be correct in each account
    Then the Staked Ethereum asset detail page should show the correct amount for the account
    Then the Ethereum asset detail page should show the correct Staked Ethereum amount
    
 Scenario: user has multiple accounts with ETH, 1 with 0 Staked ETH
    Given user has 0 Staked Eth on an account

    When user views the token list
    Then the Staked Ethereum balance should not show in token list
    Then the Ethereum asset detail page should show no Staked Ethereum at all
    Then the Ethereum asset detail page should show APR and Earn History even when 0 Staked ETH

Screenshots/Recordings

Before

Simulator.Screen.Recording.-.iPhone.17.Pro.-.2025-11-25.at.02.08.03.mp4

After

Simulator.Screen.Recording.-.iPhone.17.Pro.-.2025-11-25.at.10.15.10.mp4

Simulator Screenshot - iPhone 17 Pro - 2025-11-25
at 10 15 28
Simulator Screenshot - iPhone 17 Pro - 2025-11-25
at 10 15 31

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

Stops marking native assets as staked and introduces a separate Staked Ethereum token, updating zero-balance filtering and tests accordingly.

  • Selectors (EVM multichain):
    • selectedAccountNativeTokenCachedBalanceByChainId: always sets isStaked: false for native balances.
    • selectNativeTokensAcrossChainsForAddress: adds distinct staked token (name: 'Staked Ethereum') alongside native, using stakedBalance/fiat; shows when applicable (supports current-network zero-balance visibility).
    • Cleanup: remove unused toHex import.
  • Tests:
    • Update native balance expectations to isStaked: false.
    • Adjust zero-balance filter test to include Staked Ethereum and updated count.
    • Keep memoization and network filtering tests intact with new expectations.

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

e76aaf4

…rst account staked balance across accounts (#23257)

<!--
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**

1. What is the reason for the change?
There is a bug where we are not able to see the correct staked ethereum
balance when there are multiple accounts with staked ethereum. There is
also a bug where we are not able to see the APR and Earn History for a
user with 0 staked ethereum balance.

2. What is the improvement/solution?
- Ensure that the native asset is not set isStaked true, as the Staked
Ethereum asset is the one which should be set isStaked true.
- Add accountId to filtering of token data in assets list selector to
ensure we have correct balances across multiple accounts for staked
ethereum.
- Allow zero value staked ethereum in the allTokens selector, but limit
to supported staking chains to lessen amount of tokens returned.

<!--
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?
-->

## **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: null

## **Related issues**

Fixes: https://consensyssoftware.atlassian.net/browse/MUSD-114
Fixes: https://consensyssoftware.atlassian.net/browse/MUSD-112
Fixes: #23259
Fixes: #23260
## **Manual testing steps**

```gherkin
Feature: fix staked eth balances across multiple accounts and apr / earn history for zero balance staked eth
  Scenario: user has multiple accounts with ETH
    Given user stakes ETH on all accounts

    When user views the token list
    Then the Staked Ethereum balance should be correct in each account
    Then the Staked Ethereum asset detail page should show the correct amount for the account
    Then the Ethereum asset detail page should show the correct Staked Ethereum amount
    
 Scenario: user has multiple accounts with ETH, 1 with 0 Staked ETH
    Given user has 0 Staked Eth on an account

    When user views the token list
    Then the Staked Ethereum balance should not show in token list
    Then the Ethereum asset detail page should show no Staked Ethereum at all
    Then the Ethereum asset detail page should show APR and Earn History even when 0 Staked ETH
```

## **Screenshots/Recordings**

<!-- If applicable, add screenshots and/or recordings to visualize the
before and after of your change. -->

### **Before**


https://github.com/user-attachments/assets/b08a1c20-6e57-45cf-b238-53d3b5008b6a

<!-- [screenshots/recordings] -->

### **After**


https://github.com/user-attachments/assets/488c8b0e-57a8-4228-8e6f-0b43c00ee952

<img width="200" alt="Simulator Screenshot - iPhone 17 Pro - 2025-11-25
at 10 15 28"
src="https://github.com/user-attachments/assets/0ee7d224-8b4e-413a-8f52-9e7db6eb5182"
/>
<img width="200" alt="Simulator Screenshot - iPhone 17 Pro - 2025-11-25
at 10 15 31"
src="https://github.com/user-attachments/assets/8c41b2b2-64fa-4a07-bd7a-80f98f7c6194"
/>

<!-- [screenshots/recordings] -->

## **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]
> Ensure native assets are never marked staked, include a distinct
Staked Ethereum entry, and adjust zero-balance filtering to retain
native/staked tokens on the current network; update tests accordingly.
> 
> - **Selectors**:
> - Set `isStaked: false` for native balances in
`selectedAccountNativeTokenCachedBalanceByChainId*`.
> - Update `selectNativeTokensAcrossChains` to always add a separate
"Staked Ethereum" token alongside the native asset using cached staked
balance data.
> - Modify zero-balance behavior in
`selectEvmTokensWithZeroBalanceFilter` to keep native and staked tokens
on the current network when hiding zero balances.
>   - Cleanup: remove unused `toHex` import.
> - **Tests**:
> - Adjust expectations for `isStaked` on native balances and
zero-balance filtering results.
> - Assert presence of "Staked Ethereum" in filtered lists and updated
token counts.
>   - Maintain memoization and network filtering coverage.
> 
> <sup>Written by [Cursor
Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit
ce72756. This will update automatically
on new commits. Configure
[here](https://cursor.com/dashboard?tab=bugbot).</sup>
<!-- /CURSOR_SUMMARY -->
@github-actions
Copy link
Contributor

CLA Signature Action: All authors have signed the CLA. You may need to manually re-run the blocking PR check if it doesn't pass in a few minutes.

@metamaskbot metamaskbot added the team-bots Bot team (for MetaMask Bot, Runway Bot, etc.) label Nov 25, 2025
@github-actions
Copy link
Contributor

🔍 Smart E2E Test Selection

  • Selected E2E tags: SmokeAccounts, SmokeCore, SmokeConfirmationsRedesigned, SmokeIdentity, SmokeNetworkAbstractions, SmokeNetworkExpansion, SmokeTrade, SmokeWalletPlatform, SmokeWalletUX, SmokeAssets, SmokeSwaps, SmokeStake, SmokeCard, SmokeNotifications, SmokeRewards, SmokePerps, SmokeRamps, SmokeMultiChainPermissions, SmokeAnalytics, SmokeMultiChainAPI, SmokePredictions
  • Risk Level: high
  • AI Confidence: %
click to see 🤖 AI reasoning details

Fallback: AI analysis did not complete successfully. Running all tests.

View GitHub Actions results

nativeTokenInfoByChainId.stakedBalance !== toHex(0) &&
nativeTokenInfoByChainId.stakedBalance !== '0'
) {
if (nativeTokenInfoByChainId && !nativeTokenInfoByChainId.isStaked) {
Copy link

Choose a reason for hiding this comment

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

Bug: Staked tokens created for all chains, not just staking-supported

The condition !nativeTokenInfoByChainId.isStaked is always true because isStaked is now always set to false on line 82. This causes "Staked Ethereum" tokens to be created for ALL chains with account data (including non-ETH chains like Polygon), not just staking-supported chains. For example, Polygon would get a token with name: 'Staked Ethereum' but symbol: 'POL', which is nonsensical. The PR description mentions "limit to supported staking chains" but this limitation wasn't implemented - the condition effectively became just if (nativeTokenInfoByChainId).

Additional Locations (1)

Fix in Cursor Fix in Web

@sonarqubecloud
Copy link

@joaoloureirop joaoloureirop enabled auto-merge (squash) November 25, 2025 22:41
@joaoloureirop joaoloureirop merged commit 07717ba into release/7.60.0 Nov 25, 2025
89 of 90 checks passed
@joaoloureirop joaoloureirop deleted the runway-cherry-pick-7.60.0-1764098457 branch November 25, 2025 22:41
@github-actions github-actions bot locked and limited conversation to collaborators Nov 25, 2025
@metamaskbot metamaskbot added the release-7.60.0 Issue or pull request that will be included in release 7.60.0 label Nov 25, 2025
@metamaskbot
Copy link
Collaborator

No release label on PR. Adding release label release-7.60.0 on PR, as PR was cherry-picked in branch 7.60.0.

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

Labels

release-7.60.0 Issue or pull request that will be included in release 7.60.0 team-bots Bot team (for MetaMask Bot, Runway Bot, etc.)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants