Skip to content

Commit

Permalink
add megavault operator params and update message (#2259)
Browse files Browse the repository at this point in the history
  • Loading branch information
tqin7 authored Sep 16, 2024
1 parent 025cc85 commit 521ed1b
Show file tree
Hide file tree
Showing 29 changed files with 1,223 additions and 135 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { NumShares, NumSharesSDKType, OwnerShare, OwnerShareSDKType, OwnerShareUnlocks, OwnerShareUnlocksSDKType } from "./share";
import { QuotingParams, QuotingParamsSDKType, VaultParams, VaultParamsSDKType } from "./params";
import { QuotingParams, QuotingParamsSDKType, OperatorParams, OperatorParamsSDKType, VaultParams, VaultParamsSDKType } from "./params";
import { VaultId, VaultIdSDKType } from "./vault";
import * as _m0 from "protobufjs/minimal";
import { DeepPartial } from "../../helpers";
Expand All @@ -20,6 +20,9 @@ export interface GenesisState {
/** All owner share unlocks. */

allOwnerShareUnlocks: OwnerShareUnlocks[];
/** The parameters regarding megavault operator. */

operatorParams?: OperatorParams;
}
/** GenesisState defines `x/vault`'s genesis state. */

Expand All @@ -38,6 +41,9 @@ export interface GenesisStateSDKType {
/** All owner share unlocks. */

all_owner_share_unlocks: OwnerShareUnlocksSDKType[];
/** The parameters regarding megavault operator. */

operator_params?: OperatorParamsSDKType;
}
/** Vault defines the state of a vault. */

Expand Down Expand Up @@ -136,7 +142,8 @@ function createBaseGenesisState(): GenesisState {
ownerShares: [],
vaults: [],
defaultQuotingParams: undefined,
allOwnerShareUnlocks: []
allOwnerShareUnlocks: [],
operatorParams: undefined
};
}

Expand All @@ -162,6 +169,10 @@ export const GenesisState = {
OwnerShareUnlocks.encode(v!, writer.uint32(42).fork()).ldelim();
}

if (message.operatorParams !== undefined) {
OperatorParams.encode(message.operatorParams, writer.uint32(50).fork()).ldelim();
}

return writer;
},

Expand Down Expand Up @@ -194,6 +205,10 @@ export const GenesisState = {
message.allOwnerShareUnlocks.push(OwnerShareUnlocks.decode(reader, reader.uint32()));
break;

case 6:
message.operatorParams = OperatorParams.decode(reader, reader.uint32());
break;

default:
reader.skipType(tag & 7);
break;
Expand All @@ -210,6 +225,7 @@ export const GenesisState = {
message.vaults = object.vaults?.map(e => Vault.fromPartial(e)) || [];
message.defaultQuotingParams = object.defaultQuotingParams !== undefined && object.defaultQuotingParams !== null ? QuotingParams.fromPartial(object.defaultQuotingParams) : undefined;
message.allOwnerShareUnlocks = object.allOwnerShareUnlocks?.map(e => OwnerShareUnlocks.fromPartial(e)) || [];
message.operatorParams = object.operatorParams !== undefined && object.operatorParams !== null ? OperatorParams.fromPartial(object.operatorParams) : undefined;
return message;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,16 @@ export interface VaultParamsSDKType {

quoting_params?: QuotingParamsSDKType;
}
/** OperatorParams stores parameters regarding megavault operator. */

export interface OperatorParams {
operator: string;
}
/** OperatorParams stores parameters regarding megavault operator. */

export interface OperatorParamsSDKType {
operator: string;
}
/**
* Deprecated: Params stores `x/vault` parameters.
* Deprecated since v6.x as is replaced by QuotingParams.
Expand Down Expand Up @@ -330,6 +340,51 @@ export const VaultParams = {

};

function createBaseOperatorParams(): OperatorParams {
return {
operator: ""
};
}

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

return writer;
},

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

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

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

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

return message;
},

fromPartial(object: DeepPartial<OperatorParams>): OperatorParams {
const message = createBaseOperatorParams();
message.operator = object.operator ?? "";
return message;
}

};

function createBaseParams(): Params {
return {
layers: 0,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Rpc } from "../../helpers";
import * as _m0 from "protobufjs/minimal";
import { MsgDepositToMegavault, MsgDepositToMegavaultResponse, MsgUpdateDefaultQuotingParams, MsgUpdateDefaultQuotingParamsResponse, MsgSetVaultParams, MsgSetVaultParamsResponse, MsgUnlockShares, MsgUnlockSharesResponse } from "./tx";
import { MsgDepositToMegavault, MsgDepositToMegavaultResponse, MsgUpdateDefaultQuotingParams, MsgUpdateDefaultQuotingParamsResponse, MsgUpdateOperatorParams, MsgUpdateOperatorParamsResponse, MsgSetVaultParams, MsgSetVaultParamsResponse, MsgUnlockShares, MsgUnlockSharesResponse } from "./tx";
/** Msg defines the Msg service. */

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

updateDefaultQuotingParams(request: MsgUpdateDefaultQuotingParams): Promise<MsgUpdateDefaultQuotingParamsResponse>;
/** UpdateOperatorParams sets the parameters regarding megavault operator. */

updateOperatorParams(request: MsgUpdateOperatorParams): Promise<MsgUpdateOperatorParamsResponse>;
/** SetVaultParams sets the parameters of a specific vault. */

setVaultParams(request: MsgSetVaultParams): Promise<MsgSetVaultParamsResponse>;
Expand All @@ -26,6 +29,7 @@ export class MsgClientImpl implements Msg {
this.rpc = rpc;
this.depositToMegavault = this.depositToMegavault.bind(this);
this.updateDefaultQuotingParams = this.updateDefaultQuotingParams.bind(this);
this.updateOperatorParams = this.updateOperatorParams.bind(this);
this.setVaultParams = this.setVaultParams.bind(this);
this.unlockShares = this.unlockShares.bind(this);
}
Expand All @@ -42,6 +46,12 @@ export class MsgClientImpl implements Msg {
return promise.then(data => MsgUpdateDefaultQuotingParamsResponse.decode(new _m0.Reader(data)));
}

updateOperatorParams(request: MsgUpdateOperatorParams): Promise<MsgUpdateOperatorParamsResponse> {
const data = MsgUpdateOperatorParams.encode(request).finish();
const promise = this.rpc.request("dydxprotocol.vault.Msg", "UpdateOperatorParams", data);
return promise.then(data => MsgUpdateOperatorParamsResponse.decode(new _m0.Reader(data)));
}

setVaultParams(request: MsgSetVaultParams): Promise<MsgSetVaultParamsResponse> {
const data = MsgSetVaultParams.encode(request).finish();
const promise = this.rpc.request("dydxprotocol.vault.Msg", "SetVaultParams", data);
Expand Down
113 changes: 112 additions & 1 deletion indexer/packages/v4-protos/src/codegen/dydxprotocol/vault/tx.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { SubaccountId, SubaccountIdSDKType } from "../subaccounts/subaccount";
import { QuotingParams, QuotingParamsSDKType, VaultParams, VaultParamsSDKType, Params, ParamsSDKType } from "./params";
import { QuotingParams, QuotingParamsSDKType, OperatorParams, OperatorParamsSDKType, VaultParams, VaultParamsSDKType, Params, ParamsSDKType } from "./params";
import { VaultId, VaultIdSDKType } from "./vault";
import { NumShares, NumSharesSDKType } from "./share";
import * as _m0 from "protobufjs/minimal";
Expand Down Expand Up @@ -156,6 +156,28 @@ export interface MsgUpdateParamsSDKType {

params?: ParamsSDKType;
}
/** MsgUpdateOperatorParams is the Msg/UpdateOperatorParams request type. */

export interface MsgUpdateOperatorParams {
authority: string;
/** Operator parameters to set. */

params?: OperatorParams;
}
/** MsgUpdateOperatorParams is the Msg/UpdateOperatorParams request type. */

export interface MsgUpdateOperatorParamsSDKType {
authority: string;
/** Operator parameters to set. */

params?: OperatorParamsSDKType;
}
/** MsgUpdateVaultParamsResponse is the Msg/UpdateOperatorParams response type. */

export interface MsgUpdateOperatorParamsResponse {}
/** MsgUpdateVaultParamsResponse is the Msg/UpdateOperatorParams response type. */

export interface MsgUpdateOperatorParamsResponseSDKType {}

function createBaseMsgDepositToMegavault(): MsgDepositToMegavault {
return {
Expand Down Expand Up @@ -598,4 +620,93 @@ export const MsgUpdateParams = {
return message;
}

};

function createBaseMsgUpdateOperatorParams(): MsgUpdateOperatorParams {
return {
authority: "",
params: undefined
};
}

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

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

return writer;
},

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

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

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

case 2:
message.params = OperatorParams.decode(reader, reader.uint32());
break;

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

return message;
},

fromPartial(object: DeepPartial<MsgUpdateOperatorParams>): MsgUpdateOperatorParams {
const message = createBaseMsgUpdateOperatorParams();
message.authority = object.authority ?? "";
message.params = object.params !== undefined && object.params !== null ? OperatorParams.fromPartial(object.params) : undefined;
return message;
}

};

function createBaseMsgUpdateOperatorParamsResponse(): MsgUpdateOperatorParamsResponse {
return {};
}

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

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

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

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

return message;
},

fromPartial(_: DeepPartial<MsgUpdateOperatorParamsResponse>): MsgUpdateOperatorParamsResponse {
const message = createBaseMsgUpdateOperatorParamsResponse();
return message;
}

};
2 changes: 2 additions & 0 deletions proto/dydxprotocol/vault/genesis.proto
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ message GenesisState {
// All owner share unlocks.
repeated OwnerShareUnlocks all_owner_share_unlocks = 5
[ (gogoproto.nullable) = false ];
// The parameters regarding megavault operator.
OperatorParams operator_params = 6 [ (gogoproto.nullable) = false ];
}

// Vault defines the state of a vault.
Expand Down
6 changes: 6 additions & 0 deletions proto/dydxprotocol/vault/params.proto
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
syntax = "proto3";
package dydxprotocol.vault;

import "cosmos_proto/cosmos.proto";
import "dydxprotocol/vault/vault.proto";
import "gogoproto/gogo.proto";

Expand Down Expand Up @@ -48,6 +49,11 @@ message VaultParams {
QuotingParams quoting_params = 2;
}

// OperatorParams stores parameters regarding megavault operator.
message OperatorParams {
string operator = 1 [ (cosmos_proto.scalar) = "cosmos.AddressString" ];
}

// Deprecated: Params stores `x/vault` parameters.
// Deprecated since v6.x as is replaced by QuotingParams.
message Params {
Expand Down
17 changes: 17 additions & 0 deletions proto/dydxprotocol/vault/tx.proto
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ service Msg {
rpc UpdateDefaultQuotingParams(MsgUpdateDefaultQuotingParams)
returns (MsgUpdateDefaultQuotingParamsResponse);

// UpdateOperatorParams sets the parameters regarding megavault operator.
rpc UpdateOperatorParams(MsgUpdateOperatorParams)
returns (MsgUpdateOperatorParamsResponse);

// SetVaultParams sets the parameters of a specific vault.
rpc SetVaultParams(MsgSetVaultParams) returns (MsgSetVaultParamsResponse);

Expand Down Expand Up @@ -112,3 +116,16 @@ message MsgUpdateParams {
// The parameters to update. Each field must be set.
Params params = 2 [ (gogoproto.nullable) = false ];
}

// MsgUpdateOperatorParams is the Msg/UpdateOperatorParams request type.
message MsgUpdateOperatorParams {
// Authority is the address that controls the module.
option (cosmos.msg.v1.signer) = "authority";
string authority = 1 [ (cosmos_proto.scalar) = "cosmos.AddressString" ];

// Operator parameters to set.
OperatorParams params = 2 [ (gogoproto.nullable) = false ];
}

// MsgUpdateVaultParamsResponse is the Msg/UpdateOperatorParams response type.
message MsgUpdateOperatorParamsResponse {}
2 changes: 2 additions & 0 deletions protocol/app/msgs/all_msgs.go
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,8 @@ var (
"/dydxprotocol.vault.MsgUnlockSharesResponse": {},
"/dydxprotocol.vault.MsgUpdateDefaultQuotingParams": {},
"/dydxprotocol.vault.MsgUpdateDefaultQuotingParamsResponse": {},
"/dydxprotocol.vault.MsgUpdateOperatorParams": {},
"/dydxprotocol.vault.MsgUpdateOperatorParamsResponse": {},
"/dydxprotocol.vault.MsgUpdateParams": {},

// vest
Expand Down
2 changes: 2 additions & 0 deletions protocol/app/msgs/internal_msgs.go
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,8 @@ var (
"/dydxprotocol.vault.MsgUnlockSharesResponse": nil,
"/dydxprotocol.vault.MsgUpdateDefaultQuotingParams": &vault.MsgUpdateDefaultQuotingParams{},
"/dydxprotocol.vault.MsgUpdateDefaultQuotingParamsResponse": nil,
"/dydxprotocol.vault.MsgUpdateOperatorParams": &vault.MsgUpdateOperatorParams{},
"/dydxprotocol.vault.MsgUpdateOperatorParamsResponse": nil,

// vest
"/dydxprotocol.vest.MsgSetVestEntry": &vest.MsgSetVestEntry{},
Expand Down
2 changes: 2 additions & 0 deletions protocol/app/msgs/internal_msgs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,8 @@ func TestInternalMsgSamples_Gov_Key(t *testing.T) {
"/dydxprotocol.vault.MsgUnlockSharesResponse",
"/dydxprotocol.vault.MsgUpdateDefaultQuotingParams",
"/dydxprotocol.vault.MsgUpdateDefaultQuotingParamsResponse",
"/dydxprotocol.vault.MsgUpdateOperatorParams",
"/dydxprotocol.vault.MsgUpdateOperatorParamsResponse",

// vest
"/dydxprotocol.vest.MsgDeleteVestEntry",
Expand Down
3 changes: 3 additions & 0 deletions protocol/app/testdata/default_genesis_state.json
Original file line number Diff line number Diff line change
Expand Up @@ -501,6 +501,9 @@
"order_expiration_seconds": 60,
"activation_threshold_quote_quantums": "1000000000"
},
"operator_params": {
"operator": "dydx10d07y265gmmuvt4z0w9aw880jnsr700jnmapky"
},
"owner_shares": [],
"total_shares": {
"num_shares": "0"
Expand Down
Loading

0 comments on commit 521ed1b

Please sign in to comment.