diff --git a/CHANGELOG.md b/CHANGELOG.md index 0c6c9adf4..061a307b7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 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={(() => {