feat(perps): new TPSL view design #21396
Open
+574
−230
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 implements TAT-1729, adding expected profit/loss calculation display to the Auto Close (TP/SL) configuration screen. It also includes several UX improvements based on design refinements.
What is the reason for the change?
Users need to see the expected net profit or loss when setting TP/SL values, accounting for trading fees. This helps them make informed decisions about their risk management strategy. Additionally, several UX improvements were needed to match the final design specifications.
What is the improvement/solution?
Expected P&L Display: Shows real-time expected profit/loss below TP and SL input fields
formatPerpsFiat
with PRICE_RANGES_MINIMAL_VIEWTerminology Update: Renamed "TP/SL" to "Auto close" throughout the UI
UX Improvements:
Implementation Approach (DRY):
calculatePnL()
utility frompnlCalculations.ts
usePerpsOrderFees()
hook for accurate fee calculationcalculatePositionSize()
for new orderscalculateExpectedPnL()
wrapper that combines P&L with fee deductionusePerpsTPSLForm
hook return values (no new hooks created)formatPerpsFiat
)Changelog
CHANGELOG entry: Added expected profit/loss display to Auto Close (TP/SL) configuration showing net profit after fees, improved UI layout and terminology
Related issues
Manual testing steps
Screenshots/Recordings
Before
After
Screen.Recording.2025-10-18.at.7.43.52.PM.mov
Pre-merge author checklist
Pre-merge reviewer checklist
Note
Adds net expected profit/loss (incl. fees) to Auto close (TP/SL) and updates UI/labels, button flow, and tests.
Clear
actions; removedOff
preset buttons and active styles.$
label moved left; layout tweaks, spacing, and condensed sections; auto-scroll on input focus; keypad footer now showsDone
when focused,Cancel
+Set
otherwise.usePerpsTPSLForm
: computesexpectedTakeProfitPnL
/expectedStopLossPnL
; supports newamount
/szDecimals
for new orders; derives position size; integratesusePerpsOrderFees
to net fees.calculateExpectedPnL
inpnlCalculations
(reusescalculatePnL
minus closing fee).cancel
,set
,clear
,expected_profit
,expected_loss
; changeusd_label
to$
.Clear
,Set
/Cancel
, expected PnL rendering); refactor hook tests with Redux wrapper and new params; adjust assertions for removed active states and button text changes.Written by Cursor Bugbot for commit c8a44a2. This will update automatically on new commits. Configure here.