-
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.
- Loading branch information
1 parent
bd8889e
commit 65ab7ba
Showing
4 changed files
with
66 additions
and
10 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 |
---|---|---|
|
@@ -22,6 +22,7 @@ jobs: | |
- Liveness | ||
- Reentrancy | ||
- Reverts | ||
- SafeMath | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
|
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,11 @@ | ||
{ | ||
"files": [ | ||
"src/PreLiquidation.sol" | ||
], | ||
"solc_via_ir" : true, | ||
"solc": "solc-0.8.27", | ||
"verify": "PreLiquidation:certora/specs/SafeMath.spec", | ||
"rule_sanity": "basic", | ||
"server": "production", | ||
"msg": "PreLiquidation Safe Maths" | ||
} |
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,44 @@ | ||
// SPDX-License-Identifier: GPL-2.0-or-later | ||
|
||
definition WAD() returns uint256 = 10^18; | ||
|
||
function summaryWMulDown(uint256 x,uint256 y) returns uint256 { | ||
// Safe require because the reference implementation would revert. | ||
return require_uint256((x * y)/WAD()); | ||
} | ||
|
||
function summaryWDivUp(uint256 x,uint256 y) returns uint256 { | ||
// Safe require because the reference implementation would revert. | ||
return require_uint256((x * WAD() + (y-1)) / y); | ||
} | ||
|
||
|
||
// Check that LTV <= LLTV is equivalent to borrowed <= (collateralQuoted * LLTV) / WAD. | ||
rule borrowedLECollatQuotedTimesLLTVEqLtvLTEqLLTV { | ||
uint256 borrowed; | ||
uint256 collateralQuoted; | ||
|
||
// Safe require because the implementation would revert, see rule zeroCollateralQuotedReverts. | ||
require collateralQuoted > 0; | ||
|
||
mathint ltv = summaryWDivUp(borrowed, collateralQuoted); | ||
|
||
assert (ltv <= currentContract.LLTV) <=> borrowed <= summaryWMulDown(collateralQuoted, currentContract.LLTV); | ||
} | ||
|
||
// Check that substracting the PRE_LLTV to LTV wont underflow. | ||
rule ltvMinusPreLltvWontUnderflow { | ||
uint256 borrowed; | ||
uint256 collateralQuoted; | ||
uint256 preLltv; | ||
|
||
// Safe require because the implementation would revert, see rule zeroCollateralQuotedReverts. | ||
require (collateralQuoted > 0); | ||
|
||
// Safe require because the implementation would revert if borrowed threshold is not ensured. | ||
uint256 borrowThreshold = summaryWMulDown(collateralQuoted, preLltv); | ||
require (borrowed > borrowThreshold); | ||
|
||
uint256 ltv = summaryWDivUp(borrowed, collateralQuoted); | ||
assert ltv >= preLltv; | ||
} |