Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func PriceCmpUnsafe ¶
PriceCmpUnsafe implements a standard comparator function for the Price type.
NOTE: unsafe from under/overflows. Ensure the inputs are valid Price [MinPrice, MaxPrice].
Types ¶
type FeedOption ¶
type FeedOption int
FeedOption is an enum for the different types of price feeds that can be queried.
const ( Feed_ZERO FeedOption = iota // 0 => no price feed to query Feed_SINGULAR // 1 => only 1 price feed to query for the final price Feed_TRIANGULAR // 2 => use triangular arbitrage to get price from target )
type Price ¶
type Price int64
Prices are represented by int64s.
func CalculateTriangularConf ¶
Returns the confidence of baseP/quoteP in the desired precision. Assumes baseP/quoteP are in the same precision. Logic taken from Pyth Rust SDK. (https://github.com/pyth-network/pyth-sdk-rs/blob/main/pyth-sdk/src/price.rs#L424)
func CalculateTriangularPrice ¶
Returns baseP/quoteP in the desired precision. Assumes baseP/quoteP are in the same precision.
func NormalizeToPrecision ¶
NormalizeToPrecision normalizes a int64 of decimals to a int64 with the desired precision.
type PriceUpdate ¶
type PriceUpdate struct { PairIndex uint64 Price Price Conf Price TimeStamp uint64 PythUpdateData [][]byte PythUpdateFee *big.Int }
PriceUpdate represents a price update received by the oracle.
func GetPriceUpdateFromPythResult ¶
func GetPriceUpdateFromPythResult( lpd *types.LatestPriceData, pairIndex uint64, useEma bool, desiredPrecision int, ) *PriceUpdate
Builds a PriceUpdate for a Pyth oracle result.
NOTE: does not set the PythUpdateFee or the FeedType.
func GetPriceUpdateFromPythStructsPriceFeed ¶
func GetPriceUpdateFromPythStructsPriceFeed( pf *apyth.PythStructsPriceFeed, pairIndex uint64, useEma bool, desiredPrecision int, ) *PriceUpdate
Builds a PriceUpdate for a Pyth price feed struct.
NOTE: does not set the PythUpdateFee or the FeedType.
type PriceUpdates ¶
type PriceUpdates map[uint64]*PriceUpdate
PriceUpdates is a map of price updates, keyed by pair index.