How each position grows
Credit: interest earned and paid
Credit positions don’t have a single PnL. Collateral can earn a supply rate (supply_apy), and debt grows at the borrow rate (borrow_apy). The API reports each side separately:
interest_earnedon each collateral position:amount_supplied + total_withdrawn - total_depositedinterest_paidon each debt position:amount_borrowed + total_repaid - total_borrowed
total_usd_value is the account’s net value: collateral minus debt.
How PnL is calculated
Earn and Tokenized Assets calculate PnL with FIFO (first in, first out) cost basis:- Every deposit or purchase becomes a lot with its own cost. For a vault, a lot is the shares received and the share price paid.
- A withdrawal or sale uses up the oldest lots first.
realized_pnlgrows by the amount received minus the cost of the lots used. unrealized_pnlis the current value minus the cost of everything still held.total_pnlis realized plus unrealized.total_pnl_percentdivides it bytotal_deposited, the sum of all deposits.
Example
A user makes two deposits into a USDC vault, then withdraws part of the position:
What’s left is 40 shares from lot 1 (cost 40) and 49.02 shares from lot 2 (cost 50), worth 89.02 × 1.05 = 93.47 USDC. The position then reports:
What the APY numbers mean
None of these numbers is a promise. Vault and Tokenized Assets APYs look back over a window, and Aave and Credit rates change with supply and demand. Only a Pendle PT held to maturity earns a fixed rate. APY fields can be
null, for example when there isn’t enough history yet.
Good to know
- Vault APYs are net of the vault’s own fees, because they’re measured from the share price.
- PnL can lag right after a transaction. The current value is read live from the chain, while PnL is built from indexed transaction history. For a short time after a deposit or withdrawal, the two can disagree.
- Tokenized Assets PnL is
nullwhen the cost is unknown, for example for tokens sent into the account from outside, since there’s no purchase price to measure against. - Performance fees use the same numbers. A
PERFORMANCEembedded fee on an Earn withdrawal is a share of that withdrawal’s realized profit, calculated with the same FIFO cost basis.
Next
Withdraw Funds
Exit positions and send tokens back to the user’s wallet.