From 900ed29f0ca06826f31c025a4e400f71ce430463 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Sza=C5=82owski?= Date: Fri, 7 Feb 2025 15:02:01 +0100 Subject: [PATCH] fix: remove abstain governance action votes from total stake --- CHANGELOG.md | 1 + govtool/backend/sql/list-proposals.sql | 2 +- .../components/molecules/VotesSubmitted.tsx | 19 +++++++++++++++---- 3 files changed, 17 insertions(+), 5 deletions(-) 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..b4c1afe53 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; + (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); @@ -143,7 +154,7 @@ export const VotesSubmitted = ({ yesVotesPercentage={dRepYesVotesPercentage} noVotes={dRepNoVotes} noVotesPercentage={dRepNoVotesPercentage} - abstainVotes={dRepAbstainVotes} + abstainVotes={totalAbstainVotes} notVotedVotes={dRepNotVotedVotes} notVotedPercentage={dRepNotVotedVotesPercentage} threshold={(() => {