Skip to content

Commit

Permalink
feat: add claim twice rule
Browse files Browse the repository at this point in the history
  • Loading branch information
QGarchery committed Mar 6, 2024
1 parent ac2af4c commit 48fb135
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion certora/specs/RewardsDistributor.spec
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ rule updatedClaimedAmount(address _account, uint256 _claimable, bytes32[] _proof
}

// Check an account can only claim greater amounts each time.
// Together with the previous rule, it ensures that an account cannot claim twice the rewards.
rule increasingClaimedAmounts(address _account, uint256 _claimable, bytes32[] _proof) {
uint256 claimed = claimed(_account);

Expand All @@ -31,6 +30,22 @@ rule increasingClaimedAmounts(address _account, uint256 _claimable, bytes32[] _p
assert _claimable > claimed;
}

// Check that claiming twice is equivalent to claiming once with the last amount.
rule claimTwice(address _account, uint256 _claim1, uint256 _claim2) {
storage initStorage = lastStorage;

bytes32[] _proof1; bytes32[] _proof2;
claim(_account, _claim1, _proof1);
claim(_account, _claim2, _proof2);

storage afterBothStorage = lastStorage;

bytes32[] _proof;
claim(_account, _claim2, _proof) at initStorage;

assert lastStorage == afterBothStorage;
}

// Check that the transferred amount is equal to the claimed amount minus the previous claimed amount.
rule transferredTokens(address _account, uint256 _claimable, bytes32[] _proof) {
// Assume that the rewards distributor itself is not receiving the tokens, to simplify this rule.
Expand Down

0 comments on commit 48fb135

Please sign in to comment.