Skip to content

Commit

Permalink
fix: bound liquidate seized assets rounding up
Browse files Browse the repository at this point in the history
  • Loading branch information
QGarchery committed Sep 29, 2024
1 parent fc6793a commit 208c886
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions test/forge/BaseTest.sol
Original file line number Diff line number Diff line change
Expand Up @@ -330,13 +330,15 @@ contract BaseTest is Test {
{
Id _id = _marketParams.id();

uint256 collateral = morpho.collateral(_id, borrower);
uint256 collateralPrice = IOracle(_marketParams.oracle).price();
uint256 maxRepaidAssets = morpho.expectedBorrowAssets(_marketParams, borrower);
uint256 borrowShares = morpho.borrowShares(_id, borrower);
(,, uint256 totalBorrowAssets, uint256 totalBorrowShares) = morpho.expectedMarketBalances(_marketParams);
uint256 maxRepaidAssets = borrowShares.toAssetsDown(totalBorrowAssets, totalBorrowShares);
uint256 maxSeizedAssets = maxRepaidAssets.wMulDown(_liquidationIncentiveFactor(_marketParams.lltv)).mulDivDown(
ORACLE_PRICE_SCALE, collateralPrice
);

uint256 collateral = morpho.collateral(_id, borrower);
return bound(seizedAssets, 0, Math.min(collateral, maxSeizedAssets));
}

Expand Down

0 comments on commit 208c886

Please sign in to comment.