Skip to main content
This guide walks through how to compute Vault TVL, Vault APY, rewards APY, and Loop APY using Loopscale’s data endpoints. These are the key metrics for building dashboards, portfolio trackers, or any integration that displays Loopscale yield data.

Vault Metrics

Use the Get Vaults endpoint to retrieve Vault data. You can also query the Get Vault Depositors endpoint for depositor-level breakdowns. All of the fields referenced below are located in the vaultStrategy object of the response. Example request:
Example
curl -X POST https://tars.loopscale.com/v1/markets/lending_vaults/info \
  -H "Content-Type: application/json" \
  -d '{
    "page": 0,
    "pageSize": 10,
    "includeRewards": true
  }'

Computing Vault TVL

Sum the following fields from vaultStrategy.strategy:
Example
const SECONDS_PER_YEAR = 31_536_000;

const vaultTvl =
  strategy.tokenBalance
  + strategy.externalYieldAmount
  + strategy.currentDeployedAmount
  + strategy.outstandingInterestAmount;
Field
Description
tokenBalanceIdle tokens held in the Vault
externalYieldAmountTokens deployed to external yield sources
currentDeployedAmountTokens currently lent out through the order book
outstandingInterestAmountAccrued interest not yet repaid

Computing Vault APY

The total Vault APY that a depositor earns is the sum of two components, the lending APY from order-book interest, and the rewards APY from any active token incentive schedules.
This blends the interest earned from order-book lending with the yield from any external yield source, normalized over the total TVL.
Example
const orderBookInterest = strategy.interestPerSecond * SECONDS_PER_YEAR;
const externalYield = externalYieldInfo.apy * strategy.externalYieldAmount;

const lendingApy = (orderBookInterest + externalYield) / vaultTvl;

Calculating Total APY

The following combines both components into a single calculation:
Example
// 1. Lending APY from order-book interest + external yield
const orderBookInterest = strategy.interestPerSecond * SECONDS_PER_YEAR;
const externalYield = externalYieldInfo.apy * strategy.externalYieldAmount;
const lendingApy = (orderBookInterest + externalYield) / vaultTvl;

// 2. Rewards APY from all active incentive schedules
let totalRewardsApy = 0;

for (const schedule of vaultRewardsSchedule) {
  const isActive =
    now >= schedule.rewardStartTime
    && now <= schedule.rewardEndTime;

  if (isActive) {
    const emissionsPerSecond = Number(schedule.emissionsPerSecond) / 1e9;
    const annualRewardValue = emissionsPerSecond * SECONDS_PER_YEAR * rewardTokenPrice;
    totalRewardsApy += annualRewardValue / vaultTvl;
  }
}

// 3. Total Vault APY
const totalVaultApy = lendingApy + totalRewardsApy;

Loop Metrics

Use the Get Loop Info endpoint to retrieve Loop data. You can filter by:
  • Loop identifiers — either the slug (e.g. acred-usdg) or the mints formatted as {PRINCIPAL_MINT}-{COLLATERAL_MINT}
  • Tags — e.g. Stablecoin, Exponent, Hylo, etc.
Example request:
Example
curl -X POST https://tars.loopscale.com/v1/markets/loop/info \
  -H "Content-Type: application/json" \
  -d '{
    "identifiers": ["acred-usdg"]
  }'

Total Looped Assets

The collateralDeposited field returns the total assets deposited into the Loop, in decimal-scaled value.
Example
const totalLoopedAssets = loopInfo.collateralDeposited;

Computing Loop APY

Use the wAvgApy field, which represents the current weighted-average APY across all active positions, weighted by size.
Example
// Prefer wAvgApy over maxApy for display
const loopApy = loopInfo.wAvgApy;
Avoid using maxApy for display purposes. If borrow liquidity is exhausted, maxApy may be empty or pull from a small strategy with an unrealistically high or low yield. wAvgApy is more reliable and representative of actual user returns.