mirror of
https://github.com/Instadapp/aave-protocol-v2.git
synced 2024-07-29 21:47:30 +00:00
Added memory accessors to reserveConfiguration
This commit is contained in:
parent
4b35df5c4c
commit
be517ad960
|
@ -282,6 +282,7 @@ library ReserveConfiguration {
|
|||
uint256,
|
||||
uint256,
|
||||
uint256,
|
||||
uint256,
|
||||
uint256
|
||||
)
|
||||
{
|
||||
|
@ -291,7 +292,61 @@ library ReserveConfiguration {
|
|||
dataLocal & ~LTV_MASK,
|
||||
(dataLocal & ~LIQUIDATION_THRESHOLD_MASK) >> LIQUIDATION_THRESHOLD_START_BIT_POSITION,
|
||||
(dataLocal & ~LIQUIDATION_BONUS_MASK) >> LIQUIDATION_BONUS_START_BIT_POSITION,
|
||||
(dataLocal & ~DECIMALS_MASK) >> RESERVE_DECIMALS_START_BIT_POSITION
|
||||
(dataLocal & ~DECIMALS_MASK) >> RESERVE_DECIMALS_START_BIT_POSITION,
|
||||
(dataLocal & ~RESERVE_FACTOR_MASK) >> RESERVE_FACTOR_START_BIT_POSITION
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dev gets the configuration paramters of the reserve from a memory object
|
||||
* @param self the reserve configuration
|
||||
* @return the state params representing ltv, liquidation threshold, liquidation bonus, the reserve decimals
|
||||
**/
|
||||
function getParamsMemory(ReserveConfiguration.Map memory self)
|
||||
internal
|
||||
pure
|
||||
returns (
|
||||
uint256,
|
||||
uint256,
|
||||
uint256,
|
||||
uint256,
|
||||
uint256
|
||||
)
|
||||
{
|
||||
uint256 dataLocal = self.data;
|
||||
|
||||
return (
|
||||
dataLocal & ~LTV_MASK,
|
||||
(dataLocal & ~LIQUIDATION_THRESHOLD_MASK) >> LIQUIDATION_THRESHOLD_START_BIT_POSITION,
|
||||
(dataLocal & ~LIQUIDATION_BONUS_MASK) >> LIQUIDATION_BONUS_START_BIT_POSITION,
|
||||
(dataLocal & ~DECIMALS_MASK) >> RESERVE_DECIMALS_START_BIT_POSITION,
|
||||
(dataLocal & ~RESERVE_FACTOR_MASK) >> RESERVE_FACTOR_START_BIT_POSITION
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @dev gets the configuration flags of the reserve from a memory object
|
||||
* @param self the reserve configuration
|
||||
* @return the state flags representing active, freezed, borrowing enabled, stableRateBorrowing enabled
|
||||
**/
|
||||
function getFlagsMemory(ReserveConfiguration.Map memory self)
|
||||
internal
|
||||
pure
|
||||
returns (
|
||||
bool,
|
||||
bool,
|
||||
bool,
|
||||
bool
|
||||
)
|
||||
{
|
||||
uint256 dataLocal = self.data;
|
||||
|
||||
return (
|
||||
(dataLocal & ~ACTIVE_MASK) >> IS_ACTIVE_START_BIT_POSITION != 0,
|
||||
(dataLocal & ~FROZEN_MASK) >> IS_FROZEN_START_BIT_POSITION != 0,
|
||||
(dataLocal & ~BORROWING_MASK) >> BORROWING_ENABLED_START_BIT_POSITION != 0,
|
||||
(dataLocal & ~STABLE_BORROWING_MASK) >> STABLE_BORROWING_ENABLED_START_BIT_POSITION != 0
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user