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

Run fundamental equation of DAI with cvl2 #4

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
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
18 changes: 9 additions & 9 deletions Vat.spec
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
// Vat.spec

methods {
debt() returns (uint256) envfree
vice() returns (uint256) envfree
function debt() external returns (uint256) envfree;
function vice() external returns (uint256) envfree;
}

ghost sumOfVaultDebtGhost() returns uint256 {
Expand All @@ -17,24 +17,24 @@ ghost mapping(bytes32 => uint256) ArtGhost {
init_state axiom forall bytes32 ilk. ArtGhost[ilk] == 0;
}

hook Sload uint256 v currentContract.ilks[KEY bytes32 ilk].(offset 0) STORAGE {
hook Sload uint256 v currentContract.ilks[KEY bytes32 ilk].(offset 0) {
require ArtGhost[ilk] == v;
}

hook Sstore currentContract.ilks[KEY bytes32 ilk].(offset 0) uint256 newArt (uint256 oldArt) STORAGE {
havoc sumOfVaultDebtGhost assuming sumOfVaultDebtGhost@new() == sumOfVaultDebtGhost@old() + (newArt * rateGhost[ilk]) - (oldArt * rateGhost[ilk]);
hook Sstore currentContract.ilks[KEY bytes32 ilk].(offset 0) uint256 newArt (uint256 oldArt) {
havoc sumOfVaultDebtGhost assuming sumOfVaultDebtGhost@new() == assert_uint256(sumOfVaultDebtGhost@old() + (newArt * rateGhost[ilk]) - (oldArt * rateGhost[ilk]));
ArtGhost[ilk] = newArt;
}

hook Sload uint256 v currentContract.ilks[KEY bytes32 ilk].(offset 32) STORAGE {
hook Sload uint256 v currentContract.ilks[KEY bytes32 ilk].(offset 32) {
require rateGhost[ilk] == v;
}

hook Sstore currentContract.ilks[KEY bytes32 ilk].(offset 32) uint256 newRate (uint256 oldRate) STORAGE {
havoc sumOfVaultDebtGhost assuming sumOfVaultDebtGhost@new() == sumOfVaultDebtGhost@old() + (ArtGhost[ilk] * newRate) - (ArtGhost[ilk] * oldRate);
hook Sstore currentContract.ilks[KEY bytes32 ilk].(offset 32) uint256 newRate (uint256 oldRate) {
havoc sumOfVaultDebtGhost assuming sumOfVaultDebtGhost@new() == assert_uint256(sumOfVaultDebtGhost@old() + (ArtGhost[ilk] * newRate) - (ArtGhost[ilk] * oldRate));
rateGhost[ilk] = newRate;
}

invariant fundamental_equation_of_dai()
debt() == vice() + sumOfVaultDebtGhost()
debt() == assert_uint256(vice() + sumOfVaultDebtGhost())
filtered { f -> !f.isFallback }