Skip to content

Commit eddb899

Browse files
committed
(fix) Hotfix for calculations on SPOs on gov actions
1 parent 0d7b44b commit eddb899

File tree

2 files changed

+19
-8
lines changed

2 files changed

+19
-8
lines changed

govtool/backend/sql/get-network-total-stake.sql

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,16 @@ TotalStakeControlledByActiveDReps AS (
6767
AND COALESCE(rd.deposit, 0) >= 0
6868
AND ((DRepActivity.epoch_no - GREATEST(COALESCE(lve.epoch_no, 0), COALESCE(rd.epoch_no, 0))) <= DRepActivity.drep_activity)
6969
),
70+
-- it's a hotfix for duplication issue https://github.com/IntersectMBO/cardano-db-sync/issues/1986
71+
LatestPoolStat AS (
72+
SELECT DISTINCT ON (pool_hash_id) *
73+
FROM
74+
pool_stat
75+
WHERE
76+
epoch_no = (SELECT MAX(no) FROM epoch)
77+
),
7078
TotalStakeControlledBySPOs AS (
71-
SELECT SUM(ps.stake)::bigint AS total FROM pool_stat ps WHERE ps.epoch_no = (SELECT no FROM CurrentEpoch)
79+
SELECT SUM(ps.stake)::bigint AS total FROM LatestPoolStat ps WHERE ps.epoch_no = (SELECT no FROM CurrentEpoch)
7280
),
7381
AlwaysAbstainVotingPower AS (
7482
SELECT COALESCE((SELECT amount FROM drep_hash

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

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -109,14 +109,17 @@ export const VotesSubmitted = ({
109109
100 - (dRepYesVotesPercentage ?? 0) - (dRepNoVotesPercentage ?? 0);
110110

111111
const poolYesVotesPercentage =
112-
poolYesVotes + poolNoVotes
113-
? (poolYesVotes / (poolYesVotes + poolNoVotes)) * 100
112+
typeof poolYesVotes === "number" &&
113+
typeof networkTotalStake?.totalStakeControlledBySPOs === "number" &&
114+
networkTotalStake.totalStakeControlledBySPOs > 0
115+
? (poolYesVotes / networkTotalStake.totalStakeControlledBySPOs) * 100
116+
: undefined;
117+
const poolNoVotesPercentage =
118+
typeof poolNoVotes === "number" &&
119+
typeof networkTotalStake?.totalStakeControlledBySPOs === "number" &&
120+
networkTotalStake.totalStakeControlledBySPOs > 0
121+
? (poolNoVotes / networkTotalStake.totalStakeControlledBySPOs) * 100
114122
: undefined;
115-
const poolNoVotesPercentage = poolYesVotesPercentage
116-
? 100 - poolYesVotesPercentage
117-
: poolNoVotes
118-
? 100
119-
: undefined;
120123

121124
const ccYesVotesPercentage = noOfCommitteeMembers
122125
? (ccYesVotes / noOfCommitteeMembers) * 100

0 commit comments

Comments
 (0)