Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[TRA-572] Add upsert vault event. #2250

Merged
merged 7 commits into from
Sep 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
410 changes: 206 additions & 204 deletions indexer/packages/v4-protos/src/codegen/dydxprotocol/bundle.ts

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { IndexerSubaccountId, IndexerSubaccountIdSDKType, IndexerPerpetualPositi
import { IndexerOrder, IndexerOrderSDKType, IndexerOrderId, IndexerOrderIdSDKType, ClobPairStatus, ClobPairStatusSDKType } from "../protocol/v1/clob";
import { OrderRemovalReason, OrderRemovalReasonSDKType } from "../shared/removal_reason";
import { PerpetualMarketType, PerpetualMarketTypeSDKType } from "../protocol/v1/perpetual";
import { VaultStatus, VaultStatusSDKType } from "../protocol/v1/vault";
import * as _m0 from "protobufjs/minimal";
import { DeepPartial, Long } from "../../../helpers";
/** Type is the type for funding values. */
Expand Down Expand Up @@ -1503,6 +1504,30 @@ export interface RegisterAffiliateEventV1SDKType {

affiliate: string;
}
/** Event emitted when a vault is created / updated. */

export interface UpsertVaultEventV1 {
/** Address of the vault. */
address: string;
/** Clob pair Id associated with the vault. */

clobPairId: number;
/** Status of the vault. */

status: VaultStatus;
}
/** Event emitted when a vault is created / updated. */

export interface UpsertVaultEventV1SDKType {
/** Address of the vault. */
address: string;
/** Clob pair Id associated with the vault. */

clob_pair_id: number;
/** Status of the vault. */

status: VaultStatusSDKType;
}

function createBaseFundingUpdateV1(): FundingUpdateV1 {
return {
Expand Down Expand Up @@ -3802,4 +3827,69 @@ export const RegisterAffiliateEventV1 = {
return message;
}

};

function createBaseUpsertVaultEventV1(): UpsertVaultEventV1 {
return {
address: "",
clobPairId: 0,
status: 0
};
}

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

if (message.clobPairId !== 0) {
writer.uint32(16).uint32(message.clobPairId);
}

if (message.status !== 0) {
writer.uint32(24).int32(message.status);
}

return writer;
},

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

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

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

case 2:
message.clobPairId = reader.uint32();
break;

case 3:
message.status = (reader.int32() as any);
break;

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

return message;
},

fromPartial(object: DeepPartial<UpsertVaultEventV1>): UpsertVaultEventV1 {
const message = createBaseUpsertVaultEventV1();
message.address = object.address ?? "";
message.clobPairId = object.clobPairId ?? 0;
message.status = object.status ?? 0;
return message;
}

};
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
/** VaultStatus represents the status of a vault. */
export enum VaultStatus {
/** VAULT_STATUS_UNSPECIFIED - Default value, invalid and unused. */
VAULT_STATUS_UNSPECIFIED = 0,

/** VAULT_STATUS_DEACTIVATED - Don’t place orders. Does not count toward global vault balances. */
VAULT_STATUS_DEACTIVATED = 1,

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

/** VAULT_STATUS_QUOTING - Places orders on both sides of the book. */
VAULT_STATUS_QUOTING = 3,

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

export enum VaultStatusSDKType {
/** VAULT_STATUS_UNSPECIFIED - Default value, invalid and unused. */
VAULT_STATUS_UNSPECIFIED = 0,

/** VAULT_STATUS_DEACTIVATED - Don’t place orders. Does not count toward global vault balances. */
VAULT_STATUS_DEACTIVATED = 1,

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

/** VAULT_STATUS_QUOTING - Places orders on both sides of the book. */
VAULT_STATUS_QUOTING = 3,

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

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

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

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

case 4:
case "VAULT_STATUS_CLOSE_ONLY":
return VaultStatus.VAULT_STATUS_CLOSE_ONLY;

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

case VaultStatus.VAULT_STATUS_DEACTIVATED:
return "VAULT_STATUS_DEACTIVATED";

case VaultStatus.VAULT_STATUS_STAND_BY:
return "VAULT_STATUS_STAND_BY";

case VaultStatus.VAULT_STATUS_QUOTING:
return "VAULT_STATUS_QUOTING";

case VaultStatus.VAULT_STATUS_CLOSE_ONLY:
return "VAULT_STATUS_CLOSE_ONLY";

case VaultStatus.UNRECOGNIZED:
default:
return "UNRECOGNIZED";
}
}
4 changes: 2 additions & 2 deletions indexer/packages/v4-protos/src/codegen/gogoproto/bundle.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
import * as _126 from "./gogo";
export const gogoproto = { ..._126
import * as _127 from "./gogo";
export const gogoproto = { ..._127
};
22 changes: 11 additions & 11 deletions indexer/packages/v4-protos/src/codegen/google/bundle.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
import * as _127 from "./api/annotations";
import * as _128 from "./api/http";
import * as _129 from "./protobuf/descriptor";
import * as _130 from "./protobuf/duration";
import * as _131 from "./protobuf/timestamp";
import * as _132 from "./protobuf/any";
import * as _128 from "./api/annotations";
import * as _129 from "./api/http";
import * as _130 from "./protobuf/descriptor";
import * as _131 from "./protobuf/duration";
import * as _132 from "./protobuf/timestamp";
import * as _133 from "./protobuf/any";
export namespace google {
export const api = { ..._127,
..._128
export const api = { ..._128,
..._129
};
export const protobuf = { ..._129,
..._130,
export const protobuf = { ..._130,
..._131,
..._132
..._132,
..._133
};
}
13 changes: 13 additions & 0 deletions proto/dydxprotocol/indexer/events/events.proto
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import "dydxprotocol/indexer/shared/removal_reason.proto";
import "dydxprotocol/indexer/protocol/v1/clob.proto";
import "dydxprotocol/indexer/protocol/v1/perpetual.proto";
import "dydxprotocol/indexer/protocol/v1/subaccount.proto";
import "dydxprotocol/indexer/protocol/v1/vault.proto";

option go_package = "github.com/dydxprotocol/v4-chain/protocol/indexer/events";

Expand Down Expand Up @@ -590,3 +591,15 @@ message RegisterAffiliateEventV1 {
// Address of the affiliate associated with the referee.
string affiliate = 2 [ (cosmos_proto.scalar) = "cosmos.AddressString" ];
}

// Event emitted when a vault is created / updated.
message UpsertVaultEventV1 {
// Address of the vault.
string address = 1 [ (cosmos_proto.scalar) = "cosmos.AddressString" ];

// Clob pair Id associated with the vault.
uint32 clob_pair_id = 2;

// Status of the vault.
dydxprotocol.indexer.protocol.v1.VaultStatus status = 3;
}
27 changes: 27 additions & 0 deletions proto/dydxprotocol/indexer/protocol/v1/vault.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
syntax = "proto3";
package dydxprotocol.indexer.protocol.v1;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fix the package directory to match the package name.

The static analysis tool buf has flagged an issue with the package directory not matching the package name. To fix this, move the file to the directory dydxprotocol/indexer/protocol/v1 relative to the root of the repository.

Apply this fix to resolve the buf issue:

  1. Create the directory dydxprotocol/indexer/protocol/v1 relative to the root of the repository if it doesn't exist.
  2. Move the file proto/dydxprotocol/indexer/protocol/v1/vault.proto to the new directory dydxprotocol/indexer/protocol/v1/vault.proto.
  3. Update any import statements in other files that reference this file to use the new path.
Tools
buf

2-2: Files with package "dydxprotocol.indexer.protocol.v1" must be within a directory "dydxprotocol/indexer/protocol/v1" relative to root but were in directory "proto/dydxprotocol/indexer/protocol/v1".

(PACKAGE_DIRECTORY_MATCH)


option go_package = "github.com/dydxprotocol/v4-chain/protocol/indexer/protocol/v1/types";

// Initial copy of protos from dYdX chain application state protos for the
// vault module for use to send Indexer specific messages. Do not make any
// breaking changes to these protos, a new version should be created if a
// breaking change is needed.

// VaultStatus represents the status of a vault.
enum VaultStatus {
// Default value, invalid and unused.
VAULT_STATUS_UNSPECIFIED = 0;

// Don’t place orders. Does not count toward global vault balances.
VAULT_STATUS_DEACTIVATED = 1;

// Don’t place orders. Does count towards global vault balances.
VAULT_STATUS_STAND_BY = 2;

// Places orders on both sides of the book.
VAULT_STATUS_QUOTING = 3;

// Only place orders that close the position.
VAULT_STATUS_CLOSE_ONLY = 4;
}
Loading
Loading