Skip to content

Commit

Permalink
fix: add sanity checks to thresholds
Browse files Browse the repository at this point in the history
  • Loading branch information
GalloDaSballo committed Oct 15, 2024
1 parent 0b1ab3a commit ceb0f7e
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/Governance.sol
Original file line number Diff line number Diff line change
Expand Up @@ -86,11 +86,22 @@ contract Governance is Multicall, UserProxyFactory, ReentrancyGuard, IGovernance
bold = IERC20(_bold);
require(_config.minClaim <= _config.minAccrual, "Gov: min-claim-gt-min-accrual");
REGISTRATION_FEE = _config.registrationFee;

// Registration threshold must be below 100% of votes
require(_config.registrationThresholdFactor < WAD, "Gov: registration-config");
REGISTRATION_THRESHOLD_FACTOR = _config.registrationThresholdFactor;

// Unregistration must be X times above the `votingThreshold`
require(_config.unregistrationThresholdFactor > WAD, "Gov: unregistration-config");
UNREGISTRATION_THRESHOLD_FACTOR = _config.unregistrationThresholdFactor;

REGISTRATION_WARM_UP_PERIOD = _config.registrationWarmUpPeriod;
UNREGISTRATION_AFTER_EPOCHS = _config.unregistrationAfterEpochs;

// Voting threshold must be below 100% of votes
require(_config.votingThresholdFactor < WAD, "Gov: voting-config");
VOTING_THRESHOLD_FACTOR = _config.votingThresholdFactor;

MIN_CLAIM = _config.minClaim;
MIN_ACCRUAL = _config.minAccrual;
EPOCH_START = _config.epochStart;
Expand Down
1 change: 1 addition & 0 deletions test/Governance.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -477,6 +477,7 @@ contract GovernanceTest is Test {
uint128 _votingThresholdFactor,
uint88 _minClaim
) public {
_votingThresholdFactor = _votingThresholdFactor % 1e18; /// Clamp to prevent misconfig
governance = new Governance(
address(lqty),
address(lusd),
Expand Down

0 comments on commit ceb0f7e

Please sign in to comment.