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:
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:
const SECONDS_PER_YEAR = 31_536_000;
const vaultTvl =
strategy.tokenBalance
+ strategy.externalYieldAmount
+ strategy.currentDeployedAmount
+ strategy.outstandingInterestAmount;
Field | Description |
|---|
tokenBalance | Idle tokens held in the Vault |
externalYieldAmount | Tokens deployed to external yield sources |
currentDeployedAmount | Tokens currently lent out through the order book |
outstandingInterestAmount | Accrued 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.const orderBookInterest = strategy.interestPerSecond * SECONDS_PER_YEAR;
const externalYield = externalYieldInfo.apy * strategy.externalYieldAmount;
const lendingApy = (orderBookInterest + externalYield) / vaultTvl;
If the Vault has active reward emissions, they are available in the vaultRewardsSchedule array on the response. Each entry represents a token emission schedule.For each schedule:
- Verify the schedule is active by checking that the current time falls between
rewardStartTime and rewardEndTime.
- Compute the annualized value of emissions. Since rewards can be denominated in various tokens, you will need to source the token price externally.
// For each active reward schedule
const isActive =
now >= schedule.rewardStartTime
&& now <= schedule.rewardEndTime;
if (isActive) {
// Convert from lamports
const emissionsPerSecond = Number(schedule.emissionsPerSecond) / 1e9;
const annualRewardValue = emissionsPerSecond * SECONDS_PER_YEAR * rewardTokenPrice;
const rewardsApy = annualRewardValue / vaultTvl;
}
If multiple reward schedules are active, sum their individual APYs to get the total rewards APY.
Calculating Total APY
The following combines both components into a single calculation:
// 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:
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.
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.
// 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.