From a4ff5bf1d0567e514e07c1403503502343943141 Mon Sep 17 00:00:00 2001 From: Jian Xiao <99709935+jianoaix@users.noreply.github.com> Date: Fri, 31 May 2024 13:00:25 -0700 Subject: [PATCH] Allow decimal basis points for stake share (#590) --- node/metrics.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/node/metrics.go b/node/metrics.go index a429a5513..940b0a130 100644 --- a/node/metrics.go +++ b/node/metrics.go @@ -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.