Skip to content

Commit

Permalink
[TRA-461] Remove x/vault/MsgWithdrawFromVault (#1859)
Browse files Browse the repository at this point in the history
  • Loading branch information
ttl33 authored and tqin7 committed Jul 11, 2024
1 parent 8d9c0e1 commit 852fe79
Show file tree
Hide file tree
Showing 9 changed files with 43 additions and 1,101 deletions.
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
import { Rpc } from "../../helpers";
import * as _m0 from "protobufjs/minimal";
import { MsgDepositToVault, MsgDepositToVaultResponse, MsgWithdrawFromVault, MsgWithdrawFromVaultResponse, MsgUpdateParams, MsgUpdateParamsResponse } from "./tx";
import { MsgDepositToVault, MsgDepositToVaultResponse, MsgUpdateParams, MsgUpdateParamsResponse } from "./tx";
/** Msg defines the Msg service. */

export interface Msg {
/** DepositToVault deposits funds into a vault. */
depositToVault(request: MsgDepositToVault): Promise<MsgDepositToVaultResponse>;
/** WithdrawFromVault attempts to withdraw funds from a vault. */

withdrawFromVault(request: MsgWithdrawFromVault): Promise<MsgWithdrawFromVaultResponse>;
/** UpdateParams updates the Params in state. */

updateParams(request: MsgUpdateParams): Promise<MsgUpdateParamsResponse>;
Expand All @@ -19,7 +16,6 @@ export class MsgClientImpl implements Msg {
constructor(rpc: Rpc) {
this.rpc = rpc;
this.depositToVault = this.depositToVault.bind(this);
this.withdrawFromVault = this.withdrawFromVault.bind(this);
this.updateParams = this.updateParams.bind(this);
}

Expand All @@ -29,12 +25,6 @@ export class MsgClientImpl implements Msg {
return promise.then(data => MsgDepositToVaultResponse.decode(new _m0.Reader(data)));
}

withdrawFromVault(request: MsgWithdrawFromVault): Promise<MsgWithdrawFromVaultResponse> {
const data = MsgWithdrawFromVault.encode(request).finish();
const promise = this.rpc.request("dydxprotocol.vault.Msg", "WithdrawFromVault", data);
return promise.then(data => MsgWithdrawFromVaultResponse.decode(new _m0.Reader(data)));
}

updateParams(request: MsgUpdateParams): Promise<MsgUpdateParamsResponse> {
const data = MsgUpdateParams.encode(request).finish();
const promise = this.rpc.request("dydxprotocol.vault.Msg", "UpdateParams", data);
Expand Down
234 changes: 1 addition & 233 deletions indexer/packages/v4-protos/src/codegen/dydxprotocol/vault/tx.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { VaultId, VaultIdSDKType, NumShares, NumSharesSDKType } from "./vault";
import { VaultId, VaultIdSDKType } from "./vault";
import { SubaccountId, SubaccountIdSDKType } from "../subaccounts/subaccount";
import { Params, ParamsSDKType } from "./params";
import * as _m0 from "protobufjs/minimal";
Expand Down Expand Up @@ -39,88 +39,6 @@ export interface MsgDepositToVaultResponse {}
/** MsgDepositToVaultResponse is the Msg/DepositToVault response type. */

export interface MsgDepositToVaultResponseSDKType {}
/**
* MsgWithdrawFromVault attempts to withdraw the specified target amount of
* asset from the vault to the subaccount.
*/

export interface MsgWithdrawFromVault {
/** The vault to withdraw from. */
vaultId?: VaultId;
/**
* The subaccount to withdraw to.
* The subaccount must own shares in the vault.
*/

subaccountId?: SubaccountId;
/**
* The number of shares to redeem as quote quantums and withdraw.
* If the specified number exceeds the number of shares owned by the
* subaccount, then all the shares owned by the subaccount are redeemed and
* withdrawn.
*/

shares?: NumShares;
}
/**
* MsgWithdrawFromVault attempts to withdraw the specified target amount of
* asset from the vault to the subaccount.
*/

export interface MsgWithdrawFromVaultSDKType {
/** The vault to withdraw from. */
vault_id?: VaultIdSDKType;
/**
* The subaccount to withdraw to.
* The subaccount must own shares in the vault.
*/

subaccount_id?: SubaccountIdSDKType;
/**
* The number of shares to redeem as quote quantums and withdraw.
* If the specified number exceeds the number of shares owned by the
* subaccount, then all the shares owned by the subaccount are redeemed and
* withdrawn.
*/

shares?: NumSharesSDKType;
}
/** MsgWithdrawFromVaultResponse is the Msg/WithdrawFromVault response type. */

export interface MsgWithdrawFromVaultResponse {
/** Number of owner shares that have been redeemed as part of the withdrawal. */
redeemedShares?: NumShares;
/** Amount of equity (in quote quantums) that has been withdrawn. */

withdrawnQuoteQuantums: Uint8Array;
/** Number of owner shares remaining after the withdrawal. */

remainingShares?: NumShares;
/** Number of total vault shares after the withdrawal. */

totalVaultShares?: NumShares;
/** Vault equity (in quote quantums) after the withdrawal. */

totalVaultEquity: Uint8Array;
}
/** MsgWithdrawFromVaultResponse is the Msg/WithdrawFromVault response type. */

export interface MsgWithdrawFromVaultResponseSDKType {
/** Number of owner shares that have been redeemed as part of the withdrawal. */
redeemed_shares?: NumSharesSDKType;
/** Amount of equity (in quote quantums) that has been withdrawn. */

withdrawn_quote_quantums: Uint8Array;
/** Number of owner shares remaining after the withdrawal. */

remaining_shares?: NumSharesSDKType;
/** Number of total vault shares after the withdrawal. */

total_vault_shares?: NumSharesSDKType;
/** Vault equity (in quote quantums) after the withdrawal. */

total_vault_equity: Uint8Array;
}
/** MsgUpdateParams is the Msg/UpdateParams request type. */

export interface MsgUpdateParams {
Expand Down Expand Up @@ -243,156 +161,6 @@ export const MsgDepositToVaultResponse = {

};

function createBaseMsgWithdrawFromVault(): MsgWithdrawFromVault {
return {
vaultId: undefined,
subaccountId: undefined,
shares: undefined
};
}

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

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

if (message.shares !== undefined) {
NumShares.encode(message.shares, writer.uint32(26).fork()).ldelim();
}

return writer;
},

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

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

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

case 2:
message.subaccountId = SubaccountId.decode(reader, reader.uint32());
break;

case 3:
message.shares = NumShares.decode(reader, reader.uint32());
break;

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

return message;
},

fromPartial(object: DeepPartial<MsgWithdrawFromVault>): MsgWithdrawFromVault {
const message = createBaseMsgWithdrawFromVault();
message.vaultId = object.vaultId !== undefined && object.vaultId !== null ? VaultId.fromPartial(object.vaultId) : undefined;
message.subaccountId = object.subaccountId !== undefined && object.subaccountId !== null ? SubaccountId.fromPartial(object.subaccountId) : undefined;
message.shares = object.shares !== undefined && object.shares !== null ? NumShares.fromPartial(object.shares) : undefined;
return message;
}

};

function createBaseMsgWithdrawFromVaultResponse(): MsgWithdrawFromVaultResponse {
return {
redeemedShares: undefined,
withdrawnQuoteQuantums: new Uint8Array(),
remainingShares: undefined,
totalVaultShares: undefined,
totalVaultEquity: new Uint8Array()
};
}

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

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

if (message.remainingShares !== undefined) {
NumShares.encode(message.remainingShares, writer.uint32(26).fork()).ldelim();
}

if (message.totalVaultShares !== undefined) {
NumShares.encode(message.totalVaultShares, writer.uint32(34).fork()).ldelim();
}

if (message.totalVaultEquity.length !== 0) {
writer.uint32(42).bytes(message.totalVaultEquity);
}

return writer;
},

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

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

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

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

case 3:
message.remainingShares = NumShares.decode(reader, reader.uint32());
break;

case 4:
message.totalVaultShares = NumShares.decode(reader, reader.uint32());
break;

case 5:
message.totalVaultEquity = reader.bytes();
break;

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

return message;
},

fromPartial(object: DeepPartial<MsgWithdrawFromVaultResponse>): MsgWithdrawFromVaultResponse {
const message = createBaseMsgWithdrawFromVaultResponse();
message.redeemedShares = object.redeemedShares !== undefined && object.redeemedShares !== null ? NumShares.fromPartial(object.redeemedShares) : undefined;
message.withdrawnQuoteQuantums = object.withdrawnQuoteQuantums ?? new Uint8Array();
message.remainingShares = object.remainingShares !== undefined && object.remainingShares !== null ? NumShares.fromPartial(object.remainingShares) : undefined;
message.totalVaultShares = object.totalVaultShares !== undefined && object.totalVaultShares !== null ? NumShares.fromPartial(object.totalVaultShares) : undefined;
message.totalVaultEquity = object.totalVaultEquity ?? new Uint8Array();
return message;
}

};

function createBaseMsgUpdateParams(): MsgUpdateParams {
return {
authority: "",
Expand Down
52 changes: 0 additions & 52 deletions proto/dydxprotocol/vault/tx.proto
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,6 @@ service Msg {
// DepositToVault deposits funds into a vault.
rpc DepositToVault(MsgDepositToVault) returns (MsgDepositToVaultResponse);

// WithdrawFromVault attempts to withdraw funds from a vault.
rpc WithdrawFromVault(MsgWithdrawFromVault)
returns (MsgWithdrawFromVaultResponse);

// UpdateParams updates the Params in state.
rpc UpdateParams(MsgUpdateParams) returns (MsgUpdateParamsResponse);
}
Expand Down Expand Up @@ -48,54 +44,6 @@ message MsgDepositToVault {
// MsgDepositToVaultResponse is the Msg/DepositToVault response type.
message MsgDepositToVaultResponse {}

// MsgWithdrawFromVault attempts to withdraw the specified target amount of
// asset from the vault to the subaccount.
message MsgWithdrawFromVault {
// This annotation enforces that the tx signer is the owner specified in
// subaccount_id. Therefore, this enforces that only the owner of the
// subaccount can withdraw from the vault equity allocated to the subaccount.
option (cosmos.msg.v1.signer) = "subaccount_id";

// The vault to withdraw from.
VaultId vault_id = 1;

// The subaccount to withdraw to.
// The subaccount must own shares in the vault.
dydxprotocol.subaccounts.SubaccountId subaccount_id = 2;

// The number of shares to redeem as quote quantums and withdraw.
// If the specified number exceeds the number of shares owned by the
// subaccount, then all the shares owned by the subaccount are redeemed and
// withdrawn.
NumShares shares = 3;
}

// MsgWithdrawFromVaultResponse is the Msg/WithdrawFromVault response type.
message MsgWithdrawFromVaultResponse {
// Number of owner shares that have been redeemed as part of the withdrawal.
NumShares redeemed_shares = 1;

// Amount of equity (in quote quantums) that has been withdrawn.
bytes withdrawn_quote_quantums = 2 [
(gogoproto.customtype) =
"github.com/dydxprotocol/v4-chain/protocol/dtypes.SerializableInt",
(gogoproto.nullable) = false
];

// Number of owner shares remaining after the withdrawal.
NumShares remaining_shares = 3;

// Number of total vault shares after the withdrawal.
NumShares total_vault_shares = 4;

// Vault equity (in quote quantums) after the withdrawal.
bytes total_vault_equity = 5 [
(gogoproto.customtype) =
"github.com/dydxprotocol/v4-chain/protocol/dtypes.SerializableInt",
(gogoproto.nullable) = false
];
}

// MsgUpdateParams is the Msg/UpdateParams request type.
message MsgUpdateParams {
// Authority is the address that controls the module.
Expand Down
3 changes: 0 additions & 3 deletions protocol/app/module/interface_registry.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,9 +95,6 @@ func NewInterfaceRegistry(addrPrefix string, valAddrPrefix string) (types.Interf
"dydxprotocol.vault.MsgDepositToVault": getLegacyMsgSignerFn(
[]string{"subaccount_id", "owner"},
),
"dydxprotocol.vault.MsgWithdrawFromVault": getLegacyMsgSignerFn(
[]string{"subaccount_id", "owner"},
),

// App injected messages have no signers.
"dydxprotocol.bridge.MsgAcknowledgeBridges": noSigners,
Expand Down
10 changes: 4 additions & 6 deletions protocol/app/msgs/all_msgs.go
Original file line number Diff line number Diff line change
Expand Up @@ -235,12 +235,10 @@ var (
"/dydxprotocol.stats.MsgUpdateParamsResponse": {},

// vault
"/dydxprotocol.vault.MsgDepositToVault": {},
"/dydxprotocol.vault.MsgDepositToVaultResponse": {},
"/dydxprotocol.vault.MsgWithdrawFromVault": {},
"/dydxprotocol.vault.MsgWithdrawFromVaultResponse": {},
"/dydxprotocol.vault.MsgUpdateParams": {},
"/dydxprotocol.vault.MsgUpdateParamsResponse": {},
"/dydxprotocol.vault.MsgDepositToVault": {},
"/dydxprotocol.vault.MsgDepositToVaultResponse": {},
"/dydxprotocol.vault.MsgUpdateParams": {},
"/dydxprotocol.vault.MsgUpdateParamsResponse": {},

// vest
"/dydxprotocol.vest.MsgSetVestEntry": {},
Expand Down
6 changes: 2 additions & 4 deletions protocol/app/msgs/normal_msgs.go
Original file line number Diff line number Diff line change
Expand Up @@ -236,9 +236,7 @@ var (
"/dydxprotocol.sending.MsgWithdrawFromSubaccountResponse": nil,

// vault
"/dydxprotocol.vault.MsgDepositToVault": &vault.MsgDepositToVault{},
"/dydxprotocol.vault.MsgDepositToVaultResponse": nil,
"/dydxprotocol.vault.MsgWithdrawFromVault": &vault.MsgWithdrawFromVault{},
"/dydxprotocol.vault.MsgWithdrawFromVaultResponse": nil,
"/dydxprotocol.vault.MsgDepositToVault": &vault.MsgDepositToVault{},
"/dydxprotocol.vault.MsgDepositToVaultResponse": nil,
}
)
Loading

0 comments on commit 852fe79

Please sign in to comment.