Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ changes.

### Removed

-
- Remove abstain from total DRep votes calculation

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

Expand Down
2 changes: 1 addition & 1 deletion govtool/backend/sql/get-network-metrics.sql
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ SELECT
TotalDRepVotes.count AS total_drep_votes,
TotalRegisteredDReps.unique_registrations AS total_registered_dreps,
TotalDRepDistr.total_drep_distr,
COALESCE(TotalStakeControlledByActiveDReps.total, 0) + COALESCE(AlwaysAbstainVotingPower.amount, 0) + COALESCE(AlwaysNoConfidenceVotingPower.amount, 0) AS total_stake_controlled_dreps,
COALESCE(TotalStakeControlledByActiveDReps.total, 0) + COALESCE(AlwaysNoConfidenceVotingPower.amount, 0) AS total_stake_controlled_by_active_dreps,
COALESCE(TotalStakeControlledBySPOs.total, 0) AS total_stake_controlled_by_spos,
TotalActiveDReps.unique_active_drep_registrations AS total_active_dreps,
TotalInactiveDReps.total_inactive_dreps AS total_inactive_dreps,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ export const GovernanceActionDetailsCardVotes = ({
isInProgress={isInProgress}
/>
) : (
<VotesSubmitted votes={proposal} />
<VotesSubmitted type={proposal.type} votes={proposal} />
)}
</Box>
);
Expand Down
28 changes: 17 additions & 11 deletions govtool/frontend/src/components/molecules/VotesSubmitted.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,15 @@ import {
} from "@utils";
import { SubmittedVotesData } from "@models";
import { useFeatureFlag, useAppContext } from "@/context";
import { GovernanceActionType } from "@/types/governanceAction";

type Props = {
type: GovernanceActionType;
votes: SubmittedVotesData;
};

export const VotesSubmitted = ({
type: govActionType,
votes: {
dRepYesVotes,
dRepAbstainVotes,
Expand Down Expand Up @@ -50,21 +53,24 @@ export const VotesSubmitted = ({
const totalStakeControlledByDReps =
networkMetrics?.totalStakeControlledByDReps ?? 0;

const totalDRepVotes = totalStakeControlledByDReps
? totalStakeControlledByDReps - dRepAbstainVotes
// TODO: Move this logic to backend
const dRepYesVotesPercentage = totalStakeControlledByDReps
? (dRepYesVotes / totalStakeControlledByDReps) * 100
: undefined;
const dRepYesVotesPercentage = totalDRepVotes
? (dRepYesVotes / totalDRepVotes) * 100
: undefined;
const dRepNoVotesPercentage = totalDRepVotes
? (dRepNoVotes / totalDRepVotes) * 100
const dRepNoVotesPercentage = totalStakeControlledByDReps
? (dRepNoVotes / totalStakeControlledByDReps) * 100
: undefined;
const dRepNotVotedVotes = totalStakeControlledByDReps
? totalStakeControlledByDReps -
dRepYesVotes -
dRepNoVotes -
dRepAbstainVotes +
(networkMetrics?.alwaysNoConfidenceVotingPower ?? 0)
(dRepYesVotes -
(govActionType === GovernanceActionType.NoConfidence
? networkMetrics?.alwaysNoConfidenceVotingPower ?? 0
: 0)) -
(dRepNoVotes -
(govActionType === GovernanceActionType.NoConfidence
? 0
: networkMetrics?.alwaysNoConfidenceVotingPower ?? 0)) -
(dRepAbstainVotes - (networkMetrics?.alwaysAbstainVotingPower ?? 0))
: undefined;
const dRepNotVotedVotesPercentage =
100 - (dRepYesVotesPercentage ?? 0) - (dRepNoVotesPercentage ?? 0);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export const SubmittedVotesModal = forwardRef<HTMLDivElement>((_, ref) => {
>
<ModalContents>
<Box alignItems="center">
<VotesSubmitted votes={state} />
<VotesSubmitted type={state.type} votes={state} />
</Box>
</ModalContents>
</ModalWrapper>
Expand Down