Skip to content

Commit

Permalink
test: fix precision of repaid assets computation
Browse files Browse the repository at this point in the history
  • Loading branch information
QGarchery committed Sep 29, 2024
1 parent dee266f commit f178c58
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions test/forge/invariant/MorphoInvariantTest.sol
Original file line number Diff line number Diff line change
Expand Up @@ -170,12 +170,11 @@ contract MorphoInvariantTest is InvariantTest {
{
uint256 collateralPrice = oracle.price();
uint256 liquidationIncentiveFactor = _liquidationIncentiveFactor(_marketParams.lltv);
Market memory _market = morpho.market(_marketParams.id());
(,, uint256 totalBorrowAssets, uint256 totalBorrowShares) = morpho.expectedMarketBalances(_marketParams);
uint256 seizedAssetsQuoted = seizedAssets.mulDivUp(collateralPrice, ORACLE_PRICE_SCALE);
uint256 repaidShares = seizedAssetsQuoted.wDivUp(liquidationIncentiveFactor).toSharesUp(
_market.totalBorrowAssets, _market.totalBorrowShares
);
uint256 repaidAssets = repaidShares.toAssetsUp(_market.totalBorrowAssets, _market.totalBorrowShares);
uint256 repaidShares =
seizedAssetsQuoted.wDivUp(liquidationIncentiveFactor).toSharesUp(totalBorrowAssets, totalBorrowShares);
uint256 repaidAssets = repaidShares.toAssetsUp(totalBorrowAssets, totalBorrowShares);

loanToken.setBalance(msg.sender, repaidAssets);

Expand Down

0 comments on commit f178c58

Please sign in to comment.