3ī¸Calculator

This module contains the core calculation functions used in the lending and borrowing process in NAVI.

This section contains functions for calculating utilization, borrow rates,supply rates, and interest, as well as for converting between asset amounts and values using oracle price data.

This module is essential for performing calculations such as determining the current state of a lending pool, applying interest to loans or deposits, and converting between different tokens based on their price.

calculate_utilization

Description: This function calculates the utilization ratio of an asset in a lending pool. The utilization ratio is the ratio of total borrowed assets to the total available assets.

Use Cases: This function is used when determining the demand for an asset in the lending pool, which can influence the interest rates applied to borrowing and lending transactions.

public fun caculate_utilization(
    storage: &mut Storage, 
    asset: u8
): u256 {}

calculate_borrow_rate

Description: This function calculates the borrowing interest rate for an asset based on its utilization ratio.

Use Cases: This function is used when a user wishes to borrow an asset from the lending pool. The interest rate calculated will be applied to the loan.

public fun calculate_borrow_rate(
    storage: &mut Storage, 
    asset: u8
): u256 {}

calculate_supply_rate

Description: This function calculates the supply (or deposit) interest rate for an asset based on its borrowing rate and utilization ratio.

Use Cases: This function is used when a user deposits an asset into the lending pool. The interest rate calculated will be the rate at which their deposit accrues interest.

public fun calculate_supply_rate(
    storage: &mut Storage, 
    asset: u8, 
    borrow_rate: u256
): u256 {}

calculate_compounded_interest

Description: This function calculates the compounded interest over a period of time based on a given rate.

Use Cases: This function can be used when calculating the interest accrued on a deposit or loan over a period of time.

public fun calculate_compounded_interest(
    timestamp_difference: u256, 
    rate: u256
): u256 {}

calculate_linear_interest

Description: This function calculates the linear interest over a period of time based on a given rate.

Use Cases: This function can be used when calculating the interest accrued on a deposit or loan over a period of time.

public fun calculate_linear_interest(
    timestamp_difference: u256, 
    rate: u256
): u256 {}

calculate_value

Description: This function converts an amount of an asset to its value in a base currency using the price data from a price oracle.

Use Cases: This function can be used when displaying the value of an asset to a user, or when performing calculations that require the value of an asset in the base currency.

public fun calculate_value(
    clock: &Clock, 
    oracle: &PriceOracle, 
    amount: u256, 
    oracle_id: u8
): u256 {}

calculate_amount

Description: This function converts a value in a base currency to an amount of an asset using the price data from a price oracle.

public fun calculate_amount(
    clock: &Clock, 
    oracle: &PriceOracle, 
    value: u256, 
    oracle_id: u8
): u256 {}

Last updated