diff --git a/apps/governance/src/routes/staking/home/validator-tables/consensus-validators-table.spec.tsx b/apps/governance/src/routes/staking/home/validator-tables/consensus-validators-table.spec.tsx index d11d729b7..bae509c58 100644 --- a/apps/governance/src/routes/staking/home/validator-tables/consensus-validators-table.spec.tsx +++ b/apps/governance/src/routes/staking/home/validator-tables/consensus-validators-table.spec.tsx @@ -288,7 +288,7 @@ describe('Consensus validators table', () => { expect( grid.querySelector('[role="gridcell"][col-id="totalPenalties"]') - ).toHaveTextContent('13.16%'); + ).toHaveTextContent('10.07%'); expect( grid.querySelector('[role="gridcell"][col-id="normalisedVotingPower"]') diff --git a/apps/governance/src/routes/staking/home/validator-tables/consensus-validators-table.tsx b/apps/governance/src/routes/staking/home/validator-tables/consensus-validators-table.tsx index 63272683f..915d7f394 100644 --- a/apps/governance/src/routes/staking/home/validator-tables/consensus-validators-table.tsx +++ b/apps/governance/src/routes/staking/home/validator-tables/consensus-validators-table.tsx @@ -185,15 +185,19 @@ export const ConsensusValidatorsTable = ({ const { rawValidatorScore: previousEpochValidatorScore } = getLastEpochScoreAndPerformance(previousEpochData, id); - const overstakingPenalty = calculateOverallPenalty( + const overstakingPenalty = calculateOverstakedPenalty( id, allNodesInPreviousEpoch ); - const totalPenalty = calculateOverstakedPenalty( + const totalPenalty = calculateOverallPenalty( id, allNodesInPreviousEpoch ); + const lastEpochDataForNode = allNodesInPreviousEpoch.find( + (node) => node.id === id + ); + return { id, [ValidatorFields.RANKING_INDEX]: stakedTotalRanking, @@ -239,6 +243,12 @@ export const ConsensusValidatorsTable = ({ : undefined, [ValidatorFields.MULTISIG_ERROR]: multisigStatus?.showMultisigStatusError, + [ValidatorFields.MULTISIG_PENALTY]: formatNumberPercentage( + new BigNumber(1) + .minus(lastEpochDataForNode?.rewardScore?.multisigScore ?? 1) + .times(100), + 2 + ), }; } ); @@ -378,7 +388,6 @@ export const ConsensusValidatorsTable = ({ headerTooltip: t('StakeDescription').toString(), cellRenderer: TotalStakeRenderer, width: 120, - sort: 'desc', }, { field: ValidatorFields.PENDING_STAKE, @@ -400,6 +409,7 @@ export const ConsensusValidatorsTable = ({ headerTooltip: t('NormalisedVotingPowerDescription').toString(), cellRenderer: VotingPowerRenderer, width: 120, + sort: 'desc', }, { field: ValidatorFields.TOTAL_PENALTIES, diff --git a/apps/governance/src/routes/staking/home/validator-tables/shared.tsx b/apps/governance/src/routes/staking/home/validator-tables/shared.tsx index 1abc3f8d3..fd804ce2e 100644 --- a/apps/governance/src/routes/staking/home/validator-tables/shared.tsx +++ b/apps/governance/src/routes/staking/home/validator-tables/shared.tsx @@ -40,6 +40,7 @@ export enum ValidatorFields { PENDING_USER_STAKE = 'pendingUserStake', USER_STAKE_SHARE = 'userStakeShare', MULTISIG_ERROR = 'multisigError', + MULTISIG_PENALTY = 'multisigPenalty', } export const addUserDataToValidator = ( @@ -327,7 +328,7 @@ interface TotalPenaltiesRendererProps { overstakedAmount: string; overstakingPenalty: string; totalPenalties: string; - multisigError?: boolean; + multisigPenalty: string; }; } @@ -346,11 +347,9 @@ export const TotalPenaltiesRenderer = ({
{t('overstakedPenalty')}: {data.overstakingPenalty}
- {data.multisigError && ( -
- {t('multisigPenalty')}: 100% -
- )} +
+ {t('multisigPenalty')}: {data.multisigPenalty} +
} > diff --git a/apps/governance/src/routes/staking/node/validator-table.tsx b/apps/governance/src/routes/staking/node/validator-table.tsx index 7c0c79a19..550052796 100644 --- a/apps/governance/src/routes/staking/node/validator-table.tsx +++ b/apps/governance/src/routes/staking/node/validator-table.tsx @@ -37,7 +37,6 @@ import { import type { ReactNode } from 'react'; import type { StakingNodeFieldsFragment } from '../__generated__/Staking'; import type { PreviousEpochQuery } from '../__generated__/PreviousEpoch'; -import { getMultisigStatusInfo } from '../../../lib/get-multisig-status-info'; const statuses = { [Schema.ValidatorStatus.VALIDATOR_NODE_STATUS_ERSATZ]: 'status-ersatz', @@ -105,9 +104,10 @@ export const ValidatorTable = ({ }; }, [node, previousEpochData?.epoch.validatorsConnection?.edges]); - const multisigStatus = previousEpochData - ? getMultisigStatusInfo(previousEpochData) - : undefined; + const previousNodeData = + previousEpochData?.epoch.validatorsConnection?.edges?.find( + (e) => e?.node.id === node.id + ); return ( <> @@ -293,21 +293,15 @@ export const ValidatorTable = ({ data-testid="multisig-penalty" className="flex gap-2 items-baseline" > - {multisigStatus?.zeroScoreNodes.find( - (n) => n.id === node.id - ) ? ( - - - - ) : null} {formatNumberPercentage( - BigNumber( - multisigStatus?.showMultisigStatusError ? 100 : 0 - ), + new BigNumber(1) + .minus( + previousNodeData?.node.rewardScore?.multisigScore ?? + 1 + ) + .times(100), 2 )}