Skip to content

chore: leaderboard - abbreviate large token amounts in position rows#29316

Merged
xavier-brochard merged 3 commits into
mainfrom
TSA-447-Format-token-amounts-in-Trader-Profile-position
Apr 24, 2026
Merged

chore: leaderboard - abbreviate large token amounts in position rows#29316
xavier-brochard merged 3 commits into
mainfrom
TSA-447-Format-token-amounts-in-Trader-Profile-position

Conversation

@zone-live
Copy link
Copy Markdown
Contributor

@zone-live zone-live commented Apr 24, 2026

Description

Token quantities in the Trader Profile position rows (216,649,924.26742363 ASTEROID) were rendered with full precision, making list rows noisy and hard to watch. Updated formatTokenAmount method to abbreviate values ≥ 1,000 using K/M/B/T suffixes (reusing the existing pattern in the app) and cap smaller values at 4 decimal places with a < 0.00001 floor, aligning with the market-data display convention already used in AssetOverview.

Simulator Screenshot - iPhone 17 Pro - 2026-04-24 at 11 55 22

Changelog

CHANGELOG entry: null

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

Performance checks (if applicable)

  • I've tested on Android
    • Ideally on a mid-range device; emulator is acceptable
  • I've tested with a power user scenario
    • Use these power-user SRPs to import wallets with many accounts and tokens
  • I've instrumented key operations with Sentry traces for production performance metrics

For performance guidelines and tooling, see the Performance Guide.

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

Low Risk
Low risk UI formatting change limited to how token quantities are displayed in social leaderboard position rows, with broad unit tests added to catch edge cases.

Overview
Updates formatTokenAmount used by Social Leaderboard position rows to abbreviate values >= 1,000 with K/M/B/T suffixes (via localizeLargeNumber), while handling dust/precision for smaller values via formatAmountWithThreshold and returning 0 for non-finite inputs.

Adjusts the PositionRow test expectation for large balances and adds a dedicated formatters.test.ts suite covering USD, token amount, percent, and trade date formatting (including negative, null/undefined, dust threshold, and seconds-vs-ms timestamps).

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

@github-actions
Copy link
Copy Markdown
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.

@metamaskbotv2 metamaskbotv2 Bot added the team-social-ai Social & AI team label Apr 24, 2026
Copy link
Copy Markdown
Contributor

@cursor cursor Bot left a comment

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 84240d5. Configure here.

Comment thread app/components/Views/SocialLeaderboard/utils/formatters.ts Outdated
@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: 95%
click to see 🤖 AI reasoning details

E2E Test Selection:
The three changed files are all within the SocialLeaderboard feature area:

  1. formatters.ts: Refactors formatTokenAmount to use formatAmountWithThreshold and localizeLargeNumber for better display of large token quantities (K/M/B/T suffixes) and dust values. This is a pure utility function change scoped entirely to the SocialLeaderboard feature.

  2. formatters.test.ts: New unit test file covering the formatter functions — no E2E impact.

  3. PositionRow.test.tsx: Updates an existing unit test to match the new formatting behavior — no E2E impact.

No E2E test tags exist for the SocialLeaderboard feature. The changes are isolated to a feature-flagged component with no impact on shared infrastructure, navigation, controllers, confirmations, or any other cross-cutting concerns. The changes are well-covered by the added/updated unit tests. No E2E tags need to be run.

Performance Test Selection:
The changes are limited to a utility formatter function within the SocialLeaderboard feature. No performance-sensitive code paths (rendering, state management, data loading, app startup) are affected. The refactoring only changes how token amounts are displayed as strings, with no impact on rendering performance or data fetching.

View GitHub Actions results

@sonarqubecloud
Copy link
Copy Markdown

@xavier-brochard xavier-brochard added this pull request to the merge queue Apr 24, 2026
Merged via the queue into main with commit 9dc9557 Apr 24, 2026
64 checks passed
@xavier-brochard xavier-brochard deleted the TSA-447-Format-token-amounts-in-Trader-Profile-position branch April 24, 2026 14:07
@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 size-M team-social-ai Social & AI team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants