APR Calculation (Detailed)

Realized APR Formula

When profits are realized (converted to USDC):

Profit % = Realized Profit / Last Snapshot Total Credited USDC
Daily Rate = Profit % / Days Since Last Realization
Realized APR = Daily Rate × 365

Unrealized APR Formula

When profits are credited (still in position):

Unrealized Profit = (Position Value + Unclaimed Fees) - Last Snapshot Credited USDC - New Capital
Profit % = Unrealized Profit / (Snapshot Credited + New Capital)
Daily Rate = Profit % / Days Since Last Realization
Unrealized APR = Daily Rate × 365

Snapshot Logic

A snapshot of Total Credited USDC is recorded every time profits are realized or credited. This snapshot is used as the denominator in future APR calculations.

Daily Profit Rate Calculation

Based on the time difference from the last profit event. This allows APR to adapt dynamically depending on the frequency and scale of profit events.

Profit Accounting Methods

  • realizeProfit: Agent converts profit to USDC, adds to vault. APR is Realized.

  • creditProfit: Agent leaves profit in position but updates the vault’s accounting. APR is still treated as Realized.

If neither function is called recently, APR falls back to Unrealized based on the active DEX position value.

Last updated