-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
fix(perps): balance display without full decimals cp-7.58.0 #21355
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
+258
−171
Conversation
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
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. |
21d6d75
to
905f860
Compare
905f860
to
662c524
Compare
7 tasks
michalconsensys
approved these changes
Oct 21, 2025
|
nickewansmith
approved these changes
Oct 21, 2025
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Labels
No E2E Smoke Needed
If the PR does not need E2E smoke test run
release-7.58.0
Issue or pull request that will be included in release 7.58.0
size-M
team-perps
Perps team
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.
Description
This PR fixes two currency formatting issues in the Perps feature that were introduced in PR #20971:
Missing Trailing Zeros: Fiat currency values were displaying without trailing zeros (e.g., "$13.40" showing as "$13.4", "$1,250.00" showing as "$1,250"). This violated standard fiat currency formatting conventions.
Misleading Zero Fallbacks: Several components were using hardcoded
'0'
fallbacks instead of semantic constants, making "$0.00" look like legitimate data when it actually represented unavailable/loading state.Root Causes:
formatPerpsFiat
to defaultstripTrailingZeros: true
for crypto token flexibility, but this broke fiat currency displays which should always show 2 decimal places.|| '0'
fallbacks instead of the semantic constants defined inperpsConfig.ts
(FALLBACK_DATA_DISPLAY = '--'
,FALLBACK_PRICE_DISPLAY = '$---'
).Solutions:
stripTrailingZeros: false
toPRICE_RANGES_MINIMAL_VIEW
configuration template informatUtils.ts
(1 line change instead of modifying 9 call sites).'0'
fallbacks with conditional rendering using appropriate semantic constants.Changelog
CHANGELOG entry: Fixed fiat currency formatting to always display two decimal places and use semantic fallback indicators for unavailable data
Related issues
Fixes: [Internal issue - currency formatting regression after PR #20971]
Manual testing steps
Screenshots/Recordings
Before
After
Pre-merge author checklist
Pre-merge reviewer checklist
Technical Details
Files Changed:
app/components/UI/Perps/utils/formatUtils.ts
stripTrailingZeros: false
toPRICE_RANGES_MINIMAL_VIEW
configuration (line 339)app/components/UI/Perps/Views/PerpsPositionsView/PerpsPositionsView.tsx
'0'
fallbacks with conditional rendering usingPERPS_CONSTANTS.FALLBACK_DATA_DISPLAY
app/components/UI/Perps/Views/PerpsTransactionsView/PerpsPositionTransactionView.tsx
'0'
fallbacks with semantic constantsPERPS_CONSTANTS.FALLBACK_PRICE_DISPLAY
(line 106-108)PERPS_CONSTANTS.FALLBACK_DATA_DISPLAY
(line 116-120)Impact:
Note
Standardizes fiat formatting to show proper decimals (fiat-style) and replaces hardcoded zero fallbacks with semantic placeholders, with null-safety and minor logic cleanups across Perps views and tests.
formatPerpsFiat
defaults toPRICE_RANGES_MINIMAL_VIEW
with fiat-style.00
stripping, addsfiatStyleStripping
, refines trailing-zero logic and options precedence; updates minimal ranges; keeps universal ranges.PERPS_CONSTANTS
), explicit null/undefined checks before formatting, andPRICE_RANGES_MINIMAL_VIEW
where appropriate; minor label/logic refactors (e.g., button label keys, rewards state switch, funding display sign/color logic).'0'
fallbacks withFALLBACK_DATA_DISPLAY
; format balances with minimal view.calculateEffectiveEntryPrice
, clarifies direction/price selection, safer boolean checks, keypad value selection cleanup.$
for very small fees; updates expected display.$7.50
,$10.50
,$125.50
), fallback displays ($---
), and liquidation invalid leverage handling; update PositionCard liquidation fallback and funding assertions.Written by Cursor Bugbot for commit 1c6ec51. This will update automatically on new commits. Configure here.