-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/style/constructor-readability' i…
…nto feat/lif-restriction
- Loading branch information
Showing
13 changed files
with
562 additions
and
302 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 |
---|---|---|
|
@@ -17,6 +17,7 @@ jobs: | |
matrix: | ||
conf: | ||
- Immutability | ||
- Liveness | ||
- Reentrancy | ||
|
||
steps: | ||
|
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 |
---|---|---|
@@ -1,16 +1,16 @@ | ||
{ | ||
"files": [ | ||
"src/PreLiquidation.sol", | ||
], | ||
"solc": "solc-0.8.27", | ||
"solc_via_ir" : true, | ||
"verify": "PreLiquidation:certora/specs/Immutability.spec", | ||
"prover_args": [ | ||
"-depth 3", | ||
"-mediumTimeout 20", | ||
"-timeout 120", | ||
], | ||
"rule_sanity": "basic", | ||
"server": "production", | ||
"msg": "PreLiquidation Immutability", | ||
"files": [ | ||
"src/PreLiquidation.sol" | ||
], | ||
"solc": "solc-0.8.27", | ||
"solc_via_ir": true, | ||
"verify": "PreLiquidation:certora/specs/Immutability.spec", | ||
"prover_args": [ | ||
"-depth 3", | ||
"-mediumTimeout 20", | ||
"-timeout 120" | ||
], | ||
"rule_sanity": "basic", | ||
"server": "production", | ||
"msg": "PreLiquidation Immutability" | ||
} |
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,31 @@ | ||
{ | ||
"files": [ | ||
"src/PreLiquidation.sol", | ||
"lib/morpho-blue/src/Morpho.sol" | ||
], | ||
"link": [ | ||
"PreLiquidation:MORPHO=Morpho" | ||
], | ||
"parametric_contracts": [ | ||
"PreLiquidation" | ||
], | ||
"solc_via_ir": true, | ||
"verify": "PreLiquidation:certora/specs/Liveness.spec", | ||
"solc_optimize_map": { | ||
"Morpho": "99999", | ||
"PreLiquidation": "99999" | ||
}, | ||
"solc_map": { | ||
"Morpho": "solc-0.8.19", | ||
"PreLiquidation": "solc-0.8.27" | ||
}, | ||
"prover_args": [ | ||
"-depth 3", | ||
"-mediumTimeout 20", | ||
"-timeout 120", | ||
"-smt_nonLinearArithmetic true" | ||
], | ||
"rule_sanity": "basic", | ||
"server": "production", | ||
"msg": "PreLiquidation Liveness" | ||
} |
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 |
---|---|---|
@@ -1,17 +1,17 @@ | ||
{ | ||
"files": [ | ||
"src/PreLiquidation.sol", | ||
], | ||
"solc": "solc-0.8.27", | ||
"solc_via_ir" : true, | ||
"verify": "PreLiquidation:certora/specs/Reentrancy.spec", | ||
"prover_args": [ | ||
"-enableStorageSplitting false", | ||
"-depth 3", | ||
"-mediumTimeout 20", | ||
"-timeout 120", | ||
], | ||
"rule_sanity": "basic", | ||
"server": "production", | ||
"msg": "PreLiquidation Reentrancy", | ||
"files": [ | ||
"src/PreLiquidation.sol" | ||
], | ||
"solc": "solc-0.8.27", | ||
"solc_via_ir": true, | ||
"verify": "PreLiquidation:certora/specs/Reentrancy.spec", | ||
"prover_args": [ | ||
"-enableStorageSplitting false", | ||
"-depth 3", | ||
"-mediumTimeout 20", | ||
"-timeout 120" | ||
], | ||
"rule_sanity": "basic", | ||
"server": "production", | ||
"msg": "PreLiquidation Reentrancy" | ||
} |
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,56 @@ | ||
// SPDX-License-Identifier: GPL-2.0-or-later | ||
|
||
// True when `preLiquidate` has been called. | ||
persistent ghost bool preLiquidateCalled; | ||
|
||
// True when `onMorphoRepay` has been called. | ||
persistent ghost bool onMorphoRepayCalled; | ||
|
||
hook CALL(uint g, address addr, uint value, uint argsOffset, uint argsLength, uint retOffset, uint retLength) uint rc { | ||
if (selector == sig:preLiquidate(address, uint256, uint256, bytes).selector) { | ||
preLiquidateCalled = true; | ||
} else if (selector == sig:onMorphoRepay(uint256, bytes).selector) { | ||
onMorphoRepayCalled = true; | ||
} | ||
} | ||
|
||
// Check that pre-liquidations happen if and only if `onMorphoRepay` is called. | ||
rule preLiquidateRepays(method f, env e, calldataarg data) { | ||
// Set up the initial state. | ||
require !preLiquidateCalled; | ||
require !onMorphoRepayCalled; | ||
|
||
// Safe require because Morpho cannot send transactions. | ||
require e.msg.sender != currentContract.MORPHO; | ||
// Capture the first method call which is not performed with a CALL opcode. | ||
if (f.selector == sig:preLiquidate(address, uint256, uint256, bytes).selector) { | ||
preLiquidateCalled = true; | ||
} else if (f.selector == sig:onMorphoRepay(uint256, bytes).selector) { | ||
onMorphoRepayCalled = true; | ||
} | ||
|
||
f@withrevert(e,data); | ||
|
||
// Avoid failing vacuity checks, either the proposition is true or the execution reverts. | ||
assert !lastReverted => (preLiquidateCalled <=> onMorphoRepayCalled); | ||
} | ||
// Check that you can pre-liquidate non-zero tokens by passing shares. | ||
rule canPreLiquidateByPassingShares(env e, address borrower, uint256 repaidShares, bytes data) { | ||
uint256 seizedAssets; | ||
uint256 repaidAssets; | ||
seizedAssets, repaidAssets = preLiquidate(e, borrower, 0, repaidShares, data); | ||
|
||
satisfy seizedAssets != 0 && repaidAssets != 0; | ||
} | ||
|
||
// Check that you can pre-liquidate non-zero tokens by passing seized assets. | ||
rule canPreLiquidateByPassingSeizedAssets(env e, address borrower, uint256 seizedAssets, bytes data) { | ||
uint256 repaidAssets; | ||
_, repaidAssets = preLiquidate(e, borrower, seizedAssets, 0, data); | ||
|
||
satisfy repaidAssets != 0; | ||
} |
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
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
Oops, something went wrong.