types

package
v1.2.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 added in v1.2.0

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 added in v1.2.0

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

func (CurrencyPairsToProviderTickers) MustGetProviderTicker added in v1.2.0

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

func (CurrencyPairsToProviderTickers) ToProviderTickers added in v1.2.0

func (tpt CurrencyPairsToProviderTickers) ToProviderTickers() []ProviderTicker

ToProviderTickers converts the map to a list of provider tickers.

type DefaultProviderTicker added in v1.2.0

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 added in v1.2.0

func (t DefaultProviderTicker) GetJSON() string

GetJSON returns additional JSON data for the ticker.

func (DefaultProviderTicker) GetOffChainTicker added in v1.2.0

func (t DefaultProviderTicker) GetOffChainTicker() string

GetOffChainTicker returns the off-chain representation for the ticker.

func (DefaultProviderTicker) String added in v1.2.0

func (t DefaultProviderTicker) String() string

String returns the string representation of the provider ticker.

type PriceAPIDataHandler added in v1.2.0

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 added in v1.2.0

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 added in v1.2.0

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 added in v1.2.0

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 added in v1.2.0

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 added in v1.2.0

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 added in v1.2.0

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 added in v1.2.0

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 added in v1.2.0

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 added in v1.2.0

type Prices = map[string]*big.Float

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

type ProviderTicker added in v1.2.0

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 added in v1.2.0

func NewProviderTicker(
	offChain, json string,
) ProviderTicker

NewProviderTicker returns a new provider ticker.

func ProviderTickersFromMarketMap added in v1.2.0

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 added in v1.2.0

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

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

func NewProviderTickers added in v1.2.0

func NewProviderTickers(tickers ...ProviderTicker) ProviderTickers

NewProviderTickers returns a new list of provider tickers.

func (*ProviderTickers) Add added in v1.2.0

func (t *ProviderTickers) Add(ticker ProviderTicker)

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

func (*ProviderTickers) FromOffChainTicker added in v1.2.0

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

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

func (*ProviderTickers) NoPriceChangeResponse added in v1.2.0

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 added in v1.2.0

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

ResolvedPrices is a type alias for the resolved prices.

type UnResolvedPrices added in v1.2.0

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