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:
Here is an example of calculating the supply and borrow APY with Web3.js JavaScript:
Last updated
Was this helpful?