diff --git a/README.md b/README.md index b346ad969f6..edaec4d5be5 100644 --- a/README.md +++ b/README.md @@ -20,6 +20,19 @@ Note that this doesn't pull in upstream tags, so in order to do this follow thes 1. `git fetch upstream` 2. `git push --tags` +## dYdX Proto maintenance + +In order to support some of our custom functionality, we require some dydx protobuf files to be copied into this repository. Currently, the source of truth for protos is in `dydxprotocol/v4`, and any changes that require updates to any of the protos in this repository should be sync'd over as well. Here are steps for updating and compiling the protos here. + +1. Modify the protos in `proto/dydxcometbft`. +2. `make proto-gen` + +Note that the protos cannot be copied over directly. golang protobufs share a global namespace, and we have changed the package name slightly to avoid a name clash. + +We've also included a new dependency in the `buf.yaml` file for `"cosmos_proto/cosmos.proto"`. If this needs to be updated, run `buf build`. For more information, read [here](https://github.com/dydxprotocol/v4/tree/main/proto#update-protos). + +In the future, we will aim to have a single source of truth for protos. + ## Updating CometBFT to new versions When a new version of CometBFT is published, we may want to adopt the changes in our fork. This process can be somewhat tedious, but below are the recommended steps to accomplish this. diff --git a/mempool/clist_mempool.go b/mempool/clist_mempool.go index fb3aac2d373..57de6d8d0ad 100644 --- a/mempool/clist_mempool.go +++ b/mempool/clist_mempool.go @@ -430,14 +430,14 @@ func (mem *CListMempool) resCbFirstTime( "total", mem.Size(), ) - // If this transaction is a `PlaceOrder` or `CancelOrder` transaction, + // If this transaction is a short term `PlaceOrder` or `CancelOrder` transaction, // don't call `notifyTxsAvailable()`. The `notifyTxsAvailable()` function // uses a channel in the mempool called `txsAvailable` to signal to the // consensus algorithm that transactions are available to be included in // the next proposal. If no transactions are available for inclusion in // the next proposal, the consensus algorithm will wait for `create_empty_blocks_interval` // before proposing an empty block instead. - if IsClobOrderTransaction(memTx.tx, mem.logger) { + if IsShortTermClobOrderTransaction(memTx.tx, mem.logger) { return } @@ -572,9 +572,10 @@ func (mem *CListMempool) ReapMaxBytesMaxGas(maxBytes, maxGas int64) types.Txs { for e := mem.txs.Front(); e != nil; e = e.Next() { memTx := e.Value.(*mempoolTx) - // If this transaction is Cosmos transaction containing a `PlaceOrder` or `CancelOrder` message, + // If this transaction is Cosmos transaction containing a + // short term `PlaceOrder` or `CancelOrder` message, // don't include it in the next proposed block. - if IsClobOrderTransaction(memTx.tx, mem.logger) { + if IsShortTermClobOrderTransaction(memTx.tx, mem.logger) { continue } @@ -726,9 +727,10 @@ func (mem *CListMempool) recheckTxs() { for e := mem.txs.Front(); e != nil; e = e.Next() { memTx := e.Value.(*mempoolTx) - // If this transaction is Cosmos transaction containing a `PlaceOrder` or `CancelOrder` message, + // If this transaction is Cosmos transaction containing a + // short term `PlaceOrder` or `CancelOrder` message, // remove it from the mempool instead of rechecking. - if IsClobOrderTransaction(memTx.tx, mem.logger) { + if IsShortTermClobOrderTransaction(memTx.tx, mem.logger) { if err := mem.RemoveTxByKey(memTx.tx.Key()); err != nil { mem.logger.Debug("Recheck failed to remove short term CLOB transaction from mempool", "err", err) } diff --git a/mempool/dydx_helpers.go b/mempool/dydx_helpers.go index 18513b1847b..5e22d9aac66 100644 --- a/mempool/dydx_helpers.go +++ b/mempool/dydx_helpers.go @@ -2,13 +2,15 @@ package mempool import ( "github.com/cometbft/cometbft/libs/log" + "github.com/cometbft/cometbft/proto/dydxcometbft/clob" "github.com/cometbft/cometbft/types" cosmostx "github.com/cosmos/cosmos-sdk/types/tx" ) -// isClobOrderTransaction returns true if the provided `tx` is a -// Cosmos transaction containing a `MsgPlaceOrder` or `MsgCancelOrder` message. -func IsClobOrderTransaction( +// IsShortTermClobOrderTransaction returns true if the provided `tx` is a +// Cosmos transaction containing a short-term `MsgPlaceOrder` or +// short-term `MsgCancelOrder` message. +func IsShortTermClobOrderTransaction( tx types.Tx, mempoolLogger log.Logger, ) bool { @@ -18,12 +20,30 @@ func IsClobOrderTransaction( mempoolLogger.Error("isClobOrderTransaction error. Invalid Cosmos Transaction.") return false } - - if cosmosTx.Body != nil && - len(cosmosTx.Body.Messages) == 1 && - (cosmosTx.Body.Messages[0].TypeUrl == "/dydxprotocol.clob.MsgPlaceOrder" || - cosmosTx.Body.Messages[0].TypeUrl == "/dydxprotocol.clob.MsgCancelOrder") { - return true + if cosmosTx.Body != nil && len(cosmosTx.Body.Messages) == 1 { + bytes := cosmosTx.Body.Messages[0].Value + if cosmosTx.Body.Messages[0].TypeUrl == "/dydxprotocol.clob.MsgPlaceOrder" { + msgPlaceOrder := &clob.MsgPlaceOrder{} + err := msgPlaceOrder.Unmarshal(bytes) + // In the case of an unmarshalling error, panic. + // Chances are, the protos are out of sync with the dydx v4 repo. + if err != nil { + panic( + "Failed to unmarshal MsgPlaceOrder from Cosmos transaction in CometBFT mempool.", + ) + } + return msgPlaceOrder.Order.OrderId.IsShortTermOrder() + } + if cosmosTx.Body.Messages[0].TypeUrl == "/dydxprotocol.clob.MsgCancelOrder" { + msgCancelOrder := &clob.MsgCancelOrder{} + err := msgCancelOrder.Unmarshal(bytes) + // In the case of an unmarshalling error, panic. + // Chances are, the protos are out of sync with the dydx v4 repo. + if err != nil { + panic("Failed to unmarshal MsgCancelOrder from Cosmos transaction.") + } + return msgCancelOrder.OrderId.IsShortTermOrder() + } } return false diff --git a/proto/buf.lock b/proto/buf.lock index 51b78ffe35a..1bc0a2429e6 100644 --- a/proto/buf.lock +++ b/proto/buf.lock @@ -1,6 +1,11 @@ # Generated by buf. DO NOT EDIT. version: v1 deps: + - remote: buf.build + owner: cosmos + repository: cosmos-proto + commit: 1935555c206d4afb9e94615dfd0fad31 + digest: shake256:c74d91a3ac7ae07d579e90eee33abf9b29664047ac8816500cf22c081fec0d72d62c89ce0bebafc1f6fec7aa5315be72606717740ca95007248425102c365377 - remote: buf.build owner: cosmos repository: gogo-proto diff --git a/proto/buf.yaml b/proto/buf.yaml index a646c2030a7..a6e58e4edb5 100644 --- a/proto/buf.yaml +++ b/proto/buf.yaml @@ -2,6 +2,8 @@ version: v1 name: buf.build/tendermint/tendermint deps: - buf.build/cosmos/gogo-proto + # Latest release was in Dec 2021, https://buf.build/cosmos/cosmos-proto/commits/main + - buf.build/cosmos/cosmos-proto:1935555c206d4afb9e94615dfd0fad31 breaking: use: - FILE diff --git a/proto/dydxcometbft/clob/matches.pb.go b/proto/dydxcometbft/clob/matches.pb.go new file mode 100644 index 00000000000..63e7094f1e5 --- /dev/null +++ b/proto/dydxcometbft/clob/matches.pb.go @@ -0,0 +1,1952 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: dydxcometbft/clob/matches.proto + +package clob + +import ( + fmt "fmt" + subaccounts "github.com/cometbft/cometbft/proto/dydxcometbft/subaccounts" + _ "github.com/cosmos/gogoproto/gogoproto" + proto "github.com/cosmos/gogoproto/proto" + io "io" + math "math" + math_bits "math/bits" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package + +// ClobMatch represents an operations queue entry around all different types +// of matches, specifically regular matches, liquidation matches, and +// deleveraging matches. +type ClobMatch struct { + // The match type that this message includes. + // + // Types that are valid to be assigned to Match: + // *ClobMatch_MatchOrders + // *ClobMatch_MatchPerpetualLiquidation + // *ClobMatch_MatchPerpetualDeleveraging + Match isClobMatch_Match `protobuf_oneof:"match"` +} + +func (m *ClobMatch) Reset() { *m = ClobMatch{} } +func (m *ClobMatch) String() string { return proto.CompactTextString(m) } +func (*ClobMatch) ProtoMessage() {} +func (*ClobMatch) Descriptor() ([]byte, []int) { + return fileDescriptor_16615552089766b1, []int{0} +} +func (m *ClobMatch) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *ClobMatch) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_ClobMatch.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *ClobMatch) XXX_Merge(src proto.Message) { + xxx_messageInfo_ClobMatch.Merge(m, src) +} +func (m *ClobMatch) XXX_Size() int { + return m.Size() +} +func (m *ClobMatch) XXX_DiscardUnknown() { + xxx_messageInfo_ClobMatch.DiscardUnknown(m) +} + +var xxx_messageInfo_ClobMatch proto.InternalMessageInfo + +type isClobMatch_Match interface { + isClobMatch_Match() + MarshalTo([]byte) (int, error) + Size() int +} + +type ClobMatch_MatchOrders struct { + MatchOrders *MatchOrders `protobuf:"bytes,1,opt,name=match_orders,json=matchOrders,proto3,oneof" json:"match_orders,omitempty"` +} +type ClobMatch_MatchPerpetualLiquidation struct { + MatchPerpetualLiquidation *MatchPerpetualLiquidation `protobuf:"bytes,2,opt,name=match_perpetual_liquidation,json=matchPerpetualLiquidation,proto3,oneof" json:"match_perpetual_liquidation,omitempty"` +} +type ClobMatch_MatchPerpetualDeleveraging struct { + MatchPerpetualDeleveraging *MatchPerpetualDeleveraging `protobuf:"bytes,3,opt,name=match_perpetual_deleveraging,json=matchPerpetualDeleveraging,proto3,oneof" json:"match_perpetual_deleveraging,omitempty"` +} + +func (*ClobMatch_MatchOrders) isClobMatch_Match() {} +func (*ClobMatch_MatchPerpetualLiquidation) isClobMatch_Match() {} +func (*ClobMatch_MatchPerpetualDeleveraging) isClobMatch_Match() {} + +func (m *ClobMatch) GetMatch() isClobMatch_Match { + if m != nil { + return m.Match + } + return nil +} + +func (m *ClobMatch) GetMatchOrders() *MatchOrders { + if x, ok := m.GetMatch().(*ClobMatch_MatchOrders); ok { + return x.MatchOrders + } + return nil +} + +func (m *ClobMatch) GetMatchPerpetualLiquidation() *MatchPerpetualLiquidation { + if x, ok := m.GetMatch().(*ClobMatch_MatchPerpetualLiquidation); ok { + return x.MatchPerpetualLiquidation + } + return nil +} + +func (m *ClobMatch) GetMatchPerpetualDeleveraging() *MatchPerpetualDeleveraging { + if x, ok := m.GetMatch().(*ClobMatch_MatchPerpetualDeleveraging); ok { + return x.MatchPerpetualDeleveraging + } + return nil +} + +// XXX_OneofWrappers is for the internal use of the proto package. +func (*ClobMatch) XXX_OneofWrappers() []interface{} { + return []interface{}{ + (*ClobMatch_MatchOrders)(nil), + (*ClobMatch_MatchPerpetualLiquidation)(nil), + (*ClobMatch_MatchPerpetualDeleveraging)(nil), + } +} + +// MakerFill represents the filled amount of a matched maker order. +type MakerFill struct { + // The filled amount of the matched maker order, in base quantums. + FillAmount uint64 `protobuf:"varint,1,opt,name=fill_amount,json=fillAmount,proto3" json:"fill_amount,omitempty"` + // The `OrderId` of the matched maker order. + MakerOrderId OrderId `protobuf:"bytes,2,opt,name=maker_order_id,json=makerOrderId,proto3" json:"maker_order_id"` +} + +func (m *MakerFill) Reset() { *m = MakerFill{} } +func (m *MakerFill) String() string { return proto.CompactTextString(m) } +func (*MakerFill) ProtoMessage() {} +func (*MakerFill) Descriptor() ([]byte, []int) { + return fileDescriptor_16615552089766b1, []int{1} +} +func (m *MakerFill) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MakerFill) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MakerFill.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *MakerFill) XXX_Merge(src proto.Message) { + xxx_messageInfo_MakerFill.Merge(m, src) +} +func (m *MakerFill) XXX_Size() int { + return m.Size() +} +func (m *MakerFill) XXX_DiscardUnknown() { + xxx_messageInfo_MakerFill.DiscardUnknown(m) +} + +var xxx_messageInfo_MakerFill proto.InternalMessageInfo + +func (m *MakerFill) GetFillAmount() uint64 { + if m != nil { + return m.FillAmount + } + return 0 +} + +func (m *MakerFill) GetMakerOrderId() OrderId { + if m != nil { + return m.MakerOrderId + } + return OrderId{} +} + +// MatchOrders is an injected message used for matching orders. +type MatchOrders struct { + // The `OrderId` of the taker order. + TakerOrderId OrderId `protobuf:"bytes,1,opt,name=taker_order_id,json=takerOrderId,proto3" json:"taker_order_id"` + // An ordered list of fills created by this taker order. + Fills []MakerFill `protobuf:"bytes,2,rep,name=fills,proto3" json:"fills"` + // The `OrderHash` of the taker order. Used to differentiate replacement + // orders. + // TODO(CLOB-274): Determine whether this can replace the `taker_order_id` + // above, or if this is necessary to be included in the block at all. + TakerOrderHash []byte `protobuf:"bytes,3,opt,name=taker_order_hash,json=takerOrderHash,proto3" json:"taker_order_hash,omitempty"` +} + +func (m *MatchOrders) Reset() { *m = MatchOrders{} } +func (m *MatchOrders) String() string { return proto.CompactTextString(m) } +func (*MatchOrders) ProtoMessage() {} +func (*MatchOrders) Descriptor() ([]byte, []int) { + return fileDescriptor_16615552089766b1, []int{2} +} +func (m *MatchOrders) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MatchOrders) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MatchOrders.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *MatchOrders) XXX_Merge(src proto.Message) { + xxx_messageInfo_MatchOrders.Merge(m, src) +} +func (m *MatchOrders) XXX_Size() int { + return m.Size() +} +func (m *MatchOrders) XXX_DiscardUnknown() { + xxx_messageInfo_MatchOrders.DiscardUnknown(m) +} + +var xxx_messageInfo_MatchOrders proto.InternalMessageInfo + +func (m *MatchOrders) GetTakerOrderId() OrderId { + if m != nil { + return m.TakerOrderId + } + return OrderId{} +} + +func (m *MatchOrders) GetFills() []MakerFill { + if m != nil { + return m.Fills + } + return nil +} + +func (m *MatchOrders) GetTakerOrderHash() []byte { + if m != nil { + return m.TakerOrderHash + } + return nil +} + +// MatchPerpetualLiquidation is an injected message used for liquidating a +// subaccount. +type MatchPerpetualLiquidation struct { + // ID of the subaccount that was liquidated. + Liquidated subaccounts.SubaccountId `protobuf:"bytes,1,opt,name=liquidated,proto3" json:"liquidated"` + // The ID of the clob pair involved in the liquidation. + ClobPairId uint32 `protobuf:"varint,2,opt,name=clob_pair_id,json=clobPairId,proto3" json:"clob_pair_id,omitempty"` + // The ID of the perpetual involved in the liquidation. + PerpetualId uint32 `protobuf:"varint,3,opt,name=perpetual_id,json=perpetualId,proto3" json:"perpetual_id,omitempty"` + // The total size of the liquidation order including any unfilled size. + TotalSize uint64 `protobuf:"varint,4,opt,name=total_size,json=totalSize,proto3" json:"total_size,omitempty"` + // `true` if liquidating a short position, `false` otherwise. + IsBuy bool `protobuf:"varint,5,opt,name=is_buy,json=isBuy,proto3" json:"is_buy,omitempty"` + // An ordered list of fills created by this liquidation. + Fills []MakerFill `protobuf:"bytes,6,rep,name=fills,proto3" json:"fills"` +} + +func (m *MatchPerpetualLiquidation) Reset() { *m = MatchPerpetualLiquidation{} } +func (m *MatchPerpetualLiquidation) String() string { return proto.CompactTextString(m) } +func (*MatchPerpetualLiquidation) ProtoMessage() {} +func (*MatchPerpetualLiquidation) Descriptor() ([]byte, []int) { + return fileDescriptor_16615552089766b1, []int{3} +} +func (m *MatchPerpetualLiquidation) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MatchPerpetualLiquidation) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MatchPerpetualLiquidation.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *MatchPerpetualLiquidation) XXX_Merge(src proto.Message) { + xxx_messageInfo_MatchPerpetualLiquidation.Merge(m, src) +} +func (m *MatchPerpetualLiquidation) XXX_Size() int { + return m.Size() +} +func (m *MatchPerpetualLiquidation) XXX_DiscardUnknown() { + xxx_messageInfo_MatchPerpetualLiquidation.DiscardUnknown(m) +} + +var xxx_messageInfo_MatchPerpetualLiquidation proto.InternalMessageInfo + +func (m *MatchPerpetualLiquidation) GetLiquidated() subaccounts.SubaccountId { + if m != nil { + return m.Liquidated + } + return subaccounts.SubaccountId{} +} + +func (m *MatchPerpetualLiquidation) GetClobPairId() uint32 { + if m != nil { + return m.ClobPairId + } + return 0 +} + +func (m *MatchPerpetualLiquidation) GetPerpetualId() uint32 { + if m != nil { + return m.PerpetualId + } + return 0 +} + +func (m *MatchPerpetualLiquidation) GetTotalSize() uint64 { + if m != nil { + return m.TotalSize + } + return 0 +} + +func (m *MatchPerpetualLiquidation) GetIsBuy() bool { + if m != nil { + return m.IsBuy + } + return false +} + +func (m *MatchPerpetualLiquidation) GetFills() []MakerFill { + if m != nil { + return m.Fills + } + return nil +} + +// MatchPerpetualDeleveraging is an injected message used for deleveraging a +// subaccount. +type MatchPerpetualDeleveraging struct { + // ID of the subaccount that was liquidated. + Liquidated subaccounts.SubaccountId `protobuf:"bytes,1,opt,name=liquidated,proto3" json:"liquidated"` + // The ID of the perpetual that was liquidated. + PerpetualId uint32 `protobuf:"varint,2,opt,name=perpetual_id,json=perpetualId,proto3" json:"perpetual_id,omitempty"` + // An ordered list of fills created by this liquidation. + Fills []MatchPerpetualDeleveraging_Fill `protobuf:"bytes,3,rep,name=fills,proto3" json:"fills"` +} + +func (m *MatchPerpetualDeleveraging) Reset() { *m = MatchPerpetualDeleveraging{} } +func (m *MatchPerpetualDeleveraging) String() string { return proto.CompactTextString(m) } +func (*MatchPerpetualDeleveraging) ProtoMessage() {} +func (*MatchPerpetualDeleveraging) Descriptor() ([]byte, []int) { + return fileDescriptor_16615552089766b1, []int{4} +} +func (m *MatchPerpetualDeleveraging) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MatchPerpetualDeleveraging) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MatchPerpetualDeleveraging.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *MatchPerpetualDeleveraging) XXX_Merge(src proto.Message) { + xxx_messageInfo_MatchPerpetualDeleveraging.Merge(m, src) +} +func (m *MatchPerpetualDeleveraging) XXX_Size() int { + return m.Size() +} +func (m *MatchPerpetualDeleveraging) XXX_DiscardUnknown() { + xxx_messageInfo_MatchPerpetualDeleveraging.DiscardUnknown(m) +} + +var xxx_messageInfo_MatchPerpetualDeleveraging proto.InternalMessageInfo + +func (m *MatchPerpetualDeleveraging) GetLiquidated() subaccounts.SubaccountId { + if m != nil { + return m.Liquidated + } + return subaccounts.SubaccountId{} +} + +func (m *MatchPerpetualDeleveraging) GetPerpetualId() uint32 { + if m != nil { + return m.PerpetualId + } + return 0 +} + +func (m *MatchPerpetualDeleveraging) GetFills() []MatchPerpetualDeleveraging_Fill { + if m != nil { + return m.Fills + } + return nil +} + +// Fill represents a fill between the liquidated and deleveraged subaccount. +type MatchPerpetualDeleveraging_Fill struct { + // ID of the subaccount that was deleveraged. + Deleveraged subaccounts.SubaccountId `protobuf:"bytes,1,opt,name=deleveraged,proto3" json:"deleveraged"` + // The amount filled between the liquidated and deleveraged position, in + // base quantums. + FillAmount uint64 `protobuf:"varint,2,opt,name=fill_amount,json=fillAmount,proto3" json:"fill_amount,omitempty"` +} + +func (m *MatchPerpetualDeleveraging_Fill) Reset() { *m = MatchPerpetualDeleveraging_Fill{} } +func (m *MatchPerpetualDeleveraging_Fill) String() string { return proto.CompactTextString(m) } +func (*MatchPerpetualDeleveraging_Fill) ProtoMessage() {} +func (*MatchPerpetualDeleveraging_Fill) Descriptor() ([]byte, []int) { + return fileDescriptor_16615552089766b1, []int{4, 0} +} +func (m *MatchPerpetualDeleveraging_Fill) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MatchPerpetualDeleveraging_Fill) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MatchPerpetualDeleveraging_Fill.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *MatchPerpetualDeleveraging_Fill) XXX_Merge(src proto.Message) { + xxx_messageInfo_MatchPerpetualDeleveraging_Fill.Merge(m, src) +} +func (m *MatchPerpetualDeleveraging_Fill) XXX_Size() int { + return m.Size() +} +func (m *MatchPerpetualDeleveraging_Fill) XXX_DiscardUnknown() { + xxx_messageInfo_MatchPerpetualDeleveraging_Fill.DiscardUnknown(m) +} + +var xxx_messageInfo_MatchPerpetualDeleveraging_Fill proto.InternalMessageInfo + +func (m *MatchPerpetualDeleveraging_Fill) GetDeleveraged() subaccounts.SubaccountId { + if m != nil { + return m.Deleveraged + } + return subaccounts.SubaccountId{} +} + +func (m *MatchPerpetualDeleveraging_Fill) GetFillAmount() uint64 { + if m != nil { + return m.FillAmount + } + return 0 +} + +func init() { + proto.RegisterType((*ClobMatch)(nil), "dydxcometbft.clob.ClobMatch") + proto.RegisterType((*MakerFill)(nil), "dydxcometbft.clob.MakerFill") + proto.RegisterType((*MatchOrders)(nil), "dydxcometbft.clob.MatchOrders") + proto.RegisterType((*MatchPerpetualLiquidation)(nil), "dydxcometbft.clob.MatchPerpetualLiquidation") + proto.RegisterType((*MatchPerpetualDeleveraging)(nil), "dydxcometbft.clob.MatchPerpetualDeleveraging") + proto.RegisterType((*MatchPerpetualDeleveraging_Fill)(nil), "dydxcometbft.clob.MatchPerpetualDeleveraging.Fill") +} + +func init() { proto.RegisterFile("dydxcometbft/clob/matches.proto", fileDescriptor_16615552089766b1) } + +var fileDescriptor_16615552089766b1 = []byte{ + // 587 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x54, 0x4d, 0x6e, 0xd3, 0x40, + 0x14, 0xb6, 0xdd, 0xa4, 0xd0, 0xe7, 0xb4, 0x82, 0x11, 0x48, 0xae, 0x69, 0x9d, 0x90, 0x05, 0x0a, + 0x12, 0x38, 0x52, 0x60, 0xc1, 0x96, 0x14, 0x55, 0xa9, 0xd4, 0x86, 0xca, 0xdd, 0xb1, 0xb1, 0xc6, + 0xf6, 0x34, 0x19, 0x61, 0x67, 0x52, 0x7b, 0x0c, 0xa4, 0xa7, 0xe0, 0x04, 0xdc, 0x03, 0x89, 0x03, + 0x74, 0xd9, 0x15, 0x62, 0x85, 0x50, 0x72, 0x11, 0x34, 0xe3, 0x24, 0x76, 0x92, 0x46, 0x50, 0xc4, + 0x6e, 0xfc, 0x7e, 0xbe, 0xf7, 0x7d, 0x9f, 0xe7, 0x0d, 0x54, 0x83, 0x51, 0xf0, 0xc9, 0x67, 0x11, + 0xe1, 0xde, 0x39, 0x6f, 0xfa, 0x21, 0xf3, 0x9a, 0x11, 0xe6, 0x7e, 0x9f, 0x24, 0xf6, 0x30, 0x66, + 0x9c, 0xa1, 0xfb, 0xc5, 0x02, 0x5b, 0x14, 0x98, 0x0f, 0x7a, 0xac, 0xc7, 0x64, 0xb6, 0x29, 0x4e, + 0x59, 0xa1, 0xf9, 0x74, 0x01, 0x29, 0x49, 0x3d, 0xec, 0xfb, 0x2c, 0x1d, 0xf0, 0xa4, 0x70, 0x9e, + 0x96, 0xee, 0xaf, 0x0e, 0x65, 0x71, 0x40, 0xe2, 0x2c, 0x5d, 0xff, 0xa6, 0xc1, 0xd6, 0x41, 0xc8, + 0xbc, 0x13, 0x41, 0x04, 0x1d, 0x40, 0x45, 0x32, 0x72, 0x65, 0x49, 0x62, 0xa8, 0x35, 0xb5, 0xa1, + 0xb7, 0x2c, 0x7b, 0x85, 0x97, 0x2d, 0xeb, 0xdf, 0xca, 0xaa, 0x8e, 0xe2, 0xe8, 0x51, 0xfe, 0x89, + 0x06, 0xf0, 0x28, 0x03, 0x19, 0x92, 0x78, 0x48, 0x78, 0x8a, 0x43, 0x37, 0xa4, 0x17, 0x29, 0x0d, + 0x30, 0xa7, 0x6c, 0x60, 0x68, 0x12, 0xf3, 0xd9, 0x3a, 0xcc, 0xd3, 0x59, 0xd3, 0x71, 0xde, 0xd3, + 0x51, 0x9c, 0xdd, 0x68, 0x5d, 0x12, 0x5d, 0xc0, 0xde, 0xf2, 0xbc, 0x80, 0x84, 0xe4, 0x03, 0x89, + 0x71, 0x8f, 0x0e, 0x7a, 0xc6, 0x86, 0x1c, 0xf8, 0xfc, 0x8f, 0x03, 0xdf, 0x14, 0x9a, 0x3a, 0x8a, + 0x63, 0x46, 0x6b, 0xb3, 0xed, 0x3b, 0x50, 0x96, 0xd9, 0x3a, 0x87, 0xad, 0x13, 0xfc, 0x9e, 0xc4, + 0x87, 0x34, 0x0c, 0x51, 0x15, 0xf4, 0x73, 0x1a, 0x86, 0x2e, 0x8e, 0x84, 0xff, 0xd2, 0xbc, 0x92, + 0x03, 0x22, 0xf4, 0x5a, 0x46, 0xd0, 0x21, 0xec, 0x44, 0xa2, 0x3a, 0xb3, 0xd7, 0xa5, 0xc1, 0xd4, + 0x0c, 0xf3, 0x06, 0x6e, 0xd2, 0xcc, 0xa3, 0xa0, 0x5d, 0xba, 0xfa, 0x59, 0x55, 0x9c, 0x8a, 0xec, + 0x9b, 0xc6, 0xea, 0x5f, 0x55, 0xd0, 0x0b, 0x3f, 0x40, 0xe0, 0xf2, 0x45, 0x5c, 0xf5, 0x6f, 0x71, + 0x79, 0x01, 0x17, 0xbd, 0x82, 0xb2, 0x60, 0x9b, 0x18, 0x5a, 0x6d, 0xa3, 0xa1, 0xb7, 0xf6, 0x6e, + 0xb4, 0x6c, 0xaa, 0x76, 0x0a, 0x90, 0x35, 0xa0, 0x06, 0xdc, 0x2b, 0x32, 0xe8, 0xe3, 0xa4, 0x2f, + 0x7d, 0xaf, 0x38, 0x3b, 0xf9, 0x84, 0x0e, 0x4e, 0xfa, 0xf5, 0x2f, 0x1a, 0xec, 0xae, 0xfd, 0xd1, + 0xe8, 0x18, 0x60, 0x76, 0x57, 0xc8, 0x4c, 0xc5, 0x93, 0x45, 0x1a, 0x85, 0xdb, 0x6e, 0x9f, 0xcd, + 0xcf, 0x73, 0x45, 0x85, 0x7e, 0x54, 0x83, 0x8a, 0x20, 0xed, 0x0e, 0x31, 0x9d, 0xbb, 0xbd, 0xed, + 0x80, 0x88, 0x9d, 0x62, 0x2a, 0x14, 0x3f, 0x86, 0x4a, 0x7e, 0x6b, 0x68, 0x20, 0x39, 0x6f, 0x3b, + 0xfa, 0x3c, 0x76, 0x14, 0xa0, 0x7d, 0x00, 0xce, 0x38, 0x0e, 0xdd, 0x84, 0x5e, 0x12, 0xa3, 0x24, + 0x7f, 0xea, 0x96, 0x8c, 0x9c, 0xd1, 0x4b, 0x82, 0x1e, 0xc2, 0x26, 0x4d, 0x5c, 0x2f, 0x1d, 0x19, + 0xe5, 0x9a, 0xda, 0xb8, 0xeb, 0x94, 0x69, 0xd2, 0x4e, 0x47, 0xb9, 0x95, 0x9b, 0xb7, 0xb4, 0xb2, + 0xfe, 0x5d, 0x03, 0x73, 0xfd, 0xc5, 0xfc, 0xcf, 0x0e, 0x2d, 0xeb, 0xd7, 0x56, 0xf5, 0x77, 0x67, + 0x4a, 0x36, 0xa4, 0x92, 0xd6, 0xad, 0xf6, 0xc8, 0x5e, 0xd1, 0x67, 0x7e, 0x84, 0x92, 0xdc, 0x96, + 0x2e, 0xe8, 0xf3, 0x35, 0xfd, 0x47, 0x25, 0x45, 0x80, 0xe5, 0xed, 0xd3, 0x96, 0xb7, 0xaf, 0xdd, + 0xbd, 0x1a, 0x5b, 0xea, 0xf5, 0xd8, 0x52, 0x7f, 0x8d, 0x2d, 0xf5, 0xf3, 0xc4, 0x52, 0xae, 0x27, + 0x96, 0xf2, 0x63, 0x62, 0x29, 0xef, 0x5e, 0xf6, 0x28, 0xef, 0xa7, 0x9e, 0xed, 0xb3, 0xa8, 0x99, + 0x3f, 0x95, 0xb3, 0x43, 0xf6, 0xfa, 0xae, 0x3c, 0xa3, 0xde, 0xa6, 0x4c, 0xbc, 0xf8, 0x1d, 0x00, + 0x00, 0xff, 0xff, 0xa7, 0xac, 0xd6, 0xe9, 0xd7, 0x05, 0x00, 0x00, +} + +func (m *ClobMatch) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *ClobMatch) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *ClobMatch) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Match != nil { + { + size := m.Match.Size() + i -= size + if _, err := m.Match.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + } + } + return len(dAtA) - i, nil +} + +func (m *ClobMatch_MatchOrders) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *ClobMatch_MatchOrders) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + if m.MatchOrders != nil { + { + size, err := m.MatchOrders.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintMatches(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} +func (m *ClobMatch_MatchPerpetualLiquidation) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *ClobMatch_MatchPerpetualLiquidation) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + if m.MatchPerpetualLiquidation != nil { + { + size, err := m.MatchPerpetualLiquidation.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintMatches(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + return len(dAtA) - i, nil +} +func (m *ClobMatch_MatchPerpetualDeleveraging) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *ClobMatch_MatchPerpetualDeleveraging) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + if m.MatchPerpetualDeleveraging != nil { + { + size, err := m.MatchPerpetualDeleveraging.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintMatches(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x1a + } + return len(dAtA) - i, nil +} +func (m *MakerFill) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *MakerFill) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MakerFill) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + { + size, err := m.MakerOrderId.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintMatches(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + if m.FillAmount != 0 { + i = encodeVarintMatches(dAtA, i, uint64(m.FillAmount)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + +func (m *MatchOrders) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *MatchOrders) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MatchOrders) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.TakerOrderHash) > 0 { + i -= len(m.TakerOrderHash) + copy(dAtA[i:], m.TakerOrderHash) + i = encodeVarintMatches(dAtA, i, uint64(len(m.TakerOrderHash))) + i-- + dAtA[i] = 0x1a + } + if len(m.Fills) > 0 { + for iNdEx := len(m.Fills) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.Fills[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintMatches(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + } + { + size, err := m.TakerOrderId.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintMatches(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + return len(dAtA) - i, nil +} + +func (m *MatchPerpetualLiquidation) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *MatchPerpetualLiquidation) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MatchPerpetualLiquidation) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Fills) > 0 { + for iNdEx := len(m.Fills) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.Fills[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintMatches(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x32 + } + } + if m.IsBuy { + i-- + if m.IsBuy { + dAtA[i] = 1 + } else { + dAtA[i] = 0 + } + i-- + dAtA[i] = 0x28 + } + if m.TotalSize != 0 { + i = encodeVarintMatches(dAtA, i, uint64(m.TotalSize)) + i-- + dAtA[i] = 0x20 + } + if m.PerpetualId != 0 { + i = encodeVarintMatches(dAtA, i, uint64(m.PerpetualId)) + i-- + dAtA[i] = 0x18 + } + if m.ClobPairId != 0 { + i = encodeVarintMatches(dAtA, i, uint64(m.ClobPairId)) + i-- + dAtA[i] = 0x10 + } + { + size, err := m.Liquidated.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintMatches(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + return len(dAtA) - i, nil +} + +func (m *MatchPerpetualDeleveraging) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *MatchPerpetualDeleveraging) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MatchPerpetualDeleveraging) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Fills) > 0 { + for iNdEx := len(m.Fills) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.Fills[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintMatches(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x1a + } + } + if m.PerpetualId != 0 { + i = encodeVarintMatches(dAtA, i, uint64(m.PerpetualId)) + i-- + dAtA[i] = 0x10 + } + { + size, err := m.Liquidated.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintMatches(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + return len(dAtA) - i, nil +} + +func (m *MatchPerpetualDeleveraging_Fill) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *MatchPerpetualDeleveraging_Fill) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MatchPerpetualDeleveraging_Fill) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.FillAmount != 0 { + i = encodeVarintMatches(dAtA, i, uint64(m.FillAmount)) + i-- + dAtA[i] = 0x10 + } + { + size, err := m.Deleveraged.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintMatches(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + return len(dAtA) - i, nil +} + +func encodeVarintMatches(dAtA []byte, offset int, v uint64) int { + offset -= sovMatches(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *ClobMatch) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Match != nil { + n += m.Match.Size() + } + return n +} + +func (m *ClobMatch_MatchOrders) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.MatchOrders != nil { + l = m.MatchOrders.Size() + n += 1 + l + sovMatches(uint64(l)) + } + return n +} +func (m *ClobMatch_MatchPerpetualLiquidation) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.MatchPerpetualLiquidation != nil { + l = m.MatchPerpetualLiquidation.Size() + n += 1 + l + sovMatches(uint64(l)) + } + return n +} +func (m *ClobMatch_MatchPerpetualDeleveraging) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.MatchPerpetualDeleveraging != nil { + l = m.MatchPerpetualDeleveraging.Size() + n += 1 + l + sovMatches(uint64(l)) + } + return n +} +func (m *MakerFill) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.FillAmount != 0 { + n += 1 + sovMatches(uint64(m.FillAmount)) + } + l = m.MakerOrderId.Size() + n += 1 + l + sovMatches(uint64(l)) + return n +} + +func (m *MatchOrders) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = m.TakerOrderId.Size() + n += 1 + l + sovMatches(uint64(l)) + if len(m.Fills) > 0 { + for _, e := range m.Fills { + l = e.Size() + n += 1 + l + sovMatches(uint64(l)) + } + } + l = len(m.TakerOrderHash) + if l > 0 { + n += 1 + l + sovMatches(uint64(l)) + } + return n +} + +func (m *MatchPerpetualLiquidation) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = m.Liquidated.Size() + n += 1 + l + sovMatches(uint64(l)) + if m.ClobPairId != 0 { + n += 1 + sovMatches(uint64(m.ClobPairId)) + } + if m.PerpetualId != 0 { + n += 1 + sovMatches(uint64(m.PerpetualId)) + } + if m.TotalSize != 0 { + n += 1 + sovMatches(uint64(m.TotalSize)) + } + if m.IsBuy { + n += 2 + } + if len(m.Fills) > 0 { + for _, e := range m.Fills { + l = e.Size() + n += 1 + l + sovMatches(uint64(l)) + } + } + return n +} + +func (m *MatchPerpetualDeleveraging) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = m.Liquidated.Size() + n += 1 + l + sovMatches(uint64(l)) + if m.PerpetualId != 0 { + n += 1 + sovMatches(uint64(m.PerpetualId)) + } + if len(m.Fills) > 0 { + for _, e := range m.Fills { + l = e.Size() + n += 1 + l + sovMatches(uint64(l)) + } + } + return n +} + +func (m *MatchPerpetualDeleveraging_Fill) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = m.Deleveraged.Size() + n += 1 + l + sovMatches(uint64(l)) + if m.FillAmount != 0 { + n += 1 + sovMatches(uint64(m.FillAmount)) + } + return n +} + +func sovMatches(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozMatches(x uint64) (n int) { + return sovMatches(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *ClobMatch) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowMatches + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: ClobMatch: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: ClobMatch: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field MatchOrders", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowMatches + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthMatches + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthMatches + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + v := &MatchOrders{} + if err := v.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + m.Match = &ClobMatch_MatchOrders{v} + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field MatchPerpetualLiquidation", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowMatches + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthMatches + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthMatches + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + v := &MatchPerpetualLiquidation{} + if err := v.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + m.Match = &ClobMatch_MatchPerpetualLiquidation{v} + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field MatchPerpetualDeleveraging", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowMatches + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthMatches + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthMatches + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + v := &MatchPerpetualDeleveraging{} + if err := v.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + m.Match = &ClobMatch_MatchPerpetualDeleveraging{v} + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipMatches(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthMatches + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *MakerFill) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowMatches + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: MakerFill: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MakerFill: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field FillAmount", wireType) + } + m.FillAmount = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowMatches + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.FillAmount |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field MakerOrderId", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowMatches + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthMatches + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthMatches + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.MakerOrderId.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipMatches(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthMatches + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *MatchOrders) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowMatches + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: MatchOrders: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MatchOrders: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field TakerOrderId", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowMatches + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthMatches + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthMatches + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.TakerOrderId.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Fills", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowMatches + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthMatches + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthMatches + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Fills = append(m.Fills, MakerFill{}) + if err := m.Fills[len(m.Fills)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field TakerOrderHash", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowMatches + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthMatches + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthMatches + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.TakerOrderHash = append(m.TakerOrderHash[:0], dAtA[iNdEx:postIndex]...) + if m.TakerOrderHash == nil { + m.TakerOrderHash = []byte{} + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipMatches(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthMatches + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *MatchPerpetualLiquidation) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowMatches + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: MatchPerpetualLiquidation: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MatchPerpetualLiquidation: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Liquidated", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowMatches + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthMatches + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthMatches + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.Liquidated.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 2: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field ClobPairId", wireType) + } + m.ClobPairId = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowMatches + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.ClobPairId |= uint32(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 3: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field PerpetualId", wireType) + } + m.PerpetualId = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowMatches + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.PerpetualId |= uint32(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 4: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field TotalSize", wireType) + } + m.TotalSize = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowMatches + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.TotalSize |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 5: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field IsBuy", wireType) + } + var v int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowMatches + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + m.IsBuy = bool(v != 0) + case 6: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Fills", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowMatches + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthMatches + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthMatches + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Fills = append(m.Fills, MakerFill{}) + if err := m.Fills[len(m.Fills)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipMatches(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthMatches + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *MatchPerpetualDeleveraging) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowMatches + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: MatchPerpetualDeleveraging: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MatchPerpetualDeleveraging: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Liquidated", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowMatches + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthMatches + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthMatches + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.Liquidated.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 2: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field PerpetualId", wireType) + } + m.PerpetualId = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowMatches + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.PerpetualId |= uint32(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Fills", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowMatches + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthMatches + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthMatches + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Fills = append(m.Fills, MatchPerpetualDeleveraging_Fill{}) + if err := m.Fills[len(m.Fills)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipMatches(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthMatches + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *MatchPerpetualDeleveraging_Fill) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowMatches + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: Fill: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: Fill: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Deleveraged", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowMatches + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthMatches + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthMatches + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.Deleveraged.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 2: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field FillAmount", wireType) + } + m.FillAmount = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowMatches + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.FillAmount |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + default: + iNdEx = preIndex + skippy, err := skipMatches(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthMatches + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipMatches(dAtA []byte) (n int, err error) { + l := len(dAtA) + iNdEx := 0 + depth := 0 + for iNdEx < l { + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowMatches + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + wireType := int(wire & 0x7) + switch wireType { + case 0: + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowMatches + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + iNdEx++ + if dAtA[iNdEx-1] < 0x80 { + break + } + } + case 1: + iNdEx += 8 + case 2: + var length int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowMatches + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + length |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if length < 0 { + return 0, ErrInvalidLengthMatches + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupMatches + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthMatches + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthMatches = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowMatches = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupMatches = fmt.Errorf("proto: unexpected end of group") +) diff --git a/proto/dydxcometbft/clob/matches.proto b/proto/dydxcometbft/clob/matches.proto new file mode 100644 index 00000000000..153c90770c8 --- /dev/null +++ b/proto/dydxcometbft/clob/matches.proto @@ -0,0 +1,80 @@ +syntax = "proto3"; +package dydxcometbft.clob; + +import "gogoproto/gogo.proto"; +import "dydxcometbft/subaccounts/subaccount.proto"; +import "dydxcometbft/clob/order.proto"; + +option go_package = "github.com/cometbft/cometbft/proto/dydxcometbft/clob"; + +// ClobMatch represents an operations queue entry around all different types +// of matches, specifically regular matches, liquidation matches, and +// deleveraging matches. +message ClobMatch { + // The match type that this message includes. + oneof match { + MatchOrders match_orders = 1; + MatchPerpetualLiquidation match_perpetual_liquidation = 2; + MatchPerpetualDeleveraging match_perpetual_deleveraging = 3; + } +} + +// MakerFill represents the filled amount of a matched maker order. +message MakerFill { + // The filled amount of the matched maker order, in base quantums. + uint64 fill_amount = 1; + // The `OrderId` of the matched maker order. + dydxcometbft.clob.OrderId maker_order_id = 2 [ (gogoproto.nullable) = false ]; +} + +// MatchOrders is an injected message used for matching orders. +message MatchOrders { + // The `OrderId` of the taker order. + dydxcometbft.clob.OrderId taker_order_id = 1 [ (gogoproto.nullable) = false ]; + // An ordered list of fills created by this taker order. + repeated MakerFill fills = 2 [ (gogoproto.nullable) = false ]; + // The `OrderHash` of the taker order. Used to differentiate replacement + // orders. + // TODO(CLOB-274): Determine whether this can replace the `taker_order_id` + // above, or if this is necessary to be included in the block at all. + bytes taker_order_hash = 3; +} + +// MatchPerpetualLiquidation is an injected message used for liquidating a +// subaccount. +message MatchPerpetualLiquidation { + // ID of the subaccount that was liquidated. + dydxcometbft.subaccounts.SubaccountId liquidated = 1 + [ (gogoproto.nullable) = false ]; + // The ID of the clob pair involved in the liquidation. + uint32 clob_pair_id = 2; + // The ID of the perpetual involved in the liquidation. + uint32 perpetual_id = 3; + // The total size of the liquidation order including any unfilled size. + uint64 total_size = 4; + // `true` if liquidating a short position, `false` otherwise. + bool is_buy = 5; + // An ordered list of fills created by this liquidation. + repeated MakerFill fills = 6 [ (gogoproto.nullable) = false ]; +} + +// MatchPerpetualDeleveraging is an injected message used for deleveraging a +// subaccount. +message MatchPerpetualDeleveraging { + // ID of the subaccount that was liquidated. + dydxcometbft.subaccounts.SubaccountId liquidated = 1 + [ (gogoproto.nullable) = false ]; + // The ID of the perpetual that was liquidated. + uint32 perpetual_id = 2; + // Fill represents a fill between the liquidated and deleveraged subaccount. + message Fill { + // ID of the subaccount that was deleveraged. + dydxcometbft.subaccounts.SubaccountId deleveraged = 1 + [ (gogoproto.nullable) = false ]; + // The amount filled between the liquidated and deleveraged position, in + // base quantums. + uint64 fill_amount = 2; + } + // An ordered list of fills created by this liquidation. + repeated Fill fills = 3 [ (gogoproto.nullable) = false ]; +} diff --git a/proto/dydxcometbft/clob/order.pb.go b/proto/dydxcometbft/clob/order.pb.go new file mode 100644 index 00000000000..c0ae3af2f56 --- /dev/null +++ b/proto/dydxcometbft/clob/order.pb.go @@ -0,0 +1,2115 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: dydxcometbft/clob/order.proto + +package clob + +import ( + encoding_binary "encoding/binary" + fmt "fmt" + subaccounts "github.com/cometbft/cometbft/proto/dydxcometbft/subaccounts" + _ "github.com/cosmos/gogoproto/gogoproto" + proto "github.com/cosmos/gogoproto/proto" + io "io" + math "math" + math_bits "math/bits" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package + +// Represents the side of the orderbook the order will be placed on. +// Note that Side.SIDE_UNSPECIFIED is an invalid order and cannot be +// placed on the orderbook. +type Order_Side int32 + +const ( + // Default value. This value is invalid and unused. + Order_SIDE_UNSPECIFIED Order_Side = 0 + // SIDE_BUY is used to represent a BUY order. + Order_SIDE_BUY Order_Side = 1 + // SIDE_SELL is used to represent a SELL order. + Order_SIDE_SELL Order_Side = 2 +) + +var Order_Side_name = map[int32]string{ + 0: "SIDE_UNSPECIFIED", + 1: "SIDE_BUY", + 2: "SIDE_SELL", +} + +var Order_Side_value = map[string]int32{ + "SIDE_UNSPECIFIED": 0, + "SIDE_BUY": 1, + "SIDE_SELL": 2, +} + +func (x Order_Side) String() string { + return proto.EnumName(Order_Side_name, int32(x)) +} + +func (Order_Side) EnumDescriptor() ([]byte, []int) { + return fileDescriptor_412b688ef1f07093, []int{6, 0} +} + +// TimeInForce indicates how long an order will remain active before it +// is executed or expires. +type Order_TimeInForce int32 + +const ( + // TIME_IN_FORCE_UNSPECIFIED represents the default behavior where an + // order will first match with existing orders on the book, and any + // remaining size will be added to the book as a maker order. + Order_TIME_IN_FORCE_UNSPECIFIED Order_TimeInForce = 0 + // TIME_IN_FORCE_IOC enforces that an order only be matched with + // maker orders on the book. If the order has remaining size after + // matching with existing orders on the book, the remaining size + // is not placed on the book. + Order_TIME_IN_FORCE_IOC Order_TimeInForce = 1 + // TIME_IN_FORCE_POST_ONLY enforces that an order only be placed + // on the book as a maker order. Note this means that validators will cancel + // any newly-placed post only orders that would cross with other maker + // orders. + Order_TIME_IN_FORCE_POST_ONLY Order_TimeInForce = 2 + // TIME_IN_FORCE_FILL_OR_KILL enforces that an order will either be filled + // completely and immediately by maker orders on the book or canceled if the + // entire amount can‘t be matched. + Order_TIME_IN_FORCE_FILL_OR_KILL Order_TimeInForce = 3 +) + +var Order_TimeInForce_name = map[int32]string{ + 0: "TIME_IN_FORCE_UNSPECIFIED", + 1: "TIME_IN_FORCE_IOC", + 2: "TIME_IN_FORCE_POST_ONLY", + 3: "TIME_IN_FORCE_FILL_OR_KILL", +} + +var Order_TimeInForce_value = map[string]int32{ + "TIME_IN_FORCE_UNSPECIFIED": 0, + "TIME_IN_FORCE_IOC": 1, + "TIME_IN_FORCE_POST_ONLY": 2, + "TIME_IN_FORCE_FILL_OR_KILL": 3, +} + +func (x Order_TimeInForce) String() string { + return proto.EnumName(Order_TimeInForce_name, int32(x)) +} + +func (Order_TimeInForce) EnumDescriptor() ([]byte, []int) { + return fileDescriptor_412b688ef1f07093, []int{6, 1} +} + +// OrderId refers to a single order belonging to a Subaccount. +type OrderId struct { + // The subaccount ID that opened this order. + // Note that this field has `gogoproto.nullable = false` so that it is + // generated as a value instead of a pointer. This is because the `OrderId` + // proto is used as a key within maps, and map comparisons will compare + // pointers for equality (when the desired behavior is to compare the values). + SubaccountId subaccounts.SubaccountId `protobuf:"bytes,1,opt,name=subaccount_id,json=subaccountId,proto3" json:"subaccount_id"` + // The client ID of this order, unique with respect to the specific + // sub account (I.E., the same subaccount can't have two orders with + // the same ClientId). + ClientId uint32 `protobuf:"fixed32,2,opt,name=client_id,json=clientId,proto3" json:"client_id,omitempty"` + // order_flags represent order flags for the order. This field is invalid if + // it's greater than 127 (larger than one byte). Each bit in the first byte + // represents a different flag. Currently only two flags are supported. + // + // Starting from the bit after the most MSB (note that the MSB is used in + // proto varint encoding, and therefore cannot be used): Bit 1 is set if this + // order is a Long-Term order (0x40, or 64 as a uint8). Bit 2 is set if this + // order is a Conditional order (0x20, or 32 as a uint8). + // + // If neither bit is set, the order is assumed to be a Short-Term order. + // + // If both bits are set or bits other than the 2nd and 3rd are set, the order + // ID is invalid. + OrderFlags uint32 `protobuf:"varint,3,opt,name=order_flags,json=orderFlags,proto3" json:"order_flags,omitempty"` + // ID of the CLOB the order is created for. + ClobPairId uint32 `protobuf:"varint,4,opt,name=clob_pair_id,json=clobPairId,proto3" json:"clob_pair_id,omitempty"` +} + +func (m *OrderId) Reset() { *m = OrderId{} } +func (m *OrderId) String() string { return proto.CompactTextString(m) } +func (*OrderId) ProtoMessage() {} +func (*OrderId) Descriptor() ([]byte, []int) { + return fileDescriptor_412b688ef1f07093, []int{0} +} +func (m *OrderId) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *OrderId) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_OrderId.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *OrderId) XXX_Merge(src proto.Message) { + xxx_messageInfo_OrderId.Merge(m, src) +} +func (m *OrderId) XXX_Size() int { + return m.Size() +} +func (m *OrderId) XXX_DiscardUnknown() { + xxx_messageInfo_OrderId.DiscardUnknown(m) +} + +var xxx_messageInfo_OrderId proto.InternalMessageInfo + +func (m *OrderId) GetSubaccountId() subaccounts.SubaccountId { + if m != nil { + return m.SubaccountId + } + return subaccounts.SubaccountId{} +} + +func (m *OrderId) GetClientId() uint32 { + if m != nil { + return m.ClientId + } + return 0 +} + +func (m *OrderId) GetOrderFlags() uint32 { + if m != nil { + return m.OrderFlags + } + return 0 +} + +func (m *OrderId) GetClobPairId() uint32 { + if m != nil { + return m.ClobPairId + } + return 0 +} + +// OrdersFilledDuringLatestBlock represents a list of `OrderIds` that were +// filled by any non-zero amount in the latest block. +type OrdersFilledDuringLatestBlock struct { + // A list of unique order_ids that were filled by any non-zero amount in the + // latest block. + OrderIds []OrderId `protobuf:"bytes,1,rep,name=order_ids,json=orderIds,proto3" json:"order_ids"` +} + +func (m *OrdersFilledDuringLatestBlock) Reset() { *m = OrdersFilledDuringLatestBlock{} } +func (m *OrdersFilledDuringLatestBlock) String() string { return proto.CompactTextString(m) } +func (*OrdersFilledDuringLatestBlock) ProtoMessage() {} +func (*OrdersFilledDuringLatestBlock) Descriptor() ([]byte, []int) { + return fileDescriptor_412b688ef1f07093, []int{1} +} +func (m *OrdersFilledDuringLatestBlock) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *OrdersFilledDuringLatestBlock) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_OrdersFilledDuringLatestBlock.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *OrdersFilledDuringLatestBlock) XXX_Merge(src proto.Message) { + xxx_messageInfo_OrdersFilledDuringLatestBlock.Merge(m, src) +} +func (m *OrdersFilledDuringLatestBlock) XXX_Size() int { + return m.Size() +} +func (m *OrdersFilledDuringLatestBlock) XXX_DiscardUnknown() { + xxx_messageInfo_OrdersFilledDuringLatestBlock.DiscardUnknown(m) +} + +var xxx_messageInfo_OrdersFilledDuringLatestBlock proto.InternalMessageInfo + +func (m *OrdersFilledDuringLatestBlock) GetOrderIds() []OrderId { + if m != nil { + return m.OrderIds + } + return nil +} + +// PotentiallyPrunableOrders represents a list of orders that may be prunable +// from state at a future block height. +type PotentiallyPrunableOrders struct { + // A list of unique order_ids that may potentially be pruned from state at a + // future block height. + OrderIds []OrderId `protobuf:"bytes,1,rep,name=order_ids,json=orderIds,proto3" json:"order_ids"` +} + +func (m *PotentiallyPrunableOrders) Reset() { *m = PotentiallyPrunableOrders{} } +func (m *PotentiallyPrunableOrders) String() string { return proto.CompactTextString(m) } +func (*PotentiallyPrunableOrders) ProtoMessage() {} +func (*PotentiallyPrunableOrders) Descriptor() ([]byte, []int) { + return fileDescriptor_412b688ef1f07093, []int{2} +} +func (m *PotentiallyPrunableOrders) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *PotentiallyPrunableOrders) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_PotentiallyPrunableOrders.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *PotentiallyPrunableOrders) XXX_Merge(src proto.Message) { + xxx_messageInfo_PotentiallyPrunableOrders.Merge(m, src) +} +func (m *PotentiallyPrunableOrders) XXX_Size() int { + return m.Size() +} +func (m *PotentiallyPrunableOrders) XXX_DiscardUnknown() { + xxx_messageInfo_PotentiallyPrunableOrders.DiscardUnknown(m) +} + +var xxx_messageInfo_PotentiallyPrunableOrders proto.InternalMessageInfo + +func (m *PotentiallyPrunableOrders) GetOrderIds() []OrderId { + if m != nil { + return m.OrderIds + } + return nil +} + +// OrderFillState represents the fill amount of an order according to on-chain +// state. This proto includes both the current on-chain fill amount of the +// order, as well as the block at which this information can be pruned from +// state. +type OrderFillState struct { + // The current fillAmount of the order according to on-chain state. + FillAmount uint64 `protobuf:"varint,1,opt,name=fill_amount,json=fillAmount,proto3" json:"fill_amount,omitempty"` + // The block height at which the fillAmount state for this order can be + // pruned. + PrunableBlockHeight uint32 `protobuf:"varint,2,opt,name=prunable_block_height,json=prunableBlockHeight,proto3" json:"prunable_block_height,omitempty"` +} + +func (m *OrderFillState) Reset() { *m = OrderFillState{} } +func (m *OrderFillState) String() string { return proto.CompactTextString(m) } +func (*OrderFillState) ProtoMessage() {} +func (*OrderFillState) Descriptor() ([]byte, []int) { + return fileDescriptor_412b688ef1f07093, []int{3} +} +func (m *OrderFillState) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *OrderFillState) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_OrderFillState.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *OrderFillState) XXX_Merge(src proto.Message) { + xxx_messageInfo_OrderFillState.Merge(m, src) +} +func (m *OrderFillState) XXX_Size() int { + return m.Size() +} +func (m *OrderFillState) XXX_DiscardUnknown() { + xxx_messageInfo_OrderFillState.DiscardUnknown(m) +} + +var xxx_messageInfo_OrderFillState proto.InternalMessageInfo + +func (m *OrderFillState) GetFillAmount() uint64 { + if m != nil { + return m.FillAmount + } + return 0 +} + +func (m *OrderFillState) GetPrunableBlockHeight() uint32 { + if m != nil { + return m.PrunableBlockHeight + } + return 0 +} + +// StatefulOrderTimeSliceValue represents the type of the value of the +// `StatefulOrdersTimeSlice` in state. The `StatefulOrdersTimeSlice` +// in state consists of key/value pairs where the keys are UTF-8-encoded +// `RFC3339NANO` timestamp strings with right-padded zeroes and no +// time zone info, and the values are of type `StatefulOrderTimeSliceValue`. +// This `StatefulOrdersTimeSlice` in state is used for managing stateful +// order expiration. +type StatefulOrderTimeSliceValue struct { + // A unique list of order_ids that expire at this timestamp, sorted in + // ascending order by block height and transaction index of each stateful + // order. + OrderIds []OrderId `protobuf:"bytes,1,rep,name=order_ids,json=orderIds,proto3" json:"order_ids"` +} + +func (m *StatefulOrderTimeSliceValue) Reset() { *m = StatefulOrderTimeSliceValue{} } +func (m *StatefulOrderTimeSliceValue) String() string { return proto.CompactTextString(m) } +func (*StatefulOrderTimeSliceValue) ProtoMessage() {} +func (*StatefulOrderTimeSliceValue) Descriptor() ([]byte, []int) { + return fileDescriptor_412b688ef1f07093, []int{4} +} +func (m *StatefulOrderTimeSliceValue) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *StatefulOrderTimeSliceValue) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_StatefulOrderTimeSliceValue.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *StatefulOrderTimeSliceValue) XXX_Merge(src proto.Message) { + xxx_messageInfo_StatefulOrderTimeSliceValue.Merge(m, src) +} +func (m *StatefulOrderTimeSliceValue) XXX_Size() int { + return m.Size() +} +func (m *StatefulOrderTimeSliceValue) XXX_DiscardUnknown() { + xxx_messageInfo_StatefulOrderTimeSliceValue.DiscardUnknown(m) +} + +var xxx_messageInfo_StatefulOrderTimeSliceValue proto.InternalMessageInfo + +func (m *StatefulOrderTimeSliceValue) GetOrderIds() []OrderId { + if m != nil { + return m.OrderIds + } + return nil +} + +// StatefulOrderPlacement represents the placement of a stateful order in +// state. It stores the stateful order itself and the `BlockHeight` and +// `TransactionIndex` at which the order was placed. +type StatefulOrderPlacement struct { + Order Order `protobuf:"bytes,1,opt,name=order,proto3" json:"order"` + // The block height at which the order was placed. + // Used for ordering by time priority when the chain is restarted. + BlockHeight uint32 `protobuf:"varint,2,opt,name=block_height,json=blockHeight,proto3" json:"block_height,omitempty"` + // The index at which this transaction appeared in the + // `MsgProposedMatchOrders` message. Used for ordering by time priority when + // the chain is restarted. + TransactionIndex uint32 `protobuf:"varint,3,opt,name=transaction_index,json=transactionIndex,proto3" json:"transaction_index,omitempty"` +} + +func (m *StatefulOrderPlacement) Reset() { *m = StatefulOrderPlacement{} } +func (m *StatefulOrderPlacement) String() string { return proto.CompactTextString(m) } +func (*StatefulOrderPlacement) ProtoMessage() {} +func (*StatefulOrderPlacement) Descriptor() ([]byte, []int) { + return fileDescriptor_412b688ef1f07093, []int{5} +} +func (m *StatefulOrderPlacement) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *StatefulOrderPlacement) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_StatefulOrderPlacement.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *StatefulOrderPlacement) XXX_Merge(src proto.Message) { + xxx_messageInfo_StatefulOrderPlacement.Merge(m, src) +} +func (m *StatefulOrderPlacement) XXX_Size() int { + return m.Size() +} +func (m *StatefulOrderPlacement) XXX_DiscardUnknown() { + xxx_messageInfo_StatefulOrderPlacement.DiscardUnknown(m) +} + +var xxx_messageInfo_StatefulOrderPlacement proto.InternalMessageInfo + +func (m *StatefulOrderPlacement) GetOrder() Order { + if m != nil { + return m.Order + } + return Order{} +} + +func (m *StatefulOrderPlacement) GetBlockHeight() uint32 { + if m != nil { + return m.BlockHeight + } + return 0 +} + +func (m *StatefulOrderPlacement) GetTransactionIndex() uint32 { + if m != nil { + return m.TransactionIndex + } + return 0 +} + +// Order represents a single order belonging to a `Subaccount` +// for a particular `ClobPair`. +type Order struct { + // The unique ID of this order. Meant to be unique across all orders. + OrderId OrderId `protobuf:"bytes,1,opt,name=order_id,json=orderId,proto3" json:"order_id"` + Side Order_Side `protobuf:"varint,2,opt,name=side,proto3,enum=dydxcometbft.clob.Order_Side" json:"side,omitempty"` + // The size of this order in base quantums. Must be a multiple of + // `ClobPair.StepBaseQuantums` and above `ClobPair.MinOrderBaseQuantums` + // (where `ClobPair.Id = orderId.ClobPairId`). + Quantums uint64 `protobuf:"varint,3,opt,name=quantums,proto3" json:"quantums,omitempty"` + // The price level that this order will be placed at on the orderbook, + // in subticks. Must be a multiple of ClobPair.SubticksPerTick + // (where `ClobPair.Id = orderId.ClobPairId`). + Subticks uint64 `protobuf:"varint,4,opt,name=subticks,proto3" json:"subticks,omitempty"` + // Information about when the order expires. + // + // Types that are valid to be assigned to GoodTilOneof: + // + // *Order_GoodTilBlock + // *Order_GoodTilBlockTime + GoodTilOneof isOrder_GoodTilOneof `protobuf_oneof:"good_til_oneof"` + // The time in force of this order. + TimeInForce Order_TimeInForce `protobuf:"varint,7,opt,name=time_in_force,json=timeInForce,proto3,enum=dydxcometbft.clob.Order_TimeInForce" json:"time_in_force,omitempty"` + // Enforces that the order can only reduce the size of an existing position. + // If a ReduceOnly order would change the side of the existing position, + // its size is reduced to that of the remaining size of the position. + // If existing orders on the book with ReduceOnly + // would already close the position, the least aggressive (out-of-the-money) + // ReduceOnly orders are resized and canceled first. + ReduceOnly bool `protobuf:"varint,8,opt,name=reduce_only,json=reduceOnly,proto3" json:"reduce_only,omitempty"` + // Set of bit flags set arbitrarily by clients and ignored by the protocol. + // Used by indexer to infer information about a placed order. + ClientMetadata uint32 `protobuf:"varint,9,opt,name=client_metadata,json=clientMetadata,proto3" json:"client_metadata,omitempty"` +} + +func (m *Order) Reset() { *m = Order{} } +func (m *Order) String() string { return proto.CompactTextString(m) } +func (*Order) ProtoMessage() {} +func (*Order) Descriptor() ([]byte, []int) { + return fileDescriptor_412b688ef1f07093, []int{6} +} +func (m *Order) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *Order) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_Order.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *Order) XXX_Merge(src proto.Message) { + xxx_messageInfo_Order.Merge(m, src) +} +func (m *Order) XXX_Size() int { + return m.Size() +} +func (m *Order) XXX_DiscardUnknown() { + xxx_messageInfo_Order.DiscardUnknown(m) +} + +var xxx_messageInfo_Order proto.InternalMessageInfo + +type isOrder_GoodTilOneof interface { + isOrder_GoodTilOneof() + MarshalTo([]byte) (int, error) + Size() int +} + +type Order_GoodTilBlock struct { + GoodTilBlock uint32 `protobuf:"varint,5,opt,name=good_til_block,json=goodTilBlock,proto3,oneof" json:"good_til_block,omitempty"` +} +type Order_GoodTilBlockTime struct { + GoodTilBlockTime uint32 `protobuf:"fixed32,6,opt,name=good_til_block_time,json=goodTilBlockTime,proto3,oneof" json:"good_til_block_time,omitempty"` +} + +func (*Order_GoodTilBlock) isOrder_GoodTilOneof() {} +func (*Order_GoodTilBlockTime) isOrder_GoodTilOneof() {} + +func (m *Order) GetGoodTilOneof() isOrder_GoodTilOneof { + if m != nil { + return m.GoodTilOneof + } + return nil +} + +func (m *Order) GetOrderId() OrderId { + if m != nil { + return m.OrderId + } + return OrderId{} +} + +func (m *Order) GetSide() Order_Side { + if m != nil { + return m.Side + } + return Order_SIDE_UNSPECIFIED +} + +func (m *Order) GetQuantums() uint64 { + if m != nil { + return m.Quantums + } + return 0 +} + +func (m *Order) GetSubticks() uint64 { + if m != nil { + return m.Subticks + } + return 0 +} + +func (m *Order) GetGoodTilBlock() uint32 { + if x, ok := m.GetGoodTilOneof().(*Order_GoodTilBlock); ok { + return x.GoodTilBlock + } + return 0 +} + +func (m *Order) GetGoodTilBlockTime() uint32 { + if x, ok := m.GetGoodTilOneof().(*Order_GoodTilBlockTime); ok { + return x.GoodTilBlockTime + } + return 0 +} + +func (m *Order) GetTimeInForce() Order_TimeInForce { + if m != nil { + return m.TimeInForce + } + return Order_TIME_IN_FORCE_UNSPECIFIED +} + +func (m *Order) GetReduceOnly() bool { + if m != nil { + return m.ReduceOnly + } + return false +} + +func (m *Order) GetClientMetadata() uint32 { + if m != nil { + return m.ClientMetadata + } + return 0 +} + +// XXX_OneofWrappers is for the internal use of the proto package. +func (*Order) XXX_OneofWrappers() []interface{} { + return []interface{}{ + (*Order_GoodTilBlock)(nil), + (*Order_GoodTilBlockTime)(nil), + } +} + +func init() { + proto.RegisterEnum("dydxcometbft.clob.Order_Side", Order_Side_name, Order_Side_value) + proto.RegisterEnum("dydxcometbft.clob.Order_TimeInForce", Order_TimeInForce_name, Order_TimeInForce_value) + proto.RegisterType((*OrderId)(nil), "dydxcometbft.clob.OrderId") + proto.RegisterType((*OrdersFilledDuringLatestBlock)(nil), "dydxcometbft.clob.OrdersFilledDuringLatestBlock") + proto.RegisterType((*PotentiallyPrunableOrders)(nil), "dydxcometbft.clob.PotentiallyPrunableOrders") + proto.RegisterType((*OrderFillState)(nil), "dydxcometbft.clob.OrderFillState") + proto.RegisterType((*StatefulOrderTimeSliceValue)(nil), "dydxcometbft.clob.StatefulOrderTimeSliceValue") + proto.RegisterType((*StatefulOrderPlacement)(nil), "dydxcometbft.clob.StatefulOrderPlacement") + proto.RegisterType((*Order)(nil), "dydxcometbft.clob.Order") +} + +func init() { proto.RegisterFile("dydxcometbft/clob/order.proto", fileDescriptor_412b688ef1f07093) } + +var fileDescriptor_412b688ef1f07093 = []byte{ + // 801 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xa4, 0x54, 0xc1, 0x6e, 0xdb, 0x46, + 0x10, 0x15, 0x6d, 0x39, 0x96, 0x47, 0x92, 0x4b, 0x6f, 0x92, 0x96, 0x91, 0x61, 0x45, 0x15, 0x8a, + 0x54, 0x45, 0x01, 0x09, 0x75, 0x73, 0x29, 0x8a, 0x1e, 0x2a, 0x5b, 0x82, 0x89, 0x32, 0x96, 0x4a, + 0x3a, 0x05, 0x12, 0x14, 0x5d, 0x2c, 0xb9, 0x2b, 0x79, 0x91, 0x25, 0xd7, 0x25, 0x97, 0x40, 0x7c, + 0xeb, 0x27, 0xf4, 0x0b, 0xfa, 0x25, 0xfd, 0x80, 0x1c, 0x73, 0xec, 0xa9, 0x28, 0xec, 0x6b, 0x3f, + 0xa2, 0xd8, 0x25, 0x6d, 0x51, 0x4d, 0x8d, 0x1e, 0x72, 0xdb, 0x79, 0x6f, 0xf8, 0x66, 0xde, 0xec, + 0x70, 0xe1, 0x80, 0x5e, 0xd2, 0xd7, 0x91, 0x8c, 0x99, 0x0a, 0x17, 0x6a, 0x14, 0x09, 0x19, 0x8e, + 0x64, 0x4a, 0x59, 0x3a, 0xbc, 0x48, 0xa5, 0x92, 0x68, 0xaf, 0x4a, 0x0f, 0x35, 0xdd, 0x79, 0xb0, + 0x94, 0x4b, 0x69, 0xd8, 0x91, 0x3e, 0x15, 0x89, 0x9d, 0xcf, 0xd6, 0x74, 0xb2, 0x3c, 0x24, 0x51, + 0x24, 0xf3, 0x44, 0x65, 0x95, 0x73, 0x91, 0xda, 0xff, 0xdd, 0x82, 0xed, 0x99, 0xae, 0xe1, 0x52, + 0xf4, 0x3d, 0xb4, 0x57, 0x3c, 0xe6, 0xd4, 0xb1, 0x7a, 0xd6, 0xa0, 0x79, 0xf8, 0x64, 0xb8, 0x56, + 0xb7, 0x22, 0x37, 0x0c, 0x6e, 0xcf, 0x2e, 0x1d, 0xd7, 0xdf, 0xfc, 0xf9, 0xb8, 0xe6, 0xb7, 0xb2, + 0x0a, 0x86, 0xf6, 0x61, 0x27, 0x12, 0x9c, 0x15, 0x72, 0x1b, 0x3d, 0x6b, 0xb0, 0xed, 0x37, 0x0a, + 0xc0, 0xa5, 0xe8, 0x31, 0x34, 0x8d, 0x3d, 0xbc, 0x10, 0x64, 0x99, 0x39, 0x9b, 0x3d, 0x6b, 0xd0, + 0xf6, 0xc1, 0x40, 0x53, 0x8d, 0xa0, 0x1e, 0xb4, 0xb4, 0x4b, 0x7c, 0x41, 0x78, 0xaa, 0x05, 0xea, + 0x45, 0x86, 0xc6, 0xe6, 0x84, 0xa7, 0x2e, 0xed, 0xff, 0x04, 0x07, 0xa6, 0xfb, 0x6c, 0xca, 0x85, + 0x60, 0xf4, 0x38, 0x4f, 0x79, 0xb2, 0xf4, 0x88, 0x62, 0x99, 0x1a, 0x0b, 0x19, 0xbd, 0x42, 0xdf, + 0xc0, 0x4e, 0x51, 0x83, 0xd3, 0xcc, 0xb1, 0x7a, 0x9b, 0x83, 0xe6, 0x61, 0x67, 0xf8, 0xce, 0x1c, + 0x87, 0xe5, 0x08, 0x4a, 0x0f, 0x0d, 0x59, 0x84, 0x59, 0xff, 0x25, 0x3c, 0x9a, 0x4b, 0xc5, 0x12, + 0xc5, 0x89, 0x10, 0x97, 0xf3, 0x34, 0x4f, 0x48, 0x28, 0x58, 0x51, 0xf2, 0x7d, 0xb5, 0x19, 0xec, + 0x1a, 0x4a, 0xb7, 0x1e, 0x28, 0xa2, 0x98, 0x1e, 0xc8, 0x82, 0x0b, 0x81, 0x49, 0xac, 0xc7, 0x67, + 0xc6, 0x5f, 0xf7, 0x41, 0x43, 0xdf, 0x1a, 0x04, 0x1d, 0xc2, 0xc3, 0x8b, 0xb2, 0x07, 0x1c, 0x6a, + 0x7f, 0xf8, 0x9c, 0xf1, 0xe5, 0xb9, 0x32, 0xa3, 0x6d, 0xfb, 0xf7, 0x6f, 0x48, 0xe3, 0xfd, 0xc4, + 0x50, 0xfd, 0x1f, 0x61, 0xdf, 0xa8, 0x2f, 0x72, 0x61, 0xca, 0x9d, 0xf1, 0x98, 0x05, 0x82, 0x47, + 0xec, 0x07, 0x22, 0x72, 0xf6, 0xbe, 0x26, 0x7e, 0xb3, 0xe0, 0xc3, 0x35, 0xf9, 0xb9, 0x20, 0x11, + 0x8b, 0x59, 0xa2, 0xd0, 0x53, 0xd8, 0x32, 0x69, 0xe5, 0x1a, 0x39, 0x77, 0xa9, 0x96, 0x9a, 0x45, + 0x32, 0xfa, 0x18, 0x5a, 0xff, 0xe1, 0xac, 0x19, 0xae, 0x1c, 0xa1, 0xcf, 0x61, 0x4f, 0xa5, 0x24, + 0xc9, 0x48, 0xa4, 0xb8, 0x4c, 0x30, 0x4f, 0x28, 0x7b, 0x5d, 0x6e, 0x8f, 0x5d, 0x21, 0x5c, 0x8d, + 0xf7, 0xff, 0xae, 0xc3, 0x96, 0x29, 0x83, 0xbe, 0x86, 0xc6, 0x8d, 0xd3, 0xb2, 0xa5, 0xff, 0x37, + 0xba, 0x5d, 0x1a, 0x45, 0x5f, 0x40, 0x3d, 0xe3, 0x94, 0x99, 0x76, 0x76, 0x0f, 0x0f, 0xee, 0xfa, + 0x70, 0x18, 0x70, 0xca, 0x7c, 0x93, 0x8a, 0x3a, 0xd0, 0xf8, 0x39, 0x27, 0x89, 0xca, 0xe3, 0x62, + 0xb7, 0xeb, 0xfe, 0x6d, 0xac, 0xb9, 0x2c, 0x0f, 0x15, 0x8f, 0x5e, 0x65, 0x66, 0xab, 0xeb, 0xfe, + 0x6d, 0x8c, 0x9e, 0xc0, 0xee, 0x52, 0x4a, 0x8a, 0x15, 0x17, 0xc5, 0x25, 0x3b, 0x5b, 0xda, 0xdb, + 0x49, 0xcd, 0x6f, 0x69, 0xfc, 0x8c, 0x8b, 0x62, 0xb5, 0x47, 0x70, 0x7f, 0x3d, 0x0f, 0x2b, 0x1e, + 0x33, 0xe7, 0x9e, 0xfe, 0xcb, 0x4e, 0x6a, 0xbe, 0x5d, 0x4d, 0xd6, 0x97, 0x8e, 0x4e, 0xa0, 0xad, + 0x33, 0x30, 0x4f, 0xf0, 0x42, 0xa6, 0x11, 0x73, 0xb6, 0x8d, 0x99, 0x4f, 0xee, 0x34, 0xa3, 0xbf, + 0x72, 0x93, 0xa9, 0xce, 0xf5, 0x9b, 0x6a, 0x15, 0xe8, 0x45, 0x4d, 0x19, 0xcd, 0x23, 0x86, 0x65, + 0x22, 0x2e, 0x9d, 0x46, 0xcf, 0x1a, 0x34, 0x7c, 0x28, 0xa0, 0x59, 0x22, 0x2e, 0xd1, 0xa7, 0xf0, + 0x41, 0xf9, 0xdf, 0xc7, 0x4c, 0x11, 0x4a, 0x14, 0x71, 0x76, 0xcc, 0x05, 0xed, 0x16, 0xf0, 0xb3, + 0x12, 0xed, 0x7f, 0x05, 0x75, 0x3d, 0x32, 0xf4, 0x00, 0xec, 0xc0, 0x3d, 0x9e, 0xe0, 0xe7, 0xa7, + 0xc1, 0x7c, 0x72, 0xe4, 0x4e, 0xdd, 0xc9, 0xb1, 0x5d, 0x43, 0x2d, 0x68, 0x18, 0x74, 0xfc, 0xfc, + 0x85, 0x6d, 0xa1, 0x36, 0xec, 0x98, 0x28, 0x98, 0x78, 0x9e, 0xbd, 0xd1, 0xff, 0xc5, 0x82, 0x66, + 0xa5, 0x43, 0x74, 0x00, 0x8f, 0xce, 0xdc, 0x67, 0x13, 0xec, 0x9e, 0xe2, 0xe9, 0xcc, 0x3f, 0xfa, + 0xb7, 0xd6, 0x43, 0xd8, 0x5b, 0xa7, 0xdd, 0xd9, 0x91, 0x6d, 0xa1, 0x7d, 0xf8, 0x68, 0x1d, 0x9e, + 0xcf, 0x82, 0x33, 0x3c, 0x3b, 0xf5, 0x5e, 0xd8, 0x1b, 0xa8, 0x0b, 0x9d, 0x75, 0x72, 0xea, 0x7a, + 0x1e, 0x9e, 0xf9, 0xf8, 0x3b, 0xd7, 0xf3, 0xec, 0xcd, 0xb1, 0x5d, 0xb9, 0x2a, 0x99, 0x30, 0xb9, + 0x18, 0x9f, 0xbe, 0xb9, 0xea, 0x5a, 0x6f, 0xaf, 0xba, 0xd6, 0x5f, 0x57, 0x5d, 0xeb, 0xd7, 0xeb, + 0x6e, 0xed, 0xed, 0x75, 0xb7, 0xf6, 0xc7, 0x75, 0xb7, 0xf6, 0xf2, 0xe9, 0x92, 0xab, 0xf3, 0x3c, + 0x1c, 0x46, 0x32, 0x1e, 0xad, 0xde, 0xf8, 0x9b, 0x43, 0xf1, 0x86, 0xbf, 0xf3, 0xfe, 0x87, 0xf7, + 0x0c, 0xf1, 0xe5, 0x3f, 0x01, 0x00, 0x00, 0xff, 0xff, 0x87, 0x20, 0x52, 0x52, 0x1b, 0x06, 0x00, + 0x00, +} + +func (m *OrderId) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *OrderId) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *OrderId) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.ClobPairId != 0 { + i = encodeVarintOrder(dAtA, i, uint64(m.ClobPairId)) + i-- + dAtA[i] = 0x20 + } + if m.OrderFlags != 0 { + i = encodeVarintOrder(dAtA, i, uint64(m.OrderFlags)) + i-- + dAtA[i] = 0x18 + } + if m.ClientId != 0 { + i -= 4 + encoding_binary.LittleEndian.PutUint32(dAtA[i:], uint32(m.ClientId)) + i-- + dAtA[i] = 0x15 + } + { + size, err := m.SubaccountId.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintOrder(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + return len(dAtA) - i, nil +} + +func (m *OrdersFilledDuringLatestBlock) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *OrdersFilledDuringLatestBlock) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *OrdersFilledDuringLatestBlock) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.OrderIds) > 0 { + for iNdEx := len(m.OrderIds) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.OrderIds[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintOrder(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + } + } + return len(dAtA) - i, nil +} + +func (m *PotentiallyPrunableOrders) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *PotentiallyPrunableOrders) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *PotentiallyPrunableOrders) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.OrderIds) > 0 { + for iNdEx := len(m.OrderIds) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.OrderIds[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintOrder(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + } + } + return len(dAtA) - i, nil +} + +func (m *OrderFillState) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *OrderFillState) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *OrderFillState) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.PrunableBlockHeight != 0 { + i = encodeVarintOrder(dAtA, i, uint64(m.PrunableBlockHeight)) + i-- + dAtA[i] = 0x10 + } + if m.FillAmount != 0 { + i = encodeVarintOrder(dAtA, i, uint64(m.FillAmount)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + +func (m *StatefulOrderTimeSliceValue) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *StatefulOrderTimeSliceValue) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *StatefulOrderTimeSliceValue) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.OrderIds) > 0 { + for iNdEx := len(m.OrderIds) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.OrderIds[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintOrder(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + } + } + return len(dAtA) - i, nil +} + +func (m *StatefulOrderPlacement) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *StatefulOrderPlacement) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *StatefulOrderPlacement) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.TransactionIndex != 0 { + i = encodeVarintOrder(dAtA, i, uint64(m.TransactionIndex)) + i-- + dAtA[i] = 0x18 + } + if m.BlockHeight != 0 { + i = encodeVarintOrder(dAtA, i, uint64(m.BlockHeight)) + i-- + dAtA[i] = 0x10 + } + { + size, err := m.Order.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintOrder(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + return len(dAtA) - i, nil +} + +func (m *Order) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *Order) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *Order) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.ClientMetadata != 0 { + i = encodeVarintOrder(dAtA, i, uint64(m.ClientMetadata)) + i-- + dAtA[i] = 0x48 + } + if m.ReduceOnly { + i-- + if m.ReduceOnly { + dAtA[i] = 1 + } else { + dAtA[i] = 0 + } + i-- + dAtA[i] = 0x40 + } + if m.TimeInForce != 0 { + i = encodeVarintOrder(dAtA, i, uint64(m.TimeInForce)) + i-- + dAtA[i] = 0x38 + } + if m.GoodTilOneof != nil { + { + size := m.GoodTilOneof.Size() + i -= size + if _, err := m.GoodTilOneof.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + } + } + if m.Subticks != 0 { + i = encodeVarintOrder(dAtA, i, uint64(m.Subticks)) + i-- + dAtA[i] = 0x20 + } + if m.Quantums != 0 { + i = encodeVarintOrder(dAtA, i, uint64(m.Quantums)) + i-- + dAtA[i] = 0x18 + } + if m.Side != 0 { + i = encodeVarintOrder(dAtA, i, uint64(m.Side)) + i-- + dAtA[i] = 0x10 + } + { + size, err := m.OrderId.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintOrder(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + return len(dAtA) - i, nil +} + +func (m *Order_GoodTilBlock) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *Order_GoodTilBlock) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + i = encodeVarintOrder(dAtA, i, uint64(m.GoodTilBlock)) + i-- + dAtA[i] = 0x28 + return len(dAtA) - i, nil +} +func (m *Order_GoodTilBlockTime) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *Order_GoodTilBlockTime) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + i -= 4 + encoding_binary.LittleEndian.PutUint32(dAtA[i:], uint32(m.GoodTilBlockTime)) + i-- + dAtA[i] = 0x35 + return len(dAtA) - i, nil +} +func encodeVarintOrder(dAtA []byte, offset int, v uint64) int { + offset -= sovOrder(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *OrderId) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = m.SubaccountId.Size() + n += 1 + l + sovOrder(uint64(l)) + if m.ClientId != 0 { + n += 5 + } + if m.OrderFlags != 0 { + n += 1 + sovOrder(uint64(m.OrderFlags)) + } + if m.ClobPairId != 0 { + n += 1 + sovOrder(uint64(m.ClobPairId)) + } + return n +} + +func (m *OrdersFilledDuringLatestBlock) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.OrderIds) > 0 { + for _, e := range m.OrderIds { + l = e.Size() + n += 1 + l + sovOrder(uint64(l)) + } + } + return n +} + +func (m *PotentiallyPrunableOrders) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.OrderIds) > 0 { + for _, e := range m.OrderIds { + l = e.Size() + n += 1 + l + sovOrder(uint64(l)) + } + } + return n +} + +func (m *OrderFillState) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.FillAmount != 0 { + n += 1 + sovOrder(uint64(m.FillAmount)) + } + if m.PrunableBlockHeight != 0 { + n += 1 + sovOrder(uint64(m.PrunableBlockHeight)) + } + return n +} + +func (m *StatefulOrderTimeSliceValue) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.OrderIds) > 0 { + for _, e := range m.OrderIds { + l = e.Size() + n += 1 + l + sovOrder(uint64(l)) + } + } + return n +} + +func (m *StatefulOrderPlacement) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = m.Order.Size() + n += 1 + l + sovOrder(uint64(l)) + if m.BlockHeight != 0 { + n += 1 + sovOrder(uint64(m.BlockHeight)) + } + if m.TransactionIndex != 0 { + n += 1 + sovOrder(uint64(m.TransactionIndex)) + } + return n +} + +func (m *Order) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = m.OrderId.Size() + n += 1 + l + sovOrder(uint64(l)) + if m.Side != 0 { + n += 1 + sovOrder(uint64(m.Side)) + } + if m.Quantums != 0 { + n += 1 + sovOrder(uint64(m.Quantums)) + } + if m.Subticks != 0 { + n += 1 + sovOrder(uint64(m.Subticks)) + } + if m.GoodTilOneof != nil { + n += m.GoodTilOneof.Size() + } + if m.TimeInForce != 0 { + n += 1 + sovOrder(uint64(m.TimeInForce)) + } + if m.ReduceOnly { + n += 2 + } + if m.ClientMetadata != 0 { + n += 1 + sovOrder(uint64(m.ClientMetadata)) + } + return n +} + +func (m *Order_GoodTilBlock) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + n += 1 + sovOrder(uint64(m.GoodTilBlock)) + return n +} +func (m *Order_GoodTilBlockTime) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + n += 5 + return n +} + +func sovOrder(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozOrder(x uint64) (n int) { + return sovOrder(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *OrderId) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowOrder + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: OrderId: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: OrderId: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field SubaccountId", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowOrder + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthOrder + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthOrder + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.SubaccountId.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 2: + if wireType != 5 { + return fmt.Errorf("proto: wrong wireType = %d for field ClientId", wireType) + } + m.ClientId = 0 + if (iNdEx + 4) > l { + return io.ErrUnexpectedEOF + } + m.ClientId = uint32(encoding_binary.LittleEndian.Uint32(dAtA[iNdEx:])) + iNdEx += 4 + case 3: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field OrderFlags", wireType) + } + m.OrderFlags = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowOrder + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.OrderFlags |= uint32(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 4: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field ClobPairId", wireType) + } + m.ClobPairId = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowOrder + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.ClobPairId |= uint32(b&0x7F) << shift + if b < 0x80 { + break + } + } + default: + iNdEx = preIndex + skippy, err := skipOrder(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthOrder + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *OrdersFilledDuringLatestBlock) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowOrder + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: OrdersFilledDuringLatestBlock: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: OrdersFilledDuringLatestBlock: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field OrderIds", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowOrder + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthOrder + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthOrder + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.OrderIds = append(m.OrderIds, OrderId{}) + if err := m.OrderIds[len(m.OrderIds)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipOrder(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthOrder + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *PotentiallyPrunableOrders) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowOrder + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: PotentiallyPrunableOrders: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: PotentiallyPrunableOrders: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field OrderIds", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowOrder + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthOrder + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthOrder + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.OrderIds = append(m.OrderIds, OrderId{}) + if err := m.OrderIds[len(m.OrderIds)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipOrder(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthOrder + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *OrderFillState) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowOrder + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: OrderFillState: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: OrderFillState: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field FillAmount", wireType) + } + m.FillAmount = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowOrder + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.FillAmount |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 2: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field PrunableBlockHeight", wireType) + } + m.PrunableBlockHeight = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowOrder + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.PrunableBlockHeight |= uint32(b&0x7F) << shift + if b < 0x80 { + break + } + } + default: + iNdEx = preIndex + skippy, err := skipOrder(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthOrder + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *StatefulOrderTimeSliceValue) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowOrder + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: StatefulOrderTimeSliceValue: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: StatefulOrderTimeSliceValue: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field OrderIds", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowOrder + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthOrder + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthOrder + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.OrderIds = append(m.OrderIds, OrderId{}) + if err := m.OrderIds[len(m.OrderIds)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipOrder(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthOrder + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *StatefulOrderPlacement) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowOrder + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: StatefulOrderPlacement: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: StatefulOrderPlacement: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Order", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowOrder + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthOrder + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthOrder + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.Order.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 2: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field BlockHeight", wireType) + } + m.BlockHeight = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowOrder + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.BlockHeight |= uint32(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 3: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field TransactionIndex", wireType) + } + m.TransactionIndex = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowOrder + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.TransactionIndex |= uint32(b&0x7F) << shift + if b < 0x80 { + break + } + } + default: + iNdEx = preIndex + skippy, err := skipOrder(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthOrder + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *Order) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowOrder + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: Order: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: Order: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field OrderId", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowOrder + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthOrder + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthOrder + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.OrderId.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 2: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Side", wireType) + } + m.Side = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowOrder + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Side |= Order_Side(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 3: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Quantums", wireType) + } + m.Quantums = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowOrder + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Quantums |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 4: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Subticks", wireType) + } + m.Subticks = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowOrder + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Subticks |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 5: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field GoodTilBlock", wireType) + } + var v uint32 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowOrder + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= uint32(b&0x7F) << shift + if b < 0x80 { + break + } + } + m.GoodTilOneof = &Order_GoodTilBlock{v} + case 6: + if wireType != 5 { + return fmt.Errorf("proto: wrong wireType = %d for field GoodTilBlockTime", wireType) + } + var v uint32 + if (iNdEx + 4) > l { + return io.ErrUnexpectedEOF + } + v = uint32(encoding_binary.LittleEndian.Uint32(dAtA[iNdEx:])) + iNdEx += 4 + m.GoodTilOneof = &Order_GoodTilBlockTime{v} + case 7: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field TimeInForce", wireType) + } + m.TimeInForce = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowOrder + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.TimeInForce |= Order_TimeInForce(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 8: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field ReduceOnly", wireType) + } + var v int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowOrder + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + m.ReduceOnly = bool(v != 0) + case 9: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field ClientMetadata", wireType) + } + m.ClientMetadata = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowOrder + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.ClientMetadata |= uint32(b&0x7F) << shift + if b < 0x80 { + break + } + } + default: + iNdEx = preIndex + skippy, err := skipOrder(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthOrder + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipOrder(dAtA []byte) (n int, err error) { + l := len(dAtA) + iNdEx := 0 + depth := 0 + for iNdEx < l { + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowOrder + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + wireType := int(wire & 0x7) + switch wireType { + case 0: + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowOrder + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + iNdEx++ + if dAtA[iNdEx-1] < 0x80 { + break + } + } + case 1: + iNdEx += 8 + case 2: + var length int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowOrder + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + length |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if length < 0 { + return 0, ErrInvalidLengthOrder + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupOrder + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthOrder + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthOrder = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowOrder = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupOrder = fmt.Errorf("proto: unexpected end of group") +) diff --git a/proto/dydxcometbft/clob/order.proto b/proto/dydxcometbft/clob/order.proto new file mode 100644 index 00000000000..6fc7432106a --- /dev/null +++ b/proto/dydxcometbft/clob/order.proto @@ -0,0 +1,184 @@ +syntax = "proto3"; +package dydxcometbft.clob; + +import "gogoproto/gogo.proto"; +import "dydxcometbft/subaccounts/subaccount.proto"; + +option go_package = "github.com/cometbft/cometbft/proto/dydxcometbft/clob"; + +// OrderId refers to a single order belonging to a Subaccount. +message OrderId { + // The subaccount ID that opened this order. + // Note that this field has `gogoproto.nullable = false` so that it is + // generated as a value instead of a pointer. This is because the `OrderId` + // proto is used as a key within maps, and map comparisons will compare + // pointers for equality (when the desired behavior is to compare the values). + dydxcometbft.subaccounts.SubaccountId subaccount_id = 1 + [ (gogoproto.nullable) = false ]; + + // The client ID of this order, unique with respect to the specific + // sub account (I.E., the same subaccount can't have two orders with + // the same ClientId). + fixed32 client_id = 2; + + // order_flags represent order flags for the order. This field is invalid if + // it's greater than 127 (larger than one byte). Each bit in the first byte + // represents a different flag. Currently only two flags are supported. + // + // Starting from the bit after the most MSB (note that the MSB is used in + // proto varint encoding, and therefore cannot be used): Bit 1 is set if this + // order is a Long-Term order (0x40, or 64 as a uint8). Bit 2 is set if this + // order is a Conditional order (0x20, or 32 as a uint8). + // + // If neither bit is set, the order is assumed to be a Short-Term order. + // + // If both bits are set or bits other than the 2nd and 3rd are set, the order + // ID is invalid. + uint32 order_flags = 3; + + // ID of the CLOB the order is created for. + uint32 clob_pair_id = 4; +} + +// OrdersFilledDuringLatestBlock represents a list of `OrderIds` that were +// filled by any non-zero amount in the latest block. +message OrdersFilledDuringLatestBlock { + // A list of unique order_ids that were filled by any non-zero amount in the + // latest block. + repeated OrderId order_ids = 1 [ (gogoproto.nullable) = false ]; +} + +// PotentiallyPrunableOrders represents a list of orders that may be prunable +// from state at a future block height. +message PotentiallyPrunableOrders { + // A list of unique order_ids that may potentially be pruned from state at a + // future block height. + repeated OrderId order_ids = 1 [ (gogoproto.nullable) = false ]; +} + +// OrderFillState represents the fill amount of an order according to on-chain +// state. This proto includes both the current on-chain fill amount of the +// order, as well as the block at which this information can be pruned from +// state. +message OrderFillState { + // The current fillAmount of the order according to on-chain state. + uint64 fill_amount = 1; + // The block height at which the fillAmount state for this order can be + // pruned. + uint32 prunable_block_height = 2; +} + +// StatefulOrderTimeSliceValue represents the type of the value of the +// `StatefulOrdersTimeSlice` in state. The `StatefulOrdersTimeSlice` +// in state consists of key/value pairs where the keys are UTF-8-encoded +// `RFC3339NANO` timestamp strings with right-padded zeroes and no +// time zone info, and the values are of type `StatefulOrderTimeSliceValue`. +// This `StatefulOrdersTimeSlice` in state is used for managing stateful +// order expiration. +message StatefulOrderTimeSliceValue { + // A unique list of order_ids that expire at this timestamp, sorted in + // ascending order by block height and transaction index of each stateful + // order. + repeated OrderId order_ids = 1 [ (gogoproto.nullable) = false ]; +} + +// StatefulOrderPlacement represents the placement of a stateful order in +// state. It stores the stateful order itself and the `BlockHeight` and +// `TransactionIndex` at which the order was placed. +message StatefulOrderPlacement { + Order order = 1 [ (gogoproto.nullable) = false ]; + + // The block height at which the order was placed. + // Used for ordering by time priority when the chain is restarted. + uint32 block_height = 2; + + // The index at which this transaction appeared in the + // `MsgProposedMatchOrders` message. Used for ordering by time priority when + // the chain is restarted. + uint32 transaction_index = 3; +} + +// Order represents a single order belonging to a `Subaccount` +// for a particular `ClobPair`. +message Order { + // The unique ID of this order. Meant to be unique across all orders. + OrderId order_id = 1 [ (gogoproto.nullable) = false ]; + + // Represents the side of the orderbook the order will be placed on. + // Note that Side.SIDE_UNSPECIFIED is an invalid order and cannot be + // placed on the orderbook. + enum Side { + // Default value. This value is invalid and unused. + SIDE_UNSPECIFIED = 0; + // SIDE_BUY is used to represent a BUY order. + SIDE_BUY = 1; + // SIDE_SELL is used to represent a SELL order. + SIDE_SELL = 2; + } + + Side side = 2; + + // The size of this order in base quantums. Must be a multiple of + // `ClobPair.StepBaseQuantums` and above `ClobPair.MinOrderBaseQuantums` + // (where `ClobPair.Id = orderId.ClobPairId`). + uint64 quantums = 3; + + // The price level that this order will be placed at on the orderbook, + // in subticks. Must be a multiple of ClobPair.SubticksPerTick + // (where `ClobPair.Id = orderId.ClobPairId`). + uint64 subticks = 4; + + // Information about when the order expires. + oneof good_til_oneof { + // The last block this order can be executed at (after which it will be + // unfillable). Used only for Short-Term orders. If this value is non-zero + // then the order is assumed to be a Short-Term order. + uint32 good_til_block = 5; + + // good_til_block_time represents the unix timestamp (in seconds) at which a + // stateful order will be considered expired. The + // good_til_block_time is always evaluated against the previous block's + // `BlockTime` instead of the block in which the order is committed. If this + // value is non-zero then the order is assumed to be a stateful or + // conditional order. + fixed32 good_til_block_time = 6; + } + + // TimeInForce indicates how long an order will remain active before it + // is executed or expires. + enum TimeInForce { + // TIME_IN_FORCE_UNSPECIFIED represents the default behavior where an + // order will first match with existing orders on the book, and any + // remaining size will be added to the book as a maker order. + TIME_IN_FORCE_UNSPECIFIED = 0; + // TIME_IN_FORCE_IOC enforces that an order only be matched with + // maker orders on the book. If the order has remaining size after + // matching with existing orders on the book, the remaining size + // is not placed on the book. + TIME_IN_FORCE_IOC = 1; + // TIME_IN_FORCE_POST_ONLY enforces that an order only be placed + // on the book as a maker order. Note this means that validators will cancel + // any newly-placed post only orders that would cross with other maker + // orders. + TIME_IN_FORCE_POST_ONLY = 2; + // TIME_IN_FORCE_FILL_OR_KILL enforces that an order will either be filled + // completely and immediately by maker orders on the book or canceled if the + // entire amount can‘t be matched. + TIME_IN_FORCE_FILL_OR_KILL = 3; + } + + // The time in force of this order. + TimeInForce time_in_force = 7; + + // Enforces that the order can only reduce the size of an existing position. + // If a ReduceOnly order would change the side of the existing position, + // its size is reduced to that of the remaining size of the position. + // If existing orders on the book with ReduceOnly + // would already close the position, the least aggressive (out-of-the-money) + // ReduceOnly orders are resized and canceled first. + bool reduce_only = 8; + + // Set of bit flags set arbitrarily by clients and ignored by the protocol. + // Used by indexer to infer information about a placed order. + uint32 client_metadata = 9; +} diff --git a/proto/dydxcometbft/clob/order_id.go b/proto/dydxcometbft/clob/order_id.go new file mode 100644 index 00000000000..4f7870184b5 --- /dev/null +++ b/proto/dydxcometbft/clob/order_id.go @@ -0,0 +1,48 @@ +package clob + +import ( + gogoproto "github.com/cosmos/gogoproto/proto" +) + +//nolint:stylecheck,revive // Match variable formats in dydx v4 repo +const ( + OrderIdFlags_ShortTerm = uint32(0) + OrderIdFlags_Conditional = uint32(32) + OrderIdFlags_LongTerm = uint32(64) +) + +// IsShortTermOrder returns true if this order ID is for a short-term order, false if +// not (which implies the order ID is for a long-term or conditional order). +// Note that all short-term orders will have the `OrderFlags` field set to 0. +func (o *OrderId) IsShortTermOrder() bool { + return o.OrderFlags == OrderIdFlags_ShortTerm +} + +// IsConditionalOrder returns true if this order ID is for a conditional order, false if +// not (which implies the order ID is for a short-term or long-term order). +func (o *OrderId) IsConditionalOrder() bool { + // If the third bit in the first byte is set and no other bits are set, + // this is a conditional order. + // Note that 32 in decimal == 0x20 in hex == 0b00100000 in binary. + return o.OrderFlags == OrderIdFlags_Conditional +} + +// IsLongTermOrder returns true if this order ID is for a long-term order, false if +// not (which implies the order ID is for a short-term or conditional order). +func (o *OrderId) IsLongTermOrder() bool { + // If the second bit in the first byte is set and no other bits are set, + // this is a long-term order. + // Note that 64 in decimal == 0x40 in hex == 0b01000000 in binary. + return o.OrderFlags == OrderIdFlags_LongTerm +} + +// IsStatefulOrder returns whether this order is a stateful order, which is true for Long-Term +// and conditional orders and false for Short-Term orders. +func (o *OrderId) IsStatefulOrder() bool { + return o.IsLongTermOrder() || o.IsConditionalOrder() +} + +// GetOrderTextString returns the JSON representation of this order. +func (o *Order) GetOrderTextString() string { + return gogoproto.MarshalTextString(o) +} diff --git a/proto/dydxcometbft/clob/tx.pb.go b/proto/dydxcometbft/clob/tx.pb.go new file mode 100644 index 00000000000..abec593d7c4 --- /dev/null +++ b/proto/dydxcometbft/clob/tx.pb.go @@ -0,0 +1,641 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: dydxcometbft/clob/tx.proto + +package clob + +import ( + encoding_binary "encoding/binary" + fmt "fmt" + _ "github.com/cosmos/cosmos-proto" + _ "github.com/cosmos/gogoproto/gogoproto" + proto "github.com/cosmos/gogoproto/proto" + io "io" + math "math" + math_bits "math/bits" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package + +// MsgPlaceOrder is a request type used for placing orders. +type MsgPlaceOrder struct { + Order Order `protobuf:"bytes,1,opt,name=order,proto3" json:"order"` +} + +func (m *MsgPlaceOrder) Reset() { *m = MsgPlaceOrder{} } +func (m *MsgPlaceOrder) String() string { return proto.CompactTextString(m) } +func (*MsgPlaceOrder) ProtoMessage() {} +func (*MsgPlaceOrder) Descriptor() ([]byte, []int) { + return fileDescriptor_1ad81d2b2aff9221, []int{0} +} +func (m *MsgPlaceOrder) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgPlaceOrder) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgPlaceOrder.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *MsgPlaceOrder) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgPlaceOrder.Merge(m, src) +} +func (m *MsgPlaceOrder) XXX_Size() int { + return m.Size() +} +func (m *MsgPlaceOrder) XXX_DiscardUnknown() { + xxx_messageInfo_MsgPlaceOrder.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgPlaceOrder proto.InternalMessageInfo + +func (m *MsgPlaceOrder) GetOrder() Order { + if m != nil { + return m.Order + } + return Order{} +} + +// MsgCancelOrder is a request type used for canceling orders. +type MsgCancelOrder struct { + OrderId OrderId `protobuf:"bytes,1,opt,name=order_id,json=orderId,proto3" json:"order_id"` + // Information about when the order cancellation expires. + // + // Types that are valid to be assigned to GoodTilOneof: + // *MsgCancelOrder_GoodTilBlock + // *MsgCancelOrder_GoodTilBlockTime + GoodTilOneof isMsgCancelOrder_GoodTilOneof `protobuf_oneof:"good_til_oneof"` +} + +func (m *MsgCancelOrder) Reset() { *m = MsgCancelOrder{} } +func (m *MsgCancelOrder) String() string { return proto.CompactTextString(m) } +func (*MsgCancelOrder) ProtoMessage() {} +func (*MsgCancelOrder) Descriptor() ([]byte, []int) { + return fileDescriptor_1ad81d2b2aff9221, []int{1} +} +func (m *MsgCancelOrder) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgCancelOrder) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgCancelOrder.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *MsgCancelOrder) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgCancelOrder.Merge(m, src) +} +func (m *MsgCancelOrder) XXX_Size() int { + return m.Size() +} +func (m *MsgCancelOrder) XXX_DiscardUnknown() { + xxx_messageInfo_MsgCancelOrder.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgCancelOrder proto.InternalMessageInfo + +type isMsgCancelOrder_GoodTilOneof interface { + isMsgCancelOrder_GoodTilOneof() + MarshalTo([]byte) (int, error) + Size() int +} + +type MsgCancelOrder_GoodTilBlock struct { + GoodTilBlock uint32 `protobuf:"varint,2,opt,name=good_til_block,json=goodTilBlock,proto3,oneof" json:"good_til_block,omitempty"` +} +type MsgCancelOrder_GoodTilBlockTime struct { + GoodTilBlockTime uint32 `protobuf:"fixed32,3,opt,name=good_til_block_time,json=goodTilBlockTime,proto3,oneof" json:"good_til_block_time,omitempty"` +} + +func (*MsgCancelOrder_GoodTilBlock) isMsgCancelOrder_GoodTilOneof() {} +func (*MsgCancelOrder_GoodTilBlockTime) isMsgCancelOrder_GoodTilOneof() {} + +func (m *MsgCancelOrder) GetGoodTilOneof() isMsgCancelOrder_GoodTilOneof { + if m != nil { + return m.GoodTilOneof + } + return nil +} + +func (m *MsgCancelOrder) GetOrderId() OrderId { + if m != nil { + return m.OrderId + } + return OrderId{} +} + +func (m *MsgCancelOrder) GetGoodTilBlock() uint32 { + if x, ok := m.GetGoodTilOneof().(*MsgCancelOrder_GoodTilBlock); ok { + return x.GoodTilBlock + } + return 0 +} + +func (m *MsgCancelOrder) GetGoodTilBlockTime() uint32 { + if x, ok := m.GetGoodTilOneof().(*MsgCancelOrder_GoodTilBlockTime); ok { + return x.GoodTilBlockTime + } + return 0 +} + +// XXX_OneofWrappers is for the internal use of the proto package. +func (*MsgCancelOrder) XXX_OneofWrappers() []interface{} { + return []interface{}{ + (*MsgCancelOrder_GoodTilBlock)(nil), + (*MsgCancelOrder_GoodTilBlockTime)(nil), + } +} + +func init() { + proto.RegisterType((*MsgPlaceOrder)(nil), "dydxcometbft.clob.MsgPlaceOrder") + proto.RegisterType((*MsgCancelOrder)(nil), "dydxcometbft.clob.MsgCancelOrder") +} + +func init() { proto.RegisterFile("dydxcometbft/clob/tx.proto", fileDescriptor_1ad81d2b2aff9221) } + +var fileDescriptor_1ad81d2b2aff9221 = []byte{ + // 315 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x74, 0x91, 0xcf, 0x4a, 0xc3, 0x40, + 0x10, 0x87, 0xb3, 0xfe, 0xab, 0xac, 0xb6, 0xd4, 0xe8, 0x21, 0x06, 0xdc, 0x96, 0x1e, 0xa4, 0xa7, + 0x04, 0xb4, 0x37, 0x6f, 0x11, 0xa1, 0x1e, 0xaa, 0x52, 0x7a, 0xf2, 0x12, 0x9a, 0xdd, 0xed, 0x76, + 0x71, 0xb7, 0x23, 0xcd, 0x0a, 0xf5, 0x2d, 0x7c, 0x1c, 0x1f, 0xa1, 0xc7, 0x1e, 0x3d, 0x89, 0xb4, + 0x2f, 0x22, 0xc9, 0x46, 0x8c, 0x04, 0x6f, 0x33, 0xf3, 0xfd, 0xe6, 0x63, 0x99, 0xc5, 0x3e, 0x7b, + 0x65, 0x0b, 0x0a, 0x9a, 0x9b, 0x64, 0x62, 0x42, 0xaa, 0x20, 0x09, 0xcd, 0x22, 0x78, 0x9e, 0x83, + 0x01, 0xf7, 0xa8, 0xcc, 0x82, 0x8c, 0xf9, 0x27, 0x02, 0x04, 0xe4, 0x34, 0xcc, 0x2a, 0x1b, 0xf4, + 0x4f, 0x29, 0xa4, 0x1a, 0xd2, 0xd8, 0x02, 0xdb, 0x14, 0xe8, 0xac, 0xea, 0x87, 0x39, 0xe3, 0xf3, + 0x02, 0xb7, 0xaa, 0x58, 0x8f, 0x0d, 0x9d, 0xf2, 0x62, 0xbf, 0x73, 0x83, 0xeb, 0x83, 0x54, 0x3c, + 0xa8, 0x31, 0xe5, 0xf7, 0xd9, 0x9e, 0xdb, 0xc3, 0xbb, 0xb9, 0xc0, 0x43, 0x6d, 0xd4, 0x3d, 0xb8, + 0xf0, 0x82, 0xca, 0x23, 0x83, 0x3c, 0x18, 0xed, 0x2c, 0x3f, 0x5b, 0xce, 0xd0, 0x86, 0x3b, 0xef, + 0x08, 0x37, 0x06, 0xa9, 0xb8, 0x1e, 0xcf, 0x28, 0x57, 0x56, 0x74, 0x85, 0xf7, 0x73, 0x16, 0x4b, + 0x56, 0xb8, 0xfc, 0xff, 0x5c, 0xb7, 0xac, 0xb0, 0xd5, 0xc0, 0xb6, 0xee, 0x39, 0x6e, 0x08, 0x00, + 0x16, 0x1b, 0xa9, 0xe2, 0x44, 0x01, 0x7d, 0xf2, 0xb6, 0xda, 0xa8, 0x5b, 0xef, 0x3b, 0xc3, 0xc3, + 0x6c, 0x3e, 0x92, 0x2a, 0xca, 0xa6, 0x6e, 0x88, 0x8f, 0xff, 0xe6, 0x62, 0x23, 0x35, 0xf7, 0xb6, + 0xdb, 0xa8, 0x5b, 0xeb, 0x3b, 0xc3, 0x66, 0x39, 0x3c, 0x92, 0x9a, 0x47, 0xcd, 0x92, 0x18, 0x66, + 0x1c, 0x26, 0xd1, 0xdd, 0x72, 0x4d, 0xd0, 0x6a, 0x4d, 0xd0, 0xd7, 0x9a, 0xa0, 0xb7, 0x0d, 0x71, + 0x56, 0x1b, 0xe2, 0x7c, 0x6c, 0x88, 0xf3, 0xd8, 0x13, 0xd2, 0x4c, 0x5f, 0x92, 0x80, 0x82, 0x0e, + 0x7f, 0x6f, 0xf8, 0x53, 0xd8, 0xcf, 0xa8, 0xdc, 0x37, 0xd9, 0xcb, 0xc1, 0xe5, 0x77, 0x00, 0x00, + 0x00, 0xff, 0xff, 0xcf, 0x43, 0xf9, 0x7a, 0xfa, 0x01, 0x00, 0x00, +} + +func (m *MsgPlaceOrder) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *MsgPlaceOrder) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgPlaceOrder) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + { + size, err := m.Order.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintTx(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + return len(dAtA) - i, nil +} + +func (m *MsgCancelOrder) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *MsgCancelOrder) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgCancelOrder) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.GoodTilOneof != nil { + { + size := m.GoodTilOneof.Size() + i -= size + if _, err := m.GoodTilOneof.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + } + } + { + size, err := m.OrderId.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintTx(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + return len(dAtA) - i, nil +} + +func (m *MsgCancelOrder_GoodTilBlock) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgCancelOrder_GoodTilBlock) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + i = encodeVarintTx(dAtA, i, uint64(m.GoodTilBlock)) + i-- + dAtA[i] = 0x10 + return len(dAtA) - i, nil +} +func (m *MsgCancelOrder_GoodTilBlockTime) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgCancelOrder_GoodTilBlockTime) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + i -= 4 + encoding_binary.LittleEndian.PutUint32(dAtA[i:], uint32(m.GoodTilBlockTime)) + i-- + dAtA[i] = 0x1d + return len(dAtA) - i, nil +} +func encodeVarintTx(dAtA []byte, offset int, v uint64) int { + offset -= sovTx(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *MsgPlaceOrder) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = m.Order.Size() + n += 1 + l + sovTx(uint64(l)) + return n +} + +func (m *MsgCancelOrder) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = m.OrderId.Size() + n += 1 + l + sovTx(uint64(l)) + if m.GoodTilOneof != nil { + n += m.GoodTilOneof.Size() + } + return n +} + +func (m *MsgCancelOrder_GoodTilBlock) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + n += 1 + sovTx(uint64(m.GoodTilBlock)) + return n +} +func (m *MsgCancelOrder_GoodTilBlockTime) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + n += 5 + return n +} + +func sovTx(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozTx(x uint64) (n int) { + return sovTx(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *MsgPlaceOrder) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: MsgPlaceOrder: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgPlaceOrder: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Order", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.Order.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *MsgCancelOrder) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: MsgCancelOrder: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgCancelOrder: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field OrderId", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.OrderId.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 2: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field GoodTilBlock", wireType) + } + var v uint32 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= uint32(b&0x7F) << shift + if b < 0x80 { + break + } + } + m.GoodTilOneof = &MsgCancelOrder_GoodTilBlock{v} + case 3: + if wireType != 5 { + return fmt.Errorf("proto: wrong wireType = %d for field GoodTilBlockTime", wireType) + } + var v uint32 + if (iNdEx + 4) > l { + return io.ErrUnexpectedEOF + } + v = uint32(encoding_binary.LittleEndian.Uint32(dAtA[iNdEx:])) + iNdEx += 4 + m.GoodTilOneof = &MsgCancelOrder_GoodTilBlockTime{v} + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipTx(dAtA []byte) (n int, err error) { + l := len(dAtA) + iNdEx := 0 + depth := 0 + for iNdEx < l { + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowTx + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + wireType := int(wire & 0x7) + switch wireType { + case 0: + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowTx + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + iNdEx++ + if dAtA[iNdEx-1] < 0x80 { + break + } + } + case 1: + iNdEx += 8 + case 2: + var length int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowTx + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + length |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if length < 0 { + return 0, ErrInvalidLengthTx + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupTx + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthTx + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthTx = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowTx = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupTx = fmt.Errorf("proto: unexpected end of group") +) diff --git a/proto/dydxcometbft/clob/tx.proto b/proto/dydxcometbft/clob/tx.proto new file mode 100644 index 00000000000..93edcd8b6f4 --- /dev/null +++ b/proto/dydxcometbft/clob/tx.proto @@ -0,0 +1,35 @@ +syntax = "proto3"; +package dydxcometbft.clob; + +import "gogoproto/gogo.proto"; +import "cosmos_proto/cosmos.proto"; +import "dydxcometbft/clob/order.proto"; +import "dydxcometbft/clob/matches.proto"; + +// this line is used by starport scaffolding # proto/tx/import + +option go_package = "github.com/cometbft/cometbft/proto/dydxcometbft/clob"; + +// dYdX fork: This file is trimmed down to not include the service component since it requires the +// `option (cosmos.msg.v1.service) = true;` tag. + +// MsgPlaceOrder is a request type used for placing orders. +message MsgPlaceOrder { Order order = 1 [ (gogoproto.nullable) = false ]; } + +// MsgCancelOrder is a request type used for canceling orders. +message MsgCancelOrder { + OrderId order_id = 1 [ (gogoproto.nullable) = false ]; + // Information about when the order cancellation expires. + oneof good_til_oneof { + // The last block this order cancellation can be executed at. + // Used only for Short-Term orders and must be zero for stateful orders. + uint32 good_til_block = 2; + + // good_til_block_time represents the unix timestamp (in seconds) at which a + // stateful order cancellation will be considered expired. The + // good_til_block_time is always evaluated against the previous block's + // `BlockTime` instead of the block in which the order is committed. + // This value must be zero for Short-Term orders. + fixed32 good_til_block_time = 3; + } +} diff --git a/proto/dydxcometbft/gotypes/serializable_int.go b/proto/dydxcometbft/gotypes/serializable_int.go new file mode 100644 index 00000000000..7de7fa29156 --- /dev/null +++ b/proto/dydxcometbft/gotypes/serializable_int.go @@ -0,0 +1,129 @@ +package gotypes + +import ( + "encoding" + "encoding/json" + "math/big" +) + +// SerializableInt is basically copied from cosmos-sdk/types/Int but: +// - doesn’t have a bit-length restriction +// - uses GobEncode/GobDecode instead of serializing to an ascii string +// - removes superfluous functions to do `big.Int` math on the underlying value +type SerializableInt struct { + i *big.Int +} + +// BigInt converts Int to big.Int +func (i SerializableInt) BigInt() *big.Int { + if i.IsNil() { + return nil + } + return new(big.Int).Set(i.i) +} + +// IsNil returns true if Int is uninitialized +func (i SerializableInt) IsNil() bool { + return i.i == nil +} + +// NewInt constructs Int from int64 +func NewInt(n int64) SerializableInt { + return SerializableInt{big.NewInt(n)} +} + +// NewIntFromUint64 constructs an Int from a uint64. +func NewIntFromUint64(n uint64) SerializableInt { + b := big.NewInt(0) + b.SetUint64(n) + return SerializableInt{b} +} + +// NewIntFromBigInt constructs Int from big.Int. If the provided big.Int is nil, +func NewIntFromBigInt(i *big.Int) SerializableInt { + if i == nil { + return SerializableInt{} + } + + return SerializableInt{i} +} + +// ZeroInt returns Int value with zero +func ZeroInt() SerializableInt { + return SerializableInt{big.NewInt(0)} +} + +// Marshal implements the gogo proto custom type interface. +func (i SerializableInt) Marshal() ([]byte, error) { + i.ensureNonNil() + return i.i.GobEncode() +} + +// MarshalTo implements the gogo proto custom type interface. +func (i *SerializableInt) MarshalTo(data []byte) (n int, err error) { + bz, err := i.Marshal() + if err != nil { + return 0, err + } + + n = copy(data, bz) + return n, nil +} + +// Unmarshal implements the gogo proto custom type interface. +func (i *SerializableInt) Unmarshal(data []byte) error { + i.ensureNonNil() + + return i.i.GobDecode(data) +} + +// Size implements the gogo proto custom type interface. +func (i *SerializableInt) Size() int { + i.ensureNonNil() + n := i.i.BitLen() + return 1 + ((n + 7) / 8) +} + +// MarshalJSON defines custom encoding scheme +func (i SerializableInt) MarshalJSON() ([]byte, error) { + i.ensureNonNil() + return marshalJSON(i.i) +} + +// UnmarshalJSON defines custom decoding scheme +func (i *SerializableInt) UnmarshalJSON(bz []byte) error { + i.ensureNonNil() + return unmarshalJSON(i.i, bz) +} + +// MarshalJSON for custom encoding scheme +// Must be encoded as a string for JSON precision +func marshalJSON(i encoding.TextMarshaler) ([]byte, error) { + text, err := i.MarshalText() + if err != nil { + return nil, err + } + + return json.Marshal(string(text)) +} + +// UnmarshalJSON for custom decoding scheme +// Must be encoded as a string for JSON precision +func unmarshalJSON(i *big.Int, bz []byte) error { + var text string + if err := json.Unmarshal(bz, &text); err != nil { + return err + } + + return unmarshalText(i, text) +} + +func unmarshalText(i *big.Int, text string) error { + return i.UnmarshalText([]byte(text)) +} + +func (i *SerializableInt) ensureNonNil() { + if i.i == nil { + i.i = new(big.Int) + } +} diff --git a/proto/dydxcometbft/subaccounts/asset_position.pb.go b/proto/dydxcometbft/subaccounts/asset_position.pb.go new file mode 100644 index 00000000000..e56d34d2fc4 --- /dev/null +++ b/proto/dydxcometbft/subaccounts/asset_position.pb.go @@ -0,0 +1,396 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: dydxcometbft/subaccounts/asset_position.proto + +package subaccounts + +import ( + fmt "fmt" + github_com_cometbft_cometbft_proto_dydxcometbft_gotypes "github.com/cometbft/cometbft/proto/dydxcometbft/gotypes" + _ "github.com/cosmos/gogoproto/gogoproto" + proto "github.com/cosmos/gogoproto/proto" + io "io" + math "math" + math_bits "math/bits" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package + +// AssetPositions define an account’s positions of an `Asset`. +// Therefore they hold any information needed to trade on Spot and Margin. +type AssetPosition struct { + // The `Id` of the `Asset`. + AssetId uint32 `protobuf:"varint,1,opt,name=asset_id,json=assetId,proto3" json:"asset_id,omitempty"` + // The absolute size of the position in base quantums. + Quantums github_com_cometbft_cometbft_proto_dydxcometbft_gotypes.SerializableInt `protobuf:"bytes,2,opt,name=quantums,proto3,customtype=github.com/cometbft/cometbft/proto/dydxcometbft/gotypes.SerializableInt" json:"quantums"` + // The `Index` (either `LongIndex` or `ShortIndex`) of the `Asset` the last + // time this position was settled + // TODO(DEC-582): pending margin trading being added. + Index uint64 `protobuf:"varint,3,opt,name=index,proto3" json:"index,omitempty"` +} + +func (m *AssetPosition) Reset() { *m = AssetPosition{} } +func (m *AssetPosition) String() string { return proto.CompactTextString(m) } +func (*AssetPosition) ProtoMessage() {} +func (*AssetPosition) Descriptor() ([]byte, []int) { + return fileDescriptor_2bd5132195353311, []int{0} +} +func (m *AssetPosition) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *AssetPosition) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_AssetPosition.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *AssetPosition) XXX_Merge(src proto.Message) { + xxx_messageInfo_AssetPosition.Merge(m, src) +} +func (m *AssetPosition) XXX_Size() int { + return m.Size() +} +func (m *AssetPosition) XXX_DiscardUnknown() { + xxx_messageInfo_AssetPosition.DiscardUnknown(m) +} + +var xxx_messageInfo_AssetPosition proto.InternalMessageInfo + +func (m *AssetPosition) GetAssetId() uint32 { + if m != nil { + return m.AssetId + } + return 0 +} + +func (m *AssetPosition) GetIndex() uint64 { + if m != nil { + return m.Index + } + return 0 +} + +func init() { + proto.RegisterType((*AssetPosition)(nil), "dydxcometbft.subaccounts.AssetPosition") +} + +func init() { + proto.RegisterFile("dydxcometbft/subaccounts/asset_position.proto", fileDescriptor_2bd5132195353311) +} + +var fileDescriptor_2bd5132195353311 = []byte{ + // 254 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0xd2, 0x4d, 0xa9, 0x4c, 0xa9, + 0x48, 0xce, 0xcf, 0x4d, 0x2d, 0x49, 0x4a, 0x2b, 0xd1, 0x2f, 0x2e, 0x4d, 0x4a, 0x4c, 0x4e, 0xce, + 0x2f, 0xcd, 0x2b, 0x29, 0xd6, 0x4f, 0x2c, 0x2e, 0x4e, 0x2d, 0x89, 0x2f, 0xc8, 0x2f, 0xce, 0x2c, + 0xc9, 0xcc, 0xcf, 0xd3, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x92, 0x40, 0x56, 0xae, 0x87, 0xa4, + 0x5c, 0x4a, 0x24, 0x3d, 0x3f, 0x3d, 0x1f, 0xac, 0x48, 0x1f, 0xc4, 0x82, 0xa8, 0x57, 0x5a, 0xcb, + 0xc8, 0xc5, 0xeb, 0x08, 0x32, 0x28, 0x00, 0x6a, 0x8e, 0x90, 0x24, 0x17, 0x07, 0xc4, 0xe4, 0xcc, + 0x14, 0x09, 0x46, 0x05, 0x46, 0x0d, 0xde, 0x20, 0x76, 0x30, 0xdf, 0x33, 0x45, 0x28, 0x9b, 0x8b, + 0xa3, 0xb0, 0x34, 0x31, 0xaf, 0xa4, 0x34, 0xb7, 0x58, 0x82, 0x49, 0x81, 0x51, 0x83, 0xc7, 0xc9, + 0xff, 0xc4, 0x3d, 0x79, 0x86, 0x5b, 0xf7, 0xe4, 0xdd, 0xd3, 0x33, 0x4b, 0x32, 0x4a, 0x93, 0xf4, + 0x92, 0xf3, 0x73, 0xf5, 0xe1, 0x8e, 0x85, 0x33, 0x20, 0xb6, 0xa2, 0x78, 0x24, 0x3d, 0xbf, 0xa4, + 0xb2, 0x20, 0xb5, 0x58, 0x2f, 0x38, 0xb5, 0x28, 0x33, 0x31, 0x27, 0xb3, 0x2a, 0x31, 0x29, 0x27, + 0xd5, 0x33, 0xaf, 0x24, 0x08, 0x6e, 0x81, 0x90, 0x08, 0x17, 0x6b, 0x66, 0x5e, 0x4a, 0x6a, 0x85, + 0x04, 0xb3, 0x02, 0xa3, 0x06, 0x4b, 0x10, 0x84, 0xe3, 0x14, 0x7a, 0xe2, 0x91, 0x1c, 0xe3, 0x85, + 0x47, 0x72, 0x8c, 0x0f, 0x1e, 0xc9, 0x31, 0x4e, 0x78, 0x2c, 0xc7, 0x70, 0xe1, 0xb1, 0x1c, 0xc3, + 0x8d, 0xc7, 0x72, 0x0c, 0x51, 0xd6, 0xa4, 0x3a, 0x01, 0x29, 0x70, 0x92, 0xd8, 0xc0, 0xf2, 0xc6, + 0x80, 0x00, 0x00, 0x00, 0xff, 0xff, 0xbb, 0x65, 0x39, 0xeb, 0x6e, 0x01, 0x00, 0x00, +} + +func (m *AssetPosition) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *AssetPosition) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *AssetPosition) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Index != 0 { + i = encodeVarintAssetPosition(dAtA, i, uint64(m.Index)) + i-- + dAtA[i] = 0x18 + } + { + size := m.Quantums.Size() + i -= size + if _, err := m.Quantums.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintAssetPosition(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + if m.AssetId != 0 { + i = encodeVarintAssetPosition(dAtA, i, uint64(m.AssetId)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + +func encodeVarintAssetPosition(dAtA []byte, offset int, v uint64) int { + offset -= sovAssetPosition(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *AssetPosition) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.AssetId != 0 { + n += 1 + sovAssetPosition(uint64(m.AssetId)) + } + l = m.Quantums.Size() + n += 1 + l + sovAssetPosition(uint64(l)) + if m.Index != 0 { + n += 1 + sovAssetPosition(uint64(m.Index)) + } + return n +} + +func sovAssetPosition(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozAssetPosition(x uint64) (n int) { + return sovAssetPosition(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *AssetPosition) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowAssetPosition + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: AssetPosition: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: AssetPosition: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field AssetId", wireType) + } + m.AssetId = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowAssetPosition + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.AssetId |= uint32(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Quantums", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowAssetPosition + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthAssetPosition + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthAssetPosition + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.Quantums.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 3: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Index", wireType) + } + m.Index = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowAssetPosition + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Index |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + default: + iNdEx = preIndex + skippy, err := skipAssetPosition(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthAssetPosition + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipAssetPosition(dAtA []byte) (n int, err error) { + l := len(dAtA) + iNdEx := 0 + depth := 0 + for iNdEx < l { + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowAssetPosition + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + wireType := int(wire & 0x7) + switch wireType { + case 0: + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowAssetPosition + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + iNdEx++ + if dAtA[iNdEx-1] < 0x80 { + break + } + } + case 1: + iNdEx += 8 + case 2: + var length int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowAssetPosition + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + length |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if length < 0 { + return 0, ErrInvalidLengthAssetPosition + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupAssetPosition + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthAssetPosition + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthAssetPosition = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowAssetPosition = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupAssetPosition = fmt.Errorf("proto: unexpected end of group") +) diff --git a/proto/dydxcometbft/subaccounts/asset_position.proto b/proto/dydxcometbft/subaccounts/asset_position.proto new file mode 100644 index 00000000000..0702434538c --- /dev/null +++ b/proto/dydxcometbft/subaccounts/asset_position.proto @@ -0,0 +1,23 @@ +syntax = "proto3"; +package dydxcometbft.subaccounts; + +import "gogoproto/gogo.proto"; + +option go_package = "github.com/cometbft/cometbft/proto/dydxcometbft/subaccounts"; + +// AssetPositions define an account’s positions of an `Asset`. +// Therefore they hold any information needed to trade on Spot and Margin. +message AssetPosition { + // The `Id` of the `Asset`. + uint32 asset_id = 1; + // The absolute size of the position in base quantums. + bytes quantums = 2 [ + (gogoproto.customtype) = + "github.com/cometbft/cometbft/proto/dydxcometbft/gotypes.SerializableInt", + (gogoproto.nullable) = false + ]; + // The `Index` (either `LongIndex` or `ShortIndex`) of the `Asset` the last + // time this position was settled + // TODO(DEC-582): pending margin trading being added. + uint64 index = 3; +} diff --git a/proto/dydxcometbft/subaccounts/perpetual_position.pb.go b/proto/dydxcometbft/subaccounts/perpetual_position.pb.go new file mode 100644 index 00000000000..372bb8e8d0f --- /dev/null +++ b/proto/dydxcometbft/subaccounts/perpetual_position.pb.go @@ -0,0 +1,407 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: dydxcometbft/subaccounts/perpetual_position.proto + +package subaccounts + +import ( + fmt "fmt" + github_com_cometbft_cometbft_proto_dydxcometbft_gotypes "github.com/cometbft/cometbft/proto/dydxcometbft/gotypes" + _ "github.com/cosmos/gogoproto/gogoproto" + proto "github.com/cosmos/gogoproto/proto" + io "io" + math "math" + math_bits "math/bits" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package + +// PerpetualPositions are an account’s positions of a `Perpetual`. +// Therefore they hold any information needed to trade perpetuals. +type PerpetualPosition struct { + // The `Id` of the `Perpetual`. + PerpetualId uint32 `protobuf:"varint,1,opt,name=perpetual_id,json=perpetualId,proto3" json:"perpetual_id,omitempty"` + // The size of the position in base quantums. + Quantums github_com_cometbft_cometbft_proto_dydxcometbft_gotypes.SerializableInt `protobuf:"bytes,2,opt,name=quantums,proto3,customtype=github.com/cometbft/cometbft/proto/dydxcometbft/gotypes.SerializableInt" json:"quantums"` + // The funding_index of the `Perpetual` the last time this position was + // settled. + FundingIndex github_com_cometbft_cometbft_proto_dydxcometbft_gotypes.SerializableInt `protobuf:"bytes,3,opt,name=funding_index,json=fundingIndex,proto3,customtype=github.com/cometbft/cometbft/proto/dydxcometbft/gotypes.SerializableInt" json:"funding_index"` +} + +func (m *PerpetualPosition) Reset() { *m = PerpetualPosition{} } +func (m *PerpetualPosition) String() string { return proto.CompactTextString(m) } +func (*PerpetualPosition) ProtoMessage() {} +func (*PerpetualPosition) Descriptor() ([]byte, []int) { + return fileDescriptor_42e6131366cd5faf, []int{0} +} +func (m *PerpetualPosition) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *PerpetualPosition) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_PerpetualPosition.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *PerpetualPosition) XXX_Merge(src proto.Message) { + xxx_messageInfo_PerpetualPosition.Merge(m, src) +} +func (m *PerpetualPosition) XXX_Size() int { + return m.Size() +} +func (m *PerpetualPosition) XXX_DiscardUnknown() { + xxx_messageInfo_PerpetualPosition.DiscardUnknown(m) +} + +var xxx_messageInfo_PerpetualPosition proto.InternalMessageInfo + +func (m *PerpetualPosition) GetPerpetualId() uint32 { + if m != nil { + return m.PerpetualId + } + return 0 +} + +func init() { + proto.RegisterType((*PerpetualPosition)(nil), "dydxcometbft.subaccounts.PerpetualPosition") +} + +func init() { + proto.RegisterFile("dydxcometbft/subaccounts/perpetual_position.proto", fileDescriptor_42e6131366cd5faf) +} + +var fileDescriptor_42e6131366cd5faf = []byte{ + // 268 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x32, 0x4c, 0xa9, 0x4c, 0xa9, + 0x48, 0xce, 0xcf, 0x4d, 0x2d, 0x49, 0x4a, 0x2b, 0xd1, 0x2f, 0x2e, 0x4d, 0x4a, 0x4c, 0x4e, 0xce, + 0x2f, 0xcd, 0x2b, 0x29, 0xd6, 0x2f, 0x48, 0x2d, 0x2a, 0x48, 0x2d, 0x29, 0x4d, 0xcc, 0x89, 0x2f, + 0xc8, 0x2f, 0xce, 0x2c, 0xc9, 0xcc, 0xcf, 0xd3, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x92, 0x40, + 0xd6, 0xa2, 0x87, 0xa4, 0x45, 0x4a, 0x24, 0x3d, 0x3f, 0x3d, 0x1f, 0xac, 0x48, 0x1f, 0xc4, 0x82, + 0xa8, 0x57, 0x9a, 0xc9, 0xc4, 0x25, 0x18, 0x00, 0x33, 0x2c, 0x00, 0x6a, 0x96, 0x90, 0x22, 0x17, + 0x0f, 0xc2, 0x86, 0xcc, 0x14, 0x09, 0x46, 0x05, 0x46, 0x0d, 0xde, 0x20, 0x6e, 0xb8, 0x98, 0x67, + 0x8a, 0x50, 0x36, 0x17, 0x47, 0x61, 0x69, 0x62, 0x5e, 0x49, 0x69, 0x6e, 0xb1, 0x04, 0x93, 0x02, + 0xa3, 0x06, 0x8f, 0x93, 0xff, 0x89, 0x7b, 0xf2, 0x0c, 0xb7, 0xee, 0xc9, 0xbb, 0xa7, 0x67, 0x96, + 0x64, 0x94, 0x26, 0xe9, 0x25, 0xe7, 0xe7, 0xea, 0xc3, 0x1d, 0x0f, 0x67, 0x40, 0x5c, 0x80, 0xe2, + 0xb1, 0xf4, 0xfc, 0x92, 0xca, 0x82, 0xd4, 0x62, 0xbd, 0xe0, 0xd4, 0xa2, 0xcc, 0xc4, 0x9c, 0xcc, + 0xaa, 0xc4, 0xa4, 0x9c, 0x54, 0xcf, 0xbc, 0x92, 0x20, 0xb8, 0x05, 0x42, 0x25, 0x5c, 0xbc, 0x69, + 0xa5, 0x79, 0x29, 0x99, 0x79, 0xe9, 0xf1, 0x99, 0x79, 0x29, 0xa9, 0x15, 0x12, 0xcc, 0xb4, 0xb1, + 0x91, 0x07, 0x6a, 0x8b, 0x27, 0xc8, 0x12, 0xa7, 0xd0, 0x13, 0x8f, 0xe4, 0x18, 0x2f, 0x3c, 0x92, + 0x63, 0x7c, 0xf0, 0x48, 0x8e, 0x71, 0xc2, 0x63, 0x39, 0x86, 0x0b, 0x8f, 0xe5, 0x18, 0x6e, 0x3c, + 0x96, 0x63, 0x88, 0xb2, 0x26, 0xd5, 0x42, 0xa4, 0x88, 0x48, 0x62, 0x03, 0xcb, 0x1b, 0x03, 0x02, + 0x00, 0x00, 0xff, 0xff, 0xd0, 0x1e, 0x06, 0xdd, 0xde, 0x01, 0x00, 0x00, +} + +func (m *PerpetualPosition) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *PerpetualPosition) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *PerpetualPosition) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + { + size := m.FundingIndex.Size() + i -= size + if _, err := m.FundingIndex.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintPerpetualPosition(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x1a + { + size := m.Quantums.Size() + i -= size + if _, err := m.Quantums.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintPerpetualPosition(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + if m.PerpetualId != 0 { + i = encodeVarintPerpetualPosition(dAtA, i, uint64(m.PerpetualId)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + +func encodeVarintPerpetualPosition(dAtA []byte, offset int, v uint64) int { + offset -= sovPerpetualPosition(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *PerpetualPosition) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.PerpetualId != 0 { + n += 1 + sovPerpetualPosition(uint64(m.PerpetualId)) + } + l = m.Quantums.Size() + n += 1 + l + sovPerpetualPosition(uint64(l)) + l = m.FundingIndex.Size() + n += 1 + l + sovPerpetualPosition(uint64(l)) + return n +} + +func sovPerpetualPosition(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozPerpetualPosition(x uint64) (n int) { + return sovPerpetualPosition(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *PerpetualPosition) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowPerpetualPosition + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: PerpetualPosition: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: PerpetualPosition: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field PerpetualId", wireType) + } + m.PerpetualId = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowPerpetualPosition + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.PerpetualId |= uint32(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Quantums", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowPerpetualPosition + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthPerpetualPosition + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthPerpetualPosition + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.Quantums.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field FundingIndex", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowPerpetualPosition + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthPerpetualPosition + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthPerpetualPosition + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.FundingIndex.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipPerpetualPosition(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthPerpetualPosition + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipPerpetualPosition(dAtA []byte) (n int, err error) { + l := len(dAtA) + iNdEx := 0 + depth := 0 + for iNdEx < l { + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowPerpetualPosition + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + wireType := int(wire & 0x7) + switch wireType { + case 0: + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowPerpetualPosition + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + iNdEx++ + if dAtA[iNdEx-1] < 0x80 { + break + } + } + case 1: + iNdEx += 8 + case 2: + var length int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowPerpetualPosition + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + length |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if length < 0 { + return 0, ErrInvalidLengthPerpetualPosition + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupPerpetualPosition + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthPerpetualPosition + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthPerpetualPosition = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowPerpetualPosition = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupPerpetualPosition = fmt.Errorf("proto: unexpected end of group") +) diff --git a/proto/dydxcometbft/subaccounts/perpetual_position.proto b/proto/dydxcometbft/subaccounts/perpetual_position.proto new file mode 100644 index 00000000000..2119cc7d09e --- /dev/null +++ b/proto/dydxcometbft/subaccounts/perpetual_position.proto @@ -0,0 +1,26 @@ +syntax = "proto3"; +package dydxcometbft.subaccounts; + +import "gogoproto/gogo.proto"; + +option go_package = "github.com/cometbft/cometbft/proto/dydxcometbft/subaccounts"; + +// PerpetualPositions are an account’s positions of a `Perpetual`. +// Therefore they hold any information needed to trade perpetuals. +message PerpetualPosition { + // The `Id` of the `Perpetual`. + uint32 perpetual_id = 1; + // The size of the position in base quantums. + bytes quantums = 2 [ + (gogoproto.customtype) = + "github.com/cometbft/cometbft/proto/dydxcometbft/gotypes.SerializableInt", + (gogoproto.nullable) = false + ]; + // The funding_index of the `Perpetual` the last time this position was + // settled. + bytes funding_index = 3 [ + (gogoproto.customtype) = + "github.com/cometbft/cometbft/proto/dydxcometbft/gotypes.SerializableInt", + (gogoproto.nullable) = false + ]; +} diff --git a/proto/dydxcometbft/subaccounts/subaccount.pb.go b/proto/dydxcometbft/subaccounts/subaccount.pb.go new file mode 100644 index 00000000000..cce8b8e56f6 --- /dev/null +++ b/proto/dydxcometbft/subaccounts/subaccount.pb.go @@ -0,0 +1,721 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: dydxcometbft/subaccounts/subaccount.proto + +package subaccounts + +import ( + fmt "fmt" + _ "github.com/cosmos/cosmos-proto" + proto "github.com/cosmos/gogoproto/proto" + io "io" + math "math" + math_bits "math/bits" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package + +// SubaccountId defines a unique identifier for a Subaccount. +type SubaccountId struct { + // The address of the wallet that owns this subaccount. + Owner string `protobuf:"bytes,1,opt,name=owner,proto3" json:"owner,omitempty"` + // < 128 Since 128 should be enough to start and it fits within + // 1 Byte (1 Bit needed to indicate that the first byte is the last). + Number uint32 `protobuf:"varint,2,opt,name=number,proto3" json:"number,omitempty"` +} + +func (m *SubaccountId) Reset() { *m = SubaccountId{} } +func (m *SubaccountId) String() string { return proto.CompactTextString(m) } +func (*SubaccountId) ProtoMessage() {} +func (*SubaccountId) Descriptor() ([]byte, []int) { + return fileDescriptor_128246a59376a188, []int{0} +} +func (m *SubaccountId) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *SubaccountId) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_SubaccountId.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *SubaccountId) XXX_Merge(src proto.Message) { + xxx_messageInfo_SubaccountId.Merge(m, src) +} +func (m *SubaccountId) XXX_Size() int { + return m.Size() +} +func (m *SubaccountId) XXX_DiscardUnknown() { + xxx_messageInfo_SubaccountId.DiscardUnknown(m) +} + +var xxx_messageInfo_SubaccountId proto.InternalMessageInfo + +func (m *SubaccountId) GetOwner() string { + if m != nil { + return m.Owner + } + return "" +} + +func (m *SubaccountId) GetNumber() uint32 { + if m != nil { + return m.Number + } + return 0 +} + +// Subaccount defines a single sub-account for a given address. +// Subaccounts are uniquely indexed by a subaccountNumber/owner pair. +type Subaccount struct { + // The Id of the Subaccount + Id *SubaccountId `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` + // All `AssetPosition`s associated with this subaccount. + // Always sorted ascending by `asset_id`. + AssetPositions []*AssetPosition `protobuf:"bytes,2,rep,name=asset_positions,json=assetPositions,proto3" json:"asset_positions,omitempty"` + // All `PerpetualPosition`s associated with this subaccount. + // Always sorted ascending by `perpetual_id. + PerpetualPositions []*PerpetualPosition `protobuf:"bytes,3,rep,name=perpetual_positions,json=perpetualPositions,proto3" json:"perpetual_positions,omitempty"` + // Set by the owner. If true, then margin trades can be made in this + // subaccount. + MarginEnabled bool `protobuf:"varint,4,opt,name=margin_enabled,json=marginEnabled,proto3" json:"margin_enabled,omitempty"` +} + +func (m *Subaccount) Reset() { *m = Subaccount{} } +func (m *Subaccount) String() string { return proto.CompactTextString(m) } +func (*Subaccount) ProtoMessage() {} +func (*Subaccount) Descriptor() ([]byte, []int) { + return fileDescriptor_128246a59376a188, []int{1} +} +func (m *Subaccount) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *Subaccount) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_Subaccount.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *Subaccount) XXX_Merge(src proto.Message) { + xxx_messageInfo_Subaccount.Merge(m, src) +} +func (m *Subaccount) XXX_Size() int { + return m.Size() +} +func (m *Subaccount) XXX_DiscardUnknown() { + xxx_messageInfo_Subaccount.DiscardUnknown(m) +} + +var xxx_messageInfo_Subaccount proto.InternalMessageInfo + +func (m *Subaccount) GetId() *SubaccountId { + if m != nil { + return m.Id + } + return nil +} + +func (m *Subaccount) GetAssetPositions() []*AssetPosition { + if m != nil { + return m.AssetPositions + } + return nil +} + +func (m *Subaccount) GetPerpetualPositions() []*PerpetualPosition { + if m != nil { + return m.PerpetualPositions + } + return nil +} + +func (m *Subaccount) GetMarginEnabled() bool { + if m != nil { + return m.MarginEnabled + } + return false +} + +func init() { + proto.RegisterType((*SubaccountId)(nil), "dydxcometbft.subaccounts.SubaccountId") + proto.RegisterType((*Subaccount)(nil), "dydxcometbft.subaccounts.Subaccount") +} + +func init() { + proto.RegisterFile("dydxcometbft/subaccounts/subaccount.proto", fileDescriptor_128246a59376a188) +} + +var fileDescriptor_128246a59376a188 = []byte{ + // 350 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x74, 0x92, 0x41, 0x4b, 0xf3, 0x30, + 0x18, 0xc7, 0x97, 0xee, 0x7d, 0x87, 0x66, 0x6e, 0x42, 0x14, 0x89, 0x3b, 0x94, 0x32, 0x50, 0x2b, + 0xb2, 0x0e, 0x27, 0x78, 0xf1, 0xb4, 0x81, 0x07, 0x6f, 0xa3, 0x43, 0x0f, 0x22, 0x8c, 0xb6, 0x89, + 0x33, 0xb0, 0x26, 0x25, 0x49, 0x51, 0xbf, 0x85, 0x77, 0xbf, 0x86, 0x1f, 0xc2, 0xe3, 0xf0, 0xe4, + 0x51, 0xd6, 0x2f, 0x22, 0xb6, 0xb5, 0xd6, 0x49, 0x6f, 0x79, 0x9e, 0xfe, 0xfe, 0x3f, 0xd2, 0xe7, + 0x09, 0x3c, 0x24, 0x8f, 0xe4, 0x21, 0x10, 0x21, 0xd5, 0xfe, 0xad, 0xee, 0xab, 0xd8, 0xf7, 0x82, + 0x40, 0xc4, 0x5c, 0xab, 0xd2, 0xd9, 0x89, 0xa4, 0xd0, 0x02, 0xe1, 0x32, 0xea, 0x94, 0xd0, 0xce, + 0x6e, 0x20, 0x54, 0x28, 0xd4, 0x34, 0xe5, 0xfa, 0x59, 0x91, 0x85, 0x3a, 0xbd, 0x4a, 0xbf, 0xa7, + 0x14, 0xd5, 0xd3, 0x48, 0x28, 0xa6, 0x99, 0xe0, 0x39, 0x7e, 0x5c, 0x89, 0x47, 0x54, 0x46, 0x54, + 0xc7, 0xde, 0x7c, 0x25, 0xd2, 0xbd, 0x82, 0x1b, 0x93, 0x82, 0xbb, 0x20, 0xc8, 0x81, 0xff, 0xc5, + 0x3d, 0xa7, 0x12, 0x03, 0x0b, 0xd8, 0xeb, 0x23, 0xfc, 0xf6, 0xd2, 0xdb, 0xce, 0xaf, 0x34, 0x24, + 0x44, 0x52, 0xa5, 0x26, 0x5a, 0x32, 0x3e, 0x73, 0x33, 0x0c, 0xed, 0xc0, 0x06, 0x8f, 0x43, 0x9f, + 0x4a, 0x6c, 0x58, 0xc0, 0x6e, 0xb9, 0x79, 0xd5, 0x7d, 0x36, 0x20, 0xfc, 0x11, 0xa3, 0x53, 0x68, + 0x30, 0x92, 0x3a, 0x9b, 0x83, 0x7d, 0xa7, 0x6a, 0x14, 0x4e, 0xf9, 0x2a, 0xae, 0xc1, 0x08, 0x1a, + 0xc3, 0xcd, 0xdf, 0x7f, 0xaa, 0xb0, 0x61, 0xd5, 0xed, 0xe6, 0xe0, 0xa0, 0x5a, 0x32, 0xfc, 0x0a, + 0x8c, 0x73, 0xde, 0x6d, 0x7b, 0xe5, 0x52, 0xa1, 0x1b, 0xb8, 0xf5, 0x77, 0x18, 0x0a, 0xd7, 0x53, + 0xeb, 0x51, 0xb5, 0x75, 0xfc, 0x1d, 0x2a, 0xcc, 0x28, 0x5a, 0x6d, 0x29, 0xb4, 0x07, 0xdb, 0xa1, + 0x27, 0x67, 0x8c, 0x4f, 0x29, 0xf7, 0xfc, 0x39, 0x25, 0xf8, 0x9f, 0x05, 0xec, 0x35, 0xb7, 0x95, + 0x75, 0xcf, 0xb3, 0xe6, 0xe8, 0xf2, 0x75, 0x69, 0x82, 0xc5, 0xd2, 0x04, 0x1f, 0x4b, 0x13, 0x3c, + 0x25, 0x66, 0x6d, 0x91, 0x98, 0xb5, 0xf7, 0xc4, 0xac, 0x5d, 0x9f, 0xcd, 0x98, 0xbe, 0x8b, 0x7d, + 0x27, 0x10, 0x61, 0xbf, 0xd8, 0x64, 0x71, 0xc8, 0x9e, 0x48, 0xd5, 0x96, 0xfd, 0x46, 0xfa, 0xfd, + 0xe4, 0x33, 0x00, 0x00, 0xff, 0xff, 0x8d, 0x54, 0xae, 0xa2, 0x97, 0x02, 0x00, 0x00, +} + +func (m *SubaccountId) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *SubaccountId) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *SubaccountId) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Number != 0 { + i = encodeVarintSubaccount(dAtA, i, uint64(m.Number)) + i-- + dAtA[i] = 0x10 + } + if len(m.Owner) > 0 { + i -= len(m.Owner) + copy(dAtA[i:], m.Owner) + i = encodeVarintSubaccount(dAtA, i, uint64(len(m.Owner))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *Subaccount) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *Subaccount) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *Subaccount) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.MarginEnabled { + i-- + if m.MarginEnabled { + dAtA[i] = 1 + } else { + dAtA[i] = 0 + } + i-- + dAtA[i] = 0x20 + } + if len(m.PerpetualPositions) > 0 { + for iNdEx := len(m.PerpetualPositions) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.PerpetualPositions[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintSubaccount(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x1a + } + } + if len(m.AssetPositions) > 0 { + for iNdEx := len(m.AssetPositions) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.AssetPositions[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintSubaccount(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + } + if m.Id != nil { + { + size, err := m.Id.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintSubaccount(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func encodeVarintSubaccount(dAtA []byte, offset int, v uint64) int { + offset -= sovSubaccount(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *SubaccountId) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Owner) + if l > 0 { + n += 1 + l + sovSubaccount(uint64(l)) + } + if m.Number != 0 { + n += 1 + sovSubaccount(uint64(m.Number)) + } + return n +} + +func (m *Subaccount) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Id != nil { + l = m.Id.Size() + n += 1 + l + sovSubaccount(uint64(l)) + } + if len(m.AssetPositions) > 0 { + for _, e := range m.AssetPositions { + l = e.Size() + n += 1 + l + sovSubaccount(uint64(l)) + } + } + if len(m.PerpetualPositions) > 0 { + for _, e := range m.PerpetualPositions { + l = e.Size() + n += 1 + l + sovSubaccount(uint64(l)) + } + } + if m.MarginEnabled { + n += 2 + } + return n +} + +func sovSubaccount(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozSubaccount(x uint64) (n int) { + return sovSubaccount(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *SubaccountId) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowSubaccount + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: SubaccountId: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: SubaccountId: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Owner", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowSubaccount + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthSubaccount + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthSubaccount + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Owner = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Number", wireType) + } + m.Number = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowSubaccount + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Number |= uint32(b&0x7F) << shift + if b < 0x80 { + break + } + } + default: + iNdEx = preIndex + skippy, err := skipSubaccount(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthSubaccount + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *Subaccount) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowSubaccount + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: Subaccount: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: Subaccount: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Id", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowSubaccount + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthSubaccount + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthSubaccount + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Id == nil { + m.Id = &SubaccountId{} + } + if err := m.Id.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field AssetPositions", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowSubaccount + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthSubaccount + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthSubaccount + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.AssetPositions = append(m.AssetPositions, &AssetPosition{}) + if err := m.AssetPositions[len(m.AssetPositions)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field PerpetualPositions", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowSubaccount + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthSubaccount + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthSubaccount + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.PerpetualPositions = append(m.PerpetualPositions, &PerpetualPosition{}) + if err := m.PerpetualPositions[len(m.PerpetualPositions)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 4: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field MarginEnabled", wireType) + } + var v int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowSubaccount + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + m.MarginEnabled = bool(v != 0) + default: + iNdEx = preIndex + skippy, err := skipSubaccount(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthSubaccount + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipSubaccount(dAtA []byte) (n int, err error) { + l := len(dAtA) + iNdEx := 0 + depth := 0 + for iNdEx < l { + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowSubaccount + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + wireType := int(wire & 0x7) + switch wireType { + case 0: + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowSubaccount + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + iNdEx++ + if dAtA[iNdEx-1] < 0x80 { + break + } + } + case 1: + iNdEx += 8 + case 2: + var length int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowSubaccount + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + length |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if length < 0 { + return 0, ErrInvalidLengthSubaccount + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupSubaccount + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthSubaccount + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthSubaccount = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowSubaccount = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupSubaccount = fmt.Errorf("proto: unexpected end of group") +) diff --git a/proto/dydxcometbft/subaccounts/subaccount.proto b/proto/dydxcometbft/subaccounts/subaccount.proto new file mode 100644 index 00000000000..95b9e091398 --- /dev/null +++ b/proto/dydxcometbft/subaccounts/subaccount.proto @@ -0,0 +1,33 @@ +syntax = "proto3"; +package dydxcometbft.subaccounts; + +import "cosmos_proto/cosmos.proto"; +import "dydxcometbft/subaccounts/asset_position.proto"; +import "dydxcometbft/subaccounts/perpetual_position.proto"; + +option go_package = "github.com/cometbft/cometbft/proto/dydxcometbft/subaccounts"; + +// SubaccountId defines a unique identifier for a Subaccount. +message SubaccountId { + // The address of the wallet that owns this subaccount. + string owner = 1 [ (cosmos_proto.scalar) = "cosmos.AddressString" ]; + // < 128 Since 128 should be enough to start and it fits within + // 1 Byte (1 Bit needed to indicate that the first byte is the last). + uint32 number = 2; +} + +// Subaccount defines a single sub-account for a given address. +// Subaccounts are uniquely indexed by a subaccountNumber/owner pair. +message Subaccount { + // The Id of the Subaccount + SubaccountId id = 1; + // All `AssetPosition`s associated with this subaccount. + // Always sorted ascending by `asset_id`. + repeated AssetPosition asset_positions = 2; + // All `PerpetualPosition`s associated with this subaccount. + // Always sorted ascending by `perpetual_id. + repeated PerpetualPosition perpetual_positions = 3; + // Set by the owner. If true, then margin trades can be made in this + // subaccount. + bool margin_enabled = 4; +}