Skip to content

fix: in the position card, when user has multiple TP (or SL) orders, Then display TP (or SL) orders count instead of the position TP (or SL) priceof - #9912

Merged
abretonc7s merged 2 commits into
mainfrom
TAT-3791-fix-fix-position-card-tp-sl-count
Aug 20, 2026
Merged

fix: in the position card, when user has multiple TP (or SL) orders, Then display TP (or SL) orders count instead of the position TP (or SL) priceof#9912
abretonc7s merged 2 commits into
mainfrom
TAT-3791-fix-fix-position-card-tp-sl-count

Conversation

@abretonc7s

@abretonc7s abretonc7s commented Aug 19, 2026

Copy link
Copy Markdown
Contributor

Explanation

A partial (quantity-scoped) take profit cannot be position-bound — a position-bound
trigger always closes the whole position — so updatePositionTPSL places it with
grouping: 'na' as a standalone reduce-only trigger. The scalar summary fields
Position.takeProfitPrice / stopLossPrice were only ever scanned from
position-bound triggers, so a position whose only take profit was partial reported
takeProfitCount: 1 with no price at all. Clients that render the scalar — the
mobile position card among them — showed nothing where a price belongs.

This adds resolvePositionTriggerSummaryPrice to @metamask/perps-controller/utils
and uses it wherever a position's TP/SL summary is assembled: when a direction has
exactly one trigger order, that order's price is the summary price, partial or not.
Two or more triggers keep the previously scanned value, because no single price
describes them and clients render takeProfitCount instead; zero triggers keep it
too, since it still carries the TP/SL of a pending order on the market, which the
trigger arrays deliberately exclude.

The same summary is computed at three independent sites — the REST getPositions
path, getUserDataSnapshot, and the WebSocket merge in
HyperLiquidSubscriptionService. All three now go through the helper, so the price a
position reports no longer depends on whether the WebSocket cache happens to be warm.

Note for clients: a partial take profit now surfaces on the scalar. A TP/SL editor
that prefills from takeProfitPrice should key off takeProfitOrders /
takeProfitCount instead, so a partial trigger is not silently offered up for
replacement by a whole-position one.

Proved end to end against HyperLiquid testnet: one real partial take profit attached
through the controller's signing path, read back through
PerpsController.getUserDataSnapshot()takeProfitPrice was null before the
change and carries the trigger's price after, with a whole-position replacement
asserted in the same run to cover the pre-existing path.

References

  • Fixes TAT-3791

Checklist

  • I've updated the test suite for new or updated code as appropriate
  • I've updated documentation (JSDoc, Markdown, etc.) for new or updated code as appropriate
  • I've communicated my changes to consumers by updating changelogs for packages I've changed
  • I've introduced breaking changes in this PR and have prepared draft pull requests for clients and consumer packages to resolve them

Note

Cursor Bugbot is generating a summary for commit ec70743. Configure here.

A partial (quantity-scoped) take profit cannot be position-bound, so it is
placed as a standalone reduce-only trigger. The scalar summary fields
takeProfitPrice/stopLossPrice were only ever scanned from position-bound
triggers, so a position whose only take profit was partial reported
takeProfitCount: 1 with no price, and clients rendering the scalar showed none.

Add resolvePositionTriggerSummaryPrice and use it wherever the summary is
assembled — REST getPositions, getUserDataSnapshot, and the WebSocket merge —
so a lone trigger reports its own price whatever its grouping. Two or more
triggers keep the scanned value, since clients render the count instead.
@abretonc7s abretonc7s changed the title chore: prepare farmslot publication pkg-3d17fca8-mt09br71 fix: in the position card, when user has multiple TP (or SL) orders, Then display TP (or SL) orders count instead of the position TP (or SL) priceof Aug 19, 2026
@abretonc7s
abretonc7s marked this pull request as ready for review August 19, 2026 16:38
@abretonc7s
abretonc7s requested review from a team as code owners August 19, 2026 16:38
@abretonc7s
abretonc7s deployed to default-branch August 19, 2026 16:38 — with GitHub Actions Active
The Unreleased entries carried placeholder #0000 links, which the
Check changelog workflow rejects: it requires each entry to link to the
current PR.
@abretonc7s
abretonc7s added this pull request to the merge queue Aug 20, 2026
Merged via the queue into main with commit 95e9c9a Aug 20, 2026
46 checks passed
@abretonc7s
abretonc7s deleted the TAT-3791-fix-fix-position-card-tp-sl-count branch August 20, 2026 01:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants