diff --git a/contracts/governance/GovernorSimple.sol b/contracts/governance/GovernorSimple.sol index 3dcbc88..3279c3e 100644 --- a/contracts/governance/GovernorSimple.sol +++ b/contracts/governance/GovernorSimple.sol @@ -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); diff --git a/contracts/governance/VetoGovernor.sol b/contracts/governance/VetoGovernor.sol index f339639..09c07b3 100644 --- a/contracts/governance/VetoGovernor.sol +++ b/contracts/governance/VetoGovernor.sol @@ -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); diff --git a/test/VeloGovernor.t.sol b/test/VeloGovernor.t.sol index ec4791a..fa291af 100644 --- a/test/VeloGovernor.t.sol +++ b/test/VeloGovernor.t.sol @@ -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();