From b64482666e6eaae544f34b8f6861ac367379d38b Mon Sep 17 00:00:00 2001 From: JCNoguera Date: Thu, 30 Nov 2023 10:24:29 +0100 Subject: [PATCH] exclude a validator on role changes --- .../ManaCalculator/actions/calculateManaRewards.ts | 14 +++++++++----- .../components/AdvancedSettingsValidator.tsx | 12 +++++++----- .../ManaCalculator/hooks/useManaState.ts | 7 +++++++ .../ManaCalculator/types/validator.type.ts | 1 + 4 files changed, 24 insertions(+), 10 deletions(-) diff --git a/src/components/ManaCalculator/actions/calculateManaRewards.ts b/src/components/ManaCalculator/actions/calculateManaRewards.ts index b2ea44e3863..affe8cde86f 100644 --- a/src/components/ManaCalculator/actions/calculateManaRewards.ts +++ b/src/components/ManaCalculator/actions/calculateManaRewards.ts @@ -32,16 +32,20 @@ export function calculateManaRewards( totalTargetReward = targetReward(initialEpoch, supply, generationPerSlot); } - const lockedStake: number[] = validators.map( + const filteredValidators = validators.filter( + (validator) => !validator.excluded, + ); + + const lockedStake: number[] = filteredValidators.map( (validator) => validator.lockedStake, ); - const fixedCosts: number[] = validators.map( + const fixedCosts: number[] = filteredValidators.map( (validator) => validator.fixedCost, ); - const performance: number[] = validators.map( + const performance: number[] = filteredValidators.map( (validator) => validator.performanceFactor, ); - const delegatedStake: number[] = validators.map( + const delegatedStake: number[] = filteredValidators.map( (validator) => validator.delegatedStake, ); @@ -55,7 +59,7 @@ export function calculateManaRewards( validatorParameters.attractedDelegatedStakeFromOtherPools * delegatedStake.reduce((a, b) => a + b, 0), ); - for (let i = 0; i < validators.length; i++) { + for (let i = 0; i < filteredValidators.length; i++) { delegatedStake[i] *= 1 - validatorParameters.attractedDelegatedStakeFromOtherPools; } diff --git a/src/components/ManaCalculator/components/AdvancedSettingsValidator.tsx b/src/components/ManaCalculator/components/AdvancedSettingsValidator.tsx index e29f0ae995f..d0d9026ce29 100644 --- a/src/components/ManaCalculator/components/AdvancedSettingsValidator.tsx +++ b/src/components/ManaCalculator/components/AdvancedSettingsValidator.tsx @@ -37,11 +37,13 @@ export function AdvancedSettingsValidator() {
- {state.validators.map((validator, i) => ( -
- -
- ))} + {state.validators + .filter(({ excluded }) => !excluded) + .map((validator, i) => ( +
+ +
+ ))}