Skip to content
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

[Certora] Dev #136

Merged
merged 285 commits into from
Dec 1, 2023
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
Show all changes
285 commits
Select commit Hold shift + click to select a range
31b9133
Merge pull request #304 from morpho-labs/certora/liquiditywip
jhoenicke Aug 15, 2023
e46fd73
chore: add blue ratio math summary to CI
QGarchery Aug 15, 2023
7cd9d1e
Merge pull request #315 from morpho-labs/certora/update-ci
jhoenicke Aug 16, 2023
898abf9
feat: add withdraw and withdrawCollateral exit liquidity
QGarchery Aug 16, 2023
b696596
feat: repay liquidity
QGarchery Aug 16, 2023
80ee464
refactor: remove unnecessary method declaration
QGarchery Aug 16, 2023
f4a744c
Merge pull request #316 from morpho-labs/certora/exit-liquidity
QGarchery Aug 16, 2023
b347891
Reentrancy specification.
jhoenicke Aug 16, 2023
520b150
Check for no delegate calls, add workflow
jhoenicke Aug 16, 2023
80458ea
feat: add dispatch for tokens
QGarchery Aug 16, 2023
845984d
workaround a bug in prover
jhoenicke Aug 16, 2023
db4503c
Merge pull request #325 from morpho-labs/certora/reentrancy
QGarchery Aug 16, 2023
e502109
feat: add verification of summary for transfers
QGarchery Aug 16, 2023
41aca52
feat: add transfer summary to the CI
QGarchery Aug 16, 2023
f201437
Merge remote-tracking branch 'origin/certora/dev' into certora/dispat…
QGarchery Aug 16, 2023
9229f3c
fix: install dependencies in CI
QGarchery Aug 16, 2023
ffc7844
fix: change name to TransferHarness
QGarchery Aug 16, 2023
87eff1c
Merge remote-tracking branch 'origin/main' into certora/dev
QGarchery Aug 17, 2023
dcb6cbd
chore: move to certora-cli-beta in the CI
QGarchery Aug 17, 2023
7125c7d
refactor: simplify transfer summary check
QGarchery Aug 17, 2023
9739986
fix: cast balance to mathint
QGarchery Aug 17, 2023
5b9dc63
feat: add dispatch token not reverting and returning a boolean
QGarchery Aug 17, 2023
e0a9b50
refactor: rename transfer to not only verify summary
QGarchery Aug 17, 2023
12e2261
Merge pull request #321 from morpho-labs/certora/dispatch-tokens
QGarchery Aug 17, 2023
9a3cd0e
Merge pull request #339 from morpho-labs/certora/ci-beta
QGarchery Aug 17, 2023
21fdad0
Specification to check isHealthy
jhoenicke Aug 15, 2023
08e0f30
Verify that Supply/Withdraw roundtrip is not profitable.
jhoenicke Aug 16, 2023
c0df5f7
Added script to workflow
jhoenicke Aug 17, 2023
edec6b4
Merge pull request #345 from morpho-labs/certora/roundtrip
QGarchery Aug 17, 2023
43b0df3
feat: more thorough verification of the transfer lib
QGarchery Aug 17, 2023
e52b3ce
Add missing totalSupply function.
jhoenicke Aug 17, 2023
c6f4614
Add totalSupply to USDT, some linting.
jhoenicke Aug 17, 2023
2ee608d
Merge pull request #344 from morpho-labs/certora/healthy
QGarchery Aug 17, 2023
8cf9559
Merge pull request #346 from morpho-labs/certora/transfer-unit
QGarchery Aug 17, 2023
df8e27f
More generic rules
jhoenicke Aug 16, 2023
f3fc707
Rule for withdrawing everything
jhoenicke Aug 17, 2023
d17bd5a
Merge pull request #348 from morpho-labs/certora/morerules
jhoenicke Aug 18, 2023
35531ea
Remove doubled line
jhoenicke Aug 18, 2023
0fd1de5
Merge pull request #352 from morpho-labs/certora/morerules
jhoenicke Aug 18, 2023
d35e97a
Added rule for borrow ratio
jhoenicke Aug 15, 2023
01fa73c
Add a summary for accrueInterests
jhoenicke Aug 17, 2023
2f9caca
Split verification of ratio increases in two parts
jhoenicke Aug 18, 2023
cfc6cf7
Do not remove solc allowed path
jhoenicke Aug 18, 2023
d451a30
feat: add validation and revert conditions on all functions
QGarchery Aug 18, 2023
5d5df6c
fix: revert of enable IRM and set fee
QGarchery Aug 18, 2023
4d1ac12
fix: set fee validation use last call to check revert
QGarchery Aug 18, 2023
f2c0507
style: start committing to one format
QGarchery Aug 18, 2023
a444b0f
Merge branch 'certora/dev' into certora/reverts
QGarchery Aug 18, 2023
1ae114e
fix: rename isCreated missed
QGarchery Aug 18, 2023
fd00f20
Merge pull request #353 from morpho-labs/certora/shareratio
QGarchery Aug 18, 2023
299edf7
Merge pull request #358 from morpho-labs/certora/reverts
QGarchery Aug 18, 2023
5ec5169
Merge remote-tracking branch 'origin/main' into certora/update-dev
QGarchery Aug 19, 2023
c9bff6d
feat: add every script to the CI
QGarchery Aug 19, 2023
b5a22c9
Merge remote-tracking branch 'origin/main' into certora/update-dev
QGarchery Aug 19, 2023
b4d7bf8
fix: adapt to renaming and storage refactor
QGarchery Aug 19, 2023
daa6a3b
fix: update in verifyReverts
QGarchery Aug 20, 2023
1332140
fix: reentrancy check
QGarchery Aug 20, 2023
4abca55
chore: remove extSloads for now
QGarchery Aug 23, 2023
b902feb
Merge remote-tracking branch 'origin/main' into certora/update-dev
QGarchery Aug 23, 2023
d425b71
fix: merge fix and remove extSloads
QGarchery Aug 23, 2023
af78edf
chore: certora ci to 0.8.19
QGarchery Aug 23, 2023
bb3f0bc
fix: update reverts specs
QGarchery Aug 23, 2023
fe3bbf9
fix: blue ratio math update
QGarchery Aug 23, 2023
f2ea7d8
refactor: remove allowance of USDC in NoRevert token
QGarchery Aug 23, 2023
7869482
New spec for checking commutativity of accrueInterests
jhoenicke Aug 23, 2023
4e2062a
Check revert-equivalence
jhoenicke Aug 23, 2023
ebacb12
feat: adding always collateralized invariant
QGarchery Aug 23, 2023
740266b
Fix spec file name
jhoenicke Aug 23, 2023
27bcba4
Merge remote-tracking branch 'origin/main' into certora/update-dev
QGarchery Aug 23, 2023
9281c47
chore: remove extSloads
QGarchery Aug 23, 2023
c410a21
Merge pull request #427 from morpho-labs/certora/jochen
QGarchery Aug 23, 2023
0e741d5
Merge remote-tracking branch 'origin/main' into certora/update-dev
QGarchery Aug 24, 2023
1de8b40
Merge remote-tracking branch 'origin/fix/compilation-liquidate' into …
QGarchery Aug 24, 2023
2059555
fix: update to new liquidate signature
QGarchery Aug 24, 2023
e742a36
fix: remove via IR compilation for now
QGarchery Aug 24, 2023
e52ecdd
fix: require denominator 0
QGarchery Aug 24, 2023
90392ed
fix: seized renaming
QGarchery Aug 24, 2023
8aebfd4
fix: liquidate input validation
QGarchery Aug 24, 2023
2733de7
fix: adapt borrowRate signature
QGarchery Aug 24, 2023
755b012
Added option plaininjectivity
jhoenicke Aug 24, 2023
e4a8ad3
Merge pull request #442 from morpho-labs/certora/plaininjectivity
QGarchery Aug 24, 2023
bd98c55
Merge remote-tracking branch 'origin/main' into certora/dev
QGarchery Aug 24, 2023
21f5cc8
Merge remote-tracking branch 'origin/certora/dev' into certora/update…
QGarchery Aug 24, 2023
ecf5226
fix: rename user to position
QGarchery Aug 24, 2023
8fb896b
fix: marketParams renaming for accrue interest
QGarchery Aug 24, 2023
00e2415
fix: rename accrueInterest
QGarchery Aug 24, 2023
b33db92
chore: munging of market params lib
QGarchery Aug 25, 2023
a49d137
fix: spelling marketParams
QGarchery Aug 25, 2023
7e83331
fix: borrow rate parameters
QGarchery Aug 25, 2023
b8538fe
fix: timestamp overflow
QGarchery Aug 25, 2023
e04c732
Merge remote-tracking branch 'origin/fix/underflow' into certora/upda…
QGarchery Aug 28, 2023
4fe8cce
fix: adapt borrow ratio spec to the underflow change
QGarchery Aug 28, 2023
ca63f5d
fix: repay stay healthy (times out)
QGarchery Aug 28, 2023
6b20024
fix: remove time-outs
QGarchery Aug 29, 2023
735ee4f
Merge remote-tracking branch 'origin/main' into certora/update-dev
QGarchery Aug 29, 2023
4197eed
Merge remote-tracking branch 'origin/main' into certora/check-underflow
QGarchery Aug 29, 2023
5571a6d
Merge remote-tracking branch 'origin/main' into certora/dev
QGarchery Aug 29, 2023
8afbc96
Merge branch 'certora/update-dev' into certora/check-underflow
QGarchery Aug 29, 2023
d9bab7f
Merge pull request #447 from morpho-labs/certora/check-underflow
QGarchery Aug 29, 2023
f3aa509
Merge remote-tracking branch 'origin/certora/dev' into certora/update…
QGarchery Aug 29, 2023
c3627e3
Merge pull request #373 from morpho-labs/certora/update-dev
QGarchery Aug 29, 2023
9593236
feat: use munging
QGarchery Aug 29, 2023
72336fd
Merge pull request #450 from morpho-labs/certora/munging
QGarchery Aug 29, 2023
e066c47
feat: exit liveness
QGarchery Aug 29, 2023
f76a90c
chore: add liveness to the CI
QGarchery Aug 29, 2023
272ee06
fix: remove useless return value, simplify non det interest
QGarchery Aug 30, 2023
43397a3
fix: remove extSloads munging
QGarchery Aug 30, 2023
029b974
chore: remove canRepayAll rule for now
QGarchery Aug 30, 2023
ecad5e1
Merge pull request #451 from morpho-labs/certora/liveness
QGarchery Aug 30, 2023
c3ba07a
Merge pull request #458 from morpho-labs/certora/remove-sload-munging
QGarchery Aug 30, 2023
fbea389
docs: renaming and documentation of the rules
QGarchery Aug 31, 2023
2f489aa
chore: update scripts run by the CI
QGarchery Aug 31, 2023
d7476a2
fix: typos
QGarchery Aug 31, 2023
6b7ea58
style: rename harness functions, add license
QGarchery Aug 31, 2023
4063fd2
fix: renaming typos
QGarchery Aug 31, 2023
b1e88f1
chore: send all jobs at the start
QGarchery Aug 31, 2023
b6c2b0a
fix: repay decreases borrow ratio
QGarchery Aug 31, 2023
eaaeb4b
fix: timeout on repayDecreasesBorrowRatio
QGarchery Sep 1, 2023
96a3391
docs: add comment back
QGarchery Sep 1, 2023
26f790e
Merge pull request #461 from morpho-labs/certora/cleaning
QGarchery Sep 1, 2023
c8bfa56
chore: license for the whole certora folder
QGarchery Sep 1, 2023
66db270
chore: explicit import in ERC20Standard
QGarchery Sep 1, 2023
770e1c2
refactor: use munged files consistently
QGarchery Sep 1, 2023
c98b4fb
remove optimistic_loop option
jhoenicke Sep 3, 2023
197257c
feat: start documentation
QGarchery Sep 5, 2023
75dcf22
docs: complete files description
QGarchery Sep 5, 2023
f138fe3
fix: safe transfer library functions names
QGarchery Sep 5, 2023
662904d
feat: finish high level description
QGarchery Sep 5, 2023
6981f8e
fix: grammar check on README
QGarchery Sep 5, 2023
6b4107a
docs: minor tweaks
QGarchery Sep 5, 2023
5c6911c
fix: from review
QGarchery Sep 5, 2023
5325441
docs: add title to the high level description
QGarchery Sep 5, 2023
c04151a
fix: small rewording
QGarchery Sep 5, 2023
7d0d5f6
docs: more explicity comment about health after an interaction
QGarchery Sep 5, 2023
3623610
Merge pull request #465 from morpho-labs/certora/docs
QGarchery Sep 6, 2023
c928547
feat: complete liveness for all the main functions
QGarchery Sep 7, 2023
269f610
Merge pull request #467 from morpho-labs/certora/complete-liveness
QGarchery Sep 7, 2023
2f64b48
docs: improve revert documentation
QGarchery Sep 7, 2023
3e5e785
feat: remove unnecessary require in stayHealthy
QGarchery Sep 7, 2023
3f60a51
Merge pull request #468 from morpho-labs/certora/improve-revert-docum…
QGarchery Sep 8, 2023
7ab7047
Merge pull request #469 from morpho-labs/certora/remove-require-healthy
QGarchery Sep 8, 2023
fa02076
refactor: remove unnecessary storage variables in tokens
QGarchery Sep 11, 2023
3a3b75c
refactor: remove unecessary allow path
QGarchery Sep 11, 2023
c5bf5cb
Merge pull request #471 from morpho-labs/certora/mathis-review-fixes
QGarchery Sep 12, 2023
bd70670
Merge pull request #472 from morpho-labs/certora/improve-scripts
QGarchery Sep 13, 2023
3b180c4
chore: increase timeout on split to 12 sec
QGarchery Sep 13, 2023
c4b656b
Merge pull request #473 from morpho-labs/certora/fix-timeout-exactmath
QGarchery Sep 13, 2023
5a611ff
refactor: remove unused oracle in Certora script
QGarchery Sep 13, 2023
2a9ca79
feat: verify the id function summary
QGarchery Sep 15, 2023
8fb8449
Merge pull request #491 from morpho-labs/certora/check-id-summary
QGarchery Sep 15, 2023
3e1e213
feat: enable verification of the canRepayAll rule
QGarchery Sep 15, 2023
c548f84
refactor: document and clean the Reentrancy file
QGarchery Sep 15, 2023
56742c8
Merge pull request #492 from morpho-labs/certora/repay-all
QGarchery Sep 15, 2023
9b3f24e
refactor: remove outdated comments
QGarchery Sep 15, 2023
b3c7038
feat: remove munging
QGarchery Sep 15, 2023
73ad72d
feat: use summary of id in liveness
QGarchery Sep 15, 2023
602804d
refactor: actual removal of munging files
QGarchery Sep 16, 2023
c9142fd
refactor: remove summary id on ExactMath
QGarchery Sep 16, 2023
b8680ae
increase medium timeout to 30
Sep 20, 2023
abc93ac
Merge pull request #494 from morpho-labs/certora/remove-munging
QGarchery Sep 20, 2023
69ee160
perf: plain injectivity setting for health script
QGarchery Sep 21, 2023
6ee4bf0
Merge pull request #505 from morpho-labs/certora/script-perf
QGarchery Sep 21, 2023
d8d1fc2
Merge remote-tracking branch 'origin/main' into certora/dev
QGarchery Oct 12, 2023
1dc07bd
fix: rename borrowableToken into loanToken
QGarchery Oct 12, 2023
0783ddb
refactor: remove OZ dependency in dispatch
QGarchery Oct 12, 2023
a6b4667
docs: certora documentation layout
QGarchery Oct 6, 2023
b4271a2
docs: certora documentation of transfers
QGarchery Oct 12, 2023
f754980
docs: certora documentation of markets
QGarchery Oct 12, 2023
375a86b
docs: certora documentation of shares
QGarchery Oct 12, 2023
8a4d786
docs: certora documentation of health
QGarchery Oct 13, 2023
b90cdb2
docs: certora documentation of authorization
QGarchery Oct 13, 2023
a32acdb
docs: certora documentation of other safety properties
QGarchery Oct 13, 2023
35de6cf
docs: certora documentation of liveness properties
QGarchery Oct 13, 2023
e4aca4c
docs: certora documentation of protection against common attack vectors
QGarchery Oct 13, 2023
d7f4f95
feat: use configuration file instead of script
QGarchery Oct 17, 2023
ac88f34
fix: use conf matrix
QGarchery Oct 17, 2023
2f8d601
fix: remove unused script row
QGarchery Oct 17, 2023
defa1e7
chore: switch to certora-cli
QGarchery Oct 17, 2023
473e750
feat: add every script as a configuration file
QGarchery Oct 17, 2023
88c1739
fix: add missing extension on configuration files
QGarchery Oct 17, 2023
093bcd2
refactor: order parameters in configuration files
QGarchery Oct 17, 2023
80995c8
fix: missing comma
QGarchery Oct 17, 2023
6204fa5
Merge pull request #538 from morpho-org/certora/documentation
QGarchery Oct 17, 2023
0a089af
Merge pull request #545 from morpho-org/certora/configuration-files
QGarchery Oct 17, 2023
dfe4834
docs: update README to configuration files
QGarchery Oct 18, 2023
0ff92f8
refactor: missing refactor of LibSummary.conf
QGarchery Oct 19, 2023
610719a
Merge remote-tracking branch 'origin/main' into certora/dev
QGarchery Nov 21, 2023
f914b28
fix: remove unnecessary accrueInterest harness function
QGarchery Nov 21, 2023
b787286
refactor: harness visibility to external
QGarchery Nov 21, 2023
c11af7c
fix: precendence of equality and equivalence
QGarchery Nov 21, 2023
526b2de
chore: increase timeout for ratio math
QGarchery Nov 21, 2023
f5dd194
fix: increase timeout for RatioMath
QGarchery Nov 21, 2023
6c99282
chore: update to v5 DELETE syntax
QGarchery Nov 21, 2023
f196ce0
feat: add basic sanity checks
QGarchery Nov 21, 2023
4b915f1
Merge pull request #600 from morpho-org/certora/update-v5
QGarchery Nov 21, 2023
84d206c
Merge pull request #599 from morpho-org/certora/sanity
QGarchery Nov 21, 2023
d6524d9
refactor: rename configuration folder to confs
QGarchery Nov 21, 2023
e58b8a2
fix: update CI path to CVL conf files
QGarchery Nov 22, 2023
8106624
feat: add gambit initial configuration
QGarchery Nov 21, 2023
d5c7303
fix: remove breaking solc version
QGarchery Oct 31, 2023
766667f
test: mutant 2
QGarchery Nov 22, 2023
744d0ff
test: mutant 3
QGarchery Nov 22, 2023
e445aaf
test: mutant 6
QGarchery Nov 22, 2023
9eba54d
test: mutant 10
QGarchery Nov 22, 2023
d21a86f
test: mutant 13
QGarchery Nov 22, 2023
de3147c
feat: respecting non-zero input
QGarchery Nov 23, 2023
0ef14b5
Revert "test: mutant 2"
QGarchery Nov 23, 2023
57a648a
Merge pull request #617 from morpho-org/certora/mutant-2
QGarchery Nov 23, 2023
957d61c
feat: test liquidity in liveness
QGarchery Nov 23, 2023
04f0c4b
refactor: improving mutant to get significant result
QGarchery Nov 23, 2023
c4306f1
feat: accrue interest input validation
QGarchery Nov 23, 2023
c25947a
revert: test mutant 13
QGarchery Nov 23, 2023
7d1a1c2
feat: improving coverage of liquidity check in repay liveness
QGarchery Nov 23, 2023
0abb423
Merge pull request #606 from morpho-org/certora/mutant-13
QGarchery Nov 23, 2023
bb6d9bb
revert: mutant 6
QGarchery Nov 23, 2023
4b5116a
Merge pull request #613 from morpho-org/certora/mutant-6
QGarchery Nov 23, 2023
4d1a18a
Merge remote-tracking branch 'origin/certora/gambit' into certora/mut…
QGarchery Nov 23, 2023
3e22f7c
feat: added liveness for liquidate
QGarchery Nov 23, 2023
641a6f1
test: mutant 12
QGarchery Nov 22, 2023
75025b0
feat: add setAuthorizationWithSig liveness and input validation
QGarchery Nov 23, 2023
033670c
fix: repaidShares input in liquidation
QGarchery Nov 23, 2023
d76c9f4
fix: revert condition setAuthorizationWithSig
QGarchery Nov 23, 2023
2aac61f
fix: liquidate liveness only in case loan and collateral are different
QGarchery Nov 23, 2023
35eb09a
Revert "test: mutant 10"
QGarchery Nov 23, 2023
f5c34bd
Revert "test: mutant 12"
QGarchery Nov 23, 2023
5753c9f
feat: can use shares properties
QGarchery Nov 23, 2023
2a0028f
Merge pull request #609 from morpho-org/certora/mutant-10
QGarchery Nov 24, 2023
166ea99
Merge remote-tracking branch 'origin/certora/gambit' into certora/mut…
QGarchery Nov 24, 2023
87d55a6
Revert "test: mutant 3"
QGarchery Nov 24, 2023
434df02
Merge pull request #616 from morpho-org/certora/mutant-3
QGarchery Nov 24, 2023
9f80ff1
Merge pull request #607 from morpho-org/certora/mutant-12
QGarchery Nov 24, 2023
dfc58ad
docs: update certora/README.md with mutations
QGarchery Nov 24, 2023
2a137a8
Merge pull request #564 from morpho-org/certora/gambit
QGarchery Nov 27, 2023
3e4f205
refactor: roundtrip with arbitrary amounts
QGarchery Nov 22, 2023
c2522fa
refactor: remove Transfer address 0 case
QGarchery Nov 30, 2023
193c8c9
refactor: use isCreated function
QGarchery Nov 30, 2023
6699854
feat: receiver 0 input validation
QGarchery Nov 30, 2023
9449ba7
docs: clarify Reentrancy
QGarchery Nov 30, 2023
46c66c9
docs: clarify ExitLiquidity owned/owed
QGarchery Nov 30, 2023
5870024
docs: alwaysCollateralized comment
QGarchery Nov 30, 2023
ff35479
refactor: only check interest overflow on the supply
QGarchery Nov 30, 2023
d590bbe
fix: receiver parameter wrong place
QGarchery Nov 30, 2023
7e9a1b8
docs: small comment fix
QGarchery Nov 30, 2023
17d221d
feat: liveness liquidate by passing shares
QGarchery Nov 30, 2023
b8bc824
Merge pull request #620 from morpho-org/certora/suggestions-from-review
QGarchery Nov 30, 2023
2d5a8f6
Merge pull request #621 from morpho-org/certora/liquidate-liveness
QGarchery Nov 30, 2023
83f692f
fix: rules specification
QGarchery Nov 30, 2023
3646c4d
Merge pull request #619 from morpho-org/certora/refactor-exact-math
QGarchery Dec 1, 2023
c716556
Merge remote-tracking branch 'origin/main' into certora/dev
QGarchery Dec 1, 2023
c265b46
refactor: clean Certora CI
QGarchery Dec 1, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ docs/
# Node modules
/node_modules

# Certora
.certora**

# Hardhat
/types
/cache_hardhat
Expand Down
28 changes: 28 additions & 0 deletions certora/harness/MorphoHarness.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
pragma solidity 0.8.19;

import "../../src/Morpho.sol";
import "../../src/libraries/SharesMathLib.sol";

contract MorphoHarness is Morpho {
constructor(address newOwner) Morpho(newOwner) {}

function getVirtualTotalSupply(Id id) external view returns (uint256) {
return totalSupply[id] + SharesMathLib.VIRTUAL_ASSETS;
}

function getVirtualTotalSupplyShares(Id id) external view returns (uint256) {
return totalSupplyShares[id] + SharesMathLib.VIRTUAL_SHARES;
}

function getTotalSupply(Id id) external view returns (uint256) {
return totalSupply[id];
}

function getTotalSupplyShares(Id id) external view returns (uint256) {
return totalSupplyShares[id];
}

function getTotalBorrowShares(Id id) external view returns (uint256) {
return totalBorrowShares[id];
}
QGarchery marked this conversation as resolved.
Show resolved Hide resolved
}
11 changes: 11 additions & 0 deletions certora/scripts/verifyBlue.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/sh

certoraRun \
certora/harness/MorphoHarness.sol \
--verify MorphoHarness:certora/specs/Blue.spec \
--solc_allow_path src \
--loop_iter 3 \
--optimistic_loop \
--msg "Morpho Blue" \
--send_only \
"$@"
70 changes: 70 additions & 0 deletions certora/specs/Blue.spec
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
methods {
function supply(MorphoHarness.Market, uint256, uint256, address, bytes) external;
function getVirtualTotalSupply(MorphoHarness.Id) external returns uint256 envfree;
function getVirtualTotalSupplyShares(MorphoHarness.Id) external returns uint256 envfree;
function getTotalSupply(MorphoHarness.Id) external returns uint256 envfree;
function getTotalSupplyShares(MorphoHarness.Id) external returns uint256 envfree;
function getTotalBorrowShares(MorphoHarness.Id) external returns uint256 envfree;

function _.borrowRate(MorphoHarness.Market) external => DISPATCHER(true);

// function _.safeTransfer(address, uint256) internal => DISPATCHER(true);
// function _.safeTransferFrom(address, address, uint256) internal => DISPATCHER(true);
}

ghost mapping(MorphoHarness.Id => mathint) sumSupplyShares
{
init_state axiom (forall MorphoHarness.Id id. sumSupplyShares[id] == 0);
}
ghost mapping(MorphoHarness.Id => mathint) sumBorrowShares
{
init_state axiom (forall MorphoHarness.Id id. sumBorrowShares[id] == 0);
}
ghost mapping(MorphoHarness.Id => mathint) sumCollateral
{
init_state axiom (forall MorphoHarness.Id id. sumCollateral[id] == 0);
}

hook Sstore supplyShares[KEY MorphoHarness.Id id][KEY address owner] uint256 newShares (uint256 oldShares) STORAGE {
sumSupplyShares[id] = sumSupplyShares[id] - oldShares + newShares;
}

hook Sstore borrowShares[KEY MorphoHarness.Id id][KEY address owner] uint256 newShares (uint256 oldShares) STORAGE {
sumBorrowShares[id] = sumBorrowShares[id] - oldShares + newShares;
}

hook Sstore collateral[KEY MorphoHarness.Id id][KEY address owner] uint256 newAmount (uint256 oldAmount) STORAGE {
sumCollateral[id] = sumCollateral[id] - oldAmount + newAmount;
}

invariant sumSupplySharesCorrect(MorphoHarness.Id id)
to_mathint(getTotalSupplyShares(id)) == sumSupplyShares[id];
invariant sumBorrowSharesCorrect(MorphoHarness.Id id)
to_mathint(getTotalBorrowShares(id)) == sumBorrowShares[id];

rule whatDoesNotIncreaseRatio(MorphoHarness.Id id) {
mathint assetsBefore = getVirtualTotalSupply(id);
mathint sharesBefore = getVirtualTotalSupplyShares(id);

method f;
env e;
calldataarg args;

f(e,args);

mathint assetsAfter = getVirtualTotalSupply(id);
mathint sharesAfter = getVirtualTotalSupplyShares(id);

// check if assetsBefore/shareBefore <= assetsAfter / sharesAfter;
assert assetsBefore * sharesAfter <= assetsAfter * sharesBefore;
}


rule supplyRevertZero(MorphoHarness.Market market) {
env e;
bytes b;

supply@withrevert(e, market, 0, 0, e.msg.sender, b);

assert lastReverted;
}
2 changes: 1 addition & 1 deletion src/Morpho.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: UNLICENSED
pragma solidity 0.8.21;
pragma solidity 0.8.19;

import "./interfaces/IMorpho.sol";
import "./interfaces/IMorphoCallbacks.sol";
Expand Down