Skip to content

Commit

Permalink
Fix division by zero
Browse files Browse the repository at this point in the history
  • Loading branch information
Mariano Aguero committed Jun 28, 2019
1 parent a459d93 commit 66dde59
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion server/helpers/services/delegatorService.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,10 @@ class DelegatorService {
delegateService.getDelegateRewardToDelegators(delegateAddress)
])
// Delegator participation FORMULA: delegatorTotalStake / delegateTotalStake
const delegatorParticipationInTotalStake = MathBN.div(totalStake, delegateTotalStake)
let delegatorParticipationInTotalStake = 0
if (delegateTotalStake > 0) {
delegatorParticipationInTotalStake = MathBN.div(totalStake, delegateTotalStake)
}
return MathBN.mul(rewardToDelegators, delegatorParticipationInTotalStake)
}
}
Expand Down

0 comments on commit 66dde59

Please sign in to comment.