Skip to content

Commit 1d12815

Browse files
committed
fix: remove abstain governance action votes from total stake
1 parent b96c61f commit 1d12815

File tree

3 files changed

+15
-3
lines changed

3 files changed

+15
-3
lines changed

CHANGELOG.md

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

1919
- Fix calculating votes counting for governance actions
20+
- Remove abstain votes (not auto abstain) from total DRep stake
2021

2122
### Changed
2223

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: 13 additions & 2 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 =
5456
networkMetrics?.totalStakeControlledByDReps ?? 0;
5557

58+
// Governance action abstain votesa + auto abstain votes
59+
const totalAbstainVotes =
60+
dRepAbstainVotes + (networkMetrics?.alwaysAbstainVotingPower ?? 0);
61+
5662
// TODO: Move this logic to backend
5763
const dRepYesVotesPercentage = totalStakeControlledByDReps
5864
? (dRepYesVotes / totalStakeControlledByDReps) * 100
5965
: undefined;
66+
6067
const dRepNoVotesPercentage = totalStakeControlledByDReps
6168
? (dRepNoVotes / totalStakeControlledByDReps) * 100
6269
: undefined;
70+
6371
const dRepNotVotedVotes = totalStakeControlledByDReps
6472
? totalStakeControlledByDReps -
6573
(dRepYesVotes -
74+
// As this is already added on backend
6675
(govActionType === GovernanceActionType.NoConfidence
6776
? networkMetrics?.alwaysNoConfidenceVotingPower ?? 0
6877
: 0)) -
6978
(dRepNoVotes -
79+
// As this is already added on backend
7080
(govActionType === GovernanceActionType.NoConfidence
7181
? 0
7282
: networkMetrics?.alwaysNoConfidenceVotingPower ?? 0)) -
73-
(dRepAbstainVotes - (networkMetrics?.alwaysAbstainVotingPower ?? 0))
83+
// As this being voted for the action becomes part of the total active stake
84+
dRepAbstainVotes
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)