Documentation ¶
Index ¶
Constants ¶
const (
// Name is the name of this provider
Name = "coinmarketcap"
)
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct { // APIKey is the API key used to make requests to the coinmarketcap API. APIKey string `mapstructure:"api_key" toml:"api_key"` // TokenNameToMetadata is a map of token names to their metadata. TokenNameToSymbol map[string]string `mapstructure:"token_name_to_symbol" toml:"token_name_to_symbol"` }
Config is the config struct for the coinmarketcap provider.
func ReadCoinMarketCapConfigFromFile ¶
ReadCoinMarketCapConfigFromFile reads a config from a file and returns the config.
type Provider ¶
type Provider struct {
// contains filtered or unexported fields
}
Provider is the implementation of the oracle's Provider interface for coinmarketcap.
func NewProvider ¶
func NewProvider(logger log.Logger, pairs []oracletypes.CurrencyPair, providerConfig config.ProviderConfig) (*Provider, error)
NewProvider returns a new coinmarketcap provider. It uses the provided API-key in the header of outgoing requests to coinmarketcap's API.
func (*Provider) GetPairs ¶
func (p *Provider) GetPairs() []oracletypes.CurrencyPair
GetPairs returns the currency pairs that the provider is fetching prices for.
func (*Provider) GetPrices ¶
func (p *Provider) GetPrices(ctx context.Context) (map[oracletypes.CurrencyPair]aggregator.QuotePrice, error)
GetPrices returns the current set of prices for each of the currency pairs. This method starts all price requests concurrently, and waits for them all to finish, or for the context to be cancelled, at which point it aggregates the responses and returns.
func (*Provider) SetPairs ¶
func (p *Provider) SetPairs(pairs ...oracletypes.CurrencyPair)
SetPairs sets the currency pairs that the provider will fetch prices for.