Skip to content

Commit

Permalink
feat: add hints for the final assert
Browse files Browse the repository at this point in the history
  • Loading branch information
QGarchery committed Nov 22, 2024
1 parent 6b41f7b commit f04942e
Showing 1 changed file with 3 additions and 9 deletions.
12 changes: 3 additions & 9 deletions certora/specs/LiquidateBuffer.spec
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,6 @@ function summaryMulDivDown(uint256 x, uint256 y, uint256 d) returns uint256 {
return require_uint256((x * y) / d);
}

function wDivDown(uint256 x, uint256 y) returns uint256 {
return summaryMulDivDown(x, Util.wad(), y);
}

function wDivUp(uint256 x, uint256 y) returns uint256 {
return summaryMulDivUp(x, Util.wad(), y);
}

rule liquidateImprovePosition(MorphoLiquidateHarness.MarketParams marketParams, uint256 seizedAssetsInput, uint256 repaidSharesInput) {
MorphoLiquidateHarness.Id id = Util.libId(marketParams);

Expand All @@ -57,7 +49,6 @@ rule liquidateImprovePosition(MorphoLiquidateHarness.MarketParams marketParams,
uint256 repaidAssets;
uint256 lif;
(seizedAssets, repaidShares, repaidAssets, lif) = liquidateView(marketParams, seizedAssetsInput, repaidSharesInput, collateralPrice);
require repaidAssets > 0;

uint256 borrowerCollateralQuoted = summaryMulDivDown(borrowerCollateral, collateralPrice, Util.oraclePriceScale());
require summaryMulDivUp(lif, borrowerAssets, Util.wad()) <= borrowerCollateralQuoted;
Expand All @@ -73,5 +64,8 @@ rule liquidateImprovePosition(MorphoLiquidateHarness.MarketParams marketParams,
uint256 newBorrowerCollateral = require_uint256(borrowerCollateral - seizedAssets);

assert repaidShares * borrowerCollateral >= seizedAssets * borrowerShares;
assert borrowerShares * newBorrowerCollateral >= newBorrowerShares * borrowerCollateral;
assert newTotalShares * virtualTotalBorrowAssets(id) >= newTotalAssets * virtualTotalBorrowShares(id);
assert borrowerShares * virtualTotalBorrowAssets(id) * newTotalShares * newBorrowerCollateral >= newBorrowerShares * virtualTotalBorrowShares(id) * newTotalAssets * borrowerCollateral;
assert borrowerAssets * newBorrowerCollateral >= newBorrowerAssets * borrowerCollateral;
}

0 comments on commit f04942e

Please sign in to comment.