Minting Calculations

Vesto's derivative minting process relies on precise mathematical calculations to ensure each derivative token is properly backed by the appropriate collateral assets. This document outlines the key formulas used in the minting process and provides concrete examples to illustrate how these calculations work in practice.

Key Formulas

Nominal Units Calculation

When a derivative pool is initialized, nominal units are calculated for each collateral asset. These represent the base quantity of each token required to mint one unit of the derivative token.

For each asset i:

CNi=Wi×BaseValuePricei×10TokenDecimalsi1018CN_i = \frac{W_i \times BaseValue}{Price_i} \times \frac{10^{TokenDecimals_i}}{10^{18}}

Where:

  • CNiCN_i = Nominal units for asset i
  • WiW_i = Normalized weight for asset i (in 1e18 precision)
  • BaseValueBaseValue = Base value of the derivative (typically 1e18 for $1)
  • PriceiPrice_i = Current price of asset i in USD (in 1e18 precision)
  • TokenDecimalsiTokenDecimals_i = Decimal places for asset i

Required Amounts for Multi-Asset Entry

When minting derivative tokens with multiple assets, the required amount of each collateral token is calculated as:

RequiredAmounti=DerivativeAmount×NominalUniti1018RequiredAmount_i = \frac{DerivativeAmount \times NominalUnit_i}{10^{18}}

Where:

  • RequiredAmountiRequiredAmount_i = Required amount of collateral token i
  • DerivativeAmountDerivativeAmount = Amount of derivative tokens to mint
  • NominalUnitiNominalUnit_i = Nominal unit for asset i

vBasket Value Calculation

The vBasket represents the total value of the derivative basket and is calculated as:

vBasket=i=1nNominalUniti×Pricei10TokenDecimalsi×1018vBasket = \sum_{i=1}^{n} \frac{NominalUnit_i \times Price_i}{10^{TokenDecimals_i}} \times 10^{18}

Where:

  • vBasketvBasket = Total value of the derivative basket in USD (in 1e18 precision)
  • nn = Number of collateral assets in the basket

Single-Asset Entry Calculation

For single-asset entry, the derivative amount that can be minted is:

DerivativeAmount=InputValueUSD×1018vBasketDerivativeAmount = \frac{InputValueUSD \times 10^{18}}{vBasket}

Where:

  • InputValueUSDInputValueUSD = Value of input token in USD (in 1e18 precision)
  • InputValueUSD=InputAmount×InputTokenPrice10InputTokenDecimalsInputValueUSD = \frac{InputAmount \times InputTokenPrice}{10^{InputTokenDecimals}}

Practical Examples

Example 1: Nominal Units Calculation

Consider a derivative pool with two assets: WETH and USDC.

  • WETH weight: 0.6 × 10¹⁸ (60%)
  • USDC weight: 0.4 × 10¹⁸ (40%)
  • Base value: 1 × 10¹⁸ ($1)
  • WETH price: 3,000 × 10¹⁸ ($3,000)
  • USDC price: 1 × 10¹⁸ ($1)
  • WETH decimals: 18
  • USDC decimals: 6

Nominal units for WETH:

CNWETH=0.6×1018×1×10183,000×1018×10181018=0.0002×1018CN_{WETH} = \frac{0.6 \times 10^{18} \times 1 \times 10^{18}}{3,000 \times 10^{18}} \times \frac{10^{18}}{10^{18}} = 0.0002 \times 10^{18}

Nominal units for USDC:

CNUSDC=0.4×1018×1×10181×1018×1061018=0.4×106CN_{USDC} = \frac{0.4 \times 10^{18} \times 1 \times 10^{18}}{1 \times 10^{18}} \times \frac{10^{6}}{10^{18}} = 0.4 \times 10^{6}

Example 2: Required Amounts for Multi-Asset Entry

Building on Example 1, if a user wants to mint 100 derivative tokens:

Required WETH:

RequiredAmountWETH=100×0.0002×10181018=0.02 WETHRequiredAmount_{WETH} = \frac{100 \times 0.0002 \times 10^{18}}{10^{18}} = 0.02 \text{ WETH}

Required USDC:

RequiredAmountUSDC=100×0.4×1061018=40 USDCRequiredAmount_{USDC} = \frac{100 \times 0.4 \times 10^{6}}{10^{18}} = 40 \text{ USDC}

Example 3: vBasket Value Calculation

With the same parameters as Example 1:

WETH contribution:

ValueWETH=0.0002×1018×3,000×10181018×1018=0.6×1018Value_{WETH} = \frac{0.0002 \times 10^{18} \times 3,000 \times 10^{18}}{10^{18}} \times 10^{18} = 0.6 \times 10^{18}

USDC contribution:

ValueUSDC=0.4×106×1×1018106×1018=0.4×1018Value_{USDC} = \frac{0.4 \times 10^{6} \times 1 \times 10^{18}}{10^{6}} \times 10^{18} = 0.4 \times 10^{18}

vBasket value:

vBasket=0.6×1018+0.4×1018=1×1018vBasket = 0.6 \times 10^{18} + 0.4 \times 10^{18} = 1 \times 10^{18}

Example 4: Single-Asset Entry Calculation

If a user wants to enter the same pool using only WETH:

  • Input amount: 0.05 WETH
  • WETH price: 3,000 × 10¹⁸ ($3,000)
  • vBasket value: 1 × 10¹⁸ ($1)

Input value in USD:

InputValueUSD=0.05×1018×3,000×10181018=150×1018InputValueUSD = \frac{0.05 \times 10^{18} \times 3,000 \times 10^{18}}{10^{18}} = 150 \times 10^{18}

Derivative amount:

DerivativeAmount=150×1018×10181×1018=150 derivative tokensDerivativeAmount = \frac{150 \times 10^{18} \times 10^{18}}{1 \times 10^{18}} = 150 \text{ derivative tokens}

This means providing 0.05 WETH would allow the user to mint 150 derivative tokens. Behind the scenes, the protocol would convert part of the WETH to obtain the necessary USDC to maintain the proper collateral ratio.

Implementation in Smart Contracts

In the Vesto contracts, these calculations are implemented in several key functions:

  1. The _initialize function in the VestoPool contract calculates the nominal units during pool creation
  2. The issue function calculates required amounts for multi-asset entry
  3. The calculateDerivativeAmountViaInputToken function handles the single-asset entry calculations
  4. The calculateVestoPoolValue function computes the current vBasket value

These calculations ensure that derivative tokens maintain their proper backing regardless of market price fluctuations, providing users with a reliable and transparent mechanism for creating and redeeming synthetic assets on the Vesto protocol.