Commit 4dca9ba
fix: use subscript for price notation (#24441)
## **Description**
This PR improves the price formatting in the Trending Tokens feature by
introducing subscript notation for very small token prices (e.g.,
0.00000614 → $0.0₆14).
Changes include:
* New formatPriceWithSubscriptNotation function - Formats prices with
subscript notation for values with 4+ leading zeros, making small token
prices more readable
* Zero value handling - Shows "—" (em dash) when price is zero, and also
for percentage change when price is zero
* Market stats dash display - Shows "-" for market cap and volume when
values are zero instead of displaying misleading "$0" values
## **Changelog**
CHANGELOG entry: Improved price display for trending tokens with
subscript notation for very small values (e.g., $0.0₆14)
## **Related issues**
Fixes: #24327
Fixes: #24326
## **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] -->
https://github.com/user-attachments/assets/46766765-b326-44c6-92ee-a73bf88aceed
## **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.
<!-- CURSOR_SUMMARY -->
---
> [!NOTE]
> Improves readability of tiny token prices and zero-value stats in
Trending Tokens.
>
> - Adds `formatPriceWithSubscriptNotation` in `Predict/utils/format.ts`
(with `toSubscript`) to render very small prices using subscript (e.g.,
`$0.0₅614`), returns `—` for zero, otherwise 2–4 decimals
> - Updates `TrendingTokenRowItem.tsx` to use the new formatter and
display `—` instead of percentage change when price is zero
> - Changes `formatMarketStats` in `TrendingTokenRowItem/utils.ts` to
show `-` for zero `marketCap`/`volume`
> - Updates/extends tests: comprehensive cases for the new price
formatting, adjusted expectations for zero stats, and component
rendering behaviors
>
> <sup>Written by [Cursor
Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit
9aa0b5d. This will update automatically
on new commits. Configure
[here](https://cursor.com/dashboard?tab=bugbot).</sup>
<!-- /CURSOR_SUMMARY -->1 parent 95fb5a3 commit 4dca9ba
6 files changed
Lines changed: 555 additions & 20 deletions
File tree
- app/components/UI
- Predict/utils
- Trending/components/TrendingTokenRowItem
0 commit comments