InterestRateModel
InterestRateModel
Dynamic interest rate model implementation
Model stores some Silo specific data. If model is replaced, it needs to set proper config after redeployment for seamless service. Please refer to separte litepaper about model for design details.
function DP() external view returns (int256)
DP is 18 decimal points used for integer calculations
Name | Type | Description |
---|---|---|
_0 | int256 | undefined |
function RCOMP_MAX() external view returns (uint256)
maximum value of compound interest the model will return
Name | Type | Description |
---|---|---|
_0 | uint256 | undefined |
function X_MAX() external view returns (int256)
maximum value of X for which, RCOMP_MAX should be returned
Name | Type | Description |
---|---|---|
_0 | int256 | undefined |
function acceptOwnership() external nonpayable
Transfers ownership of the contract to a pending owner Can only be called by the pending owner.
function calculateCompoundInterestRate(IInterestRateModel.Config _c, int256 _u, uint256 _interestRateTimestamp, uint256 _blockTimestamp) external pure returns (uint256 rcomp, int256 ri, int256 Tcrit)
pure function that calculates interest rate based on raw input data
Name | Type | Description |
---|---|---|
_c | IInterestRateModel.Config | configuration object, InterestRateModel.Config |
_u | int256 | asset untilization |
_interestRateTimestamp | uint256 | timestamp of last interest rate update |
_blockTimestamp | uint256 | current block timestamp |
Name | Type | Description |
---|---|---|
rcomp | uint256 | compounded interest rate from last update until now |
ri | int256 | current integral part of the rate |
Tcrit | int256 | time during which the utilization exceeds the critical value |
function calculateCurrentInterestRate(IInterestRateModel.Config _c, int256 _u, uint256 _interestRateTimestamp, uint256 _blockTimestamp) external pure returns (uint256 rcur)
pure function that calculates current annual interest rate
Name | Type | Description |
---|---|---|
_c | IInterestRateModel.Config | configuration object, InterestRateModel.Config |
_u | int256 | asset untilization |
_interestRateTimestamp | uint256 | timestamp of last interest rate update |
_blockTimestamp | uint256 | current block timestamp |
Name | Type | Description |
---|---|---|
rcur | uint256 | current annual interest rate |
function config(address, address) external view returns (int256 uopt, int256 ucrit, int256 ulow, int256 ki, int256 kcrit, int256 klow, int256 klin, int256 beta, int256 ri, int256 Tcrit)
Name | Type | Description |
---|---|---|
_0 | address | undefined |
_1 | address | undefined |
Name | Type | Description |
---|---|---|
uopt | int256 | undefined |
ucrit | int256 | undefined |
ulow | int256 | undefined |
ki | int256 | undefined |
kcrit | int256 | undefined |
klow | int256 | undefined |
klin | int256 | undefined |
beta | int256 | undefined |
ri | int256 | undefined |
Tcrit | int256 | undefined |
function getCompoundInterestRate(address _silo, address _asset, uint256 _blockTimestamp) external view returns (uint256 rcomp)
get compound interest rate
Name | Type | Description |
---|---|---|
_silo | address | address of Silo |
_asset | address | address of an asset in Silo for which interest rate should be calculated |
_blockTimestamp | uint256 | current block timestamp |
Name | Type | Description |
---|---|---|
rcomp | uint256 | compounded interest rate from last update until now |
function getCompoundInterestRateAndUpdate(address _asset, uint256 _blockTimestamp) external nonpayable returns (uint256 rcomp)
get compound interest rate and update model storage
Name | Type | Description |
---|---|---|
_asset | address | address of an asset in Silo for which interest rate should be calculated |
_blockTimestamp | uint256 | current block timestamp |
Name | Type | Description |
---|---|---|
rcomp | uint256 | compounded interest rate from last update until now |
function getConfig(address _silo, address _asset) external view returns (struct IInterestRateModel.Config)
Get config for giver asset in a Silo. If dedicated config is not set, default one will be returned.
Name | Type | Description |
---|---|---|
_silo | address | Silo address for which config should be set |
_asset | address | asset address for which config should be set |
Name | Type | Description |
---|---|---|
_0 | IInterestRateModel.Config | Config sturct for asset in Silo |
function getCurrentInterestRate(address _silo, address _asset, uint256 _blockTimestamp) external view returns (uint256 rcur)
get current annual interest rate
Name | Type | Description |
---|---|---|
_silo | address | address of Silo |
_asset | address | address of an asset in Silo for which interest rate should be calculated |
_blockTimestamp | uint256 | current block timestamp |
Name | Type | Description |
---|---|---|
rcur | uint256 | current annual interest rate |
function interestRateModelPing() external pure returns (bool)
just a helper method to see if address is a InterestRateModel
Name | Type | Description |
---|---|---|
_0 | bool | always true |
function owner() external view returns (address)
Returns the address of the current owner.
Name | Type | Description |
---|---|---|
_0 | address | undefined |
function pendingOwner() external view returns (address)
Returns the address of the pending owner.
Name | Type | Description |
---|---|---|
_0 | address | undefined |
function renounceOwnership() external nonpayable
Leaves the contract without owner. It will not be possible to call
onlyOwner
functions anymore. Can only be called by the current owner. NOTE: Renouncing ownership will leave the contract without an owner, thereby removing any functionality that is only available to the owner.function setConfig(address _silo, address _asset, IInterestRateModel.Config _config) external nonpayable
Set dedicated config for giver asset in a Silo. Config is per asset per Silo so different assets in different Silo can have different configs.
Name | Type | Description |
---|---|---|
_silo | address | Silo address for which config should be set |
_asset | address | asset address for which config should be set |
_config | IInterestRateModel.Config | undefined |
function transferOwnership(address newOwner) external nonpayable
Transfers ownership of the contract to a new account (
newOwner
). Can only be called by the current owner.Name | Type | Description |
---|---|---|
newOwner | address | undefined |
function transferPendingOwnership(address newPendingOwner) external nonpayable
Transfers pending ownership of the contract to a new account (
newPendingOwner
). Can only be called by the current owner.Name | Type | Description |
---|---|---|
newPendingOwner | address | undefined |
event ConfigUpdate(address indexed silo, address indexed asset, IInterestRateModel.Config config)
Emitted on config change
Name | Type | Description |
---|---|---|
silo indexed | address | Silo address for which config should be set |
asset indexed | address | asset address for which config should be set |
config | IInterestRateModel.Config | config sturct for asset in Silo |
event OwnershipPending(address indexed previousOwner, address indexed newOwner)
Emitted when ownership transfer is proposed, aka pending owner is set
Name | Type | Description |
---|---|---|
previousOwner indexed | address | undefined |
newOwner indexed | address | undefined |
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner)
Emitted when ownership is transferred on
transferOwnership
and acceptOwnership
Name | Type | Description |
---|---|---|
previousOwner indexed | address | undefined |
newOwner indexed | address | undefined |
Last modified 1yr ago