config

package
v1.0.1-alpha Latest Latest
Warning

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

Go to latest
Published: Apr 25, 2023 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DenomUSD = "USD"
)

Variables

View Source
var (

	// ErrEmptyConfigPath defines a sentinel error for an empty config path.
	ErrEmptyConfigPath = errors.New("empty configuration file path")

	// SupportedProviders defines a lookup table of all the supported currency API
	// providers.
	SupportedProviders = map[provider.Name]struct{}{
		provider.Kraken:    {},
		provider.Binance:   {},
		provider.BinanceUS: {},
		provider.Osmosis:   {},
		provider.Crypto:    {},
		provider.Coinbase:  {},
		provider.Huobi:     {},
		provider.Mock:      {},
	}

	// SupportedQuotes defines a lookup table for which assets we support
	// using as quotes.
	SupportedQuotes = map[string]struct{}{
		DenomUSD: {},
	}
)

Functions

func CheckProviderMinimum

func CheckProviderMinimum(ctx context.Context, logger zerolog.Logger, cfg Config) error

CheckProviderMinimum starts the currency provider tracker to check the amount of providers available for a currency by querying CoinGecko's API. It will enforce a provider minimum for a given currency based on its available providers.

Types

type Account

type Account struct {
	ChainID   string `mapstructure:"chain_id" validate:"required"`
	Address   string `mapstructure:"address" validate:"required"`
	Validator string `mapstructure:"validator" validate:"required"`
}

Account defines account related configuration that is related to the persistenceOne network and transaction signing functionality.

type Config

type Config struct {
	Server              Server              `mapstructure:"server"`
	CurrencyPairs       []CurrencyPair      `mapstructure:"currency_pairs" validate:"required,gt=0,dive,required"`
	Deviations          []Deviation         `mapstructure:"deviation_thresholds"`
	Account             Account             `mapstructure:"account" validate:"required,gt=0,dive,required"`
	Keyring             Keyring             `mapstructure:"keyring" validate:"required,gt=0,dive,required"`
	RPC                 RPC                 `mapstructure:"rpc" validate:"required,gt=0,dive,required"`
	GasAdjustment       float64             `mapstructure:"gas_adjustment" validate:"required"`
	ProviderTimeout     string              `mapstructure:"provider_timeout"`
	ProviderMinOverride bool                `mapstructure:"provider_min_override"`
	ProviderEndpoints   []provider.Endpoint `mapstructure:"provider_endpoints" validate:"dive"`
	Fees                string              `mapstructure:"fees"`
}

Config defines all necessary price-feeder configuration parameters.

func ParseConfig

func ParseConfig(configPath string) (Config, error)

ParseConfig attempts to read and parse configuration from the given file path. An error is returned if reading or parsing the config fails.

func (Config) Validate

func (c Config) Validate() error

Validate returns an error if the Config object is invalid.

type CurrencyPair

type CurrencyPair struct {
	Base      string          `mapstructure:"base" validate:"required"`
	Quote     string          `mapstructure:"quote" validate:"required"`
	Providers []provider.Name `mapstructure:"providers" validate:"required,gt=0,dive,required"`
}

CurrencyPair defines a price quote of the exchange rate for two different currencies and the supported providers for getting the exchange rate.

type CurrencyProviderTracker

type CurrencyProviderTracker struct {
	// contains filtered or unexported fields
}

CurrencyProviderTracker queries the CoinGecko API for all the exchanges that support the currency pairs set in the price feeder config. It will poll the APIs every 24 hours to log any new exchanges that were added for a given currency.

REF: https://www.coingecko.com/en/api/documentation

func (*CurrencyProviderTracker) GetMinCurrencyProvider

func (t *CurrencyProviderTracker) GetMinCurrencyProvider() map[string]int

return the minimum amount of providers for each currency.

type Deviation

type Deviation struct {
	Base      string `mapstructure:"base" validate:"required"`
	Threshold string `mapstructure:"threshold" validate:"required"`
}

Deviation defines a maximum amount of standard deviations that a given asset can be from the median without being filtered out before voting.

type Keyring

type Keyring struct {
	Dir        string `mapstructure:"dir"`
	Backend    string `mapstructure:"backend"`
	Passphrase string `mapstructure:"passphrase"`
	PrivKeyHex string `mapstructure:"priv_key_hex"`
	Mnemonic   string `mapstructure:"mnemonic"`
}

Keyring defines the required persistenceOne keyring configuration. If privkey hex or mnemonic provided, it must match with account address.

type RPC

type RPC struct {
	TMRPCEndpoint string `mapstructure:"tmrpc_endpoint" validate:"required"`
	GRPCEndpoint  string `mapstructure:"grpc_endpoint" validate:"required"`
	RPCTimeout    string `mapstructure:"rpc_timeout" validate:"required"`
}

RPC defines RPC configuration of both the persistenceOne gRPC and Tendermint nodes.

type Server

type Server struct {
	ListenAddr     string   `mapstructure:"listen_addr"`
	WriteTimeout   string   `mapstructure:"write_timeout"`
	ReadTimeout    string   `mapstructure:"read_timeout"`
	VerboseCORS    bool     `mapstructure:"verbose_cors"`
	AllowedOrigins []string `mapstructure:"allowed_origins"`
}

Server defines the API server configuration.

Jump to

Keyboard shortcuts

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