Skip to content

Commit

Permalink
add protos
Browse files Browse the repository at this point in the history
  • Loading branch information
tqin7 committed Aug 13, 2024
1 parent af25b92 commit e71c30e
Show file tree
Hide file tree
Showing 12 changed files with 600 additions and 164 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { QuotingParams, QuotingParamsSDKType } from "./params";
import { QuotingParams, QuotingParamsSDKType, VaultParams, VaultParamsSDKType } from "./params";
import { VaultId, VaultIdSDKType } from "./vault";
import { NumShares, NumSharesSDKType, OwnerShare, OwnerShareSDKType } from "./share";
import * as _m0 from "protobufjs/minimal";
Expand All @@ -21,7 +21,7 @@ export interface GenesisStateSDKType {

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

};

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

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

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

return writer;
},

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

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

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

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

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

return message;
},

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

};

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

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

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

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

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

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

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

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

Expand Down
75 changes: 75 additions & 0 deletions indexer/packages/v4-protos/src/codegen/dydxprotocol/vault/vault.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,81 @@ export function vaultTypeToJSON(object: VaultType): string {
return "UNRECOGNIZED";
}
}
/** VaultStatus represents the status of a vault. */

export enum VaultStatus {
/** DEACTIVATED - Don’t place orders. Does not count toward global vault balances. */
DEACTIVATED = 0,

/** STAND_BY - Don’t place orders. Does count towards global vault balances. */
STAND_BY = 1,

/** QUOTING - Places orders on both sides of the book. */
QUOTING = 2,

/** CLOSE_ONLY - Only place orders that close the position. */
CLOSE_ONLY = 3,
UNRECOGNIZED = -1,
}
/** VaultStatus represents the status of a vault. */

export enum VaultStatusSDKType {
/** DEACTIVATED - Don’t place orders. Does not count toward global vault balances. */
DEACTIVATED = 0,

/** STAND_BY - Don’t place orders. Does count towards global vault balances. */
STAND_BY = 1,

/** QUOTING - Places orders on both sides of the book. */
QUOTING = 2,

/** CLOSE_ONLY - Only place orders that close the position. */
CLOSE_ONLY = 3,
UNRECOGNIZED = -1,
}
export function vaultStatusFromJSON(object: any): VaultStatus {
switch (object) {
case 0:
case "DEACTIVATED":
return VaultStatus.DEACTIVATED;

case 1:
case "STAND_BY":
return VaultStatus.STAND_BY;

case 2:
case "QUOTING":
return VaultStatus.QUOTING;

case 3:
case "CLOSE_ONLY":
return VaultStatus.CLOSE_ONLY;

case -1:
case "UNRECOGNIZED":
default:
return VaultStatus.UNRECOGNIZED;
}
}
export function vaultStatusToJSON(object: VaultStatus): string {
switch (object) {
case VaultStatus.DEACTIVATED:
return "DEACTIVATED";

case VaultStatus.STAND_BY:
return "STAND_BY";

case VaultStatus.QUOTING:
return "QUOTING";

case VaultStatus.CLOSE_ONLY:
return "CLOSE_ONLY";

case VaultStatus.UNRECOGNIZED:
default:
return "UNRECOGNIZED";
}
}
/** VaultId uniquely identifies a vault by its type and number. */

export interface VaultId {
Expand Down
6 changes: 3 additions & 3 deletions proto/dydxprotocol/vault/genesis.proto
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,16 @@ 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;
// The total number of shares in the 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;
// The client IDs of the most recently placed orders of the vault.
repeated uint32 most_recent_client_ids = 5;
}
9 changes: 9 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 "dydxprotocol/vault/vault.proto";
import "gogoproto/gogo.proto";

option go_package = "github.com/dydxprotocol/v4-chain/protocol/x/vault/types";
Expand Down Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion proto/dydxprotocol/vault/query.proto
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
15 changes: 15 additions & 0 deletions proto/dydxprotocol/vault/vault.proto
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,18 @@ message VaultId {
// Unique ID of the vault within above type.
uint32 number = 2;
}

// VaultStatus represents the status of a vault.
enum VaultStatus {
// Don’t place orders. Does not count toward global vault balances.
DEACTIVATED = 0;

// Don’t place orders. Does count towards global vault balances.
STAND_BY = 1;

// Places orders on both sides of the book.
QUOTING = 2;

// Only place orders that close the position.
CLOSE_ONLY = 3;
}
Loading

0 comments on commit e71c30e

Please sign in to comment.