voteweighted

package
v0.0.0-...-23a414b Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 14, 2024 License: AGPL-3.0, AGPL-3.0-or-later Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultPowerThreshold = big.NewRat(2, 3)

DefaultPowerThreshold defines the total voting power % that must be submitted in order for a currency pair to be considered for the final oracle price. We provide a default supermajority threshold of 2/3+.

Functions

func ComputeMedian

func ComputeMedian(prices []PricePerValidator, totalWeight math.Int) *big.Int

func GetPowerFromBondedTokens

func GetPowerFromBondedTokens(
	tokens math.Int,
) int64

Types

type AggregatorPricePair

type AggregatorPricePair struct {
	SpotPrice *big.Int
	PnlPrice  *big.Int
}

type ConversionRateAggregateFn

type ConversionRateAggregateFn func(ctx sdk.Context, veConversionRates map[string]*big.Int) (*big.Int, error)

func MedianConversionRate

func MedianConversionRate(
	logger log.Logger,
	validatorStore ValidatorStore,
	threshold *big.Rat,
) ConversionRateAggregateFn

type ConverstionRateInfo

type ConverstionRateInfo struct {
	ConversionRates []PricePerValidator
	TotalWeight     math.Int
}

type PriceInfo

type PriceInfo struct {
	SpotPrices  []PricePerValidator
	PnlPrices   []PricePerValidator
	TotalWeight math.Int
}

VoteWeightPriceInfo tracks the stake weight(s) + price(s) for a given currency pair.

type PricePerValidator

type PricePerValidator struct {
	VoteWeight math.Int
	Price      *big.Int
}

VoteWeightPrice defines a price update that includes the stake weight of the validator.

type PricesAggregateFn

type PricesAggregateFn func(ctx sdk.Context, vePrices map[string]map[string]AggregatorPricePair) (map[string]AggregatorPricePair, error)

func MedianPrices

func MedianPrices(
	logger log.Logger,
	validatorStore ValidatorStore,
	threshold *big.Rat,
) PricesAggregateFn

type ValidatorStore

type ValidatorStore interface {
	ValidatorByConsAddr(ctx context.Context, addr sdk.ConsAddress) (stakingtypes.ValidatorI, error)
	TotalBondedTokens(ctx context.Context) (math.Int, error)
	GetPubKeyByConsAddr(context.Context, sdk.ConsAddress) (cmtprotocrypto.PublicKey, error)
	GetValidator(ctx context.Context, valAddr sdk.ValAddress) (stakingtypes.Validator, error)
	GetAllValidators(ctx context.Context) ([]stakingtypes.Validator, error)
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL