From 4e8fe0c7520776dd2dd8387634a040da25503773 Mon Sep 17 00:00:00 2001 From: Jian Xiao Date: Fri, 31 May 2024 18:25:15 +0000 Subject: [PATCH] Allow decimal basis points for stake share --- node/metrics.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/node/metrics.go b/node/metrics.go index a429a5513e..940b0a1300 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.