client

package module
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: 6 Imported by: 0

README

go-pyth-client

Tag License GoDoc Lint Go Report Card

Go client library for interacting with Pyth Hermes and Benchmarks APIs in EVM based contracts. For more information on Pyth Hermes, please visit Pyth's documentation on price feeds. For more information on Pyth Benchmarks, please visit Pyth's documentation on benchmarks.

This project is still under development. For support on more endpoints and use cases, please open an issue or contribute!

Install

go-pyth-client is a standard Go module which can be installed with:

go get github.com/calbera/go-pyth-client

Usage

Please read the Go documentation for this library for interface information.

Maintainers

Cal Bera: @calbera.

Contribute

Contributions welcome. Please check out the issues.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var NewBenchmarks = benchmarks.NewClient

NewBenchmarks creates a new Pyth Benchmarks client.

View Source
var NewHermes = hermes.NewClient

NewHermes creates a new Pyth Hermes client.

Functions

This section is empty.

Types

type Benchmarks

type Benchmarks interface {
	// Queries the `v1/updates/price/{timestamp}` endpoint for all price feed IDs 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.
	GetHistoricalPriceUpdatesSync(
		ctx context.Context, timestamp time.Time, priceFeeds ...string,
	) (map[string]*apyth.PythStructsPriceFeed, error)

	// Shutdown gracefully shuts down the Pyth Benchmarks client.
	Shutdown()
}

Benchmarks is the interface of the Benchmarks client.

type Hermes

type Hermes interface {
	// 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.
	GetLatestPriceUpdatesAsync(
		ctx 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.
	GetLatestPriceUpdatesSync(
		ctx context.Context, priceFeeds ...string,
	) (map[string]*types.LatestPriceData, error)

	// 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.
	SubscribePriceStreaming(ctx context.Context, priceFeeds ...string)

	// Queries cached price feed update data, obtained from the SSE streaming endpoint.
	// Returns the Pyth PriceFeed struct and the price feed update data for each pair.
	GetCachedLatestPriceUpdates(
		ctx context.Context, priceFeeds ...string,
	) (map[string]*types.LatestPriceData, error)

	// Gracefully shuts down the Pyth Hermes client.
	Shutdown()
}

Hermes is the interface of the Hermes client.

Directories

Path Synopsis
examples
lib

Jump to

Keyboard shortcuts

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