Updated ReserveMap and UserMap

This commit is contained in:
The3D 2020-11-24 16:17:27 +01:00
parent 093e692573
commit 126458c7aa
17 changed files with 83 additions and 83 deletions

View File

@ -353,14 +353,14 @@ interface ILendingPool {
* @param asset The address of the underlying asset of the reserve * @param asset The address of the underlying asset of the reserve
* @return The configuration of the reserve * @return The configuration of the reserve
**/ **/
function getConfiguration(address asset) external view returns (DataTypes.ReserveBitmap memory); function getConfiguration(address asset) external view returns (DataTypes.ReserveConfigurationMap memory);
/** /**
* @dev Returns the configuration of the user across all the reserves * @dev Returns the configuration of the user across all the reserves
* @param user The user address * @param user The user address
* @return The configuration of the user * @return The configuration of the user
**/ **/
function getUserConfiguration(address user) external view returns (DataTypes.UserBitmap memory); function getUserConfiguration(address user) external view returns (DataTypes.UserConfigurationMap memory);
/** /**
* @dev Returns the normalized income normalized income of the reserve * @dev Returns the normalized income normalized income of the reserve

View File

@ -12,8 +12,8 @@ import {IVariableDebtToken} from '../protocol/tokenization/interfaces/IVariableD
import {DataTypes} from '../protocol/libraries/types/DataTypes.sol'; import {DataTypes} from '../protocol/libraries/types/DataTypes.sol';
contract AaveProtocolDataProvider { contract AaveProtocolDataProvider {
using ReserveConfiguration for DataTypes.ReserveBitmap; using ReserveConfiguration for DataTypes.ReserveConfigurationMap;
using UserConfiguration for DataTypes.UserBitmap; using UserConfiguration for DataTypes.UserConfigurationMap;
address constant MKR = 0x9f8F72aA9304c8B593d555F12eF6589cC3A579A2; address constant MKR = 0x9f8F72aA9304c8B593d555F12eF6589cC3A579A2;
address constant ETH = 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE; address constant ETH = 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE;
@ -80,7 +80,7 @@ contract AaveProtocolDataProvider {
bool isFrozen bool isFrozen
) )
{ {
DataTypes.ReserveBitmap memory configuration = DataTypes.ReserveConfigurationMap memory configuration =
ILendingPool(ADDRESSES_PROVIDER.getLendingPool()).getConfiguration(asset); ILendingPool(ADDRESSES_PROVIDER.getLendingPool()).getConfiguration(asset);
(ltv, liquidationThreshold, liquidationBonus, decimals, reserveFactor) = configuration (ltv, liquidationThreshold, liquidationBonus, decimals, reserveFactor) = configuration
@ -143,7 +143,7 @@ contract AaveProtocolDataProvider {
DataTypes.ReserveData memory reserve = DataTypes.ReserveData memory reserve =
ILendingPool(ADDRESSES_PROVIDER.getLendingPool()).getReserveData(asset); ILendingPool(ADDRESSES_PROVIDER.getLendingPool()).getReserveData(asset);
DataTypes.UserBitmap memory userConfig = DataTypes.UserConfigurationMap memory userConfig =
ILendingPool(ADDRESSES_PROVIDER.getLendingPool()).getUserConfiguration(user); ILendingPool(ADDRESSES_PROVIDER.getLendingPool()).getUserConfiguration(user);
currentATokenBalance = IERC20Detailed(reserve.aTokenAddress).balanceOf(user); currentATokenBalance = IERC20Detailed(reserve.aTokenAddress).balanceOf(user);

View File

@ -21,8 +21,8 @@ import {DataTypes} from '../protocol/libraries/types/DataTypes.sol';
contract UiPoolDataProvider is IUiPoolDataProvider { contract UiPoolDataProvider is IUiPoolDataProvider {
using WadRayMath for uint256; using WadRayMath for uint256;
using ReserveConfiguration for DataTypes.ReserveBitmap; using ReserveConfiguration for DataTypes.ReserveConfigurationMap;
using UserConfiguration for DataTypes.UserBitmap; using UserConfiguration for DataTypes.UserConfigurationMap;
address public constant MOCK_USD_ADDRESS = 0x10F7Fc1F91Ba351f9C629c5947AD69bD03C05b96; address public constant MOCK_USD_ADDRESS = 0x10F7Fc1F91Ba351f9C629c5947AD69bD03C05b96;
@ -57,7 +57,7 @@ contract UiPoolDataProvider is IUiPoolDataProvider {
ILendingPool lendingPool = ILendingPool(provider.getLendingPool()); ILendingPool lendingPool = ILendingPool(provider.getLendingPool());
IPriceOracleGetter oracle = IPriceOracleGetter(provider.getPriceOracle()); IPriceOracleGetter oracle = IPriceOracleGetter(provider.getPriceOracle());
address[] memory reserves = lendingPool.getReservesList(); address[] memory reserves = lendingPool.getReservesList();
DataTypes.UserBitmap memory userConfig = lendingPool.getUserConfiguration(user); DataTypes.UserConfigurationMap memory userConfig = lendingPool.getUserConfiguration(user);
AggregatedReserveData[] memory reservesData = new AggregatedReserveData[](reserves.length); AggregatedReserveData[] memory reservesData = new AggregatedReserveData[](reserves.length);
UserReserveData[] memory userReservesData = UserReserveData[] memory userReservesData =

View File

@ -15,8 +15,8 @@ import {IERC20} from '../dependencies/openzeppelin/contracts/IERC20.sol';
import {DataTypes} from '../protocol/libraries/types/DataTypes.sol'; import {DataTypes} from '../protocol/libraries/types/DataTypes.sol';
contract WETHGateway is IWETHGateway, Ownable { contract WETHGateway is IWETHGateway, Ownable {
using ReserveConfiguration for DataTypes.ReserveBitmap; using ReserveConfiguration for DataTypes.ReserveConfigurationMap;
using UserConfiguration for DataTypes.UserBitmap; using UserConfiguration for DataTypes.UserConfigurationMap;
IWETH internal immutable WETH; IWETH internal immutable WETH;
ILendingPool internal immutable POOL; ILendingPool internal immutable POOL;

View File

@ -23,7 +23,7 @@ contract WalletBalanceProvider {
using Address for address payable; using Address for address payable;
using Address for address; using Address for address;
using SafeERC20 for IERC20; using SafeERC20 for IERC20;
using ReserveConfiguration for DataTypes.ReserveBitmap; using ReserveConfiguration for DataTypes.ReserveConfigurationMap;
address constant MOCK_ETH_ADDRESS = 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE; address constant MOCK_ETH_ADDRESS = 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE;
@ -93,7 +93,7 @@ contract WalletBalanceProvider {
uint256[] memory balances = new uint256[](reservesWithEth.length); uint256[] memory balances = new uint256[](reservesWithEth.length);
for (uint256 j = 0; j < reserves.length; j++) { for (uint256 j = 0; j < reserves.length; j++) {
DataTypes.ReserveBitmap memory configuration = pool.getConfiguration(reservesWithEth[j]); DataTypes.ReserveConfigurationMap memory configuration = pool.getConfiguration(reservesWithEth[j]);
(bool isActive, , , ) = configuration.getFlagsMemory(); (bool isActive, , , ) = configuration.getFlagsMemory();

View File

@ -623,7 +623,7 @@ contract LendingPool is VersionedInitializable, ILendingPool, LendingPoolStorage
external external
view view
override override
returns (DataTypes.ReserveBitmap memory) returns (DataTypes.ReserveConfigurationMap memory)
{ {
return _reserves[asset].configuration; return _reserves[asset].configuration;
} }
@ -637,7 +637,7 @@ contract LendingPool is VersionedInitializable, ILendingPool, LendingPoolStorage
external external
view view
override override
returns (DataTypes.UserBitmap memory) returns (DataTypes.UserConfigurationMap memory)
{ {
return _usersConfig[user]; return _usersConfig[user];
} }
@ -730,13 +730,13 @@ contract LendingPool is VersionedInitializable, ILendingPool, LendingPoolStorage
if (from != to) { if (from != to) {
if (balanceFromBefore.sub(amount) == 0) { if (balanceFromBefore.sub(amount) == 0) {
DataTypes.UserBitmap storage fromConfig = _usersConfig[from]; DataTypes.UserConfigurationMap storage fromConfig = _usersConfig[from];
fromConfig.setUsingAsCollateral(reserveId, false); fromConfig.setUsingAsCollateral(reserveId, false);
emit ReserveUsedAsCollateralDisabled(asset, from); emit ReserveUsedAsCollateralDisabled(asset, from);
} }
if (balanceToBefore == 0 && amount != 0) { if (balanceToBefore == 0 && amount != 0) {
DataTypes.UserBitmap storage toConfig = _usersConfig[to]; DataTypes.UserConfigurationMap storage toConfig = _usersConfig[to];
toConfig.setUsingAsCollateral(reserveId, true); toConfig.setUsingAsCollateral(reserveId, true);
emit ReserveUsedAsCollateralEnabled(asset, to); emit ReserveUsedAsCollateralEnabled(asset, to);
} }
@ -825,7 +825,7 @@ contract LendingPool is VersionedInitializable, ILendingPool, LendingPoolStorage
function _executeBorrow(ExecuteBorrowParams memory vars) internal { function _executeBorrow(ExecuteBorrowParams memory vars) internal {
DataTypes.ReserveData storage reserve = _reserves[vars.asset]; DataTypes.ReserveData storage reserve = _reserves[vars.asset];
DataTypes.UserBitmap storage userConfig = _usersConfig[vars.onBehalfOf]; DataTypes.UserConfigurationMap storage userConfig = _usersConfig[vars.onBehalfOf];
address oracle = _addressesProvider.getPriceOracle(); address oracle = _addressesProvider.getPriceOracle();

View File

@ -97,7 +97,7 @@ contract LendingPoolCollateralManager is
) external override returns (uint256, string memory) { ) external override returns (uint256, string memory) {
DataTypes.ReserveData storage collateralReserve = _reserves[collateral]; DataTypes.ReserveData storage collateralReserve = _reserves[collateral];
DataTypes.ReserveData storage principalReserve = _reserves[principal]; DataTypes.ReserveData storage principalReserve = _reserves[principal];
DataTypes.UserBitmap storage userConfig = _usersConfig[user]; DataTypes.UserConfigurationMap storage userConfig = _usersConfig[user];
LiquidationCallLocalVars memory vars; LiquidationCallLocalVars memory vars;

View File

@ -25,7 +25,7 @@ import {DataTypes} from '../libraries/types/DataTypes.sol';
contract LendingPoolConfigurator is VersionedInitializable { contract LendingPoolConfigurator is VersionedInitializable {
using SafeMath for uint256; using SafeMath for uint256;
using ReserveConfiguration for DataTypes.ReserveBitmap; using ReserveConfiguration for DataTypes.ReserveConfigurationMap;
/** /**
* @dev emitted when a reserve is initialized. * @dev emitted when a reserve is initialized.
@ -250,7 +250,7 @@ contract LendingPoolConfigurator is VersionedInitializable {
interestRateStrategyAddress interestRateStrategyAddress
); );
DataTypes.ReserveBitmap memory currentConfig = pool.getConfiguration(asset); DataTypes.ReserveConfigurationMap memory currentConfig = pool.getConfiguration(asset);
currentConfig.setDecimals(underlyingAssetDecimals); currentConfig.setDecimals(underlyingAssetDecimals);
@ -316,7 +316,7 @@ contract LendingPoolConfigurator is VersionedInitializable {
external external
onlyPoolAdmin onlyPoolAdmin
{ {
DataTypes.ReserveBitmap memory currentConfig = pool.getConfiguration(asset); DataTypes.ReserveConfigurationMap memory currentConfig = pool.getConfiguration(asset);
currentConfig.setBorrowingEnabled(true); currentConfig.setBorrowingEnabled(true);
currentConfig.setStableRateBorrowingEnabled(stableBorrowRateEnabled); currentConfig.setStableRateBorrowingEnabled(stableBorrowRateEnabled);
@ -331,7 +331,7 @@ contract LendingPoolConfigurator is VersionedInitializable {
* @param asset the address of the reserve * @param asset the address of the reserve
**/ **/
function disableBorrowingOnReserve(address asset) external onlyPoolAdmin { function disableBorrowingOnReserve(address asset) external onlyPoolAdmin {
DataTypes.ReserveBitmap memory currentConfig = pool.getConfiguration(asset); DataTypes.ReserveConfigurationMap memory currentConfig = pool.getConfiguration(asset);
currentConfig.setBorrowingEnabled(false); currentConfig.setBorrowingEnabled(false);
@ -354,7 +354,7 @@ contract LendingPoolConfigurator is VersionedInitializable {
uint256 liquidationThreshold, uint256 liquidationThreshold,
uint256 liquidationBonus uint256 liquidationBonus
) external onlyPoolAdmin { ) external onlyPoolAdmin {
DataTypes.ReserveBitmap memory currentConfig = pool.getConfiguration(asset); DataTypes.ReserveConfigurationMap memory currentConfig = pool.getConfiguration(asset);
//validation of the parameters: the LTV can //validation of the parameters: the LTV can
//only be lower or equal than the liquidation threshold //only be lower or equal than the liquidation threshold
@ -396,7 +396,7 @@ contract LendingPoolConfigurator is VersionedInitializable {
* @param asset the address of the reserve * @param asset the address of the reserve
**/ **/
function enableReserveStableRate(address asset) external onlyPoolAdmin { function enableReserveStableRate(address asset) external onlyPoolAdmin {
DataTypes.ReserveBitmap memory currentConfig = pool.getConfiguration(asset); DataTypes.ReserveConfigurationMap memory currentConfig = pool.getConfiguration(asset);
currentConfig.setStableRateBorrowingEnabled(true); currentConfig.setStableRateBorrowingEnabled(true);
@ -410,7 +410,7 @@ contract LendingPoolConfigurator is VersionedInitializable {
* @param asset the address of the reserve * @param asset the address of the reserve
**/ **/
function disableReserveStableRate(address asset) external onlyPoolAdmin { function disableReserveStableRate(address asset) external onlyPoolAdmin {
DataTypes.ReserveBitmap memory currentConfig = pool.getConfiguration(asset); DataTypes.ReserveConfigurationMap memory currentConfig = pool.getConfiguration(asset);
currentConfig.setStableRateBorrowingEnabled(false); currentConfig.setStableRateBorrowingEnabled(false);
@ -424,7 +424,7 @@ contract LendingPoolConfigurator is VersionedInitializable {
* @param asset the address of the reserve * @param asset the address of the reserve
**/ **/
function activateReserve(address asset) external onlyPoolAdmin { function activateReserve(address asset) external onlyPoolAdmin {
DataTypes.ReserveBitmap memory currentConfig = pool.getConfiguration(asset); DataTypes.ReserveConfigurationMap memory currentConfig = pool.getConfiguration(asset);
currentConfig.setActive(true); currentConfig.setActive(true);
@ -440,7 +440,7 @@ contract LendingPoolConfigurator is VersionedInitializable {
function deactivateReserve(address asset) external onlyPoolAdmin { function deactivateReserve(address asset) external onlyPoolAdmin {
_checkNoLiquidity(asset); _checkNoLiquidity(asset);
DataTypes.ReserveBitmap memory currentConfig = pool.getConfiguration(asset); DataTypes.ReserveConfigurationMap memory currentConfig = pool.getConfiguration(asset);
currentConfig.setActive(false); currentConfig.setActive(false);
@ -454,7 +454,7 @@ contract LendingPoolConfigurator is VersionedInitializable {
* @param asset the address of the reserve * @param asset the address of the reserve
**/ **/
function freezeReserve(address asset) external onlyPoolAdmin { function freezeReserve(address asset) external onlyPoolAdmin {
DataTypes.ReserveBitmap memory currentConfig = pool.getConfiguration(asset); DataTypes.ReserveConfigurationMap memory currentConfig = pool.getConfiguration(asset);
currentConfig.setFrozen(true); currentConfig.setFrozen(true);
@ -468,7 +468,7 @@ contract LendingPoolConfigurator is VersionedInitializable {
* @param asset the address of the reserve * @param asset the address of the reserve
**/ **/
function unfreezeReserve(address asset) external onlyPoolAdmin { function unfreezeReserve(address asset) external onlyPoolAdmin {
DataTypes.ReserveBitmap memory currentConfig = pool.getConfiguration(asset); DataTypes.ReserveConfigurationMap memory currentConfig = pool.getConfiguration(asset);
currentConfig.setFrozen(false); currentConfig.setFrozen(false);
@ -483,7 +483,7 @@ contract LendingPoolConfigurator is VersionedInitializable {
* @param reserveFactor the new reserve factor of the reserve * @param reserveFactor the new reserve factor of the reserve
**/ **/
function setReserveFactor(address asset, uint256 reserveFactor) external onlyPoolAdmin { function setReserveFactor(address asset, uint256 reserveFactor) external onlyPoolAdmin {
DataTypes.ReserveBitmap memory currentConfig = pool.getConfiguration(asset); DataTypes.ReserveConfigurationMap memory currentConfig = pool.getConfiguration(asset);
currentConfig.setReserveFactor(reserveFactor); currentConfig.setReserveFactor(reserveFactor);
@ -535,7 +535,7 @@ contract LendingPoolConfigurator is VersionedInitializable {
InitializableImmutableAdminUpgradeabilityProxy proxy = InitializableImmutableAdminUpgradeabilityProxy proxy =
InitializableImmutableAdminUpgradeabilityProxy(payable(proxyAddress)); InitializableImmutableAdminUpgradeabilityProxy(payable(proxyAddress));
DataTypes.ReserveBitmap memory configuration = pool.getConfiguration(asset); DataTypes.ReserveConfigurationMap memory configuration = pool.getConfiguration(asset);
(, , , uint256 decimals, ) = configuration.getParamsMemory(); (, , , uint256 decimals, ) = configuration.getParamsMemory();

View File

@ -9,13 +9,13 @@ import {DataTypes} from '../libraries/types/DataTypes.sol';
contract LendingPoolStorage { contract LendingPoolStorage {
using ReserveLogic for DataTypes.ReserveData; using ReserveLogic for DataTypes.ReserveData;
using ReserveConfiguration for DataTypes.ReserveBitmap; using ReserveConfiguration for DataTypes.ReserveConfigurationMap;
using UserConfiguration for DataTypes.UserBitmap; using UserConfiguration for DataTypes.UserConfigurationMap;
ILendingPoolAddressesProvider internal _addressesProvider; ILendingPoolAddressesProvider internal _addressesProvider;
mapping(address => DataTypes.ReserveData) internal _reserves; mapping(address => DataTypes.ReserveData) internal _reserves;
mapping(address => DataTypes.UserBitmap) internal _usersConfig; mapping(address => DataTypes.UserConfigurationMap) internal _usersConfig;
// the list of the available reserves, structured as a mapping for gas savings reasons // the list of the available reserves, structured as a mapping for gas savings reasons
mapping(uint256 => address) internal _reservesList; mapping(uint256 => address) internal _reservesList;

View File

@ -41,7 +41,7 @@ library ReserveConfiguration {
* @param self the reserve configuration * @param self the reserve configuration
* @param ltv the new ltv * @param ltv the new ltv
**/ **/
function setLtv(DataTypes.ReserveBitmap memory self, uint256 ltv) internal pure { function setLtv(DataTypes.ReserveConfigurationMap memory self, uint256 ltv) internal pure {
require(ltv <= MAX_VALID_LTV, Errors.RC_INVALID_LTV); require(ltv <= MAX_VALID_LTV, Errors.RC_INVALID_LTV);
self.data = (self.data & LTV_MASK) | ltv; self.data = (self.data & LTV_MASK) | ltv;
@ -52,7 +52,7 @@ library ReserveConfiguration {
* @param self the reserve configuration * @param self the reserve configuration
* @return the loan to value * @return the loan to value
**/ **/
function getLtv(DataTypes.ReserveBitmap storage self) internal view returns (uint256) { function getLtv(DataTypes.ReserveConfigurationMap storage self) internal view returns (uint256) {
return self.data & ~LTV_MASK; return self.data & ~LTV_MASK;
} }
@ -61,7 +61,7 @@ library ReserveConfiguration {
* @param self the reserve configuration * @param self the reserve configuration
* @param threshold the new liquidation threshold * @param threshold the new liquidation threshold
**/ **/
function setLiquidationThreshold(DataTypes.ReserveBitmap memory self, uint256 threshold) function setLiquidationThreshold(DataTypes.ReserveConfigurationMap memory self, uint256 threshold)
internal internal
pure pure
{ {
@ -77,7 +77,7 @@ library ReserveConfiguration {
* @param self the reserve configuration * @param self the reserve configuration
* @return the liquidation threshold * @return the liquidation threshold
**/ **/
function getLiquidationThreshold(DataTypes.ReserveBitmap storage self) function getLiquidationThreshold(DataTypes.ReserveConfigurationMap storage self)
internal internal
view view
returns (uint256) returns (uint256)
@ -90,7 +90,7 @@ library ReserveConfiguration {
* @param self the reserve configuration * @param self the reserve configuration
* @param bonus the new liquidation bonus * @param bonus the new liquidation bonus
**/ **/
function setLiquidationBonus(DataTypes.ReserveBitmap memory self, uint256 bonus) internal pure { function setLiquidationBonus(DataTypes.ReserveConfigurationMap memory self, uint256 bonus) internal pure {
require(bonus <= MAX_VALID_LIQUIDATION_BONUS, Errors.RC_INVALID_LIQ_BONUS); require(bonus <= MAX_VALID_LIQUIDATION_BONUS, Errors.RC_INVALID_LIQ_BONUS);
self.data = self.data =
@ -103,7 +103,7 @@ library ReserveConfiguration {
* @param self the reserve configuration * @param self the reserve configuration
* @return the liquidation bonus * @return the liquidation bonus
**/ **/
function getLiquidationBonus(DataTypes.ReserveBitmap storage self) function getLiquidationBonus(DataTypes.ReserveConfigurationMap storage self)
internal internal
view view
returns (uint256) returns (uint256)
@ -116,7 +116,7 @@ library ReserveConfiguration {
* @param self the reserve configuration * @param self the reserve configuration
* @param decimals the decimals * @param decimals the decimals
**/ **/
function setDecimals(DataTypes.ReserveBitmap memory self, uint256 decimals) internal pure { function setDecimals(DataTypes.ReserveConfigurationMap memory self, uint256 decimals) internal pure {
require(decimals <= MAX_VALID_DECIMALS, Errors.RC_INVALID_DECIMALS); require(decimals <= MAX_VALID_DECIMALS, Errors.RC_INVALID_DECIMALS);
self.data = (self.data & DECIMALS_MASK) | (decimals << RESERVE_DECIMALS_START_BIT_POSITION); self.data = (self.data & DECIMALS_MASK) | (decimals << RESERVE_DECIMALS_START_BIT_POSITION);
@ -127,7 +127,7 @@ library ReserveConfiguration {
* @param self the reserve configuration * @param self the reserve configuration
* @return the decimals of the asset * @return the decimals of the asset
**/ **/
function getDecimals(DataTypes.ReserveBitmap storage self) internal view returns (uint256) { function getDecimals(DataTypes.ReserveConfigurationMap storage self) internal view returns (uint256) {
return (self.data & ~DECIMALS_MASK) >> RESERVE_DECIMALS_START_BIT_POSITION; return (self.data & ~DECIMALS_MASK) >> RESERVE_DECIMALS_START_BIT_POSITION;
} }
@ -136,7 +136,7 @@ library ReserveConfiguration {
* @param self the reserve configuration * @param self the reserve configuration
* @param active the active state * @param active the active state
**/ **/
function setActive(DataTypes.ReserveBitmap memory self, bool active) internal pure { function setActive(DataTypes.ReserveConfigurationMap memory self, bool active) internal pure {
self.data = self.data =
(self.data & ACTIVE_MASK) | (self.data & ACTIVE_MASK) |
(uint256(active ? 1 : 0) << IS_ACTIVE_START_BIT_POSITION); (uint256(active ? 1 : 0) << IS_ACTIVE_START_BIT_POSITION);
@ -147,7 +147,7 @@ library ReserveConfiguration {
* @param self the reserve configuration * @param self the reserve configuration
* @return the active state * @return the active state
**/ **/
function getActive(DataTypes.ReserveBitmap storage self) internal view returns (bool) { function getActive(DataTypes.ReserveConfigurationMap storage self) internal view returns (bool) {
return (self.data & ~ACTIVE_MASK) != 0; return (self.data & ~ACTIVE_MASK) != 0;
} }
@ -156,7 +156,7 @@ library ReserveConfiguration {
* @param self the reserve configuration * @param self the reserve configuration
* @param frozen the frozen state * @param frozen the frozen state
**/ **/
function setFrozen(DataTypes.ReserveBitmap memory self, bool frozen) internal pure { function setFrozen(DataTypes.ReserveConfigurationMap memory self, bool frozen) internal pure {
self.data = self.data =
(self.data & FROZEN_MASK) | (self.data & FROZEN_MASK) |
(uint256(frozen ? 1 : 0) << IS_FROZEN_START_BIT_POSITION); (uint256(frozen ? 1 : 0) << IS_FROZEN_START_BIT_POSITION);
@ -167,7 +167,7 @@ library ReserveConfiguration {
* @param self the reserve configuration * @param self the reserve configuration
* @return the frozen state * @return the frozen state
**/ **/
function getFrozen(DataTypes.ReserveBitmap storage self) internal view returns (bool) { function getFrozen(DataTypes.ReserveConfigurationMap storage self) internal view returns (bool) {
return (self.data & ~FROZEN_MASK) != 0; return (self.data & ~FROZEN_MASK) != 0;
} }
@ -176,7 +176,7 @@ library ReserveConfiguration {
* @param self the reserve configuration * @param self the reserve configuration
* @param enabled true if the borrowing needs to be enabled, false otherwise * @param enabled true if the borrowing needs to be enabled, false otherwise
**/ **/
function setBorrowingEnabled(DataTypes.ReserveBitmap memory self, bool enabled) internal pure { function setBorrowingEnabled(DataTypes.ReserveConfigurationMap memory self, bool enabled) internal pure {
self.data = self.data =
(self.data & BORROWING_MASK) | (self.data & BORROWING_MASK) |
(uint256(enabled ? 1 : 0) << BORROWING_ENABLED_START_BIT_POSITION); (uint256(enabled ? 1 : 0) << BORROWING_ENABLED_START_BIT_POSITION);
@ -187,7 +187,7 @@ library ReserveConfiguration {
* @param self the reserve configuration * @param self the reserve configuration
* @return the borrowing state * @return the borrowing state
**/ **/
function getBorrowingEnabled(DataTypes.ReserveBitmap storage self) internal view returns (bool) { function getBorrowingEnabled(DataTypes.ReserveConfigurationMap storage self) internal view returns (bool) {
return (self.data & ~BORROWING_MASK) != 0; return (self.data & ~BORROWING_MASK) != 0;
} }
@ -196,7 +196,7 @@ library ReserveConfiguration {
* @param self the reserve configuration * @param self the reserve configuration
* @param enabled true if the stable rate borrowing needs to be enabled, false otherwise * @param enabled true if the stable rate borrowing needs to be enabled, false otherwise
**/ **/
function setStableRateBorrowingEnabled(DataTypes.ReserveBitmap memory self, bool enabled) function setStableRateBorrowingEnabled(DataTypes.ReserveConfigurationMap memory self, bool enabled)
internal internal
pure pure
{ {
@ -210,7 +210,7 @@ library ReserveConfiguration {
* @param self the reserve configuration * @param self the reserve configuration
* @return the stable rate borrowing state * @return the stable rate borrowing state
**/ **/
function getStableRateBorrowingEnabled(DataTypes.ReserveBitmap storage self) function getStableRateBorrowingEnabled(DataTypes.ReserveConfigurationMap storage self)
internal internal
view view
returns (bool) returns (bool)
@ -223,7 +223,7 @@ library ReserveConfiguration {
* @param self the reserve configuration * @param self the reserve configuration
* @param reserveFactor the reserve factor * @param reserveFactor the reserve factor
**/ **/
function setReserveFactor(DataTypes.ReserveBitmap memory self, uint256 reserveFactor) function setReserveFactor(DataTypes.ReserveConfigurationMap memory self, uint256 reserveFactor)
internal internal
pure pure
{ {
@ -239,7 +239,7 @@ library ReserveConfiguration {
* @param self the reserve configuration * @param self the reserve configuration
* @return the reserve factor * @return the reserve factor
**/ **/
function getReserveFactor(DataTypes.ReserveBitmap storage self) internal view returns (uint256) { function getReserveFactor(DataTypes.ReserveConfigurationMap storage self) internal view returns (uint256) {
return (self.data & ~RESERVE_FACTOR_MASK) >> RESERVE_FACTOR_START_BIT_POSITION; return (self.data & ~RESERVE_FACTOR_MASK) >> RESERVE_FACTOR_START_BIT_POSITION;
} }
@ -248,7 +248,7 @@ library ReserveConfiguration {
* @param self the reserve configuration * @param self the reserve configuration
* @return the state flags representing active, frozen, borrowing enabled, stableRateBorrowing enabled * @return the state flags representing active, frozen, borrowing enabled, stableRateBorrowing enabled
**/ **/
function getFlags(DataTypes.ReserveBitmap storage self) function getFlags(DataTypes.ReserveConfigurationMap storage self)
internal internal
view view
returns ( returns (
@ -273,7 +273,7 @@ library ReserveConfiguration {
* @param self the reserve configuration * @param self the reserve configuration
* @return the state params representing ltv, liquidation threshold, liquidation bonus, the reserve decimals * @return the state params representing ltv, liquidation threshold, liquidation bonus, the reserve decimals
**/ **/
function getParams(DataTypes.ReserveBitmap storage self) function getParams(DataTypes.ReserveConfigurationMap storage self)
internal internal
view view
returns ( returns (
@ -300,7 +300,7 @@ library ReserveConfiguration {
* @param self the reserve configuration * @param self the reserve configuration
* @return the state params representing ltv, liquidation threshold, liquidation bonus, the reserve decimals * @return the state params representing ltv, liquidation threshold, liquidation bonus, the reserve decimals
**/ **/
function getParamsMemory(DataTypes.ReserveBitmap memory self) function getParamsMemory(DataTypes.ReserveConfigurationMap memory self)
internal internal
pure pure
returns ( returns (
@ -325,7 +325,7 @@ library ReserveConfiguration {
* @param self the reserve configuration * @param self the reserve configuration
* @return the state flags representing active, frozen, borrowing enabled, stableRateBorrowing enabled * @return the state flags representing active, frozen, borrowing enabled, stableRateBorrowing enabled
**/ **/
function getFlagsMemory(DataTypes.ReserveBitmap memory self) function getFlagsMemory(DataTypes.ReserveConfigurationMap memory self)
internal internal
pure pure
returns ( returns (

View File

@ -20,7 +20,7 @@ library UserConfiguration {
* @param borrowing true if the user is borrowing the reserve, false otherwise * @param borrowing true if the user is borrowing the reserve, false otherwise
**/ **/
function setBorrowing( function setBorrowing(
DataTypes.UserBitmap storage self, DataTypes.UserConfigurationMap storage self,
uint256 reserveIndex, uint256 reserveIndex,
bool borrowing bool borrowing
) internal { ) internal {
@ -37,7 +37,7 @@ library UserConfiguration {
* @param _usingAsCollateral true if the user is usin the reserve as collateral, false otherwise * @param _usingAsCollateral true if the user is usin the reserve as collateral, false otherwise
**/ **/
function setUsingAsCollateral( function setUsingAsCollateral(
DataTypes.UserBitmap storage self, DataTypes.UserConfigurationMap storage self,
uint256 reserveIndex, uint256 reserveIndex,
bool _usingAsCollateral bool _usingAsCollateral
) internal { ) internal {
@ -53,7 +53,7 @@ library UserConfiguration {
* @param reserveIndex the index of the reserve in the bitmap * @param reserveIndex the index of the reserve in the bitmap
* @return true if the user has been using a reserve for borrowing or as collateral, false otherwise * @return true if the user has been using a reserve for borrowing or as collateral, false otherwise
**/ **/
function isUsingAsCollateralOrBorrowing(DataTypes.UserBitmap memory self, uint256 reserveIndex) function isUsingAsCollateralOrBorrowing(DataTypes.UserConfigurationMap memory self, uint256 reserveIndex)
internal internal
pure pure
returns (bool) returns (bool)
@ -68,7 +68,7 @@ library UserConfiguration {
* @param reserveIndex the index of the reserve in the bitmap * @param reserveIndex the index of the reserve in the bitmap
* @return true if the user has been using a reserve for borrowing, false otherwise * @return true if the user has been using a reserve for borrowing, false otherwise
**/ **/
function isBorrowing(DataTypes.UserBitmap memory self, uint256 reserveIndex) function isBorrowing(DataTypes.UserConfigurationMap memory self, uint256 reserveIndex)
internal internal
pure pure
returns (bool) returns (bool)
@ -83,7 +83,7 @@ library UserConfiguration {
* @param reserveIndex the index of the reserve in the bitmap * @param reserveIndex the index of the reserve in the bitmap
* @return true if the user has been using a reserve as collateral, false otherwise * @return true if the user has been using a reserve as collateral, false otherwise
**/ **/
function isUsingAsCollateral(DataTypes.UserBitmap memory self, uint256 reserveIndex) function isUsingAsCollateral(DataTypes.UserConfigurationMap memory self, uint256 reserveIndex)
internal internal
pure pure
returns (bool) returns (bool)
@ -97,7 +97,7 @@ library UserConfiguration {
* @param self the configuration object * @param self the configuration object
* @return true if the user has been borrowing any reserve, false otherwise * @return true if the user has been borrowing any reserve, false otherwise
**/ **/
function isBorrowingAny(DataTypes.UserBitmap memory self) internal pure returns (bool) { function isBorrowingAny(DataTypes.UserConfigurationMap memory self) internal pure returns (bool) {
return self.data & BORROWING_MASK != 0; return self.data & BORROWING_MASK != 0;
} }
@ -106,7 +106,7 @@ library UserConfiguration {
* @param self the configuration object * @param self the configuration object
* @return true if the user has been borrowing any reserve, false otherwise * @return true if the user has been borrowing any reserve, false otherwise
**/ **/
function isEmpty(DataTypes.UserBitmap memory self) internal pure returns (bool) { function isEmpty(DataTypes.UserConfigurationMap memory self) internal pure returns (bool) {
return self.data == 0; return self.data == 0;
} }
} }

View File

@ -22,8 +22,8 @@ library GenericLogic {
using SafeMath for uint256; using SafeMath for uint256;
using WadRayMath for uint256; using WadRayMath for uint256;
using PercentageMath for uint256; using PercentageMath for uint256;
using ReserveConfiguration for DataTypes.ReserveBitmap; using ReserveConfiguration for DataTypes.ReserveConfigurationMap;
using UserConfiguration for DataTypes.UserBitmap; using UserConfiguration for DataTypes.UserConfigurationMap;
uint256 public constant HEALTH_FACTOR_LIQUIDATION_THRESHOLD = 1 ether; uint256 public constant HEALTH_FACTOR_LIQUIDATION_THRESHOLD = 1 ether;
@ -57,7 +57,7 @@ library GenericLogic {
address user, address user,
uint256 amount, uint256 amount,
mapping(address => DataTypes.ReserveData) storage reservesData, mapping(address => DataTypes.ReserveData) storage reservesData,
DataTypes.UserBitmap calldata userConfig, DataTypes.UserConfigurationMap calldata userConfig,
mapping(uint256 => address) storage reserves, mapping(uint256 => address) storage reserves,
uint256 reservesCount, uint256 reservesCount,
address oracle address oracle
@ -152,7 +152,7 @@ library GenericLogic {
function calculateUserAccountData( function calculateUserAccountData(
address user, address user,
mapping(address => DataTypes.ReserveData) storage reservesData, mapping(address => DataTypes.ReserveData) storage reservesData,
DataTypes.UserBitmap memory userConfig, DataTypes.UserConfigurationMap memory userConfig,
mapping(uint256 => address) storage reserves, mapping(uint256 => address) storage reserves,
uint256 reservesCount, uint256 reservesCount,
address oracle address oracle

View File

@ -45,7 +45,7 @@ library ReserveLogic {
); );
using ReserveLogic for DataTypes.ReserveData; using ReserveLogic for DataTypes.ReserveData;
using ReserveConfiguration for DataTypes.ReserveBitmap; using ReserveConfiguration for DataTypes.ReserveConfigurationMap;
/** /**
* @dev returns the ongoing normalized income for the reserve. * @dev returns the ongoing normalized income for the reserve.

View File

@ -27,8 +27,8 @@ library ValidationLogic {
using WadRayMath for uint256; using WadRayMath for uint256;
using PercentageMath for uint256; using PercentageMath for uint256;
using SafeERC20 for IERC20; using SafeERC20 for IERC20;
using ReserveConfiguration for DataTypes.ReserveBitmap; using ReserveConfiguration for DataTypes.ReserveConfigurationMap;
using UserConfiguration for DataTypes.UserBitmap; using UserConfiguration for DataTypes.UserConfigurationMap;
uint256 public constant REBALANCE_UP_LIQUIDITY_RATE_THRESHOLD = 4000; uint256 public constant REBALANCE_UP_LIQUIDITY_RATE_THRESHOLD = 4000;
uint256 public constant REBALANCE_UP_USAGE_RATIO_THRESHOLD = 0.95 * 1e27; //usage ratio of 95% uint256 public constant REBALANCE_UP_USAGE_RATIO_THRESHOLD = 0.95 * 1e27; //usage ratio of 95%
@ -62,7 +62,7 @@ library ValidationLogic {
uint256 amount, uint256 amount,
uint256 userBalance, uint256 userBalance,
mapping(address => DataTypes.ReserveData) storage reservesData, mapping(address => DataTypes.ReserveData) storage reservesData,
DataTypes.UserBitmap storage userConfig, DataTypes.UserConfigurationMap storage userConfig,
mapping(uint256 => address) storage reserves, mapping(uint256 => address) storage reserves,
uint256 reservesCount, uint256 reservesCount,
address oracle address oracle
@ -133,7 +133,7 @@ library ValidationLogic {
uint256 interestRateMode, uint256 interestRateMode,
uint256 maxStableLoanPercent, uint256 maxStableLoanPercent,
mapping(address => DataTypes.ReserveData) storage reservesData, mapping(address => DataTypes.ReserveData) storage reservesData,
DataTypes.UserBitmap storage userConfig, DataTypes.UserConfigurationMap storage userConfig,
mapping(uint256 => address) storage reserves, mapping(uint256 => address) storage reserves,
uint256 reservesCount, uint256 reservesCount,
address oracle address oracle
@ -266,7 +266,7 @@ library ValidationLogic {
*/ */
function validateSwapRateMode( function validateSwapRateMode(
DataTypes.ReserveData storage reserve, DataTypes.ReserveData storage reserve,
DataTypes.UserBitmap storage userConfig, DataTypes.UserConfigurationMap storage userConfig,
uint256 stableDebt, uint256 stableDebt,
uint256 variableDebt, uint256 variableDebt,
DataTypes.InterestRateMode currentRateMode DataTypes.InterestRateMode currentRateMode
@ -354,7 +354,7 @@ library ValidationLogic {
address reserveAddress, address reserveAddress,
bool useAsCollateral, bool useAsCollateral,
mapping(address => DataTypes.ReserveData) storage reservesData, mapping(address => DataTypes.ReserveData) storage reservesData,
DataTypes.UserBitmap storage userConfig, DataTypes.UserConfigurationMap storage userConfig,
mapping(uint256 => address) storage reserves, mapping(uint256 => address) storage reserves,
uint256 reservesCount, uint256 reservesCount,
address oracle address oracle
@ -400,7 +400,7 @@ library ValidationLogic {
function validateLiquidationCall( function validateLiquidationCall(
DataTypes.ReserveData storage collateralReserve, DataTypes.ReserveData storage collateralReserve,
DataTypes.ReserveData storage principalReserve, DataTypes.ReserveData storage principalReserve,
DataTypes.UserBitmap storage userConfig, DataTypes.UserConfigurationMap storage userConfig,
uint256 userHealthFactor, uint256 userHealthFactor,
uint256 userStableDebt, uint256 userStableDebt,
uint256 userVariableDebt uint256 userVariableDebt
@ -454,7 +454,7 @@ library ValidationLogic {
function validateTransfer( function validateTransfer(
address from, address from,
mapping(address => DataTypes.ReserveData) storage reservesData, mapping(address => DataTypes.ReserveData) storage reservesData,
DataTypes.UserBitmap storage userConfig, DataTypes.UserConfigurationMap storage userConfig,
mapping(uint256 => address) storage reserves, mapping(uint256 => address) storage reserves,
uint256 reservesCount, uint256 reservesCount,
address oracle address oracle

View File

@ -5,7 +5,7 @@ library DataTypes {
// refer to the whitepaper, section 1.1 basic concepts for a formal description of these properties. // refer to the whitepaper, section 1.1 basic concepts for a formal description of these properties.
struct ReserveData { struct ReserveData {
//stores the reserve configuration //stores the reserve configuration
ReserveBitmap configuration; ReserveConfigurationMap configuration;
//the liquidity index. Expressed in ray //the liquidity index. Expressed in ray
uint128 liquidityIndex; uint128 liquidityIndex;
//variable borrow index. Expressed in ray //variable borrow index. Expressed in ray
@ -27,7 +27,7 @@ library DataTypes {
uint8 id; uint8 id;
} }
struct ReserveBitmap { struct ReserveConfigurationMap {
//bit 0-15: LTV //bit 0-15: LTV
//bit 16-31: Liq. threshold //bit 16-31: Liq. threshold
//bit 32-47: Liq. bonus //bit 32-47: Liq. bonus
@ -41,7 +41,7 @@ library DataTypes {
uint256 data; uint256 data;
} }
struct UserBitmap { struct UserConfigurationMap {
uint256 data; uint256 data;
} }

View File

@ -90,7 +90,7 @@ contract LendingPoolHarnessForVariableDebtToken is ILendingPool {
external external
view view
override override
returns (DataTypes.UserBitmap memory) returns (DataTypes.UserConfigurationMap memory)
{ {
return originalPool.getUserConfiguration(user); return originalPool.getUserConfiguration(user);
} }
@ -142,7 +142,7 @@ contract LendingPoolHarnessForVariableDebtToken is ILendingPool {
external external
view view
override override
returns (DataTypes.ReserveBitmap memory) returns (DataTypes.ReserveConfigurationMap memory)
{ {
return originalPool.getConfiguration(asset); return originalPool.getConfiguration(asset);
} }

View File

@ -7,7 +7,7 @@ import {UserConfiguration} from '../../contracts/libraries/configuration/UserCon
A wrapper contract for calling functions from the library UserConfiguration. A wrapper contract for calling functions from the library UserConfiguration.
*/ */
contract UserConfigurationHarness { contract UserConfigurationHarness {
DataTypes.UserBitmap internal usersConfig; DataTypes.UserConfigurationMap internal usersConfig;
function setBorrowing( function setBorrowing(
address user, address user,