-
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.
feat(RewardsStreamerMP): introduce emergency mode and ability to leave
This adds a new emergency mode that can be enabled by the owner of the system. When in emergency mode, stakers or `StakeVault`s can leave the system immediately. Closes #66
- Loading branch information
Showing
11 changed files
with
470 additions
and
77 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
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,21 @@ | ||
{ | ||
"files": [ | ||
"src/RewardsStreamerMP.sol", | ||
"certora/helpers/ERC20A.sol" | ||
], | ||
"link" : [ | ||
"RewardsStreamerMP:STAKING_TOKEN=ERC20A", | ||
"RewardsStreamerMP:REWARD_TOKEN=ERC20A" | ||
], | ||
"msg": "Verifying RewardsStreamerMP.sol", | ||
"rule_sanity": "basic", | ||
"verify": "RewardsStreamerMP:certora/specs/EmergencyMode.spec", | ||
"parametric_contracts": ["RewardsStreamerMP"], | ||
"optimistic_loop": true, | ||
"loop_iter": "3", | ||
"packages": [ | ||
"forge-std=lib/forge-std/src", | ||
"@openzeppelin=lib/openzeppelin-contracts" | ||
] | ||
} | ||
|
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,55 @@ | ||
using RewardsStreamerMP as streamer; | ||
using ERC20A as staked; | ||
|
||
methods { | ||
function emergencyModeEnabled() external returns (bool) envfree; | ||
} | ||
|
||
definition isViewFunction(method f) returns bool = ( | ||
f.selector == sig:streamer.STAKING_TOKEN().selector || | ||
f.selector == sig:streamer.REWARD_TOKEN().selector || | ||
f.selector == sig:streamer.SCALE_FACTOR().selector || | ||
f.selector == sig:streamer.MP_RATE_PER_YEAR().selector || | ||
f.selector == sig:streamer.MIN_LOCKUP_PERIOD().selector || | ||
f.selector == sig:streamer.MAX_LOCKUP_PERIOD().selector || | ||
f.selector == sig:streamer.MAX_MULTIPLIER().selector || | ||
f.selector == sig:streamer.accountedRewards().selector || | ||
f.selector == sig:streamer.rewardIndex().selector || | ||
f.selector == sig:streamer.lastMPUpdatedTime().selector || | ||
f.selector == sig:streamer.owner().selector || | ||
f.selector == sig:streamer.totalStaked().selector || | ||
f.selector == sig:streamer.totalMaxMP().selector || | ||
f.selector == sig:streamer.totalMP().selector || | ||
f.selector == sig:streamer.accounts(address).selector || | ||
f.selector == sig:streamer.emergencyModeEnabled().selector || | ||
f.selector == sig:streamer.getStakedBalance(address).selector || | ||
f.selector == sig:streamer.getAccount(address).selector || | ||
f.selector == sig:streamer.getPendingRewards(address).selector || | ||
f.selector == sig:streamer.calculateAccountRewards(address).selector | ||
); | ||
|
||
definition isOwnableFunction(method f) returns bool = ( | ||
f.selector == sig:streamer.renounceOwnership().selector || | ||
f.selector == sig:streamer.transferOwnership(address).selector | ||
); | ||
|
||
definition isTrustedCodehashAccessFunction(method f) returns bool = ( | ||
f.selector == sig:streamer.setTrustedCodehash(bytes32, bool).selector || | ||
f.selector == sig:streamer.isTrustedCodehash(bytes32).selector | ||
); | ||
|
||
rule accountCanOnlyLeaveInEmergencyMode(method f) { | ||
env e; | ||
calldataarg args; | ||
|
||
require emergencyModeEnabled() == true; | ||
|
||
f@withrevert(e, args); | ||
bool isReverted = lastReverted; | ||
|
||
assert !isReverted => f.selector == sig:streamer.leave().selector || | ||
isViewFunction(f)|| | ||
isOwnableFunction(f)|| | ||
isTrustedCodehashAccessFunction(f); | ||
} | ||
|
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
Oops, something went wrong.