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.
Methods
DP
function DP() external view returns (int256)
DP is 18 decimal points used for integer calculations
Returns
_0
int256
undefined
RCOMP_MAX
function RCOMP_MAX() external view returns (uint256)
maximum value of compound interest the model will return
Returns
_0
uint256
undefined
X_MAX
function X_MAX() external view returns (int256)
maximum value of X for which, RCOMP_MAX should be returned
Returns
_0
int256
undefined
acceptOwnership
function acceptOwnership() external nonpayable
Transfers ownership of the contract to a pending owner Can only be called by the pending owner.
calculateCompoundInterestRate
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
Parameters
_c
IInterestRateModel.Config
configuration object, InterestRateModel.Config
_u
int256
asset untilization
_interestRateTimestamp
uint256
timestamp of last interest rate update
_blockTimestamp
uint256
current block timestamp
Returns
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
calculateCurrentInterestRate
function calculateCurrentInterestRate(IInterestRateModel.Config _c, int256 _u, uint256 _interestRateTimestamp, uint256 _blockTimestamp) external pure returns (uint256 rcur)
pure function that calculates current annual interest rate
Parameters
_c
IInterestRateModel.Config
configuration object, InterestRateModel.Config
_u
int256
asset untilization
_interestRateTimestamp
uint256
timestamp of last interest rate update
_blockTimestamp
uint256
current block timestamp
Returns
rcur
uint256
current annual interest rate
config
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)
Parameters
_0
address
undefined
_1
address
undefined
Returns
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
getCompoundInterestRate
function getCompoundInterestRate(address _silo, address _asset, uint256 _blockTimestamp) external view returns (uint256 rcomp)
get compound interest rate
Parameters
_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
Returns
rcomp
uint256
compounded interest rate from last update until now
getCompoundInterestRateAndUpdate
function getCompoundInterestRateAndUpdate(address _asset, uint256 _blockTimestamp) external nonpayable returns (uint256 rcomp)
get compound interest rate and update model storage
Parameters
_asset
address
address of an asset in Silo for which interest rate should be calculated
_blockTimestamp
uint256
current block timestamp
Returns
rcomp
uint256
compounded interest rate from last update until now
getConfig
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.
Parameters
_silo
address
Silo address for which config should be set
_asset
address
asset address for which config should be set
Returns
_0
IInterestRateModel.Config
Config sturct for asset in Silo
getCurrentInterestRate
function getCurrentInterestRate(address _silo, address _asset, uint256 _blockTimestamp) external view returns (uint256 rcur)
get current annual interest rate
Parameters
_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
Returns
rcur
uint256
current annual interest rate
interestRateModelPing
function interestRateModelPing() external pure returns (bool)
just a helper method to see if address is a InterestRateModel
Returns
_0
bool
always true
owner
function owner() external view returns (address)
Returns the address of the current owner.
Returns
_0
address
undefined
pendingOwner
function pendingOwner() external view returns (address)
Returns the address of the pending owner.
Returns
_0
address
undefined
renounceOwnership
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.
setConfig
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.
Parameters
_silo
address
Silo address for which config should be set
_asset
address
asset address for which config should be set
_config
IInterestRateModel.Config
undefined
transferOwnership
function transferOwnership(address newOwner) external nonpayable
Transfers ownership of the contract to a new account (newOwner
). Can only be called by the current owner.
Parameters
newOwner
address
undefined
transferPendingOwnership
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.
Parameters
newPendingOwner
address
undefined
Events
ConfigUpdate
event ConfigUpdate(address indexed silo, address indexed asset, IInterestRateModel.Config config)
Emitted on config change
Parameters
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
OwnershipPending
event OwnershipPending(address indexed previousOwner, address indexed newOwner)
Emitted when ownership transfer is proposed, aka pending owner is set
Parameters
previousOwner indexed
address
undefined
newOwner indexed
address
undefined
OwnershipTransferred
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner)
Emitted when ownership is transferred on transferOwnership
and acceptOwnership
Parameters
previousOwner indexed
address
undefined
newOwner indexed
address
undefined
Last updated