Documentation
¶
Index ¶
- Constants
- Variables
- type Client
- func (c *Client) GetMarketPairHC() daemontypes.HealthCheckable
- func (c *Client) GetPriceHC() daemontypes.HealthCheckable
- func (c *Client) GetSidecarVersionHC() daemontypes.HealthCheckable
- func (c *Client) RunMarketPairFetcher(ctx context.Context, appFlags appflags.Flags, ...)
- func (c *Client) RunPriceFetcher(ctx context.Context)
- func (c *Client) RunSidecarVersionChecker(ctx context.Context)
- func (c *Client) Stop()
- type MarketPairFetcher
- type MarketPairFetcherImpl
- type PriceFetcher
- type PriceFetcherImpl
- type SidecarVersionChecker
- type SidecarVersionCheckerImpl
Constants ¶
const ( // SlinkyClientDaemonModuleName is the module name used in logging. SlinkyClientDaemonModuleName = "slinky-client-daemon" SlinkyClientPriceFetcherDaemonModuleName = "slinky-client-price-fetcher-daemon" SlinkyClientMarketPairFetcherDaemonModuleName = "slinky-client-market-pair-fetcher-daemon" SlinkyClientSidecarVersionFetcherDaemonModuleName = "slinky-client-sidecar-version-fetcher-daemon" MinSidecarVersion = "v1.0.12" )
Variables ¶
var ( // SlinkyPriceServerConnectionTimeout controls the timeout of establishing a // grpc connection to the pricefeed server. SlinkyPriceServerConnectionTimeout = time.Second * 5 // SlinkyPriceFetchDelay controls the frequency at which we pull prices from slinky and push // them to the pricefeed server. SlinkyPriceFetchDelay = time.Second * 2 // SlinkyMarketParamFetchDelay is the frequency at which we query the x/price module to refresh mappings from // currency pair to x/price ID. SlinkyMarketParamFetchDelay = time.Millisecond * 1900 SlinkySidecarCheckDelay = time.Second * 60 )
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client is the daemon implementation for pulling price data from the slinky sidecar.
func StartNewClient ¶
func StartNewClient( ctx context.Context, slinky oracleclient.OracleClient, indexPriceCache *pricefeedtypes.MarketToExchangePrices, grpcClient daemontypes.GrpcClient, daemonFlags flags.DaemonFlags, appFlags appflags.Flags, logger log.Logger, ) *Client
StartNewClient creates and runs a Client. The client creates the MarketPairFetcher, PriceFetcher, and SidecarVersionChecker, connects to the required grpc services, and launches them in goroutines. It is non-blocking and returns on successful startup. If it hits a critical error in startup it panics.
func (*Client) GetMarketPairHC ¶
func (c *Client) GetMarketPairHC() daemontypes.HealthCheckable
func (*Client) GetPriceHC ¶
func (c *Client) GetPriceHC() daemontypes.HealthCheckable
func (*Client) GetSidecarVersionHC ¶
func (c *Client) GetSidecarVersionHC() daemontypes.HealthCheckable
func (*Client) RunMarketPairFetcher ¶
func (c *Client) RunMarketPairFetcher(ctx context.Context, appFlags appflags.Flags, grpcClient daemontypes.GrpcClient)
RunMarketPairFetcher periodically calls the marketPairFetcher to cache mappings between currency pair and market param ID.
func (*Client) RunPriceFetcher ¶
RunPriceFetcher periodically calls the priceFetcher to grab prices from the slinky sidecar and push them to the pricefeed server.
func (*Client) RunSidecarVersionChecker ¶
RunSidecarVersionChecker periodically calls the sidecarVersionChecker to check if the running sidecar version is at least a minimum acceptable version.
type MarketPairFetcher ¶
type MarketPairFetcher interface {
Start(context.Context, appflags.Flags, daemontypes.GrpcClient) error
Stop()
GetIDForPair(slinkytypes.CurrencyPair) (uint32, error)
FetchIdMappings(context.Context) error
}
MarketPairFetcher is a lightweight process run in a goroutine by the slinky client. Its purpose is to periodically query the prices module for MarketParams and create an easily indexed mapping between Slinky's CurrencyPair type and the corresponding ID in the x/prices module.
func NewMarketPairFetcher ¶
func NewMarketPairFetcher(logger log.Logger) MarketPairFetcher
type MarketPairFetcherImpl ¶
type MarketPairFetcherImpl struct {
Logger log.Logger
QueryConn *grpc.ClientConn
PricesQueryClient pricetypes.QueryClient
// contains filtered or unexported fields
}
MarketPairFetcherImpl implements the MarketPairFetcher interface.
func (*MarketPairFetcherImpl) FetchIdMappings ¶
func (m *MarketPairFetcherImpl) FetchIdMappings(ctx context.Context) error
FetchIdMappings is run periodically to refresh the cache of known mappings between CurrencyPair and MarketParam ID.
func (*MarketPairFetcherImpl) GetIDForPair ¶
func (m *MarketPairFetcherImpl) GetIDForPair(cp slinkytypes.CurrencyPair) (uint32, error)
GetIDForPair returns the ID corresponding to the currency pair in the x/prices module. If the currency pair is not found it will return an error.
func (*MarketPairFetcherImpl) Start ¶
func (m *MarketPairFetcherImpl) Start( ctx context.Context, appFlags appflags.Flags, grpcClient daemontypes.GrpcClient) error
Start opens the grpc connections for the fetcher.
func (*MarketPairFetcherImpl) Stop ¶
func (m *MarketPairFetcherImpl) Stop()
Stop closes all existing connections.
type PriceFetcher ¶
type PriceFetcher interface {
Start(ctx context.Context) error
Stop()
FetchPrices(ctx context.Context) error
}
PriceFetcher is responsible for pulling prices from the slinky sidecar and sending them to the pricefeed server.
func NewPriceFetcher ¶
func NewPriceFetcher( marketPairFetcher MarketPairFetcher, indexPriceCache *pricefeedtypes.MarketToExchangePrices, slinky oracleclient.OracleClient, logger log.Logger) PriceFetcher
NewPriceFetcher creates a PriceFetcher.
type PriceFetcherImpl ¶
type PriceFetcherImpl struct {
// contains filtered or unexported fields
}
PriceFetcherImpl implements the PriceFetcher interface.
func (*PriceFetcherImpl) FetchPrices ¶
func (p *PriceFetcherImpl) FetchPrices(ctx context.Context) error
FetchPrices pulls prices from Slinky, translates the returned data format to dydx-compatible types, and sends the price updates to the index price cache via the pricefeed server. It uses the MarketPairFetcher to efficiently map between Slinky's CurrencyPair primary key and dydx's MarketParam (or MarketPrice) ID.
The markets in the index price cache will only have a single index price (from slinky). This is because the sidecar pre-aggregates market data.
type SidecarVersionChecker ¶
type SidecarVersionChecker interface {
Start(ctx context.Context) error
Stop()
CheckSidecarVersion(context.Context) error
}
SidecarVersionChecker is a lightweight process run in a goroutine by the slinky client. Its purpose is to query the running sidecar version and check if it is at least a minimum acceptable version.
func NewSidecarVersionChecker ¶
func NewSidecarVersionChecker(slinky oracleclient.OracleClient, logger log.Logger) SidecarVersionChecker
type SidecarVersionCheckerImpl ¶
type SidecarVersionCheckerImpl struct {
// contains filtered or unexported fields
}
SidecarVersionCheckerImpl implements the SidecarVersionChecker interface.
func (*SidecarVersionCheckerImpl) CheckSidecarVersion ¶
func (s *SidecarVersionCheckerImpl) CheckSidecarVersion(ctx context.Context) error
func (*SidecarVersionCheckerImpl) Start ¶
func (s *SidecarVersionCheckerImpl) Start( ctx context.Context) error
Start initializes the underlying connections of the SidecarVersionChecker.
func (*SidecarVersionCheckerImpl) Stop ¶
func (s *SidecarVersionCheckerImpl) Stop()
Stop closes all existing connections.