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

[TRA-885] Upgrade handler to set market, perp and clob pair id to fixed number #2589

Merged
merged 15 commits into from
Nov 27, 2024
Merged
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { setPaginationParams } from "../../helpers";
import { LCDClient } from "@osmonauts/lcd";
import { QueryGetClobPairRequest, QueryClobPairResponseSDKType, QueryAllClobPairRequest, QueryClobPairAllResponseSDKType, QueryEquityTierLimitConfigurationRequest, QueryEquityTierLimitConfigurationResponseSDKType, QueryBlockRateLimitConfigurationRequest, QueryBlockRateLimitConfigurationResponseSDKType, QueryLiquidationsConfigurationRequest, QueryLiquidationsConfigurationResponseSDKType } from "./query";
import { QueryGetClobPairRequest, QueryClobPairResponseSDKType, QueryAllClobPairRequest, QueryClobPairAllResponseSDKType, QueryEquityTierLimitConfigurationRequest, QueryEquityTierLimitConfigurationResponseSDKType, QueryBlockRateLimitConfigurationRequest, QueryBlockRateLimitConfigurationResponseSDKType, QueryLiquidationsConfigurationRequest, QueryLiquidationsConfigurationResponseSDKType, QueryNextClobPairIdRequest, QueryNextClobPairIdResponseSDKType } from "./query";
export class LCDQueryClient {
req: LCDClient;

Expand All @@ -15,6 +15,7 @@ export class LCDQueryClient {
this.equityTierLimitConfiguration = this.equityTierLimitConfiguration.bind(this);
this.blockRateLimitConfiguration = this.blockRateLimitConfiguration.bind(this);
this.liquidationsConfiguration = this.liquidationsConfiguration.bind(this);
this.nextClobPairId = this.nextClobPairId.bind(this);
}
/* Queries a ClobPair by id. */

Expand Down Expand Up @@ -61,5 +62,12 @@ export class LCDQueryClient {
const endpoint = `dydxprotocol/clob/liquidations_config`;
return await this.req.get<QueryLiquidationsConfigurationResponseSDKType>(endpoint);
}
/* Queries the next clob pair id. */


async nextClobPairId(_params: QueryNextClobPairIdRequest = {}): Promise<QueryNextClobPairIdResponseSDKType> {
const endpoint = `dydxprotocol/clob/next_clob_pair_id`;
return await this.req.get<QueryNextClobPairIdResponseSDKType>(endpoint);
}

}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Rpc } from "../../helpers";
import * as _m0 from "protobufjs/minimal";
import { QueryClient, createProtobufRpcClient } from "@cosmjs/stargate";
import { QueryGetClobPairRequest, QueryClobPairResponse, QueryAllClobPairRequest, QueryClobPairAllResponse, MevNodeToNodeCalculationRequest, MevNodeToNodeCalculationResponse, QueryEquityTierLimitConfigurationRequest, QueryEquityTierLimitConfigurationResponse, QueryBlockRateLimitConfigurationRequest, QueryBlockRateLimitConfigurationResponse, QueryLiquidationsConfigurationRequest, QueryLiquidationsConfigurationResponse, QueryStatefulOrderRequest, QueryStatefulOrderResponse, StreamOrderbookUpdatesRequest, StreamOrderbookUpdatesResponse } from "./query";
import { QueryGetClobPairRequest, QueryClobPairResponse, QueryAllClobPairRequest, QueryClobPairAllResponse, MevNodeToNodeCalculationRequest, MevNodeToNodeCalculationResponse, QueryEquityTierLimitConfigurationRequest, QueryEquityTierLimitConfigurationResponse, QueryBlockRateLimitConfigurationRequest, QueryBlockRateLimitConfigurationResponse, QueryLiquidationsConfigurationRequest, QueryLiquidationsConfigurationResponse, QueryStatefulOrderRequest, QueryStatefulOrderResponse, QueryNextClobPairIdRequest, QueryNextClobPairIdResponse, StreamOrderbookUpdatesRequest, StreamOrderbookUpdatesResponse } from "./query";
/** Query defines the gRPC querier service. */

export interface Query {
Expand All @@ -25,6 +25,9 @@ export interface Query {
/** Queries the stateful order for a given order id. */

statefulOrder(request: QueryStatefulOrderRequest): Promise<QueryStatefulOrderResponse>;
/** Queries the next clob pair id. */

nextClobPairId(request?: QueryNextClobPairIdRequest): Promise<QueryNextClobPairIdResponse>;
/**
* Streams orderbook updates. Updates contain orderbook data
* such as order placements, updates, and fills.
Expand All @@ -44,6 +47,7 @@ export class QueryClientImpl implements Query {
this.blockRateLimitConfiguration = this.blockRateLimitConfiguration.bind(this);
this.liquidationsConfiguration = this.liquidationsConfiguration.bind(this);
this.statefulOrder = this.statefulOrder.bind(this);
this.nextClobPairId = this.nextClobPairId.bind(this);
this.streamOrderbookUpdates = this.streamOrderbookUpdates.bind(this);
}

Expand Down Expand Up @@ -91,6 +95,12 @@ export class QueryClientImpl implements Query {
return promise.then(data => QueryStatefulOrderResponse.decode(new _m0.Reader(data)));
}

nextClobPairId(request: QueryNextClobPairIdRequest = {}): Promise<QueryNextClobPairIdResponse> {
const data = QueryNextClobPairIdRequest.encode(request).finish();
const promise = this.rpc.request("dydxprotocol.clob.Query", "NextClobPairId", data);
return promise.then(data => QueryNextClobPairIdResponse.decode(new _m0.Reader(data)));
}

streamOrderbookUpdates(request: StreamOrderbookUpdatesRequest): Promise<StreamOrderbookUpdatesResponse> {
const data = StreamOrderbookUpdatesRequest.encode(request).finish();
const promise = this.rpc.request("dydxprotocol.clob.Query", "StreamOrderbookUpdates", data);
Expand Down Expand Up @@ -130,6 +140,10 @@ export const createRpcQueryExtension = (base: QueryClient) => {
return queryService.statefulOrder(request);
},

nextClobPairId(request?: QueryNextClobPairIdRequest): Promise<QueryNextClobPairIdResponse> {
return queryService.nextClobPairId(request);
},

streamOrderbookUpdates(request: StreamOrderbookUpdatesRequest): Promise<StreamOrderbookUpdatesResponse> {
return queryService.streamOrderbookUpdates(request);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,24 @@ export interface QueryLiquidationsConfigurationResponse {
export interface QueryLiquidationsConfigurationResponseSDKType {
liquidations_config?: LiquidationsConfigSDKType;
}
/** QueryNextClobPairIdRequest is a request message for the next clob pair id */

export interface QueryNextClobPairIdRequest {}
/** QueryNextClobPairIdRequest is a request message for the next clob pair id */

export interface QueryNextClobPairIdRequestSDKType {}
/** QueryNextClobPairIdResponse is a response message for the next clob pair id */

export interface QueryNextClobPairIdResponse {
/** QueryNextClobPairIdResponse is a response message for the next clob pair id */
nextClobPairId: number;
}
/** QueryNextClobPairIdResponse is a response message for the next clob pair id */

export interface QueryNextClobPairIdResponseSDKType {
/** QueryNextClobPairIdResponse is a response message for the next clob pair id */
next_clob_pair_id: number;
}
/**
* StreamOrderbookUpdatesRequest is a request message for the
* StreamOrderbookUpdates method.
Expand Down Expand Up @@ -1197,6 +1215,85 @@ export const QueryLiquidationsConfigurationResponse = {

};

function createBaseQueryNextClobPairIdRequest(): QueryNextClobPairIdRequest {
return {};
}

export const QueryNextClobPairIdRequest = {
encode(_: QueryNextClobPairIdRequest, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer {
return writer;
},

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

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

switch (tag >>> 3) {
default:
reader.skipType(tag & 7);
break;
}
}

return message;
},

fromPartial(_: DeepPartial<QueryNextClobPairIdRequest>): QueryNextClobPairIdRequest {
const message = createBaseQueryNextClobPairIdRequest();
return message;
}

};

function createBaseQueryNextClobPairIdResponse(): QueryNextClobPairIdResponse {
return {
nextClobPairId: 0
};
}

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

return writer;
},

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

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

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

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

return message;
},

fromPartial(object: DeepPartial<QueryNextClobPairIdResponse>): QueryNextClobPairIdResponse {
const message = createBaseQueryNextClobPairIdResponse();
message.nextClobPairId = object.nextClobPairId ?? 0;
return message;
}

};

function createBaseStreamOrderbookUpdatesRequest(): StreamOrderbookUpdatesRequest {
return {
clobPairId: [],
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { setPaginationParams } from "../../helpers";
import { LCDClient } from "@osmonauts/lcd";
import { QueryPerpetualRequest, QueryPerpetualResponseSDKType, QueryAllPerpetualsRequest, QueryAllPerpetualsResponseSDKType, QueryAllLiquidityTiersRequest, QueryAllLiquidityTiersResponseSDKType, QueryPremiumVotesRequest, QueryPremiumVotesResponseSDKType, QueryPremiumSamplesRequest, QueryPremiumSamplesResponseSDKType, QueryParamsRequest, QueryParamsResponseSDKType } from "./query";
import { QueryPerpetualRequest, QueryPerpetualResponseSDKType, QueryAllPerpetualsRequest, QueryAllPerpetualsResponseSDKType, QueryAllLiquidityTiersRequest, QueryAllLiquidityTiersResponseSDKType, QueryPremiumVotesRequest, QueryPremiumVotesResponseSDKType, QueryPremiumSamplesRequest, QueryPremiumSamplesResponseSDKType, QueryParamsRequest, QueryParamsResponseSDKType, QueryNextPerpetualIdRequest, QueryNextPerpetualIdResponseSDKType } from "./query";
export class LCDQueryClient {
req: LCDClient;

Expand All @@ -16,6 +16,7 @@ export class LCDQueryClient {
this.premiumVotes = this.premiumVotes.bind(this);
this.premiumSamples = this.premiumSamples.bind(this);
this.params = this.params.bind(this);
this.nextPerpetualId = this.nextPerpetualId.bind(this);
}
/* Queries a Perpetual by id. */

Expand Down Expand Up @@ -79,5 +80,12 @@ export class LCDQueryClient {
const endpoint = `dydxprotocol/perpetuals/params`;
return await this.req.get<QueryParamsResponseSDKType>(endpoint);
}
/* Queries the next perpetual id. */


async nextPerpetualId(_params: QueryNextPerpetualIdRequest = {}): Promise<QueryNextPerpetualIdResponseSDKType> {
const endpoint = `dydxprotocol/perpetuals/next_perpetual_id`;
shrenujb marked this conversation as resolved.
Show resolved Hide resolved
return await this.req.get<QueryNextPerpetualIdResponseSDKType>(endpoint);
}

}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Rpc } from "../../helpers";
import * as _m0 from "protobufjs/minimal";
import { QueryClient, createProtobufRpcClient } from "@cosmjs/stargate";
import { QueryPerpetualRequest, QueryPerpetualResponse, QueryAllPerpetualsRequest, QueryAllPerpetualsResponse, QueryAllLiquidityTiersRequest, QueryAllLiquidityTiersResponse, QueryPremiumVotesRequest, QueryPremiumVotesResponse, QueryPremiumSamplesRequest, QueryPremiumSamplesResponse, QueryParamsRequest, QueryParamsResponse } from "./query";
import { QueryPerpetualRequest, QueryPerpetualResponse, QueryAllPerpetualsRequest, QueryAllPerpetualsResponse, QueryAllLiquidityTiersRequest, QueryAllLiquidityTiersResponse, QueryPremiumVotesRequest, QueryPremiumVotesResponse, QueryPremiumSamplesRequest, QueryPremiumSamplesResponse, QueryParamsRequest, QueryParamsResponse, QueryNextPerpetualIdRequest, QueryNextPerpetualIdResponse } from "./query";
/** Query defines the gRPC querier service. */

export interface Query {
Expand All @@ -22,6 +22,9 @@ export interface Query {
/** Queries the perpetual params. */

params(request?: QueryParamsRequest): Promise<QueryParamsResponse>;
/** Queries the next perpetual id. */

nextPerpetualId(request?: QueryNextPerpetualIdRequest): Promise<QueryNextPerpetualIdResponse>;
}
export class QueryClientImpl implements Query {
private readonly rpc: Rpc;
Expand All @@ -34,6 +37,7 @@ export class QueryClientImpl implements Query {
this.premiumVotes = this.premiumVotes.bind(this);
this.premiumSamples = this.premiumSamples.bind(this);
this.params = this.params.bind(this);
this.nextPerpetualId = this.nextPerpetualId.bind(this);
}

perpetual(request: QueryPerpetualRequest): Promise<QueryPerpetualResponse> {
Expand Down Expand Up @@ -76,6 +80,12 @@ export class QueryClientImpl implements Query {
return promise.then(data => QueryParamsResponse.decode(new _m0.Reader(data)));
}

nextPerpetualId(request: QueryNextPerpetualIdRequest = {}): Promise<QueryNextPerpetualIdResponse> {
const data = QueryNextPerpetualIdRequest.encode(request).finish();
const promise = this.rpc.request("dydxprotocol.perpetuals.Query", "NextPerpetualId", data);
return promise.then(data => QueryNextPerpetualIdResponse.decode(new _m0.Reader(data)));
}

}
export const createRpcQueryExtension = (base: QueryClient) => {
const rpc = createProtobufRpcClient(base);
Expand Down Expand Up @@ -103,6 +113,10 @@ export const createRpcQueryExtension = (base: QueryClient) => {

params(request?: QueryParamsRequest): Promise<QueryParamsResponse> {
return queryService.params(request);
},

nextPerpetualId(request?: QueryNextPerpetualIdRequest): Promise<QueryNextPerpetualIdResponse> {
return queryService.nextPerpetualId(request);
}

};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,24 @@ export interface QueryParamsResponse {
export interface QueryParamsResponseSDKType {
params?: ParamsSDKType;
}
/** QueryNextPerpetualIdRequest is the request type for the NextPerpetualId RPC */

export interface QueryNextPerpetualIdRequest {}
/** QueryNextPerpetualIdRequest is the request type for the NextPerpetualId RPC */

export interface QueryNextPerpetualIdRequestSDKType {}
/** QueryNextPerpetualIdResponse is the response type for the NextPerpetualId RPC */

export interface QueryNextPerpetualIdResponse {
/** QueryNextPerpetualIdResponse is the response type for the NextPerpetualId RPC */
nextPerpetualId: number;
}
/** QueryNextPerpetualIdResponse is the response type for the NextPerpetualId RPC */

export interface QueryNextPerpetualIdResponseSDKType {
/** QueryNextPerpetualIdResponse is the response type for the NextPerpetualId RPC */
next_perpetual_id: number;
}

function createBaseQueryPerpetualRequest(): QueryPerpetualRequest {
return {
Expand Down Expand Up @@ -667,4 +685,83 @@ export const QueryParamsResponse = {
return message;
}

};

function createBaseQueryNextPerpetualIdRequest(): QueryNextPerpetualIdRequest {
return {};
}

export const QueryNextPerpetualIdRequest = {
encode(_: QueryNextPerpetualIdRequest, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer {
return writer;
},

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

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

switch (tag >>> 3) {
default:
reader.skipType(tag & 7);
break;
}
}

return message;
},

fromPartial(_: DeepPartial<QueryNextPerpetualIdRequest>): QueryNextPerpetualIdRequest {
const message = createBaseQueryNextPerpetualIdRequest();
return message;
}

};

function createBaseQueryNextPerpetualIdResponse(): QueryNextPerpetualIdResponse {
return {
nextPerpetualId: 0
};
}

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

return writer;
},

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

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

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

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

return message;
},

fromPartial(object: DeepPartial<QueryNextPerpetualIdResponse>): QueryNextPerpetualIdResponse {
const message = createBaseQueryNextPerpetualIdResponse();
message.nextPerpetualId = object.nextPerpetualId ?? 0;
return message;
}

};
Loading
Loading