setBorrowing
Last updated
Last updated
bool ifFirstBorrowing
captures the return value from either of the debt token's mint function. It is true
, if the user had no debt previously, thereby making this incoming borrow action the user's very first one.
The function performs bitwise operations to set or unset the borrowing status for the specified reserve.
It calculates the bit position based on the reserveIndex
and creates a bit mask by left shifting 1
by twice the reserveIndex
value. This mask is captured by the bit variable.
Setting Borrowing Status: If borrowing
is true, the function uses a bitwise OR operation (|=
) to set the corresponding bit in the self.data
bitmap. This indicates that the user is borrowing the specified reserve.
Unsetting Borrowing Status: If borrowing is false, the function uses a bitwise AND operation (&=
) with the bitwise negation (~bit
) to unset the corresponding bit in the self.data
map. This indicates that the user is not borrowing the specified reserve.
For in-depth illustration on how this function works, see: setUsingAsCollateral.
The process for both are similar, one sets the borrow flag, the other sets the collateral flag.