@@ -14,9 +14,12 @@ import (
1414 "github.com/fatih/color"
1515 "github.com/kilnfi/near-validator-watcher/pkg/metrics"
1616 "github.com/kilnfi/near-validator-watcher/pkg/near"
17+ "github.com/shopspring/decimal"
1718 "github.com/sirupsen/logrus"
1819)
1920
21+ var yoctoUnit = decimal .NewFromInt (10 ).Pow (decimal .NewFromInt (24 ))
22+
2023type Watcher struct {
2124 config * Config
2225 client * near.Client
@@ -158,7 +161,7 @@ func (w *Watcher) collectValidators(ctx context.Context) (near.ValidatorsRespons
158161 w .metrics .ValidatorProducedChunks .WithLabelValues (labels ... ).Set (float64 (v .NumProducedChunks ))
159162
160163 w .metrics .ValidatorSlashed .WithLabelValues (labels ... ).Set (metrics .BoolToFloat64 (v .IsSlashed ))
161- w .metrics .ValidatorStake .WithLabelValues (labels ... ).Set (v .Stake .InexactFloat64 ())
164+ w .metrics .ValidatorStake .WithLabelValues (labels ... ).Set (v .Stake .Div ( yoctoUnit ). InexactFloat64 ())
162165
163166 t := v .Stake .InexactFloat64 ()
164167 if seatPrice == 0 {
@@ -174,13 +177,13 @@ func (w *Watcher) collectValidators(ctx context.Context) (near.ValidatorsRespons
174177 for _ , v := range validators .NextValidators {
175178 w .metrics .NextValidatorStake .
176179 WithLabelValues (v .AccountId , v .PublicKey , labelEpochStartHeight , w .isTracked (v .AccountId )).
177- Set (v .Stake .InexactFloat64 ())
180+ Set (v .Stake .Div ( yoctoUnit ). InexactFloat64 ())
178181 }
179182
180183 for _ , v := range validators .CurrentProposals {
181184 w .metrics .CurrentProposals .
182185 WithLabelValues (v .AccountId , v .PublicKey , labelEpochStartHeight , w .isTracked (v .AccountId )).
183- Set (v .Stake .InexactFloat64 ())
186+ Set (v .Stake .Div ( yoctoUnit ). InexactFloat64 ())
184187 }
185188
186189 for _ , v := range validators .PrevEpochKickOut {
0 commit comments