From addac5b125da7368fa239da90962b411144f1968 Mon Sep 17 00:00:00 2001 From: Tian Qin Date: Fri, 2 Aug 2024 15:30:05 -0400 Subject: [PATCH] add gov msg that sets vault quoting params --- .../src/codegen/dydxprotocol/clob/order.ts | 128 +++++ .../src/codegen/dydxprotocol/clob/query.ts | 214 +++++++- .../codegen/dydxprotocol/vault/tx.rpc.msg.ts | 12 +- .../src/codegen/dydxprotocol/vault/tx.ts | 133 +++++ proto/dydxprotocol/vault/tx.proto | 21 + protocol/app/msgs/all_msgs.go | 2 + protocol/app/msgs/internal_msgs.go | 2 + protocol/app/msgs/internal_msgs_test.go | 2 + protocol/lib/ante/internal_msg.go | 1 + protocol/testutil/constants/vault.go | 10 + .../msg_server_set_vault_quoting_params.go | 40 ++ ...sg_server_set_vault_quoting_params_test.go | 89 +++ protocol/x/vault/keeper/vault.go | 9 +- protocol/x/vault/keeper/vault_test.go | 22 +- protocol/x/vault/types/tx.pb.go | 511 ++++++++++++++++-- 15 files changed, 1154 insertions(+), 42 deletions(-) create mode 100644 protocol/x/vault/keeper/msg_server_set_vault_quoting_params.go create mode 100644 protocol/x/vault/keeper/msg_server_set_vault_quoting_params_test.go diff --git a/indexer/packages/v4-protos/src/codegen/dydxprotocol/clob/order.ts b/indexer/packages/v4-protos/src/codegen/dydxprotocol/clob/order.ts index aeaaa06aa69..fcfd44ba3f1 100644 --- a/indexer/packages/v4-protos/src/codegen/dydxprotocol/clob/order.ts +++ b/indexer/packages/v4-protos/src/codegen/dydxprotocol/clob/order.ts @@ -1,4 +1,5 @@ import { SubaccountId, SubaccountIdSDKType } from "../subaccounts/subaccount"; +import { PerpetualLiquidationInfo, PerpetualLiquidationInfoSDKType } from "./liquidations"; import * as _m0 from "protobufjs/minimal"; import { DeepPartial, Long } from "../../helpers"; /** @@ -700,6 +701,48 @@ export interface TransactionOrderingSDKType { transaction_index: number; } +/** + * StreamLiquidationOrder represents an protocol-generated IOC liquidation order. + * Used in full node streaming. + */ + +export interface StreamLiquidationOrder { + /** Information about this liquidation order. */ + liquidationInfo?: PerpetualLiquidationInfo; + /** CLOB pair ID of the CLOB pair the liquidation order will be matched against. */ + + clobPairId: number; + /** True if this is a buy order liquidating a short position, false if vice versa. */ + + isBuy: boolean; + /** The number of base quantums for this liquidation order. */ + + quantums: Long; + /** The subticks this liquidation order will be submitted at. */ + + subticks: Long; +} +/** + * StreamLiquidationOrder represents an protocol-generated IOC liquidation order. + * Used in full node streaming. + */ + +export interface StreamLiquidationOrderSDKType { + /** Information about this liquidation order. */ + liquidation_info?: PerpetualLiquidationInfoSDKType; + /** CLOB pair ID of the CLOB pair the liquidation order will be matched against. */ + + clob_pair_id: number; + /** True if this is a buy order liquidating a short position, false if vice versa. */ + + is_buy: boolean; + /** The number of base quantums for this liquidation order. */ + + quantums: Long; + /** The subticks this liquidation order will be submitted at. */ + + subticks: Long; +} function createBaseOrderId(): OrderId { return { @@ -1284,4 +1327,89 @@ export const TransactionOrdering = { return message; } +}; + +function createBaseStreamLiquidationOrder(): StreamLiquidationOrder { + return { + liquidationInfo: undefined, + clobPairId: 0, + isBuy: false, + quantums: Long.UZERO, + subticks: Long.UZERO + }; +} + +export const StreamLiquidationOrder = { + encode(message: StreamLiquidationOrder, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { + if (message.liquidationInfo !== undefined) { + PerpetualLiquidationInfo.encode(message.liquidationInfo, writer.uint32(10).fork()).ldelim(); + } + + if (message.clobPairId !== 0) { + writer.uint32(16).uint32(message.clobPairId); + } + + if (message.isBuy === true) { + writer.uint32(24).bool(message.isBuy); + } + + if (!message.quantums.isZero()) { + writer.uint32(32).uint64(message.quantums); + } + + if (!message.subticks.isZero()) { + writer.uint32(40).uint64(message.subticks); + } + + return writer; + }, + + decode(input: _m0.Reader | Uint8Array, length?: number): StreamLiquidationOrder { + const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseStreamLiquidationOrder(); + + while (reader.pos < end) { + const tag = reader.uint32(); + + switch (tag >>> 3) { + case 1: + message.liquidationInfo = PerpetualLiquidationInfo.decode(reader, reader.uint32()); + break; + + case 2: + message.clobPairId = reader.uint32(); + break; + + case 3: + message.isBuy = reader.bool(); + break; + + case 4: + message.quantums = (reader.uint64() as Long); + break; + + case 5: + message.subticks = (reader.uint64() as Long); + break; + + default: + reader.skipType(tag & 7); + break; + } + } + + return message; + }, + + fromPartial(object: DeepPartial): StreamLiquidationOrder { + const message = createBaseStreamLiquidationOrder(); + message.liquidationInfo = object.liquidationInfo !== undefined && object.liquidationInfo !== null ? PerpetualLiquidationInfo.fromPartial(object.liquidationInfo) : undefined; + message.clobPairId = object.clobPairId ?? 0; + message.isBuy = object.isBuy ?? false; + message.quantums = object.quantums !== undefined && object.quantums !== null ? Long.fromValue(object.quantums) : Long.UZERO; + message.subticks = object.subticks !== undefined && object.subticks !== null ? Long.fromValue(object.subticks) : Long.UZERO; + return message; + } + }; \ No newline at end of file diff --git a/indexer/packages/v4-protos/src/codegen/dydxprotocol/clob/query.ts b/indexer/packages/v4-protos/src/codegen/dydxprotocol/clob/query.ts index e3ebe88ee09..57c9dc32658 100644 --- a/indexer/packages/v4-protos/src/codegen/dydxprotocol/clob/query.ts +++ b/indexer/packages/v4-protos/src/codegen/dydxprotocol/clob/query.ts @@ -1,6 +1,6 @@ import { PageRequest, PageRequestSDKType, PageResponse, PageResponseSDKType } from "../../cosmos/base/query/v1beta1/pagination"; import { ValidatorMevMatches, ValidatorMevMatchesSDKType, MevNodeToNodeMetrics, MevNodeToNodeMetricsSDKType } from "./mev"; -import { OrderId, OrderIdSDKType, LongTermOrderPlacement, LongTermOrderPlacementSDKType, Order, OrderSDKType } from "./order"; +import { OrderId, OrderIdSDKType, LongTermOrderPlacement, LongTermOrderPlacementSDKType, Order, OrderSDKType, StreamLiquidationOrder, StreamLiquidationOrderSDKType } from "./order"; import { ClobPair, ClobPairSDKType } from "./clob_pair"; import { EquityTierLimitConfiguration, EquityTierLimitConfigurationSDKType } from "./equity_tier_limit_config"; import { BlockRateLimitConfiguration, BlockRateLimitConfigurationSDKType } from "./block_rate_limit_config"; @@ -391,6 +391,88 @@ export interface StreamOrderbookFillSDKType { fill_amounts: Long[]; } +/** + * StreamTakerOrder provides information on a taker order that was attempted + * to be matched on the orderbook. + * It is intended to be used only in full node streaming. + */ + +export interface StreamTakerOrder { + order?: Order; + liquidationOrder?: StreamLiquidationOrder; + /** + * Information on the taker order after it is matched on the book, + * either successfully or unsuccessfully. + */ + + takerOrderStatus?: StreamTakerOrderStatus; +} +/** + * StreamTakerOrder provides information on a taker order that was attempted + * to be matched on the orderbook. + * It is intended to be used only in full node streaming. + */ + +export interface StreamTakerOrderSDKType { + order?: OrderSDKType; + liquidation_order?: StreamLiquidationOrderSDKType; + /** + * Information on the taker order after it is matched on the book, + * either successfully or unsuccessfully. + */ + + taker_order_status?: StreamTakerOrderStatusSDKType; +} +/** + * StreamTakerOrderStatus is a representation of a taker order + * after it is attempted to be matched on the orderbook. + * It is intended to be used only in full node streaming. + */ + +export interface StreamTakerOrderStatus { + /** + * The state of the taker order after attempting to match it against the orderbook. + * Possible enum values can be found here: + * https://github.com/dydxprotocol/v4-chain/blob/main/protocol/x/clob/types/orderbook.go#L105 + */ + orderStatus: number; + /** The amount of remaining (non-matched) base quantums of this taker order. */ + + remainingQuantums: Long; + /** + * The amount of base quantums that were *optimistically* filled for this taker order + * when the order is matched against the orderbook. Note that if any quantums of this order + * were optimistically filled or filled in state before this invocation of the matching loop, + * this value will not include them. + */ + + optimisticallyFilledQuantums: Long; +} +/** + * StreamTakerOrderStatus is a representation of a taker order + * after it is attempted to be matched on the orderbook. + * It is intended to be used only in full node streaming. + */ + +export interface StreamTakerOrderStatusSDKType { + /** + * The state of the taker order after attempting to match it against the orderbook. + * Possible enum values can be found here: + * https://github.com/dydxprotocol/v4-chain/blob/main/protocol/x/clob/types/orderbook.go#L105 + */ + order_status: number; + /** The amount of remaining (non-matched) base quantums of this taker order. */ + + remaining_quantums: Long; + /** + * The amount of base quantums that were *optimistically* filled for this taker order + * when the order is matched against the orderbook. Note that if any quantums of this order + * were optimistically filled or filled in state before this invocation of the matching loop, + * this value will not include them. + */ + + optimistically_filled_quantums: Long; +} function createBaseQueryGetClobPairRequest(): QueryGetClobPairRequest { return { @@ -1401,4 +1483,134 @@ export const StreamOrderbookFill = { return message; } +}; + +function createBaseStreamTakerOrder(): StreamTakerOrder { + return { + order: undefined, + liquidationOrder: undefined, + takerOrderStatus: undefined + }; +} + +export const StreamTakerOrder = { + encode(message: StreamTakerOrder, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { + if (message.order !== undefined) { + Order.encode(message.order, writer.uint32(10).fork()).ldelim(); + } + + if (message.liquidationOrder !== undefined) { + StreamLiquidationOrder.encode(message.liquidationOrder, writer.uint32(18).fork()).ldelim(); + } + + if (message.takerOrderStatus !== undefined) { + StreamTakerOrderStatus.encode(message.takerOrderStatus, writer.uint32(26).fork()).ldelim(); + } + + return writer; + }, + + decode(input: _m0.Reader | Uint8Array, length?: number): StreamTakerOrder { + const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseStreamTakerOrder(); + + while (reader.pos < end) { + const tag = reader.uint32(); + + switch (tag >>> 3) { + case 1: + message.order = Order.decode(reader, reader.uint32()); + break; + + case 2: + message.liquidationOrder = StreamLiquidationOrder.decode(reader, reader.uint32()); + break; + + case 3: + message.takerOrderStatus = StreamTakerOrderStatus.decode(reader, reader.uint32()); + break; + + default: + reader.skipType(tag & 7); + break; + } + } + + return message; + }, + + fromPartial(object: DeepPartial): StreamTakerOrder { + const message = createBaseStreamTakerOrder(); + message.order = object.order !== undefined && object.order !== null ? Order.fromPartial(object.order) : undefined; + message.liquidationOrder = object.liquidationOrder !== undefined && object.liquidationOrder !== null ? StreamLiquidationOrder.fromPartial(object.liquidationOrder) : undefined; + message.takerOrderStatus = object.takerOrderStatus !== undefined && object.takerOrderStatus !== null ? StreamTakerOrderStatus.fromPartial(object.takerOrderStatus) : undefined; + return message; + } + +}; + +function createBaseStreamTakerOrderStatus(): StreamTakerOrderStatus { + return { + orderStatus: 0, + remainingQuantums: Long.UZERO, + optimisticallyFilledQuantums: Long.UZERO + }; +} + +export const StreamTakerOrderStatus = { + encode(message: StreamTakerOrderStatus, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { + if (message.orderStatus !== 0) { + writer.uint32(8).uint32(message.orderStatus); + } + + if (!message.remainingQuantums.isZero()) { + writer.uint32(16).uint64(message.remainingQuantums); + } + + if (!message.optimisticallyFilledQuantums.isZero()) { + writer.uint32(24).uint64(message.optimisticallyFilledQuantums); + } + + return writer; + }, + + decode(input: _m0.Reader | Uint8Array, length?: number): StreamTakerOrderStatus { + const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseStreamTakerOrderStatus(); + + while (reader.pos < end) { + const tag = reader.uint32(); + + switch (tag >>> 3) { + case 1: + message.orderStatus = reader.uint32(); + break; + + case 2: + message.remainingQuantums = (reader.uint64() as Long); + break; + + case 3: + message.optimisticallyFilledQuantums = (reader.uint64() as Long); + break; + + default: + reader.skipType(tag & 7); + break; + } + } + + return message; + }, + + fromPartial(object: DeepPartial): StreamTakerOrderStatus { + const message = createBaseStreamTakerOrderStatus(); + message.orderStatus = object.orderStatus ?? 0; + message.remainingQuantums = object.remainingQuantums !== undefined && object.remainingQuantums !== null ? Long.fromValue(object.remainingQuantums) : Long.UZERO; + message.optimisticallyFilledQuantums = object.optimisticallyFilledQuantums !== undefined && object.optimisticallyFilledQuantums !== null ? Long.fromValue(object.optimisticallyFilledQuantums) : Long.UZERO; + return message; + } + }; \ No newline at end of file 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 6f79eea71c2..b207669872f 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 } from "./tx"; +import { MsgDepositToVault, MsgDepositToVaultResponse, MsgUpdateDefaultQuotingParams, MsgUpdateDefaultQuotingParamsResponse, MsgSetVaultQuotingParams, MsgSetVaultQuotingParamsResponse } from "./tx"; /** Msg defines the Msg service. */ export interface Msg { @@ -9,6 +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. */ + + setVaultQuotingParams(request: MsgSetVaultQuotingParams): Promise; } export class MsgClientImpl implements Msg { private readonly rpc: Rpc; @@ -17,6 +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); } depositToVault(request: MsgDepositToVault): Promise { @@ -31,4 +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))); + } + } \ 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 682b7c183e7..5c8470c4a22 100644 --- a/indexer/packages/v4-protos/src/codegen/dydxprotocol/vault/tx.ts +++ b/indexer/packages/v4-protos/src/codegen/dydxprotocol/vault/tx.ts @@ -73,6 +73,40 @@ export interface MsgUpdateDefaultQuotingParamsResponse {} */ export interface MsgUpdateDefaultQuotingParamsResponseSDKType {} +/** MsgSetVaultQuotingParams is the Msg/SetVaultQuotingParams request type. */ + +export interface MsgSetVaultQuotingParams { + authority: string; + /** The vault to set quoting params of. */ + + vaultId?: VaultId; + /** The quoting parameters to set. Each field must be set. */ + + quotingParams?: QuotingParams; +} +/** MsgSetVaultQuotingParams is the Msg/SetVaultQuotingParams request type. */ + +export interface MsgSetVaultQuotingParamsSDKType { + authority: string; + /** The vault to set quoting params of. */ + + vault_id?: VaultIdSDKType; + /** The quoting parameters to set. Each field must be set. */ + + quoting_params?: QuotingParamsSDKType; +} +/** + * MsgSetVaultQuotingParamsResponse is the Msg/SetVaultQuotingParams response + * type. + */ + +export interface MsgSetVaultQuotingParamsResponse {} +/** + * MsgSetVaultQuotingParamsResponse is the Msg/SetVaultQuotingParams response + * type. + */ + +export interface MsgSetVaultQuotingParamsResponseSDKType {} function createBaseMsgDepositToVault(): MsgDepositToVault { return { @@ -260,4 +294,103 @@ export const MsgUpdateDefaultQuotingParamsResponse = { return message; } +}; + +function createBaseMsgSetVaultQuotingParams(): MsgSetVaultQuotingParams { + return { + authority: "", + vaultId: undefined, + quotingParams: undefined + }; +} + +export const MsgSetVaultQuotingParams = { + encode(message: MsgSetVaultQuotingParams, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { + if (message.authority !== "") { + writer.uint32(10).string(message.authority); + } + + if (message.vaultId !== undefined) { + VaultId.encode(message.vaultId, writer.uint32(18).fork()).ldelim(); + } + + if (message.quotingParams !== undefined) { + QuotingParams.encode(message.quotingParams, writer.uint32(26).fork()).ldelim(); + } + + return writer; + }, + + decode(input: _m0.Reader | Uint8Array, length?: number): MsgSetVaultQuotingParams { + const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseMsgSetVaultQuotingParams(); + + while (reader.pos < end) { + const tag = reader.uint32(); + + switch (tag >>> 3) { + case 1: + message.authority = reader.string(); + break; + + case 2: + message.vaultId = VaultId.decode(reader, reader.uint32()); + break; + + case 3: + message.quotingParams = QuotingParams.decode(reader, reader.uint32()); + break; + + default: + reader.skipType(tag & 7); + break; + } + } + + return message; + }, + + fromPartial(object: DeepPartial): MsgSetVaultQuotingParams { + const message = createBaseMsgSetVaultQuotingParams(); + 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; + return message; + } + +}; + +function createBaseMsgSetVaultQuotingParamsResponse(): MsgSetVaultQuotingParamsResponse { + return {}; +} + +export const MsgSetVaultQuotingParamsResponse = { + encode(_: MsgSetVaultQuotingParamsResponse, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { + return writer; + }, + + decode(input: _m0.Reader | Uint8Array, length?: number): MsgSetVaultQuotingParamsResponse { + const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseMsgSetVaultQuotingParamsResponse(); + + while (reader.pos < end) { + const tag = reader.uint32(); + + switch (tag >>> 3) { + default: + reader.skipType(tag & 7); + break; + } + } + + return message; + }, + + fromPartial(_: DeepPartial): MsgSetVaultQuotingParamsResponse { + const message = createBaseMsgSetVaultQuotingParamsResponse(); + return message; + } + }; \ No newline at end of file diff --git a/proto/dydxprotocol/vault/tx.proto b/proto/dydxprotocol/vault/tx.proto index 9ff30685529..c9119c3e4eb 100644 --- a/proto/dydxprotocol/vault/tx.proto +++ b/proto/dydxprotocol/vault/tx.proto @@ -18,6 +18,10 @@ service Msg { // UpdateDefaultQuotingParams updates the default quoting params in state. rpc UpdateDefaultQuotingParams(MsgUpdateDefaultQuotingParams) returns (MsgUpdateDefaultQuotingParamsResponse); + + // SetVaultQuotingParams sets the quoting parameters of a specific vault. + rpc SetVaultQuotingParams(MsgSetVaultQuotingParams) + returns (MsgSetVaultQuotingParamsResponse); } // MsgDepositToVault deposits the specified asset from the subaccount to the @@ -59,3 +63,20 @@ message MsgUpdateDefaultQuotingParams { // MsgUpdateDefaultQuotingParamsResponse is the Msg/UpdateDefaultQuotingParams // response type. message MsgUpdateDefaultQuotingParamsResponse {} + +// MsgSetVaultQuotingParams is the Msg/SetVaultQuotingParams request type. +message MsgSetVaultQuotingParams { + // 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. + VaultId vault_id = 2 [ (gogoproto.nullable) = false ]; + + // The quoting parameters to set. Each field must be set. + QuotingParams quoting_params = 3 [ (gogoproto.nullable) = false ]; +} + +// MsgSetVaultQuotingParamsResponse is the Msg/SetVaultQuotingParams response +// type. +message MsgSetVaultQuotingParamsResponse {} diff --git a/protocol/app/msgs/all_msgs.go b/protocol/app/msgs/all_msgs.go index bc120b78961..6423f335260 100644 --- a/protocol/app/msgs/all_msgs.go +++ b/protocol/app/msgs/all_msgs.go @@ -245,6 +245,8 @@ var ( "/dydxprotocol.vault.MsgDepositToVaultResponse": {}, "/dydxprotocol.vault.MsgUpdateDefaultQuotingParams": {}, "/dydxprotocol.vault.MsgUpdateDefaultQuotingParamsResponse": {}, + "/dydxprotocol.vault.MsgSetVaultQuotingParams": {}, + "/dydxprotocol.vault.MsgSetVaultQuotingParamsResponse": {}, // vest "/dydxprotocol.vest.MsgSetVestEntry": {}, diff --git a/protocol/app/msgs/internal_msgs.go b/protocol/app/msgs/internal_msgs.go index 9d43de6c6fc..aa76606acfa 100644 --- a/protocol/app/msgs/internal_msgs.go +++ b/protocol/app/msgs/internal_msgs.go @@ -188,6 +188,8 @@ var ( // vault "/dydxprotocol.vault.MsgUpdateDefaultQuotingParams": &vault.MsgUpdateDefaultQuotingParams{}, "/dydxprotocol.vault.MsgUpdateDefaultQuotingParamsResponse": nil, + "/dydxprotocol.vault.MsgSetVaultQuotingParams": &vault.MsgSetVaultQuotingParams{}, + "/dydxprotocol.vault.MsgSetVaultQuotingParamsResponse": nil, // vest "/dydxprotocol.vest.MsgSetVestEntry": &vest.MsgSetVestEntry{}, diff --git a/protocol/app/msgs/internal_msgs_test.go b/protocol/app/msgs/internal_msgs_test.go index 9b66919e7fe..6138d7ba56d 100644 --- a/protocol/app/msgs/internal_msgs_test.go +++ b/protocol/app/msgs/internal_msgs_test.go @@ -146,6 +146,8 @@ func TestInternalMsgSamples_Gov_Key(t *testing.T) { // vault "/dydxprotocol.vault.MsgUpdateDefaultQuotingParams", "/dydxprotocol.vault.MsgUpdateDefaultQuotingParamsResponse", + "/dydxprotocol.vault.MsgSetVaultQuotingParams", + "/dydxprotocol.vault.MsgSetVaultQuotingParamsResponse", // vest "/dydxprotocol.vest.MsgDeleteVestEntry", diff --git a/protocol/lib/ante/internal_msg.go b/protocol/lib/ante/internal_msg.go index a0951c5d8c8..8537a80f703 100644 --- a/protocol/lib/ante/internal_msg.go +++ b/protocol/lib/ante/internal_msg.go @@ -127,6 +127,7 @@ func IsInternalMsg(msg sdk.Msg) bool { // vault *vault.MsgUpdateDefaultQuotingParams, + *vault.MsgSetVaultQuotingParams, // vest *vest.MsgDeleteVestEntry, diff --git a/protocol/testutil/constants/vault.go b/protocol/testutil/constants/vault.go index de97a965d45..23fc44feb4b 100644 --- a/protocol/testutil/constants/vault.go +++ b/protocol/testutil/constants/vault.go @@ -20,4 +20,14 @@ var ( SubaccountId: &Alice_Num0, QuoteQuantums: dtypes.NewInt(100), } + + QuotingParams = types.QuotingParams{ + Layers: 3, + SpreadMinPpm: 4_321, + SpreadBufferPpm: 1_789, + SkewFactorPpm: 767_323, + OrderSizePctPpm: 234_567, + OrderExpirationSeconds: 111, + ActivationThresholdQuoteQuantums: dtypes.NewInt(9_876_543), + } ) diff --git a/protocol/x/vault/keeper/msg_server_set_vault_quoting_params.go b/protocol/x/vault/keeper/msg_server_set_vault_quoting_params.go new file mode 100644 index 00000000000..ecdfd98a59a --- /dev/null +++ b/protocol/x/vault/keeper/msg_server_set_vault_quoting_params.go @@ -0,0 +1,40 @@ +package keeper + +import ( + "context" + + errorsmod "cosmossdk.io/errors" + + govtypes "github.com/cosmos/cosmos-sdk/x/gov/types" + "github.com/dydxprotocol/v4-chain/protocol/lib" + "github.com/dydxprotocol/v4-chain/protocol/x/vault/types" +) + +// SetVaultQuotingParams sets the quoting parameters of a specific vault. +func (k msgServer) SetVaultQuotingParams( + goCtx context.Context, + msg *types.MsgSetVaultQuotingParams, +) (*types.MsgSetVaultQuotingParamsResponse, error) { + // Check if authority is valid. + if !k.HasAuthority(msg.Authority) { + return nil, errorsmod.Wrapf( + govtypes.ErrInvalidSigner, + "invalid authority %s", + msg.Authority, + ) + } + + ctx := lib.UnwrapSDKContext(goCtx, types.ModuleName) + + // Validate quoting parameters. + if err := msg.QuotingParams.Validate(); err != nil { + return nil, err + } + + // Set quoting parameters for specified vault. + if err := k.Keeper.SetVaultQuotingParams(ctx, msg.VaultId, msg.QuotingParams); err != nil { + return nil, err + } + + return &types.MsgSetVaultQuotingParamsResponse{}, nil +} 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 new file mode 100644 index 00000000000..37ea4d54ffe --- /dev/null +++ b/protocol/x/vault/keeper/msg_server_set_vault_quoting_params_test.go @@ -0,0 +1,89 @@ +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 - 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/vault.go b/protocol/x/vault/keeper/vault.go index 1f7923c4328..e76c5acebb6 100644 --- a/protocol/x/vault/keeper/vault.go +++ b/protocol/x/vault/keeper/vault.go @@ -82,7 +82,10 @@ func (k Keeper) DecommissionNonPositiveEquityVaults( } } -// DecommissionVault decommissions a vault by deleting its total shares and owner shares. +// DecommissionVault decommissions a vault by +// 1. deleting its total shares and owner shares +// 2. deleting its address from vault address store +// 3. deleting its quoting params if any func (k Keeper) DecommissionVault( ctx sdk.Context, vaultId types.VaultId, @@ -102,6 +105,10 @@ func (k Keeper) DecommissionVault( // Delete from vault address store. 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()) } // AddVaultToAddressStore adds a vault's address to the vault address store. diff --git a/protocol/x/vault/keeper/vault_test.go b/protocol/x/vault/keeper/vault_test.go index d38675c5b0e..b3c67bc9aee 100644 --- a/protocol/x/vault/keeper/vault_test.go +++ b/protocol/x/vault/keeper/vault_test.go @@ -160,26 +160,30 @@ func TestDecommissionVault(t *testing.T) { totalSharesExists bool // Owners. owners []string + // Vault quoting params. + quotingParams *vaulttypes.QuotingParams }{ - "Total shares doesn't exist, no owners": { + "Total shares doesn't exist, no owners, default quoting params": { vaultId: constants.Vault_Clob0, }, - "Total shares exists, no owners": { + "Total shares exists, no owners, default quoting params": { vaultId: constants.Vault_Clob0, totalSharesExists: true, }, - "Total shares exists, one owner": { + "Total shares exists, one owner, non-default quoting params": { vaultId: constants.Vault_Clob1, totalSharesExists: true, owners: []string{constants.Alice_Num0.Owner}, + quotingParams: &constants.QuotingParams, }, - "Total shares exists, two owners": { + "Total shares exists, two owners, non-default quoting params": { vaultId: constants.Vault_Clob1, totalSharesExists: true, owners: []string{ constants.Alice_Num0.Owner, constants.Bob_Num0.Owner, }, + quotingParams: &constants.QuotingParams, }, } for name, tc := range tests { @@ -210,6 +214,10 @@ 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) + } // Decommission vault. k.DecommissionVault(ctx, tc.vaultId) @@ -222,6 +230,12 @@ 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), + ) }) } } diff --git a/protocol/x/vault/types/tx.pb.go b/protocol/x/vault/types/tx.pb.go index 22e889a22c5..435ac32a5a4 100644 --- a/protocol/x/vault/types/tx.pb.go +++ b/protocol/x/vault/types/tx.pb.go @@ -220,51 +220,157 @@ func (m *MsgUpdateDefaultQuotingParamsResponse) XXX_DiscardUnknown() { var xxx_messageInfo_MsgUpdateDefaultQuotingParamsResponse proto.InternalMessageInfo +// MsgSetVaultQuotingParams is the Msg/SetVaultQuotingParams request type. +type MsgSetVaultQuotingParams struct { + Authority string `protobuf:"bytes,1,opt,name=authority,proto3" json:"authority,omitempty"` + // The vault to set quoting 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"` +} + +func (m *MsgSetVaultQuotingParams) Reset() { *m = MsgSetVaultQuotingParams{} } +func (m *MsgSetVaultQuotingParams) String() string { return proto.CompactTextString(m) } +func (*MsgSetVaultQuotingParams) ProtoMessage() {} +func (*MsgSetVaultQuotingParams) Descriptor() ([]byte, []int) { + return fileDescriptor_ced574c6017ce006, []int{4} +} +func (m *MsgSetVaultQuotingParams) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgSetVaultQuotingParams) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgSetVaultQuotingParams.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 *MsgSetVaultQuotingParams) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgSetVaultQuotingParams.Merge(m, src) +} +func (m *MsgSetVaultQuotingParams) XXX_Size() int { + return m.Size() +} +func (m *MsgSetVaultQuotingParams) XXX_DiscardUnknown() { + xxx_messageInfo_MsgSetVaultQuotingParams.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgSetVaultQuotingParams proto.InternalMessageInfo + +func (m *MsgSetVaultQuotingParams) GetAuthority() string { + if m != nil { + return m.Authority + } + return "" +} + +func (m *MsgSetVaultQuotingParams) GetVaultId() VaultId { + if m != nil { + return m.VaultId + } + return VaultId{} +} + +func (m *MsgSetVaultQuotingParams) GetQuotingParams() QuotingParams { + if m != nil { + return m.QuotingParams + } + return QuotingParams{} +} + +// MsgSetVaultQuotingParamsResponse is the Msg/SetVaultQuotingParams response +// type. +type MsgSetVaultQuotingParamsResponse struct { +} + +func (m *MsgSetVaultQuotingParamsResponse) Reset() { *m = MsgSetVaultQuotingParamsResponse{} } +func (m *MsgSetVaultQuotingParamsResponse) String() string { return proto.CompactTextString(m) } +func (*MsgSetVaultQuotingParamsResponse) ProtoMessage() {} +func (*MsgSetVaultQuotingParamsResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_ced574c6017ce006, []int{5} +} +func (m *MsgSetVaultQuotingParamsResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgSetVaultQuotingParamsResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgSetVaultQuotingParamsResponse.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 *MsgSetVaultQuotingParamsResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgSetVaultQuotingParamsResponse.Merge(m, src) +} +func (m *MsgSetVaultQuotingParamsResponse) XXX_Size() int { + return m.Size() +} +func (m *MsgSetVaultQuotingParamsResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgSetVaultQuotingParamsResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgSetVaultQuotingParamsResponse 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") } func init() { proto.RegisterFile("dydxprotocol/vault/tx.proto", fileDescriptor_ced574c6017ce006) } var fileDescriptor_ced574c6017ce006 = []byte{ - // 529 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x54, 0xc1, 0x6e, 0xd3, 0x40, - 0x10, 0x8d, 0x5b, 0x04, 0x74, 0x69, 0x23, 0xb1, 0x8a, 0x20, 0x75, 0x84, 0x53, 0x22,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xa5, 0xc2, 0xf7, 0xe0, 0x16, 0x96, 0xf5, 0xac, - 0x81, 0x2c, 0x68, 0xc9, 0x65, 0x27, 0x8a, 0xde, 0xcd, 0x5b, 0x47, 0xa6, 0x75, 0xe3, 0x4a, 0x2c, - 0x93, 0x59, 0xc2, 0x39, 0x63, 0x1d, 0x14, 0x63, 0xa6, 0xb3, 0x76, 0xb5, 0xfb, 0x60, 0xfb, 0x42, - 0x1e, 0x29, 0xe3, 0xbd, 0xbf, 0x0a, 0x58, 0x6d, 0x31, 0x07, 0x1e, 0x81, 0xe2, 0x7f, 0x27, 0xb3, - 0x9d, 0x37, 0xd1, 0x82, 0x74, 0x6a, 0x7d, 0xa9, 0xb4, 0xb4, 0x1f, 0xfc, 0xa4, 0x00, 0xf5, 0x02, - 0x79, 0x77, 0xcf, 0xa9, 0x76, 0x3e, 0x44, 0x7d, 0x7a, 0x69, 0x48, 0x3a, 0x4c, 0xa3, 0x7d, 0x3c, - 0xd1, 0x94, 0x93, 0x89, 0xa6, 0xfc, 0x9e, 0x68, 0xca, 0xe7, 0xa9, 0x56, 0x38, 0x99, 0x6a, 0x85, - 0x9f, 0x53, 0xad, 0xf0, 0xee, 0xc9, 0xf2, 0xa7, 0x38, 0x4a, 0xbf, 0x25, 0xf1, 0x45, 0x76, 0xaf, - 0x0a, 0xff, 0xa3, 0x7f, 0x01, 0x00, 0x00, 0xff, 0xff, 0x6a, 0x66, 0x7c, 0x37, 0x6e, 0x04, 0x00, - 0x00, + // 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, 0x98, 0x04, 0x97, 0x6b, 0xc4, 0x3c, 0x40, 0x0e, + 0x26, 0x16, 0x7d, 0x81, 0x0f, 0xfd, 0x0a, 0x71, 0x0f, 0x5c, 0x64, 0xa5, 0x4d, 0x0b, 0xe6, 0x84, + 0xa2, 0xb0, 0x75, 0x69, 0x27, 0xaf, 0xcc, 0x43, 0x56, 0x58, 0x72, 0x15, 0x6a, 0x17, 0xfa, 0xdc, + 0x10, 0x9f, 0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00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -283,6 +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) } type msgClient struct { @@ -311,12 +419,23 @@ 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...) + if err != nil { + return nil, err + } + return out, nil +} + // MsgServer is the server API for Msg service. type MsgServer interface { // DepositToVault deposits funds into a vault. 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) } // UnimplementedMsgServer can be embedded to have forward compatible implementations. @@ -329,6 +448,9 @@ 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 RegisterMsgServer(s grpc1.Server, srv MsgServer) { s.RegisterService(&_Msg_serviceDesc, srv) @@ -370,6 +492,24 @@ 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) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MsgServer).SetVaultQuotingParams(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/dydxprotocol.vault.Msg/SetVaultQuotingParams", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).SetVaultQuotingParams(ctx, req.(*MsgSetVaultQuotingParams)) + } + return interceptor(ctx, in, info, handler) +} + var _Msg_serviceDesc = grpc.ServiceDesc{ ServiceName: "dydxprotocol.vault.Msg", HandlerType: (*MsgServer)(nil), @@ -382,6 +522,10 @@ var _Msg_serviceDesc = grpc.ServiceDesc{ MethodName: "UpdateDefaultQuotingParams", Handler: _Msg_UpdateDefaultQuotingParams_Handler, }, + { + MethodName: "SetVaultQuotingParams", + Handler: _Msg_SetVaultQuotingParams_Handler, + }, }, Streams: []grpc.StreamDesc{}, Metadata: "dydxprotocol/vault/tx.proto", @@ -530,6 +674,79 @@ func (m *MsgUpdateDefaultQuotingParamsResponse) MarshalToSizedBuffer(dAtA []byte return len(dAtA) - i, nil } +func (m *MsgSetVaultQuotingParams) 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 *MsgSetVaultQuotingParams) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgSetVaultQuotingParams) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + { + size, err := m.QuotingParams.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintTx(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x1a + { + size, err := m.VaultId.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintTx(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + if len(m.Authority) > 0 { + i -= len(m.Authority) + copy(dAtA[i:], m.Authority) + i = encodeVarintTx(dAtA, i, uint64(len(m.Authority))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *MsgSetVaultQuotingParamsResponse) 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 *MsgSetVaultQuotingParamsResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgSetVaultQuotingParamsResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + func encodeVarintTx(dAtA []byte, offset int, v uint64) int { offset -= sovTx(v) base := offset @@ -593,6 +810,32 @@ func (m *MsgUpdateDefaultQuotingParamsResponse) Size() (n int) { return n } +func (m *MsgSetVaultQuotingParams) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Authority) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = m.VaultId.Size() + n += 1 + l + sovTx(uint64(l)) + l = m.QuotingParams.Size() + n += 1 + l + sovTx(uint64(l)) + return n +} + +func (m *MsgSetVaultQuotingParamsResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + func sovTx(x uint64) (n int) { return (math_bits.Len64(x|1) + 6) / 7 } @@ -969,6 +1212,204 @@ func (m *MsgUpdateDefaultQuotingParamsResponse) Unmarshal(dAtA []byte) error { } return nil } +func (m *MsgSetVaultQuotingParams) 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 ErrIntOverflowTx + } + 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: MsgSetVaultQuotingParams: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgSetVaultQuotingParams: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Authority", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Authority = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field VaultId", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.VaultId.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 3: + 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 ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.QuotingParams.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *MsgSetVaultQuotingParamsResponse) 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 ErrIntOverflowTx + } + 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: MsgSetVaultQuotingParamsResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgSetVaultQuotingParamsResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} func skipTx(dAtA []byte) (n int, err error) { l := len(dAtA) iNdEx := 0