Skip to content

Commit

Permalink
[TRA-566] Add listing vault deposit params proto and msg (#2120)
Browse files Browse the repository at this point in the history
Signed-off-by: Shrenuj Bansal <[email protected]>
  • Loading branch information
shrenujb authored Aug 21, 2024
1 parent 3c13930 commit 637fa18
Show file tree
Hide file tree
Showing 31 changed files with 2,274 additions and 253 deletions.
370 changes: 187 additions & 183 deletions indexer/packages/v4-protos/src/codegen/dydxprotocol/bundle.ts

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions indexer/packages/v4-protos/src/codegen/dydxprotocol/lcd.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ export const createLCDClient = async ({
feetiers: new (await import("./feetiers/query.lcd")).LCDQueryClient({
requestClient
}),
listing: new (await import("./listing/query.lcd")).LCDQueryClient({
requestClient
}),
perpetuals: new (await import("./perpetuals/query.lcd")).LCDQueryClient({
requestClient
}),
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
import * as _m0 from "protobufjs/minimal";
import { DeepPartial } from "../../helpers";
/** ListingVaultDepositParams represents the params for PML megavault deposits */

export interface ListingVaultDepositParams {
/** Amount that will be deposited into the new market vault exclusively */
newVaultDepositAmount: Uint8Array;
/**
* Amount deposited into the main vault exclusively. This amount does not
* include the amount deposited into the new vault.
*/

mainVaultDepositAmount: Uint8Array;
/** Lockup period for this deposit */

numBlocksToLockShares: number;
}
/** ListingVaultDepositParams represents the params for PML megavault deposits */

export interface ListingVaultDepositParamsSDKType {
/** Amount that will be deposited into the new market vault exclusively */
new_vault_deposit_amount: Uint8Array;
/**
* Amount deposited into the main vault exclusively. This amount does not
* include the amount deposited into the new vault.
*/

main_vault_deposit_amount: Uint8Array;
/** Lockup period for this deposit */

num_blocks_to_lock_shares: number;
}

function createBaseListingVaultDepositParams(): ListingVaultDepositParams {
return {
newVaultDepositAmount: new Uint8Array(),
mainVaultDepositAmount: new Uint8Array(),
numBlocksToLockShares: 0
};
}

export const ListingVaultDepositParams = {
encode(message: ListingVaultDepositParams, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer {
if (message.newVaultDepositAmount.length !== 0) {
writer.uint32(10).bytes(message.newVaultDepositAmount);
}

if (message.mainVaultDepositAmount.length !== 0) {
writer.uint32(18).bytes(message.mainVaultDepositAmount);
}

if (message.numBlocksToLockShares !== 0) {
writer.uint32(24).uint32(message.numBlocksToLockShares);
}

return writer;
},

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

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

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

case 2:
message.mainVaultDepositAmount = reader.bytes();
break;

case 3:
message.numBlocksToLockShares = reader.uint32();
break;

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

return message;
},

fromPartial(object: DeepPartial<ListingVaultDepositParams>): ListingVaultDepositParams {
const message = createBaseListingVaultDepositParams();
message.newVaultDepositAmount = object.newVaultDepositAmount ?? new Uint8Array();
message.mainVaultDepositAmount = object.mainVaultDepositAmount ?? new Uint8Array();
message.numBlocksToLockShares = object.numBlocksToLockShares ?? 0;
return message;
}

};
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import { LCDClient } from "@osmonauts/lcd";
import { QueryListingVaultDepositParams, QueryListingVaultDepositParamsResponseSDKType } from "./query";
export class LCDQueryClient {
req: LCDClient;

constructor({
requestClient
}: {
requestClient: LCDClient;
}) {
this.req = requestClient;
this.listingVaultDepositParams = this.listingVaultDepositParams.bind(this);
}
/* Queries the listing vault deposit params */


async listingVaultDepositParams(_params: QueryListingVaultDepositParams = {}): Promise<QueryListingVaultDepositParamsResponseSDKType> {
const endpoint = `dydxprotocol/listing/vault_deposit_params`;
return await this.req.get<QueryListingVaultDepositParamsResponseSDKType>(endpoint);
}

}
Original file line number Diff line number Diff line change
@@ -1,19 +1,23 @@
import { Rpc } from "../../helpers";
import * as _m0 from "protobufjs/minimal";
import { QueryClient, createProtobufRpcClient } from "@cosmjs/stargate";
import { QueryMarketsHardCap, QueryMarketsHardCapResponse } from "./query";
import { QueryMarketsHardCap, QueryMarketsHardCapResponse, QueryListingVaultDepositParams, QueryListingVaultDepositParamsResponse } from "./query";
/** Query defines the gRPC querier service. */

export interface Query {
/** Queries for the hard cap number of listed markets */
marketsHardCap(request?: QueryMarketsHardCap): Promise<QueryMarketsHardCapResponse>;
/** Queries the listing vault deposit params */

listingVaultDepositParams(request?: QueryListingVaultDepositParams): Promise<QueryListingVaultDepositParamsResponse>;
}
export class QueryClientImpl implements Query {
private readonly rpc: Rpc;

constructor(rpc: Rpc) {
this.rpc = rpc;
this.marketsHardCap = this.marketsHardCap.bind(this);
this.listingVaultDepositParams = this.listingVaultDepositParams.bind(this);
}

marketsHardCap(request: QueryMarketsHardCap = {}): Promise<QueryMarketsHardCapResponse> {
Expand All @@ -22,13 +26,23 @@ export class QueryClientImpl implements Query {
return promise.then(data => QueryMarketsHardCapResponse.decode(new _m0.Reader(data)));
}

listingVaultDepositParams(request: QueryListingVaultDepositParams = {}): Promise<QueryListingVaultDepositParamsResponse> {
const data = QueryListingVaultDepositParams.encode(request).finish();
const promise = this.rpc.request("dydxprotocol.listing.Query", "ListingVaultDepositParams", data);
return promise.then(data => QueryListingVaultDepositParamsResponse.decode(new _m0.Reader(data)));
}

}
export const createRpcQueryExtension = (base: QueryClient) => {
const rpc = createProtobufRpcClient(base);
const queryService = new QueryClientImpl(rpc);
return {
marketsHardCap(request?: QueryMarketsHardCap): Promise<QueryMarketsHardCapResponse> {
return queryService.marketsHardCap(request);
},

listingVaultDepositParams(request?: QueryListingVaultDepositParams): Promise<QueryListingVaultDepositParamsResponse> {
return queryService.listingVaultDepositParams(request);
}

};
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { ListingVaultDepositParams, ListingVaultDepositParamsSDKType } from "./params";
import * as _m0 from "protobufjs/minimal";
import { DeepPartial } from "../../helpers";
/** Queries for the hard cap on listed markets */
Expand All @@ -18,6 +19,22 @@ export interface QueryMarketsHardCapResponseSDKType {
/** Response type indicating the hard cap on listed markets */
hard_cap: number;
}
/** Queries the listing vault deposit params */

export interface QueryListingVaultDepositParams {}
/** Queries the listing vault deposit params */

export interface QueryListingVaultDepositParamsSDKType {}
/** Response type for QueryListingVaultDepositParams */

export interface QueryListingVaultDepositParamsResponse {
params?: ListingVaultDepositParams;
}
/** Response type for QueryListingVaultDepositParams */

export interface QueryListingVaultDepositParamsResponseSDKType {
params?: ListingVaultDepositParamsSDKType;
}

function createBaseQueryMarketsHardCap(): QueryMarketsHardCap {
return {};
Expand Down Expand Up @@ -96,4 +113,83 @@ export const QueryMarketsHardCapResponse = {
return message;
}

};

function createBaseQueryListingVaultDepositParams(): QueryListingVaultDepositParams {
return {};
}

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

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

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

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

return message;
},

fromPartial(_: DeepPartial<QueryListingVaultDepositParams>): QueryListingVaultDepositParams {
const message = createBaseQueryListingVaultDepositParams();
return message;
}

};

function createBaseQueryListingVaultDepositParamsResponse(): QueryListingVaultDepositParamsResponse {
return {
params: undefined
};
}

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

return writer;
},

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

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

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

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

return message;
},

fromPartial(object: DeepPartial<QueryListingVaultDepositParamsResponse>): QueryListingVaultDepositParamsResponse {
const message = createBaseQueryListingVaultDepositParamsResponse();
message.params = object.params !== undefined && object.params !== null ? ListingVaultDepositParams.fromPartial(object.params) : undefined;
return message;
}

};
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Rpc } from "../../helpers";
import * as _m0 from "protobufjs/minimal";
import { MsgSetMarketsHardCap, MsgSetMarketsHardCapResponse, MsgCreateMarketPermissionless, MsgCreateMarketPermissionlessResponse } from "./tx";
import { MsgSetMarketsHardCap, MsgSetMarketsHardCapResponse, MsgCreateMarketPermissionless, MsgCreateMarketPermissionlessResponse, MsgSetListingVaultDepositParams, MsgSetListingVaultDepositParamsResponse } from "./tx";
/** Msg defines the Msg service. */

export interface Msg {
Expand All @@ -9,6 +9,9 @@ export interface Msg {
/** CreateMarketPermissionless creates a new market without going through x/gov */

createMarketPermissionless(request: MsgCreateMarketPermissionless): Promise<MsgCreateMarketPermissionlessResponse>;
/** SetListingVaultDepositParams sets PML megavault deposit params */

setListingVaultDepositParams(request: MsgSetListingVaultDepositParams): Promise<MsgSetListingVaultDepositParamsResponse>;
}
export class MsgClientImpl implements Msg {
private readonly rpc: Rpc;
Expand All @@ -17,6 +20,7 @@ export class MsgClientImpl implements Msg {
this.rpc = rpc;
this.setMarketsHardCap = this.setMarketsHardCap.bind(this);
this.createMarketPermissionless = this.createMarketPermissionless.bind(this);
this.setListingVaultDepositParams = this.setListingVaultDepositParams.bind(this);
}

setMarketsHardCap(request: MsgSetMarketsHardCap): Promise<MsgSetMarketsHardCapResponse> {
Expand All @@ -31,4 +35,10 @@ export class MsgClientImpl implements Msg {
return promise.then(data => MsgCreateMarketPermissionlessResponse.decode(new _m0.Reader(data)));
}

setListingVaultDepositParams(request: MsgSetListingVaultDepositParams): Promise<MsgSetListingVaultDepositParamsResponse> {
const data = MsgSetListingVaultDepositParams.encode(request).finish();
const promise = this.rpc.request("dydxprotocol.listing.Msg", "SetListingVaultDepositParams", data);
return promise.then(data => MsgSetListingVaultDepositParamsResponse.decode(new _m0.Reader(data)));
}

}
Loading

0 comments on commit 637fa18

Please sign in to comment.