Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,16 @@ export interface BlockRateLimitConfiguration {

maxShortTermOrderCancellationsPerNBlocks: MaxPerNBlocksRateLimit[];
maxShortTermOrdersAndCancelsPerNBlocks: MaxPerNBlocksRateLimit[];
/**
* How many leverage update attempts (successful and failed) are allowed for
* an account per N blocks. Note that the rate limits are applied in an AND
* fashion such that a leverage update must pass all rate limit
* configurations.
*
* Specifying 0 values disables this rate limit.
*/

maxLeverageUpdatesPerNBlocks: MaxPerNBlocksRateLimit[];
}
/** Defines the block rate limits for CLOB specific operations. */

Expand Down Expand Up @@ -61,6 +71,16 @@ export interface BlockRateLimitConfigurationSDKType {

max_short_term_order_cancellations_per_n_blocks: MaxPerNBlocksRateLimitSDKType[];
max_short_term_orders_and_cancels_per_n_blocks: MaxPerNBlocksRateLimitSDKType[];
/**
* How many leverage update attempts (successful and failed) are allowed for
* an account per N blocks. Note that the rate limits are applied in an AND
* fashion such that a leverage update must pass all rate limit
* configurations.
*
* Specifying 0 values disables this rate limit.
*/

max_leverage_updates_per_n_blocks: MaxPerNBlocksRateLimitSDKType[];
}
/** Defines a rate limit over a specific number of blocks. */

Expand Down Expand Up @@ -98,7 +118,8 @@ function createBaseBlockRateLimitConfiguration(): BlockRateLimitConfiguration {
maxShortTermOrdersPerNBlocks: [],
maxStatefulOrdersPerNBlocks: [],
maxShortTermOrderCancellationsPerNBlocks: [],
maxShortTermOrdersAndCancelsPerNBlocks: []
maxShortTermOrdersAndCancelsPerNBlocks: [],
maxLeverageUpdatesPerNBlocks: []
};
}

Expand All @@ -120,6 +141,10 @@ export const BlockRateLimitConfiguration = {
MaxPerNBlocksRateLimit.encode(v!, writer.uint32(34).fork()).ldelim();
}

for (const v of message.maxLeverageUpdatesPerNBlocks) {
MaxPerNBlocksRateLimit.encode(v!, writer.uint32(42).fork()).ldelim();
}

return writer;
},

Expand Down Expand Up @@ -148,6 +173,10 @@ export const BlockRateLimitConfiguration = {
message.maxShortTermOrdersAndCancelsPerNBlocks.push(MaxPerNBlocksRateLimit.decode(reader, reader.uint32()));
break;

case 5:
message.maxLeverageUpdatesPerNBlocks.push(MaxPerNBlocksRateLimit.decode(reader, reader.uint32()));
break;

default:
reader.skipType(tag & 7);
break;
Expand All @@ -163,6 +192,7 @@ export const BlockRateLimitConfiguration = {
message.maxStatefulOrdersPerNBlocks = object.maxStatefulOrdersPerNBlocks?.map(e => MaxPerNBlocksRateLimit.fromPartial(e)) || [];
message.maxShortTermOrderCancellationsPerNBlocks = object.maxShortTermOrderCancellationsPerNBlocks?.map(e => MaxPerNBlocksRateLimit.fromPartial(e)) || [];
message.maxShortTermOrdersAndCancelsPerNBlocks = object.maxShortTermOrdersAndCancelsPerNBlocks?.map(e => MaxPerNBlocksRateLimit.fromPartial(e)) || [];
message.maxLeverageUpdatesPerNBlocks = object.maxLeverageUpdatesPerNBlocks?.map(e => MaxPerNBlocksRateLimit.fromPartial(e)) || [];
return message;
}

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 { QueryGetClobPairRequest, QueryClobPairResponseSDKType, QueryAllClobPairRequest, QueryClobPairAllResponseSDKType, QueryEquityTierLimitConfigurationRequest, QueryEquityTierLimitConfigurationResponseSDKType, QueryBlockRateLimitConfigurationRequest, QueryBlockRateLimitConfigurationResponseSDKType, QueryLiquidationsConfigurationRequest, QueryLiquidationsConfigurationResponseSDKType, QueryNextClobPairIdRequest, QueryNextClobPairIdResponseSDKType } from "./query";
import { QueryGetClobPairRequest, QueryClobPairResponseSDKType, QueryAllClobPairRequest, QueryClobPairAllResponseSDKType, QueryEquityTierLimitConfigurationRequest, QueryEquityTierLimitConfigurationResponseSDKType, QueryBlockRateLimitConfigurationRequest, QueryBlockRateLimitConfigurationResponseSDKType, QueryLiquidationsConfigurationRequest, QueryLiquidationsConfigurationResponseSDKType, QueryNextClobPairIdRequest, QueryNextClobPairIdResponseSDKType, QueryLeverageRequest, QueryLeverageResponseSDKType } from "./query";
export class LCDQueryClient {
req: LCDClient;

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

Expand Down Expand Up @@ -69,5 +70,12 @@ export class LCDQueryClient {
const endpoint = `dydxprotocol/clob/next_clob_pair_id`;
return await this.req.get<QueryNextClobPairIdResponseSDKType>(endpoint);
}
/* Queries leverage for a subaccount. */


async leverage(params: QueryLeverageRequest): Promise<QueryLeverageResponseSDKType> {
const endpoint = `dydxprotocol/clob/leverage/${params.owner}/${params.number}`;
return await this.req.get<QueryLeverageResponseSDKType>(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, QueryNextClobPairIdRequest, QueryNextClobPairIdResponse, StreamOrderbookUpdatesRequest, StreamOrderbookUpdatesResponse } from "./query";
import { QueryGetClobPairRequest, QueryClobPairResponse, QueryAllClobPairRequest, QueryClobPairAllResponse, MevNodeToNodeCalculationRequest, MevNodeToNodeCalculationResponse, QueryEquityTierLimitConfigurationRequest, QueryEquityTierLimitConfigurationResponse, QueryBlockRateLimitConfigurationRequest, QueryBlockRateLimitConfigurationResponse, QueryLiquidationsConfigurationRequest, QueryLiquidationsConfigurationResponse, QueryStatefulOrderRequest, QueryStatefulOrderResponse, QueryNextClobPairIdRequest, QueryNextClobPairIdResponse, QueryLeverageRequest, QueryLeverageResponse, StreamOrderbookUpdatesRequest, StreamOrderbookUpdatesResponse } from "./query";
/** Query defines the gRPC querier service. */

export interface Query {
Expand All @@ -28,6 +28,9 @@ export interface Query {
/** Queries the next clob pair id. */

nextClobPairId(request?: QueryNextClobPairIdRequest): Promise<QueryNextClobPairIdResponse>;
/** Queries leverage for a subaccount. */

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

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

leverage(request: QueryLeverageRequest): Promise<QueryLeverageResponse> {
const data = QueryLeverageRequest.encode(request).finish();
const promise = this.rpc.request("dydxprotocol.clob.Query", "Leverage", data);
return promise.then(data => QueryLeverageResponse.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 @@ -144,6 +154,10 @@ export const createRpcQueryExtension = (base: QueryClient) => {
return queryService.nextClobPairId(request);
},

leverage(request: QueryLeverageRequest): Promise<QueryLeverageResponse> {
return queryService.leverage(request);
},

streamOrderbookUpdates(request: StreamOrderbookUpdatesRequest): Promise<StreamOrderbookUpdatesResponse> {
return queryService.streamOrderbookUpdates(request);
}
Expand Down
203 changes: 203 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 @@ -264,6 +264,54 @@ export interface QueryNextClobPairIdResponseSDKType {
/** QueryNextClobPairIdResponse is a response message for the next clob pair id */
next_clob_pair_id: number;
}
/** QueryLeverageRequest is a request message for Leverage. */

export interface QueryLeverageRequest {
/** The address of the wallet that owns the subaccount. */
owner: string;
/** The unique number of the subaccount for the owner. */

number: number;
}
/** QueryLeverageRequest is a request message for Leverage. */

export interface QueryLeverageRequestSDKType {
/** The address of the wallet that owns the subaccount. */
owner: string;
/** The unique number of the subaccount for the owner. */

number: number;
}
/** QueryLeverageResponse is a response message that contains the leverage map. */

export interface QueryLeverageResponse {
/** List of clob pair leverage settings. */
clobPairLeverage: ClobPairLeverageInfo[];
}
/** QueryLeverageResponse is a response message that contains the leverage map. */

export interface QueryLeverageResponseSDKType {
/** List of clob pair leverage settings. */
clob_pair_leverage: ClobPairLeverageInfoSDKType[];
}
/** ClobPairLeverageInfo represents the leverage setting for a single clob pair. */

export interface ClobPairLeverageInfo {
/** The clob pair ID. */
clobPairId: number;
/** The leverage amount. */

leverage: number;
}
/** ClobPairLeverageInfo represents the leverage setting for a single clob pair. */

export interface ClobPairLeverageInfoSDKType {
/** The clob pair ID. */
clob_pair_id: number;
/** The leverage amount. */

leverage: number;
}
/**
* StreamOrderbookUpdatesRequest is a request message for the
* StreamOrderbookUpdates method.
Expand Down Expand Up @@ -1308,6 +1356,161 @@ export const QueryNextClobPairIdResponse = {

};

function createBaseQueryLeverageRequest(): QueryLeverageRequest {
return {
owner: "",
number: 0
};
}

export const QueryLeverageRequest = {
encode(message: QueryLeverageRequest, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer {
if (message.owner !== "") {
writer.uint32(10).string(message.owner);
}

if (message.number !== 0) {
writer.uint32(16).uint32(message.number);
}

return writer;
},

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

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

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

case 2:
message.number = reader.uint32();
break;

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

return message;
},

fromPartial(object: DeepPartial<QueryLeverageRequest>): QueryLeverageRequest {
const message = createBaseQueryLeverageRequest();
message.owner = object.owner ?? "";
message.number = object.number ?? 0;
return message;
}

};

function createBaseQueryLeverageResponse(): QueryLeverageResponse {
return {
clobPairLeverage: []
};
}

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

return writer;
},

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

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

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

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

return message;
},

fromPartial(object: DeepPartial<QueryLeverageResponse>): QueryLeverageResponse {
const message = createBaseQueryLeverageResponse();
message.clobPairLeverage = object.clobPairLeverage?.map(e => ClobPairLeverageInfo.fromPartial(e)) || [];
return message;
}

};

function createBaseClobPairLeverageInfo(): ClobPairLeverageInfo {
return {
clobPairId: 0,
leverage: 0
};
}

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

if (message.leverage !== 0) {
writer.uint32(16).uint32(message.leverage);
}

return writer;
},

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

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

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

case 2:
message.leverage = reader.uint32();
break;

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

return message;
},

fromPartial(object: DeepPartial<ClobPairLeverageInfo>): ClobPairLeverageInfo {
const message = createBaseClobPairLeverageInfo();
message.clobPairId = object.clobPairId ?? 0;
message.leverage = object.leverage ?? 0;
return message;
}

};

function createBaseStreamOrderbookUpdatesRequest(): StreamOrderbookUpdatesRequest {
return {
clobPairId: [],
Expand Down
Loading
Loading