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

Name
Type
Description

_0

int256

undefined

RCOMP_MAX

function RCOMP_MAX() external view returns (uint256)

maximum value of compound interest the model will return

Returns

Name
Type
Description

_0

uint256

undefined

X_MAX

maximum value of X for which, RCOMP_MAX should be returned

Returns

Name
Type
Description

_0

int256

undefined

acceptOwnership

Transfers ownership of the contract to a pending owner Can only be called by the pending owner.

calculateCompoundInterestRate

pure function that calculates interest rate based on raw input data

Parameters

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

Returns

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

calculateCurrentInterestRate

pure function that calculates current annual interest rate

Parameters

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

Returns

Name
Type
Description

rcur

uint256

current annual interest rate

config

Parameters

Name
Type
Description

_0

address

undefined

_1

address

undefined

Returns

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

getCompoundInterestRate

get compound interest rate

Parameters

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

Returns

Name
Type
Description

rcomp

uint256

compounded interest rate from last update until now

getCompoundInterestRateAndUpdate

get compound interest rate and update model storage

Parameters

Name
Type
Description

_asset

address

address of an asset in Silo for which interest rate should be calculated

_blockTimestamp

uint256

current block timestamp

Returns

Name
Type
Description

rcomp

uint256

compounded interest rate from last update until now

getConfig

Get config for giver asset in a Silo. If dedicated config is not set, default one will be returned.

Parameters

Name
Type
Description

_silo

address

Silo address for which config should be set

_asset

address

asset address for which config should be set

Returns

Name
Type
Description

_0

IInterestRateModel.Config

Config sturct for asset in Silo

getCurrentInterestRate

get current annual interest rate

Parameters

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

Returns

Name
Type
Description

rcur

uint256

current annual interest rate

interestRateModelPing

just a helper method to see if address is a InterestRateModel

Returns

Name
Type
Description

_0

bool

always true

owner

Returns the address of the current owner.

Returns

Name
Type
Description

_0

address

undefined

pendingOwner

Returns the address of the pending owner.

Returns

Name
Type
Description

_0

address

undefined

renounceOwnership

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

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

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

transferOwnership

Transfers ownership of the contract to a new account (newOwner). Can only be called by the current owner.

Parameters

Name
Type
Description

newOwner

address

undefined

transferPendingOwnership

Transfers pending ownership of the contract to a new account (newPendingOwner). Can only be called by the current owner.

Parameters

Name
Type
Description

newPendingOwner

address

undefined

Events

ConfigUpdate

Emitted on config change

Parameters

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

OwnershipPending

Emitted when ownership transfer is proposed, aka pending owner is set

Parameters

Name
Type
Description

previousOwner indexed

address

undefined

newOwner indexed

address

undefined

OwnershipTransferred

Emitted when ownership is transferred on transferOwnership and acceptOwnership

Parameters

Name
Type
Description

previousOwner indexed

address

undefined

newOwner indexed

address

undefined

Last updated