Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[CT-1320] proto for FNS price updates #2586

Merged
merged 3 commits into from
Nov 21, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
362 changes: 182 additions & 180 deletions indexer/packages/v4-protos/src/codegen/dydxprotocol/bundle.ts

Large diffs are not rendered by default.

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
@@ -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;
Comment on lines +175 to +176
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

technically we can derive these from the clob pair ids, but i think this is slightly more flexible

}

// 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
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 {
Copy link
Contributor

@teddyding teddyding Nov 20, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need to add this to StagedFinalizeBlockEvent? We probably want price update streams to go through similar flows (store in transient store, stream in Precommit)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added!

// 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
Loading