-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
fix: ensure that close position screen uses correct decimals #21982
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
fix: ensure that close position screen uses correct decimals #21982
Conversation
|
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. |
da23b77 to
89b30c3
Compare
…ens-in-close-screen
|
@gambinish this was prev approved but i add sonar cloud updates that were blocking and also unrelated to the PR. Those were mostly removed after the rebase with main just now. |
|
gambinish
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Stamping based on previous approval



Description
Fixed the decimal precision issue for token amounts displayed in the Perps Close Position screen. The component now uses asset-specific szDecimals from market metadata to format position sizes correctly, ensuring proper display across different cryptocurrencies.
🐛 Problem
Previously, formatPositionSize was called without the szDecimals parameter, causing inconsistent decimal precision across different assets. This resulted in either too many or too few decimal places being displayed for token amounts (e.g., BTC showing too many decimals, DOGE showing unnecessary precision).
✅ Solution
Added usePerpsMarketData hook to fetch market metadata for the position's asset
Passed marketData?.szDecimals to both formatPositionSize calls:
Token amount display in PerpsAmountDisplay component
Token amount in the toggle container text
The formatting now respects asset-specific decimal precision
Changelog
CHANGELOG entry: null
Related issues
Fixes: https://consensyssoftware.atlassian.net/browse/TAT-1922
Manual testing steps
Screenshots/Recordings
Before
After
Pre-merge author checklist
Pre-merge reviewer checklist
Note
Uses asset-specific szDecimals from market data to format token amounts in Close Position and adds focused tests; minor key fix in error list rendering.
usePerpsMarketData(position.coin)and passmarketData?.szDecimalstoformatPositionSizefortokenAmountand the toggle text.error-${index}).Written by Cursor Bugbot for commit 6ace779. This will update automatically on new commits. Configure here.