Skip to content

Commit dd251bc

Browse files
committed
fix: remove abstain governance action votes from total stake
1 parent 07d521b commit dd251bc

File tree

3 files changed

+17
-5
lines changed

3 files changed

+17
-5
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ changes.
1818

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

2223
### Changed
2324

govtool/backend/sql/list-proposals.sql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,7 @@ SELECT
251251
ELSE
252252
drep_voting_power.no_confidence
253253
END) no_votes,
254-
COALESCE(SUM(ldd_drep.amount) FILTER (WHERE rdv.vote::text = 'Abstain'), 0) + drep_voting_power.abstain abstain_votes,
254+
COALESCE(SUM(ldd_drep.amount) FILTER (WHERE rdv.vote::text = 'Abstain'), 0) abstain_votes,
255255
COALESCE(ps.poolYesVotes, 0) pool_yes_votes,
256256
COALESCE(ps.poolNoVotes, 0) pool_no_votes,
257257
COALESCE(ps.poolAbstainVotes, 0) pool_abstain_votes,

govtool/frontend/src/components/molecules/VotesSubmitted.tsx

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,27 +50,38 @@ export const VotesSubmitted = ({
5050
const { t } = useTranslation();
5151
const { epochParams, networkMetrics } = useAppContext();
5252

53+
// Coming from be
54+
// Equal to: total active drep stake + auto no-confidence stake
5355
const totalStakeControlledByDReps =
54-
networkMetrics?.totalStakeControlledByDReps ?? 0;
56+
(networkMetrics?.totalStakeControlledByDReps ?? 0) -
57+
// As this being voted for the action becomes part of the total active stake
58+
dRepAbstainVotes;
59+
60+
// Governance action abstain votesa + auto abstain votes
61+
const totalAbstainVotes =
62+
dRepAbstainVotes + (networkMetrics?.alwaysAbstainVotingPower ?? 0);
5563

5664
// TODO: Move this logic to backend
5765
const dRepYesVotesPercentage = totalStakeControlledByDReps
5866
? (dRepYesVotes / totalStakeControlledByDReps) * 100
5967
: undefined;
68+
6069
const dRepNoVotesPercentage = totalStakeControlledByDReps
6170
? (dRepNoVotes / totalStakeControlledByDReps) * 100
6271
: undefined;
72+
6373
const dRepNotVotedVotes = totalStakeControlledByDReps
6474
? totalStakeControlledByDReps -
6575
(dRepYesVotes -
76+
// As this is already added on backend
6677
(govActionType === GovernanceActionType.NoConfidence
6778
? networkMetrics?.alwaysNoConfidenceVotingPower ?? 0
6879
: 0)) -
6980
(dRepNoVotes -
81+
// As this is already added on backend
7082
(govActionType === GovernanceActionType.NoConfidence
7183
? 0
72-
: networkMetrics?.alwaysNoConfidenceVotingPower ?? 0)) -
73-
(dRepAbstainVotes - (networkMetrics?.alwaysAbstainVotingPower ?? 0))
84+
: networkMetrics?.alwaysNoConfidenceVotingPower ?? 0))
7485
: undefined;
7586
const dRepNotVotedVotesPercentage =
7687
100 - (dRepYesVotesPercentage ?? 0) - (dRepNoVotesPercentage ?? 0);
@@ -143,7 +154,7 @@ export const VotesSubmitted = ({
143154
yesVotesPercentage={dRepYesVotesPercentage}
144155
noVotes={dRepNoVotes}
145156
noVotesPercentage={dRepNoVotesPercentage}
146-
abstainVotes={dRepAbstainVotes}
157+
abstainVotes={totalAbstainVotes}
147158
notVotedVotes={dRepNotVotedVotes}
148159
notVotedPercentage={dRepNotVotedVotesPercentage}
149160
threshold={(() => {

0 commit comments

Comments
 (0)