mirror of
https://github.com/Instadapp/aave-protocol-v2.git
synced 2024-07-29 21:47:30 +00:00
Merge branch 'fix/96-remove-bit-movements' into 'master'
Fixes #96 Closes #96 See merge request aave-tech/protocol-v2!108
This commit is contained in:
commit
ecd2c04001
|
@ -9,15 +9,15 @@ import {Errors} from '../helpers/Errors.sol';
|
||||||
* @notice Implements the bitmap logic to handle the reserve configuration
|
* @notice Implements the bitmap logic to handle the reserve configuration
|
||||||
*/
|
*/
|
||||||
library ReserveConfiguration {
|
library ReserveConfiguration {
|
||||||
uint256 constant LTV_MASK = 0xFFFFFFFFFFFFFFFF0000;
|
uint256 constant LTV_MASK = 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF0000; // prettier-ignore
|
||||||
uint256 constant LIQUIDATION_THRESHOLD_MASK = 0xFFFFFFFFFFFF0000FFFF;
|
uint256 constant LIQUIDATION_THRESHOLD_MASK = 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF0000FFFF; // prettier-ignore
|
||||||
uint256 constant LIQUIDATION_BONUS_MASK = 0xFFFFFFFF0000FFFFFFFF;
|
uint256 constant LIQUIDATION_BONUS_MASK = 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF0000FFFFFFFF; // prettier-ignore
|
||||||
uint256 constant DECIMALS_MASK = 0xFFFFFF00FFFFFFFFFFFF;
|
uint256 constant DECIMALS_MASK = 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF00FFFFFFFFFFFF; // prettier-ignore
|
||||||
uint256 constant ACTIVE_MASK = 0xFFFFFEFFFFFFFFFFFFFF;
|
uint256 constant ACTIVE_MASK = 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFFFFFFFFFF; // prettier-ignore
|
||||||
uint256 constant FROZEN_MASK = 0xFFFFFDFFFFFFFFFFFFFF;
|
uint256 constant FROZEN_MASK = 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFDFFFFFFFFFFFFFF; // prettier-ignore
|
||||||
uint256 constant BORROWING_MASK = 0xFFFFFBFFFFFFFFFFFFFF;
|
uint256 constant BORROWING_MASK = 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFBFFFFFFFFFFFFFF; // prettier-ignore
|
||||||
uint256 constant STABLE_BORROWING_MASK = 0xFFFFF7FFFFFFFFFFFFFF;
|
uint256 constant STABLE_BORROWING_MASK = 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF7FFFFFFFFFFFFFF; // prettier-ignore
|
||||||
uint256 constant RESERVE_FACTOR_MASK = 0xFFFFFFFFFFFFFFFF;
|
uint256 constant RESERVE_FACTOR_MASK = 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF0000FFFFFFFFFFFFFFFF; // prettier-ignore
|
||||||
|
|
||||||
/// @dev For the LTV, the start bit is 0 (up to 15), but we don't declare it as for 0 no bit movement is needed
|
/// @dev For the LTV, the start bit is 0 (up to 15), but we don't declare it as for 0 no bit movement is needed
|
||||||
uint256 constant LIQUIDATION_THRESHOLD_START_BIT_POSITION = 16;
|
uint256 constant LIQUIDATION_THRESHOLD_START_BIT_POSITION = 16;
|
||||||
|
@ -161,7 +161,7 @@ library ReserveConfiguration {
|
||||||
* @return the active state
|
* @return the active state
|
||||||
**/
|
**/
|
||||||
function getActive(ReserveConfiguration.Map storage self) internal view returns (bool) {
|
function getActive(ReserveConfiguration.Map storage self) internal view returns (bool) {
|
||||||
return ((self.data & ~ACTIVE_MASK) >> IS_ACTIVE_START_BIT_POSITION) != 0;
|
return (self.data & ~ACTIVE_MASK) != 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -181,7 +181,7 @@ library ReserveConfiguration {
|
||||||
* @return the frozen state
|
* @return the frozen state
|
||||||
**/
|
**/
|
||||||
function getFrozen(ReserveConfiguration.Map storage self) internal view returns (bool) {
|
function getFrozen(ReserveConfiguration.Map storage self) internal view returns (bool) {
|
||||||
return ((self.data & ~FROZEN_MASK) >> IS_FROZEN_START_BIT_POSITION) != 0;
|
return (self.data & ~FROZEN_MASK) != 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -201,7 +201,7 @@ library ReserveConfiguration {
|
||||||
* @return the borrowing state
|
* @return the borrowing state
|
||||||
**/
|
**/
|
||||||
function getBorrowingEnabled(ReserveConfiguration.Map storage self) internal view returns (bool) {
|
function getBorrowingEnabled(ReserveConfiguration.Map storage self) internal view returns (bool) {
|
||||||
return ((self.data & ~BORROWING_MASK) >> BORROWING_ENABLED_START_BIT_POSITION) != 0;
|
return (self.data & ~BORROWING_MASK) != 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -228,8 +228,7 @@ library ReserveConfiguration {
|
||||||
view
|
view
|
||||||
returns (bool)
|
returns (bool)
|
||||||
{
|
{
|
||||||
return
|
return (self.data & ~STABLE_BORROWING_MASK) != 0;
|
||||||
((self.data & ~STABLE_BORROWING_MASK) >> STABLE_BORROWING_ENABLED_START_BIT_POSITION) != 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -275,10 +274,10 @@ library ReserveConfiguration {
|
||||||
uint256 dataLocal = self.data;
|
uint256 dataLocal = self.data;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
(dataLocal & ~ACTIVE_MASK) >> IS_ACTIVE_START_BIT_POSITION != 0,
|
(dataLocal & ~ACTIVE_MASK) != 0,
|
||||||
(dataLocal & ~FROZEN_MASK) >> IS_FROZEN_START_BIT_POSITION != 0,
|
(dataLocal & ~FROZEN_MASK) != 0,
|
||||||
(dataLocal & ~BORROWING_MASK) >> BORROWING_ENABLED_START_BIT_POSITION != 0,
|
(dataLocal & ~BORROWING_MASK) != 0,
|
||||||
(dataLocal & ~STABLE_BORROWING_MASK) >> STABLE_BORROWING_ENABLED_START_BIT_POSITION != 0
|
(dataLocal & ~STABLE_BORROWING_MASK) != 0
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -350,10 +349,10 @@ library ReserveConfiguration {
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
return (
|
return (
|
||||||
(self.data & ~ACTIVE_MASK) >> IS_ACTIVE_START_BIT_POSITION != 0,
|
(self.data & ~ACTIVE_MASK) != 0,
|
||||||
(self.data & ~FROZEN_MASK) >> IS_FROZEN_START_BIT_POSITION != 0,
|
(self.data & ~FROZEN_MASK) != 0,
|
||||||
(self.data & ~BORROWING_MASK) >> BORROWING_ENABLED_START_BIT_POSITION != 0,
|
(self.data & ~BORROWING_MASK) != 0,
|
||||||
(self.data & ~STABLE_BORROWING_MASK) >> STABLE_BORROWING_ENABLED_START_BIT_POSITION != 0
|
(self.data & ~STABLE_BORROWING_MASK) != 0
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user