UserConfiguration
Implements the bitmap logic to handle the user configuration
BORROWING_MASK
COLLATERAL_MASK
setBorrowing
Sets if the user is borrowing the reserve identified by reserveIndex
Parameters
Name | Type | Description |
---|---|---|
self | struct DataTypes.UserConfigurationMap | The configuration object |
reserveIndex | uint256 | The index of the reserve in the bitmap |
borrowing | bool | True if the user is borrowing the reserve, false otherwise |
setUsingAsCollateral
Sets if the user is using as collateral the reserve identified by reserveIndex
Parameters
Name | Type | Description |
---|---|---|
self | struct DataTypes.UserConfigurationMap | The configuration object |
reserveIndex | uint256 | The index of the reserve in the bitmap |
usingAsCollateral | bool | True if the user is using the reserve as collateral, false otherwise |
isUsingAsCollateralOrBorrowing
Returns if a user has been using the reserve for borrowing or as collateral
Parameters
Name | Type | Description |
---|---|---|
self | struct DataTypes.UserConfigurationMap | The configuration object |
reserveIndex | uint256 | The index of the reserve in the bitmap |
Return Values
Name | Type | Description |
---|---|---|
[0] | bool | True if the user has been using a reserve for borrowing or as collateral, false otherwise |
isBorrowing
Validate a user has been using the reserve for borrowing
Parameters
Name | Type | Description |
---|---|---|
self | struct DataTypes.UserConfigurationMap | The configuration object |
reserveIndex | uint256 | The index of the reserve in the bitmap |
Return Values
Name | Type | Description |
---|---|---|
[0] | bool | True if the user has been using a reserve for borrowing, false otherwise |
isUsingAsCollateral
Validate a user has been using the reserve as collateral
Parameters
Name | Type | Description |
---|---|---|
self | struct DataTypes.UserConfigurationMap | The configuration object |
reserveIndex | uint256 | The index of the reserve in the bitmap |
Return Values
Name | Type | Description |
---|---|---|
[0] | bool | True if the user has been using a reserve as collateral, false otherwise |
isUsingAsCollateralOne
Checks if a user has been supplying only one reserve as collateral
this uses a simple trick - if a number is a power of two (only one bit set) then n & (n - 1) == 0
Parameters
Name | Type | Description |
---|---|---|
self | struct DataTypes.UserConfigurationMap | The configuration object |
Return Values
Name | Type | Description |
---|---|---|
[0] | bool | True if the user has been supplying as collateral one reserve, false otherwise |
isUsingAsCollateralAny
Checks if a user has been supplying any reserve as collateral
Parameters
Name | Type | Description |
---|---|---|
self | struct DataTypes.UserConfigurationMap | The configuration object |
Return Values
Name | Type | Description |
---|---|---|
[0] | bool | True if the user has been supplying as collateral any reserve, false otherwise |
isBorrowingOne
Checks if a user has been borrowing only one asset
this uses a simple trick - if a number is a power of two (only one bit set) then n & (n - 1) == 0
Parameters
Name | Type | Description |
---|---|---|
self | struct DataTypes.UserConfigurationMap | The configuration object |
Return Values
Name | Type | Description |
---|---|---|
[0] | bool | True if the user has been supplying as collateral one reserve, false otherwise |
isBorrowingAny
Checks if a user has been borrowing from any reserve
Parameters
Name | Type | Description |
---|---|---|
self | struct DataTypes.UserConfigurationMap | The configuration object |
Return Values
Name | Type | Description |
---|---|---|
[0] | bool | True if the user has been borrowing any reserve, false otherwise |
isEmpty
Checks if a user has not been using any reserve for borrowing or supply
Parameters
Name | Type | Description |
---|---|---|
self | struct DataTypes.UserConfigurationMap | The configuration object |
Return Values
Name | Type | Description |
---|---|---|
[0] | bool | True if the user has not been borrowing or supplying any reserve, false otherwise |
getSiloedBorrowingState
Returns the siloed borrowing state for the user
Parameters
Name | Type | Description |
---|---|---|
self | struct DataTypes.UserConfigurationMap | The configuration object |
reservesData | mapping(address => struct DataTypes.ReserveData) | The data of all the reserves |
reservesList | mapping(uint256 => address) | The reserve list |
Return Values
Name | Type | Description |
---|---|---|
[0] | bool | True if the user has borrowed a siloed asset, false otherwise |
[1] | address | The address of the only borrowed asset |
_getFirstAssetIdByMask
Returns the address of the first asset flagged in the bitmap given the corresponding bitmask
Parameters
Name | Type | Description |
---|---|---|
self | struct DataTypes.UserConfigurationMap | The configuration object |
mask | uint256 |
Return Values
Name | Type | Description |
---|---|---|
[0] | uint256 | The index of the first asset flagged in the bitmap once the corresponding mask is applied |