diff --git a/packages/desktop/views/dashboard/governance/components/proposal-details/QuorumProgress.svelte b/packages/desktop/views/dashboard/governance/components/proposal-details/QuorumProgress.svelte
index d9b2d0ae14..fa35223285 100644
--- a/packages/desktop/views/dashboard/governance/components/proposal-details/QuorumProgress.svelte
+++ b/packages/desktop/views/dashboard/governance/components/proposal-details/QuorumProgress.svelte
@@ -5,16 +5,24 @@
selectedParticipationEventStatus,
} from '@contexts/governance'
import { Text, Progress, TooltipIcon } from '@bloomwalletio/ui'
- import { localize } from '@core/i18n'
+ import { getDecimalSeparator, localize } from '@core/i18n'
+ import { networkStatus } from '@core/network'
+ import { getSignificantDigitsAndRound } from '@core/utils'
export let proposal: IProposal
const QUORUM_PERCENTAGE_DECIMAL = 0.05
- $: circulatingSupplyVotedPercentage = getCirculatingSupplyVotedPercentage(
- $selectedParticipationEventStatus,
- proposal
- )
+ const currentMilestone = $networkStatus.currentMilestone
+
+ $: circulatingSupplyVotedPercentage =
+ getCirculatingSupplyVotedPercentage($selectedParticipationEventStatus, proposal, currentMilestone) ?? 0
+
+ function formatPercentage(percentage: number): string {
+ const percentageWithSignificantDigits = getSignificantDigitsAndRound(Number(percentage))
+ const percentageString = String(percentageWithSignificantDigits).replace(/[,.]/g, getDecimalSeparator()) + '%'
+ return percentageString
+ }
@@ -24,14 +32,10 @@
- {circulatingSupplyVotedPercentage} / {QUORUM_PERCENTAGE_DECIMAL * 100}%
+
+ {formatPercentage(circulatingSupplyVotedPercentage)} / {QUORUM_PERCENTAGE_DECIMAL * 100}%
+
-
+
diff --git a/packages/shared/src/lib/contexts/governance/utils/getCirculatingSupplyVotedPercentage.ts b/packages/shared/src/lib/contexts/governance/utils/getCirculatingSupplyVotedPercentage.ts
index a3a9a13088..c2aeebf4ed 100644
--- a/packages/shared/src/lib/contexts/governance/utils/getCirculatingSupplyVotedPercentage.ts
+++ b/packages/shared/src/lib/contexts/governance/utils/getCirculatingSupplyVotedPercentage.ts
@@ -1,31 +1,36 @@
import { IProfile } from '@core/profile/interfaces'
import { activeProfile } from '@core/profile/stores'
-import { get } from 'svelte/store'
+import { calculatePercentageOfBigInt } from '@core/utils/number'
import { ParticipationEventStatus } from '@iota/sdk'
+import { get } from 'svelte/store'
import { IProposal } from '../interfaces'
-import { calculatePercentageOfBigInt, getSignificantDigitsAndRound } from '@core/utils/number'
-import { getDecimalSeparator } from '@core/i18n'
export function getCirculatingSupplyVotedPercentage(
participationEventStatus: ParticipationEventStatus,
proposal: IProposal,
+ currentMilestone: number,
profile: IProfile = get(activeProfile)
-): string {
+): number {
const circulatingSupply = profile.network.protocol?.circulatingSupply
if (!circulatingSupply || !participationEventStatus?.questions || !proposal?.milestones) {
- return '0%'
+ return 0
}
+ let milestoneCount: number
+ if (currentMilestone < proposal.milestones.holding) {
+ milestoneCount = 1
+ } else if (currentMilestone > proposal.milestones.ended) {
+ milestoneCount = proposal.milestones.ended - proposal.milestones.holding
+ } else {
+ milestoneCount = currentMilestone - proposal.milestones.holding
+ }
const totalEventVotes = participationEventStatus.questions[0].answers.reduce(
(total, answer) => (total += BigInt(answer.accumulated)),
BigInt(0)
)
- const milestoneCount = proposal.milestones.ended - proposal.milestones.holding
const maximumVotes = BigInt(circulatingSupply) * BigInt(milestoneCount)
const percentage = calculatePercentageOfBigInt(totalEventVotes, maximumVotes, 6)
- const percentageWithSignificantDigits = getSignificantDigitsAndRound(Number(percentage))
- const percentageString = String(percentageWithSignificantDigits).replace(/[,.]/g, getDecimalSeparator()) + '%'
- return percentageString
+ return percentage
}