diff --git a/contracts/libraries/configuration/ReserveConfiguration.sol b/contracts/libraries/configuration/ReserveConfiguration.sol index 5053c0fd..78d1fcf2 100644 --- a/contracts/libraries/configuration/ReserveConfiguration.sol +++ b/contracts/libraries/configuration/ReserveConfiguration.sol @@ -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 ); } }