Skip to content

Commit 42fddab

Browse files
committed
If no Underdog, lower stake become one
1 parent 4a56d02 commit 42fddab

File tree

2 files changed

+24
-12
lines changed

2 files changed

+24
-12
lines changed

src/components/prestaking/PrestakingValidatorPage.vue

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,15 @@
2121
<div class="validator-list" ref="validatorList$">
2222
<div class="scroll-mask top"></div>
2323
<LoadingList v-if="!stakeFetched" :length="4" :type="LoadingListType.VALIDATOR" />
24-
<ValidatorListItem v-else
25-
v-for="validator in sortedList" :key="validator.address"
26-
:validator="validator"
27-
:container="validatorList$"
28-
@click.native="selectValidator(validator)"
29-
/>
24+
<template v-else>
25+
<ValidatorListItem
26+
v-for="validator in sortedList"
27+
:key="validator.address"
28+
:validator="validator"
29+
:container="validatorList$"
30+
@click.native="selectValidator(validator)"
31+
/>
32+
</template>
3033
<div class="scroll-mask bottom"></div>
3134
</div>
3235
</PageBody>
@@ -121,7 +124,18 @@ export default defineComponent({
121124
if (cmp) return cmp;
122125
return a.address < b.address ? -1 : 1;
123126
});
124-
return list;
127+
128+
// Calculate underdog status
129+
const poolsWithStake = list.filter((v) => 'label' in v && v.stake !== null);
130+
const totalStake = poolsWithStake.reduce((sum, v) => sum + (v.stake || 0), 0);
131+
const hasUnderdog = poolsWithStake.some((v) => (v.stake || 0) / totalStake < 0.1);
132+
133+
return list.map((validator) => ({
134+
...validator,
135+
isUnderdog: 'label' in validator
136+
&& ((validator.stake || 0) / totalStake < 0.1
137+
|| (!hasUnderdog && validator === poolsWithStake[0])),
138+
}));
125139
}
126140
}
127141
});

src/components/prestaking/ValidatorListItem.vue

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
<div v-if="validator.stake !== null" class="validator-stake">
2525
{{ $t('Stake: {validatorStake}%', { validatorStake: validatorStakePercentage }) }}
2626
</div>
27-
<template v-if="isUnderdog">
27+
<template v-if="validator.isUnderdog">
2828
<strong class="dot">&middot;</strong>
2929
<div class="validator-underdog">
3030
{{ $t('Underdog') }}
@@ -43,7 +43,7 @@
4343
</div>
4444
</div>
4545
<!-- <ValidatorRewardBubble v-if="'reward' in validator" :reward="validator.reward" /> -->
46-
<div v-if="isUnderdog" class="underdog-info flex-row">
46+
<div v-if="validator.isUnderdog" class="underdog-info flex-row">
4747
<img src="../../assets/prestaking/underdog-icon.svg" alt="Underdog" class="underdog-icon">
4848
<div class="points-pill">{{ $t('5x points') }}</div>
4949
</div>
@@ -64,7 +64,7 @@ export default defineComponent({
6464
props: {
6565
container: HTMLElement,
6666
validator: {
67-
type: Object as () => Validator,
67+
type: Object as () => Validator & { isUnderdog?: boolean },
6868
required: true,
6969
},
7070
},
@@ -83,13 +83,11 @@ export default defineComponent({
8383
() => Math.round(((props.validator.stake || 0) / globalStake.value) * 1000) / 10,
8484
);
8585
86-
const isUnderdog = computed(() => props.validator.stake !== null && validatorStakePercentage.value < 10);
8786
const hasHighStake = computed(() => props.validator.stake !== null && validatorStakePercentage.value >= 20);
8887
8988
return {
9089
// payoutText,
9190
validatorStakePercentage,
92-
isUnderdog,
9391
hasHighStake,
9492
};
9593
},

0 commit comments

Comments
 (0)