Skip to content

Commit b96c61f

Browse files
authored
Merge pull request #2917 from IntersectMBO/chore/remove-abstain-from-total-dreps-calculation
chore: remove abstain from total drep votes calculation
2 parents 4b649a5 + 57581ef commit b96c61f

File tree

5 files changed

+21
-15
lines changed

5 files changed

+21
-15
lines changed

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ changes.
2525

2626
### Removed
2727

28-
-
28+
- Remove abstain from total DRep votes calculation
2929

3030
## [v2.0.11](https://github.com/IntersectMBO/govtool/releases/tag/v2.0.11) 2025-02-04
3131

govtool/backend/sql/get-network-metrics.sql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ SELECT
196196
TotalDRepVotes.count AS total_drep_votes,
197197
TotalRegisteredDReps.unique_registrations AS total_registered_dreps,
198198
TotalDRepDistr.total_drep_distr,
199-
COALESCE(TotalStakeControlledByActiveDReps.total, 0) + COALESCE(AlwaysAbstainVotingPower.amount, 0) + COALESCE(AlwaysNoConfidenceVotingPower.amount, 0) AS total_stake_controlled_dreps,
199+
COALESCE(TotalStakeControlledByActiveDReps.total, 0) + COALESCE(AlwaysNoConfidenceVotingPower.amount, 0) AS total_stake_controlled_by_active_dreps,
200200
COALESCE(TotalStakeControlledBySPOs.total, 0) AS total_stake_controlled_by_spos,
201201
TotalActiveDReps.unique_active_drep_registrations AS total_active_dreps,
202202
TotalInactiveDReps.total_inactive_dreps AS total_inactive_dreps,

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ export const GovernanceActionDetailsCardVotes = ({
5858
isInProgress={isInProgress}
5959
/>
6060
) : (
61-
<VotesSubmitted votes={proposal} />
61+
<VotesSubmitted type={proposal.type} votes={proposal} />
6262
)}
6363
</Box>
6464
);

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

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,15 @@ import {
1010
} from "@utils";
1111
import { SubmittedVotesData } from "@models";
1212
import { useFeatureFlag, useAppContext } from "@/context";
13+
import { GovernanceActionType } from "@/types/governanceAction";
1314

1415
type Props = {
16+
type: GovernanceActionType;
1517
votes: SubmittedVotesData;
1618
};
1719

1820
export const VotesSubmitted = ({
21+
type: govActionType,
1922
votes: {
2023
dRepYesVotes,
2124
dRepAbstainVotes,
@@ -50,21 +53,24 @@ export const VotesSubmitted = ({
5053
const totalStakeControlledByDReps =
5154
networkMetrics?.totalStakeControlledByDReps ?? 0;
5255

53-
const totalDRepVotes = totalStakeControlledByDReps
54-
? totalStakeControlledByDReps - dRepAbstainVotes
56+
// TODO: Move this logic to backend
57+
const dRepYesVotesPercentage = totalStakeControlledByDReps
58+
? (dRepYesVotes / totalStakeControlledByDReps) * 100
5559
: undefined;
56-
const dRepYesVotesPercentage = totalDRepVotes
57-
? (dRepYesVotes / totalDRepVotes) * 100
58-
: undefined;
59-
const dRepNoVotesPercentage = totalDRepVotes
60-
? (dRepNoVotes / totalDRepVotes) * 100
60+
const dRepNoVotesPercentage = totalStakeControlledByDReps
61+
? (dRepNoVotes / totalStakeControlledByDReps) * 100
6162
: undefined;
6263
const dRepNotVotedVotes = totalStakeControlledByDReps
6364
? totalStakeControlledByDReps -
64-
dRepYesVotes -
65-
dRepNoVotes -
66-
dRepAbstainVotes +
67-
(networkMetrics?.alwaysNoConfidenceVotingPower ?? 0)
65+
(dRepYesVotes -
66+
(govActionType === GovernanceActionType.NoConfidence
67+
? networkMetrics?.alwaysNoConfidenceVotingPower ?? 0
68+
: 0)) -
69+
(dRepNoVotes -
70+
(govActionType === GovernanceActionType.NoConfidence
71+
? 0
72+
: networkMetrics?.alwaysNoConfidenceVotingPower ?? 0)) -
73+
(dRepAbstainVotes - (networkMetrics?.alwaysAbstainVotingPower ?? 0))
6874
: undefined;
6975
const dRepNotVotedVotesPercentage =
7076
100 - (dRepYesVotesPercentage ?? 0) - (dRepNoVotesPercentage ?? 0);

govtool/frontend/src/components/organisms/Modal/SubmittedVotesModal.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ export const SubmittedVotesModal = forwardRef<HTMLDivElement>((_, ref) => {
2323
>
2424
<ModalContents>
2525
<Box alignItems="center">
26-
<VotesSubmitted votes={state} />
26+
<VotesSubmitted type={state.type} votes={state} />
2727
</Box>
2828
</ModalContents>
2929
</ModalWrapper>

0 commit comments

Comments
 (0)