package
2.1.1
Repository: https://github.com/skip-mev/connect.git
Documentation: pkg.go.dev

# README

Oracle

Responsibilities of the Oracle:

  • Spinning up the necessary services (e.g. the sidecar, the price fetchers, etc.).
  • Managing the lifecycle of the providers.
  • Determining the set of markets that need to be fetched and updating the providers accordingly.

Configuration

At a high level the oracle is configured with a oracle.json file that contains all providers that need to be instantiated. To read more about the configuration of oracle.json, please refer to the oracle configuration documentation.

Each provider is instantiated using the PriceAPIQueryHandlerFactory, PriceWebSocketQueryHandlerFactory, and MarketMapFactory factory functions. Think of these as the constructors for the providers.

  • PriceAPIQueryHandlerFactory - This is used to create the API query handler for the provider - which is then passed into a base provider.
  • PriceWebSocketQueryHandlerFactory - This is used to create the WebSocket query handler for the provider - which is then passed into a base provider.
  • MarketMapFactory - This is used to create the market map provider.

Lifecycle

The oracle can be initialized with an option of WithMarketMap which allows each provider to be instantiated with a predetermined set of markets. If this option is not provided, the oracle will fetch the markets from the market map provider. Both options can be set.

The oracle will then start each provider in a separate goroutine. Additionally, if the oracle has a market map provider, it will start a goroutine that will periodically fetch the markets from the market map provider and update the providers accordingly.

All providers are running concurrently and will do so until the main context is canceled (what is passed into Start). If the oracle is canceled, it will cancel all providers and wait for them to finish before returning.

# Packages

No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author

# Functions

New returns a new Oracle.
WithLogger sets the logger for the oracle.
WithMarketMap sets the market map for the oracle.
WithMarketMapperFactory sets the market map factory for the oracle.
WithMetrics sets the metrics service the Oracle will use to emit metrics.
WithPriceAPIQueryHandlerFactory sets the Price API query handler factory for the oracle.
WithPriceProviders allows pre-instantiated price providers to be used in the Oracle's price fetching loop.
WithPriceWebSocketQueryHandlerFactory sets the websocket query handler factory for the oracle.
WithWriteTo sets the file path to which market map updates will be written to.

# Structs

OracleImpl maintains providers and the state provided by them.
ProviderState is the state of a provider.

# Interfaces

Oracle defines the expected interface for an oracle.
PriceAggregator is an interface for aggregating prices from multiple providers.

# Type aliases

Option is a functional option for the market map state.