Skip to content

Commit

Permalink
Allow decimal basis points for stake share (#590)
Browse files Browse the repository at this point in the history
  • Loading branch information
jianoaix authored May 31, 2024
1 parent 5aecf5c commit a4ff5bf
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion node/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -231,8 +231,12 @@ func (g *Metrics) collectOnchainMetrics() {
}
for q, operators := range state.Operators {
operatorStakeShares := make([]*OperatorStakeShare, 0)
totalStake := new(big.Float).SetInt(state.Totals[q].Stake)
for opId, opInfo := range operators {
share, _ := new(big.Int).Div(new(big.Int).Mul(opInfo.Stake, big.NewInt(10000)), state.Totals[q].Stake).Float64()
opStake := new(big.Float).SetInt(opInfo.Stake)
share, _ := new(big.Float).Quo(
new(big.Float).Mul(opStake, big.NewFloat(100000)),
totalStake).Float64()
operatorStakeShares = append(operatorStakeShares, &OperatorStakeShare{operatorId: opId, stakeShare: share})
}
// Descending order by stake share in the quorum.
Expand Down

0 comments on commit a4ff5bf

Please sign in to comment.