Documentation
¶
Overview ¶
Package pricefeed polls the Jupiter Price API v3 for a configurable list of token mints and publishes price updates on a channel.
https://developers.jup.ag/docs/price
An API key is optional -- when set it's sent as the x-api-key header for the paid tier's higher rate limit; when empty, requests go out unauthenticated against the free public tier (1 request/sec, up to 50 mints per request; mint lists longer than 50 are split into batches).
Index ¶
Constants ¶
const DefaultBaseURL = "https://api.jup.ag/price/v3"
Jupiter Price API v3 endpoint
Jupiter's free-tier rate. Jupiter's own docs claim 1 req/sec, but that reliably drew 429s in practice against the real public gateway; 3s between requests was confirmed empirically (5/5 requests succeeded).
const MaxMintsPerRequest = 50
The maximum number of token mints Jupiter accepts in a single request's "ids" parameter.
const PaidTierInterval = 100 * time.Millisecond
Jupiter's $25/mo paid tier rate (10 req/sec)
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct {
APIKey string // optional; sent as the x-api-key header when non-empty
Mints []sgo.PublicKey // configurable list of token mints to price
Interval time.Duration // how often one batch is polled (default: FreeTierInterval)
}
Poller config
type Poller ¶
type Poller struct {
// contains filtered or unexported fields
}
Polls the Jupiter Price API v3 for Config.Mints on a fixed interval and publishes results on the channel returned by Run.
func (*Poller) Run ¶
func (p *Poller) Run(ctx context.Context) <-chan PriceUpdate
Run starts polling in a goroutine and returns the channel (channel is closed once ctx is cancelled and the poll loop exits)
type PriceUpdate ¶
type PriceUpdate struct {
Mint sgo.PublicKey
USDPrice float64
Decimals uint8
BlockID uint64 // block/slot Jupiter computed this price against
PriceChange24h float64 // 24h percentage change
FetchedAt time.Time // when the poller received the response (local clock)
}
Mint's price at single poll
Source Files
¶
- client.go
- poller.go
- pricefeed.go