priceprovider

package
v1.0.3 Latest Latest
Warning

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

Go to latest
Published: Jun 7, 2024 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewAggregatePriceProvider

func NewAggregatePriceProvider(
	sourcesToPairSymbolMap map[string]map[asset.Pair]types.Symbol,
	sourceConfigMap map[string]json.RawMessage,
	logger zerolog.Logger,
) types.PriceProvider

NewAggregatePriceProvider instantiates a new AggregatePriceProvider instance given multiple PriceProvider.

func NewPriceProvider

func NewPriceProvider(
	sourceName string,
	pairToSymbolMap map[asset.Pair]types.Symbol,
	config json.RawMessage,
	logger zerolog.Logger,
) types.PriceProvider

NewPriceProvider returns a types.PriceProvider given the price source we want to gather prices from, the mapping between nibiru asset.Pair and the source's symbols, and a zerolog.Logger instance.

Types

type AggregatePriceProvider

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

AggregatePriceProvider aggregates multiple price providers and queries them for prices.

func (AggregatePriceProvider) Close

func (a AggregatePriceProvider) Close()

func (AggregatePriceProvider) GetPrice

func (a AggregatePriceProvider) GetPrice(pair asset.Pair) types.Price

GetPrice fetches the first available and correct price from the wrapped PriceProviders. Iteration is exhaustive and random. If no correct PriceResponse is found, then an invalid PriceResponse is returned.

type PriceProvider

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

PriceProvider implements the types.PriceProvider interface. it wraps a Source and handles conversions between nibiru asset pair to exchange symbols.

func (*PriceProvider) Close

func (p *PriceProvider) Close()

func (*PriceProvider) GetPrice

func (p *PriceProvider) GetPrice(pair asset.Pair) types.Price

GetPrice returns the types.Price for the given asset.Pair in case price has expired, or for some reason it's impossible to get the last available price, then an invalid types.Price is returned.

Directories

Path Synopsis
Credit: @oleksandrmarkelov https://github.com/NibiruChain/pricefeeder/pull/27
Credit: @oleksandrmarkelov https://github.com/NibiruChain/pricefeeder/pull/27

Jump to

Keyboard shortcuts

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