Skip to content

Commit

Permalink
fix useValidatorsList when totalStaking is zero
Browse files Browse the repository at this point in the history
  • Loading branch information
eshark9312 committed Aug 7, 2023
1 parent c515ad6 commit 0bd4e2f
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions packages/ui/src/validators/hooks/useValidatorsList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -95,15 +95,15 @@ export const useValidatorsList = () => {
map(([activeValidators, stakingInfo, rewardHistory, validatorInfo]) => {
const encodedAddress = encodeAddress(address)
const apr =
rewardHistory.length &&
stakingInfo.total.toNumber() &&
last(rewardHistory)
.eraReward.toBn()
.muln(ERAS_PER_YEAR)
.mul(validatorInfo.commission.toBn())
.div(stakingInfo.total.toBn())
.divn(10 ** 7) // Convert from Perbill to Percent
.toNumber()
rewardHistory.length && !stakingInfo.total.toBn().isZero()
? last(rewardHistory)
.eraReward.toBn()
.muln(ERAS_PER_YEAR)
.mul(validatorInfo.commission.toBn())
.div(stakingInfo.total.toBn())
.divn(10 ** 7) // Convert from Perbill to Percent
.toNumber()
: 0
return {
member: getMember(encodedAddress),
address: encodedAddress,
Expand Down

0 comments on commit 0bd4e2f

Please sign in to comment.