off_chain_updates

package
v1.0.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 31, 2023 License: AGPL-3.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidLengthOffChainUpdates        = fmt.Errorf("proto: negative length found during unmarshaling")
	ErrIntOverflowOffChainUpdates          = fmt.Errorf("proto: integer overflow")
	ErrUnexpectedEndOfGroupOffChainUpdates = fmt.Errorf("proto: unexpected end of group")
)
View Source
var OrderPlaceV1_OrderPlacementStatus_name = map[int32]string{
	0: "ORDER_PLACEMENT_STATUS_UNSPECIFIED",
	1: "ORDER_PLACEMENT_STATUS_BEST_EFFORT_OPENED",
	2: "ORDER_PLACEMENT_STATUS_OPENED",
}
View Source
var OrderPlaceV1_OrderPlacementStatus_value = map[string]int32{
	"ORDER_PLACEMENT_STATUS_UNSPECIFIED":        0,
	"ORDER_PLACEMENT_STATUS_BEST_EFFORT_OPENED": 1,
	"ORDER_PLACEMENT_STATUS_OPENED":             2,
}
View Source
var OrderRemoveV1_OrderRemovalStatus_name = map[int32]string{
	0: "ORDER_REMOVAL_STATUS_UNSPECIFIED",
	1: "ORDER_REMOVAL_STATUS_BEST_EFFORT_CANCELED",
	2: "ORDER_REMOVAL_STATUS_CANCELED",
	3: "ORDER_REMOVAL_STATUS_FILLED",
}
View Source
var OrderRemoveV1_OrderRemovalStatus_value = map[string]int32{
	"ORDER_REMOVAL_STATUS_UNSPECIFIED":          0,
	"ORDER_REMOVAL_STATUS_BEST_EFFORT_CANCELED": 1,
	"ORDER_REMOVAL_STATUS_CANCELED":             2,
	"ORDER_REMOVAL_STATUS_FILLED":               3,
}

Functions

func CreateOrderPlaceMessage

func CreateOrderPlaceMessage(
	logger log.Logger,
	order clobtypes.Order,
) (message msgsender.Message, success bool)

CreateOrderPlaceMessage creates an off-chain update message for an order.

func CreateOrderRemoveMessage

func CreateOrderRemoveMessage(
	logger log.Logger,
	orderId clobtypes.OrderId,
	orderStatus clobtypes.OrderStatus,
	orderError error,
	removalStatus OrderRemoveV1_OrderRemovalStatus,
) (message msgsender.Message, success bool)

CreateOrderRemoveMessage creates an off-chain update message for an order being removed, with the order's status and the resulting removal status of the removed order.

func CreateOrderRemoveMessageWithDefaultReason

func CreateOrderRemoveMessageWithDefaultReason(
	logger log.Logger,
	orderId clobtypes.OrderId,
	orderStatus clobtypes.OrderStatus,
	orderError error,
	removalStatus OrderRemoveV1_OrderRemovalStatus,
	defaultRemovalReason shared.OrderRemovalReason,
) (message msgsender.Message, success bool)

CreateOrderRemoveMessageWithDefaultReason creates an off-chain update message for an order being removed with the resulting removal status of the removed order. It attempts to look up the removal reason using the given orderStatus & orderError. If the reason cannot be found, it logs an error and falls back to the defaultRemovalReason. If defaultRemovalReason is ...UNSPECIFIED, it panics.

func CreateOrderRemoveMessageWithReason

func CreateOrderRemoveMessageWithReason(
	logger log.Logger,
	orderId clobtypes.OrderId,
	reason shared.OrderRemovalReason,
	removalStatus OrderRemoveV1_OrderRemovalStatus,
) (message msgsender.Message, success bool)

CreateOrderRemoveMessageWithReason creates an off-chain update message for an order being removed with a specific reason for the removal and the resulting removal status of the removed order.

func CreateOrderUpdateMessage

func CreateOrderUpdateMessage(
	logger log.Logger,
	orderId clobtypes.OrderId,
	totalFilled satypes.BaseQuantums,
) (message msgsender.Message, success bool)

CreateOrderUpdateMessage creates an off-chain update message for an order being updated.

func GetOrderIdHash

func GetOrderIdHash(orderId clobtypes.OrderId) ([]byte, error)

GetOrderIdHash gets the SHA256 hash of the `IndexerOrderId` mapped from an `OrderId`.

func MustCreateOrderPlaceMessage

func MustCreateOrderPlaceMessage(
	logger log.Logger,
	order clobtypes.Order,
) msgsender.Message

MustCreateOrderPlaceMessage invokes CreateOrderPlaceMessage and panics if creation was unsuccessful.

func MustCreateOrderRemoveMessage

func MustCreateOrderRemoveMessage(logger log.Logger,
	orderId clobtypes.OrderId,
	orderStatus clobtypes.OrderStatus,
	orderError error,
	removalStatus OrderRemoveV1_OrderRemovalStatus,
) msgsender.Message

MustCreateOrderRemoveMessage invokes CreateOrderRemoveMessage and panics if creation was unsuccessful.

func MustCreateOrderRemoveMessageWithReason

func MustCreateOrderRemoveMessageWithReason(
	logger log.Logger,
	orderId clobtypes.OrderId,
	reason shared.OrderRemovalReason,
	removalStatus OrderRemoveV1_OrderRemovalStatus,
) msgsender.Message

MustCreateOrderRemoveMessageWithReason invokes CreateOrderRemoveMessageWithReason and panics if creation was unsuccessful.

func MustCreateOrderUpdateMessage

func MustCreateOrderUpdateMessage(
	logger log.Logger,
	orderId clobtypes.OrderId,
	totalFilled satypes.BaseQuantums,
) msgsender.Message

MustCreateOrderUpdateMessage invokes CreateOrderUpdateMessage and panics if creation was unsuccessful.

func ShouldSendOrderRemovalOnReplay

func ShouldSendOrderRemovalOnReplay(
	orderError error,
) bool

ShouldSendOrderRemovalOnReplay returns a true/false for whether an order removal message should be sent given the error encountered while replaying an order. TODO(CLOB-518): Re-visit enumerating all the errors where an order removal should be / not be sent vs using the existence of an order nonce to determine if an order removal message should be sent.

Types

type OffChainUpdateV1

type OffChainUpdateV1 struct {
	// Contains one of an OrderPlaceV1, OrderRemoveV1, and OrderUpdateV1 message.
	//
	// Types that are valid to be assigned to UpdateMessage:
	//	*OffChainUpdateV1_OrderPlace
	//	*OffChainUpdateV1_OrderRemove
	//	*OffChainUpdateV1_OrderUpdate
	UpdateMessage isOffChainUpdateV1_UpdateMessage `protobuf_oneof:"update_message"`
}

An OffChainUpdate message is the message type which will be sent on Kafka to the Indexer.

func (*OffChainUpdateV1) Descriptor

func (*OffChainUpdateV1) Descriptor() ([]byte, []int)

func (*OffChainUpdateV1) GetOrderPlace

func (m *OffChainUpdateV1) GetOrderPlace() *OrderPlaceV1

func (*OffChainUpdateV1) GetOrderRemove

func (m *OffChainUpdateV1) GetOrderRemove() *OrderRemoveV1

func (*OffChainUpdateV1) GetOrderUpdate

func (m *OffChainUpdateV1) GetOrderUpdate() *OrderUpdateV1

func (*OffChainUpdateV1) GetUpdateMessage

func (m *OffChainUpdateV1) GetUpdateMessage() isOffChainUpdateV1_UpdateMessage

func (*OffChainUpdateV1) Marshal

func (m *OffChainUpdateV1) Marshal() (dAtA []byte, err error)

func (*OffChainUpdateV1) MarshalTo

func (m *OffChainUpdateV1) MarshalTo(dAtA []byte) (int, error)

func (*OffChainUpdateV1) MarshalToSizedBuffer

func (m *OffChainUpdateV1) MarshalToSizedBuffer(dAtA []byte) (int, error)

func (*OffChainUpdateV1) ProtoMessage

func (*OffChainUpdateV1) ProtoMessage()

func (*OffChainUpdateV1) Reset

func (m *OffChainUpdateV1) Reset()

func (*OffChainUpdateV1) Size

func (m *OffChainUpdateV1) Size() (n int)

func (*OffChainUpdateV1) String

func (m *OffChainUpdateV1) String() string

func (*OffChainUpdateV1) Unmarshal

func (m *OffChainUpdateV1) Unmarshal(dAtA []byte) error

func (*OffChainUpdateV1) XXX_DiscardUnknown

func (m *OffChainUpdateV1) XXX_DiscardUnknown()

func (*OffChainUpdateV1) XXX_Marshal

func (m *OffChainUpdateV1) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*OffChainUpdateV1) XXX_Merge

func (m *OffChainUpdateV1) XXX_Merge(src proto.Message)

func (*OffChainUpdateV1) XXX_OneofWrappers

func (*OffChainUpdateV1) XXX_OneofWrappers() []interface{}

XXX_OneofWrappers is for the internal use of the proto package.

func (*OffChainUpdateV1) XXX_Size

func (m *OffChainUpdateV1) XXX_Size() int

func (*OffChainUpdateV1) XXX_Unmarshal

func (m *OffChainUpdateV1) XXX_Unmarshal(b []byte) error

type OffChainUpdateV1_OrderPlace

type OffChainUpdateV1_OrderPlace struct {
	OrderPlace *OrderPlaceV1 `protobuf:"bytes,1,opt,name=order_place,json=orderPlace,proto3,oneof" json:"order_place,omitempty"`
}

func (*OffChainUpdateV1_OrderPlace) MarshalTo

func (m *OffChainUpdateV1_OrderPlace) MarshalTo(dAtA []byte) (int, error)

func (*OffChainUpdateV1_OrderPlace) MarshalToSizedBuffer

func (m *OffChainUpdateV1_OrderPlace) MarshalToSizedBuffer(dAtA []byte) (int, error)

func (*OffChainUpdateV1_OrderPlace) Size

func (m *OffChainUpdateV1_OrderPlace) Size() (n int)

type OffChainUpdateV1_OrderRemove

type OffChainUpdateV1_OrderRemove struct {
	OrderRemove *OrderRemoveV1 `protobuf:"bytes,2,opt,name=order_remove,json=orderRemove,proto3,oneof" json:"order_remove,omitempty"`
}

func (*OffChainUpdateV1_OrderRemove) MarshalTo

func (m *OffChainUpdateV1_OrderRemove) MarshalTo(dAtA []byte) (int, error)

func (*OffChainUpdateV1_OrderRemove) MarshalToSizedBuffer

func (m *OffChainUpdateV1_OrderRemove) MarshalToSizedBuffer(dAtA []byte) (int, error)

func (*OffChainUpdateV1_OrderRemove) Size

func (m *OffChainUpdateV1_OrderRemove) Size() (n int)

type OffChainUpdateV1_OrderUpdate

type OffChainUpdateV1_OrderUpdate struct {
	OrderUpdate *OrderUpdateV1 `protobuf:"bytes,3,opt,name=order_update,json=orderUpdate,proto3,oneof" json:"order_update,omitempty"`
}

func (*OffChainUpdateV1_OrderUpdate) MarshalTo

func (m *OffChainUpdateV1_OrderUpdate) MarshalTo(dAtA []byte) (int, error)

func (*OffChainUpdateV1_OrderUpdate) MarshalToSizedBuffer

func (m *OffChainUpdateV1_OrderUpdate) MarshalToSizedBuffer(dAtA []byte) (int, error)

func (*OffChainUpdateV1_OrderUpdate) Size

func (m *OffChainUpdateV1_OrderUpdate) Size() (n int)

type OrderPlaceV1

type OrderPlaceV1 struct {
	Order           *v1.IndexerOrder                  `protobuf:"bytes,1,opt,name=order,proto3" json:"order,omitempty"`
	PlacementStatus OrderPlaceV1_OrderPlacementStatus `` /* 185-byte string literal not displayed */
}

OrderPlace messages contain the order placed/replaced.

func (*OrderPlaceV1) Descriptor

func (*OrderPlaceV1) Descriptor() ([]byte, []int)

func (*OrderPlaceV1) GetOrder

func (m *OrderPlaceV1) GetOrder() *v1.IndexerOrder

func (*OrderPlaceV1) GetPlacementStatus

func (m *OrderPlaceV1) GetPlacementStatus() OrderPlaceV1_OrderPlacementStatus

func (*OrderPlaceV1) Marshal

func (m *OrderPlaceV1) Marshal() (dAtA []byte, err error)

func (*OrderPlaceV1) MarshalTo

func (m *OrderPlaceV1) MarshalTo(dAtA []byte) (int, error)

func (*OrderPlaceV1) MarshalToSizedBuffer

func (m *OrderPlaceV1) MarshalToSizedBuffer(dAtA []byte) (int, error)

func (*OrderPlaceV1) ProtoMessage

func (*OrderPlaceV1) ProtoMessage()

func (*OrderPlaceV1) Reset

func (m *OrderPlaceV1) Reset()

func (*OrderPlaceV1) Size

func (m *OrderPlaceV1) Size() (n int)

func (*OrderPlaceV1) String

func (m *OrderPlaceV1) String() string

func (*OrderPlaceV1) Unmarshal

func (m *OrderPlaceV1) Unmarshal(dAtA []byte) error

func (*OrderPlaceV1) XXX_DiscardUnknown

func (m *OrderPlaceV1) XXX_DiscardUnknown()

func (*OrderPlaceV1) XXX_Marshal

func (m *OrderPlaceV1) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*OrderPlaceV1) XXX_Merge

func (m *OrderPlaceV1) XXX_Merge(src proto.Message)

func (*OrderPlaceV1) XXX_Size

func (m *OrderPlaceV1) XXX_Size() int

func (*OrderPlaceV1) XXX_Unmarshal

func (m *OrderPlaceV1) XXX_Unmarshal(b []byte) error

type OrderPlaceV1_OrderPlacementStatus

type OrderPlaceV1_OrderPlacementStatus int32

OrderPlacementStatus is an enum for the resulting status after an order is placed.

const (
	// Default value, this is invalid and unused.
	OrderPlaceV1_ORDER_PLACEMENT_STATUS_UNSPECIFIED OrderPlaceV1_OrderPlacementStatus = 0
	// A best effort opened order is one that has only been confirmed to be
	// placed on the V4 node sending the off-chain update message.
	// The cases where this happens includes:
	// - The V4 node places an order in it's in-memory orderbook during the
	//   CheckTx flow.
	// A best effort placed order may not have been placed on other V4
	// nodes including other V4 validator nodes and may still be excluded in
	// future order matches.
	OrderPlaceV1_ORDER_PLACEMENT_STATUS_BEST_EFFORT_OPENED OrderPlaceV1_OrderPlacementStatus = 1
	// An opened order is one that is confirmed to be placed on all V4 nodes
	// (discounting dishonest V4 nodes) and will be included in any future
	// order matches.
	// This status is used internally by the indexer and will not be sent
	// out by protocol.
	OrderPlaceV1_ORDER_PLACEMENT_STATUS_OPENED OrderPlaceV1_OrderPlacementStatus = 2
)

func (OrderPlaceV1_OrderPlacementStatus) EnumDescriptor

func (OrderPlaceV1_OrderPlacementStatus) EnumDescriptor() ([]byte, []int)

func (OrderPlaceV1_OrderPlacementStatus) String

type OrderRemoveV1

type OrderRemoveV1 struct {
	RemovedOrderId *v1.IndexerOrderId               `protobuf:"bytes,1,opt,name=removed_order_id,json=removedOrderId,proto3" json:"removed_order_id,omitempty"`
	Reason         shared.OrderRemovalReason        `protobuf:"varint,2,opt,name=reason,proto3,enum=dydxprotocol.indexer.shared.OrderRemovalReason" json:"reason,omitempty"`
	RemovalStatus  OrderRemoveV1_OrderRemovalStatus `` /* 178-byte string literal not displayed */
}

OrderRemove messages contain the id of the order removed, the reason for the removal and the resulting status from the removal.

func (*OrderRemoveV1) Descriptor

func (*OrderRemoveV1) Descriptor() ([]byte, []int)

func (*OrderRemoveV1) GetReason

func (m *OrderRemoveV1) GetReason() shared.OrderRemovalReason

func (*OrderRemoveV1) GetRemovalStatus

func (m *OrderRemoveV1) GetRemovalStatus() OrderRemoveV1_OrderRemovalStatus

func (*OrderRemoveV1) GetRemovedOrderId

func (m *OrderRemoveV1) GetRemovedOrderId() *v1.IndexerOrderId

func (*OrderRemoveV1) Marshal

func (m *OrderRemoveV1) Marshal() (dAtA []byte, err error)

func (*OrderRemoveV1) MarshalTo

func (m *OrderRemoveV1) MarshalTo(dAtA []byte) (int, error)

func (*OrderRemoveV1) MarshalToSizedBuffer

func (m *OrderRemoveV1) MarshalToSizedBuffer(dAtA []byte) (int, error)

func (*OrderRemoveV1) ProtoMessage

func (*OrderRemoveV1) ProtoMessage()

func (*OrderRemoveV1) Reset

func (m *OrderRemoveV1) Reset()

func (*OrderRemoveV1) Size

func (m *OrderRemoveV1) Size() (n int)

func (*OrderRemoveV1) String

func (m *OrderRemoveV1) String() string

func (*OrderRemoveV1) Unmarshal

func (m *OrderRemoveV1) Unmarshal(dAtA []byte) error

func (*OrderRemoveV1) XXX_DiscardUnknown

func (m *OrderRemoveV1) XXX_DiscardUnknown()

func (*OrderRemoveV1) XXX_Marshal

func (m *OrderRemoveV1) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*OrderRemoveV1) XXX_Merge

func (m *OrderRemoveV1) XXX_Merge(src proto.Message)

func (*OrderRemoveV1) XXX_Size

func (m *OrderRemoveV1) XXX_Size() int

func (*OrderRemoveV1) XXX_Unmarshal

func (m *OrderRemoveV1) XXX_Unmarshal(b []byte) error

type OrderRemoveV1_OrderRemovalStatus

type OrderRemoveV1_OrderRemovalStatus int32

OrderRemovalStatus is an enum for the resulting status after an order is removed.

const (
	// Default value, this is invalid and unused.
	OrderRemoveV1_ORDER_REMOVAL_STATUS_UNSPECIFIED OrderRemoveV1_OrderRemovalStatus = 0
	// A best effort canceled order is one that has only been confirmed to be
	// removed on the V4 node sending the off-chain update message.
	// The cases where this happens includes:
	// - the order was removed due to the V4 node receiving a CancelOrder
	//   transaction for the order.
	// - the order was removed due to being undercollateralized during
	//   optimistic matching.
	// A best effort canceled order may not have been removed on other V4
	// nodes including other V4 validator nodes and may still be included in
	// future order matches.
	OrderRemoveV1_ORDER_REMOVAL_STATUS_BEST_EFFORT_CANCELED OrderRemoveV1_OrderRemovalStatus = 1
	// A canceled order is one that is confirmed to be removed on all V4 nodes
	// (discounting dishonest V4 nodes) and will not be included in any future
	// order matches.
	// The cases where this happens includes:
	// - the order is expired.
	OrderRemoveV1_ORDER_REMOVAL_STATUS_CANCELED OrderRemoveV1_OrderRemovalStatus = 2
	// An order was fully-filled. Only sent by the Indexer for stateful orders.
	OrderRemoveV1_ORDER_REMOVAL_STATUS_FILLED OrderRemoveV1_OrderRemovalStatus = 3
)

func (OrderRemoveV1_OrderRemovalStatus) EnumDescriptor

func (OrderRemoveV1_OrderRemovalStatus) EnumDescriptor() ([]byte, []int)

func (OrderRemoveV1_OrderRemovalStatus) String

type OrderUpdateV1

type OrderUpdateV1 struct {
	OrderId             *v1.IndexerOrderId `protobuf:"bytes,1,opt,name=order_id,json=orderId,proto3" json:"order_id,omitempty"`
	TotalFilledQuantums uint64             `protobuf:"varint,2,opt,name=total_filled_quantums,json=totalFilledQuantums,proto3" json:"total_filled_quantums,omitempty"`
}

OrderUpdate messages contain the id of the order being updated, and the updated total filled quantums of the order.

func (*OrderUpdateV1) Descriptor

func (*OrderUpdateV1) Descriptor() ([]byte, []int)

func (*OrderUpdateV1) GetOrderId

func (m *OrderUpdateV1) GetOrderId() *v1.IndexerOrderId

func (*OrderUpdateV1) GetTotalFilledQuantums

func (m *OrderUpdateV1) GetTotalFilledQuantums() uint64

func (*OrderUpdateV1) Marshal

func (m *OrderUpdateV1) Marshal() (dAtA []byte, err error)

func (*OrderUpdateV1) MarshalTo

func (m *OrderUpdateV1) MarshalTo(dAtA []byte) (int, error)

func (*OrderUpdateV1) MarshalToSizedBuffer

func (m *OrderUpdateV1) MarshalToSizedBuffer(dAtA []byte) (int, error)

func (*OrderUpdateV1) ProtoMessage

func (*OrderUpdateV1) ProtoMessage()

func (*OrderUpdateV1) Reset

func (m *OrderUpdateV1) Reset()

func (*OrderUpdateV1) Size

func (m *OrderUpdateV1) Size() (n int)

func (*OrderUpdateV1) String

func (m *OrderUpdateV1) String() string

func (*OrderUpdateV1) Unmarshal

func (m *OrderUpdateV1) Unmarshal(dAtA []byte) error

func (*OrderUpdateV1) XXX_DiscardUnknown

func (m *OrderUpdateV1) XXX_DiscardUnknown()

func (*OrderUpdateV1) XXX_Marshal

func (m *OrderUpdateV1) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*OrderUpdateV1) XXX_Merge

func (m *OrderUpdateV1) XXX_Merge(src proto.Message)

func (*OrderUpdateV1) XXX_Size

func (m *OrderUpdateV1) XXX_Size() int

func (*OrderUpdateV1) XXX_Unmarshal

func (m *OrderUpdateV1) XXX_Unmarshal(b []byte) error

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL