getIsolationModeState
Overview

getIsolationModeState
Check if user is in isolation mode, if so, return the isolated asset address and its corresponding debt ceiling.
There 3 other functions within getIsolationModeState which we will cover:
isUsingAsCollateralOne_getFirstAssetIdByMaskgetDebtCeiling
Essentially,
isUsingAsCollateralOne: check if user has ONLY ONE asset as collateral (any one).If check returns true, possible that the user is in isolation mode.
get and return isolation details:
(true, assetAddress, debtCeiling)
_getFirstAssetIdByMaskis used to obtain theassetIDof this asset.Since
isUsingAsCollateralOneistrue,only 1 asset to ID, no need to worry about multiple assets
If
isUsingAsCollateralOneisfalseuser has multiple reserves as collateral
not in Isolation mode
return
(false, address(0), 0)
isUsingAsCollateralOne
isUsingAsCollateralOneCheck if user has ONLY ONE asset as collateral (any one).

This function was explained previously when covering the supply function: isUsingCollateralOne
_getFirstAssetIdByMask
_getFirstAssetIdByMaskReturns the address of the first asset flagged in the bitmap given the corresponding bitmask.
if collateral_mask, find the first asset which has its collateral bit set to
1

uint256 internal constant COLLATERAL_MASK =
0xAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA;COLLATERAL_MASKis passed asmaskbitmapDatais the binary string comprising of isolated collateral bits as explained in: isUsingAsCollateralAny
As we can see, we can end with id of value 1 -> index of the first asset which has its collateral bit set to 1 is 1.
getDebtCeiling
getDebtCeilingWith the previously obtained asset index, we can retrieve the assetAddress by the reserveList mapping. With the address, we can retrieve its corresponding reservesData struct, using it to obtain the debt ceiling.
address assetAddress = reserveList[assetId]; //declared on PoolStorage.sol
uint256 ceiling = reservesData[assetAddress].configuration.getDebtCeiling();
getDebtCeiling will extract the debt ceiling value held within bits 212-251 in the ReserveConfigurationMap.
getDebtCeiling utilizes the same approach as explained in getReserveFactor; see that section for an in-depth explanation.
Last updated
Was this helpful?
