Portfolio: show unrealized P&L from hub marks (#675) #1179

Merged
PlasticDigits merged 2 commits from feat/675-portfolio-unrealized-pnl into main 2026-08-27 04:49:46 +00:00
PlasticDigits commented 2026-08-27 00:35:05 +00:00 (Migrated from gitlab.com)

Summary

  • Open positions on /portfolio and /trader/:addr now show current hub mark-to-market and unrealized P&L next to realized, so one-directional accumulation is not stuck at realized 0.
  • Convention: unrealized is current hub value of remaining quote minus on-DEX cost (holdings vs cost). Remaining quote with zero cost/avg shows No cost basis instead of an invented figure.
  • Marks use the same GET /api/v1/hub-prices catalog as #560 (DEX pool, including wrap discount vs CEX). Positions JSON stays raw.

Closes #675

Test plan

  • make verify-issue-675 (docs + Vitest)
  • /portfolio connected wallet: open UST1/cUSTC (or UST1/USTR) accumulation shows Mark $… and Unrealized ±… UST1 while Realized stays 0
  • Header Total Unrealized P&L matches the priced rows; unpriced / GEMX omitted (not $0)
  • Wrapped cUSTC mark follows hub custc, not CEX USTC
  • A row with remaining quote and cost=0 / avg=0 shows No cost basis
  • /trader/:addr shares the same table + header (not portfolio-only)
  • Realized human-scale + hub USD still look correct (make verify-issue-551, make verify-issue-560 optional)
## Summary - Open positions on `/portfolio` and `/trader/:addr` now show **current hub mark-to-market** and **unrealized P&L** next to realized, so one-directional accumulation is not stuck at realized `0`. - Convention: unrealized is **current hub value of remaining quote minus on-DEX cost** (holdings vs cost). Remaining quote with zero cost/avg shows **No cost basis** instead of an invented figure. - Marks use the same `GET /api/v1/hub-prices` catalog as #560 (DEX pool, including wrap discount vs CEX). Positions JSON stays raw. Closes #675 ## Test plan - [ ] `make verify-issue-675` (docs + Vitest) - [ ] `/portfolio` connected wallet: open UST1/cUSTC (or UST1/USTR) accumulation shows Mark `$…` and Unrealized `±… UST1` while Realized stays `0` - [ ] Header **Total Unrealized P&L** matches the priced rows; unpriced / GEMX omitted (not `$0`) - [ ] Wrapped cUSTC mark follows hub `custc`, not CEX USTC - [ ] A row with remaining quote and `cost=0` / `avg=0` shows **No cost basis** - [ ] `/trader/:addr` shares the same table + header (not portfolio-only) - [ ] Realized human-scale + hub USD still look correct (`make verify-issue-551`, `make verify-issue-560` optional)
PlasticDigits commented 2026-08-27 04:49:14 +00:00 (Migrated from gitlab.com)

added 7 commits

  • 1d760d71...479f9012 - 6 commits from branch main
  • 06a40e85 - Merge origin/main into feat/675-portfolio-unrealized-pnl.

Compare with previous version

added 7 commits <ul><li>1d760d71...479f9012 - 6 commits from branch <code>main</code></li><li>06a40e85 - Merge origin/main into feat/675-portfolio-unrealized-pnl.</li></ul> [Compare with previous version](/PlasticDigits/cl8y-dex-terraclassic/-/merge_requests/461/diffs?diff_id=1986963475&start_sha=1d760d71bf7f789bf4b5f2070f656d250f688b5c)
PlasticDigits commented 2026-08-27 04:49:47 +00:00 (Migrated from gitlab.com)

mentioned in commit 9515103569

mentioned in commit 9515103569e43ce6054d75519f79ec63fa9bc216
PlasticDigits (Migrated from gitlab.com) merged commit 9515103569 into main 2026-08-27 04:49:47 +00:00
PlasticDigits commented 2026-08-27 05:29:53 +00:00 (Migrated from gitlab.com)

mentioned in issue #686

mentioned in issue #686
PlasticDigits commented 2026-08-27 05:30:21 +00:00 (Migrated from gitlab.com)

mentioned in issue #674

mentioned in issue #674
PlasticDigits commented 2026-08-27 05:31:08 +00:00 (Migrated from gitlab.com)

mentioned in issue #675

mentioned in issue #675
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
code/cl8y-dex-terraclassic!1179
No description provided.