From c35833f24dbbf52fe7d2be586c1457d03d148a08 Mon Sep 17 00:00:00 2001 From: Mraveux Date: Tue, 8 Oct 2024 13:10:19 +0200 Subject: [PATCH] Prestaking: update default underdog calculation --- src/components/prestaking/PrestakingValidatorPage.vue | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/src/components/prestaking/PrestakingValidatorPage.vue b/src/components/prestaking/PrestakingValidatorPage.vue index f6ac94997..2e9da8838 100644 --- a/src/components/prestaking/PrestakingValidatorPage.vue +++ b/src/components/prestaking/PrestakingValidatorPage.vue @@ -55,7 +55,7 @@ export default defineComponent({ setup(props, context) { const { config } = useConfig(); const { activeAddress } = useAddressStore(); - const { validatorsList, activePrestake, setPrestake } = usePrestakingStore(); + const { validatorsList, activePrestake, setPrestake, globalStake: totalStake } = usePrestakingStore(); const validatorList$ = ref(null); const stakeFetched = ref(false); @@ -127,16 +127,13 @@ export default defineComponent({ return a.address < b.address ? -1 : 1; }); - // Calculate underdog status - const poolsWithStake = list.filter((v) => 'label' in v && v.stake !== null); - const totalStake = poolsWithStake.reduce((sum, v) => sum + (v.stake || 0), 0); - const hasUnderdog = poolsWithStake.some((v) => (v.stake || 0) / totalStake < 0.1); + const hasUnderdog = list.some((v) => (v.stake || 0) / totalStake.value < 0.1); return list.map((validator) => ({ ...validator, isUnderdog: 'label' in validator - && ((validator.stake || 0) / totalStake < 0.1 - || (!hasUnderdog && validator === poolsWithStake[0])), + && ((validator.stake || 0) / totalStake.value < 0.1 + || (!hasUnderdog && validator === list[0])), })); } }