Documentation ¶
Index ¶
- Constants
- Variables
- func CalculateFee(tokenPriceInUSD *big.Int, baseUSDFee decimal.Decimal) *big.Int
- func DecodeValueInt192(s []byte) (*big.Int, error)
- func EncodeValueInt192(i *big.Int) ([]byte, error)
- func GetConsensusAsk(paos []PAOAsk, f int) (*big.Int, error)
- func GetConsensusBenchmarkPrice(paos []PAO, f int) (*big.Int, error)
- func GetConsensusBid(paos []PAOBid, f int) (*big.Int, error)
- func GetConsensusLinkFee(paos []PAOLinkFee, f int) (*big.Int, error)
- func GetConsensusMaxFinalizedTimestamp(paos []PAOMaxFinalizedTimestamp, f int) (int64, error)
- func GetConsensusNativeFee(paos []PAONativeFee, f int) (*big.Int, error)
- func GetConsensusTimestamp(paos []PAO) uint32
- func MustEncodeValueInt192(i *big.Int) []byte
- func ValidateBetween(name string, answer *big.Int, min, max *big.Int) error
- func ValidateExpiresAt(observationTimestamp uint32, expiresAt uint32) error
- func ValidateFee(name string, answer *big.Int) error
- func ValidateValidFromTimestamp(observationTimestamp uint32, validFromTimestamp uint32) error
- type EpochRound
- type OffchainConfig
- type PAO
- type PAOAsk
- type PAOBid
- type PAOLinkFee
- type PAOMaxFinalizedTimestamp
- type PAONativeFee
- type StandardOnchainConfigCodec
Constants ¶
const ByteWidthInt192 = 24
Bounds on an int192
const EvmHashLen = 32
NOTE: hardcoded for now, this may need to change if we support block range on chains other than eth
Variables ¶
var FeeScalingFactor = decimal.NewFromInt(1e18)
FeeScalingFactor indicates the multiplier applied to fees. e.g. for a 1e18 multiplier, a LINK fee of 7.42 will be represented as 7.42e18 This is what will be baked into the report for use on-chain.
var MaxInt192 *big.Int
var MaxInt192Enc []byte
var PriceScalingFactor = decimal.NewFromInt(1e18) //nolint:revive
PriceScalingFactor indicates the multiplier applied to token prices that we expect from data source e.g. for a 1e8 multiplier, a LINK/USD value of 7.42 will be derived from a data source value of 742000000
var Zero = big.NewInt(0)
Functions ¶
func CalculateFee ¶
CalculateFee outputs a fee in wei according to the formula: baseUSDFee * scaleFactor / tokenPriceInUSD
func DecodeValueInt192 ¶
Decodes a value using 24-byte big endian two's complement representation. This function never panics.
func EncodeValueInt192 ¶
Encodes a value using 24-byte big endian two's complement representation. This function never panics.
func GetConsensusAsk ¶
GetConsensusAsk gets the median ask
func GetConsensusBenchmarkPrice ¶
GetConsensusBenchmarkPrice gets the median benchmark price
func GetConsensusBid ¶
GetConsensusBid gets the median bid
func GetConsensusLinkFee ¶
func GetConsensusLinkFee(paos []PAOLinkFee, f int) (*big.Int, error)
GetConsensusLinkFee gets the median link fee
func GetConsensusMaxFinalizedTimestamp ¶
func GetConsensusMaxFinalizedTimestamp(paos []PAOMaxFinalizedTimestamp, f int) (int64, error)
GetConsensusMaxFinalizedTimestamp returns the highest count with > f observations
func GetConsensusNativeFee ¶
func GetConsensusNativeFee(paos []PAONativeFee, f int) (*big.Int, error)
GetConsensusNativeFee gets the median native fee
func GetConsensusTimestamp ¶
GetConsensusTimestamp gets the median timestamp
func MustEncodeValueInt192 ¶
func ValidateBetween ¶
ValidateBetween checks that value is between min and max
func ValidateExpiresAt ¶
Types ¶
type EpochRound ¶
func (EpochRound) Less ¶
func (x EpochRound) Less(y EpochRound) bool
type OffchainConfig ¶
type OffchainConfig struct { ExpirationWindow uint32 `json:"expirationWindow"` // Integer number of seconds BaseUSDFee decimal.Decimal `json:"baseUSDFee"` // Base USD fee }
func DecodeOffchainConfig ¶
func DecodeOffchainConfig(b []byte) (o OffchainConfig, err error)
func (OffchainConfig) Encode ¶
func (c OffchainConfig) Encode() ([]byte, error)
type PAOLinkFee ¶
type PAONativeFee ¶
type StandardOnchainConfigCodec ¶
type StandardOnchainConfigCodec struct{}
StandardOnchainConfigCodec provides a mercury-specific implementation of OnchainConfigCodec.
An encoded onchain config is expected to be in the format <version><min><max> where version is a uint8 and min and max are in the format returned by EncodeValueInt192.
func (StandardOnchainConfigCodec) Decode ¶
func (StandardOnchainConfigCodec) Decode(ctx context.Context, b []byte) (mercury.OnchainConfig, error)
func (StandardOnchainConfigCodec) Encode ¶
func (StandardOnchainConfigCodec) Encode(ctx context.Context, c mercury.OnchainConfig) ([]byte, error)