PnL & Principal Borrowed

Moar shows profit & loss (PnL) at the credit account level — i.e., across everything inside your account, compared to a simple “HODL my deposits” baseline.


📊 What you’ll see

  • Unrealized PnL (UPnL): live gains/losses while funds remain inside your credit account.

  • Realized PnL (RPnL): the slice you’ve actually locked in.

  • Realized liquidation loss: any liquidation penalty, fixed at the moment it happens.

  • Principal Borrowed: how much you’ve borrowed (per pool), excluding accrued interest.

PnL is account-level, not per position.


✂️ When does PnL get realized?

  • Withdrawals:Yes — withdrawing locks in a proportional slice of your current UPnL.

  • Repays (internal or external):No — repaying debt alone doesn’t realize PnL; value is still inside the credit account.

  • Liquidations: Trading PnL does not realize; the penalty is booked separately as a fixed realized liquidation loss at the time of liquidation.


🏦 Principal Borrowed (per pool)

  • On borrow: principal for that pool increases by the borrowed amount.

  • Interest accrues over time on top of principal.

  • On repay: repayments first cover accrued interest; only the remainder reduces principal.

  • On liquidation: the repaid portion reduces debt; after interest is covered, principal drops accordingly.

This is presented per pool (e.g., APT pool, USDC pool) so you can see what you still owe before interest.


🧮 Comprehensive example (with values)

Assumptions (clean numbers):

  • Oracle prices: 1 USDC = $1, 1 APT = $10.

  • sthAPT starts 1:1 with APT (value-equivalent).

  • Floor rounding on proportional calculations (like the app).

1) Open and leverage

  • Deposit: $1,000 USDC → Baseline (TC) = $1,000

  • Borrow: $2,000 worth of APT (200 APT) → stake to 200 sthAPT

  • Totals (T0):

    • Total Assets (TA): $1,000 (USDC) + $2,000 (sthAPT) = $3,000

    • Total Debt (TD): $2,000

    • Equity/NAV: $1,000

    • UPnL = TA − TD − TC = 3,000 − 2,000 − 1,000 = $0

    • RPnL = $0

    • Principal Borrowed (APT pool) = $2,000

2) Time passes: yield + interest

  • sthAPT +5% (now worth $2,100)

  • Borrow interest +$30 → TD = $2,030

  • Totals (T1):

    • TA: $1,000 + $2,100 = $3,100

    • TD: $2,030 (of which principal $2,000, interest $30)

    • NAV: $1,070

    • UPnL: 3,100 − 2,030 − 1,000 = $70

    • RPnL: $0

3) Internal repay (sell sthAPT → APT → repay)

  • Repay: $400 (funded from account assets)

  • Effect: TA ↓ by $400 (to $2,700); TD ↓ by $400 (to $1,630).

    • First $30 covers interest; principal drops from $2,000 → $1,630.

  • PnL: not realized on repay; Baseline unchanged (TC = $1,000).

  • Totals (T2):

    • TA: $2,700

    • TD: $1,630

    • NAV: $1,070 (unchanged)

    • UPnL: 2,700 − 1,630 − 1,000 = $70

    • RPnL: $0

    • Principal Borrowed: $1,630

4) Withdraw $300 USDC (PnL realization happens here)

  • Withdraw value (W): $300

  • Proportional realization:

    • Pre-withdraw UPnL = $70, NAV = $1,070

    • Realized slice = floor(UPnL × W / NAV) = floor(70 × 300 / 1,070) = $19

    • RPnL → $19, UPnL → $70 − $19 = $51

  • Baseline scales down by kept-equity ratio: factor = (NAV − W) / NAV = 770 / 1,070

    • TC: floor(1,000 × 770 / 1,070) = $719

  • Totals (T3):

    • TA: 2,700 − 300 = $2,400

    • TD: $1,630

    • NAV: $770

    • UPnL: 2,400 − 1,630 − 719 = $51

    • RPnL: $19

    • Principal Borrowed: $1,630

5) Partial liquidation (fixed penalty, no trading-PnL realization)

  • Liquidator repays R = $500, seizes W = $525 (5% bonus)

  • Penalty = $25 → recorded as realized liquidation loss = $25 (fixed).

  • Balances: TA = 2,400 − 525 = $1,875; TD = 1,630 − 500 = $1,130

  • NAV: from 770 → 745 (drops $25, matching the penalty)

  • Baseline reduces by the penalty (proportionally): TC: 719 − 25 = $694

  • PnL: trading PnL does not realize on liquidation → UPnL stays $51

  • Totals (T4):

    • TA: $1,875

    • TD: $1,130

    • NAV: $745

    • UPnL: 1,875 − 1,130 − 694 = $51

    • RPnL: $19

    • Realized liquidation loss: $25

    • Principal Borrowed: $1,130

Takeaways from the example: • PnL is not realized on repay (internal/external). • PnL is realized on withdraws (proportionally). • Liquidation penalty is a fixed realized loss; trading PnL doesn’t “realize” during liq. • Principal Borrowed falls only after interest is covered, so it cleanly tracks the outstanding “original” amount.


🛡️ Notes

  • Health checks still gate all outflows — your account must remain healthy after any withdraw or strategy exit.

  • Oracles value all assets and debts; tiny rounding can appear when scaling the baseline across multiple assets.


Last updated