Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ changes.

- Fix calculating votes counting for governance actions
- Fix crashing backend on unhandled missing proposal from vote [Issue 2920](https://github.com/IntersectMBO/govtool/issues/2920)
- Remove abstain votes (not auto abstain) from total DRep stake

### Changed

Expand Down
2 changes: 1 addition & 1 deletion govtool/backend/sql/list-proposals.sql
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ SELECT
ELSE
drep_voting_power.no_confidence
END) no_votes,
COALESCE(SUM(ldd_drep.amount) FILTER (WHERE rdv.vote::text = 'Abstain'), 0) + drep_voting_power.abstain abstain_votes,
COALESCE(SUM(ldd_drep.amount) FILTER (WHERE rdv.vote::text = 'Abstain'), 0) abstain_votes,
COALESCE(ps.poolYesVotes, 0) pool_yes_votes,
COALESCE(ps.poolNoVotes, 0) pool_no_votes,
COALESCE(ps.poolAbstainVotes, 0) pool_abstain_votes,
Expand Down
19 changes: 15 additions & 4 deletions govtool/frontend/src/components/molecules/VotesSubmitted.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,27 +50,38 @@ export const VotesSubmitted = ({
const { t } = useTranslation();
const { epochParams, networkMetrics } = useAppContext();

// Coming from be
// Equal to: total active drep stake + auto no-confidence stake
const totalStakeControlledByDReps =
networkMetrics?.totalStakeControlledByDReps ?? 0;
(networkMetrics?.totalStakeControlledByDReps ?? 0) -
// As this being voted for the action becomes part of the total active stake
dRepAbstainVotes;

// Governance action abstain votesa + auto abstain votes
const totalAbstainVotes =
dRepAbstainVotes + (networkMetrics?.alwaysAbstainVotingPower ?? 0);

// TODO: Move this logic to backend
const dRepYesVotesPercentage = totalStakeControlledByDReps
? (dRepYesVotes / totalStakeControlledByDReps) * 100
: undefined;

const dRepNoVotesPercentage = totalStakeControlledByDReps
? (dRepNoVotes / totalStakeControlledByDReps) * 100
: undefined;

const dRepNotVotedVotes = totalStakeControlledByDReps
? totalStakeControlledByDReps -
(dRepYesVotes -
// As this is already added on backend
(govActionType === GovernanceActionType.NoConfidence
? networkMetrics?.alwaysNoConfidenceVotingPower ?? 0
: 0)) -
(dRepNoVotes -
// As this is already added on backend
(govActionType === GovernanceActionType.NoConfidence
? 0
: networkMetrics?.alwaysNoConfidenceVotingPower ?? 0)) -
(dRepAbstainVotes - (networkMetrics?.alwaysAbstainVotingPower ?? 0))
: networkMetrics?.alwaysNoConfidenceVotingPower ?? 0))
: undefined;
const dRepNotVotedVotesPercentage =
100 - (dRepYesVotesPercentage ?? 0) - (dRepNoVotesPercentage ?? 0);
Expand Down Expand Up @@ -143,7 +154,7 @@ export const VotesSubmitted = ({
yesVotesPercentage={dRepYesVotesPercentage}
noVotes={dRepNoVotes}
noVotesPercentage={dRepNoVotesPercentage}
abstainVotes={dRepAbstainVotes}
abstainVotes={totalAbstainVotes}
notVotedVotes={dRepNotVotedVotes}
notVotedPercentage={dRepNotVotedVotesPercentage}
threshold={(() => {
Expand Down