Documentation ¶
Index ¶
- Constants
- Variables
- func CheckProviderMins(ctx context.Context, logger zerolog.Logger, cfg Config) error
- func SupportedConversionSlice() []types.CurrencyPair
- type APIKeyRequired
- type Account
- type Config
- func (c Config) DeviationsMap() (map[string]math.LegacyDec, error)
- func (c Config) ExpectedSymbols() []string
- func (c Config) ProviderEndpointsMap() map[types.ProviderName]provider.Endpoint
- func (c Config) ProviderPairs() map[types.ProviderName][]types.CurrencyPair
- func (c Config) Validate() (err error)
- type CurrencyPair
- type CurrencyProviderTracker
- type Deviation
- type Keyring
- type PairAddressProvider
- type RPC
- type Server
Constants ¶
const ( DenomUSD = "USD" SampleNodeConfigPath = "price-feeder.example.toml" )
Variables ¶
var ( // SupportedProviders defines a lookup table of all the supported currency API // providers and whether or not they require an API key to be passed in. SupportedProviders = map[types.ProviderName]APIKeyRequired{ provider.ProviderKraken: false, provider.ProviderBinance: false, provider.ProviderBinanceUS: false, provider.ProviderCrescent: false, provider.ProviderOsmosis: false, provider.ProviderOkx: false, provider.ProviderHuobi: false, provider.ProviderGate: false, provider.ProviderCoinbase: false, provider.ProviderBitget: false, provider.ProviderMexc: false, provider.ProviderCrypto: false, provider.ProviderPolygon: true, provider.ProviderEthUniswap: false, provider.ProviderKujira: false, provider.ProviderAstroport: false, provider.ProviderMock: false, } // SupportedConversions defines a lookup table for which currency pairs we // support converting prices with. Each currency pair with a non-USD quote // requires a corresponding USD conversion rate. SupportedConversions = map[types.CurrencyPair]struct{}{ {Base: "USDC", Quote: "USD"}: {}, {Base: "USDT", Quote: "USD"}: {}, {Base: "DAI", Quote: "USD"}: {}, {Base: "BTC", Quote: "USD"}: {}, {Base: "ETH", Quote: "USD"}: {}, {Base: "ATOM", Quote: "USD"}: {}, {Base: "OSMO", Quote: "USD"}: {}, {Base: "INJ", Quote: "USD"}: {}, {Base: "OSMO", Quote: "USDT"}: {}, {Base: "JUNO", Quote: "USDT"}: {}, {Base: "WETH", Quote: "USDC"}: {}, {Base: "WBTC", Quote: "WETH"}: {}, {Base: "INJ", Quote: "USDT"}: {}, } SupportedUniswapCurrencies = map[string]struct{}{ "WETH": {}, "CBETH": {}, "RETH": {}, "WBTC": {}, } // SupportedForexCurrencies defines a lookup table for all the supported // Forex currencies SupportedForexCurrencies = map[string]struct{}{}/* 157 elements not displayed */ )
var ( // ErrEmptyConfigPath defines a sentinel error for an empty config path. ErrEmptyConfigPath = errors.New("empty configuration file path") )
Functions ¶
func CheckProviderMins ¶
CheckProviderMins 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.
func SupportedConversionSlice ¶ added in v0.1.4
func SupportedConversionSlice() []types.CurrencyPair
Types ¶
type APIKeyRequired ¶ added in v0.1.1
type APIKeyRequired bool
type Account ¶
type Account struct { ChainID string `mapstructure:"chain_id"` Address string `mapstructure:"address"` Validator string `mapstructure:"validator"` }
Account defines account related configuration that is related to the Ojo network and transaction signing functionality.
type Config ¶
type Config struct { ConfigDir string `mapstructure:"config_dir"` Server Server `mapstructure:"server"` CurrencyPairs []CurrencyPair `mapstructure:"currency_pairs" validate:"required,gt=0,dive,required"` Deviations []Deviation `mapstructure:"deviation_thresholds"` Account Account `mapstructure:"account"` Keyring Keyring `mapstructure:"keyring"` RPC RPC `mapstructure:"rpc" validate:"required,gt=0,dive,required"` Telemetry telemetry.Config `mapstructure:"telemetry"` GasAdjustment float64 `mapstructure:"gas_adjustment"` Gas uint64 `mapstructure:"gas"` ProviderTimeout string `mapstructure:"provider_timeout"` ProviderMinOverride bool `mapstructure:"provider_min_override"` ProviderEndpoints []provider.Endpoint `mapstructure:"provider_endpoints" validate:"dive"` }
Config defines all necessary price-feeder configuration parameters.
func LoadConfigFromFlags ¶ added in v0.1.6
LoadConfigFromFlags attempts to read and parse configuration from the node config file path.
func ParseConfig ¶
ParseConfig attempts to read and parse configuration from the given file path. An error is returned if reading or parsing the config fails.
func ParseConfigs ¶ added in v0.1.6
ParseConfigs attempts to read and parse configuration from the given file paths. An error is returned if reading or parsing the configs fails.
func (Config) DeviationsMap ¶ added in v0.1.4
DeviationsMap converts the deviation_thresholds from the config file into a map of math.LegacyDec where the key is the base asset.
func (Config) ExpectedSymbols ¶ added in v0.1.4
ExpectedSymbols returns a slice of all unique base symbols from the config object.
func (Config) ProviderEndpointsMap ¶ added in v0.1.1
func (c Config) ProviderEndpointsMap() map[types.ProviderName]provider.Endpoint
ProviderEndpointsMap converts the provider_endpoints from the config file into a map of provider.Endpoint where the key is the provider name.
func (Config) ProviderPairs ¶ added in v0.1.1
func (c Config) ProviderPairs() map[types.ProviderName][]types.CurrencyPair
ProviderPairs returns a map of provider.CurrencyPair where the key is the provider name.
type CurrencyPair ¶
type CurrencyPair struct { Base string `mapstructure:"base" validate:"required"` Quote string `mapstructure:"quote" validate:"required"` PairAddress []PairAddressProvider `mapstructure:"pair_address_providers" validate:"dive"` Providers []types.ProviderName `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 { CurrencyProviders map[string][]string // map of price feeder currencies and what exchanges support them CurrencyProviderMin map[string]int // map of price feeder currencies and min required providers for them // contains filtered or unexported fields }
CurrencyProviderTracker queries the CoinGecko API and OJO's indexers 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 REF: https://github.com/ojo-network/osmosis-api
func NewCurrencyProviderTracker ¶
func NewCurrencyProviderTracker( ctx context.Context, logger zerolog.Logger, pairs ...CurrencyPair, ) (*CurrencyProviderTracker, error)
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 PairAddressProvider ¶ added in v0.1.5
type PairAddressProvider struct { Address string `mapstructure:"address" validate:"required"` Provider types.ProviderName `mapstructure:"provider" validate:"required"` }
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 Ojo 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.