Earn Interest Rate Model (AlkemiRateModel.sol)
↗ Extends: Exponential
See Model here
Enums

IRError

1
enum IRError {
2
NO_ERROR,
3
FAILED_TO_ADD_CASH_PLUS_BORROWS,
4
FAILED_TO_GET_EXP,
5
FAILED_TO_MUL_PRODUCT_TIMES_BORROW_RATE
6
}
Copied!

Contract Members

Constants & Variables
1
//public members
2
uint256 public blocksPerYear;
3
address public owner;
4
address public newOwner;
5
string public contractName;
6
7
//private members
8
uint8 private hundred;
9
10
//internal members
11
struct Exponential.Exp internal SpreadLow;
12
struct Exponential.Exp internal BreakPointLow;
13
struct Exponential.Exp internal ReserveLow;
14
struct Exponential.Exp internal ReserveMid;
15
struct Exponential.Exp internal SpreadMid;
16
struct Exponential.Exp internal BreakPointHigh;
17
struct Exponential.Exp internal ReserveHigh;
18
struct Exponential.Exp internal SpreadHigh;
19
struct Exponential.Exp internal MinRateActual;
20
struct Exponential.Exp internal HealthyMinURActual;
21
struct Exponential.Exp internal HealthyMinRateActual;
22
struct Exponential.Exp internal MaxRateActual;
23
struct Exponential.Exp internal HealthyMaxURActual;
24
struct Exponential.Exp internal HealthyMaxRateActual;
Copied!
Events
1
event OwnerUpdate(address indexed owner, address indexed newOwner);
2
event blocksPerYearUpdated(uint256 oldBlocksPerYear, uint256 newBlocksPerYear);
Copied!

Modifiers

  • onlyOwner

onlyOwner

1
modifier onlyOwner() internal
Copied!
Arguments
Name
Type
Description

Functions

  • changeRates(string _contractName, uint256 MinRate, uint256 HealthyMinUR, uint256 HealthyMinRate, uint256 HealthyMaxUR, uint256 HealthyMaxRate, uint256 MaxRate)
  • changeBlocksPerYear(uint256 _blocksPerYear)
  • transferOwnership(address newOwner_)
  • acceptOwnership()
  • getUtilizationRate(uint256 cash, uint256 borrows)
  • getUtilizationAndAnnualBorrowRate(uint256 cash, uint256 borrows)
  • getSupplyRate(address _asset, uint256 cash, uint256 borrows)
  • getBorrowRate(address asset, uint256 cash, uint256 borrows)

changeRates

1
function changeRates(string _contractName, uint256 MinRate, uint256 HealthyMinUR, uint256 HealthyMinRate, uint256 HealthyMaxUR, uint256 HealthyMaxRate, uint256 MaxRate) public nonpayable onlyOwner
Copied!
Arguments
Name
Type
Description
_contractName
string
MinRate
uint256
HealthyMinUR
uint256
HealthyMinRate
uint256
HealthyMaxUR
uint256
HealthyMaxRate
uint256
MaxRate
uint256

changeBlocksPerYear

1
function changeBlocksPerYear(uint256 _blocksPerYear) external nonpayable onlyOwner
Copied!
Arguments
Name
Type
Description
_blocksPerYear
uint256

transferOwnership

1
function transferOwnership(address newOwner_) external nonpayable onlyOwner
Copied!
Arguments
Name
Type
Description
newOwner_
address

acceptOwnership

1
function acceptOwnership() external nonpayable
Copied!
Arguments
Name
Type
Description

getUtilizationRate

1
function getUtilizationRate(uint256 cash, uint256 borrows) internal view
2
returns(enum AlkemiRateModel.IRError, struct Exponential.Exp)
Copied!
Arguments
Name
Type
Description
cash
uint256
borrows
uint256

getUtilizationAndAnnualBorrowRate

1
function getUtilizationAndAnnualBorrowRate(uint256 cash, uint256 borrows) internal view
2
returns(enum AlkemiRateModel.IRError, struct Exponential.Exp, struct Exponential.Exp)
Copied!
Arguments
Name
Type
Description
cash
uint256
borrows
uint256

getSupplyRate

Gets the current supply interest rate based on the given asset, total cash and total borrows
1
function getSupplyRate(address _asset, uint256 cash, uint256 borrows) public view
2
returns(uint256, uint256)
Copied!
Returns
Success or failure and the supply interest rate per block scaled by 1e18
Arguments
Name
Type
Description
_asset
address
The asset to get the interest rate of
cash
uint256
The total cash of the asset in the market
borrows
uint256
The total borrows of the asset in the market

getBorrowRate

Gets the current borrow interest rate based on the given asset, total cash and total borrows
1
function getBorrowRate(address asset, uint256 cash, uint256 borrows) public view
2
returns(uint256, uint256)
Copied!
Returns
Success or failure and the borrow interest rate per block scaled by 1e18
Arguments
Name
Type
Description
asset
address
The asset to get the interest rate of
cash
uint256
The total cash of the asset in the market
borrows
uint256
The total borrows of the asset in the market