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 FeedIDFromReport(report ocrtypes.Report) (feedID mercury.FeedID, err 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 MustHexToConfigDigest(s string) (cd ocrtypes.ConfigDigest)
- func NewTransmitter(lggr logger.Logger, cfg TransmitterConfig, clients map[string]wsrpc.Client, ...) *mercuryTransmitter
- 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 BenchmarkPriceDecoder
- type ConfigTracker
- type EpochRound
- type ORM
- type OffchainConfig
- type OffchainConfigDigester
- type PAO
- type PAOAsk
- type PAOBid
- type PAOLinkFee
- type PAOMaxFinalizedTimestamp
- type PAONativeFee
- type PersistenceManager
- func (pm *PersistenceManager) AsyncDelete(req *pb.TransmitRequest)
- func (pm *PersistenceManager) Close() error
- func (pm *PersistenceManager) Delete(ctx context.Context, req *pb.TransmitRequest) error
- func (pm *PersistenceManager) Insert(ctx context.Context, req *pb.TransmitRequest, reportCtx ocrtypes.ReportContext) error
- func (pm *PersistenceManager) Load(ctx context.Context) ([]*Transmission, error)
- func (pm *PersistenceManager) Start(ctx context.Context) error
- type StandardOnchainConfigCodec
- type Transmission
- type TransmitQueue
- type Transmitter
- type TransmitterConfig
- type TransmitterReportDecoder
Constants ¶
const ByteWidthInt192 = 24
Bounds on an int192
const (
// Mercury server error codes
DuplicateReport = 2
)
const EvmHashLen = 32
NOTE: hardcoded for now, this may need to change if we support block range on chains other than eth
const TransmitQueueMaxSize = 10_000 // hardcode this for legacy transmitter since we want the config var to apply only to LLO
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 PayloadTypes = getPayloadTypes()
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 FeedIDFromReport ¶ added in v0.1.14
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 MustHexToConfigDigest ¶ added in v0.1.14
func MustHexToConfigDigest(s string) (cd ocrtypes.ConfigDigest)
func NewTransmitter ¶ added in v0.1.14
func NewTransmitter(lggr logger.Logger, cfg TransmitterConfig, clients map[string]wsrpc.Client, fromAccountHex string, jobID int32, feedID [32]byte, orm ORM, codec TransmitterReportDecoder, benchmarkPriceDecoder BenchmarkPriceDecoder, triggerCapability *triggers.MercuryTriggerService) *mercuryTransmitter
func ValidateBetween ¶
ValidateBetween checks that value is between min and max
func ValidateExpiresAt ¶
Types ¶
type BenchmarkPriceDecoder ¶ added in v0.1.14
type ConfigTracker ¶ added in v0.1.14
type EpochRound ¶
func (EpochRound) Less ¶
func (x EpochRound) Less(y EpochRound) bool
type ORM ¶ added in v0.1.14
type ORM interface {
InsertTransmitRequest(ctx context.Context, serverURLs []string, req *pb.TransmitRequest, jobID int32, reportCtx ocrtypes.ReportContext) error
DeleteTransmitRequests(ctx context.Context, serverURL string, reqs []*pb.TransmitRequest) error
GetTransmitRequests(ctx context.Context, serverURL string, jobID int32) ([]*Transmission, error)
PruneTransmitRequests(ctx context.Context, serverURL string, jobID int32, maxSize int) error
LatestReport(ctx context.Context, feedID [32]byte) (report []byte, err error)
}
func NewORM ¶ added in v0.1.14
func NewORM(ds sqlutil.DataSource) ORM
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 OffchainConfigDigester ¶ added in v0.1.14
type OffchainConfigDigester struct {
FeedID mercury.FeedID
ChainID *big.Int
ContractAddress common.Address
Prefix ocrtypes.ConfigDigestPrefix
}
func NewOffchainConfigDigester ¶ added in v0.1.14
func NewOffchainConfigDigester(feedID [32]byte, chainID *big.Int, contractAddress common.Address, prefix ocrtypes.ConfigDigestPrefix) OffchainConfigDigester
func (OffchainConfigDigester) ConfigDigest ¶ added in v0.1.14
func (d OffchainConfigDigester) ConfigDigest(ctx context.Context, cc ocrtypes.ContractConfig) (ocrtypes.ConfigDigest, error)
func (OffchainConfigDigester) ConfigDigestPrefix ¶ added in v0.1.14
func (d OffchainConfigDigester) ConfigDigestPrefix(ctx context.Context) (ocrtypes.ConfigDigestPrefix, error)
type PAOLinkFee ¶
type PAONativeFee ¶
type PersistenceManager ¶ added in v0.1.14
type PersistenceManager struct {
// contains filtered or unexported fields
}
func NewPersistenceManager ¶ added in v0.1.14
func (*PersistenceManager) AsyncDelete ¶ added in v0.1.14
func (pm *PersistenceManager) AsyncDelete(req *pb.TransmitRequest)
func (*PersistenceManager) Close ¶ added in v0.1.14
func (pm *PersistenceManager) Close() error
func (*PersistenceManager) Delete ¶ added in v0.1.14
func (pm *PersistenceManager) Delete(ctx context.Context, req *pb.TransmitRequest) error
func (*PersistenceManager) Insert ¶ added in v0.1.14
func (pm *PersistenceManager) Insert(ctx context.Context, req *pb.TransmitRequest, reportCtx ocrtypes.ReportContext) error
func (*PersistenceManager) Load ¶ added in v0.1.14
func (pm *PersistenceManager) Load(ctx context.Context) ([]*Transmission, error)
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)
type Transmission ¶ added in v0.1.14
type Transmission struct {
Req *pb.TransmitRequest // the payload to transmit
ReportCtx ocrtypes.ReportContext // contains priority information (latest epoch/round wins)
}
type TransmitQueue ¶ added in v0.1.14
type TransmitQueue interface {
services.Service
BlockingPop() (t *Transmission)
Push(req *pb.TransmitRequest, reportCtx ocrtypes.ReportContext) (ok bool)
Init(transmissions []*Transmission)
IsEmpty() bool
}
func NewTransmitQueue ¶ added in v0.1.14
func NewTransmitQueue(lggr logger.Logger, serverURL, feedID string, maxlen int, asyncDeleter asyncDeleter) TransmitQueue
maxlen controls how many items will be stored in the queue 0 means unlimited - be careful, this can cause memory leaks
type Transmitter ¶ added in v0.1.14
type Transmitter interface {
mercury.Transmitter
services.Service
}