Documentation
¶
Index ¶
- Constants
- Variables
- func CalculateFee(tokenPriceInUSD decimal.Decimal, baseUSDFee decimal.Decimal) *big.Int
- func ConvertTimestamp(timestampNanos uint64, precision llo.TimeResolution) uint64
- func EncodePackedBigInt(value *big.Int, typeStr string) ([]byte, error)
- func EncodePaddedBigInt(v *big.Int, t string) (b []byte, err error)
- func ExtractReportValues(report llo.Report) (nativePrice, linkPrice decimal.Decimal, quote *llo.Quote, err error)
- func ExtractTimestamps(report llo.Report) (validAfterSeconds, observationTimestampSeconds uint32, err error)
- func LLOExtraHash(donID uint32) common.Hash
- func LegacyReportContext(cd ocr2types.ConfigDigest, seqNr uint64, donID uint32) (ocr2types.ReportContext, error)
- func SeqNrToEpochAndRound(seqNr uint64) (epoch uint32, round uint8, err error)
- type ABIEncoder
- type BaseReportFields
- type LLOEVMStreamlinedReportWithContext
- func (*LLOEVMStreamlinedReportWithContext) Descriptor() ([]byte, []int)deprecated
- func (x *LLOEVMStreamlinedReportWithContext) GetConfigDigest() []byte
- func (x *LLOEVMStreamlinedReportWithContext) GetPackedPayload() []byte
- func (x *LLOEVMStreamlinedReportWithContext) GetSeqNr() uint64
- func (*LLOEVMStreamlinedReportWithContext) ProtoMessage()
- func (x *LLOEVMStreamlinedReportWithContext) ProtoReflect() protoreflect.Message
- func (x *LLOEVMStreamlinedReportWithContext) Reset()
- func (x *LLOEVMStreamlinedReportWithContext) String() string
- type ReportCodecEVMABIEncodeUnpacked
- func (r ReportCodecEVMABIEncodeUnpacked) Encode(report llo.Report, cd llotypes.ChannelDefinition, parsedOpts any) ([]byte, error)
- func (r ReportCodecEVMABIEncodeUnpacked) ParseOpts(opts []byte) (any, error)
- func (r ReportCodecEVMABIEncodeUnpacked) TimeResolution(parsedOpts any) (llo.TimeResolution, error)
- func (r ReportCodecEVMABIEncodeUnpacked) Verify(cd llotypes.ChannelDefinition) error
- type ReportCodecEVMABIEncodeUnpackedExpr
- func (r ReportCodecEVMABIEncodeUnpackedExpr) CalculatedStreamABI(parsedOpts any) ([]llo.CalculatedStreamABI, error)
- func (r ReportCodecEVMABIEncodeUnpackedExpr) Encode(report llo.Report, cd llotypes.ChannelDefinition, parsedOpts any) ([]byte, error)
- func (r ReportCodecEVMABIEncodeUnpackedExpr) ParseOpts(opts []byte) (any, error)
- func (r ReportCodecEVMABIEncodeUnpackedExpr) TimeResolution(parsedOpts any) (llo.TimeResolution, error)
- func (r ReportCodecEVMABIEncodeUnpackedExpr) Verify(cd llotypes.ChannelDefinition) error
- type ReportCodecEVMStreamlined
- func (rc ReportCodecEVMStreamlined) Encode(r llo.Report, cd llotypes.ChannelDefinition, _ any) (payload []byte, err error)
- func (rc ReportCodecEVMStreamlined) Pack(digest types.ConfigDigest, seqNr uint64, report ocr2types.Report, ...) ([]byte, error)
- func (rc ReportCodecEVMStreamlined) Verify(cd llotypes.ChannelDefinition) error
- type ReportCodecPremiumLegacy
- func (r ReportCodecPremiumLegacy) Decode(b []byte) (*v3.Report, error)
- func (r ReportCodecPremiumLegacy) Encode(report llo.Report, cd llotypes.ChannelDefinition, parsedOpts any) ([]byte, error)
- func (r ReportCodecPremiumLegacy) Pack(digest types.ConfigDigest, seqNr uint64, report ocr2types.Report, ...) ([]byte, error)
- func (r ReportCodecPremiumLegacy) ParseOpts(opts []byte) (any, error)
- func (r ReportCodecPremiumLegacy) TimeResolution(parsedOpts any) (llo.TimeResolution, error)
- func (r ReportCodecPremiumLegacy) Verify(cd llotypes.ChannelDefinition) error
- type ReportFormatEVMABIEncodeOpts
- type ReportFormatEVMPremiumLegacyOpts
- type ReportFormatEVMStreamlinedOpts
Constants ¶
const PluginVersion uint32 = 1 // the legacy mercury plugin is 0
const Precision int32 = 18
NOTE: Inexact divisions will have this degree of precision
const ZeroBytesSentinel = "bytes0"
Variables ¶
var ( BaseSchemaUint32 = getBaseSchema("uint32") BaseSchemaUint64 = getBaseSchema("uint64") )
BaseSchema represents the fixed base schema that remains unchanged for all EVMABIEncodeUnpacked reports.
An arbitrary payload will be appended to this.
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 File_evm_streamlined_proto protoreflect.FileDescriptor
var (
PayloadTypes = getPayloadTypes()
)
Functions ¶
func CalculateFee ¶
CalculateFee outputs a fee in wei according to the formula: baseUSDFee / tokenPriceInUSD
func ConvertTimestamp ¶ added in v0.1.7
func ConvertTimestamp(timestampNanos uint64, precision llo.TimeResolution) uint64
ConvertTimestamp converts a nanosecond timestamp to a specified precision.
func EncodePackedBigInt ¶
EncodePackedBigInt converts a *big.Int to packed EVM bytes according to the Solidity type. For unsigned types ("uintN"), the value must be non-negative and fit in N bits. For signed types ("intN"), the value must be between -2^(N-1) and 2^(N-1)-1; then the function returns the two's complement representation in N bits.
func ExtractReportValues ¶
func ExtractReportValues(report llo.Report) (nativePrice, linkPrice decimal.Decimal, quote *llo.Quote, err error)
ExtractReportValues extracts the native price, link price and quote from the report Can handle either *Decimal or *Quote types for native/link prices
func ExtractTimestamps ¶
func ExtractTimestamps(report llo.Report) (validAfterSeconds, observationTimestampSeconds uint32, err error)
Extracts nanosecond timestamps as uint32 number of seconds
func LLOExtraHash ¶
Uniquely identifies this as LLO plugin, rather than the legacy plugin (which uses all zeroes).
This is quite a hack but serves the purpose of uniquely identifying dons/plugin versions to the mercury server without having to modify any existing tooling or breaking backwards compatibility. It should be safe since the DonID is encoded into the config digest anyway so report context is already dependent on it, and all LLO jobs in the same don are expected to have the same don ID set.
Packs donID+pluginVersion as (uint32, uint32), for example donID=2, PluginVersion=1 Yields: 0x0000000000000000000000000000000000000000000000000000000200000001
func LegacyReportContext ¶
func LegacyReportContext(cd ocr2types.ConfigDigest, seqNr uint64, donID uint32) (ocr2types.ReportContext, error)
Types ¶
type ABIEncoder ¶
type ABIEncoder struct {
// contains filtered or unexported fields
}
An ABIEncoder encodes exactly one stream value into a byte slice
func (ABIEncoder) EncodePacked ¶
func (a ABIEncoder) EncodePacked(sv llo.StreamValue) ([]byte, error)
func (ABIEncoder) EncodePadded ¶
func (a ABIEncoder) EncodePadded(sv llo.StreamValue) ([]byte, error)
func (ABIEncoder) MarshalJSON ¶
func (a ABIEncoder) MarshalJSON() ([]byte, error)
func (*ABIEncoder) UnmarshalJSON ¶
func (a *ABIEncoder) UnmarshalJSON(data []byte) error
type BaseReportFields ¶
type LLOEVMStreamlinedReportWithContext ¶
type LLOEVMStreamlinedReportWithContext struct {
ConfigDigest []byte `protobuf:"bytes,1,opt,name=config_digest,json=configDigest,proto3" json:"config_digest,omitempty"`
SeqNr uint64 `protobuf:"varint,2,opt,name=seq_nr,json=seqNr,proto3" json:"seq_nr,omitempty"`
PackedPayload []byte `protobuf:"bytes,3,opt,name=packed_payload,json=packedPayload,proto3" json:"packed_payload,omitempty"`
// contains filtered or unexported fields
}
func (*LLOEVMStreamlinedReportWithContext) Descriptor
deprecated
func (*LLOEVMStreamlinedReportWithContext) Descriptor() ([]byte, []int)
Deprecated: Use LLOEVMStreamlinedReportWithContext.ProtoReflect.Descriptor instead.
func (*LLOEVMStreamlinedReportWithContext) GetConfigDigest ¶
func (x *LLOEVMStreamlinedReportWithContext) GetConfigDigest() []byte
func (*LLOEVMStreamlinedReportWithContext) GetPackedPayload ¶
func (x *LLOEVMStreamlinedReportWithContext) GetPackedPayload() []byte
func (*LLOEVMStreamlinedReportWithContext) GetSeqNr ¶
func (x *LLOEVMStreamlinedReportWithContext) GetSeqNr() uint64
func (*LLOEVMStreamlinedReportWithContext) ProtoMessage ¶
func (*LLOEVMStreamlinedReportWithContext) ProtoMessage()
func (*LLOEVMStreamlinedReportWithContext) ProtoReflect ¶
func (x *LLOEVMStreamlinedReportWithContext) ProtoReflect() protoreflect.Message
func (*LLOEVMStreamlinedReportWithContext) Reset ¶
func (x *LLOEVMStreamlinedReportWithContext) Reset()
func (*LLOEVMStreamlinedReportWithContext) String ¶
func (x *LLOEVMStreamlinedReportWithContext) String() string
type ReportCodecEVMABIEncodeUnpacked ¶
type ReportCodecEVMABIEncodeUnpacked struct {
logger.Logger
// contains filtered or unexported fields
}
func NewReportCodecEVMABIEncodeUnpacked ¶
func NewReportCodecEVMABIEncodeUnpacked(lggr logger.Logger, donID uint32) ReportCodecEVMABIEncodeUnpacked
func (ReportCodecEVMABIEncodeUnpacked) Encode ¶
func (r ReportCodecEVMABIEncodeUnpacked) Encode(report llo.Report, cd llotypes.ChannelDefinition, parsedOpts any) ([]byte, error)
func (ReportCodecEVMABIEncodeUnpacked) ParseOpts ¶ added in v0.1.7
func (r ReportCodecEVMABIEncodeUnpacked) ParseOpts(opts []byte) (any, error)
func (ReportCodecEVMABIEncodeUnpacked) TimeResolution ¶ added in v0.1.7
func (r ReportCodecEVMABIEncodeUnpacked) TimeResolution(parsedOpts any) (llo.TimeResolution, error)
func (ReportCodecEVMABIEncodeUnpacked) Verify ¶
func (r ReportCodecEVMABIEncodeUnpacked) Verify(cd llotypes.ChannelDefinition) error
type ReportCodecEVMABIEncodeUnpackedExpr ¶
type ReportCodecEVMABIEncodeUnpackedExpr struct {
logger.Logger
// contains filtered or unexported fields
}
func NewReportCodecEVMABIEncodeUnpackedExpr ¶
func NewReportCodecEVMABIEncodeUnpackedExpr(lggr logger.Logger, donID uint32) ReportCodecEVMABIEncodeUnpackedExpr
func (ReportCodecEVMABIEncodeUnpackedExpr) CalculatedStreamABI ¶ added in v0.1.7
func (r ReportCodecEVMABIEncodeUnpackedExpr) CalculatedStreamABI(parsedOpts any) ([]llo.CalculatedStreamABI, error)
func (ReportCodecEVMABIEncodeUnpackedExpr) Encode ¶
func (r ReportCodecEVMABIEncodeUnpackedExpr) Encode(report llo.Report, cd llotypes.ChannelDefinition, parsedOpts any) ([]byte, error)
func (ReportCodecEVMABIEncodeUnpackedExpr) ParseOpts ¶ added in v0.1.7
func (r ReportCodecEVMABIEncodeUnpackedExpr) ParseOpts(opts []byte) (any, error)
func (ReportCodecEVMABIEncodeUnpackedExpr) TimeResolution ¶ added in v0.1.7
func (r ReportCodecEVMABIEncodeUnpackedExpr) TimeResolution(parsedOpts any) (llo.TimeResolution, error)
func (ReportCodecEVMABIEncodeUnpackedExpr) Verify ¶
func (r ReportCodecEVMABIEncodeUnpackedExpr) Verify(cd llotypes.ChannelDefinition) error
type ReportCodecEVMStreamlined ¶
type ReportCodecEVMStreamlined struct{}
func NewReportCodecStreamlined ¶
func NewReportCodecStreamlined() ReportCodecEVMStreamlined
func (ReportCodecEVMStreamlined) Encode ¶
func (rc ReportCodecEVMStreamlined) Encode(r llo.Report, cd llotypes.ChannelDefinition, _ any) (payload []byte, err error)
func (ReportCodecEVMStreamlined) Pack ¶
func (rc ReportCodecEVMStreamlined) Pack(digest types.ConfigDigest, seqNr uint64, report ocr2types.Report, sigs []ocr2types.AttributedOnchainSignature) ([]byte, error)
func (ReportCodecEVMStreamlined) Verify ¶
func (rc ReportCodecEVMStreamlined) Verify(cd llotypes.ChannelDefinition) error
type ReportCodecPremiumLegacy ¶
func NewReportCodecPremiumLegacy ¶
func NewReportCodecPremiumLegacy(lggr logger.Logger, donID uint32) ReportCodecPremiumLegacy
func (ReportCodecPremiumLegacy) Decode ¶
func (r ReportCodecPremiumLegacy) Decode(b []byte) (*v3.Report, error)
func (ReportCodecPremiumLegacy) Encode ¶
func (r ReportCodecPremiumLegacy) Encode(report llo.Report, cd llotypes.ChannelDefinition, parsedOpts any) ([]byte, error)
func (ReportCodecPremiumLegacy) Pack ¶
func (r ReportCodecPremiumLegacy) Pack(digest types.ConfigDigest, seqNr uint64, report ocr2types.Report, sigs []types.AttributedOnchainSignature) ([]byte, error)
Pack assembles the report values into a payload for verifying on-chain
func (ReportCodecPremiumLegacy) ParseOpts ¶ added in v0.1.7
func (r ReportCodecPremiumLegacy) ParseOpts(opts []byte) (any, error)
func (ReportCodecPremiumLegacy) TimeResolution ¶ added in v0.1.7
func (r ReportCodecPremiumLegacy) TimeResolution(parsedOpts any) (llo.TimeResolution, error)
func (ReportCodecPremiumLegacy) Verify ¶
func (r ReportCodecPremiumLegacy) Verify(cd llotypes.ChannelDefinition) error
type ReportFormatEVMABIEncodeOpts ¶
type ReportFormatEVMABIEncodeOpts struct {
// BaseUSDFee is the cost on-chain of verifying a report
BaseUSDFee decimal.Decimal `json:"baseUSDFee"`
// Expiration window is the length of time in seconds the report is valid
// for, from the observation timestamp
ExpirationWindow uint32 `json:"expirationWindow"`
// FeedID is for compatibility with existing on-chain verifiers
FeedID common.Hash `json:"feedID"`
// ABI defines the encoding of the payload. Each element maps to exactly
// one stream (although sub-arrays may be specified for streams that
// produce a composite data type).
//
// EXAMPLE
//
// [{"multiplier":"10000","type":"uint192"}, ...]
//
// See definition of ABIEncoder struct for more details.
//
// The total number of streams must be 2+n, where n is the number of
// top-level elements in this ABI array (stream 0 is always the native
// token price and stream 1 is the link token price).
ABI []ABIEncoder `json:"abi"`
// TimeResolution is the resolution of the timestamps in the report.
// Seconds use uint32 ABI encoding, while milliseconds/microseconds/nanoseconds use uint64.
// Defaults to "s" (seconds) if not specified.
TimeResolution llo.TimeResolution `json:"timeResolution,omitempty"`
}
Opts format remains unchanged
func (*ReportFormatEVMABIEncodeOpts) Decode ¶
func (r *ReportFormatEVMABIEncodeOpts) Decode(opts []byte) error
func (*ReportFormatEVMABIEncodeOpts) Encode ¶
func (r *ReportFormatEVMABIEncodeOpts) Encode() ([]byte, error)
type ReportFormatEVMPremiumLegacyOpts ¶
type ReportFormatEVMPremiumLegacyOpts struct {
// BaseUSDFee is the cost on-chain of verifying a report
BaseUSDFee decimal.Decimal `json:"baseUSDFee"`
// Expiration window is the length of time in seconds the report is valid
// for, from the observation timestamp
ExpirationWindow uint32 `json:"expirationWindow"`
// FeedID is for compatibility with existing on-chain verifiers
FeedID common.Hash `json:"feedID"`
// Multiplier is used to scale the bid, benchmark and ask values in the
// report. If not specified, or zero is used, a multiplier of 1 is assumed.
Multiplier *ubig.Big `json:"multiplier"`
}
func (*ReportFormatEVMPremiumLegacyOpts) Decode ¶
func (r *ReportFormatEVMPremiumLegacyOpts) Decode(opts []byte) error
type ReportFormatEVMStreamlinedOpts ¶
type ReportFormatEVMStreamlinedOpts struct {
// FeedID is optional. If unspecified, the uint32 channel ID will be used
// instead to identify the payload.
FeedID *common.Hash `json:"feedID,omitempty"`
// ABI defines the encoding of the payload. Each element maps to exactly
// one stream (although sub-arrays may be specified for streams that
// produce a composite data type).
//
// EXAMPLE
//
// [{"multiplier":"10000","type":"uint192"}, ...]
//
// See definition of ABIEncoder struct for more details.
//
// The total number of streams must be n, where n is the number of
// top-level elements in this ABI array
ABI []ABIEncoder `json:"abi"`
}
func (*ReportFormatEVMStreamlinedOpts) Decode ¶
func (r *ReportFormatEVMStreamlinedOpts) Decode(opts []byte) error
func (*ReportFormatEVMStreamlinedOpts) Encode ¶
func (r *ReportFormatEVMStreamlinedOpts) Encode() ([]byte, error)