collateral check
Last updated
Last updated
Interest rates are updated to account for the withdrawal of deposits, and therefore the reduction of supply. See .updateInterestRates
Transaction reverts on invalid reserveIndex
Let's examine the bitwise manipulations with an example. In this example, we assume six bits for simplicity, w.r.t to self.data
It the result of the bitwise operations is not equal to 0, the function would return true
. This indicates that the user has been using the reserve at reserveIndex = 2
as collateral.
Set the collateral bit for a specific asset to either 0
or 1
, depending on bool usingAsCollateral
.
(reserveIndex << 1) + 1
This bitwise operation doubles the index and increments it by 1
Creates the necessary offset to manipulate the relevant bits to the asset of specified index
For more in-depth explanation see: isUsingCollateral
bit = 1 << offset
If usingAsCollateral
is true, indicating that the reserve should be marked as used for collateral,
bitwise OR operation between data
and the bit
value (self.data |= bit
).
sets the corresponding bit in the self.data
variable to 1
If usingAsCollateral
is false, indicating that the reserve should NOT be marked as collateral
bitwise AND operation between data
and the bit
value (self.data &= bit
).
sets the corresponding bit in the self.data
variable to 0