ReserveConfiguration

Git Source

Author: Aave

Implements the bitmap logic to handle the reserve configuration

State Variables

LTV_MASK

uint256 constant LTV_MASK = 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF0000;

LIQUIDATION_THRESHOLD_MASK

uint256 constant LIQUIDATION_THRESHOLD_MASK = 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF0000FFFF;

LIQUIDATION_BONUS_MASK

uint256 constant LIQUIDATION_BONUS_MASK = 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF0000FFFFFFFF;

DECIMALS_MASK

uint256 constant DECIMALS_MASK = 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF00FFFFFFFFFFFF;

ACTIVE_MASK

uint256 constant ACTIVE_MASK = 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFFFFFFFFFF;

FROZEN_MASK

uint256 constant FROZEN_MASK = 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFDFFFFFFFFFFFFFF;

BORROWING_MASK

uint256 constant BORROWING_MASK = 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFBFFFFFFFFFFFFFF;

STABLE_BORROWING_MASK

uint256 constant STABLE_BORROWING_MASK = 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF7FFFFFFFFFFFFFF;

RESERVE_FACTOR_MASK

uint256 constant RESERVE_FACTOR_MASK = 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF0000FFFFFFFFFFFFFFFF;

LIQUIDATION_THRESHOLD_START_BIT_POSITION

For the LTV, the start bit is 0 (up to 15), hence no bitshifting is needed

uint256 constant LIQUIDATION_THRESHOLD_START_BIT_POSITION = 16;

LIQUIDATION_BONUS_START_BIT_POSITION

uint256 constant LIQUIDATION_BONUS_START_BIT_POSITION = 32;

RESERVE_DECIMALS_START_BIT_POSITION

uint256 constant RESERVE_DECIMALS_START_BIT_POSITION = 48;

IS_ACTIVE_START_BIT_POSITION

uint256 constant IS_ACTIVE_START_BIT_POSITION = 56;

IS_FROZEN_START_BIT_POSITION

uint256 constant IS_FROZEN_START_BIT_POSITION = 57;

BORROWING_ENABLED_START_BIT_POSITION

uint256 constant BORROWING_ENABLED_START_BIT_POSITION = 58;

STABLE_BORROWING_ENABLED_START_BIT_POSITION

uint256 constant STABLE_BORROWING_ENABLED_START_BIT_POSITION = 59;

RESERVE_FACTOR_START_BIT_POSITION

uint256 constant RESERVE_FACTOR_START_BIT_POSITION = 64;

MAX_VALID_LTV

uint256 constant MAX_VALID_LTV = 65535;

MAX_VALID_LIQUIDATION_THRESHOLD

uint256 constant MAX_VALID_LIQUIDATION_THRESHOLD = 65535;

MAX_VALID_LIQUIDATION_BONUS

uint256 constant MAX_VALID_LIQUIDATION_BONUS = 65535;

MAX_VALID_DECIMALS

uint256 constant MAX_VALID_DECIMALS = 255;

MAX_VALID_RESERVE_FACTOR

uint256 constant MAX_VALID_RESERVE_FACTOR = 65535;

Functions

setLtv

Sets the Loan to Value of the reserve

function setLtv(DataTypes.ReserveConfigurationMap memory self, uint256 ltv) internal pure;

Parameters

NameTypeDescription
selfDataTypes.ReserveConfigurationMapThe reserve configuration
ltvuint256the new ltv

getLtv

Gets the Loan to Value of the reserve

function getLtv(DataTypes.ReserveConfigurationMap storage self) internal view returns (uint256);

Parameters

NameTypeDescription
selfDataTypes.ReserveConfigurationMapThe reserve configuration

Returns

NameTypeDescription
<none>uint256The loan to value

setLiquidationThreshold

Sets the liquidation threshold of the reserve

function setLiquidationThreshold(DataTypes.ReserveConfigurationMap memory self, uint256 threshold) internal pure;

Parameters

NameTypeDescription
selfDataTypes.ReserveConfigurationMapThe reserve configuration
thresholduint256The new liquidation threshold

getLiquidationThreshold

Gets the liquidation threshold of the reserve

function getLiquidationThreshold(DataTypes.ReserveConfigurationMap storage self) internal view returns (uint256);

Parameters

NameTypeDescription
selfDataTypes.ReserveConfigurationMapThe reserve configuration

Returns

NameTypeDescription
<none>uint256The liquidation threshold

setLiquidationBonus

Sets the liquidation bonus of the reserve

function setLiquidationBonus(DataTypes.ReserveConfigurationMap memory self, uint256 bonus) internal pure;

Parameters

NameTypeDescription
selfDataTypes.ReserveConfigurationMapThe reserve configuration
bonusuint256The new liquidation bonus

getLiquidationBonus

Gets the liquidation bonus of the reserve

function getLiquidationBonus(DataTypes.ReserveConfigurationMap storage self) internal view returns (uint256);

Parameters

NameTypeDescription
selfDataTypes.ReserveConfigurationMapThe reserve configuration

Returns

NameTypeDescription
<none>uint256The liquidation bonus

setDecimals

Sets the decimals of the underlying asset of the reserve

function setDecimals(DataTypes.ReserveConfigurationMap memory self, uint256 decimals) internal pure;

Parameters

NameTypeDescription
selfDataTypes.ReserveConfigurationMapThe reserve configuration
decimalsuint256The decimals

getDecimals

Gets the decimals of the underlying asset of the reserve

function getDecimals(DataTypes.ReserveConfigurationMap storage self) internal view returns (uint256);

Parameters

NameTypeDescription
selfDataTypes.ReserveConfigurationMapThe reserve configuration

Returns

NameTypeDescription
<none>uint256The decimals of the asset

setActive

Sets the active state of the reserve

function setActive(DataTypes.ReserveConfigurationMap memory self, bool active) internal pure;

Parameters

NameTypeDescription
selfDataTypes.ReserveConfigurationMapThe reserve configuration
activeboolThe active state

getActive

Gets the active state of the reserve

function getActive(DataTypes.ReserveConfigurationMap memory self) internal pure returns (bool);

Parameters

NameTypeDescription
selfDataTypes.ReserveConfigurationMapThe reserve configuration

Returns

NameTypeDescription
<none>boolThe active state

setFrozen

Sets the frozen state of the reserve

function setFrozen(DataTypes.ReserveConfigurationMap memory self, bool frozen) internal pure;

Parameters

NameTypeDescription
selfDataTypes.ReserveConfigurationMapThe reserve configuration
frozenboolThe frozen state

getFrozen

Gets the frozen state of the reserve

function getFrozen(DataTypes.ReserveConfigurationMap storage self) internal view returns (bool);

Parameters

NameTypeDescription
selfDataTypes.ReserveConfigurationMapThe reserve configuration

Returns

NameTypeDescription
<none>boolThe frozen state

setBorrowingEnabled

Enables or disables borrowing on the reserve

function setBorrowingEnabled(DataTypes.ReserveConfigurationMap memory self, bool enabled) internal pure;

Parameters

NameTypeDescription
selfDataTypes.ReserveConfigurationMapThe reserve configuration
enabledboolTrue if the borrowing needs to be enabled, false otherwise

getBorrowingEnabled

Gets the borrowing state of the reserve

function getBorrowingEnabled(DataTypes.ReserveConfigurationMap memory self) internal pure returns (bool);

Parameters

NameTypeDescription
selfDataTypes.ReserveConfigurationMapThe reserve configuration

Returns

NameTypeDescription
<none>boolThe borrowing state

setStableRateBorrowingEnabled

Enables or disables stable rate borrowing on the reserve

function setStableRateBorrowingEnabled(DataTypes.ReserveConfigurationMap memory self, bool enabled) internal pure;

Parameters

NameTypeDescription
selfDataTypes.ReserveConfigurationMapThe reserve configuration
enabledboolTrue if the stable rate borrowing needs to be enabled, false otherwise

getStableRateBorrowingEnabled

Gets the stable rate borrowing state of the reserve

function getStableRateBorrowingEnabled(DataTypes.ReserveConfigurationMap storage self) internal view returns (bool);

Parameters

NameTypeDescription
selfDataTypes.ReserveConfigurationMapThe reserve configuration

Returns

NameTypeDescription
<none>boolThe stable rate borrowing state

setReserveFactor

Sets the reserve factor of the reserve

function setReserveFactor(DataTypes.ReserveConfigurationMap memory self, uint256 reserveFactor) internal pure;

Parameters

NameTypeDescription
selfDataTypes.ReserveConfigurationMapThe reserve configuration
reserveFactoruint256The reserve factor

getReserveFactor

Gets the reserve factor of the reserve

function getReserveFactor(DataTypes.ReserveConfigurationMap storage self) internal view returns (uint256);

Parameters

NameTypeDescription
selfDataTypes.ReserveConfigurationMapThe reserve configuration

Returns

NameTypeDescription
<none>uint256The reserve factor

getFlags

Gets the configuration flags of the reserve

function getFlags(DataTypes.ReserveConfigurationMap storage self) internal view returns (bool, bool, bool, bool);

Parameters

NameTypeDescription
selfDataTypes.ReserveConfigurationMapThe reserve configuration

Returns

NameTypeDescription
<none>boolThe state flags representing active, frozen, borrowing enabled, stableRateBorrowing enabled
<none>bool
<none>bool
<none>bool

getParams

Gets the configuration paramters of the reserve

function getParams(DataTypes.ReserveConfigurationMap storage self)
    internal
    view
    returns (uint256, uint256, uint256, uint256, uint256);

Parameters

NameTypeDescription
selfDataTypes.ReserveConfigurationMapThe reserve configuration

Returns

NameTypeDescription
<none>uint256The state params representing ltv, liquidation threshold, liquidation bonus, the reserve decimals
<none>uint256
<none>uint256
<none>uint256
<none>uint256

getParamsMemory

Gets the configuration paramters of the reserve from a memory object

function getParamsMemory(DataTypes.ReserveConfigurationMap memory self)
    internal
    pure
    returns (uint256, uint256, uint256, uint256, uint256);

Parameters

NameTypeDescription
selfDataTypes.ReserveConfigurationMapThe reserve configuration

Returns

NameTypeDescription
<none>uint256The state params representing ltv, liquidation threshold, liquidation bonus, the reserve decimals
<none>uint256
<none>uint256
<none>uint256
<none>uint256

getFlagsMemory

Gets the configuration flags of the reserve from a memory object

function getFlagsMemory(DataTypes.ReserveConfigurationMap memory self) internal pure returns (bool, bool, bool, bool);

Parameters

NameTypeDescription
selfDataTypes.ReserveConfigurationMapThe reserve configuration

Returns

NameTypeDescription
<none>boolThe state flags representing active, frozen, borrowing enabled, stableRateBorrowing enabled
<none>bool
<none>bool
<none>bool