hermes

package
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Oct 25, 2024 License: MIT Imports: 18 Imported by: 0

README

Hermes Client

More information about the Hermes API can be found here.

Current Supported Endpoints

  • /v2/updates/price/latest (documentation)
    • For batch requests, both single-batch (sync) and multiple concurrent-single (async) requests are supported.
  • /v2/updates/price/stream (documentation)
    • SSE streaming is supported.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

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

Client is a client for the Pyth Hermes API (https://hermes.pyth.network/docs)

func NewClient

func NewClient(cfg *Config, logger retryablehttp.LeveledLogger) (*Client, error)

NewClient creates a client for the Pyth Hermes API.

func (*Client) GetCachedLatestPriceUpdates

func (c *Client) GetCachedLatestPriceUpdates(
	ctx context.Context, priceFeeds ...string,
) (map[string]*types.LatestPriceData, error)

Queries cached price feed update data, obtained from sse streaming endpoints. Returns the Pyth PriceFeed struct and the price feed update data for each pair.

func (*Client) GetLatestPriceUpdatesAsync

func (c *Client) GetLatestPriceUpdatesAsync(
	ctx context.Context, priceFeeds ...string,
) (map[string]*types.LatestPriceData, error)

Queries the `v2/updates/price/latest` endpoint for each price feed individually, in parallel. Takes the price feed keys (uses corresponding Pyth feed ID). Returns the Pyth PriceFeed struct and the price feed update data for each pair.

func (*Client) GetLatestPriceUpdatesSync

func (c *Client) GetLatestPriceUpdatesSync(
	_ context.Context, priceFeeds ...string,
) (map[string]*types.LatestPriceData, error)

Queries the `v2/updates/price/latest` endpoint for all price feed ID together. Takes the price feed keys (uses corresponding Pyth feed ID). Returns the Pyth PriceFeed struct and the price feed update data for each pair.

func (*Client) Shutdown

func (c *Client) Shutdown()

Shutdown gracefully shuts down the Pyth Hermes client.

func (*Client) SubscribePriceStreaming

func (c *Client) SubscribePriceStreaming(ctx context.Context, priceFeeds ...string)

Subscribe price feed from the streaming `v2/updates/price/stream` endpoint. Ensures this only happens once in the scope of runtime. Any further calls to this are unnecessary and no-ops.

type Config

type Config struct {
	// Offchain parameters
	APIEndpoint string
	HTTPTimeout time.Duration
	MaxRetries  int
	Ecosystem   string

	// Onchain parameters
	UseMock bool // Uses the mock Pyth contract rather than the real one.
	// contains filtered or unexported fields
}

func (*Config) Validate

func (c *Config) Validate() error

Jump to

Keyboard shortcuts

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