Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
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
1 change: 1 addition & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ snapshots
report
src/dependencies
tests/mocks/JsonBindings.sol
.certora_internal/
10 changes: 3 additions & 7 deletions certora/conf/HubAccrueSupplyRate.conf
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,18 @@
"certora/harness/MathWrapper.sol"
],
"loop_iter": 3,
"msg": "HubAccrue supply rate",
"msg": "only fee diff",
"multi_assert_check": true,
"optimistic_loop": true,
"parametric_contracts": [
"HubHarness"
],
"prover_args": [
"-splitParallel",
"true",
"-dontStopAtFirstSplitTimeout",
"true"
" -destructiveOptimizations twostage -s [z3:def{randomSeed=1},z3:def{randomSeed=2},z3:def{randomSeed=3},z3:def{randomSeed=4},z3:def{randomSeed=5},z3:def{randomSeed=6},z3:def{randomSeed=7},z3:def{randomSeed=8},z3:def{randomSeed=9},z3:def{randomSeed=10}]"
],
"rule": [
"unrealizedFeeSharesSupplyRate"
"previewRemoveByShares_time_monotonic"
],
// no need for sanity check as the rule ends in a satisfy command
"rule_sanity": "none",
"smt_timeout": 7200,
"solc_via_ir": true,
Expand Down
4 changes: 2 additions & 2 deletions certora/harness/HubHarness.sol
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ contract HubHarness is Hub {
function accrueInterest(uint256 assetId) external {
Asset storage asset = _assets[assetId];

asset.accrue(_spokes, assetId);
asset.accrue();
}

function toSharesDown(
Expand Down Expand Up @@ -55,6 +55,6 @@ contract HubHarness is Hub {

function unrealizedFeeShares(uint256 assetId) external view returns (uint256) {
Asset storage asset = _assets[assetId];
return asset.unrealizedFeeShares();
return asset.feeShares;
}
}
36 changes: 36 additions & 0 deletions certora/spec/HubAccrueSupplyRate.spec
Original file line number Diff line number Diff line change
Expand Up @@ -79,3 +79,39 @@ rule unrealizedFeeSharesSupplyRate(uint256 assetId){

}

rule previewRemoveByShares_time_monotonic(uint256 assetId, uint256 shares){
env e1; env e2; env e3;
uint256 oneM = 1000000;
require e1.block.timestamp < e2.block.timestamp && e2.block.timestamp < e3.block.timestamp;

require hub._assets[assetId].lastUpdateTimestamp!=0 && hub._assets[assetId].lastUpdateTimestamp == e1.block.timestamp;

//correlate the drawn index with the symbolic one, assume increasing and min value as proved in
// HubAccrueIntegrityDrawnIndex.spec
require hub._assets[assetId].drawnIndex == symbolicDrawnIndex(e1.block.timestamp);
//based on rule drawnIndex_increasing(assetId);
require symbolicDrawnIndex(e1.block.timestamp) <= symbolicDrawnIndex(e2.block.timestamp);
require symbolicDrawnIndex(e2.block.timestamp) <= symbolicDrawnIndex(e3.block.timestamp);
//based on requireInvariant baseDebtIndexMin(assetId);
require symbolicDrawnIndex(e1.block.timestamp) >= wadRayMath.RAY();
require symbolicDrawnIndex(e3.block.timestamp) <= wadRayMath.RAY() * 2;


mathint assets_e1 = getAddedAssets(e1, assetId);
mathint shares_e1 = hub._assets[assetId].addedShares;
//requireInvariant totalAssetsVsShares(assetId,e);
require assets_e1 >= shares_e1 ;

// get the fee shares and asset at e2
uint256 feeShares_e2 = unrealizedFeeShares(e2,assetId);
mathint assets_e2 = getAddedAssets(e2, assetId);
mathint shares_e2 = getAddedShares(e2, assetId);

// get the fee shares and asset at e2
uint256 feeShares_e3 = unrealizedFeeShares(e3,assetId);
mathint assets_e3 = getAddedAssets(e3, assetId);
mathint shares_e3 = getAddedShares(e3, assetId);
assert feeShares_e2 <= feeShares_e3;

assert (assets_e3 + oneM) * (shares_e2 + oneM) >= (assets_e2 + oneM) * (shares_e3 + oneM);
}
24 changes: 12 additions & 12 deletions snapshots/Hub.Operations.json
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
{
"add": "113832",
"draw": "122026",
"eliminateDeficit: full": "57818",
"eliminateDeficit: partial": "67394",
"payFee": "73744",
"refreshPremium": "96823",
"remove: full": "75059",
"remove: partial": "80306",
"reportDeficit": "118722",
"restore: full": "97460",
"restore: partial": "110890",
"transferShares": "79425"
"add": "115905",
"draw": "136122",
"eliminateDeficit: full": "59894",
"eliminateDeficit: partial": "69470",
"payFee": "104887",
"refreshPremium": "96807",
"remove: full": "89351",
"remove: partial": "82477",
"reportDeficit": "145071",
"restore: full": "109509",
"restore: partial": "140039",
"transferShares": "88677"
}
8 changes: 4 additions & 4 deletions snapshots/Spoke.Getters.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"getUserAccountData: supplies: 0, borrows: 0": "12164",
"getUserAccountData: supplies: 1, borrows: 0": "47260",
"getUserAccountData: supplies: 2, borrows: 0": "77471",
"getUserAccountData: supplies: 2, borrows: 1": "98212",
"getUserAccountData: supplies: 2, borrows: 2": "117607"
"getUserAccountData: supplies: 1, borrows: 0": "49358",
"getUserAccountData: supplies: 2, borrows: 0": "81667",
"getUserAccountData: supplies: 2, borrows: 1": "102408",
"getUserAccountData: supplies: 2, borrows: 2": "121803"
}
46 changes: 23 additions & 23 deletions snapshots/Spoke.Operations.ZeroRiskPremium.json
Original file line number Diff line number Diff line change
@@ -1,32 +1,32 @@
{
"borrow: first": "198976",
"borrow: second action, same reserve": "179497",
"liquidationCall: full": "291027",
"liquidationCall: partial": "315121",
"permitReserve + repay (multicall)": "235530",
"permitReserve + supply (multicall)": "140910",
"permitReserve + supply + enable collateral (multicall)": "176141",
"repay: full": "151572",
"repay: partial": "176035",
"borrow: first": "230223",
"borrow: second action, same reserve": "193644",
"liquidationCall: full": "293534",
"liquidationCall: partial": "358923",
"permitReserve + repay (multicall)": "266777",
"permitReserve + supply (multicall)": "142983",
"permitReserve + supply + enable collateral (multicall)": "190335",
"repay: full": "153645",
"repay: partial": "178108",
"setUserPositionManagerWithSig: disable": "44918",
"setUserPositionManagerWithSig: enable": "68947",
"supply + enable collateral (multicall)": "154083",
"supply: 0 borrows, collateral disabled": "115722",
"supply: 0 borrows, collateral enabled": "120119",
"supply: 1 borrow": "120111",
"supply: second action, same reserve": "103019",
"supply + enable collateral (multicall)": "168277",
"supply: 0 borrows, collateral disabled": "117795",
"supply: 0 borrows, collateral enabled": "134313",
"supply: 1 borrow": "134305",
"supply: second action, same reserve": "117213",
"updateUserDynamicConfig: 1 collateral": "73761",
"updateUserDynamicConfig: 2 collaterals": "88621",
"updateUserRiskPremium: 1 borrow": "95282",
"updateUserRiskPremium: 2 borrows": "111374",
"updateUserRiskPremium: 1 borrow": "97380",
"updateUserRiskPremium: 2 borrows": "110677",
"usingAsCollateral: 0 borrows, enable": "58976",
"usingAsCollateral: 1 borrow, disable": "105529",
"usingAsCollateral: 1 borrow, disable": "107627",
"usingAsCollateral: 1 borrow, enable": "32298",
"usingAsCollateral: 2 borrows, disable": "127994",
"usingAsCollateral: 2 borrows, disable": "130092",
"usingAsCollateral: 2 borrows, enable": "41876",
"withdraw: 0 borrows, full": "127680",
"withdraw: 0 borrows, partial": "132727",
"withdraw: 1 borrow, partial": "161709",
"withdraw: 2 borrows, partial": "184162",
"withdraw: non collateral": "126789"
"withdraw: 0 borrows, full": "142070",
"withdraw: 0 borrows, partial": "135094",
"withdraw: 1 borrow, partial": "176197",
"withdraw: 2 borrows, partial": "198650",
"withdraw: non collateral": "136337"
}
46 changes: 23 additions & 23 deletions snapshots/Spoke.Operations.json
Original file line number Diff line number Diff line change
@@ -1,32 +1,32 @@
{
"borrow: first": "269145",
"borrow: second action, same reserve": "212666",
"liquidationCall: full": "324413",
"liquidationCall: partial": "348507",
"permitReserve + repay (multicall)": "268909",
"permitReserve + supply (multicall)": "140910",
"permitReserve + supply + enable collateral (multicall)": "176141",
"repay: full": "146213",
"repay: partial": "209414",
"borrow: first": "300376",
"borrow: second action, same reserve": "226797",
"liquidationCall: full": "326904",
"liquidationCall: partial": "392293",
"permitReserve + repay (multicall)": "300140",
"permitReserve + supply (multicall)": "142983",
"permitReserve + supply + enable collateral (multicall)": "190335",
"repay: full": "148286",
"repay: partial": "211471",
"setUserPositionManagerWithSig: disable": "44918",
"setUserPositionManagerWithSig: enable": "68947",
"supply + enable collateral (multicall)": "154083",
"supply: 0 borrows, collateral disabled": "115722",
"supply: 0 borrows, collateral enabled": "120119",
"supply: 1 borrow": "120111",
"supply: second action, same reserve": "103019",
"supply + enable collateral (multicall)": "168277",
"supply: 0 borrows, collateral disabled": "117795",
"supply: 0 borrows, collateral enabled": "134313",
"supply: 1 borrow": "134305",
"supply: second action, same reserve": "117213",
"updateUserDynamicConfig: 1 collateral": "73761",
"updateUserDynamicConfig: 2 collaterals": "88621",
"updateUserRiskPremium: 1 borrow": "177369",
"updateUserRiskPremium: 2 borrows": "262734",
"updateUserRiskPremium: 1 borrow": "205825",
"updateUserRiskPremium: 2 borrows": "295653",
"usingAsCollateral: 0 borrows, enable": "58976",
"usingAsCollateral: 1 borrow, disable": "187616",
"usingAsCollateral: 1 borrow, disable": "216072",
"usingAsCollateral: 1 borrow, enable": "32298",
"usingAsCollateral: 2 borrows, disable": "287353",
"usingAsCollateral: 2 borrows, disable": "325067",
"usingAsCollateral: 2 borrows, enable": "41876",
"withdraw: 0 borrows, full": "127680",
"withdraw: 0 borrows, partial": "132727",
"withdraw: 1 borrow, partial": "241296",
"withdraw: 2 borrows, partial": "341022",
"withdraw: non collateral": "126789"
"withdraw: 0 borrows, full": "142070",
"withdraw: 0 borrows, partial": "135094",
"withdraw: 1 borrow, partial": "282142",
"withdraw: 2 borrows, partial": "391126",
"withdraw: non collateral": "136337"
}
Loading