The core protocol of WoopChain
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
woop/staking/network/values.go

31 lines
735 B

package network
import (
"math/big"
"time"
"github.com/woop-chain/woop/consensus/engine"
"github.com/woop-chain/woop/numeric"
)
// UtilityMetric ..
type UtilityMetric struct {
AccumulatorSnapshot *big.Int
CurrentStakedPercentage numeric.Dec
Deviation numeric.Dec
Adjustment numeric.Dec
}
// NewUtilityMetricSnapshot ..
func NewUtilityMetricSnapshot(beaconchain engine.ChainReader) (*UtilityMetric, error) {
soFarDoledOut, percentageStaked, err := WhatPercentStakedNow(
beaconchain, time.Now().Unix(),
)
if err != nil {
return nil, err
}
howMuchOff, adjustBy := Adjustment(*percentageStaked)
return &UtilityMetric{
soFarDoledOut, *percentageStaked, howMuchOff, adjustBy,
}, nil
}