Gloop
WebsiteTwitterDiscord
  • gLoop Litepaper v2
    • Introduction
    • The Two Tokens
    • Roadmap
  • PRODUCTS
    • GM Index
      • Providing/Removing Liquidity
      • Fees and Reflection
      • Deposit/Withdrawal Examples
    • GM Lending/Looping (Coming Soon)
    • GLOOP Staking (Coming Soon)
  • GM Points (COMING SOON)
  • FREQUENTLY ASKED QUESTIONS (FAQs)
    • GM Index (GMI)
  • Technical
    • Gloop Protocol Parameters
    • Contracts
      • GMI
        • GM Index
        • GMI USDC Zap
        • Token Banks
        • Token Oracles
        • Fees
    • Audits
  • GLoop Ecosystem
    • Tokenomics
  • Security and Risk
    • Risks
  • Social
    • Socials
Powered by GitBook
On this page
  • getBorrowRate
  • getSupplyRate
  • utilizationRate
  1. Technical
  2. Contracts
  3. GM Lending and Looping

GM Interest Rate Model

Last updated 11 months ago

Each GM token has an associated Interest Rate Model contract, which informs the percent interest attributed to the lending and borrowing of the token. It establishes four key variables, which differ between assets:

  • vertexUtilization

  • minRate

  • vertexRate

  • maxRate

The gLoop interest rate models follow a typical DeFi interest rate chart/curve (see image below), where utilization directly determines rates. Lenders of a GM asset earn interest, denominated in the base asset, based on a supply rate model. Borrowers of a GM asset pay interest in USDC, based on a borrow rate model. The models include a utilization rate “kink” -- above this point, the interest rate increases more rapidly. Interest accrues every block by using the block.number Ethereum Virtual Machine primitive.

The functions:

getBorrowRate

function getBorrowRate(uint256 cash, uint256 borrows, uint256 reserves) public view returns (uint256)

Calculates and returns the current borrow interest rate per block:

uint256 utilization = utilizationRate(cash, borrows, reserves);
        if (utilization == vertexUtilization) {
            return vertexRate;
        } else if (utilization < vertexUtilization) {
            return
                minRate + ((utilization * (vertexRate - minRate)) / 1e18)) / (vertexUtilization);
        } else {
            return
                vertexRate +
                (((utilization - vertexUtilization) * ((maxRate - vertexRate)) / 1e18) / ( 1e18 - vertexUtilization);
        }

Parameters:

Name
Type
Description

cash

uint256

The total amount of asset in cash (?)

borrows

uint256

The total amount of asset borrows

reserves

uint256

The total amount of asset reserves

Returns:

Name
Type
Description

unnamed

uint256

The borrow rate per block, as a percentage and scaled by 1e18

getSupplyRate

function getSupplyRate(uint256 cash, uint256 borrows, uint256 reserves, uint256 reserveFactorMantissa) public view returns (uint256)

Calculates and returns the current supply interest rate per block:

uint256 oneMinusReserveFactor = 1e18 - reserveFactorMantissa;
uint256 borrowRate = getBorrowRate(cash, borrows, reserves);
uint256 rateToPool = (borrowRate * oneMinusReserveFactor) / 1e18;
return utilizationRate(cash, borrows, (reserves * rateToPool) / 1e18);

Parameters:

Name
Type
Description

cash

uint256

The total amount of asset in cash (?)

borrows

uint256

The total amount of asset borrows

reserves

uint256

The total amount of asset reserves

Returns:

Name
Type
Description

unnamed

uint256

The supply rate per block (as a percentage, and scaled by 1e18)

utilizationRate

function utilizationRate(uint256 cash, uint256 borrows, uint256 reserves) public view returns (uint256)

Calculates and returns the current asset utilization rate:

utilizationRate = borrows / (cash - reserves)

Parameters:

Name
Type
Description

cash

uint256

The total amount of the asset in cash (?)

borrows

uint256

The total amount of outstanding borrows for the asset

reserves

uint256

The total amount of reserves of the asset

Returns:

Name
Type
Description

unnamed

uint256

The current utilization rate of the asset

Image by via
Guantlet
Medium