WIP: Draft: Portfolio: show unrealized P&L from hub marks (#675) #1178

Closed
PlasticDigits wants to merge 0 commits from 675-portfolio-show-unrealized-p-l-mark-to-market-on-open-positions-not-just-realized into main
PlasticDigits commented 2026-08-27 00:34:50 +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 a 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)

Closes #675

## 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 a 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) Closes #675
PlasticDigits (Migrated from gitlab.com) closed this pull request 2026-08-27 00:35:10 +00:00

Pull request closed

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!1178
No description provided.