Skip to content

Commit

Permalink
address comments
Browse files Browse the repository at this point in the history
  • Loading branch information
tqin7 committed Aug 1, 2024
1 parent 8e4009d commit 21cf0ba
Show file tree
Hide file tree
Showing 19 changed files with 1,587 additions and 228 deletions.
Original file line number Diff line number Diff line change
@@ -1,25 +1,41 @@
import { QuotingParams, QuotingParamsSDKType } from "./params";
import { Params, ParamsSDKType, QuotingParams, QuotingParamsSDKType } from "./params";
import { VaultId, VaultIdSDKType } from "./vault";
import { NumShares, NumSharesSDKType, OwnerShare, OwnerShareSDKType } from "./share";
import * as _m0 from "protobufjs/minimal";
import { DeepPartial } from "../../helpers";
/** GenesisState defines `x/vault`'s genesis state. */

export interface GenesisState {
/** The default quoting parameters for all vaults. */
defaultQuotingParams?: QuotingParams;
/**
* The parameters of the module.
* Deprecated since v6.x in favor of default_quoting_params.
*/

/** @deprecated */
params?: Params;
/** The vaults. */

vaults: Vault[];
/** The default quoting parameters for all vaults. */

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

export interface GenesisStateSDKType {
/** The default quoting parameters for all vaults. */
default_quoting_params?: QuotingParamsSDKType;
/**
* The parameters of the module.
* Deprecated since v6.x in favor of default_quoting_params.
*/

/** @deprecated */
params?: ParamsSDKType;
/** The vaults. */

vaults: VaultSDKType[];
/** The default quoting parameters for all vaults. */

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

Expand Down Expand Up @@ -60,21 +76,26 @@ export interface VaultSDKType {

function createBaseGenesisState(): GenesisState {
return {
defaultQuotingParams: undefined,
vaults: []
params: undefined,
vaults: [],
defaultQuotingParams: undefined
};
}

export const GenesisState = {
encode(message: GenesisState, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer {
if (message.defaultQuotingParams !== undefined) {
QuotingParams.encode(message.defaultQuotingParams, writer.uint32(10).fork()).ldelim();
if (message.params !== undefined) {
Params.encode(message.params, writer.uint32(10).fork()).ldelim();
}

for (const v of message.vaults) {
Vault.encode(v!, writer.uint32(18).fork()).ldelim();
}

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

return writer;
},

Expand All @@ -88,13 +109,17 @@ export const GenesisState = {

switch (tag >>> 3) {
case 1:
message.defaultQuotingParams = QuotingParams.decode(reader, reader.uint32());
message.params = Params.decode(reader, reader.uint32());
break;

case 2:
message.vaults.push(Vault.decode(reader, reader.uint32()));
break;

case 3:
message.defaultQuotingParams = QuotingParams.decode(reader, reader.uint32());
break;

default:
reader.skipType(tag & 7);
break;
Expand All @@ -106,8 +131,9 @@ export const GenesisState = {

fromPartial(object: DeepPartial<GenesisState>): GenesisState {
const message = createBaseGenesisState();
message.defaultQuotingParams = object.defaultQuotingParams !== undefined && object.defaultQuotingParams !== null ? QuotingParams.fromPartial(object.defaultQuotingParams) : undefined;
message.params = object.params !== undefined && object.params !== null ? Params.fromPartial(object.params) : undefined;
message.vaults = object.vaults?.map(e => Vault.fromPartial(e)) || [];
message.defaultQuotingParams = object.defaultQuotingParams !== undefined && object.defaultQuotingParams !== null ? QuotingParams.fromPartial(object.defaultQuotingParams) : undefined;
return message;
}

Expand Down
183 changes: 183 additions & 0 deletions indexer/packages/v4-protos/src/codegen/dydxprotocol/vault/params.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,84 @@ export interface QuotingParamsSDKType {

activation_threshold_quote_quantums: Uint8Array;
}
/**
* Deprecated: Params stores `x/vault` parameters.
* Deprecated since v6.x as is replaced by QuotingParams.
*/

export interface Params {
/**
* The number of layers of orders a vault places. For example if
* `layers=2`, a vault places 2 asks and 2 bids.
*/
layers: number;
/** The minimum base spread when a vault quotes around reservation price. */

spreadMinPpm: number;
/**
* The buffer amount to add to min_price_change_ppm to arrive at `spread`
* according to formula:
* `spread = max(spread_min_ppm, min_price_change_ppm + spread_buffer_ppm)`.
*/

spreadBufferPpm: number;
/** The factor that determines how aggressive a vault skews its orders. */

skewFactorPpm: number;
/** The percentage of vault equity that each order is sized at. */

orderSizePctPpm: number;
/** The duration that a vault's orders are valid for. */

orderExpirationSeconds: number;
/**
* The number of quote quantums in quote asset that a vault with no perpetual
* positions must have to activate, i.e. if a vault has no perpetual positions
* and has strictly less than this amount of quote asset, it will not
* activate.
*/

activationThresholdQuoteQuantums: Uint8Array;
}
/**
* Deprecated: Params stores `x/vault` parameters.
* Deprecated since v6.x as is replaced by QuotingParams.
*/

export interface ParamsSDKType {
/**
* The number of layers of orders a vault places. For example if
* `layers=2`, a vault places 2 asks and 2 bids.
*/
layers: number;
/** The minimum base spread when a vault quotes around reservation price. */

spread_min_ppm: number;
/**
* The buffer amount to add to min_price_change_ppm to arrive at `spread`
* according to formula:
* `spread = max(spread_min_ppm, min_price_change_ppm + spread_buffer_ppm)`.
*/

spread_buffer_ppm: number;
/** The factor that determines how aggressive a vault skews its orders. */

skew_factor_ppm: number;
/** The percentage of vault equity that each order is sized at. */

order_size_pct_ppm: number;
/** The duration that a vault's orders are valid for. */

order_expiration_seconds: number;
/**
* The number of quote quantums in quote asset that a vault with no perpetual
* positions must have to activate, i.e. if a vault has no perpetual positions
* and has strictly less than this amount of quote asset, it will not
* activate.
*/

activation_threshold_quote_quantums: Uint8Array;
}

function createBaseQuotingParams(): QuotingParams {
return {
Expand Down Expand Up @@ -176,4 +254,109 @@ export const QuotingParams = {
return message;
}

};

function createBaseParams(): Params {
return {
layers: 0,
spreadMinPpm: 0,
spreadBufferPpm: 0,
skewFactorPpm: 0,
orderSizePctPpm: 0,
orderExpirationSeconds: 0,
activationThresholdQuoteQuantums: new Uint8Array()
};
}

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

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

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

if (message.skewFactorPpm !== 0) {
writer.uint32(32).uint32(message.skewFactorPpm);
}

if (message.orderSizePctPpm !== 0) {
writer.uint32(40).uint32(message.orderSizePctPpm);
}

if (message.orderExpirationSeconds !== 0) {
writer.uint32(48).uint32(message.orderExpirationSeconds);
}

if (message.activationThresholdQuoteQuantums.length !== 0) {
writer.uint32(58).bytes(message.activationThresholdQuoteQuantums);
}

return writer;
},

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

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

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

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

case 3:
message.spreadBufferPpm = reader.uint32();
break;

case 4:
message.skewFactorPpm = reader.uint32();
break;

case 5:
message.orderSizePctPpm = reader.uint32();
break;

case 6:
message.orderExpirationSeconds = reader.uint32();
break;

case 7:
message.activationThresholdQuoteQuantums = reader.bytes();
break;

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

return message;
},

fromPartial(object: DeepPartial<Params>): Params {
const message = createBaseParams();
message.layers = object.layers ?? 0;
message.spreadMinPpm = object.spreadMinPpm ?? 0;
message.spreadBufferPpm = object.spreadBufferPpm ?? 0;
message.skewFactorPpm = object.skewFactorPpm ?? 0;
message.orderSizePctPpm = object.orderSizePctPpm ?? 0;
message.orderExpirationSeconds = object.orderExpirationSeconds ?? 0;
message.activationThresholdQuoteQuantums = object.activationThresholdQuoteQuantums ?? new Uint8Array();
return message;
}

};
22 changes: 20 additions & 2 deletions indexer/packages/v4-protos/src/codegen/dydxprotocol/vault/query.ts
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 { QuotingParams, QuotingParamsSDKType } from "./params";
import { Params, ParamsSDKType, QuotingParams, QuotingParamsSDKType } from "./params";
import { SubaccountId, SubaccountIdSDKType } from "../subaccounts/subaccount";
import { NumShares, NumSharesSDKType, OwnerShare, OwnerShareSDKType } from "./share";
import * as _m0 from "protobufjs/minimal";
Expand All @@ -14,11 +14,19 @@ export interface QueryParamsRequestSDKType {}
/** QueryParamsResponse is a response type for the Params RPC method. */

export interface QueryParamsResponse {
/** Deprecated since v6.x in favor of default_quoting_params. */

/** @deprecated */
params?: Params;
defaultQuotingParams?: QuotingParams;
}
/** QueryParamsResponse is a response type for the Params RPC method. */

export interface QueryParamsResponseSDKType {
/** Deprecated since v6.x in favor of default_quoting_params. */

/** @deprecated */
params?: ParamsSDKType;
default_quoting_params?: QuotingParamsSDKType;
}
/** QueryVaultRequest is a request type for the Vault RPC method. */
Expand Down Expand Up @@ -136,14 +144,19 @@ export const QueryParamsRequest = {

function createBaseQueryParamsResponse(): QueryParamsResponse {
return {
params: undefined,
defaultQuotingParams: undefined
};
}

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

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

return writer;
Expand All @@ -159,6 +172,10 @@ export const QueryParamsResponse = {

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

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

Expand All @@ -173,6 +190,7 @@ export const QueryParamsResponse = {

fromPartial(object: DeepPartial<QueryParamsResponse>): QueryParamsResponse {
const message = createBaseQueryParamsResponse();
message.params = object.params !== undefined && object.params !== null ? Params.fromPartial(object.params) : undefined;
message.defaultQuotingParams = object.defaultQuotingParams !== undefined && object.defaultQuotingParams !== null ? QuotingParams.fromPartial(object.defaultQuotingParams) : undefined;
return message;
}
Expand Down
Loading

0 comments on commit 21cf0ba

Please sign in to comment.