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
10 changes: 9 additions & 1 deletion govtool/backend/sql/get-network-total-stake.sql
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,16 @@ TotalStakeControlledByActiveDReps AS (
AND COALESCE(rd.deposit, 0) >= 0
AND ((DRepActivity.epoch_no - GREATEST(COALESCE(lve.epoch_no, 0), COALESCE(rd.epoch_no, 0))) <= DRepActivity.drep_activity)
),
-- it's a hotfix for duplication issue https://github.com/IntersectMBO/cardano-db-sync/issues/1986
LatestPoolStat AS (
SELECT DISTINCT ON (pool_hash_id) *
FROM
pool_stat
WHERE
epoch_no = (SELECT MAX(no) FROM epoch)
),
TotalStakeControlledBySPOs AS (
SELECT SUM(ps.stake)::bigint AS total FROM pool_stat ps WHERE ps.epoch_no = (SELECT no FROM CurrentEpoch)
SELECT SUM(ps.stake)::bigint AS total FROM LatestPoolStat ps WHERE ps.epoch_no = (SELECT no FROM CurrentEpoch)
),
AlwaysAbstainVotingPower AS (
SELECT COALESCE((SELECT amount FROM drep_hash
Expand Down
17 changes: 10 additions & 7 deletions govtool/frontend/src/components/molecules/VotesSubmitted.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -109,14 +109,17 @@ export const VotesSubmitted = ({
100 - (dRepYesVotesPercentage ?? 0) - (dRepNoVotesPercentage ?? 0);

const poolYesVotesPercentage =
poolYesVotes + poolNoVotes
? (poolYesVotes / (poolYesVotes + poolNoVotes)) * 100
typeof poolYesVotes === "number" &&
typeof networkTotalStake?.totalStakeControlledBySPOs === "number" &&
networkTotalStake.totalStakeControlledBySPOs > 0
? (poolYesVotes / networkTotalStake.totalStakeControlledBySPOs) * 100
: undefined;
const poolNoVotesPercentage =
typeof poolNoVotes === "number" &&
typeof networkTotalStake?.totalStakeControlledBySPOs === "number" &&
networkTotalStake.totalStakeControlledBySPOs > 0
? (poolNoVotes / networkTotalStake.totalStakeControlledBySPOs) * 100
: undefined;
const poolNoVotesPercentage = poolYesVotesPercentage
? 100 - poolYesVotesPercentage
: poolNoVotes
? 100
: undefined;

const ccYesVotesPercentage = noOfCommitteeMembers
? (ccYesVotes / noOfCommitteeMembers) * 100
Expand Down