-
Notifications
You must be signed in to change notification settings - Fork 567
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feat/isolation mode #120
Feat/isolation mode #120
Conversation
@@ -111,11 +144,46 @@ library UserConfiguration { | |||
} | |||
|
|||
/** | |||
* @notice Validate a user has not been using any reserve | |||
* @notice Checks if a user has not been using any reserve for borrowing or supply | |||
* @param self The configuration object | |||
* @return True if the user has been borrowing any reserve, false otherwise |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
has not been
|
||
/** | ||
* @notice Sets the debt ceiling for an asset | ||
* @param ceiling The new debt ceiling |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
doc for asset param is missing
uint256 | ||
) | ||
{ | ||
if (!isUsingAsCollateralAny(self)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
think we can remove this case
@@ -114,6 +125,12 @@ library BorrowLogic { | |||
userConfig.setBorrowing(reserve.id, true); | |||
} | |||
|
|||
if (isolationModeActive) { | |||
reserves[isolationModeCollateralAddress].isolationModeTotalDebt += Helpers.castUint128( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think its better to store the amount of coins, for better precision and to be aligned with reserve.unbacked
uint128 isolationModeTotalDebt = reserves[isolationModeCollateralAddress] | ||
.isolationModeTotalDebt; | ||
// since the debt ceiling does not take into account the interest accrued, it might happen that amount repaid > debt in isolation mode | ||
if (isolationModeTotalDebt < paybackAmount) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
paybackAmount
with incorrect decimals
|
||
require( | ||
reservesData[params.isolationModeCollateralAddress].isolationModeTotalDebt + | ||
params.amount <= |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
amount
with incorrect decimals
@@ -53,6 +55,7 @@ library ReserveConfiguration { | |||
uint256 constant MAX_VALID_LIQUIDATION_PROTOCOL_FEE = 10000; | |||
uint256 constant MAX_VALID_EMODE_CATEGORY = 255; | |||
uint256 constant MAX_VALID_UNBACKED_MINT_CAP = 68719476735; | |||
uint256 constant MAX_VALID_DEBT_CEILING = 4294967296; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Need to subtract one from this value I think.
4294967295
if (!isolationModeActive) { | ||
userConfig.setUsingAsCollateral(reserve.id, true); | ||
emit ReserveUsedAsCollateralEnabled(params.asset, params.onBehalfOf); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If this is the first supply of the isolation mode asset, I think it needs to be set as usingAsCollateral and emit an event (could be the same, or specific to IsolationModeCollateral)
No description provided.