feat(perps): add optimistic updates for take profit and stop loss prices#24159
feat(perps): add optimistic updates for take profit and stop loss prices#24159
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. |
gambinish
left a comment
There was a problem hiding this comment.
Looks good to me. Can we also get @abretonc7s to review this as well?
🔍 Smart E2E Test Selection
click to see 🤖 AI reasoning detailsThe changes are entirely contained within the Perps (Perpetuals) feature module:
The changes:
The |
|



Description
When users update take profit (TP) or stop loss (SL) prices in Perps, the position would display
undefinedvalues until the WebSocket returned the updated position from the server. This created a poor user experience with a visible delay.This PR implements optimistic updates that immediately reflect TP/SL price changes in the UI after a successful API response, before the WebSocket confirms the change. This provides instant feedback to users.
Changelog
CHANGELOG entry: Use optimistic approach when updating TP/SL in perps
Related issues
Fixes: https://consensyssoftware.atlassian.net/browse/TAT-2054
Manual testing steps
Screenshots/Recordings
Before
See video in https://consensyssoftware.atlassian.net/browse/TAT-2054
After
Simulator.Screen.Recording.-.iPhone.17.Pro.-.2025-12-18.at.15.42.03.mov
Pre-merge author checklist
Pre-merge reviewer checklist
Note
Introduces immediate UI feedback for TP/SL changes by updating the positions cache optimistically after a successful API response.
positions.updatePositionTPSLOptimistic(coin, takeProfitPrice, stopLossPrice)inPerpsStreamManagerto mutate cached positions and notify subscribersusePerpsTPSLUpdate(invoked before success toast) while preserving existing error handling/hapticsWritten by Cursor Bugbot for commit 1765875. This will update automatically on new commits. Configure here.