feat(perps): add precision warning for TP/SL prices exceeding 5 significant figures #24169
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 adds client-side validation for Take Profit (TP) and Stop Loss (SL) price inputs in the Perps trading feature. When users enter prices with more than 5 significant figures, a non-blocking warning is displayed informing them that the decimal precision may be reduced after submitting.
Why this change?
The HyperLiquid API enforces a maximum of 5 significant figures for price values. The
formatHyperLiquidPricefunction in the provider layer already rounds prices exceeding this limit, but users were unaware their input would be modified. This led to a confusing UX where the submitted price differed from what was entered.What's included?
countSignificantFiguresandhasExceededSignificantFiguresfunctions that match HyperLiquid's rounding behaviorPRICE_RANGES_MINIMAL_VIEWtoPRICE_RANGES_UNIVERSALto show full decimal precisionChangelog
CHANGELOG entry: Added a warning message when Take Profit or Stop Loss prices exceed 5 significant figures, informing users that decimal precision may be reduced after submitting.
Related issues
Fixes: https://consensyssoftware.atlassian.net/browse/TAT-2063
Manual testing steps
Screenshots/Recordings
Before
No visible change
After
Pre-merge author checklist
Pre-merge reviewer checklist
Note
Adds non-blocking TP/SL price precision warnings (5 significant figures), updates TP/SL display formatting, and introduces validation utilities with tests.
PerpsTPSLViewfor TP/SL when price exceeds 5 significant figures (takeProfitPrecisionWarning,stopLossPrecisionWarning).PerpsPositionCardby switching toPRICE_RANGES_UNIVERSAL.countSignificantFiguresandhasExceededSignificantFiguresinutils/tpslValidation.ts; integrate intousePerpsTPSLForm.DECIMAL_PRECISION_CONFIGwithMAX_SIGNIFICANT_FIGURES: 5.perps.tpsl.price_precision_warningstring.tpslValidation.test.ts.Written by Cursor Bugbot for commit a621323. This will update automatically on new commits. Configure here.