forked from aave/gho-core
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5 from Certora/check_variable_debt_token
Check variable debt token
- Loading branch information
Showing
6 changed files
with
153 additions
and
14 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
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,26 @@ | ||
pragma solidity 0.8.10; | ||
|
||
import {GhoVariableDebtTokenHarness} from './ghoVariableDebtTokenHarness.sol'; | ||
import {GhoVariableDebtToken} from '../munged/contracts/facilitators/aave/tokens/GhoVariableDebtToken.sol'; | ||
import {IPool} from '@aave/core-v3/contracts/interfaces/IPool.sol'; | ||
|
||
contract GhoVariableDebtTokenHarnessInternal is GhoVariableDebtTokenHarness { | ||
|
||
constructor(IPool pool) public GhoVariableDebtTokenHarness(pool) { | ||
//nop | ||
} | ||
|
||
function accrueDebtOnAction( | ||
address user, | ||
uint256 previousScaledBalance, | ||
uint256 discountPercent, | ||
uint256 index | ||
) external returns (uint256, uint256) { | ||
return _accrueDebtOnAction( | ||
user, | ||
previousScaledBalance, | ||
discountPercent, | ||
index | ||
); | ||
} | ||
} |
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,21 +1,21 @@ | ||
if (($# > 0)) | ||
then | ||
#if (($# > 0)) | ||
#then | ||
certoraRun certora/harness/GhoDiscountRateStrategyHarness.sol:GhoDiscountRateStrategyHarness \ | ||
--verify GhoDiscountRateStrategyHarness:certora/specs/ghoDiscountRateStrategy.spec \ | ||
--solc solc8.10 \ | ||
--loop_iter 2 \ | ||
--optimistic_loop \ | ||
--prover_args "-mediumTimeout 20 -depth 10" \ | ||
--smt_timeout 500 \ | ||
--rules "${@}" \ | ||
--msg "GhoDiscountRateStrategy, rules ${@}." | ||
else | ||
certoraRun certora/harness/GhoDiscountRateStrategyHarness.sol:GhoDiscountRateStrategyHarness \ | ||
--verify GhoDiscountRateStrategyHarness:certora/specs/ghoDiscountRateStrategy.spec \ | ||
--solc solc8.10 \ | ||
--loop_iter 2 \ | ||
--optimistic_loop \ | ||
--prover_args "-mediumTimeout 20 -depth 10" \ | ||
--smt_timeout 500 \ | ||
--msg "GhoDiscountRateStrategy, all rules." | ||
fi | ||
--rules "$2" \ | ||
--msg "GhoDiscountRateStrategy, rules $2." | ||
# else | ||
# certoraRun certora/harness/GhoDiscountRateStrategyHarness.sol:GhoDiscountRateStrategyHarness \ | ||
# --verify GhoDiscountRateStrategyHarness:certora/specs/ghoDiscountRateStrategy.spec \ | ||
# --solc solc8.10 \ | ||
# --loop_iter 2 \ | ||
# --optimistic_loop \ | ||
# --prover_args "-mediumTimeout 20 -depth 10" \ | ||
# --smt_timeout 500 \ | ||
# --msg "GhoDiscountRateStrategy, all rules." | ||
# fi |
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 @@ | ||
|
||
certoraRun certora/harness/ghoVariableDebtTokenHarnessInternal.sol:GhoVariableDebtTokenHarnessInternal \ | ||
certora/munged/contracts/facilitators/aave/interestStrategy/GhoDiscountRateStrategy.sol \ | ||
--verify GhoVariableDebtTokenHarnessInternal:certora/specs/ghoVariableDebtTokenInternal.spec \ | ||
--loop_iter 2 \ | ||
--solc solc8.10 \ | ||
--optimistic_loop \ | ||
--smt_timeout 900 \ | ||
--prover_args "-mediumTimeout 30 -depth 15" \ | ||
--msg "GhoVariableDebtToken internal functions" | ||
|
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,31 @@ | ||
import "ghoVariableDebtToken.spec"; | ||
|
||
methods{ | ||
} | ||
|
||
|
||
// check a scenario that function _accrueDebtOnAction() returns non zero balance increase | ||
rule positive_balanceIncrease { | ||
env e; | ||
address user; | ||
uint256 previousScaledBalance; uint256 discountPercent; uint256 index; | ||
uint256 balanceIncrease; uint256 discountScaled; | ||
uint256 user_index_before = getUserCurrentIndex(user); | ||
uint256 accumulated_interest_before = getUserAccumulatedDebtInterest(user); | ||
balanceIncrease, discountScaled = accrueDebtOnAction(e, user,previousScaledBalance,discountPercent,index); | ||
uint256 accumulated_interest_after = getUserAccumulatedDebtInterest(user); | ||
uint256 user_index_after = getUserCurrentIndex(user); | ||
|
||
assert ray() <= user_index_before | ||
&& to_mathint(user_index_before + ray()) < to_mathint(index) // user index increase by more than 1 ray | ||
&& 0 < previousScaledBalance | ||
&& discountPercent < discStrategy.DISCOUNT_RATE() // discount rate is less than 30% | ||
//(if user index increases by 1 ray discount percent could be as high as 50%) | ||
=> balanceIncrease > 0; | ||
|
||
assert balanceIncrease > 0 => accumulated_interest_after > accumulated_interest_before; | ||
|
||
assert user_index_after == index; | ||
} | ||
|
||
|