Skip to content

Commit

Permalink
fix: governor incorrect divisor (#378)
Browse files Browse the repository at this point in the history
* fix: governor incorrect divisor

* test: minimum comment weight is acceptable

* test: comment weight acceptable threshold
  • Loading branch information
pedrovalido authored Jan 2, 2024
1 parent 4bf528a commit 8886178
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 2 deletions.
2 changes: 1 addition & 1 deletion contracts/governance/GovernorSimple.sol
Original file line number Diff line number Diff line change
Expand Up @@ -585,7 +585,7 @@ abstract contract GovernorSimple is ERC2771Context, ERC165, EIP712, IGovernor, I
address account = _msgSender();
uint256 weight = _getVotes(account, tokenId, startTime, params);
uint256 commentWeighting = IVetoGovernor(_voter.governor()).commentWeighting();
uint256 minimumWeight = (escrow.getPastTotalSupply(startTime) * commentWeighting) / 10_000;
uint256 minimumWeight = (escrow.getPastTotalSupply(startTime) * commentWeighting) / COMMENT_DENOMINATOR;
require(weight > minimumWeight, "EpochGovernor: insufficient voting power");

emit Comment(proposalId, account, tokenId, message);
Expand Down
2 changes: 1 addition & 1 deletion contracts/governance/VetoGovernor.sol
Original file line number Diff line number Diff line change
Expand Up @@ -630,7 +630,7 @@ abstract contract VetoGovernor is Context, ERC165, EIP712, IVetoGovernor, IERC72
uint256 startTime = proposal.voteStart;
address account = _msgSender();
uint256 weight = _getVotes(account, tokenId, startTime, params);
uint256 minimumWeight = (escrow.getPastTotalSupply(startTime) * commentWeighting) / 10_000;
uint256 minimumWeight = (escrow.getPastTotalSupply(startTime) * commentWeighting) / COMMENT_DENOMINATOR;
require(weight > minimumWeight, "Governor: insufficient voting power");

emit Comment(proposalId, account, tokenId, message);
Expand Down
33 changes: 33 additions & 0 deletions test/VeloGovernor.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -977,6 +977,39 @@ contract VeloGovernorTest is BaseTest {
governor.comment(pid, tokenId, "test");
}

function testMinimumWeightIsAcceptable() public {
uint256 pid = createProposal();

vm.startPrank(address(owner3));
VELO.approve(address(escrow), 1);
escrow.increaseAmount(3, 1);
vm.stopPrank();

//total supply of locked tokens is now 100
vm.prank(escrow.team());
escrow.toggleSplit(address(this), true);
(, uint256 tokenId) = escrow.split(1, 4e14 + 11e7);

governor.comment(pid, tokenId, "test");
}

function testBelowMinimumAcceptableWeight() public {
uint256 pid = createProposal();

vm.startPrank(address(owner3));
VELO.approve(address(escrow), 1);
escrow.increaseAmount(3, 1);
vm.stopPrank();

//total supply of locked tokens is now 100
vm.prank(escrow.team());
escrow.toggleSplit(address(this), true);
(, uint256 tokenId) = escrow.split(1, 4e14);

vm.expectRevert("Governor: insufficient voting power");
governor.comment(pid, tokenId, "test");
}

function testCannotCommentIfProposalNotActiveOrPending() public {
uint256 pid = createProposal();

Expand Down

0 comments on commit 8886178

Please sign in to comment.