Skip to content

Commit

Permalink
Prestaking: update default underdog calculation
Browse files Browse the repository at this point in the history
  • Loading branch information
mraveux committed Oct 8, 2024
1 parent 271731d commit c35833f
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions src/components/prestaking/PrestakingValidatorPage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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<HTMLElement | null>(null);
const stakeFetched = ref(false);
Expand Down Expand Up @@ -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])),
}));
}
}
Expand Down

0 comments on commit c35833f

Please sign in to comment.