Skip to main content
Positions earn in different ways depending on where the funds sit. This page explains how each one grows, how the API turns that into PnL, and what each APY field measures, so the numbers you show users are accurate.

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_earned on each collateral position: amount_supplied + total_withdrawn - total_deposited
  • interest_paid on 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:
  1. 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.
  2. A withdrawal or sale uses up the oldest lots first. realized_pnl grows by the amount received minus the cost of the lots used.
  3. unrealized_pnl is the current value minus the cost of everything still held.
  4. total_pnl is realized plus unrealized. total_pnl_percent divides it by total_deposited, the sum of all deposits.
Earn reports PnL in the position’s own asset: the underlying token for vaults and Aave, and SY units for Pendle PT. Tokenized Assets reports it in USD, taking the cost from the USDC paid in the same transaction.

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

Tokenized Assets APYs are fractions, while every other APY on this page is a percentage. Multiply them by 100 before you show them next to Earn or Credit rates.
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 null when 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 PERFORMANCE embedded 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.