Skip to content

Commit

Permalink
refactor: change order of require for clarity
Browse files Browse the repository at this point in the history
  • Loading branch information
QGarchery committed Oct 6, 2024
1 parent 1af02e4 commit 525cfdf
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/PreLiquidation.sol
Original file line number Diff line number Diff line change
Expand Up @@ -142,11 +142,11 @@ contract PreLiquidation is IPreLiquidation, IMorphoRepayCallback {
uint256 collateralQuoted = uint256(position.collateral).mulDivDown(collateralPrice, ORACLE_PRICE_SCALE);
uint256 borrowed = uint256(position.borrowShares).toAssetsUp(market.totalBorrowAssets, market.totalBorrowShares);

// The following require is equivalent to checking that ltv > PRE_LLTV.
require(borrowed > collateralQuoted.wMulDown(PRE_LLTV), ErrorsLib.NotPreLiquidatablePosition());
// The two following require-statements ensure that collateralQuoted is different from zero.
require(borrowed <= collateralQuoted.wMulDown(LLTV), ErrorsLib.LiquidatablePosition());
// The following require-statement is equivalent to checking that ltv > PRE_LLTV.
require(borrowed > collateralQuoted.wMulDown(PRE_LLTV), ErrorsLib.NotPreLiquidatablePosition());

// The two preceding requires ensures that collateralQuoted is different from zero.
uint256 ltv = borrowed.wDivUp(collateralQuoted);
uint256 preLIF = (ltv - PRE_LLTV).wDivDown(LLTV - PRE_LLTV).wMulDown(PRE_LIF_2 - PRE_LIF_1) + PRE_LIF_1;

Expand Down

0 comments on commit 525cfdf

Please sign in to comment.