Portfolio: show unrealized P&L (mark-to-market) on open positions, not just realized #675

Closed
opened 2026-08-26 22:01:09 +00:00 by leonardocolucci · 10 comments
leonardocolucci commented 2026-08-26 22:01:09 +00:00 (Migrated from gitlab.com)

Summary

/portfolio shows realized P&L only. For any position with one-directional flow (pure accumulation, or a full exit into the quote token), realized P&L reads 0 even when the open position has meaningful unrealized gain/loss. A user looking at the page can't tell whether their open positions are currently up or down.

Follow-on to #551 (realized P&L) and #674 (hide test tokens).

Expected

Each open position also shows current mark-to-market value and unrealized P&L, marked with the same hub prices used elsewhere (#551), alongside the existing realized column.

Convention to get right (so it doesn't mislead)

  • For one-directional swaps, "unrealized P&L" is effectively a mark on the asset you swapped out of — define and document the convention (e.g., current value of holdings vs cost basis) rather than showing a bare number.
  • The DEX only knows on-DEX cost basis. Positions built from assets acquired off-DEX (bridged/minted) have no basis — surface those as "no cost basis" instead of a misleading figure.
  • Mark consistently at the DEX pool price where a wrapped asset diverges from its CEX oracle (a wrapped token can trade at a discount to the reference), matching hub-prices.
## Summary [/portfolio](https://dex.cl8y.com/portfolio) shows **realized P&L only**. For any position with one-directional flow (pure accumulation, or a full exit into the quote token), realized P&L reads **0** even when the open position has meaningful unrealized gain/loss. A user looking at the page can't tell whether their open positions are currently up or down. Follow-on to #551 (realized P&L) and #674 (hide test tokens). ## Expected Each open position also shows **current mark-to-market value** and **unrealized P&L**, marked with the same hub prices used elsewhere (#551), alongside the existing realized column. ## Convention to get right (so it doesn't mislead) - For one-directional swaps, "unrealized P&L" is effectively a mark on the asset you swapped *out of* — define and document the convention (e.g., current value of holdings vs cost basis) rather than showing a bare number. - The DEX only knows **on-DEX** cost basis. Positions built from assets acquired off-DEX (bridged/minted) have no basis — surface those as "no cost basis" instead of a misleading figure. - Mark consistently at the **DEX pool** price where a wrapped asset diverges from its CEX oracle (a wrapped token can trade at a discount to the reference), matching hub-prices.
PlasticDigits commented 2026-08-27 00:33:43 +00:00 (Migrated from gitlab.com)

mentioned in issue #674

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

mentioned in commit 1d760d71bf

mentioned in commit 1d760d71bf7f789bf4b5f2070f656d250f688b5c
PlasticDigits commented 2026-08-27 00:34:50 +00:00 (Migrated from gitlab.com)

mentioned in merge request !1178

mentioned in merge request !1178
PlasticDigits commented 2026-08-27 00:35:06 +00:00 (Migrated from gitlab.com)

mentioned in merge request !1179

mentioned in merge request !1179
PlasticDigits commented 2026-08-27 04:49:14 +00:00 (Migrated from gitlab.com)

mentioned in commit 06a40e8511

mentioned in commit 06a40e85111a8c689f4bba3b5ebd412b64cb9cdd
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) closed this issue 2026-08-27 04:49:48 +00:00
PlasticDigits commented 2026-08-27 04:51:38 +00:00 (Migrated from gitlab.com)

mentioned in commit 226a3b3f07

mentioned in commit 226a3b3f0764ab10be2d187238a47d92503a53c5
PlasticDigits commented 2026-08-27 05:29:51 +00:00 (Migrated from gitlab.com)

mentioned in issue #686

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

marked as related to #686

marked as related to #686
PlasticDigits commented 2026-08-27 05:31:08 +00:00 (Migrated from gitlab.com)

Merged via !1179 (95151035) onto main 36d64528 after resolving conflicts with #674 (same positions table).

make verify-issue-675 PASS (3/3). Header unrealized uses visible (filtered) rows on /portfolio. Coolify leftover: frontend rebuild. Do not reopen unless P675 is wrong. Post-merge ops: #686.

Merged via !1179 (`95151035`) onto `main` `36d64528` after resolving conflicts with #674 (same positions table). `make verify-issue-675` **PASS** (3/3). Header unrealized uses visible (filtered) rows on `/portfolio`. Coolify leftover: frontend rebuild. Do not reopen unless P675 is wrong. Post-merge ops: #686.
Sign in to join this conversation.
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#675
No description provided.