@@ -4,7 +4,10 @@ import { Box } from "@mui/material";
44import { IMAGES , SECURITY_RELEVANT_PARAMS_MAP } from "@consts" ;
55import { Typography , VotePill } from "@atoms" ;
66import { useTranslation } from "@hooks" ;
7- import { correctVoteAdaFormat , getGovActionVotingThresholdKey } from "@utils" ;
7+ import {
8+ correctDRepDirectoryFormat ,
9+ getGovActionVotingThresholdKey ,
10+ } from "@utils" ;
811import { SubmittedVotesData } from "@models" ;
912import { useFeatureFlag , useAppContext } from "@/context" ;
1013
@@ -42,17 +45,28 @@ export const VotesSubmitted = ({
4245 areCCVoteTotalsDisplayed,
4346 } = useFeatureFlag ( ) ;
4447 const { t } = useTranslation ( ) ;
45- const { epochParams } = useAppContext ( ) ;
48+ const { epochParams, networkMetrics } = useAppContext ( ) ;
4649
47- const dRepYesVotesPercentage =
48- dRepYesVotes + dRepNoVotes
49- ? ( dRepYesVotes / ( dRepYesVotes + dRepNoVotes ) ) * 100
50- : undefined ;
51- const dRepNoVotesPercentage = dRepYesVotesPercentage
52- ? 100 - dRepYesVotesPercentage
53- : dRepNoVotes
54- ? 100
50+ const totalStakeControlledByDReps =
51+ networkMetrics ?. totalStakeControlledByDReps ?? 0 ;
52+
53+ const totalDRepVotes = totalStakeControlledByDReps
54+ ? totalStakeControlledByDReps - dRepAbstainVotes
55+ : undefined ;
56+ const dRepYesVotesPercentage = totalDRepVotes
57+ ? ( dRepYesVotes / totalDRepVotes ) * 100
5558 : undefined ;
59+ const dRepNoVotesPercentage = totalDRepVotes
60+ ? ( dRepNoVotes / totalDRepVotes ) * 100
61+ : undefined ;
62+ const dRepNotVotedVotes = totalStakeControlledByDReps
63+ ? totalStakeControlledByDReps -
64+ dRepYesVotes -
65+ dRepNoVotes -
66+ dRepAbstainVotes
67+ : undefined ;
68+ const dRepNotVotedVotesPercentage =
69+ 100 - ( dRepYesVotesPercentage ?? 0 ) - ( dRepNoVotesPercentage ?? 0 ) ;
5670
5771 const poolYesVotesPercentage =
5872 poolYesVotes + poolNoVotes
@@ -123,6 +137,8 @@ export const VotesSubmitted = ({
123137 noVotes = { dRepNoVotes }
124138 noVotesPercentage = { dRepNoVotesPercentage }
125139 abstainVotes = { dRepAbstainVotes }
140+ notVotedVotes = { dRepNotVotedVotes }
141+ notVotedPercentage = { dRepNotVotedVotesPercentage }
126142 threshold = { ( ( ) => {
127143 const votingThresholdKey = getGovActionVotingThresholdKey ( {
128144 govActionType : type ,
@@ -174,6 +190,8 @@ type VotesGroupProps = {
174190 yesVotesPercentage ?: number ;
175191 noVotes : number ;
176192 noVotesPercentage ?: number ;
193+ notVotedVotes ?: number ;
194+ notVotedPercentage ?: number ;
177195 abstainVotes : number ;
178196 threshold ?: number | null ;
179197} ;
@@ -184,6 +202,8 @@ const VotesGroup = ({
184202 yesVotesPercentage,
185203 noVotes,
186204 noVotesPercentage,
205+ notVotedVotes,
206+ notVotedPercentage,
187207 abstainVotes,
188208 threshold,
189209} : VotesGroupProps ) => {
@@ -219,7 +239,15 @@ const VotesGroup = ({
219239 percentage = { noVotesPercentage }
220240 value = { noVotes }
221241 />
222- { threshold !== undefined && (
242+ { typeof notVotedVotes === "number" && (
243+ < Vote
244+ type = { type }
245+ vote = "notVoted"
246+ percentage = { notVotedPercentage }
247+ value = { notVotedVotes }
248+ />
249+ ) }
250+ { threshold !== undefined && threshold !== null && (
223251 < Box
224252 display = "flex"
225253 flexDirection = "row"
@@ -246,7 +274,7 @@ const VotesGroup = ({
246274 color : "neutralGray" ,
247275 } }
248276 >
249- { threshold }
277+ { threshold * 100 } %
250278 </ Typography >
251279 </ Box >
252280 ) }
@@ -285,7 +313,9 @@ const Vote = ({ type, vote, value, percentage }: VoteProps) => (
285313 fontWeight : "500" ,
286314 } }
287315 >
288- { type !== "ccCommittee" ? `₳ ${ correctVoteAdaFormat ( value ) } ` : value }
316+ { type !== "ccCommittee"
317+ ? `₳ ${ correctDRepDirectoryFormat ( value ) } `
318+ : value }
289319 </ Typography >
290320 { vote !== "abstain" && typeof percentage === "number" && (
291321 < Typography
0 commit comments