Skip to content

Commit

Permalink
[CT-1320] proto for FNS price updates (#2586)
Browse files Browse the repository at this point in the history
  • Loading branch information
jayy04 authored Nov 21, 2024
1 parent aa9ff70 commit e700de9
Show file tree
Hide file tree
Showing 12 changed files with 1,198 additions and 339 deletions.
362 changes: 182 additions & 180 deletions indexer/packages/v4-protos/src/codegen/dydxprotocol/bundle.ts

Large diffs are not rendered by default.

45 changes: 43 additions & 2 deletions indexer/packages/v4-protos/src/codegen/dydxprotocol/clob/query.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { EquityTierLimitConfiguration, EquityTierLimitConfigurationSDKType } fro
import { BlockRateLimitConfiguration, BlockRateLimitConfigurationSDKType } from "./block_rate_limit_config";
import { LiquidationsConfig, LiquidationsConfigSDKType } from "./liquidations_config";
import { StreamSubaccountUpdate, StreamSubaccountUpdateSDKType } from "../subaccounts/streaming";
import { StreamPriceUpdate, StreamPriceUpdateSDKType } from "../prices/streaming";
import { OffChainUpdateV1, OffChainUpdateV1SDKType } from "../indexer/off_chain_updates/off_chain_updates";
import { ClobMatch, ClobMatchSDKType } from "./matches";
import * as _m0 from "protobufjs/minimal";
Expand Down Expand Up @@ -256,6 +257,9 @@ export interface StreamOrderbookUpdatesRequest {
/** Subaccount ids to stream subaccount updates for. */

subaccountIds: SubaccountId[];
/** Market ids for price updates. */

marketIds: number[];
}
/**
* StreamOrderbookUpdatesRequest is a request message for the
Expand All @@ -268,6 +272,9 @@ export interface StreamOrderbookUpdatesRequestSDKType {
/** Subaccount ids to stream subaccount updates for. */

subaccount_ids: SubaccountIdSDKType[];
/** Market ids for price updates. */

market_ids: number[];
}
/**
* StreamOrderbookUpdatesResponse is a response message for the
Expand Down Expand Up @@ -302,6 +309,7 @@ export interface StreamUpdate {
orderFill?: StreamOrderbookFill;
takerOrder?: StreamTakerOrder;
subaccountUpdate?: StreamSubaccountUpdate;
priceUpdate?: StreamPriceUpdate;
}
/**
* StreamUpdate is an update that will be pushed through the
Expand All @@ -318,6 +326,7 @@ export interface StreamUpdateSDKType {
order_fill?: StreamOrderbookFillSDKType;
taker_order?: StreamTakerOrderSDKType;
subaccount_update?: StreamSubaccountUpdateSDKType;
price_update?: StreamPriceUpdateSDKType;
}
/**
* StreamOrderbookUpdate provides information on an orderbook update. Used in
Expand Down Expand Up @@ -1191,7 +1200,8 @@ export const QueryLiquidationsConfigurationResponse = {
function createBaseStreamOrderbookUpdatesRequest(): StreamOrderbookUpdatesRequest {
return {
clobPairId: [],
subaccountIds: []
subaccountIds: [],
marketIds: []
};
}

Expand All @@ -1209,6 +1219,13 @@ export const StreamOrderbookUpdatesRequest = {
SubaccountId.encode(v!, writer.uint32(18).fork()).ldelim();
}

writer.uint32(26).fork();

for (const v of message.marketIds) {
writer.uint32(v);
}

writer.ldelim();
return writer;
},

Expand Down Expand Up @@ -1238,6 +1255,19 @@ export const StreamOrderbookUpdatesRequest = {
message.subaccountIds.push(SubaccountId.decode(reader, reader.uint32()));
break;

case 3:
if ((tag & 7) === 2) {
const end2 = reader.uint32() + reader.pos;

while (reader.pos < end2) {
message.marketIds.push(reader.uint32());
}
} else {
message.marketIds.push(reader.uint32());
}

break;

default:
reader.skipType(tag & 7);
break;
Expand All @@ -1251,6 +1281,7 @@ export const StreamOrderbookUpdatesRequest = {
const message = createBaseStreamOrderbookUpdatesRequest();
message.clobPairId = object.clobPairId?.map(e => e) || [];
message.subaccountIds = object.subaccountIds?.map(e => SubaccountId.fromPartial(e)) || [];
message.marketIds = object.marketIds?.map(e => e) || [];
return message;
}

Expand Down Expand Up @@ -1308,7 +1339,8 @@ function createBaseStreamUpdate(): StreamUpdate {
orderbookUpdate: undefined,
orderFill: undefined,
takerOrder: undefined,
subaccountUpdate: undefined
subaccountUpdate: undefined,
priceUpdate: undefined
};
}

Expand Down Expand Up @@ -1338,6 +1370,10 @@ export const StreamUpdate = {
StreamSubaccountUpdate.encode(message.subaccountUpdate, writer.uint32(50).fork()).ldelim();
}

if (message.priceUpdate !== undefined) {
StreamPriceUpdate.encode(message.priceUpdate, writer.uint32(58).fork()).ldelim();
}

return writer;
},

Expand Down Expand Up @@ -1374,6 +1410,10 @@ export const StreamUpdate = {
message.subaccountUpdate = StreamSubaccountUpdate.decode(reader, reader.uint32());
break;

case 7:
message.priceUpdate = StreamPriceUpdate.decode(reader, reader.uint32());
break;

default:
reader.skipType(tag & 7);
break;
Expand All @@ -1391,6 +1431,7 @@ export const StreamUpdate = {
message.orderFill = object.orderFill !== undefined && object.orderFill !== null ? StreamOrderbookFill.fromPartial(object.orderFill) : undefined;
message.takerOrder = object.takerOrder !== undefined && object.takerOrder !== null ? StreamTakerOrder.fromPartial(object.takerOrder) : undefined;
message.subaccountUpdate = object.subaccountUpdate !== undefined && object.subaccountUpdate !== null ? StreamSubaccountUpdate.fromPartial(object.subaccountUpdate) : undefined;
message.priceUpdate = object.priceUpdate !== undefined && object.priceUpdate !== null ? StreamPriceUpdate.fromPartial(object.priceUpdate) : undefined;
return message;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { StreamOrderbookFill, StreamOrderbookFillSDKType, StreamOrderbookUpdate, StreamOrderbookUpdateSDKType } from "./query";
import { StreamSubaccountUpdate, StreamSubaccountUpdateSDKType } from "../subaccounts/streaming";
import { StreamPriceUpdate, StreamPriceUpdateSDKType } from "../prices/streaming";
import * as _m0 from "protobufjs/minimal";
import { DeepPartial } from "../../helpers";
/** StagedFinalizeBlockEvent is an event staged during `FinalizeBlock`. */
Expand All @@ -8,20 +9,23 @@ export interface StagedFinalizeBlockEvent {
orderFill?: StreamOrderbookFill;
subaccountUpdate?: StreamSubaccountUpdate;
orderbookUpdate?: StreamOrderbookUpdate;
priceUpdate?: StreamPriceUpdate;
}
/** StagedFinalizeBlockEvent is an event staged during `FinalizeBlock`. */

export interface StagedFinalizeBlockEventSDKType {
order_fill?: StreamOrderbookFillSDKType;
subaccount_update?: StreamSubaccountUpdateSDKType;
orderbook_update?: StreamOrderbookUpdateSDKType;
price_update?: StreamPriceUpdateSDKType;
}

function createBaseStagedFinalizeBlockEvent(): StagedFinalizeBlockEvent {
return {
orderFill: undefined,
subaccountUpdate: undefined,
orderbookUpdate: undefined
orderbookUpdate: undefined,
priceUpdate: undefined
};
}

Expand All @@ -39,6 +43,10 @@ export const StagedFinalizeBlockEvent = {
StreamOrderbookUpdate.encode(message.orderbookUpdate, writer.uint32(26).fork()).ldelim();
}

if (message.priceUpdate !== undefined) {
StreamPriceUpdate.encode(message.priceUpdate, writer.uint32(34).fork()).ldelim();
}

return writer;
},

Expand All @@ -63,6 +71,10 @@ export const StagedFinalizeBlockEvent = {
message.orderbookUpdate = StreamOrderbookUpdate.decode(reader, reader.uint32());
break;

case 4:
message.priceUpdate = StreamPriceUpdate.decode(reader, reader.uint32());
break;

default:
reader.skipType(tag & 7);
break;
Expand All @@ -77,6 +89,7 @@ export const StagedFinalizeBlockEvent = {
message.orderFill = object.orderFill !== undefined && object.orderFill !== null ? StreamOrderbookFill.fromPartial(object.orderFill) : undefined;
message.subaccountUpdate = object.subaccountUpdate !== undefined && object.subaccountUpdate !== null ? StreamSubaccountUpdate.fromPartial(object.subaccountUpdate) : undefined;
message.orderbookUpdate = object.orderbookUpdate !== undefined && object.orderbookUpdate !== null ? StreamOrderbookUpdate.fromPartial(object.orderbookUpdate) : undefined;
message.priceUpdate = object.priceUpdate !== undefined && object.priceUpdate !== null ? StreamPriceUpdate.fromPartial(object.priceUpdate) : undefined;
return message;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
import { MarketPrice, MarketPriceSDKType } from "./market_price";
import * as _m0 from "protobufjs/minimal";
import { DeepPartial } from "../../helpers";
/** StreamPriceUpdate provides information on a price update. */

export interface StreamPriceUpdate {
/** The `Id` of the `Market`. */
marketId: number;
/** The updated price. */

price?: MarketPrice;
/** Snapshot indicates if the response is from a snapshot of the price. */

snapshot: boolean;
}
/** StreamPriceUpdate provides information on a price update. */

export interface StreamPriceUpdateSDKType {
/** The `Id` of the `Market`. */
market_id: number;
/** The updated price. */

price?: MarketPriceSDKType;
/** Snapshot indicates if the response is from a snapshot of the price. */

snapshot: boolean;
}

function createBaseStreamPriceUpdate(): StreamPriceUpdate {
return {
marketId: 0,
price: undefined,
snapshot: false
};
}

export const StreamPriceUpdate = {
encode(message: StreamPriceUpdate, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer {
if (message.marketId !== 0) {
writer.uint32(8).uint32(message.marketId);
}

if (message.price !== undefined) {
MarketPrice.encode(message.price, writer.uint32(18).fork()).ldelim();
}

if (message.snapshot === true) {
writer.uint32(24).bool(message.snapshot);
}

return writer;
},

decode(input: _m0.Reader | Uint8Array, length?: number): StreamPriceUpdate {
const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input);
let end = length === undefined ? reader.len : reader.pos + length;
const message = createBaseStreamPriceUpdate();

while (reader.pos < end) {
const tag = reader.uint32();

switch (tag >>> 3) {
case 1:
message.marketId = reader.uint32();
break;

case 2:
message.price = MarketPrice.decode(reader, reader.uint32());
break;

case 3:
message.snapshot = reader.bool();
break;

default:
reader.skipType(tag & 7);
break;
}
}

return message;
},

fromPartial(object: DeepPartial<StreamPriceUpdate>): StreamPriceUpdate {
const message = createBaseStreamPriceUpdate();
message.marketId = object.marketId ?? 0;
message.price = object.price !== undefined && object.price !== null ? MarketPrice.fromPartial(object.price) : undefined;
message.snapshot = object.snapshot ?? false;
return message;
}

};
4 changes: 2 additions & 2 deletions indexer/packages/v4-protos/src/codegen/gogoproto/bundle.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
import * as _129 from "./gogo";
export const gogoproto = { ..._129
import * as _130 from "./gogo";
export const gogoproto = { ..._130
};
22 changes: 11 additions & 11 deletions indexer/packages/v4-protos/src/codegen/google/bundle.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
import * as _130 from "./api/annotations";
import * as _131 from "./api/http";
import * as _132 from "./protobuf/descriptor";
import * as _133 from "./protobuf/duration";
import * as _134 from "./protobuf/timestamp";
import * as _135 from "./protobuf/any";
import * as _131 from "./api/annotations";
import * as _132 from "./api/http";
import * as _133 from "./protobuf/descriptor";
import * as _134 from "./protobuf/duration";
import * as _135 from "./protobuf/timestamp";
import * as _136 from "./protobuf/any";
export namespace google {
export const api = { ..._130,
..._131
export const api = { ..._131,
..._132
};
export const protobuf = { ..._132,
..._133,
export const protobuf = { ..._133,
..._134,
..._135
..._135,
..._136
};
}
5 changes: 5 additions & 0 deletions proto/dydxprotocol/clob/query.proto
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import "dydxprotocol/clob/mev.proto";
import "dydxprotocol/indexer/off_chain_updates/off_chain_updates.proto";
import "dydxprotocol/subaccounts/streaming.proto";
import "dydxprotocol/subaccounts/subaccount.proto";
import "dydxprotocol/prices/streaming.proto";

option go_package = "github.com/dydxprotocol/v4-chain/protocol/x/clob/types";

Expand Down Expand Up @@ -170,6 +171,9 @@ message StreamOrderbookUpdatesRequest {

// Subaccount ids to stream subaccount updates for.
repeated dydxprotocol.subaccounts.SubaccountId subaccount_ids = 2;

// Market ids for price updates.
repeated uint32 market_ids = 3;
}

// StreamOrderbookUpdatesResponse is a response message for the
Expand All @@ -195,6 +199,7 @@ message StreamUpdate {
StreamOrderbookFill order_fill = 4;
StreamTakerOrder taker_order = 5;
dydxprotocol.subaccounts.StreamSubaccountUpdate subaccount_update = 6;
dydxprotocol.prices.StreamPriceUpdate price_update = 7;
}
}

Expand Down
2 changes: 2 additions & 0 deletions proto/dydxprotocol/clob/streaming.proto
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ syntax = "proto3";
package dydxprotocol.clob;

import "dydxprotocol/subaccounts/streaming.proto";
import "dydxprotocol/prices/streaming.proto";
import "dydxprotocol/clob/query.proto";

option go_package = "github.com/dydxprotocol/v4-chain/protocol/x/clob/types";
Expand All @@ -13,5 +14,6 @@ message StagedFinalizeBlockEvent {
StreamOrderbookFill order_fill = 1;
dydxprotocol.subaccounts.StreamSubaccountUpdate subaccount_update = 2;
StreamOrderbookUpdate orderbook_update = 3;
dydxprotocol.prices.StreamPriceUpdate price_update = 4;
}
}
19 changes: 19 additions & 0 deletions proto/dydxprotocol/prices/streaming.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
syntax = "proto3";
package dydxprotocol.prices;

import "gogoproto/gogo.proto";
import "dydxprotocol/prices/market_price.proto";

option go_package = "github.com/dydxprotocol/v4-chain/protocol/x/prices/types";

// StreamPriceUpdate provides information on a price update.
message StreamPriceUpdate {
// The `Id` of the `Market`.
uint32 market_id = 1;

// The updated price.
MarketPrice price = 2 [ (gogoproto.nullable) = false ];

// Snapshot indicates if the response is from a snapshot of the price.
bool snapshot = 3;
}
Loading

0 comments on commit e700de9

Please sign in to comment.