types

package
v2.3.0 Latest Latest
Warning

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

Go to latest
Published: Jan 16, 2025 License: Apache-2.0 Imports: 16 Imported by: 1

Documentation

Index

Constants

View Source
const ConfigType = "price_provider"

ConfigType is the type of the API/WebSocket configuration.

Variables

View Source
var (
	// NewPriceResult is a function alias for the new price result.
	NewPriceResult = providertypes.NewResult[*big.Float]

	// NewPriceResultWithCode is a function alias for the new price result with code.
	NewPriceResultWithCode = providertypes.NewResultWithCode[*big.Float]

	// NewPriceResponse is a function alias for the new price response.
	NewPriceResponse = providertypes.NewGetResponse[ProviderTicker, *big.Float]

	// NewPriceResponseWithErr is a function alias for the new price response with errors.
	NewPriceResponseWithErr = providertypes.NewGetResponseWithErr[ProviderTicker, *big.Float]

	// NewPriceProvider is a function alias for the new price provider.
	NewPriceProvider = base.NewProvider[ProviderTicker, *big.Float]

	// NewPriceAPIQueryHandlerWithFetcher is a function alias for the new API query handler with fetcher.
	NewPriceAPIQueryHandlerWithFetcher = apihandlers.NewAPIQueryHandlerWithFetcher[ProviderTicker, *big.Float]

	// NewPriceWebSocketQueryHandler is a function alias for the new web socket query handler meant to be
	// used by the price providers.
	NewPriceWebSocketQueryHandler = wshandlers.NewWebSocketQueryHandler[ProviderTicker, *big.Float]
)

Functions

This section is empty.

Types

type CurrencyPairsToProviderTickers

type CurrencyPairsToProviderTickers map[pkgtypes.CurrencyPair]DefaultProviderTicker

CurrencyPairsToProviderTickers is a map of tickers to provider tickers. This should be utilized by providers to configure the tickers they will be providing data for.

func (CurrencyPairsToProviderTickers) MustGetProviderConfig

MustGetProviderConfig returns the provider config for the given currency pair. This function is mostly used for testing.

func (CurrencyPairsToProviderTickers) MustGetProviderTicker

MustGetProviderTicker returns the provider ticker for the given currency pair. This function is mostly used for testing.

func (CurrencyPairsToProviderTickers) ToProviderTickers

func (tpt CurrencyPairsToProviderTickers) ToProviderTickers() []ProviderTicker

ToProviderTickers converts the map to a list of provider tickers.

type DefaultProviderTicker

type DefaultProviderTicker struct {
	OffChainTicker string
	JSON           string
}

DefaultProviderTicker is a basic implementation of the ProviderTicker interface. Provider's that utilize this implementation should be able to easily configure custom json data for their tickers.

func (DefaultProviderTicker) GetJSON

func (t DefaultProviderTicker) GetJSON() string

GetJSON returns additional JSON data for the ticker.

func (DefaultProviderTicker) GetOffChainTicker

func (t DefaultProviderTicker) GetOffChainTicker() string

GetOffChainTicker returns the off-chain representation for the ticker.

func (DefaultProviderTicker) String

func (t DefaultProviderTicker) String() string

String returns the string representation of the provider ticker.

type PriceAPIDataHandler

type PriceAPIDataHandler = apihandlers.APIDataHandler[ProviderTicker, *big.Float]

PriceAPIDataHandler is a type alias for the price API data handler. This is responsible for parsing http responses and returning the resolved and unresolved prices.

type PriceAPIFetcher

type PriceAPIFetcher = apihandlers.APIFetcher[ProviderTicker, *big.Float]

PriceAPIFetcher is a type alias for the price API fetcher. This is responsible for fetching the prices from the price provider.

type PriceAPIQueryHandler

type PriceAPIQueryHandler = apihandlers.APIQueryHandler[ProviderTicker, *big.Float]

PriceAPIQueryHandler is a type alias for the price API query handler. This is responsible for building the API query for the price provider and returning the resolved and unresolved prices.

type PriceAPIQueryHandlerFactory

type PriceAPIQueryHandlerFactory = func(
	ctx context.Context,
	logger *zap.Logger,
	cfg config.ProviderConfig,
	apiMetrics apimetrics.APIMetrics,
) (PriceAPIQueryHandler, error)

PriceAPIQueryHandlerFactory is a type alias for the price API query handler factory. This is responsible for creating the API query handler for the price provider.

type PriceProvider

type PriceProvider = base.Provider[ProviderTicker, *big.Float]

PriceProvider is a type alias for the base price provider. This specifically implements the provider interface for the price provider along with the additional base provider methods.

type PriceResponse

PriceResponse is a type alias for the price response. A price response is composed of a map of resolved prices and a map of unresolved prices. Resolved prices are the prices that were successfully fetched from the API, while unresolved prices are the prices that were not successfully fetched from the API.

type PriceWebSocketDataHandler

type PriceWebSocketDataHandler = wshandlers.WebSocketDataHandler[ProviderTicker, *big.Float]

PriceWebSocketDataHandler is a type alias for the price web socket data handler. This is responsible for parsing web socket messages and returning the resolved and unresolved prices.

type PriceWebSocketQueryHandler

type PriceWebSocketQueryHandler = wshandlers.WebSocketQueryHandler[ProviderTicker, *big.Float]

PriceWebSocketQueryHandler is a type alias for the price web socket query handler. This is responsible for building the web socket query for the price provider and returning the resolved and unresolved prices.

type PriceWebSocketQueryHandlerFactory

type PriceWebSocketQueryHandlerFactory = func(
	ctx context.Context,
	logger *zap.Logger,
	cfg config.ProviderConfig,
	wsMetrics wsmetrics.WebSocketMetrics,
) (PriceWebSocketQueryHandler, error)

PriceWebSocketQueryHandlerFactory is a type alias for the price web socket query handler factory. This is responsible for creating the web socket query handler for the price provider.

type Prices

type Prices = map[string]*big.Float

Prices is a type alias for a map of ticker to a price.

type ProviderTicker

type ProviderTicker interface {
	fmt.Stringer

	// GetOffChainTicker returns the off-chain representation for the ticker.
	GetOffChainTicker() string
	// GetJSON returns additional JSON data for the ticker.
	GetJSON() string
}

ProviderTicker is the interface for the ticker that provider's utilize/return.

func NewProviderTicker

func NewProviderTicker(
	offChain, json string,
) ProviderTicker

NewProviderTicker returns a new provider ticker.

func ProviderTickersFromMarketMap

func ProviderTickersFromMarketMap(
	name string,
	marketMap mmtypes.MarketMap,
) ([]ProviderTicker, error)

ProviderTickersFromMarketMap returns the set of provider tickers a given provider should be providing data for based on the market map.

type ProviderTickers

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

ProviderTickers is a thread safe helper struct to manage a list of provider tickers.

func NewProviderTickers

func NewProviderTickers(tickers ...ProviderTicker) ProviderTickers

NewProviderTickers returns a new list of provider tickers.

func (*ProviderTickers) Add

func (t *ProviderTickers) Add(ticker ProviderTicker)

Add adds a provider ticker to the list of provider tickers.

func (*ProviderTickers) FromOffChainTicker

func (t *ProviderTickers) FromOffChainTicker(offChain string) (ProviderTicker, bool)

FromOffChainTicker returns the provider ticker from the off-chain ticker.

func (*ProviderTickers) NoPriceChangeResponse

func (t *ProviderTickers) NoPriceChangeResponse() PriceResponse

NoPriceChangeResponse is used to handle a message that indicates that the price has not changed. In particular, this will update the base provider with the ResponseCodeUnchanged code for all tickers.

type ResolvedPrices

type ResolvedPrices = map[ProviderTicker]providertypes.ResolvedResult[*big.Float]

ResolvedPrices is a type alias for the resolved prices.

type UnResolvedPrices

type UnResolvedPrices = map[ProviderTicker]providertypes.UnresolvedResult

UnResolvedPrices is a type alias for the unresolved prices.

Jump to

Keyboard shortcuts

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