Skip to content

Commit

Permalink
add VaultParams protos and store (#2084)
Browse files Browse the repository at this point in the history
  • Loading branch information
tqin7 authored Aug 15, 2024
1 parent 635a62f commit 04197f4
Show file tree
Hide file tree
Showing 41 changed files with 1,268 additions and 592 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { QuotingParams, QuotingParamsSDKType } from "./params";
import { QuotingParams, QuotingParamsSDKType, VaultParams, VaultParamsSDKType } from "./params";
import { VaultId, VaultIdSDKType } from "./vault";
import { NumShares, NumSharesSDKType, OwnerShare, OwnerShareSDKType } from "./share";
import * as _m0 from "protobufjs/minimal";
Expand All @@ -21,7 +21,7 @@ export interface GenesisStateSDKType {

default_quoting_params?: QuotingParamsSDKType;
}
/** Vault defines the total shares and owner shares of a vault. */
/** Vault defines the state of a vault. */

export interface Vault {
/** The ID of the vault. */
Expand All @@ -32,14 +32,14 @@ export interface Vault {
/** The shares of each owner in the vault. */

ownerShares: OwnerShare[];
/** The quoting parameters of the vault. */
/** The parameters of the vault. */

quotingParams?: QuotingParams;
vaultParams?: VaultParams;
/** The client IDs of the most recently placed orders of the vault. */

mostRecentClientIds: number[];
}
/** Vault defines the total shares and owner shares of a vault. */
/** Vault defines the state of a vault. */

export interface VaultSDKType {
/** The ID of the vault. */
Expand All @@ -50,9 +50,9 @@ export interface VaultSDKType {
/** The shares of each owner in the vault. */

owner_shares: OwnerShareSDKType[];
/** The quoting parameters of the vault. */
/** The parameters of the vault. */

quoting_params?: QuotingParamsSDKType;
vault_params?: VaultParamsSDKType;
/** The client IDs of the most recently placed orders of the vault. */

most_recent_client_ids: number[];
Expand Down Expand Up @@ -118,7 +118,7 @@ function createBaseVault(): Vault {
vaultId: undefined,
totalShares: undefined,
ownerShares: [],
quotingParams: undefined,
vaultParams: undefined,
mostRecentClientIds: []
};
}
Expand All @@ -137,8 +137,8 @@ export const Vault = {
OwnerShare.encode(v!, writer.uint32(26).fork()).ldelim();
}

if (message.quotingParams !== undefined) {
QuotingParams.encode(message.quotingParams, writer.uint32(34).fork()).ldelim();
if (message.vaultParams !== undefined) {
VaultParams.encode(message.vaultParams, writer.uint32(34).fork()).ldelim();
}

writer.uint32(42).fork();
Expand Down Expand Up @@ -173,7 +173,7 @@ export const Vault = {
break;

case 4:
message.quotingParams = QuotingParams.decode(reader, reader.uint32());
message.vaultParams = VaultParams.decode(reader, reader.uint32());
break;

case 5:
Expand Down Expand Up @@ -203,7 +203,7 @@ export const Vault = {
message.vaultId = object.vaultId !== undefined && object.vaultId !== null ? VaultId.fromPartial(object.vaultId) : undefined;
message.totalShares = object.totalShares !== undefined && object.totalShares !== null ? NumShares.fromPartial(object.totalShares) : undefined;
message.ownerShares = object.ownerShares?.map(e => OwnerShare.fromPartial(e)) || [];
message.quotingParams = object.quotingParams !== undefined && object.quotingParams !== null ? QuotingParams.fromPartial(object.quotingParams) : undefined;
message.vaultParams = object.vaultParams !== undefined && object.vaultParams !== null ? VaultParams.fromPartial(object.vaultParams) : undefined;
message.mostRecentClientIds = object.mostRecentClientIds?.map(e => e) || [];
return message;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { VaultStatus, VaultStatusSDKType } from "./vault";
import * as _m0 from "protobufjs/minimal";
import { DeepPartial } from "../../helpers";
/** QuotingParams stores vault quoting parameters. */
Expand Down Expand Up @@ -72,6 +73,24 @@ export interface QuotingParamsSDKType {

activation_threshold_quote_quantums: Uint8Array;
}
/** VaultParams stores vault parameters. */

export interface VaultParams {
/** Status of the vault. */
status: VaultStatus;
/** Quoting parameters of the vault. */

quotingParams?: QuotingParams;
}
/** VaultParams stores vault parameters. */

export interface VaultParamsSDKType {
/** Status of the vault. */
status: VaultStatusSDKType;
/** Quoting parameters of the vault. */

quoting_params?: QuotingParamsSDKType;
}
/**
* Deprecated: Params stores `x/vault` parameters.
* Deprecated since v6.x as is replaced by QuotingParams.
Expand Down Expand Up @@ -256,6 +275,61 @@ export const QuotingParams = {

};

function createBaseVaultParams(): VaultParams {
return {
status: 0,
quotingParams: undefined
};
}

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

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

return writer;
},

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

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

switch (tag >>> 3) {
case 1:
message.status = (reader.int32() as any);
break;

case 2:
message.quotingParams = QuotingParams.decode(reader, reader.uint32());
break;

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

return message;
},

fromPartial(object: DeepPartial<VaultParams>): VaultParams {
const message = createBaseVaultParams();
message.status = object.status ?? 0;
message.quotingParams = object.quotingParams !== undefined && object.quotingParams !== null ? QuotingParams.fromPartial(object.quotingParams) : undefined;
return message;
}

};

function createBaseParams(): Params {
return {
layers: 0,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { VaultType, VaultTypeSDKType, VaultId, VaultIdSDKType } from "./vault";
import { PageRequest, PageRequestSDKType, PageResponse, PageResponseSDKType } from "../../cosmos/base/query/v1beta1/pagination";
import { Params, ParamsSDKType, QuotingParams, QuotingParamsSDKType } from "./params";
import { Params, ParamsSDKType, QuotingParams, QuotingParamsSDKType, VaultParams, VaultParamsSDKType } from "./params";
import { SubaccountId, SubaccountIdSDKType } from "../subaccounts/subaccount";
import { NumShares, NumSharesSDKType, OwnerShare, OwnerShareSDKType } from "./share";
import * as _m0 from "protobufjs/minimal";
Expand Down Expand Up @@ -49,7 +49,7 @@ export interface QueryVaultResponse {
equity: Uint8Array;
inventory: Uint8Array;
totalShares?: NumShares;
quotingParams?: QuotingParams;
vaultParams?: VaultParams;
}
/** QueryVaultResponse is a response type for the Vault RPC method. */

Expand All @@ -59,7 +59,7 @@ export interface QueryVaultResponseSDKType {
equity: Uint8Array;
inventory: Uint8Array;
total_shares?: NumSharesSDKType;
quoting_params?: QuotingParamsSDKType;
vault_params?: VaultParamsSDKType;
}
/** QueryAllVaultsRequest is a request type for the AllVaults RPC method. */

Expand Down Expand Up @@ -261,7 +261,7 @@ function createBaseQueryVaultResponse(): QueryVaultResponse {
equity: new Uint8Array(),
inventory: new Uint8Array(),
totalShares: undefined,
quotingParams: undefined
vaultParams: undefined
};
}

Expand All @@ -287,8 +287,8 @@ export const QueryVaultResponse = {
NumShares.encode(message.totalShares, writer.uint32(42).fork()).ldelim();
}

if (message.quotingParams !== undefined) {
QuotingParams.encode(message.quotingParams, writer.uint32(50).fork()).ldelim();
if (message.vaultParams !== undefined) {
VaultParams.encode(message.vaultParams, writer.uint32(50).fork()).ldelim();
}

return writer;
Expand Down Expand Up @@ -324,7 +324,7 @@ export const QueryVaultResponse = {
break;

case 6:
message.quotingParams = QuotingParams.decode(reader, reader.uint32());
message.vaultParams = VaultParams.decode(reader, reader.uint32());
break;

default:
Expand All @@ -343,7 +343,7 @@ export const QueryVaultResponse = {
message.equity = object.equity ?? new Uint8Array();
message.inventory = object.inventory ?? new Uint8Array();
message.totalShares = object.totalShares !== undefined && object.totalShares !== null ? NumShares.fromPartial(object.totalShares) : undefined;
message.quotingParams = object.quotingParams !== undefined && object.quotingParams !== null ? QuotingParams.fromPartial(object.quotingParams) : undefined;
message.vaultParams = object.vaultParams !== undefined && object.vaultParams !== null ? VaultParams.fromPartial(object.vaultParams) : undefined;
return message;
}

Expand Down
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 { MsgDepositToVault, MsgDepositToVaultResponse, MsgUpdateDefaultQuotingParams, MsgUpdateDefaultQuotingParamsResponse, MsgSetVaultQuotingParams, MsgSetVaultQuotingParamsResponse } from "./tx";
import { MsgDepositToVault, MsgDepositToVaultResponse, MsgUpdateDefaultQuotingParams, MsgUpdateDefaultQuotingParamsResponse, MsgSetVaultParams, MsgSetVaultParamsResponse } from "./tx";
/** Msg defines the Msg service. */

export interface Msg {
Expand All @@ -9,9 +9,9 @@ export interface Msg {
/** UpdateDefaultQuotingParams updates the default quoting params in state. */

updateDefaultQuotingParams(request: MsgUpdateDefaultQuotingParams): Promise<MsgUpdateDefaultQuotingParamsResponse>;
/** SetVaultQuotingParams sets the quoting parameters of a specific vault. */
/** SetVaultParams sets the parameters of a specific vault. */

setVaultQuotingParams(request: MsgSetVaultQuotingParams): Promise<MsgSetVaultQuotingParamsResponse>;
setVaultParams(request: MsgSetVaultParams): Promise<MsgSetVaultParamsResponse>;
}
export class MsgClientImpl implements Msg {
private readonly rpc: Rpc;
Expand All @@ -20,7 +20,7 @@ export class MsgClientImpl implements Msg {
this.rpc = rpc;
this.depositToVault = this.depositToVault.bind(this);
this.updateDefaultQuotingParams = this.updateDefaultQuotingParams.bind(this);
this.setVaultQuotingParams = this.setVaultQuotingParams.bind(this);
this.setVaultParams = this.setVaultParams.bind(this);
}

depositToVault(request: MsgDepositToVault): Promise<MsgDepositToVaultResponse> {
Expand All @@ -35,10 +35,10 @@ export class MsgClientImpl implements Msg {
return promise.then(data => MsgUpdateDefaultQuotingParamsResponse.decode(new _m0.Reader(data)));
}

setVaultQuotingParams(request: MsgSetVaultQuotingParams): Promise<MsgSetVaultQuotingParamsResponse> {
const data = MsgSetVaultQuotingParams.encode(request).finish();
const promise = this.rpc.request("dydxprotocol.vault.Msg", "SetVaultQuotingParams", data);
return promise.then(data => MsgSetVaultQuotingParamsResponse.decode(new _m0.Reader(data)));
setVaultParams(request: MsgSetVaultParams): Promise<MsgSetVaultParamsResponse> {
const data = MsgSetVaultParams.encode(request).finish();
const promise = this.rpc.request("dydxprotocol.vault.Msg", "SetVaultParams", data);
return promise.then(data => MsgSetVaultParamsResponse.decode(new _m0.Reader(data)));
}

}
Loading

0 comments on commit 04197f4

Please sign in to comment.