Vee.Finance | V1
  • Introduction of Vee.Finance
  • Contact
  • FAQ
  • basic concept
    • Glossary
    • Contracts
    • Protocol Parameters
    • Borrowing
    • Leverage Trade
    • Liquidations
  • Guides
    • User Manuals
    • Claim $VEE
    • Farm
    • Compensation
    • Wallet Setup
    • Testing Vee
    • Support Networks
  • GOVERNANCE
    • Tokenomics
    • Whitepaper
  • Security & Audits
  • Medium
    • Latest Update&Compensation Plan (Sept. 25)
    • Farm Airdrop
    • Weekly Report
    • Beta launch
    • Airdrop is Coming
    • MetaMask
  • Risks
  • Bridge
    • Browser Wallet
Powered by GitBook
On this page
  • Introduction
  • Calculating Accrued Interest
  • Calculating the APY Using Rate Per Block

Was this helpful?

  1. basic concept

Borrowing

Introduction

Vee.Finance protocol offers interest-free loans and is more capital efficient than other borrowing systems (i.e. less collateral is needed for the same loan). Instead of selling crypto assets to have liquid funds, you can use the protocol to lock up your crypto assets, borrow against the collateral, and then repay your loan at a future date.

Calculating Accrued Interest

Interest rates for each market update on any block in which the ratio of borrowed assets to supplied assets in the market has changed. The amount interest rates are changed depends on the interest rate model smart contract implemented for the market, and the amount of change in the ratio of borrowed assets to supplied assets in the market.

Interest accrues to all suppliers and borrowers in a market when any Avalance address interacts with the market’s veToken contract, calling one of these functions: mint, redeem, borrow, or repay. Successful execution of one of these functions triggers the accrueInterest method, which causes interest to be added to the underlying balance of every supplier and borrower in the market. Interest accrues for the current block, as well as each prior block in which the accrueInterest method was not triggered (no user interacted with the veToken contract). Interest Vee.Finance only during blocks in which the veToken contract has one of the aforementioned methods invoked.

Calculating the APY Using Rate Per Block

The Annual Percentage Yield (APY) for supplying or borrowing in each market can be calculated using the value of supplyRatePerBlock (for supply APY) or borrowRatePerBlock (for borrow APY) in this formula:

Rate = veToken.supplyRatePerBlock(); // Integer
Rate = 37893566
AVAX Mantissa = 1 * 10 ^ 18 (AVAX has 18 decimal places) 
Blocks Per Day = 6570 (13.15 seconds per block)
Days Per Year = 365

APY = ((((Rate / AVAX Mantissa  Blocks Per Day + 1) ^ Days Per Year - 1)) - 1) * 100

Here is an example of calculating the supply and borrow APY with Web3.js JavaScript:

const ethMantissa = 1e18; 
const blocksPerDay = 6570; // 13.15 seconds per block
const daysPerYear = 365;

const veToken = new web3.eth.Contract(veAvaxAbi, veAvaxAddress); 
const supplyRatePerBlock = await veToken.methods.supplyRatePerBlock().call(); 
const borrowRatePerBlock = await veToken.methods.borrowRatePerBlock().call();
const supplyApy = (((Math.pow((supplyRatePerBlock / ethMantissa  blocksPerDay) + 1, daysPerYear))) - 1)  100; 
const borrowApy = (((Math.pow((borrowRatePerBlock / ethMantissa  blocksPerDay) + 1, daysPerYear))) - 1)  100; 
console.log(Supply APY for AVAX ${supplyApy} %);
 console.log(Borrow APY for AVAX ${borrowApy} %);

PreviousProtocol ParametersNextLeverage Trade

Last updated 3 years ago

Was this helpful?