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

[CORE-700] - P1 clob queries for existing StatefulOrder keeper methods #676

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
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
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 } from "./query";
import { QueryGetClobPairRequest, QueryClobPairResponseSDKType, QueryAllClobPairRequest, QueryClobPairAllResponseSDKType, QueryEquityTierLimitConfigurationRequest, QueryEquityTierLimitConfigurationResponseSDKType, QueryAllStatefulOrdersRequest, QueryAllStatefulOrdersResponseSDKType } from "./query";
export class LCDQueryClient {
req: LCDClient;

Expand All @@ -13,6 +13,7 @@ export class LCDQueryClient {
this.clobPair = this.clobPair.bind(this);
this.clobPairAll = this.clobPairAll.bind(this);
this.equityTierLimitConfiguration = this.equityTierLimitConfiguration.bind(this);
this.allStatefulOrders = this.allStatefulOrders.bind(this);
}
/* Queries a ClobPair by id. */

Expand Down Expand Up @@ -45,5 +46,22 @@ export class LCDQueryClient {
const endpoint = `dydxprotocol/clob/equity_tier`;
return await this.req.get<QueryEquityTierLimitConfigurationResponseSDKType>(endpoint);
}
/* Queries all stateful orders. */


async allStatefulOrders(params: QueryAllStatefulOrdersRequest = {
pagination: undefined
}): Promise<QueryAllStatefulOrdersResponseSDKType> {
const options: any = {
params: {}
};

if (typeof params?.pagination !== "undefined") {
setPaginationParams(options, params.pagination);
}

const endpoint = `dydxprotocol/clob/orders/stateful`;
return await this.req.get<QueryAllStatefulOrdersResponseSDKType>(endpoint, options);
}

}
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, AreSubaccountsLiquidatableRequest, AreSubaccountsLiquidatableResponse, MevNodeToNodeCalculationRequest, MevNodeToNodeCalculationResponse, QueryEquityTierLimitConfigurationRequest, QueryEquityTierLimitConfigurationResponse } from "./query";
import { QueryGetClobPairRequest, QueryClobPairResponse, QueryAllClobPairRequest, QueryClobPairAllResponse, AreSubaccountsLiquidatableRequest, AreSubaccountsLiquidatableResponse, MevNodeToNodeCalculationRequest, MevNodeToNodeCalculationResponse, QueryEquityTierLimitConfigurationRequest, QueryEquityTierLimitConfigurationResponse, QueryAllStatefulOrdersRequest, QueryAllStatefulOrdersResponse, QueryStatefulOrderCountRequest, QueryStatefulOrderCountResponse } from "./query";
/** Query defines the gRPC querier service. */

export interface Query {
Expand All @@ -19,6 +19,12 @@ export interface Query {
/** Queries EquityTierLimitConfiguration. */

equityTierLimitConfiguration(request?: QueryEquityTierLimitConfigurationRequest): Promise<QueryEquityTierLimitConfigurationResponse>;
/** Queries all stateful orders. */

allStatefulOrders(request?: QueryAllStatefulOrdersRequest): Promise<QueryAllStatefulOrdersResponse>;
/** Queries the count of all stateful orders. */

statefulOrderCount(request: QueryStatefulOrderCountRequest): Promise<QueryStatefulOrderCountResponse>;
}
export class QueryClientImpl implements Query {
private readonly rpc: Rpc;
Expand All @@ -30,6 +36,8 @@ export class QueryClientImpl implements Query {
this.areSubaccountsLiquidatable = this.areSubaccountsLiquidatable.bind(this);
this.mevNodeToNodeCalculation = this.mevNodeToNodeCalculation.bind(this);
this.equityTierLimitConfiguration = this.equityTierLimitConfiguration.bind(this);
this.allStatefulOrders = this.allStatefulOrders.bind(this);
this.statefulOrderCount = this.statefulOrderCount.bind(this);
}

clobPair(request: QueryGetClobPairRequest): Promise<QueryClobPairResponse> {
Expand Down Expand Up @@ -64,6 +72,20 @@ export class QueryClientImpl implements Query {
return promise.then(data => QueryEquityTierLimitConfigurationResponse.decode(new _m0.Reader(data)));
}

allStatefulOrders(request: QueryAllStatefulOrdersRequest = {
pagination: undefined
}): Promise<QueryAllStatefulOrdersResponse> {
const data = QueryAllStatefulOrdersRequest.encode(request).finish();
const promise = this.rpc.request("dydxprotocol.clob.Query", "AllStatefulOrders", data);
return promise.then(data => QueryAllStatefulOrdersResponse.decode(new _m0.Reader(data)));
}

statefulOrderCount(request: QueryStatefulOrderCountRequest): Promise<QueryStatefulOrderCountResponse> {
const data = QueryStatefulOrderCountRequest.encode(request).finish();
const promise = this.rpc.request("dydxprotocol.clob.Query", "StatefulOrderCount", data);
return promise.then(data => QueryStatefulOrderCountResponse.decode(new _m0.Reader(data)));
}

}
export const createRpcQueryExtension = (base: QueryClient) => {
const rpc = createProtobufRpcClient(base);
Expand All @@ -87,6 +109,14 @@ export const createRpcQueryExtension = (base: QueryClient) => {

equityTierLimitConfiguration(request?: QueryEquityTierLimitConfigurationRequest): Promise<QueryEquityTierLimitConfigurationResponse> {
return queryService.equityTierLimitConfiguration(request);
},

allStatefulOrders(request?: QueryAllStatefulOrdersRequest): Promise<QueryAllStatefulOrdersResponse> {
return queryService.allStatefulOrders(request);
},

statefulOrderCount(request: QueryStatefulOrderCountRequest): Promise<QueryStatefulOrderCountResponse> {
return queryService.statefulOrderCount(request);
}

};
Expand Down
253 changes: 253 additions & 0 deletions indexer/packages/v4-protos/src/codegen/dydxprotocol/clob/query.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { SubaccountId, SubaccountIdSDKType } from "../subaccounts/subaccount";
import { ValidatorMevMatches, ValidatorMevMatchesSDKType, MevNodeToNodeMetrics, MevNodeToNodeMetricsSDKType } from "./mev";
import { ClobPair, ClobPairSDKType } from "./clob_pair";
import { EquityTierLimitConfiguration, EquityTierLimitConfigurationSDKType } from "./equity_tier_limit_config";
import { Order, OrderSDKType } from "./order";
import * as _m0 from "protobufjs/minimal";
import { DeepPartial, Long } from "../../helpers";
/** QueryGetClobPairRequest is request type for the ClobPair method. */
Expand Down Expand Up @@ -187,6 +188,68 @@ export interface QueryEquityTierLimitConfigurationResponse {
export interface QueryEquityTierLimitConfigurationResponseSDKType {
equity_tier_limit_config?: EquityTierLimitConfigurationSDKType;
}
/** QueryAllStatefulOrdersRequest is a request message for AllStatefulOrders. */

export interface QueryAllStatefulOrdersRequest {
pagination?: PageRequest;
}
/** QueryAllStatefulOrdersRequest is a request message for AllStatefulOrders. */

export interface QueryAllStatefulOrdersRequestSDKType {
pagination?: PageRequestSDKType;
}
/**
* QueryAllStateOrdersResponse is a response message that contains all stateful
* orders.
*/

export interface QueryAllStatefulOrdersResponse {
statefulOrders: Order[];
pagination?: PageResponse;
}
/**
* QueryAllStateOrdersResponse is a response message that contains all stateful
* orders.
*/

export interface QueryAllStatefulOrdersResponseSDKType {
stateful_orders: OrderSDKType[];
pagination?: PageResponseSDKType;
}
/** QueryStatefulOrderCountRequest is a request message for StatefulOrderCount. */

export interface QueryStatefulOrderCountRequest {
subaccountId?: SubaccountId;
}
/** QueryStatefulOrderCountRequest is a request message for StatefulOrderCount. */
clemire marked this conversation as resolved.
Show resolved Hide resolved

export interface QueryStatefulOrderCountRequestSDKType {
subaccount_id?: SubaccountIdSDKType;
}
/**
* QueryStatefulOrderCountResponse is a response message for StatefulOrderCount
* that contains the count of all stateful orders.
*/

export interface QueryStatefulOrderCountResponse {
/**
* QueryStatefulOrderCountResponse is a response message for StatefulOrderCount
* that contains the count of all stateful orders.
*/
count: number;
}
/**
* QueryStatefulOrderCountResponse is a response message for StatefulOrderCount
clemire marked this conversation as resolved.
Show resolved Hide resolved
* that contains the count of all stateful orders.
*/

export interface QueryStatefulOrderCountResponseSDKType {
/**
* QueryStatefulOrderCountResponse is a response message for StatefulOrderCount
* that contains the count of all stateful orders.
*/
clemire marked this conversation as resolved.
Show resolved Hide resolved
count: number;
}

function createBaseQueryGetClobPairRequest(): QueryGetClobPairRequest {
return {
Expand Down Expand Up @@ -765,4 +828,194 @@ export const QueryEquityTierLimitConfigurationResponse = {
return message;
}

};

function createBaseQueryAllStatefulOrdersRequest(): QueryAllStatefulOrdersRequest {
return {
pagination: undefined
};
}

export const QueryAllStatefulOrdersRequest = {
encode(message: QueryAllStatefulOrdersRequest, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer {
if (message.pagination !== undefined) {
PageRequest.encode(message.pagination, writer.uint32(10).fork()).ldelim();
}

return writer;
},

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

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

switch (tag >>> 3) {
case 1:
message.pagination = PageRequest.decode(reader, reader.uint32());
break;

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

return message;
},

fromPartial(object: DeepPartial<QueryAllStatefulOrdersRequest>): QueryAllStatefulOrdersRequest {
const message = createBaseQueryAllStatefulOrdersRequest();
message.pagination = object.pagination !== undefined && object.pagination !== null ? PageRequest.fromPartial(object.pagination) : undefined;
return message;
}

};

function createBaseQueryAllStatefulOrdersResponse(): QueryAllStatefulOrdersResponse {
return {
statefulOrders: [],
pagination: undefined
};
}

export const QueryAllStatefulOrdersResponse = {
encode(message: QueryAllStatefulOrdersResponse, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer {
for (const v of message.statefulOrders) {
Order.encode(v!, writer.uint32(10).fork()).ldelim();
}

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

return writer;
},

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

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

switch (tag >>> 3) {
case 1:
message.statefulOrders.push(Order.decode(reader, reader.uint32()));
break;

case 2:
message.pagination = PageResponse.decode(reader, reader.uint32());
break;

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

return message;
},

fromPartial(object: DeepPartial<QueryAllStatefulOrdersResponse>): QueryAllStatefulOrdersResponse {
const message = createBaseQueryAllStatefulOrdersResponse();
message.statefulOrders = object.statefulOrders?.map(e => Order.fromPartial(e)) || [];
message.pagination = object.pagination !== undefined && object.pagination !== null ? PageResponse.fromPartial(object.pagination) : undefined;
return message;
}

};

function createBaseQueryStatefulOrderCountRequest(): QueryStatefulOrderCountRequest {
return {
subaccountId: undefined
};
}

export const QueryStatefulOrderCountRequest = {
encode(message: QueryStatefulOrderCountRequest, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer {
if (message.subaccountId !== undefined) {
SubaccountId.encode(message.subaccountId, writer.uint32(10).fork()).ldelim();
}

return writer;
},

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

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

switch (tag >>> 3) {
case 1:
message.subaccountId = SubaccountId.decode(reader, reader.uint32());
break;

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

return message;
},

fromPartial(object: DeepPartial<QueryStatefulOrderCountRequest>): QueryStatefulOrderCountRequest {
const message = createBaseQueryStatefulOrderCountRequest();
message.subaccountId = object.subaccountId !== undefined && object.subaccountId !== null ? SubaccountId.fromPartial(object.subaccountId) : undefined;
return message;
}

};

function createBaseQueryStatefulOrderCountResponse(): QueryStatefulOrderCountResponse {
return {
count: 0
};
}

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

return writer;
},

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

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

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

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

return message;
},

fromPartial(object: DeepPartial<QueryStatefulOrderCountResponse>): QueryStatefulOrderCountResponse {
const message = createBaseQueryStatefulOrderCountResponse();
message.count = object.count ?? 0;
return message;
}

};
Loading
Loading