-
Notifications
You must be signed in to change notification settings - Fork 18
[Certora] Remove market liveness (WIP) #781
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
QGarchery
wants to merge
18
commits into
main
Choose a base branch
from
certora/remove-market-liveness
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+124
−8
Draft
Changes from all commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
ede7669
feat: add remove market liveness
QGarchery a04e0da
Merge remote-tracking branch 'origin/main' into certora/remove-market…
QGarchery 94a9ffb
Merge branch 'certora/market-params-list' into certora/remove-market-…
QGarchery 38ffc97
fix: disable no-revert check
QGarchery f594b3d
fix: making calls efficient
QGarchery 2011dd4
fix: internal summary of supplyShares
QGarchery e0fb80d
fix: remove supplyShares calls
QGarchery 8728771
chore: investigate vacuity
QGarchery 1783ba5
fix: loop iter in remove market liveness
QGarchery 5c9c1d2
fix: require distinct market params
QGarchery 0029a3d
fix: summaries
QGarchery d8e777c
fix: remove ghost copy
QGarchery db9d5be
chore: tweak timeouts
QGarchery 3cf2320
fix: prevent adapter from being the fee recipient
QGarchery 40609f0
chore: fmt
QGarchery 0749b68
refactor: split the rule in 2
QGarchery 7be07d9
fix: import Util from Morpho Blue
QGarchery 8413ec5
fix: shares are not zero, but assets are
QGarchery File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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,35 @@ | ||
| { | ||
| "files": [ | ||
| "src/VaultV2.sol", | ||
| "src/adapters/MorphoMarketV1Adapter.sol", | ||
| "lib/morpho-blue/certora/helpers/MorphoHarness.sol", | ||
| "test/mocks/ERC20Mock.sol", | ||
| "certora/helpers/Utils.sol" | ||
| ], | ||
| "parametric_contracts": [ | ||
| "VaultV2" | ||
| ], | ||
| "verify": "VaultV2:certora/specs/RemoveMarketLiveness.spec", | ||
| "link": [ | ||
| "VaultV2:asset=ERC20Mock", | ||
| "MorphoMarketV1Adapter:morpho=MorphoHarness", | ||
| "MorphoMarketV1Adapter:parentVault=VaultV2", | ||
| "MorphoMarketV1Adapter:asset=ERC20Mock" | ||
| ], | ||
| "loop_iter": "3", | ||
| "optimistic_loop": true, | ||
| "optimistic_hashing": true, | ||
| "compiler_map": { | ||
| "VaultV2": "solc-0.8.28", | ||
| "MorphoMarketV1Adapter": "solc-0.8.28", | ||
| "MorphoHarness": "solc-0.8.19", | ||
| "ERC20Mock": "solc-0.8.28", | ||
| "Utils": "solc-0.8.28" | ||
| }, | ||
| "prover_args": [ | ||
| "-depth 5", | ||
| "-mediumTimeout 20", | ||
| "-timeout 3600" | ||
| ], | ||
| "msg": "Vault V2 Remove Market Liveness" | ||
| } |
This file contains hidden or 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 hidden or 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,69 @@ | ||
| // SPDX-License-Identifier: GPL-2.0-or-later | ||
| // Copyright (c) 2025 Morpho Association | ||
|
|
||
| using MorphoMarketV1Adapter as MorphoMarketV1Adapter; | ||
| using MorphoHarness as Morpho; | ||
| using Utils as Utils; | ||
|
|
||
| methods { | ||
| function _.extSloads(bytes32[]) external => NONDET DELETE; | ||
| function _.multicall(bytes[] data) external => HAVOC_ALL DELETE; | ||
| function _.supplyShares(address, Morpho.Id id, address user) internal => summarySupplyShares(id, user) expect uint256; | ||
|
|
||
| function Morpho.supplyShares(Morpho.Id, address) external returns (uint256) envfree; | ||
| function MorphoMarketV1Adapter.marketParamsListLength() external returns (uint256) envfree; | ||
| function MorphoMarketV1Adapter.marketParamsList(uint256) external returns (address, address, address, address, uint256) envfree; | ||
| function Utils.decodeMarketParams(bytes data) external returns (Morpho.MarketParams memory) envfree; | ||
|
|
||
| function _.deallocate(bytes, uint256, bytes4, address) external => DISPATCHER(true); | ||
|
|
||
| // Todo: remove once it's linked to ERC20Mock. | ||
| function SafeTransferLib.safeTransfer(address, address, uint256) internal => NONDET; | ||
| function _.borrowRate(Morpho.MarketParams, Morpho.Market) external => ghostBorrowRate expect uint256; | ||
| function _.borrowRateView(Morpho.MarketParams, Morpho.Market) external => ghostBorrowRate expect uint256; | ||
|
|
||
| function _.market(Morpho.Id) external => DISPATCHER(true); | ||
| } | ||
|
|
||
| persistent ghost uint256 ghostBorrowRate; | ||
|
|
||
| function summarySupplyShares(Morpho.Id id, address user) returns uint256 { | ||
| return Morpho.supplyShares(id, user); | ||
| } | ||
|
|
||
| rule canRemoveMarket(env e, bytes data) { | ||
| Morpho.MarketParams marketParams = Utils.decodeMarketParams(data); | ||
| require Morpho.feeRecipient != MorphoMarketV1Adapter, "sane assumption to simplify the amount of asset to remove"; | ||
| uint256 assets = Utils.expectedSupplyAssets(e, Morpho, marketParams, MorphoMarketV1Adapter); | ||
|
|
||
| uint256 marketParamsListLength = MorphoMarketV1Adapter.marketParamsListLength(); | ||
| require forall uint256 i. forall uint256 j. (i < j && j < marketParamsListLength) => ( | ||
| MorphoMarketV1Adapter.marketParamsList[i].loanToken != MorphoMarketV1Adapter.marketParamsList[j].loanToken || | ||
| MorphoMarketV1Adapter.marketParamsList[i].collateralToken != MorphoMarketV1Adapter.marketParamsList[j].collateralToken || | ||
| MorphoMarketV1Adapter.marketParamsList[i].oracle != MorphoMarketV1Adapter.marketParamsList[j].oracle || | ||
| MorphoMarketV1Adapter.marketParamsList[i].irm != MorphoMarketV1Adapter.marketParamsList[j].irm || | ||
| MorphoMarketV1Adapter.marketParamsList[i].lltv != MorphoMarketV1Adapter.marketParamsList[j].lltv | ||
| ), "see distinctMarketParamsInList"; | ||
|
|
||
| // Could also check that the deallocate call doesn't revert. | ||
| deallocate(e, MorphoMarketV1Adapter, data, assets); | ||
|
|
||
| assert Utils.expectedSupplyAssets(e, Morpho, marketParams, MorphoMarketV1Adapter) == 0; | ||
|
|
||
| uint256 i; | ||
| // Is this needed ? | ||
| require i < MorphoMarketV1Adapter.marketParamsListLength(); | ||
| address loanToken; | ||
| address collateralToken; | ||
| address oracle; | ||
| address irm; | ||
| uint256 lltv; | ||
| (loanToken, collateralToken, oracle, irm, lltv) = MorphoMarketV1Adapter.marketParamsList(i); | ||
| assert ( | ||
| loanToken != marketParams.loanToken || | ||
| collateralToken != marketParams.collateralToken || | ||
| oracle != marketParams.oracle || | ||
| irm != marketParams.irm || | ||
| lltv != marketParams.lltv | ||
| ); | ||
| } |
This file contains hidden or 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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.