-
Notifications
You must be signed in to change notification settings - Fork 69
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: executable liquidate, attempt prove buffer
- Loading branch information
Showing
4 changed files
with
72 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,6 +23,7 @@ jobs: | |
- ExchangeRate | ||
- Health | ||
- LibSummary | ||
- LiquidateBuffer | ||
- Liveness | ||
- Reentrancy | ||
- Reverts | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
{ | ||
"files": [ | ||
"certora/harness/MorphoHarness.sol", | ||
"certora/harness/Util.sol" | ||
], | ||
"solc": "solc-0.8.19", | ||
"verify": "MorphoHarness:certora/specs/LiquidateBuffer.spec", | ||
"prover_args": [ | ||
"-depth 5", | ||
"-mediumTimeout 5", | ||
"-timeout 3600", | ||
"-adaptiveSolverConfig false", | ||
"-smt_nonLinearArithmetic true", | ||
"-solvers [z3:def{randomSeed=1},z3:def{randomSeed=2},z3:def{randomSeed=3},z3:def{randomSeed=4},z3:def{randomSeed=5},z3:def{randomSeed=6},z3:def{randomSeed=7},z3:lia2]" | ||
], | ||
"rule_sanity": "basic", | ||
"server": "production", | ||
"msg": "Morpho Blue Liquidate Buffer" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
// SPDX-License-Identifier: GPL-2.0-or-later | ||
|
||
import "Health.spec"; | ||
|
||
methods { | ||
function Util.lif(uint256) external returns (uint256) envfree; | ||
function Util.oraclePriceScale() external returns (uint256) envfree; | ||
function Util.wad() external returns (uint256) envfree; | ||
} | ||
|
||
rule liquidateImprovePosition(env e, MorphoHarness.MarketParams marketParams, address borrower, uint256 seizedAssetsInput, uint256 repaidSharesInput, bytes data) { | ||
// Assume no callback for simplicity. | ||
require data.length == 0; | ||
|
||
MorphoHarness.Id id = Util.libId(marketParams); | ||
|
||
// We place ourselves at the last block for getting the following variables. | ||
require lastUpdate(id) == e.block.timestamp; | ||
|
||
uint256 borrowerShares = borrowShares(id, borrower); | ||
require borrowerShares <= totalBorrowShares(id); | ||
|
||
uint256 borrowerCollateral = collateral(id, borrower); | ||
uint256 collateralPrice = mockPrice(); | ||
uint256 lif = Util.lif(marketParams.lltv); | ||
|
||
uint256 borrowerAssets = summaryMulDivUp(borrowerShares, virtualTotalBorrowAssets(id), virtualTotalBorrowShares(id)); | ||
uint256 borrowerCollateralQuoted = summaryMulDivDown(borrowerCollateral, collateralPrice, Util.oraclePriceScale()); | ||
|
||
require summaryMulDivUp(lif, borrowerAssets, Util.wad()) <= borrowerCollateralQuoted; | ||
assert borrowerCollateral * collateralPrice * virtualTotalBorrowShares(id) * Util.wad() >= borrowerShares * Util.oraclePriceScale() * virtualTotalBorrowAssets(id) * lif; | ||
|
||
uint256 seizedAssets; | ||
uint256 repaidShares; | ||
(seizedAssets, repaidShares) = liquidate(e, marketParams, borrower, seizedAssetsInput, repaidSharesInput, data); | ||
|
||
require !priceChanged; | ||
assert repaidShares * borrowerCollateral >= seizedAssets * borrowerShares; | ||
// assert borrowerShares * newBorrowerCollateral >= newBorrowerShares * borrowerCollateral; | ||
// assert newTotalShares * OldVirtualTotalBorrowAssets >= newTotalAssets * OldVirtualTotalBorrowShares; | ||
|
||
} |