Skip to content

Commit

Permalink
Fix DMDcoin#55: Ensure atleast 1 vote for quorum reached check
Browse files Browse the repository at this point in the history
  • Loading branch information
MSalman6 committed Jan 2, 2025
1 parent 8080eb5 commit ddc3f87
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions contracts/DiamondDao.sol
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,7 @@ contract DiamondDao is IDiamondDao, Initializable, ReentrancyGuardUpgradeable, V

_saveVotingResult(proposalId, result);

bool accepted = quorumReached(proposal.proposalType, result);
bool accepted = quorumReached(proposalId, proposal.proposalType, result);

proposal.state = accepted ? ProposalState.Accepted : ProposalState.Declined;

Expand Down Expand Up @@ -452,17 +452,18 @@ contract DiamondDao is IDiamondDao, Initializable, ReentrancyGuardUpgradeable, V
* @param result The voting result containing the counts of "yes" and "no" votes.
* @return A boolean indicating whether the quorum has been reached.
*/
function quorumReached(ProposalType _type, VotingResult memory result) public view returns (bool) {
function quorumReached(uint256 proposalId, ProposalType _type, VotingResult memory result) public view returns (bool) {
uint256 requiredExceeding;
uint256 totalStakedAmount = _getTotalStakedAmount();
uint256 totalVotes = _proposalVoters[proposalId].length();

if (_type == ProposalType.ContractUpgrade) {
requiredExceeding = totalStakedAmount * (50 * 100) / 10000;
} else {
requiredExceeding = totalStakedAmount * (33 * 100) / 10000;
}

return result.stakeYes >= result.stakeNo + requiredExceeding;
return totalVotes > 0 && result.stakeYes >= result.stakeNo + requiredExceeding;
}

function hashProposal(
Expand Down

0 comments on commit ddc3f87

Please sign in to comment.