From 04197f438bafb027a943f514f02dcfd043be7452 Mon Sep 17 00:00:00 2001 From: Tian Date: Thu, 15 Aug 2024 15:13:27 -0400 Subject: [PATCH] add VaultParams protos and store (#2084) --- .../src/codegen/dydxprotocol/vault/genesis.ts | 24 +- .../src/codegen/dydxprotocol/vault/params.ts | 74 +++++ .../src/codegen/dydxprotocol/vault/query.ts | 16 +- .../codegen/dydxprotocol/vault/tx.rpc.msg.ts | 16 +- .../src/codegen/dydxprotocol/vault/tx.ts | 74 +++-- .../src/codegen/dydxprotocol/vault/vault.ts | 88 ++++++ proto/dydxprotocol/vault/genesis.proto | 6 +- proto/dydxprotocol/vault/params.proto | 9 + proto/dydxprotocol/vault/query.proto | 2 +- proto/dydxprotocol/vault/tx.proto | 20 +- proto/dydxprotocol/vault/vault.proto | 18 ++ protocol/app/msgs/all_msgs.go | 4 +- protocol/app/msgs/internal_msgs.go | 4 +- protocol/app/msgs/internal_msgs_test.go | 4 +- protocol/lib/ante/internal_msg.go | 2 +- protocol/testing/genesis.sh | 2 + protocol/testutil/constants/vault.go | 13 + protocol/x/vault/genesis.go | 6 +- protocol/x/vault/keeper/grpc_query_vault.go | 19 +- .../x/vault/keeper/grpc_query_vault_test.go | 55 ++-- .../keeper/msg_server_deposit_to_vault.go | 11 + .../msg_server_deposit_to_vault_test.go | 10 + ...rams.go => msg_server_set_vault_params.go} | 18 +- .../msg_server_set_vault_params_test.go | 109 +++++++ ...sg_server_set_vault_quoting_params_test.go | 97 ------ protocol/x/vault/keeper/orders.go | 31 +- protocol/x/vault/keeper/orders_test.go | 28 +- protocol/x/vault/keeper/params.go | 50 +++- protocol/x/vault/keeper/params_test.go | 133 ++++++--- protocol/x/vault/keeper/vault.go | 13 +- protocol/x/vault/keeper/vault_test.go | 31 +- protocol/x/vault/types/errors.go | 10 + protocol/x/vault/types/genesis.go | 6 +- protocol/x/vault/types/genesis.pb.go | 97 +++--- protocol/x/vault/types/keys.go | 6 +- protocol/x/vault/types/params.go | 16 + protocol/x/vault/types/params.pb.go | 277 ++++++++++++++++-- protocol/x/vault/types/params_test.go | 44 +++ protocol/x/vault/types/query.pb.go | 132 ++++----- protocol/x/vault/types/tx.pb.go | 226 +++++++------- protocol/x/vault/types/vault.pb.go | 59 +++- 41 files changed, 1268 insertions(+), 592 deletions(-) rename protocol/x/vault/keeper/{msg_server_set_vault_quoting_params.go => msg_server_set_vault_params.go} (52%) create mode 100644 protocol/x/vault/keeper/msg_server_set_vault_params_test.go delete mode 100644 protocol/x/vault/keeper/msg_server_set_vault_quoting_params_test.go diff --git a/indexer/packages/v4-protos/src/codegen/dydxprotocol/vault/genesis.ts b/indexer/packages/v4-protos/src/codegen/dydxprotocol/vault/genesis.ts index 9264ce2266..ad090e2073 100644 --- a/indexer/packages/v4-protos/src/codegen/dydxprotocol/vault/genesis.ts +++ b/indexer/packages/v4-protos/src/codegen/dydxprotocol/vault/genesis.ts @@ -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"; @@ -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. */ @@ -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. */ @@ -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[]; @@ -118,7 +118,7 @@ function createBaseVault(): Vault { vaultId: undefined, totalShares: undefined, ownerShares: [], - quotingParams: undefined, + vaultParams: undefined, mostRecentClientIds: [] }; } @@ -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(); @@ -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: @@ -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; } diff --git a/indexer/packages/v4-protos/src/codegen/dydxprotocol/vault/params.ts b/indexer/packages/v4-protos/src/codegen/dydxprotocol/vault/params.ts index 0ad91e5a20..0dd3919cda 100644 --- a/indexer/packages/v4-protos/src/codegen/dydxprotocol/vault/params.ts +++ b/indexer/packages/v4-protos/src/codegen/dydxprotocol/vault/params.ts @@ -1,3 +1,4 @@ +import { VaultStatus, VaultStatusSDKType } from "./vault"; import * as _m0 from "protobufjs/minimal"; import { DeepPartial } from "../../helpers"; /** QuotingParams stores vault quoting parameters. */ @@ -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. @@ -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 { + 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, diff --git a/indexer/packages/v4-protos/src/codegen/dydxprotocol/vault/query.ts b/indexer/packages/v4-protos/src/codegen/dydxprotocol/vault/query.ts index 7b58765fde..bf29a13e58 100644 --- a/indexer/packages/v4-protos/src/codegen/dydxprotocol/vault/query.ts +++ b/indexer/packages/v4-protos/src/codegen/dydxprotocol/vault/query.ts @@ -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"; @@ -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. */ @@ -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. */ @@ -261,7 +261,7 @@ function createBaseQueryVaultResponse(): QueryVaultResponse { equity: new Uint8Array(), inventory: new Uint8Array(), totalShares: undefined, - quotingParams: undefined + vaultParams: undefined }; } @@ -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; @@ -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: @@ -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; } diff --git a/indexer/packages/v4-protos/src/codegen/dydxprotocol/vault/tx.rpc.msg.ts b/indexer/packages/v4-protos/src/codegen/dydxprotocol/vault/tx.rpc.msg.ts index b207669872..d6f5ba4711 100644 --- a/indexer/packages/v4-protos/src/codegen/dydxprotocol/vault/tx.rpc.msg.ts +++ b/indexer/packages/v4-protos/src/codegen/dydxprotocol/vault/tx.rpc.msg.ts @@ -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 { @@ -9,9 +9,9 @@ export interface Msg { /** UpdateDefaultQuotingParams updates the default quoting params in state. */ updateDefaultQuotingParams(request: MsgUpdateDefaultQuotingParams): Promise; - /** SetVaultQuotingParams sets the quoting parameters of a specific vault. */ + /** SetVaultParams sets the parameters of a specific vault. */ - setVaultQuotingParams(request: MsgSetVaultQuotingParams): Promise; + setVaultParams(request: MsgSetVaultParams): Promise; } export class MsgClientImpl implements Msg { private readonly rpc: Rpc; @@ -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 { @@ -35,10 +35,10 @@ export class MsgClientImpl implements Msg { return promise.then(data => MsgUpdateDefaultQuotingParamsResponse.decode(new _m0.Reader(data))); } - setVaultQuotingParams(request: MsgSetVaultQuotingParams): Promise { - 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 { + 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))); } } \ No newline at end of file diff --git a/indexer/packages/v4-protos/src/codegen/dydxprotocol/vault/tx.ts b/indexer/packages/v4-protos/src/codegen/dydxprotocol/vault/tx.ts index 5c8470c4a2..e43b804a1f 100644 --- a/indexer/packages/v4-protos/src/codegen/dydxprotocol/vault/tx.ts +++ b/indexer/packages/v4-protos/src/codegen/dydxprotocol/vault/tx.ts @@ -1,6 +1,6 @@ import { VaultId, VaultIdSDKType } from "./vault"; import { SubaccountId, SubaccountIdSDKType } from "../subaccounts/subaccount"; -import { QuotingParams, QuotingParamsSDKType } from "./params"; +import { QuotingParams, QuotingParamsSDKType, VaultParams, VaultParamsSDKType } from "./params"; import * as _m0 from "protobufjs/minimal"; import { DeepPartial } from "../../helpers"; /** @@ -73,40 +73,34 @@ export interface MsgUpdateDefaultQuotingParamsResponse {} */ export interface MsgUpdateDefaultQuotingParamsResponseSDKType {} -/** MsgSetVaultQuotingParams is the Msg/SetVaultQuotingParams request type. */ +/** MsgSetVaultParams is the Msg/SetVaultParams request type. */ -export interface MsgSetVaultQuotingParams { +export interface MsgSetVaultParams { authority: string; - /** The vault to set quoting params of. */ + /** The vault to set params of. */ vaultId?: VaultId; - /** The quoting parameters to set. Each field must be set. */ + /** The parameters to set. */ - quotingParams?: QuotingParams; + vaultParams?: VaultParams; } -/** MsgSetVaultQuotingParams is the Msg/SetVaultQuotingParams request type. */ +/** MsgSetVaultParams is the Msg/SetVaultParams request type. */ -export interface MsgSetVaultQuotingParamsSDKType { +export interface MsgSetVaultParamsSDKType { authority: string; - /** The vault to set quoting params of. */ + /** The vault to set params of. */ vault_id?: VaultIdSDKType; - /** The quoting parameters to set. Each field must be set. */ + /** The parameters to set. */ - quoting_params?: QuotingParamsSDKType; + vault_params?: VaultParamsSDKType; } -/** - * MsgSetVaultQuotingParamsResponse is the Msg/SetVaultQuotingParams response - * type. - */ +/** MsgSetVaultParamsResponse is the Msg/SetVaultParams response type. */ -export interface MsgSetVaultQuotingParamsResponse {} -/** - * MsgSetVaultQuotingParamsResponse is the Msg/SetVaultQuotingParams response - * type. - */ +export interface MsgSetVaultParamsResponse {} +/** MsgSetVaultParamsResponse is the Msg/SetVaultParams response type. */ -export interface MsgSetVaultQuotingParamsResponseSDKType {} +export interface MsgSetVaultParamsResponseSDKType {} function createBaseMsgDepositToVault(): MsgDepositToVault { return { @@ -296,16 +290,16 @@ export const MsgUpdateDefaultQuotingParamsResponse = { }; -function createBaseMsgSetVaultQuotingParams(): MsgSetVaultQuotingParams { +function createBaseMsgSetVaultParams(): MsgSetVaultParams { return { authority: "", vaultId: undefined, - quotingParams: undefined + vaultParams: undefined }; } -export const MsgSetVaultQuotingParams = { - encode(message: MsgSetVaultQuotingParams, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { +export const MsgSetVaultParams = { + encode(message: MsgSetVaultParams, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { if (message.authority !== "") { writer.uint32(10).string(message.authority); } @@ -314,17 +308,17 @@ export const MsgSetVaultQuotingParams = { VaultId.encode(message.vaultId, writer.uint32(18).fork()).ldelim(); } - if (message.quotingParams !== undefined) { - QuotingParams.encode(message.quotingParams, writer.uint32(26).fork()).ldelim(); + if (message.vaultParams !== undefined) { + VaultParams.encode(message.vaultParams, writer.uint32(26).fork()).ldelim(); } return writer; }, - decode(input: _m0.Reader | Uint8Array, length?: number): MsgSetVaultQuotingParams { + decode(input: _m0.Reader | Uint8Array, length?: number): MsgSetVaultParams { const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); let end = length === undefined ? reader.len : reader.pos + length; - const message = createBaseMsgSetVaultQuotingParams(); + const message = createBaseMsgSetVaultParams(); while (reader.pos < end) { const tag = reader.uint32(); @@ -339,7 +333,7 @@ export const MsgSetVaultQuotingParams = { break; case 3: - message.quotingParams = QuotingParams.decode(reader, reader.uint32()); + message.vaultParams = VaultParams.decode(reader, reader.uint32()); break; default: @@ -351,29 +345,29 @@ export const MsgSetVaultQuotingParams = { return message; }, - fromPartial(object: DeepPartial): MsgSetVaultQuotingParams { - const message = createBaseMsgSetVaultQuotingParams(); + fromPartial(object: DeepPartial): MsgSetVaultParams { + const message = createBaseMsgSetVaultParams(); message.authority = object.authority ?? ""; message.vaultId = object.vaultId !== undefined && object.vaultId !== null ? VaultId.fromPartial(object.vaultId) : 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; } }; -function createBaseMsgSetVaultQuotingParamsResponse(): MsgSetVaultQuotingParamsResponse { +function createBaseMsgSetVaultParamsResponse(): MsgSetVaultParamsResponse { return {}; } -export const MsgSetVaultQuotingParamsResponse = { - encode(_: MsgSetVaultQuotingParamsResponse, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { +export const MsgSetVaultParamsResponse = { + encode(_: MsgSetVaultParamsResponse, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { return writer; }, - decode(input: _m0.Reader | Uint8Array, length?: number): MsgSetVaultQuotingParamsResponse { + decode(input: _m0.Reader | Uint8Array, length?: number): MsgSetVaultParamsResponse { const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); let end = length === undefined ? reader.len : reader.pos + length; - const message = createBaseMsgSetVaultQuotingParamsResponse(); + const message = createBaseMsgSetVaultParamsResponse(); while (reader.pos < end) { const tag = reader.uint32(); @@ -388,8 +382,8 @@ export const MsgSetVaultQuotingParamsResponse = { return message; }, - fromPartial(_: DeepPartial): MsgSetVaultQuotingParamsResponse { - const message = createBaseMsgSetVaultQuotingParamsResponse(); + fromPartial(_: DeepPartial): MsgSetVaultParamsResponse { + const message = createBaseMsgSetVaultParamsResponse(); return message; } diff --git a/indexer/packages/v4-protos/src/codegen/dydxprotocol/vault/vault.ts b/indexer/packages/v4-protos/src/codegen/dydxprotocol/vault/vault.ts index 631151db13..c12ef40159 100644 --- a/indexer/packages/v4-protos/src/codegen/dydxprotocol/vault/vault.ts +++ b/indexer/packages/v4-protos/src/codegen/dydxprotocol/vault/vault.ts @@ -49,6 +49,94 @@ export function vaultTypeToJSON(object: VaultType): string { return "UNRECOGNIZED"; } } +/** VaultStatus represents the status of a vault. */ + +export enum VaultStatus { + /** VAULT_STATUS_UNSPECIFIED - Default value, invalid and unused. */ + VAULT_STATUS_UNSPECIFIED = 0, + + /** VAULT_STATUS_DEACTIVATED - Don’t place orders. Does not count toward global vault balances. */ + VAULT_STATUS_DEACTIVATED = 1, + + /** VAULT_STATUS_STAND_BY - Don’t place orders. Does count towards global vault balances. */ + VAULT_STATUS_STAND_BY = 2, + + /** VAULT_STATUS_QUOTING - Places orders on both sides of the book. */ + VAULT_STATUS_QUOTING = 3, + + /** VAULT_STATUS_CLOSE_ONLY - Only place orders that close the position. */ + VAULT_STATUS_CLOSE_ONLY = 4, + UNRECOGNIZED = -1, +} +/** VaultStatus represents the status of a vault. */ + +export enum VaultStatusSDKType { + /** VAULT_STATUS_UNSPECIFIED - Default value, invalid and unused. */ + VAULT_STATUS_UNSPECIFIED = 0, + + /** VAULT_STATUS_DEACTIVATED - Don’t place orders. Does not count toward global vault balances. */ + VAULT_STATUS_DEACTIVATED = 1, + + /** VAULT_STATUS_STAND_BY - Don’t place orders. Does count towards global vault balances. */ + VAULT_STATUS_STAND_BY = 2, + + /** VAULT_STATUS_QUOTING - Places orders on both sides of the book. */ + VAULT_STATUS_QUOTING = 3, + + /** VAULT_STATUS_CLOSE_ONLY - Only place orders that close the position. */ + VAULT_STATUS_CLOSE_ONLY = 4, + UNRECOGNIZED = -1, +} +export function vaultStatusFromJSON(object: any): VaultStatus { + switch (object) { + case 0: + case "VAULT_STATUS_UNSPECIFIED": + return VaultStatus.VAULT_STATUS_UNSPECIFIED; + + case 1: + case "VAULT_STATUS_DEACTIVATED": + return VaultStatus.VAULT_STATUS_DEACTIVATED; + + case 2: + case "VAULT_STATUS_STAND_BY": + return VaultStatus.VAULT_STATUS_STAND_BY; + + case 3: + case "VAULT_STATUS_QUOTING": + return VaultStatus.VAULT_STATUS_QUOTING; + + case 4: + case "VAULT_STATUS_CLOSE_ONLY": + return VaultStatus.VAULT_STATUS_CLOSE_ONLY; + + case -1: + case "UNRECOGNIZED": + default: + return VaultStatus.UNRECOGNIZED; + } +} +export function vaultStatusToJSON(object: VaultStatus): string { + switch (object) { + case VaultStatus.VAULT_STATUS_UNSPECIFIED: + return "VAULT_STATUS_UNSPECIFIED"; + + case VaultStatus.VAULT_STATUS_DEACTIVATED: + return "VAULT_STATUS_DEACTIVATED"; + + case VaultStatus.VAULT_STATUS_STAND_BY: + return "VAULT_STATUS_STAND_BY"; + + case VaultStatus.VAULT_STATUS_QUOTING: + return "VAULT_STATUS_QUOTING"; + + case VaultStatus.VAULT_STATUS_CLOSE_ONLY: + return "VAULT_STATUS_CLOSE_ONLY"; + + case VaultStatus.UNRECOGNIZED: + default: + return "UNRECOGNIZED"; + } +} /** VaultId uniquely identifies a vault by its type and number. */ export interface VaultId { diff --git a/proto/dydxprotocol/vault/genesis.proto b/proto/dydxprotocol/vault/genesis.proto index 750fd8b84c..c92f545b6a 100644 --- a/proto/dydxprotocol/vault/genesis.proto +++ b/proto/dydxprotocol/vault/genesis.proto @@ -18,7 +18,7 @@ message GenesisState { QuotingParams default_quoting_params = 3 [ (gogoproto.nullable) = false ]; } -// Vault defines the total shares and owner shares of a vault. +// Vault defines the state of a vault. message Vault { // The ID of the vault. VaultId vault_id = 1; @@ -26,8 +26,8 @@ message Vault { NumShares total_shares = 2; // The shares of each owner in the vault. repeated OwnerShare owner_shares = 3; - // The quoting parameters of the vault. - QuotingParams quoting_params = 4; + // The parameters of the vault. + VaultParams vault_params = 4 [ (gogoproto.nullable) = false ]; // The client IDs of the most recently placed orders of the vault. repeated uint32 most_recent_client_ids = 5; } diff --git a/proto/dydxprotocol/vault/params.proto b/proto/dydxprotocol/vault/params.proto index 9a76486899..73f5c52880 100644 --- a/proto/dydxprotocol/vault/params.proto +++ b/proto/dydxprotocol/vault/params.proto @@ -1,6 +1,7 @@ syntax = "proto3"; package dydxprotocol.vault; +import "dydxprotocol/vault/vault.proto"; import "gogoproto/gogo.proto"; option go_package = "github.com/dydxprotocol/v4-chain/protocol/x/vault/types"; @@ -39,6 +40,14 @@ message QuotingParams { ]; } +// VaultParams stores vault parameters. +message VaultParams { + // Status of the vault. + VaultStatus status = 1; + // Quoting parameters of the vault. + QuotingParams quoting_params = 2; +} + // Deprecated: Params stores `x/vault` parameters. // Deprecated since v6.x as is replaced by QuotingParams. message Params { diff --git a/proto/dydxprotocol/vault/query.proto b/proto/dydxprotocol/vault/query.proto index 4006f82615..d2073ccb0f 100644 --- a/proto/dydxprotocol/vault/query.proto +++ b/proto/dydxprotocol/vault/query.proto @@ -64,7 +64,7 @@ message QueryVaultResponse { (gogoproto.nullable) = false ]; NumShares total_shares = 5 [ (gogoproto.nullable) = false ]; - QuotingParams quoting_params = 6 [ (gogoproto.nullable) = false ]; + VaultParams vault_params = 6 [ (gogoproto.nullable) = false ]; } // QueryAllVaultsRequest is a request type for the AllVaults RPC method. diff --git a/proto/dydxprotocol/vault/tx.proto b/proto/dydxprotocol/vault/tx.proto index c9119c3e4e..ad1813908e 100644 --- a/proto/dydxprotocol/vault/tx.proto +++ b/proto/dydxprotocol/vault/tx.proto @@ -19,9 +19,8 @@ service Msg { rpc UpdateDefaultQuotingParams(MsgUpdateDefaultQuotingParams) returns (MsgUpdateDefaultQuotingParamsResponse); - // SetVaultQuotingParams sets the quoting parameters of a specific vault. - rpc SetVaultQuotingParams(MsgSetVaultQuotingParams) - returns (MsgSetVaultQuotingParamsResponse); + // SetVaultParams sets the parameters of a specific vault. + rpc SetVaultParams(MsgSetVaultParams) returns (MsgSetVaultParamsResponse); } // MsgDepositToVault deposits the specified asset from the subaccount to the @@ -64,19 +63,18 @@ message MsgUpdateDefaultQuotingParams { // response type. message MsgUpdateDefaultQuotingParamsResponse {} -// MsgSetVaultQuotingParams is the Msg/SetVaultQuotingParams request type. -message MsgSetVaultQuotingParams { +// MsgSetVaultParams is the Msg/SetVaultParams request type. +message MsgSetVaultParams { // Authority is the address that controls the module. option (cosmos.msg.v1.signer) = "authority"; string authority = 1 [ (cosmos_proto.scalar) = "cosmos.AddressString" ]; - // The vault to set quoting params of. + // The vault to set params of. VaultId vault_id = 2 [ (gogoproto.nullable) = false ]; - // The quoting parameters to set. Each field must be set. - QuotingParams quoting_params = 3 [ (gogoproto.nullable) = false ]; + // The parameters to set. + VaultParams vault_params = 3 [ (gogoproto.nullable) = false ]; } -// MsgSetVaultQuotingParamsResponse is the Msg/SetVaultQuotingParams response -// type. -message MsgSetVaultQuotingParamsResponse {} +// MsgSetVaultParamsResponse is the Msg/SetVaultParams response type. +message MsgSetVaultParamsResponse {} diff --git a/proto/dydxprotocol/vault/vault.proto b/proto/dydxprotocol/vault/vault.proto index 527c4c4938..76c30482fe 100644 --- a/proto/dydxprotocol/vault/vault.proto +++ b/proto/dydxprotocol/vault/vault.proto @@ -20,3 +20,21 @@ message VaultId { // Unique ID of the vault within above type. uint32 number = 2; } + +// VaultStatus represents the status of a vault. +enum VaultStatus { + // Default value, invalid and unused. + VAULT_STATUS_UNSPECIFIED = 0; + + // Don’t place orders. Does not count toward global vault balances. + VAULT_STATUS_DEACTIVATED = 1; + + // Don’t place orders. Does count towards global vault balances. + VAULT_STATUS_STAND_BY = 2; + + // Places orders on both sides of the book. + VAULT_STATUS_QUOTING = 3; + + // Only place orders that close the position. + VAULT_STATUS_CLOSE_ONLY = 4; +} diff --git a/protocol/app/msgs/all_msgs.go b/protocol/app/msgs/all_msgs.go index 29755e6670..ff36d5d596 100644 --- a/protocol/app/msgs/all_msgs.go +++ b/protocol/app/msgs/all_msgs.go @@ -243,8 +243,8 @@ var ( // vault "/dydxprotocol.vault.MsgDepositToVault": {}, "/dydxprotocol.vault.MsgDepositToVaultResponse": {}, - "/dydxprotocol.vault.MsgSetVaultQuotingParams": {}, - "/dydxprotocol.vault.MsgSetVaultQuotingParamsResponse": {}, + "/dydxprotocol.vault.MsgSetVaultParams": {}, + "/dydxprotocol.vault.MsgSetVaultParamsResponse": {}, "/dydxprotocol.vault.MsgUpdateDefaultQuotingParams": {}, "/dydxprotocol.vault.MsgUpdateDefaultQuotingParamsResponse": {}, diff --git a/protocol/app/msgs/internal_msgs.go b/protocol/app/msgs/internal_msgs.go index 8abd41170d..7a0ead6dfe 100644 --- a/protocol/app/msgs/internal_msgs.go +++ b/protocol/app/msgs/internal_msgs.go @@ -186,8 +186,8 @@ var ( "/dydxprotocol.stats.MsgUpdateParamsResponse": nil, // vault - "/dydxprotocol.vault.MsgSetVaultQuotingParams": &vault.MsgSetVaultQuotingParams{}, - "/dydxprotocol.vault.MsgSetVaultQuotingParamsResponse": nil, + "/dydxprotocol.vault.MsgSetVaultParams": &vault.MsgSetVaultParams{}, + "/dydxprotocol.vault.MsgSetVaultParamsResponse": nil, "/dydxprotocol.vault.MsgUpdateDefaultQuotingParams": &vault.MsgUpdateDefaultQuotingParams{}, "/dydxprotocol.vault.MsgUpdateDefaultQuotingParamsResponse": nil, diff --git a/protocol/app/msgs/internal_msgs_test.go b/protocol/app/msgs/internal_msgs_test.go index 0ffdd4b649..b0c2bf248c 100644 --- a/protocol/app/msgs/internal_msgs_test.go +++ b/protocol/app/msgs/internal_msgs_test.go @@ -144,8 +144,8 @@ func TestInternalMsgSamples_Gov_Key(t *testing.T) { "/dydxprotocol.stats.MsgUpdateParamsResponse", // vault - "/dydxprotocol.vault.MsgSetVaultQuotingParams", - "/dydxprotocol.vault.MsgSetVaultQuotingParamsResponse", + "/dydxprotocol.vault.MsgSetVaultParams", + "/dydxprotocol.vault.MsgSetVaultParamsResponse", "/dydxprotocol.vault.MsgUpdateDefaultQuotingParams", "/dydxprotocol.vault.MsgUpdateDefaultQuotingParamsResponse", diff --git a/protocol/lib/ante/internal_msg.go b/protocol/lib/ante/internal_msg.go index 88a03dbd89..04dcef92c1 100644 --- a/protocol/lib/ante/internal_msg.go +++ b/protocol/lib/ante/internal_msg.go @@ -126,7 +126,7 @@ func IsInternalMsg(msg sdk.Msg) bool { *stats.MsgUpdateParams, // vault - *vault.MsgSetVaultQuotingParams, + *vault.MsgSetVaultParams, *vault.MsgUpdateDefaultQuotingParams, // vest diff --git a/protocol/testing/genesis.sh b/protocol/testing/genesis.sh index fced0ab8d1..0f79fac247 100755 --- a/protocol/testing/genesis.sh +++ b/protocol/testing/genesis.sh @@ -2245,6 +2245,8 @@ function edit_genesis() { dasel put -t json -f "$GENESIS" ".app_state.vault.vaults.[${vault_idx}].owner_shares.[]" -v '{}' dasel put -t string -f "$GENESIS" ".app_state.vault.vaults.[${vault_idx}].owner_shares.[0].owner" -v "${vault_owner_address}" dasel put -t string -f "$GENESIS" ".app_state.vault.vaults.[${vault_idx}].owner_shares.[0].shares.num_shares" -v "${DEFAULT_SUBACCOUNT_QUOTE_BALANCE_VAULT}" + + dasel put -t string -f "$GENESIS" ".app_state.vault.vaults.[${vault_idx}].vault_params.status" -v 'VAULT_STATUS_QUOTING' vault_idx=$(($vault_idx + 1)) done } diff --git a/protocol/testutil/constants/vault.go b/protocol/testutil/constants/vault.go index 23fc44feb4..4382fc49cd 100644 --- a/protocol/testutil/constants/vault.go +++ b/protocol/testutil/constants/vault.go @@ -30,4 +30,17 @@ var ( OrderExpirationSeconds: 111, ActivationThresholdQuoteQuantums: dtypes.NewInt(9_876_543), } + VaultParams = types.VaultParams{ + Status: types.VaultStatus_VAULT_STATUS_QUOTING, + QuotingParams: &QuotingParams, + } + InvalidQuotingParams = types.QuotingParams{ + Layers: 3, + SpreadMinPpm: 4_321, + SpreadBufferPpm: 1_789, + SkewFactorPpm: 767_323, + OrderSizePctPpm: 234_567, + OrderExpirationSeconds: 0, + ActivationThresholdQuoteQuantums: dtypes.NewInt(9_876_543), + } ) diff --git a/protocol/x/vault/genesis.go b/protocol/x/vault/genesis.go index 7007bd34e0..7ec535e937 100644 --- a/protocol/x/vault/genesis.go +++ b/protocol/x/vault/genesis.go @@ -29,10 +29,8 @@ func InitGenesis(ctx sdk.Context, k keeper.Keeper, genState types.GenesisState) panic(err) } } - if vault.QuotingParams != nil { - if err := k.SetVaultQuotingParams(ctx, *vault.VaultId, *vault.QuotingParams); err != nil { - panic(err) - } + if err := k.SetVaultParams(ctx, *vault.VaultId, vault.VaultParams); err != nil { + panic(err) } k.SetMostRecentClientIds(ctx, *vault.VaultId, vault.MostRecentClientIds) k.AddVaultToAddressStore(ctx, *vault.VaultId) diff --git a/protocol/x/vault/keeper/grpc_query_vault.go b/protocol/x/vault/keeper/grpc_query_vault.go index 42e362f045..d7a9919e81 100644 --- a/protocol/x/vault/keeper/grpc_query_vault.go +++ b/protocol/x/vault/keeper/grpc_query_vault.go @@ -49,16 +49,19 @@ func (k Keeper) Vault( inventory = k.GetVaultInventoryInPerpetual(ctx, vaultId, perpId) } - // Get vault quoting params. - quotingParams := k.GetVaultQuotingParams(ctx, vaultId) + // Get vault params. + vaultParams, exists := k.GetVaultParams(ctx, vaultId) + if !exists { + return nil, status.Error(codes.NotFound, "vault not found") + } return &types.QueryVaultResponse{ - VaultId: vaultId, - SubaccountId: *vaultId.ToSubaccountId(), - Equity: dtypes.NewIntFromBigInt(equity), - Inventory: dtypes.NewIntFromBigInt(inventory), - TotalShares: totalShares, - QuotingParams: quotingParams, + VaultId: vaultId, + SubaccountId: *vaultId.ToSubaccountId(), + Equity: dtypes.NewIntFromBigInt(equity), + Inventory: dtypes.NewIntFromBigInt(inventory), + TotalShares: totalShares, + VaultParams: vaultParams, }, nil } diff --git a/protocol/x/vault/keeper/grpc_query_vault_test.go b/protocol/x/vault/keeper/grpc_query_vault_test.go index 195cfa68b4..d21922ec54 100644 --- a/protocol/x/vault/keeper/grpc_query_vault_test.go +++ b/protocol/x/vault/keeper/grpc_query_vault_test.go @@ -28,8 +28,8 @@ func TestVault(t *testing.T) { inventory *big.Int // Total shares. totalShares *big.Int - // Quoting params. - quotingParams *vaulttypes.QuotingParams + // Vault params. + vaultParams vaulttypes.VaultParams // Query request. req *vaulttypes.QueryVaultRequest @@ -47,7 +47,22 @@ func TestVault(t *testing.T) { perpId: 0, inventory: big.NewInt(200), totalShares: big.NewInt(300), - quotingParams: &constants.QuotingParams, + vaultParams: constants.VaultParams, + expectedEquity: big.NewInt(500), + }, + "Success: close only vault status": { + req: &vaulttypes.QueryVaultRequest{ + Type: vaulttypes.VaultType_VAULT_TYPE_CLOB, + Number: 0, + }, + vaultId: constants.Vault_Clob0, + asset: big.NewInt(100), + perpId: 0, + inventory: big.NewInt(200), + totalShares: big.NewInt(300), + vaultParams: vaulttypes.VaultParams{ + Status: vaulttypes.VaultStatus_VAULT_STATUS_CLOSE_ONLY, + }, expectedEquity: big.NewInt(500), }, "Success: negative inventory and equity": { @@ -60,6 +75,7 @@ func TestVault(t *testing.T) { perpId: 0, inventory: big.NewInt(-200), totalShares: big.NewInt(300), + vaultParams: constants.VaultParams, expectedEquity: big.NewInt(-300), }, "Success: non-existent clob pair": { @@ -75,7 +91,7 @@ func TestVault(t *testing.T) { perpId: 0, inventory: big.NewInt(0), totalShares: big.NewInt(300), - quotingParams: &constants.QuotingParams, + vaultParams: constants.VaultParams, expectedEquity: big.NewInt(100), }, "Error: query non-existent vault": { @@ -88,6 +104,7 @@ func TestVault(t *testing.T) { perpId: 0, inventory: big.NewInt(200), totalShares: big.NewInt(300), + vaultParams: constants.VaultParams, expectedErr: "vault not found", }, "Error: nil request": { @@ -97,6 +114,7 @@ func TestVault(t *testing.T) { perpId: 0, inventory: big.NewInt(200), totalShares: big.NewInt(300), + vaultParams: constants.VaultParams, expectedErr: "invalid request", }, } @@ -134,14 +152,11 @@ func TestVault(t *testing.T) { ctx := tApp.InitChain() k := tApp.App.VaultKeeper - // Set total shares. + // Set total shares and vault params. err := k.SetTotalShares(ctx, tc.vaultId, vaulttypes.BigIntToNumShares(tc.totalShares)) require.NoError(t, err) - - if tc.quotingParams != nil { - err := k.SetVaultQuotingParams(ctx, tc.vaultId, *tc.quotingParams) - require.NoError(t, err) - } + err = k.SetVaultParams(ctx, tc.vaultId, tc.vaultParams) + require.NoError(t, err) // Check Vault query response is as expected. response, err := k.Vault(ctx, tc.req) @@ -149,17 +164,13 @@ func TestVault(t *testing.T) { require.ErrorContains(t, err, tc.expectedErr) } else { require.NoError(t, err) - expectedQuotingParams := k.GetDefaultQuotingParams(ctx) - if tc.quotingParams != nil { - expectedQuotingParams = *tc.quotingParams - } expectedResponse := vaulttypes.QueryVaultResponse{ - VaultId: tc.vaultId, - SubaccountId: *tc.vaultId.ToSubaccountId(), - Equity: dtypes.NewIntFromBigInt(tc.expectedEquity), - Inventory: dtypes.NewIntFromBigInt(tc.inventory), - TotalShares: vaulttypes.BigIntToNumShares(tc.totalShares), - QuotingParams: expectedQuotingParams, + VaultId: tc.vaultId, + SubaccountId: *tc.vaultId.ToSubaccountId(), + Equity: dtypes.NewIntFromBigInt(tc.expectedEquity), + Inventory: dtypes.NewIntFromBigInt(tc.inventory), + TotalShares: vaulttypes.BigIntToNumShares(tc.totalShares), + VaultParams: tc.vaultParams, } require.Equal(t, expectedResponse, *response) } @@ -264,10 +275,12 @@ func TestAllVaults(t *testing.T) { ctx := tApp.InitChain() k := tApp.App.VaultKeeper - // Set total shares. + // Set total shares and vault params. for _, vaultId := range tc.vaultIds { err := k.SetTotalShares(ctx, vaultId, vaulttypes.BigIntToNumShares(tc.totalShares[vaultId])) require.NoError(t, err) + err = k.SetVaultParams(ctx, vaultId, constants.VaultParams) + require.NoError(t, err) } // Check AllVaults query response is as expected. diff --git a/protocol/x/vault/keeper/msg_server_deposit_to_vault.go b/protocol/x/vault/keeper/msg_server_deposit_to_vault.go index ff6232128b..9d736a4f78 100644 --- a/protocol/x/vault/keeper/msg_server_deposit_to_vault.go +++ b/protocol/x/vault/keeper/msg_server_deposit_to_vault.go @@ -33,6 +33,17 @@ func (k msgServer) DepositToVault( // Add vault to address store. k.AddVaultToAddressStore(ctx, *msg.VaultId) + // Initialize vault params (with status `Quoting`) if not yet set. + _, exists := k.GetVaultParams(ctx, *msg.VaultId) + if !exists { + err := k.Keeper.SetVaultParams(ctx, *msg.VaultId, types.VaultParams{ + Status: types.VaultStatus_VAULT_STATUS_QUOTING, + }) + if err != nil { + return nil, err + } + } + // Transfer from sender subaccount to vault. // Note: Transfer should take place after minting shares for // shares calculation to be correct. diff --git a/protocol/x/vault/keeper/msg_server_deposit_to_vault_test.go b/protocol/x/vault/keeper/msg_server_deposit_to_vault_test.go index 87eb978676..a4a8a97226 100644 --- a/protocol/x/vault/keeper/msg_server_deposit_to_vault_test.go +++ b/protocol/x/vault/keeper/msg_server_deposit_to_vault_test.go @@ -364,6 +364,16 @@ func TestMsgDepositToVault(t *testing.T) { require.Equal(t, tc.vaultEquityHistory[i], vaultEquity) // Check that vault exists in address store. require.True(t, tApp.App.VaultKeeper.IsVault(ctx, tc.vaultId.ToModuleAccountAddress())) + // Check that vault params are initialized. + vaultParams, exists := tApp.App.VaultKeeper.GetVaultParams(ctx, tc.vaultId) + require.True(t, exists) + require.Equal( + t, + vaulttypes.VaultParams{ + Status: vaulttypes.VaultStatus_VAULT_STATUS_QUOTING, + }, + vaultParams, + ) } }) } diff --git a/protocol/x/vault/keeper/msg_server_set_vault_quoting_params.go b/protocol/x/vault/keeper/msg_server_set_vault_params.go similarity index 52% rename from protocol/x/vault/keeper/msg_server_set_vault_quoting_params.go rename to protocol/x/vault/keeper/msg_server_set_vault_params.go index ecdfd98a59..f1aa758f01 100644 --- a/protocol/x/vault/keeper/msg_server_set_vault_quoting_params.go +++ b/protocol/x/vault/keeper/msg_server_set_vault_params.go @@ -10,11 +10,11 @@ import ( "github.com/dydxprotocol/v4-chain/protocol/x/vault/types" ) -// SetVaultQuotingParams sets the quoting parameters of a specific vault. -func (k msgServer) SetVaultQuotingParams( +// SetVaultParams sets the parameters of a specific vault. +func (k msgServer) SetVaultParams( goCtx context.Context, - msg *types.MsgSetVaultQuotingParams, -) (*types.MsgSetVaultQuotingParamsResponse, error) { + msg *types.MsgSetVaultParams, +) (*types.MsgSetVaultParamsResponse, error) { // Check if authority is valid. if !k.HasAuthority(msg.Authority) { return nil, errorsmod.Wrapf( @@ -26,15 +26,15 @@ func (k msgServer) SetVaultQuotingParams( ctx := lib.UnwrapSDKContext(goCtx, types.ModuleName) - // Validate quoting parameters. - if err := msg.QuotingParams.Validate(); err != nil { + // Validate parameters. + if err := msg.VaultParams.Validate(); err != nil { return nil, err } - // Set quoting parameters for specified vault. - if err := k.Keeper.SetVaultQuotingParams(ctx, msg.VaultId, msg.QuotingParams); err != nil { + // Set parameters for specified vault. + if err := k.Keeper.SetVaultParams(ctx, msg.VaultId, msg.VaultParams); err != nil { return nil, err } - return &types.MsgSetVaultQuotingParamsResponse{}, nil + return &types.MsgSetVaultParamsResponse{}, nil } diff --git a/protocol/x/vault/keeper/msg_server_set_vault_params_test.go b/protocol/x/vault/keeper/msg_server_set_vault_params_test.go new file mode 100644 index 0000000000..587a511301 --- /dev/null +++ b/protocol/x/vault/keeper/msg_server_set_vault_params_test.go @@ -0,0 +1,109 @@ +package keeper_test + +import ( + "testing" + + "github.com/dydxprotocol/v4-chain/protocol/dtypes" + "github.com/dydxprotocol/v4-chain/protocol/lib" + + testapp "github.com/dydxprotocol/v4-chain/protocol/testutil/app" + "github.com/dydxprotocol/v4-chain/protocol/testutil/constants" + + "github.com/dydxprotocol/v4-chain/protocol/x/vault/keeper" + "github.com/dydxprotocol/v4-chain/protocol/x/vault/types" + "github.com/stretchr/testify/require" +) + +func TestMsgSetVaultParams(t *testing.T) { + tests := map[string]struct { + // Msg. + msg *types.MsgSetVaultParams + // Expected error + expectedErr string + }{ + "Success - Vault Clob 0": { + msg: &types.MsgSetVaultParams{ + Authority: lib.GovModuleAddress.String(), + VaultId: constants.Vault_Clob0, + VaultParams: constants.VaultParams, + }, + }, + "Success - Vault Clob 1": { + msg: &types.MsgSetVaultParams{ + Authority: lib.GovModuleAddress.String(), + VaultId: constants.Vault_Clob1, + VaultParams: constants.VaultParams, + }, + }, + "Failure - Invalid Authority": { + msg: &types.MsgSetVaultParams{ + Authority: constants.AliceAccAddress.String(), + VaultId: constants.Vault_Clob0, + VaultParams: constants.VaultParams, + }, + expectedErr: "invalid authority", + }, + "Failure - Empty Authority": { + msg: &types.MsgSetVaultParams{ + Authority: "", + VaultId: constants.Vault_Clob0, + VaultParams: constants.VaultParams, + }, + expectedErr: "invalid authority", + }, + "Failure - Vault Clob 0. Invalid Quoting Params": { + msg: &types.MsgSetVaultParams{ + Authority: lib.GovModuleAddress.String(), + VaultId: constants.Vault_Clob0, + VaultParams: types.VaultParams{ + Status: types.VaultStatus_VAULT_STATUS_STAND_BY, + QuotingParams: &types.QuotingParams{ + Layers: 3, + SpreadMinPpm: 4_000, + SpreadBufferPpm: 2_000, + SkewFactorPpm: 500_000, + OrderSizePctPpm: 100_000, + OrderExpirationSeconds: 5, + ActivationThresholdQuoteQuantums: dtypes.NewInt(-1), // invalid + }, + }, + }, + expectedErr: types.ErrInvalidActivationThresholdQuoteQuantums.Error(), + }, + "Failure - Vault Clob 1. Unspecified status": { + msg: &types.MsgSetVaultParams{ + Authority: lib.GovModuleAddress.String(), + VaultId: constants.Vault_Clob0, + VaultParams: types.VaultParams{ + QuotingParams: &constants.QuotingParams, + }, + }, + expectedErr: types.ErrUnspecifiedVaultStatus.Error(), + }, + } + + for name, tc := range tests { + t.Run(name, func(t *testing.T) { + tApp := testapp.NewTestAppBuilder(t).Build() + ctx := tApp.InitChain() + k := tApp.App.VaultKeeper + ms := keeper.NewMsgServerImpl(k) + + _, err := ms.SetVaultParams(ctx, tc.msg) + if tc.expectedErr != "" { + require.ErrorContains(t, err, tc.expectedErr) + _, exists := k.GetVaultParams(ctx, tc.msg.VaultId) + require.False(t, exists) + } else { + require.NoError(t, err) + p, exists := k.GetVaultParams(ctx, tc.msg.VaultId) + require.True(t, exists) + require.Equal( + t, + tc.msg.VaultParams, + p, + ) + } + }) + } +} diff --git a/protocol/x/vault/keeper/msg_server_set_vault_quoting_params_test.go b/protocol/x/vault/keeper/msg_server_set_vault_quoting_params_test.go deleted file mode 100644 index 53150f236f..0000000000 --- a/protocol/x/vault/keeper/msg_server_set_vault_quoting_params_test.go +++ /dev/null @@ -1,97 +0,0 @@ -package keeper_test - -import ( - "testing" - - "github.com/dydxprotocol/v4-chain/protocol/dtypes" - "github.com/dydxprotocol/v4-chain/protocol/lib" - - testapp "github.com/dydxprotocol/v4-chain/protocol/testutil/app" - "github.com/dydxprotocol/v4-chain/protocol/testutil/constants" - - "github.com/dydxprotocol/v4-chain/protocol/x/vault/keeper" - "github.com/dydxprotocol/v4-chain/protocol/x/vault/types" - "github.com/stretchr/testify/require" -) - -func TestMsgSetVaultQuotingParams(t *testing.T) { - tests := map[string]struct { - // Msg. - msg *types.MsgSetVaultQuotingParams - // Expected error - expectedErr string - }{ - "Success - Vault Clob 0": { - msg: &types.MsgSetVaultQuotingParams{ - Authority: lib.GovModuleAddress.String(), - VaultId: constants.Vault_Clob0, - QuotingParams: constants.QuotingParams, - }, - }, - "Success - Vault Clob 1": { - msg: &types.MsgSetVaultQuotingParams{ - Authority: lib.GovModuleAddress.String(), - VaultId: constants.Vault_Clob1, - QuotingParams: constants.QuotingParams, - }, - }, - "Failure - Invalid Authority": { - msg: &types.MsgSetVaultQuotingParams{ - Authority: constants.AliceAccAddress.String(), - VaultId: constants.Vault_Clob0, - QuotingParams: constants.QuotingParams, - }, - expectedErr: "invalid authority", - }, - "Failure - Empty Authority": { - msg: &types.MsgSetVaultQuotingParams{ - Authority: "", - VaultId: constants.Vault_Clob0, - QuotingParams: constants.QuotingParams, - }, - expectedErr: "invalid authority", - }, - "Failure - Vault Clob 0. Invalid Quoting Params": { - msg: &types.MsgSetVaultQuotingParams{ - Authority: lib.GovModuleAddress.String(), - VaultId: constants.Vault_Clob0, - QuotingParams: types.QuotingParams{ - Layers: 3, - SpreadMinPpm: 4_000, - SpreadBufferPpm: 2_000, - SkewFactorPpm: 500_000, - OrderSizePctPpm: 100_000, - OrderExpirationSeconds: 5, - ActivationThresholdQuoteQuantums: dtypes.NewInt(-1), // invalid - }, - }, - expectedErr: types.ErrInvalidActivationThresholdQuoteQuantums.Error(), - }, - } - - for name, tc := range tests { - t.Run(name, func(t *testing.T) { - tApp := testapp.NewTestAppBuilder(t).Build() - ctx := tApp.InitChain() - k := tApp.App.VaultKeeper - ms := keeper.NewMsgServerImpl(k) - - _, err := ms.SetVaultQuotingParams(ctx, tc.msg) - if tc.expectedErr != "" { - require.ErrorContains(t, err, tc.expectedErr) - require.Equal( - t, - types.DefaultQuotingParams(), - k.GetVaultQuotingParams(ctx, tc.msg.VaultId), - ) - } else { - require.NoError(t, err) - require.Equal( - t, - tc.msg.QuotingParams, - k.GetVaultQuotingParams(ctx, tc.msg.VaultId), - ) - } - }) - } -} diff --git a/protocol/x/vault/keeper/orders.go b/protocol/x/vault/keeper/orders.go index c1f57d506b..77f2bd4510 100644 --- a/protocol/x/vault/keeper/orders.go +++ b/protocol/x/vault/keeper/orders.go @@ -40,7 +40,11 @@ func (k Keeper) RefreshAllVaultOrders(ctx sdk.Context) { // Skip if vault has no perpetual positions and strictly less than `activation_threshold_quote_quantums` USDC. vault := k.subaccountsKeeper.GetSubaccount(ctx, *vaultId.ToSubaccountId()) if vault.PerpetualPositions == nil || len(vault.PerpetualPositions) == 0 { - quotingParams := k.GetVaultQuotingParams(ctx, *vaultId) + quotingParams, exists := k.GetVaultQuotingParams(ctx, *vaultId) + if !exists { + log.ErrorLog(ctx, "Non-existent vault params", "vaultId", *vaultId) + continue + } if vault.GetUsdcPosition().Cmp(quotingParams.ActivationThresholdQuoteQuantums.BigInt()) == -1 { continue } @@ -204,8 +208,14 @@ func (k Keeper) GetVaultClobOrders( leveragePpm := new(big.Int).Mul(openNotional, lib.BigIntOneMillion()) leveragePpm.Quo(leveragePpm, equity) - // Get quoting parameters. - quotingParams := k.GetVaultQuotingParams(ctx, vaultId) + // Get vault parameters. + quotingParams, exists := k.GetVaultQuotingParams(ctx, vaultId) + if !exists { + return orders, errorsmod.Wrap( + types.ErrVaultParamsNotFound, + fmt.Sprintf("VaultId: %v", vaultId), + ) + } // Calculate order size (in base quantums). orderSizePctPpm := lib.BigU(quotingParams.OrderSizePctPpm) @@ -391,7 +401,11 @@ func (k Keeper) GetVaultClobOrderIds( } } - layers := k.GetVaultQuotingParams(ctx, vaultId).Layers + quotingParams, exists := k.GetVaultQuotingParams(ctx, vaultId) + if !exists { + return []*clobtypes.OrderId{} + } + layers := quotingParams.Layers orderIds = make([]*clobtypes.OrderId, 2*layers) for i := uint32(0); i < layers; i++ { // Construct ask order ID at this layer. @@ -430,10 +444,17 @@ func (k Keeper) ReplaceVaultClobOrder( oldOrderId *clobtypes.OrderId, newOrder *clobtypes.Order, ) error { + quotingParams, exists := k.GetVaultQuotingParams(ctx, vaultId) + if !exists { + return errorsmod.Wrap( + types.ErrVaultParamsNotFound, + fmt.Sprintf("VaultId: %v", vaultId), + ) + } // Cancel old order. err := k.clobKeeper.HandleMsgCancelOrder(ctx, clobtypes.NewMsgCancelOrderStateful( *oldOrderId, - uint32(ctx.BlockTime().Unix())+k.GetVaultQuotingParams(ctx, vaultId).OrderExpirationSeconds, + uint32(ctx.BlockTime().Unix())+quotingParams.OrderExpirationSeconds, )) vaultId.IncrCounterWithLabels( metrics.VaultCancelOrder, diff --git a/protocol/x/vault/keeper/orders_test.go b/protocol/x/vault/keeper/orders_test.go index 5a4a27f4e6..dfbf306657 100644 --- a/protocol/x/vault/keeper/orders_test.go +++ b/protocol/x/vault/keeper/orders_test.go @@ -157,7 +157,7 @@ func TestRefreshAllVaultOrders(t *testing.T) { }).Build() ctx := tApp.InitChain().WithIsCheckTx(false) - // Set total shares for each vault ID. + // Set total shares and vault params for each vault ID. for i, vaultId := range tc.vaultIds { err := tApp.App.VaultKeeper.SetTotalShares( ctx, @@ -165,6 +165,14 @@ func TestRefreshAllVaultOrders(t *testing.T) { vaulttypes.BigIntToNumShares(tc.totalShares[i]), ) require.NoError(t, err) + err = tApp.App.VaultKeeper.SetVaultParams( + ctx, + vaultId, + vaulttypes.VaultParams{ + Status: vaulttypes.VaultStatus_VAULT_STATUS_QUOTING, + }, + ) + require.NoError(t, err) } // Check that there's no stateful orders yet. @@ -335,6 +343,9 @@ func TestRefreshVaultClobOrders(t *testing.T) { }, }, }, + VaultParams: vaulttypes.VaultParams{ + Status: vaulttypes.VaultStatus_VAULT_STATUS_QUOTING, + }, }, } }, @@ -928,7 +939,10 @@ func TestGetVaultClobOrders(t *testing.T) { ctx := tApp.InitChain() // Set vault quoting parameters. - err := tApp.App.VaultKeeper.SetVaultQuotingParams(ctx, tc.vaultId, tc.vaultQuotingParams) + err := tApp.App.VaultKeeper.SetVaultParams(ctx, tc.vaultId, vaulttypes.VaultParams{ + Status: vaulttypes.VaultStatus_VAULT_STATUS_QUOTING, + QuotingParams: &tc.vaultQuotingParams, + }) require.NoError(t, err) // Get vault orders. @@ -940,7 +954,6 @@ func TestGetVaultClobOrders(t *testing.T) { require.NoError(t, err) // Get expected orders. - vaultQuotingParams := tApp.App.VaultKeeper.GetVaultQuotingParams(ctx, tc.vaultId) buildVaultClobOrder := func( layer uint8, side clobtypes.Order_Side, @@ -958,7 +971,7 @@ func TestGetVaultClobOrders(t *testing.T) { Quantums: quantums, Subticks: subticks, GoodTilOneof: &clobtypes.Order_GoodTilBlockTime{ - GoodTilBlockTime: uint32(ctx.BlockTime().Unix()) + vaultQuotingParams.OrderExpirationSeconds, + GoodTilBlockTime: uint32(ctx.BlockTime().Unix()) + tc.vaultQuotingParams.OrderExpirationSeconds, }, } } @@ -1036,9 +1049,12 @@ func TestGetVaultClobOrderIds(t *testing.T) { ctx := tApp.InitChain() // Set number of layers. - quotingParams := k.GetVaultQuotingParams(ctx, tc.vaultId) + quotingParams := constants.QuotingParams quotingParams.Layers = tc.layers - err := k.SetVaultQuotingParams(ctx, tc.vaultId, quotingParams) + err := k.SetVaultParams(ctx, tc.vaultId, vaulttypes.VaultParams{ + Status: vaulttypes.VaultStatus_VAULT_STATUS_QUOTING, + QuotingParams: "ingParams, + }) require.NoError(t, err) // Construct expected order IDs. diff --git a/protocol/x/vault/keeper/params.go b/protocol/x/vault/keeper/params.go index dee2fdd10e..bba3cab7b9 100644 --- a/protocol/x/vault/keeper/params.go +++ b/protocol/x/vault/keeper/params.go @@ -35,43 +35,65 @@ func (k Keeper) SetDefaultQuotingParams( return nil } -// GetVaultQuotingParams returns `QuotingParams` in state for a given vault, if it exists, -// and otherwise, returns module-wide `DefaultQuotingParams`. -func (k Keeper) GetVaultQuotingParams( +// GetVaultParams returns `VaultParams` in state for a given vault. +func (k Keeper) GetVaultParams( ctx sdk.Context, vaultId types.VaultId, ) ( - quotingParams types.QuotingParams, + vaultParams types.VaultParams, + exists bool, ) { - store := prefix.NewStore(ctx.KVStore(k.storeKey), []byte(types.QuotingParamsKeyPrefix)) + store := prefix.NewStore(ctx.KVStore(k.storeKey), []byte(types.VaultParamsKeyPrefix)) b := store.Get(vaultId.ToStateKey()) if b == nil { - return k.GetDefaultQuotingParams(ctx) + return vaultParams, false } - k.cdc.MustUnmarshal(b, "ingParams) - return quotingParams + k.cdc.MustUnmarshal(b, &vaultParams) + return vaultParams, true } -// SetVaultQuotingParams sets `QuotingParams` in state for a given vault. +// SetVaultParams sets `VaultParams` in state for a given vault. // Returns an error if validation fails. -func (k Keeper) SetVaultQuotingParams( +func (k Keeper) SetVaultParams( ctx sdk.Context, vaultId types.VaultId, - qoutingParams types.QuotingParams, + vaultParams types.VaultParams, ) error { - if err := qoutingParams.Validate(); err != nil { + if err := vaultParams.Validate(); err != nil { return err } - b := k.cdc.MustMarshal(&qoutingParams) - store := prefix.NewStore(ctx.KVStore(k.storeKey), []byte(types.QuotingParamsKeyPrefix)) + b := k.cdc.MustMarshal(&vaultParams) + store := prefix.NewStore(ctx.KVStore(k.storeKey), []byte(types.VaultParamsKeyPrefix)) store.Set(vaultId.ToStateKey(), b) return nil } +// GetVaultQuotingParams returns quoting parameters for a given vault, which is +// - `VaultParams.QuotingParams` if set +// - `DefaultQuotingParams` otherwise +// `exists` is false if `VaultParams` does not exist for the given vault. +func (k Keeper) GetVaultQuotingParams( + ctx sdk.Context, + vaultId types.VaultId, +) ( + params types.QuotingParams, + exists bool, +) { + vaultParams, exists := k.GetVaultParams(ctx, vaultId) + if !exists { + return params, false + } + if vaultParams.QuotingParams == nil { + return k.GetDefaultQuotingParams(ctx), true + } else { + return *vaultParams.QuotingParams, true + } +} + // UnsafeGetParams returns `Params` in state. // Used for v6.x upgrade handler. func (k Keeper) UnsafeGetParams( diff --git a/protocol/x/vault/keeper/params_test.go b/protocol/x/vault/keeper/params_test.go index db675e9a6a..07ef042aea 100644 --- a/protocol/x/vault/keeper/params_test.go +++ b/protocol/x/vault/keeper/params_test.go @@ -48,44 +48,97 @@ func TestGetSetDefaultQuotingParams(t *testing.T) { require.Equal(t, *newParams, k.GetDefaultQuotingParams(ctx)) } -func TestGetSetVaultQuotingParams(t *testing.T) { +func TestGetSetVaultParams(t *testing.T) { tests := map[string]struct { // Vault id. vaultId types.VaultId - // Vault quoting params to set. - vaultQuotingParams *types.QuotingParams + // Vault params to set. + vaultParams *types.VaultParams + // Expected error. + expectedErr error }{ - "Vault Clob 0. Default quoting params": { - vaultId: constants.Vault_Clob0, - vaultQuotingParams: nil, + "Success - Vault Clob 0": { + vaultId: constants.Vault_Clob0, + vaultParams: &constants.VaultParams, }, - "Vault Clob 0. Non-default quoting params": { + "Success - Vault Clob 1": { + vaultId: constants.Vault_Clob1, + vaultParams: &constants.VaultParams, + }, + "Success - Non-existent Vault Params": { + vaultId: constants.Vault_Clob1, + vaultParams: nil, + }, + "Failure - Unspecified Status": { vaultId: constants.Vault_Clob0, - vaultQuotingParams: &types.QuotingParams{ - Layers: 3, - SpreadMinPpm: 12_345, - SpreadBufferPpm: 5_678, - SkewFactorPpm: 4_121_787, - OrderSizePctPpm: 232_121, - OrderExpirationSeconds: 120, - ActivationThresholdQuoteQuantums: dtypes.NewInt(2_123_456_789), + vaultParams: &types.VaultParams{ + QuotingParams: &constants.QuotingParams, }, + expectedErr: types.ErrUnspecifiedVaultStatus, }, - "Vault Clob 1. Default quoting params": { - vaultId: constants.Vault_Clob0, - vaultQuotingParams: nil, + "Failure - Invalid Quoting Params": { + vaultId: constants.Vault_Clob0, + vaultParams: &types.VaultParams{ + Status: types.VaultStatus_VAULT_STATUS_STAND_BY, + QuotingParams: &constants.InvalidQuotingParams, + }, + expectedErr: types.ErrInvalidOrderExpirationSeconds, }, - "Vault Clob 1. Non-default quoting params": { + } + + for name, tc := range tests { + t.Run(name, func(t *testing.T) { + tApp := testapp.NewTestAppBuilder(t).Build() + ctx := tApp.InitChain() + k := tApp.App.VaultKeeper + + if tc.vaultParams == nil { + _, exists := k.GetVaultParams(ctx, tc.vaultId) + require.False(t, exists) + return + } + + err := k.SetVaultParams(ctx, tc.vaultId, *tc.vaultParams) + if tc.expectedErr != nil { + require.ErrorIs(t, err, tc.expectedErr) + _, exists := k.GetVaultParams(ctx, tc.vaultId) + require.False(t, exists) + } else { + require.NoError(t, err) + p, exists := k.GetVaultParams(ctx, tc.vaultId) + require.True(t, exists) + require.Equal(t, *tc.vaultParams, p) + } + }) + } +} + +func TestGetVaultQuotingParams(t *testing.T) { + tests := map[string]struct { + /* Setup */ + // Vault id. + vaultId types.VaultId + // Vault params to set. + vaultParams *types.VaultParams + /* Expectations */ + // Whether quoting params should be default. + shouldBeDefault bool + }{ + "Default Quoting Params": { vaultId: constants.Vault_Clob0, - vaultQuotingParams: &types.QuotingParams{ - Layers: 4, - SpreadMinPpm: 123_456, - SpreadBufferPpm: 87_654, - SkewFactorPpm: 5_432_111, - OrderSizePctPpm: 444_333, - OrderExpirationSeconds: 90, - ActivationThresholdQuoteQuantums: dtypes.NewInt(1_111_111_111), + vaultParams: &types.VaultParams{ + Status: types.VaultStatus_VAULT_STATUS_CLOSE_ONLY, }, + shouldBeDefault: true, + }, + "Custom Quoting Params": { + vaultId: constants.Vault_Clob1, + vaultParams: &constants.VaultParams, + shouldBeDefault: false, + }, + "Non-existent Vault Params": { + vaultId: constants.Vault_Clob1, + vaultParams: nil, }, } @@ -95,23 +148,19 @@ func TestGetSetVaultQuotingParams(t *testing.T) { ctx := tApp.InitChain() k := tApp.App.VaultKeeper - if tc.vaultQuotingParams != nil { - // Set quoting params. - err := k.SetVaultQuotingParams(ctx, tc.vaultId, *tc.vaultQuotingParams) + if tc.vaultParams != nil { + err := k.SetVaultParams(ctx, tc.vaultId, *tc.vaultParams) require.NoError(t, err) - // Verify quoting params are as set. - require.Equal( - t, - *tc.vaultQuotingParams, - k.GetVaultQuotingParams(ctx, tc.vaultId), - ) + p, exists := k.GetVaultQuotingParams(ctx, tc.vaultId) + require.True(t, exists) + if tc.shouldBeDefault { + require.Equal(t, types.DefaultQuotingParams(), p) + } else { + require.Equal(t, *tc.vaultParams.QuotingParams, p) + } } else { - // Verify quoting params are default. - require.Equal( - t, - k.GetDefaultQuotingParams(ctx), - k.GetVaultQuotingParams(ctx, tc.vaultId), - ) + _, exists := k.GetVaultQuotingParams(ctx, tc.vaultId) + require.False(t, exists) } }) } diff --git a/protocol/x/vault/keeper/vault.go b/protocol/x/vault/keeper/vault.go index e76c5acebb..60e1c802f3 100644 --- a/protocol/x/vault/keeper/vault.go +++ b/protocol/x/vault/keeper/vault.go @@ -106,9 +106,9 @@ func (k Keeper) DecommissionVault( vaultAddressStore := prefix.NewStore(ctx.KVStore(k.storeKey), []byte(types.VaultAddressKeyPrefix)) vaultAddressStore.Delete([]byte(vaultId.ToModuleAccountAddress())) - // Delete vault quoting params if any. - vaultQuotingParamsStore := prefix.NewStore(ctx.KVStore(k.storeKey), []byte(types.QuotingParamsKeyPrefix)) - vaultQuotingParamsStore.Delete(vaultId.ToStateKey()) + // Delete vault params. + vaultParamsStore := prefix.NewStore(ctx.KVStore(k.storeKey), []byte(types.VaultParamsKeyPrefix)) + vaultParamsStore.Delete(vaultId.ToStateKey()) } // AddVaultToAddressStore adds a vault's address to the vault address store. @@ -146,7 +146,10 @@ func (k Keeper) GetAllVaults(ctx sdk.Context) []*types.Vault { allOwnerShares := k.GetAllOwnerShares(ctx, *vaultId) - quotingParams := k.GetVaultQuotingParams(ctx, *vaultId) + vaultParams, exists := k.GetVaultParams(ctx, *vaultId) + if !exists { + panic("vault params not found") + } mostRecentClientIds := k.GetMostRecentClientIds(ctx, *vaultId) @@ -154,7 +157,7 @@ func (k Keeper) GetAllVaults(ctx sdk.Context) []*types.Vault { VaultId: vaultId, TotalShares: &totalShares, OwnerShares: allOwnerShares, - QuotingParams: "ingParams, + VaultParams: vaultParams, MostRecentClientIds: mostRecentClientIds, }) } diff --git a/protocol/x/vault/keeper/vault_test.go b/protocol/x/vault/keeper/vault_test.go index b3c67bc9ae..d63c959397 100644 --- a/protocol/x/vault/keeper/vault_test.go +++ b/protocol/x/vault/keeper/vault_test.go @@ -160,30 +160,26 @@ func TestDecommissionVault(t *testing.T) { totalSharesExists bool // Owners. owners []string - // Vault quoting params. - quotingParams *vaulttypes.QuotingParams }{ - "Total shares doesn't exist, no owners, default quoting params": { + "Total shares doesn't exist, no owners": { vaultId: constants.Vault_Clob0, }, - "Total shares exists, no owners, default quoting params": { + "Total shares exists, no owners": { vaultId: constants.Vault_Clob0, totalSharesExists: true, }, - "Total shares exists, one owner, non-default quoting params": { + "Total shares exists, one owner": { vaultId: constants.Vault_Clob1, totalSharesExists: true, owners: []string{constants.Alice_Num0.Owner}, - quotingParams: &constants.QuotingParams, }, - "Total shares exists, two owners, non-default quoting params": { + "Total shares exists, two owners": { vaultId: constants.Vault_Clob1, totalSharesExists: true, owners: []string{ constants.Alice_Num0.Owner, constants.Bob_Num0.Owner, }, - quotingParams: &constants.QuotingParams, }, } for name, tc := range tests { @@ -214,15 +210,13 @@ func TestDecommissionVault(t *testing.T) { ) require.NoError(t, err) } - if tc.quotingParams != nil { - err := k.SetVaultQuotingParams(ctx, tc.vaultId, *tc.quotingParams) - require.NoError(t, err) - } + err := k.SetVaultParams(ctx, tc.vaultId, constants.VaultParams) + require.NoError(t, err) // Decommission vault. k.DecommissionVault(ctx, tc.vaultId) - // Check that total shares, owner shares, and vault address are deleted. + // Check that total shares, owner shares, vault address, and vault params are deleted. _, exists := k.GetTotalShares(ctx, tc.vaultId) require.Equal(t, false, exists) for _, owner := range tc.owners { @@ -230,12 +224,8 @@ func TestDecommissionVault(t *testing.T) { require.Equal(t, false, exists) } require.False(t, k.IsVault(ctx, tc.vaultId.ToModuleAccountAddress())) - // Check that vault quoting params are back to default. - require.Equal( - t, - k.GetDefaultQuotingParams(ctx), - k.GetVaultQuotingParams(ctx, tc.vaultId), - ) + _, exists = k.GetVaultParams(ctx, tc.vaultId) + require.False(t, exists) }) } } @@ -298,6 +288,9 @@ func TestVaultIsBestFeeTier(t *testing.T) { }, }, }, + VaultParams: vaulttypes.VaultParams{ + Status: vaulttypes.VaultStatus_VAULT_STATUS_QUOTING, + }, }, } }, diff --git a/protocol/x/vault/types/errors.go b/protocol/x/vault/types/errors.go index 7fc398a207..8032c126ce 100644 --- a/protocol/x/vault/types/errors.go +++ b/protocol/x/vault/types/errors.go @@ -96,4 +96,14 @@ var ( 18, "Orders and OrderIds must have the same length", ) + ErrUnspecifiedVaultStatus = errorsmod.Register( + ModuleName, + 19, + "VaultStatus is unspecified", + ) + ErrVaultParamsNotFound = errorsmod.Register( + ModuleName, + 20, + "VaultParams not found", + ) ) diff --git a/protocol/x/vault/types/genesis.go b/protocol/x/vault/types/genesis.go index bb1cf66f36..c24f29639b 100644 --- a/protocol/x/vault/types/genesis.go +++ b/protocol/x/vault/types/genesis.go @@ -36,10 +36,8 @@ func (gs GenesisState) Validate() error { if totalShares.Sign() != 0 { return ErrMismatchedTotalAndOwnerShares } - if vault.QuotingParams != nil { - if err := vault.QuotingParams.Validate(); err != nil { - return err - } + if err := vault.VaultParams.Validate(); err != nil { + return err } } return nil diff --git a/protocol/x/vault/types/genesis.pb.go b/protocol/x/vault/types/genesis.pb.go index c4333c6484..6d2129e200 100644 --- a/protocol/x/vault/types/genesis.pb.go +++ b/protocol/x/vault/types/genesis.pb.go @@ -78,7 +78,7 @@ func (m *GenesisState) GetDefaultQuotingParams() QuotingParams { return QuotingParams{} } -// Vault defines the total shares and owner shares of a vault. +// Vault defines the state of a vault. type Vault struct { // The ID of the vault. VaultId *VaultId `protobuf:"bytes,1,opt,name=vault_id,json=vaultId,proto3" json:"vault_id,omitempty"` @@ -86,8 +86,8 @@ type Vault struct { TotalShares *NumShares `protobuf:"bytes,2,opt,name=total_shares,json=totalShares,proto3" json:"total_shares,omitempty"` // The shares of each owner in the vault. OwnerShares []*OwnerShare `protobuf:"bytes,3,rep,name=owner_shares,json=ownerShares,proto3" json:"owner_shares,omitempty"` - // The quoting parameters of the vault. - QuotingParams *QuotingParams `protobuf:"bytes,4,opt,name=quoting_params,json=quotingParams,proto3" json:"quoting_params,omitempty"` + // The parameters of the vault. + VaultParams VaultParams `protobuf:"bytes,4,opt,name=vault_params,json=vaultParams,proto3" json:"vault_params"` // The client IDs of the most recently placed orders of the vault. MostRecentClientIds []uint32 `protobuf:"varint,5,rep,packed,name=most_recent_client_ids,json=mostRecentClientIds,proto3" json:"most_recent_client_ids,omitempty"` } @@ -146,11 +146,11 @@ func (m *Vault) GetOwnerShares() []*OwnerShare { return nil } -func (m *Vault) GetQuotingParams() *QuotingParams { +func (m *Vault) GetVaultParams() VaultParams { if m != nil { - return m.QuotingParams + return m.VaultParams } - return nil + return VaultParams{} } func (m *Vault) GetMostRecentClientIds() []uint32 { @@ -168,33 +168,33 @@ func init() { func init() { proto.RegisterFile("dydxprotocol/vault/genesis.proto", fileDescriptor_4be4a747b209e41c) } var fileDescriptor_4be4a747b209e41c = []byte{ - // 407 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x92, 0x41, 0xaf, 0xd2, 0x40, - 0x10, 0xc7, 0x5b, 0xca, 0x7b, 0xbe, 0x6c, 0x79, 0xc6, 0xac, 0x2f, 0x2f, 0x15, 0xe3, 0x52, 0x39, - 0x71, 0xb1, 0x8d, 0x60, 0xf4, 0xaa, 0x78, 0x50, 0x3c, 0xa8, 0x2c, 0x89, 0x07, 0x13, 0xd3, 0x94, - 0x76, 0x2d, 0x4d, 0xda, 0x2e, 0x74, 0xb7, 0x08, 0xdf, 0xc2, 0x4f, 0xe1, 0x17, 0xf1, 0xc2, 0x91, - 0xa3, 0x27, 0x63, 0xe0, 0x8b, 0x98, 0x9d, 0x56, 0x02, 0x5a, 0x8d, 0x97, 0xed, 0xec, 0xfc, 0x7f, - 0xf3, 0xdf, 0xe9, 0x64, 0x90, 0x1d, 0xae, 0xc3, 0xd5, 0x3c, 0xe7, 0x92, 0x07, 0x3c, 0x71, 0x97, - 0x7e, 0x91, 0x48, 0x37, 0x62, 0x19, 0x13, 0xb1, 0x70, 0x20, 0x8d, 0xf1, 0x31, 0xe1, 0x00, 0xd1, - 0xbe, 0x8a, 0x78, 0xc4, 0x21, 0xe7, 0xaa, 0xa8, 0x24, 0xdb, 0x9d, 0x1a, 0xaf, 0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xe3, 0x2b, 0x1e, 0xa0, 0xeb, 0x94, 0x0b, 0xe9, 0xe5, 0x2c, 0x60, 0x99, 0xf4, 0x82, - 0x24, 0x56, 0x9f, 0x38, 0x14, 0xd6, 0x99, 0x6d, 0xf4, 0x2e, 0xe9, 0x6d, 0xa5, 0x52, 0x10, 0x9f, - 0x83, 0x36, 0x0a, 0xc5, 0x70, 0xbc, 0xd9, 0x11, 0x7d, 0xbb, 0x23, 0xfa, 0x8f, 0x1d, 0xd1, 0x3f, - 0xef, 0x89, 0xb6, 0xdd, 0x13, 0xed, 0xdb, 0x9e, 0x68, 0xef, 0x9f, 0x44, 0xb1, 0x9c, 0x15, 0x53, - 0x27, 0xe0, 0xa9, 0x7b, 0xba, 0x33, 0x8f, 0x1e, 0x04, 0x33, 0x3f, 0xce, 0xdc, 0x43, 0x66, 0x55, - 0xed, 0x91, 0x5c, 0xcf, 0x99, 0x98, 0x9e, 0x43, 0x7e, 0xf0, 0x33, 0x00, 0x00, 0xff, 0xff, 0xe9, - 0xf6, 0xd8, 0x81, 0xf7, 0x02, 0x00, 0x00, + // 410 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x7c, 0x52, 0xc1, 0xae, 0xd2, 0x40, + 0x14, 0x6d, 0x29, 0xef, 0xf9, 0x32, 0xad, 0x89, 0x19, 0x5f, 0x48, 0xc5, 0x38, 0x54, 0x56, 0x6c, + 0x6c, 0x23, 0x18, 0xdd, 0x2a, 0x2e, 0x14, 0x17, 0x2a, 0x25, 0x71, 0x61, 0x62, 0x9a, 0xd2, 0x8e, + 0xa5, 0x49, 0xdb, 0xc1, 0xce, 0x14, 0xe1, 0x2f, 0xfc, 0x0a, 0x7f, 0xc4, 0x0d, 0x4b, 0x96, 0xae, + 0x8c, 0x81, 0x1f, 0x31, 0x73, 0xa7, 0xa2, 0xc4, 0xe2, 0x66, 0x7a, 0x7b, 0xce, 0xb9, 0x67, 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xeb, 0x2a, 0x9f, 0x81, 0xc8, 0x37, 0xa1, 0x45, 0xfd, 0xe0, 0x67, 0xc8, 0x62, + 0x9f, 0x0b, 0x5a, 0xfe, 0x76, 0x30, 0x60, 0x42, 0xa4, 0xc9, 0xe1, 0x8d, 0xd4, 0x41, 0x9b, 0x6f, + 0xb2, 0x63, 0xcd, 0xf1, 0x4b, 0x64, 0xa9, 0xf0, 0xf5, 0x84, 0xda, 0x10, 0xa2, 0x77, 0xf6, 0x01, + 0x27, 0xf3, 0x31, 0x57, 0x7f, 0x20, 0x3c, 0x42, 0x9d, 0x9c, 0x71, 0x11, 0x94, 0x34, 0xa2, 0x85, + 0x08, 0xa2, 0x2c, 0x95, 0x9f, 0x34, 0xe6, 0xf6, 0x85, 0x63, 0x0c, 0x6e, 0xfa, 0xb7, 0x25, 0xeb, + 0x03, 0xf9, 0x1c, 0xb8, 0x49, 0xcc, 0xc7, 0xd3, 0xed, 0x9e, 0xe8, 0xbb, 0x3d, 0xd1, 0x7f, 0xee, + 0x89, 0xfe, 0xe5, 0x40, 0xb4, 0xdd, 0x81, 0x68, 0xdf, 0x0f, 0x44, 0x7b, 0xff, 0x24, 0x49, 0xc5, + 0xa2, 0x9a, 0xbb, 0x11, 0xcb, 0xbd, 0xd3, 0x9d, 0x79, 0xf4, 0x20, 0x5a, 0x84, 0x69, 0xe1, 0x1d, + 0x91, 0x75, 0xbd, 0x47, 0x62, 0xb3, 0xa4, 0x7c, 0x7e, 0x09, 0xf8, 0xe8, 0x57, 0x00, 0x00, 0x00, + 0xff, 0xff, 0xed, 0x63, 0xf5, 0xbe, 0xf7, 0x02, 0x00, 0x00, } func (m *GenesisState) Marshal() (dAtA []byte, err error) { @@ -282,18 +282,16 @@ func (m *Vault) MarshalToSizedBuffer(dAtA []byte) (int, error) { i-- dAtA[i] = 0x2a } - if m.QuotingParams != nil { - { - size, err := m.QuotingParams.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintGenesis(dAtA, i, uint64(size)) + { + size, err := m.VaultParams.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err } - i-- - dAtA[i] = 0x22 + i -= size + i = encodeVarintGenesis(dAtA, i, uint64(size)) } + i-- + dAtA[i] = 0x22 if len(m.OwnerShares) > 0 { for iNdEx := len(m.OwnerShares) - 1; iNdEx >= 0; iNdEx-- { { @@ -383,10 +381,8 @@ func (m *Vault) Size() (n int) { n += 1 + l + sovGenesis(uint64(l)) } } - if m.QuotingParams != nil { - l = m.QuotingParams.Size() - n += 1 + l + sovGenesis(uint64(l)) - } + l = m.VaultParams.Size() + n += 1 + l + sovGenesis(uint64(l)) if len(m.MostRecentClientIds) > 0 { l = 0 for _, e := range m.MostRecentClientIds { @@ -657,7 +653,7 @@ func (m *Vault) Unmarshal(dAtA []byte) error { iNdEx = postIndex case 4: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field QuotingParams", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field VaultParams", wireType) } var msglen int for shift := uint(0); ; shift += 7 { @@ -684,10 +680,7 @@ func (m *Vault) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - if m.QuotingParams == nil { - m.QuotingParams = &QuotingParams{} - } - if err := m.QuotingParams.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + if err := m.VaultParams.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } iNdEx = postIndex diff --git a/protocol/x/vault/types/keys.go b/protocol/x/vault/types/keys.go index 14468ab3c4..064f90230a 100644 --- a/protocol/x/vault/types/keys.go +++ b/protocol/x/vault/types/keys.go @@ -22,9 +22,9 @@ const ( // A vault uses DefaultQuotingParams if it does not have its own QuotingParams. DefaultQuotingParamsKey = "DefaultQuotingParams" - // QuotingParamsKeyPrefix is the prefix to retrieve all QuotingParams. - // QuotingParams store: vaultId VaultId -> QuotingParams. - QuotingParamsKeyPrefix = "QuotingParams:" + // VaultParamsKeyPrefix is the prefix to retrieve all VaultParams. + // VaultParams store: vaultId VaultId -> VaultParams. + VaultParamsKeyPrefix = "VaultParams:" // VaultAddressKeyPrefix is the prefix to retrieve all vault addresses. VaultAddressKeyPrefix = "VaultAddress:" diff --git a/protocol/x/vault/types/params.go b/protocol/x/vault/types/params.go index 648af682a9..d339114ee0 100644 --- a/protocol/x/vault/types/params.go +++ b/protocol/x/vault/types/params.go @@ -44,3 +44,19 @@ func (p QuotingParams) Validate() error { return nil } + +// Validate validates individual vault parameters. +func (v VaultParams) Validate() error { + // Validate status. + if v.Status == VaultStatus_VAULT_STATUS_UNSPECIFIED { + return ErrUnspecifiedVaultStatus + } + // Validate quoting params. + if v.QuotingParams != nil { + if err := v.QuotingParams.Validate(); err != nil { + return err + } + } + + return nil +} diff --git a/protocol/x/vault/types/params.pb.go b/protocol/x/vault/types/params.pb.go index 7ee3c8578e..b136d9d840 100644 --- a/protocol/x/vault/types/params.pb.go +++ b/protocol/x/vault/types/params.pb.go @@ -123,6 +123,61 @@ func (m *QuotingParams) GetOrderExpirationSeconds() uint32 { return 0 } +// VaultParams stores vault parameters. +type VaultParams struct { + // Status of the vault. + Status VaultStatus `protobuf:"varint,1,opt,name=status,proto3,enum=dydxprotocol.vault.VaultStatus" json:"status,omitempty"` + // Quoting parameters of the vault. + QuotingParams *QuotingParams `protobuf:"bytes,2,opt,name=quoting_params,json=quotingParams,proto3" json:"quoting_params,omitempty"` +} + +func (m *VaultParams) Reset() { *m = VaultParams{} } +func (m *VaultParams) String() string { return proto.CompactTextString(m) } +func (*VaultParams) ProtoMessage() {} +func (*VaultParams) Descriptor() ([]byte, []int) { + return fileDescriptor_6043e0b8bfdbca9f, []int{1} +} +func (m *VaultParams) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *VaultParams) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_VaultParams.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *VaultParams) XXX_Merge(src proto.Message) { + xxx_messageInfo_VaultParams.Merge(m, src) +} +func (m *VaultParams) XXX_Size() int { + return m.Size() +} +func (m *VaultParams) XXX_DiscardUnknown() { + xxx_messageInfo_VaultParams.DiscardUnknown(m) +} + +var xxx_messageInfo_VaultParams proto.InternalMessageInfo + +func (m *VaultParams) GetStatus() VaultStatus { + if m != nil { + return m.Status + } + return VaultStatus_VAULT_STATUS_UNSPECIFIED +} + +func (m *VaultParams) GetQuotingParams() *QuotingParams { + if m != nil { + return m.QuotingParams + } + return nil +} + // Deprecated: Params stores `x/vault` parameters. // Deprecated since v6.x as is replaced by QuotingParams. type Params struct { @@ -152,7 +207,7 @@ func (m *Params) Reset() { *m = Params{} } func (m *Params) String() string { return proto.CompactTextString(m) } func (*Params) ProtoMessage() {} func (*Params) Descriptor() ([]byte, []int) { - return fileDescriptor_6043e0b8bfdbca9f, []int{1} + return fileDescriptor_6043e0b8bfdbca9f, []int{2} } func (m *Params) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -225,39 +280,44 @@ func (m *Params) GetOrderExpirationSeconds() uint32 { func init() { proto.RegisterType((*QuotingParams)(nil), "dydxprotocol.vault.QuotingParams") + proto.RegisterType((*VaultParams)(nil), "dydxprotocol.vault.VaultParams") proto.RegisterType((*Params)(nil), "dydxprotocol.vault.Params") } func init() { proto.RegisterFile("dydxprotocol/vault/params.proto", fileDescriptor_6043e0b8bfdbca9f) } var fileDescriptor_6043e0b8bfdbca9f = []byte{ - // 407 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xec, 0x93, 0xb1, 0x8e, 0xd3, 0x30, - 0x1c, 0xc6, 0x13, 0x0a, 0x41, 0xb2, 0xae, 0x9c, 0x88, 0xd0, 0x29, 0x62, 0x48, 0xab, 0x03, 0xa1, - 0x13, 0x88, 0x64, 0x00,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d, 0x5c, 0xb4, 0xe9, 0x03, 0x00, 0x00, + // 475 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xec, 0x94, 0x4f, 0x6b, 0x13, 0x41, + 0x18, 0xc6, 0xb3, 0x46, 0x57, 0x98, 0x36, 0x29, 0x2e, 0x52, 0x96, 0x1e, 0x36, 0x31, 0x8a, 0x14, + 0xc5, 0x5d, 0xa8, 0x42, 0x3d, 0x4a, 0x40, 0xa9, 0x07, 0x21, 0x7f, 0xc4, 0x83, 0x97, 0x61, 0xb2, + 0x3b, 0x49, 0x06, 0x77, 0x77, 0x66, 0x67, 0xde, 0xad, 0x49, 0x3e, 0x45, 0x6f, 0x1e, 0xbc, 0xf9, + 0x69, 0x7a, 0xec, 0x51, 0x3c, 0x14, 0x49, 0xbe, 0x88, 0xec, 0x3b, 0x6b, 0x6d, 0xb1, 0x07, 0x8f, + 0x1e, 0x7a, 0x09, 0x33, 0xcf, 0xf3, 0x7b, 0xe7, 0x0d, 0x3c, 0x0f, 0x4b, 0x3a, 0xc9, 0x32, 0x59, + 0x28, 0x2d, 0x41, 0xc6, 0x32, 0x8d, 0x8e, 0x59, 0x99, 0x42, 0xa4, 0x98, 0x66, 0x99, 0x09, 0x51, + 0xf5, 0xbc, 0xcb, 0x40, 0x88, 0xc0, 0x5e, 0x70, 0xcd, 0x10, 0xfe, 0xda, 0x99, 0xbd, 0xfb, 0x33, + 0x39, 0x93, 0x78, 0x8c, 0xaa, 0x93, 0x55, 0x7b, 0xdf, 0x9a, 0xa4, 0x35, 0x2c, 0x25, 0x88, 0x7c, + 0x36, 0xc0, 0x0d, 0xde, 0x2e, 0x71, 0x53, 0xb6, 0xe4, 0xda, 0xf8, 0x4e, 0xd7, 0xd9, 0x6f, 0x8d, + 0xea, 0x9b, 0xf7, 0x88, 0xb4, 0x8d, 0xd2, 0x9c, 0x25, 0x34, 0x13, 0x39, 0x55, 0x2a, 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, 0x67, 0x15, 0x09, 0x1f, 0xd6, 0x1b, 0x7b, 0x27, 0x0e, 0xd9, 0xfa, 0x50, + 0x45, 0x59, 0x47, 0x74, 0x48, 0x5c, 0x03, 0x0c, 0x4a, 0x1b, 0x51, 0xfb, 0xa0, 0x13, 0xfe, 0xdd, + 0x87, 0x10, 0x07, 0xc6, 0x88, 0x8d, 0x6a, 0xdc, 0x3b, 0x22, 0xed, 0xc2, 0x86, 0x4d, 0x6d, 0x9f, + 0x30, 0xc3, 0xad, 0x83, 0x07, 0xd7, 0x3d, 0x70, 0xa5, 0x16, 0xa3, 0x56, 0x71, 0xf9, 0xda, 0xfb, + 0xda, 0x24, 0xee, 0x4d, 0x61, 0xfe, 0xd3, 0xc2, 0xf4, 0x87, 0xa7, 0xeb, 0xc0, 0x39, 0x5b, 0x07, + 0xce, 0xcf, 0x75, 0xe0, 0x9c, 0x6c, 0x82, 0xc6, 0xd9, 0x26, 0x68, 0x7c, 0xdf, 0x04, 0x8d, 0x8f, + 0x87, 0xff, 0xbe, 0x7d, 0x51, 0x7f, 0x44, 0xf0, 0x4f, 0x4c, 0x5c, 0xd4, 0x9f, 0xff, 0x0a, 0x00, + 0x00, 0xff, 0xff, 0x9a, 0x4f, 0xa0, 0xd4, 0x9c, 0x04, 0x00, 0x00, } func (m *QuotingParams) Marshal() (dAtA []byte, err error) { @@ -323,6 +383,46 @@ func (m *QuotingParams) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } +func (m *VaultParams) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *VaultParams) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *VaultParams) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.QuotingParams != nil { + { + size, err := m.QuotingParams.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintParams(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + if m.Status != 0 { + i = encodeVarintParams(dAtA, i, uint64(m.Status)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + func (m *Params) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) @@ -426,6 +526,22 @@ func (m *QuotingParams) Size() (n int) { return n } +func (m *VaultParams) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Status != 0 { + n += 1 + sovParams(uint64(m.Status)) + } + if m.QuotingParams != nil { + l = m.QuotingParams.Size() + n += 1 + l + sovParams(uint64(l)) + } + return n +} + func (m *Params) Size() (n int) { if m == nil { return 0 @@ -658,6 +774,111 @@ func (m *QuotingParams) Unmarshal(dAtA []byte) error { } return nil } +func (m *VaultParams) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowParams + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: VaultParams: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: VaultParams: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Status", wireType) + } + m.Status = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowParams + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Status |= VaultStatus(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field QuotingParams", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowParams + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthParams + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthParams + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.QuotingParams == nil { + m.QuotingParams = &QuotingParams{} + } + if err := m.QuotingParams.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipParams(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthParams + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} func (m *Params) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 diff --git a/protocol/x/vault/types/params_test.go b/protocol/x/vault/types/params_test.go index 2fe762d8ec..fe6f053942 100644 --- a/protocol/x/vault/types/params_test.go +++ b/protocol/x/vault/types/params_test.go @@ -4,6 +4,7 @@ import ( "testing" "github.com/dydxprotocol/v4-chain/protocol/dtypes" + "github.com/dydxprotocol/v4-chain/protocol/testutil/constants" "github.com/dydxprotocol/v4-chain/protocol/x/vault/types" "github.com/stretchr/testify/require" ) @@ -88,3 +89,46 @@ func TestValidateQuotingParams(t *testing.T) { }) } } + +func TestValidateVaultParams(t *testing.T) { + tests := map[string]struct { + // Params to validate. + params types.VaultParams + // Expected error + expectedErr error + }{ + "Success": { + params: types.VaultParams{ + Status: types.VaultStatus_VAULT_STATUS_QUOTING, + QuotingParams: &constants.QuotingParams, + }, + expectedErr: nil, + }, + "Success - nil quoting params": { + params: types.VaultParams{ + Status: types.VaultStatus_VAULT_STATUS_QUOTING, + }, + expectedErr: nil, + }, + "Failure - unspecified vault status": { + params: types.VaultParams{ + QuotingParams: &constants.QuotingParams, + }, + expectedErr: types.ErrUnspecifiedVaultStatus, + }, + "Failure - invalid quoting params": { + params: types.VaultParams{ + Status: types.VaultStatus_VAULT_STATUS_QUOTING, + QuotingParams: &constants.InvalidQuotingParams, + }, + expectedErr: types.ErrInvalidOrderExpirationSeconds, + }, + } + + for name, tc := range tests { + t.Run(name, func(t *testing.T) { + err := tc.params.Validate() + require.Equal(t, tc.expectedErr, err) + }) + } +} diff --git a/protocol/x/vault/types/query.pb.go b/protocol/x/vault/types/query.pb.go index 5ac16cf096..525eb7191c 100644 --- a/protocol/x/vault/types/query.pb.go +++ b/protocol/x/vault/types/query.pb.go @@ -179,12 +179,12 @@ func (m *QueryVaultRequest) GetNumber() uint32 { // QueryVaultResponse is a response type for the Vault RPC method. type QueryVaultResponse struct { - VaultId VaultId `protobuf:"bytes,1,opt,name=vault_id,json=vaultId,proto3" json:"vault_id"` - SubaccountId types.SubaccountId `protobuf:"bytes,2,opt,name=subaccount_id,json=subaccountId,proto3" json:"subaccount_id"` - Equity github_com_dydxprotocol_v4_chain_protocol_dtypes.SerializableInt `protobuf:"bytes,3,opt,name=equity,proto3,customtype=github.com/dydxprotocol/v4-chain/protocol/dtypes.SerializableInt" json:"equity"` - Inventory github_com_dydxprotocol_v4_chain_protocol_dtypes.SerializableInt `protobuf:"bytes,4,opt,name=inventory,proto3,customtype=github.com/dydxprotocol/v4-chain/protocol/dtypes.SerializableInt" json:"inventory"` - TotalShares NumShares `protobuf:"bytes,5,opt,name=total_shares,json=totalShares,proto3" json:"total_shares"` - QuotingParams QuotingParams `protobuf:"bytes,6,opt,name=quoting_params,json=quotingParams,proto3" json:"quoting_params"` + VaultId VaultId `protobuf:"bytes,1,opt,name=vault_id,json=vaultId,proto3" json:"vault_id"` + SubaccountId types.SubaccountId `protobuf:"bytes,2,opt,name=subaccount_id,json=subaccountId,proto3" json:"subaccount_id"` + Equity github_com_dydxprotocol_v4_chain_protocol_dtypes.SerializableInt `protobuf:"bytes,3,opt,name=equity,proto3,customtype=github.com/dydxprotocol/v4-chain/protocol/dtypes.SerializableInt" json:"equity"` + Inventory github_com_dydxprotocol_v4_chain_protocol_dtypes.SerializableInt `protobuf:"bytes,4,opt,name=inventory,proto3,customtype=github.com/dydxprotocol/v4-chain/protocol/dtypes.SerializableInt" json:"inventory"` + TotalShares NumShares `protobuf:"bytes,5,opt,name=total_shares,json=totalShares,proto3" json:"total_shares"` + VaultParams VaultParams `protobuf:"bytes,6,opt,name=vault_params,json=vaultParams,proto3" json:"vault_params"` } func (m *QueryVaultResponse) Reset() { *m = QueryVaultResponse{} } @@ -241,11 +241,11 @@ func (m *QueryVaultResponse) GetTotalShares() NumShares { return NumShares{} } -func (m *QueryVaultResponse) GetQuotingParams() QuotingParams { +func (m *QueryVaultResponse) GetVaultParams() VaultParams { if m != nil { - return m.QuotingParams + return m.VaultParams } - return QuotingParams{} + return VaultParams{} } // QueryAllVaultsRequest is a request type for the AllVaults RPC method. @@ -474,59 +474,59 @@ func init() { func init() { proto.RegisterFile("dydxprotocol/vault/query.proto", fileDescriptor_478fb8dc0ff21ea6) } var fileDescriptor_478fb8dc0ff21ea6 = []byte{ - // 819 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x55, 0x4f, 0x4f, 0x13, 0x41, - 0x1c, 0xed, 0x42, 0x59, 0x65, 0x5a, 0x48, 0x1c, 0x11, 0x6b, 0xc1, 0x05, 0x36, 0x91, 0xbf, 0xba, - 0x6b, 0xab, 0x89, 0xc6, 0x18, 0x23, 0x1c, 0x50, 0x2e, 0x48, 0x17, 0xe3, 0xc1, 0x44, 0xeb, 0xb4, - 0x1d, 0x96, 0x4d, 0xb6, 0x3b, 0xed, 0xee, 0x6c, 0xa5, 0x12, 0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x25, 0xf6, 0xf4, 0x56, 0xff, 0xd3, 0x79, 0x47, 0x30, 0xb1, 0x21, - 0x5d, 0x90, 0x59, 0xfd, 0xc6, 0x9f, 0x00, 0x00, 0x00, 0xff, 0xff, 0x99, 0xba, 0x4d, 0xc2, 0x4d, - 0x09, 0x00, 0x00, + // 828 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x55, 0x4f, 0x6f, 0xd3, 0x48, + 0x1c, 0x8d, 0xdb, 0xd4, 0xbb, 0x9d, 0xa4, 0x2b, 0xed, 0x6c, 0xb7, 0x9b, 0x4d, 0x8b, 0xd3, 0x5a, + 0xa2, 0x7f, 0xc1, 0x26, 0x01, 0x09, 0x84, 0x10, 0xa2, 0x3d, 0x94, 0xf6, 0x02, 0x8d, 0x8b, 0x38, + 0x20, 0x41, 0x98, 0x24, 0x53, 0xd7, 0x92, 0xe3, 0x49, 0xec, 0x71, 0x68, 0xa8, 0x7a, 0x00, 0x89, + 0x03, 0x37, 0x24, 0x3e, 0x01, 0x1c, 0x38, 0x71, 0xe0, 0x1b, 0x70, 0xed, 0xb1, 0x12, 0x17, 0xc4, + 0xa1, 0x42, 0x2d, 0x1f, 0x04, 0x79, 0x66, 0x92, 0xd8, 0x49, 0x4c, 0x23, 0xd4, 0x4b, 0xe4, 0xfc, + 0xe6, 0x37, 0xef, 0x3d, 0xbf, 0x79, 0xbf, 0x31, 0x50, 0xaa, 0xad, 0xea, 0x5e, 0xdd, 0x25, 0x94, + 0x54, 0x88, 0xad, 0x37, 0x91, 0x6f, 0x53, 0xbd, 0xe1, 0x63, 0xb7, 0xa5, 0xb1, 0x22, 0x84, 0xe1, + 0x75, 0x8d, 0xad, 0x67, 0x27, 0x4d, 0x62, 0x12, 0x56, 0xd3, 0x83, 0x27, 0xde, 0x99, 0x9d, 0x31, + 0x09, 0x31, 0x6d, 0xac, 0xa3, 0xba, 0xa5, 0x23, 0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 0xcf, 0xc8, 0x57, + 0xe0, 0x92, 0x1e, 0xf7, 0x51, 0xd2, 0xf7, 0x83, 0x4c, 0x1c, 0xe8, 0xfb, 0x3c, 0x04, 0x07, 0xf0, + 0x95, 0x04, 0xc6, 0x3b, 0xb3, 0x00, 0x97, 0x62, 0x89, 0x7a, 0x27, 0x32, 0xbb, 0x3c, 0x4c, 0xab, + 0xd0, 0x35, 0xc7, 0x74, 0x4d, 0xc3, 0xff, 0x63, 0x75, 0xc1, 0xf7, 0x12, 0x48, 0x85, 0x02, 0x04, + 0x57, 0x62, 0xe1, 0xfb, 0xa7, 0x22, 0x7b, 0x69, 0xb8, 0x66, 0xa1, 0xe6, 0x06, 0x53, 0x53, 0x80, + 0x57, 0x06, 0xa9, 0x09, 0xa7, 0xb5, 0xd7, 0xac, 0xb5, 0xe2, 0xe1, 0x89, 0x22, 0x1d, 0x9d, 0x28, + 0xd2, 0xf7, 0x13, 0x45, 0x7a, 0x73, 0xaa, 0x24, 0x8e, 0x4e, 0x95, 0xc4, 0xd7, 0x53, 0x25, 0xf1, + 0xe8, 0xfa, 0xf0, 0xf7, 0xf2, 0x9e, 0x60, 0x62, 0xd7, 0x73, 0x59, 0x66, 0xf5, 0xab, 0x3f, 0x03, + 0x00, 0x00, 0xff, 0xff, 0x34, 0xf0, 0x1e, 0x20, 0x47, 0x09, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -845,7 +845,7 @@ func (m *QueryVaultResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { var l int _ = l { - size, err := m.QuotingParams.MarshalToSizedBuffer(dAtA[:i]) + size, err := m.VaultParams.MarshalToSizedBuffer(dAtA[:i]) if err != nil { return 0, err } @@ -1149,7 +1149,7 @@ func (m *QueryVaultResponse) Size() (n int) { n += 1 + l + sovQuery(uint64(l)) l = m.TotalShares.Size() n += 1 + l + sovQuery(uint64(l)) - l = m.QuotingParams.Size() + l = m.VaultParams.Size() n += 1 + l + sovQuery(uint64(l)) return n } @@ -1680,7 +1680,7 @@ func (m *QueryVaultResponse) Unmarshal(dAtA []byte) error { iNdEx = postIndex case 6: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field QuotingParams", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field VaultParams", wireType) } var msglen int for shift := uint(0); ; shift += 7 { @@ -1707,7 +1707,7 @@ func (m *QueryVaultResponse) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - if err := m.QuotingParams.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + if err := m.VaultParams.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } iNdEx = postIndex diff --git a/protocol/x/vault/types/tx.pb.go b/protocol/x/vault/types/tx.pb.go index 435ac32a5a..3b59ce5d09 100644 --- a/protocol/x/vault/types/tx.pb.go +++ b/protocol/x/vault/types/tx.pb.go @@ -220,27 +220,27 @@ func (m *MsgUpdateDefaultQuotingParamsResponse) XXX_DiscardUnknown() { var xxx_messageInfo_MsgUpdateDefaultQuotingParamsResponse proto.InternalMessageInfo -// MsgSetVaultQuotingParams is the Msg/SetVaultQuotingParams request type. -type MsgSetVaultQuotingParams struct { +// MsgSetVaultParams is the Msg/SetVaultParams request type. +type MsgSetVaultParams struct { Authority string `protobuf:"bytes,1,opt,name=authority,proto3" json:"authority,omitempty"` - // The vault to set quoting params of. + // The vault to set params of. VaultId VaultId `protobuf:"bytes,2,opt,name=vault_id,json=vaultId,proto3" json:"vault_id"` - // The quoting parameters to set. Each field must be set. - QuotingParams QuotingParams `protobuf:"bytes,3,opt,name=quoting_params,json=quotingParams,proto3" json:"quoting_params"` + // The parameters to set. + VaultParams VaultParams `protobuf:"bytes,3,opt,name=vault_params,json=vaultParams,proto3" json:"vault_params"` } -func (m *MsgSetVaultQuotingParams) Reset() { *m = MsgSetVaultQuotingParams{} } -func (m *MsgSetVaultQuotingParams) String() string { return proto.CompactTextString(m) } -func (*MsgSetVaultQuotingParams) ProtoMessage() {} -func (*MsgSetVaultQuotingParams) Descriptor() ([]byte, []int) { +func (m *MsgSetVaultParams) Reset() { *m = MsgSetVaultParams{} } +func (m *MsgSetVaultParams) String() string { return proto.CompactTextString(m) } +func (*MsgSetVaultParams) ProtoMessage() {} +func (*MsgSetVaultParams) Descriptor() ([]byte, []int) { return fileDescriptor_ced574c6017ce006, []int{4} } -func (m *MsgSetVaultQuotingParams) XXX_Unmarshal(b []byte) error { +func (m *MsgSetVaultParams) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } -func (m *MsgSetVaultQuotingParams) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { +func (m *MsgSetVaultParams) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { - return xxx_messageInfo_MsgSetVaultQuotingParams.Marshal(b, m, deterministic) + return xxx_messageInfo_MsgSetVaultParams.Marshal(b, m, deterministic) } else { b = b[:cap(b)] n, err := m.MarshalToSizedBuffer(b) @@ -250,56 +250,55 @@ func (m *MsgSetVaultQuotingParams) XXX_Marshal(b []byte, deterministic bool) ([] return b[:n], nil } } -func (m *MsgSetVaultQuotingParams) XXX_Merge(src proto.Message) { - xxx_messageInfo_MsgSetVaultQuotingParams.Merge(m, src) +func (m *MsgSetVaultParams) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgSetVaultParams.Merge(m, src) } -func (m *MsgSetVaultQuotingParams) XXX_Size() int { +func (m *MsgSetVaultParams) XXX_Size() int { return m.Size() } -func (m *MsgSetVaultQuotingParams) XXX_DiscardUnknown() { - xxx_messageInfo_MsgSetVaultQuotingParams.DiscardUnknown(m) +func (m *MsgSetVaultParams) XXX_DiscardUnknown() { + xxx_messageInfo_MsgSetVaultParams.DiscardUnknown(m) } -var xxx_messageInfo_MsgSetVaultQuotingParams proto.InternalMessageInfo +var xxx_messageInfo_MsgSetVaultParams proto.InternalMessageInfo -func (m *MsgSetVaultQuotingParams) GetAuthority() string { +func (m *MsgSetVaultParams) GetAuthority() string { if m != nil { return m.Authority } return "" } -func (m *MsgSetVaultQuotingParams) GetVaultId() VaultId { +func (m *MsgSetVaultParams) GetVaultId() VaultId { if m != nil { return m.VaultId } return VaultId{} } -func (m *MsgSetVaultQuotingParams) GetQuotingParams() QuotingParams { +func (m *MsgSetVaultParams) GetVaultParams() VaultParams { if m != nil { - return m.QuotingParams + return m.VaultParams } - return QuotingParams{} + return VaultParams{} } -// MsgSetVaultQuotingParamsResponse is the Msg/SetVaultQuotingParams response -// type. -type MsgSetVaultQuotingParamsResponse struct { +// MsgSetVaultParamsResponse is the Msg/SetVaultParams response type. +type MsgSetVaultParamsResponse struct { } -func (m *MsgSetVaultQuotingParamsResponse) Reset() { *m = MsgSetVaultQuotingParamsResponse{} } -func (m *MsgSetVaultQuotingParamsResponse) String() string { return proto.CompactTextString(m) } -func (*MsgSetVaultQuotingParamsResponse) ProtoMessage() {} -func (*MsgSetVaultQuotingParamsResponse) Descriptor() ([]byte, []int) { +func (m *MsgSetVaultParamsResponse) Reset() { *m = MsgSetVaultParamsResponse{} } +func (m *MsgSetVaultParamsResponse) String() string { return proto.CompactTextString(m) } +func (*MsgSetVaultParamsResponse) ProtoMessage() {} +func (*MsgSetVaultParamsResponse) Descriptor() ([]byte, []int) { return fileDescriptor_ced574c6017ce006, []int{5} } -func (m *MsgSetVaultQuotingParamsResponse) XXX_Unmarshal(b []byte) error { +func (m *MsgSetVaultParamsResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } -func (m *MsgSetVaultQuotingParamsResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { +func (m *MsgSetVaultParamsResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { - return xxx_messageInfo_MsgSetVaultQuotingParamsResponse.Marshal(b, m, deterministic) + return xxx_messageInfo_MsgSetVaultParamsResponse.Marshal(b, m, deterministic) } else { b = b[:cap(b)] n, err := m.MarshalToSizedBuffer(b) @@ -309,68 +308,69 @@ func (m *MsgSetVaultQuotingParamsResponse) XXX_Marshal(b []byte, deterministic b return b[:n], nil } } -func (m *MsgSetVaultQuotingParamsResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_MsgSetVaultQuotingParamsResponse.Merge(m, src) +func (m *MsgSetVaultParamsResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgSetVaultParamsResponse.Merge(m, src) } -func (m *MsgSetVaultQuotingParamsResponse) XXX_Size() int { +func (m *MsgSetVaultParamsResponse) XXX_Size() int { return m.Size() } -func (m *MsgSetVaultQuotingParamsResponse) XXX_DiscardUnknown() { - xxx_messageInfo_MsgSetVaultQuotingParamsResponse.DiscardUnknown(m) +func (m *MsgSetVaultParamsResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgSetVaultParamsResponse.DiscardUnknown(m) } -var xxx_messageInfo_MsgSetVaultQuotingParamsResponse proto.InternalMessageInfo +var xxx_messageInfo_MsgSetVaultParamsResponse proto.InternalMessageInfo func init() { proto.RegisterType((*MsgDepositToVault)(nil), "dydxprotocol.vault.MsgDepositToVault") proto.RegisterType((*MsgDepositToVaultResponse)(nil), "dydxprotocol.vault.MsgDepositToVaultResponse") proto.RegisterType((*MsgUpdateDefaultQuotingParams)(nil), "dydxprotocol.vault.MsgUpdateDefaultQuotingParams") proto.RegisterType((*MsgUpdateDefaultQuotingParamsResponse)(nil), "dydxprotocol.vault.MsgUpdateDefaultQuotingParamsResponse") - proto.RegisterType((*MsgSetVaultQuotingParams)(nil), "dydxprotocol.vault.MsgSetVaultQuotingParams") - proto.RegisterType((*MsgSetVaultQuotingParamsResponse)(nil), "dydxprotocol.vault.MsgSetVaultQuotingParamsResponse") + proto.RegisterType((*MsgSetVaultParams)(nil), "dydxprotocol.vault.MsgSetVaultParams") + proto.RegisterType((*MsgSetVaultParamsResponse)(nil), "dydxprotocol.vault.MsgSetVaultParamsResponse") } func init() { proto.RegisterFile("dydxprotocol/vault/tx.proto", fileDescriptor_ced574c6017ce006) } var fileDescriptor_ced574c6017ce006 = []byte{ - // 590 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x54, 0xcf, 0x8e, 0xd2, 0x40, - 0x1c, 0xa6, 0x60, 0xd4, 0x1d, 0x17, 0x12, 0x1b, 0x54, 0xb6, 0xc4, 0x82, 0x24, 0xab, 0xab, 0x91, - 0x36, 0xbb, 0x6e, 0xd6, 0xb8, 0xf1, 0xa0, 0x64, 0x0f, 0x12, 0x83, 0x91, 0xa2, 0x7b, 0x30, 0x31, - 0xa4, 0x74, 0x66, 0x4b, 0x13, 0xe8, 0x94, 0xce, 0x94, 0x80, 0xde, 0x3c, 0x7a, 0xf2, 0x05, 0x7c, - 0x07, 0x0f, 0x3e, 0x83, 0xd9, 0xe3, 0xc6, 0x93, 0xf1, 0xb0, 0x31, 0x70, 0xf0, 0xea, 0xcd, 0xab, - 0xe9, 0x4c, 0x81, 0x56, 0x0a, 0x2e, 0x89, 0x17, 0xf8, 0xcd, 0xef, 0xff, 0xf7, 0xcd, 0xd7, 0x01, - 0x79, 0x38, 0x84, 0x03, 0xc7, 0xc5, 0x14, 0x1b, 0xb8, 0xa3, 0xf6, 0x75, 0xaf, 0x43, 0x55, 0x3a, - 0x50, 0x98, 0x47, 0x14, 0xc3, 0x41, 0x85, 0x05, 0xa5, 0x0d, 0x03, 0x93, 0x2e, 0x26, 0x4d, 0xe6, - 0x56, 0xf9, 0x81, 0xa7, 0x4b, 0xd7, 0xf8, 0x49, 0xed, 0x12, 0x53, 0xed, 0x6f, 0xfb, 0x7f, 0x41, - 0xe0, 0x76, 0x64, 0x08, 0xf1, 0x5a, 0xba, 0x61, 0x60, 0xcf, 0xa6, 0x24, 0x64, 0x07, 0xa9, 0x85, - 0x98, 0x7d, 0x1c, 0xdd, 0xd5, 0xbb, 0x93, 0x21, 0x72, 0x4c, 0x02, 0xfb, 0x0d, 0xe2, 0x59, 0x13, - 0x9b, 0x98, 0x2f, 0xe7, 0x5b, 0xdc, 0x5b, 0xfa, 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, 0xfc, 0x18, 0xc9, 0xc2, 0x87, 0xb1, 0x9c, 0x38, 0x19, 0xcb, 0x89, 0x6f, 0x63, 0x39, - 0xf1, 0xea, 0xfe, 0xd9, 0x9f, 0x87, 0xc1, 0xe4, 0x7d, 0xf7, 0x5f, 0x89, 0xd6, 0x79, 0xe6, 0xbf, - 0xf7, 0x27, 0x00, 0x00, 0xff, 0xff, 0x94, 0xff, 0xce, 0x08, 0x02, 0x06, 0x00, 0x00, + // 593 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xa4, 0x54, 0xcd, 0x6e, 0xd3, 0x40, + 0x10, 0x8e, 0x53, 0x04, 0x74, 0x9b, 0x46, 0x62, 0x15, 0x41, 0x9a, 0x08, 0xa7, 0x44, 0x2a, 0x14, + 0xa4, 0xd8, 0x6a, 0x41, 0x45, 0x54, 0x1c, 0x20, 0xea, 0xa1, 0x11, 0x8a, 0x44, 0x1c, 0xe0, 0x80, + 0x84, 0xa2, 0x8d, 0x77, 0xe3, 0x58, 0x4a, 0xbc, 0x8e, 0x77, 0x1d, 0x25, 0x1c, 0x39, 0x72, 0xe2, + 0x05, 0x78, 0x07, 0x0e, 0x3c, 0x03, 0xea, 0xb1, 0xe2, 0x84, 0x38, 0x54, 0x28, 0x39, 0xf0, 0x1a, + 0xc8, 0xbb, 0xce, 0x8f, 0x1b, 0xbb, 0x14, 0x71, 0x49, 0x76, 0x67, 0xe6, 0x9b, 0x99, 0xef, 0x9b, + 0x59, 0x83, 0x22, 0x1e, 0xe3, 0x91, 0xeb, 0x51, 0x4e, 0x4d, 0xda, 0xd3, 0x87, 0xc8, 0xef, 0x71, + 0x9d, 0x8f, 0x34, 0x61, 0x81, 0x70, 0xd9, 0xa9, 0x09, 0x67, 0x61, 0xcb, 0xa4, 0xac, 0x4f, 0x59, + 0x4b, 0x98, 0x75, 0x79, 0x91, 0xe1, 0x85, 0x5b, 0xf2, 0xa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, 0x53, 0xa8, 0x5c, 0x2a, 0x6c, 0x56, 0x0f, 0x7e, 0x54, 0x40, + 0xe1, 0x82, 0x0d, 0xdb, 0x4b, 0xc8, 0x96, 0x0c, 0x29, 0x3c, 0xf9, 0x67, 0xc8, 0xbc, 0x99, 0x0e, + 0xc8, 0x9e, 0x9b, 0x7d, 0x12, 0xe9, 0x68, 0x58, 0x22, 0xe9, 0x78, 0x91, 0xab, 0x8d, 0x93, 0x89, + 0xaa, 0x9c, 0x4e, 0x54, 0xe5, 0xd7, 0x44, 0x55, 0x3e, 0x4d, 0xd5, 0xd4, 0xe9, 0x54, 0x4d, 0xfd, + 0x98, 0xaa, 0xa9, 0xb7, 0x8f, 0x2f, 0xff, 0xea, 0x47, 0xb3, 0xcf, 0x76, 0xf0, 0xf8, 0xdb, 0x57, + 0x85, 0xfd, 0xe1, 0x9f, 0x00, 0x00, 0x00, 0xff, 0xff, 0x3a, 0x3d, 0xde, 0x00, 0xd9, 0x05, 0x00, + 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -389,8 +389,8 @@ type MsgClient interface { DepositToVault(ctx context.Context, in *MsgDepositToVault, opts ...grpc.CallOption) (*MsgDepositToVaultResponse, error) // UpdateDefaultQuotingParams updates the default quoting params in state. UpdateDefaultQuotingParams(ctx context.Context, in *MsgUpdateDefaultQuotingParams, opts ...grpc.CallOption) (*MsgUpdateDefaultQuotingParamsResponse, error) - // SetVaultQuotingParams sets the quoting parameters of a specific vault. - SetVaultQuotingParams(ctx context.Context, in *MsgSetVaultQuotingParams, opts ...grpc.CallOption) (*MsgSetVaultQuotingParamsResponse, error) + // SetVaultParams sets the parameters of a specific vault. + SetVaultParams(ctx context.Context, in *MsgSetVaultParams, opts ...grpc.CallOption) (*MsgSetVaultParamsResponse, error) } type msgClient struct { @@ -419,9 +419,9 @@ func (c *msgClient) UpdateDefaultQuotingParams(ctx context.Context, in *MsgUpdat return out, nil } -func (c *msgClient) SetVaultQuotingParams(ctx context.Context, in *MsgSetVaultQuotingParams, opts ...grpc.CallOption) (*MsgSetVaultQuotingParamsResponse, error) { - out := new(MsgSetVaultQuotingParamsResponse) - err := c.cc.Invoke(ctx, "/dydxprotocol.vault.Msg/SetVaultQuotingParams", in, out, opts...) +func (c *msgClient) SetVaultParams(ctx context.Context, in *MsgSetVaultParams, opts ...grpc.CallOption) (*MsgSetVaultParamsResponse, error) { + out := new(MsgSetVaultParamsResponse) + err := c.cc.Invoke(ctx, "/dydxprotocol.vault.Msg/SetVaultParams", in, out, opts...) if err != nil { return nil, err } @@ -434,8 +434,8 @@ type MsgServer interface { DepositToVault(context.Context, *MsgDepositToVault) (*MsgDepositToVaultResponse, error) // UpdateDefaultQuotingParams updates the default quoting params in state. UpdateDefaultQuotingParams(context.Context, *MsgUpdateDefaultQuotingParams) (*MsgUpdateDefaultQuotingParamsResponse, error) - // SetVaultQuotingParams sets the quoting parameters of a specific vault. - SetVaultQuotingParams(context.Context, *MsgSetVaultQuotingParams) (*MsgSetVaultQuotingParamsResponse, error) + // SetVaultParams sets the parameters of a specific vault. + SetVaultParams(context.Context, *MsgSetVaultParams) (*MsgSetVaultParamsResponse, error) } // UnimplementedMsgServer can be embedded to have forward compatible implementations. @@ -448,8 +448,8 @@ func (*UnimplementedMsgServer) DepositToVault(ctx context.Context, req *MsgDepos func (*UnimplementedMsgServer) UpdateDefaultQuotingParams(ctx context.Context, req *MsgUpdateDefaultQuotingParams) (*MsgUpdateDefaultQuotingParamsResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method UpdateDefaultQuotingParams not implemented") } -func (*UnimplementedMsgServer) SetVaultQuotingParams(ctx context.Context, req *MsgSetVaultQuotingParams) (*MsgSetVaultQuotingParamsResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method SetVaultQuotingParams not implemented") +func (*UnimplementedMsgServer) SetVaultParams(ctx context.Context, req *MsgSetVaultParams) (*MsgSetVaultParamsResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method SetVaultParams not implemented") } func RegisterMsgServer(s grpc1.Server, srv MsgServer) { @@ -492,20 +492,20 @@ func _Msg_UpdateDefaultQuotingParams_Handler(srv interface{}, ctx context.Contex return interceptor(ctx, in, info, handler) } -func _Msg_SetVaultQuotingParams_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(MsgSetVaultQuotingParams) +func _Msg_SetVaultParams_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgSetVaultParams) if err := dec(in); err != nil { return nil, err } if interceptor == nil { - return srv.(MsgServer).SetVaultQuotingParams(ctx, in) + return srv.(MsgServer).SetVaultParams(ctx, in) } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/dydxprotocol.vault.Msg/SetVaultQuotingParams", + FullMethod: "/dydxprotocol.vault.Msg/SetVaultParams", } handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(MsgServer).SetVaultQuotingParams(ctx, req.(*MsgSetVaultQuotingParams)) + return srv.(MsgServer).SetVaultParams(ctx, req.(*MsgSetVaultParams)) } return interceptor(ctx, in, info, handler) } @@ -523,8 +523,8 @@ var _Msg_serviceDesc = grpc.ServiceDesc{ Handler: _Msg_UpdateDefaultQuotingParams_Handler, }, { - MethodName: "SetVaultQuotingParams", - Handler: _Msg_SetVaultQuotingParams_Handler, + MethodName: "SetVaultParams", + Handler: _Msg_SetVaultParams_Handler, }, }, Streams: []grpc.StreamDesc{}, @@ -674,7 +674,7 @@ func (m *MsgUpdateDefaultQuotingParamsResponse) MarshalToSizedBuffer(dAtA []byte return len(dAtA) - i, nil } -func (m *MsgSetVaultQuotingParams) Marshal() (dAtA []byte, err error) { +func (m *MsgSetVaultParams) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -684,18 +684,18 @@ func (m *MsgSetVaultQuotingParams) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *MsgSetVaultQuotingParams) MarshalTo(dAtA []byte) (int, error) { +func (m *MsgSetVaultParams) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *MsgSetVaultQuotingParams) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *MsgSetVaultParams) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int _ = l { - size, err := m.QuotingParams.MarshalToSizedBuffer(dAtA[:i]) + size, err := m.VaultParams.MarshalToSizedBuffer(dAtA[:i]) if err != nil { return 0, err } @@ -724,7 +724,7 @@ func (m *MsgSetVaultQuotingParams) MarshalToSizedBuffer(dAtA []byte) (int, error return len(dAtA) - i, nil } -func (m *MsgSetVaultQuotingParamsResponse) Marshal() (dAtA []byte, err error) { +func (m *MsgSetVaultParamsResponse) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -734,12 +734,12 @@ func (m *MsgSetVaultQuotingParamsResponse) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *MsgSetVaultQuotingParamsResponse) MarshalTo(dAtA []byte) (int, error) { +func (m *MsgSetVaultParamsResponse) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *MsgSetVaultQuotingParamsResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *MsgSetVaultParamsResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int @@ -810,7 +810,7 @@ func (m *MsgUpdateDefaultQuotingParamsResponse) Size() (n int) { return n } -func (m *MsgSetVaultQuotingParams) Size() (n int) { +func (m *MsgSetVaultParams) Size() (n int) { if m == nil { return 0 } @@ -822,12 +822,12 @@ func (m *MsgSetVaultQuotingParams) Size() (n int) { } l = m.VaultId.Size() n += 1 + l + sovTx(uint64(l)) - l = m.QuotingParams.Size() + l = m.VaultParams.Size() n += 1 + l + sovTx(uint64(l)) return n } -func (m *MsgSetVaultQuotingParamsResponse) Size() (n int) { +func (m *MsgSetVaultParamsResponse) Size() (n int) { if m == nil { return 0 } @@ -1212,7 +1212,7 @@ func (m *MsgUpdateDefaultQuotingParamsResponse) Unmarshal(dAtA []byte) error { } return nil } -func (m *MsgSetVaultQuotingParams) Unmarshal(dAtA []byte) error { +func (m *MsgSetVaultParams) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -1235,10 +1235,10 @@ func (m *MsgSetVaultQuotingParams) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: MsgSetVaultQuotingParams: wiretype end group for non-group") + return fmt.Errorf("proto: MsgSetVaultParams: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: MsgSetVaultQuotingParams: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: MsgSetVaultParams: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: @@ -1308,7 +1308,7 @@ func (m *MsgSetVaultQuotingParams) Unmarshal(dAtA []byte) error { iNdEx = postIndex case 3: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field QuotingParams", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field VaultParams", wireType) } var msglen int for shift := uint(0); ; shift += 7 { @@ -1335,7 +1335,7 @@ func (m *MsgSetVaultQuotingParams) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - if err := m.QuotingParams.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + if err := m.VaultParams.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } iNdEx = postIndex @@ -1360,7 +1360,7 @@ func (m *MsgSetVaultQuotingParams) Unmarshal(dAtA []byte) error { } return nil } -func (m *MsgSetVaultQuotingParamsResponse) Unmarshal(dAtA []byte) error { +func (m *MsgSetVaultParamsResponse) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -1383,10 +1383,10 @@ func (m *MsgSetVaultQuotingParamsResponse) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: MsgSetVaultQuotingParamsResponse: wiretype end group for non-group") + return fmt.Errorf("proto: MsgSetVaultParamsResponse: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: MsgSetVaultQuotingParamsResponse: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: MsgSetVaultParamsResponse: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { default: diff --git a/protocol/x/vault/types/vault.pb.go b/protocol/x/vault/types/vault.pb.go index 99577b61fe..738c7ffc9c 100644 --- a/protocol/x/vault/types/vault.pb.go +++ b/protocol/x/vault/types/vault.pb.go @@ -50,6 +50,46 @@ func (VaultType) EnumDescriptor() ([]byte, []int) { return fileDescriptor_32accb5830bb2860, []int{0} } +// VaultStatus represents the status of a vault. +type VaultStatus int32 + +const ( + // Default value, invalid and unused. + VaultStatus_VAULT_STATUS_UNSPECIFIED VaultStatus = 0 + // Don’t place orders. Does not count toward global vault balances. + VaultStatus_VAULT_STATUS_DEACTIVATED VaultStatus = 1 + // Don’t place orders. Does count towards global vault balances. + VaultStatus_VAULT_STATUS_STAND_BY VaultStatus = 2 + // Places orders on both sides of the book. + VaultStatus_VAULT_STATUS_QUOTING VaultStatus = 3 + // Only place orders that close the position. + VaultStatus_VAULT_STATUS_CLOSE_ONLY VaultStatus = 4 +) + +var VaultStatus_name = map[int32]string{ + 0: "VAULT_STATUS_UNSPECIFIED", + 1: "VAULT_STATUS_DEACTIVATED", + 2: "VAULT_STATUS_STAND_BY", + 3: "VAULT_STATUS_QUOTING", + 4: "VAULT_STATUS_CLOSE_ONLY", +} + +var VaultStatus_value = map[string]int32{ + "VAULT_STATUS_UNSPECIFIED": 0, + "VAULT_STATUS_DEACTIVATED": 1, + "VAULT_STATUS_STAND_BY": 2, + "VAULT_STATUS_QUOTING": 3, + "VAULT_STATUS_CLOSE_ONLY": 4, +} + +func (x VaultStatus) String() string { + return proto.EnumName(VaultStatus_name, int32(x)) +} + +func (VaultStatus) EnumDescriptor() ([]byte, []int) { + return fileDescriptor_32accb5830bb2860, []int{1} +} + // VaultId uniquely identifies a vault by its type and number. type VaultId struct { // Type of the vault. @@ -107,13 +147,14 @@ func (m *VaultId) GetNumber() uint32 { func init() { proto.RegisterEnum("dydxprotocol.vault.VaultType", VaultType_name, VaultType_value) + proto.RegisterEnum("dydxprotocol.vault.VaultStatus", VaultStatus_name, VaultStatus_value) proto.RegisterType((*VaultId)(nil), "dydxprotocol.vault.VaultId") } func init() { proto.RegisterFile("dydxprotocol/vault/vault.proto", fileDescriptor_32accb5830bb2860) } var fileDescriptor_32accb5830bb2860 = []byte{ - // 222 bytes of a gzipped FileDescriptorProto + // 314 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x92, 0x4b, 0xa9, 0x4c, 0xa9, 0x28, 0x28, 0xca, 0x2f, 0xc9, 0x4f, 0xce, 0xcf, 0xd1, 0x2f, 0x4b, 0x2c, 0xcd, 0x29, 0x81, 0x90, 0x7a, 0x60, 0x41, 0x21, 0x21, 0x64, 0x79, 0x3d, 0xb0, 0x8c, 0x52, 0x08, 0x17, 0x7b, 0x18, 0x88, @@ -123,11 +164,17 @@ var fileDescriptor_32accb5830bb2860 = []byte{ 0x08, 0xca, 0xd3, 0xb2, 0xe1, 0xe2, 0x84, 0x2b, 0x15, 0x92, 0xe2, 0x12, 0x0b, 0x73, 0x0c, 0xf5, 0x09, 0x89, 0x0f, 0x89, 0x0c, 0x70, 0x8d, 0x0f, 0xf5, 0x0b, 0x0e, 0x70, 0x75, 0xf6, 0x74, 0xf3, 0x74, 0x75, 0x11, 0x60, 0x10, 0x12, 0xe6, 0xe2, 0x47, 0x92, 0x73, 0xf6, 0xf1, 0x77, 0x12, 0x60, - 0x74, 0x0a, 0x3c, 0xf1, 0x48, 0x8e, 0xf1, 0xc2, 0x23, 0x39, 0xc6, 0x07, 0x8f, 0xe4, 0x18, 0x27, - 0x3c, 0x96, 0x63, 0xb8, 0xf0, 0x58, 0x8e, 0xe1, 0xc6, 0x63, 0x39, 0x86, 0x28, 0xf3, 0xf4, 0xcc, - 0x92, 0x8c, 0xd2, 0x24, 0xbd, 0xe4, 0xfc, 0x5c, 0x7d, 0x54, 0xcf, 0x9a, 0xe8, 0x26, 0x67, 0x24, - 0x66, 0xe6, 0xe9, 0xc3, 0x45, 0x2a, 0xa0, 0x01, 0x00, 0x72, 0x67, 0x71, 0x12, 0x1b, 0x58, 0xdc, - 0x18, 0x10, 0x00, 0x00, 0xff, 0xff, 0x6f, 0x06, 0x99, 0xfd, 0x23, 0x01, 0x00, 0x00, + 0xd4, 0x9a, 0xcd, 0xc8, 0xc5, 0x0d, 0xd6, 0x1e, 0x5c, 0x92, 0x58, 0x52, 0x5a, 0x2c, 0x24, 0xc3, + 0x25, 0x01, 0x51, 0x14, 0x1c, 0xe2, 0x18, 0x12, 0x1a, 0x8c, 0x66, 0x04, 0xba, 0xac, 0x8b, 0xab, + 0xa3, 0x73, 0x88, 0x67, 0x98, 0x63, 0x88, 0xab, 0x8b, 0x00, 0xa3, 0x90, 0x24, 0x97, 0x28, 0x8a, + 0x6c, 0x70, 0x88, 0xa3, 0x9f, 0x4b, 0xbc, 0x53, 0xa4, 0x00, 0x93, 0x90, 0x04, 0x97, 0x08, 0x8a, + 0x54, 0x60, 0xa8, 0x7f, 0x88, 0xa7, 0x9f, 0xbb, 0x00, 0xb3, 0x90, 0x34, 0x97, 0x38, 0x8a, 0x8c, + 0xb3, 0x8f, 0x7f, 0xb0, 0x6b, 0xbc, 0xbf, 0x9f, 0x4f, 0xa4, 0x00, 0x8b, 0x53, 0xe0, 0x89, 0x47, + 0x72, 0x8c, 0x17, 0x1e, 0xc9, 0x31, 0x3e, 0x78, 0x24, 0xc7, 0x38, 0xe1, 0xb1, 0x1c, 0xc3, 0x85, + 0xc7, 0x72, 0x0c, 0x37, 0x1e, 0xcb, 0x31, 0x44, 0x99, 0xa7, 0x67, 0x96, 0x64, 0x94, 0x26, 0xe9, + 0x25, 0xe7, 0xe7, 0xea, 0xa3, 0x46, 0x85, 0x89, 0x6e, 0x72, 0x46, 0x62, 0x66, 0x9e, 0x3e, 0x5c, + 0xa4, 0x02, 0x1a, 0x3d, 0xa0, 0x50, 0x2c, 0x4e, 0x62, 0x03, 0x8b, 0x1b, 0x03, 0x02, 0x00, 0x00, + 0xff, 0xff, 0xab, 0x97, 0xb2, 0xb0, 0xc1, 0x01, 0x00, 0x00, } func (m *VaultId) Marshal() (dAtA []byte, err error) {