Documentation
¶
Index ¶
- Constants
- Variables
- func CreateURL(baseURL string, poolID uint64, baseAsset, quoteAsset string) (string, error)
- func NoOsmosisMetadataForTickerError(ticker string) error
- type APIPriceFetcher
- type Client
- func NewClient(api config.APIConfig, apiMetrics metrics.APIMetrics, endpoint config.Endpoint) (Client, error)
- func NewMultiClient(logger *zap.Logger, api config.APIConfig, apiMetrics metrics.APIMetrics, ...) (Client, error)
- func NewMultiClientFromEndpoints(logger *zap.Logger, api config.APIConfig, apiMetrics metrics.APIMetrics) (Client, error)
- type ClientImpl
- type MultiClientImpl
- type SpotPriceResponse
- type TickerMetadata
- type WrappedSpotPriceResponse
Constants ¶
const ( Name = "osmosis_api" QueryURLCharacter = "?" URLSeparator = "/" URLSuffix = "osmosis/poolmanager/v2/pools/%s/prices%sbase_asset_denom=%s"e_asset_denom=%s" )
Variables ¶
var DefaultAPIConfig = config.APIConfig{ Enabled: true, Name: Name, Timeout: 5 * time.Second, Interval: 2000 * time.Millisecond, ReconnectTimeout: 5 * time.Second, MaxQueries: 10, Atomic: false, BatchSize: 1, Endpoints: []config.Endpoint{ { URL: "https://osmosis-api.polkachu.com", }, }, MaxBlockHeightAge: 30 * time.Second, }
DefaultAPIConfig is the default configuration for the Osmosis API price fetcher.
Functions ¶
func NoOsmosisMetadataForTickerError ¶
NoOsmosisMetadataForTickerError is returned when there is no metadata associated with a given ticker.
Types ¶
type APIPriceFetcher ¶
type APIPriceFetcher struct {
// contains filtered or unexported fields
}
func NewAPIPriceFetcher ¶
func NewAPIPriceFetcher( logger *zap.Logger, api config.APIConfig, apiMetrics metrics.APIMetrics, ) (*APIPriceFetcher, error)
NewAPIPriceFetcher returns a new APIPriceFetcher. This method constructs the default Osmosis client in accordance with the config's endpoints.
func NewAPIPriceFetcherWithClient ¶
func NewAPIPriceFetcherWithClient( logger *zap.Logger, api config.APIConfig, apiMetrics metrics.APIMetrics, client Client, ) (*APIPriceFetcher, error)
NewAPIPriceFetcherWithClient returns a new APIPriceFetcher. This method constructs the osmosis client with the given client.
func (*APIPriceFetcher) Fetch ¶
func (pf *APIPriceFetcher) Fetch( ctx context.Context, tickers []oracletypes.ProviderTicker, ) oracletypes.PriceResponse
Fetch fetches prices from the osmosis API for the given currency-pairs. Specifically for each currency-pair,
- Query the spot price.
type Client ¶
type Client interface { SpotPrice(ctx context.Context, poolID uint64, baseAsset, quoteAsset string, ) (WrappedSpotPriceResponse, error) }
Client is the expected interface for an osmosis client.
func NewMultiClient ¶
func NewMultiClient( logger *zap.Logger, api config.APIConfig, apiMetrics metrics.APIMetrics, clients []Client, ) (Client, error)
NewMultiClient creates a new Client.
func NewMultiClientFromEndpoints ¶
func NewMultiClientFromEndpoints( logger *zap.Logger, api config.APIConfig, apiMetrics metrics.APIMetrics, ) (Client, error)
NewMultiClientFromEndpoints creates a new Client from a list of endpoints.
type ClientImpl ¶
type ClientImpl struct {
// contains filtered or unexported fields
}
ClientImpl is an implementation of a client to Osmosis using a poolmanager Query Client.
func (*ClientImpl) SpotPrice ¶
func (c *ClientImpl) SpotPrice(ctx context.Context, poolID uint64, baseAsset, quoteAsset string) (WrappedSpotPriceResponse, error)
SpotPrice uses the underlying x/poolmanager client to access spot prices.
type MultiClientImpl ¶
type MultiClientImpl struct {
// contains filtered or unexported fields
}
MultiClientImpl is an Osmosis client that wraps a set of multiple Clients.
func (*MultiClientImpl) SpotPrice ¶
func (mc *MultiClientImpl) SpotPrice(ctx context.Context, poolID uint64, baseAsset, quoteAsset string) (WrappedSpotPriceResponse, error)
SpotPrice delegates the request to all underlying clients and applies a filter to the set of responses.
type SpotPriceResponse ¶
type SpotPriceResponse struct {
SpotPrice string `json:"spot_price"`
}
type TickerMetadata ¶
type TickerMetadata struct { // PoolID is the unique uint ID of the osmosis pool. PoolID uint64 `json:"pool_id"` // BaseTokenDenom is the identifier (on osmosis) of the quote token. BaseTokenDenom string `json:"base_token_denom"` // QuoteTokenDenom is the identifier (on osmosis) of the quote token. QuoteTokenDenom string `json:"quote_token_denom"` }
TickerMetadata represents the metadata associated with a ticker's corresponding raydium pool.
func (TickerMetadata) ValidateBasic ¶
func (metadata TickerMetadata) ValidateBasic() error
ValidateBasic checks that the pool and token information is formatted properly.
type WrappedSpotPriceResponse ¶
type WrappedSpotPriceResponse struct { SpotPriceResponse BlockHeight uint64 `json:"block_height"` }