diff --git a/CHANGELOG.md b/CHANGELOG.md index 8ef661132..27ff64d84 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -17,6 +17,7 @@ changes. ### Fixed - Fix calculating votes counting for governance actions +- Remove abstain votes (not auto abstain) from total DRep stake ### Changed diff --git a/govtool/backend/sql/list-proposals.sql b/govtool/backend/sql/list-proposals.sql index a0e8d2def..cedc4e86d 100644 --- a/govtool/backend/sql/list-proposals.sql +++ b/govtool/backend/sql/list-proposals.sql @@ -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, diff --git a/govtool/frontend/src/components/molecules/VotesSubmitted.tsx b/govtool/frontend/src/components/molecules/VotesSubmitted.tsx index 6e9e933e5..4c9b60416 100644 --- a/govtool/frontend/src/components/molecules/VotesSubmitted.tsx +++ b/govtool/frontend/src/components/molecules/VotesSubmitted.tsx @@ -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; + // 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)) + // As this being voted for the action becomes part of the total active stake + dRepAbstainVotes : undefined; const dRepNotVotedVotesPercentage = 100 - (dRepYesVotesPercentage ?? 0) - (dRepNoVotesPercentage ?? 0); @@ -143,7 +154,7 @@ export const VotesSubmitted = ({ yesVotesPercentage={dRepYesVotesPercentage} noVotes={dRepNoVotes} noVotesPercentage={dRepNoVotesPercentage} - abstainVotes={dRepAbstainVotes} + abstainVotes={totalAbstainVotes} notVotedVotes={dRepNotVotedVotes} notVotedPercentage={dRepNotVotedVotesPercentage} threshold={(() => {