DeFindex Docs
  • DeFindex Protocol
    • Welcome
    • What is DeFindex?
  • Getting Started
    • How DeFindex Works
    • Creating a DeFindex Vault
    • Mainnet Deployment
  • Whitepaper
    • Whitepaper
      • Introduction
        • Core Concepts
      • The DeFindex Approach
        • Design Decisions
      • Smart Contracts
        • DeFindex Vault
        • DeFindex Strategy
        • DeFindex Zapper
      • Strategy Examples
      • State of the Art
        • Yearn Finance
      • Appendix
        • Why Not Swap in Deposit
  • WALLET DEVELOPER
    • Flutter SDK
    • Typescript SDK
    • Vault APY
  • STRATEGIES
    • What is a strategy?
    • What is Blend Capital?
    • Strategies APY
  • Users
    • About Us
    • General/FAQ
      • Additional Resources
  • Security
    • Security Audit
Powered by GitBook
On this page
  • 🧮 How to Get the Vault Price Per Share
  • 📈 How to Calculate Vault APY
Edit on GitHub
  1. WALLET DEVELOPER

Vault APY

The Vault APY shows how much the value of a vault shares grows over time — similar to earning interest on savings.

This value depends on:

  • The assets supported in the vault,

  • The strategies the vault uses,

  • The rebalancing actions taken by the Vault Manager.

Even though there are many moving parts, DeFindex Vaults make it easy to track this performance through the Vault Price Per Share (VPPS).


💡 What is Vault Price Per Share?

Just like strategies have a price per share, the vault itself has a price per share that shows how much 1 share of the vault is worth.

This includes:

  • All the strategies the vault uses,

  • How much is allocated to each strategy,

  • And how well each strategy is performing.

So, when the vault earns yield or its strategies grow, the vault price per share increases.


🧮 How to Get the Vault Price Per Share

There are two main ways to calculate it. Both give the same result.

✅ Method 1: Use the Contract Function get_asset_amounts_per_shares

fn get_asset_amounts_per_shares(
        e: Env,
        vault_shares: i128,
    ) -> Result<Vec<i128>, ContractError>;

You can get the real-time vault PPS by calling

get_asset_amounts_per_shares(1_000_000_000_000) // 1 Vault Share is SCALAR_12

This function returns a Vecof asset amounts per share. Each amount matches the asset at the same index in the vault’s asset list.

To calculate the vault share price in a specific pricing currency (e.g. USD):

Vault PPS=∑i(Asset Pricei×VAmounti)\text{Vault PPS} = \sum_{i} \left( \text{Asset Price}_i \times \text{VAmount}_i \right)Vault PPS=i∑​(Asset Pricei​×VAmounti​)

Where:

  • VAmount_i = amount of asset i per share fasdf

  • Asset Price_i = price of asset i (from an oracle or external source)

If the vault has only one asset and you're pricing in that same asset, just use the first value from get_asset_amounts_per_shares.


✅ Method 2: Use Vault Events

Each time someone deposits or withdraws from the vault, deposit and withdraw events are emitted:


pub struct VaultWithdrawEvent {
    pub withdrawer: Address,
    pub df_tokens_burned: i128,
    pub amounts_withdrawn: Vec<i128>,
    pub total_supply_before: i128,
    pub total_managed_funds_before: Vec<CurrentAssetInvestmentAllocation>,
}
pub struct VaultDepositEvent {
    pub depositor: Address,
    pub amounts: Vec<i128>,
    pub df_tokens_minted: i128,
    pub total_supply_before: i128,
    pub total_managed_funds_before: Vec<CurrentAssetInvestmentAllocation>,
} 

Each event includes:

  • total_supply_before — the number of vault shares before the action

  • total_managed_funds_before — a list of all asset allocations

Each asset allocation looks like this:

pub struct CurrentAssetInvestmentAllocation {
    pub asset: Address,
    pub total_amount: i128,
    pub idle_amount: i128,
    pub invested_amount: i128,
    pub strategy_allocations: Vec<StrategyAllocation>,
}

To calculate the vault price per share:

Vault PPS=∑(Asset Pricei×Total Asset Amounti)Total Vault Shares\text{Vault PPS} = \frac{\sum \left( \text{Asset Price}_i \times \text{Total Asset Amount}_i \right)}{\text{Total Vault Shares}}Vault PPS=Total Vault Shares∑(Asset Pricei​×Total Asset Amounti​)​

If the vault only holds one asset, then:

Vault PPS=Total Asset AmountTotal Supply\text{Vault PPS} = \frac{\text{Total Asset Amount}}{\text{Total Supply}}Vault PPS=Total SupplyTotal Asset Amount​

Where:

  • Total Asset Amount = sum of all units of that one asset held by the vault (from total_managed_funds_before[0].total_amount)

  • Total Supply = number of shares before the action (from total_supply_before)

📈 How to Calculate Vault APY

Once you have the Vault PPS at two different points in time, you can calculate APY using the same method as when is calculated for strategies:

pps_delta=PPSnowPPSthen−1\text{pps\_delta} = \frac{\text{PPS}_{\text{now}}}{\text{PPS}_{\text{then}}} - 1pps_delta=PPSthen​PPSnow​​−1

Then annualize it:

Vault APY=(1+pps_delta)(365.2425days)−1\text{Vault APY} = \left(1 + \text{pps\_delta} \right)^{\left( \frac{365.2425}{\text{days}} \right)} - 1Vault APY=(1+pps_delta)(days365.2425​)−1

Where days is the number of days between the two PPS values.

PreviousTypescript SDKNextWhat is a strategy?

Last updated 3 days ago