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-227] Add V2 for perpetual market create event + handlers. (backport #1395) #1402

Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -780,8 +780,12 @@ export interface AssetCreateEventV1SDKType {
/**
* PerpetualMarketCreateEventV1 message contains all the information about a
* new Perpetual Market on the dYdX chain.
* Deprecated. See PerpetualMarketCreateEventV2 for the most up to date message
* for the event to create a new Perpetual Market.
*/

/** @deprecated */

export interface PerpetualMarketCreateEventV1 {
/**
* Unique Perpetual id.
Expand All @@ -808,6 +812,150 @@ export interface PerpetualMarketCreateEventV1 {
marketId: number;
/** Status of the CLOB */

status: ClobPairStatus;
/**
* `10^Exponent` gives the number of QuoteQuantums traded per BaseQuantum
* per Subtick.
* Defined in clob.clob_pair
*/

quantumConversionExponent: number;
/**
* The exponent for converting an atomic amount (`size = 1`)
* to a full coin. For example, if `AtomicResolution = -8`
* then a `PerpetualPosition` with `size = 1e8` is equivalent to
* a position size of one full coin.
* Defined in perpetuals.perpetual
*/

atomicResolution: number;
/**
* Defines the tick size of the orderbook by defining how many subticks
* are in one tick. That is, the subticks of any valid order must be a
* multiple of this value. Generally this value should start `>= 100`to
* allow room for decreasing it.
* Defined in clob.clob_pair
*/

subticksPerTick: number;
/**
* Minimum increment in the size of orders on the CLOB, in base quantums.
* Defined in clob.clob_pair
*/

stepBaseQuantums: Long;
/**
* The liquidity_tier that this perpetual is associated with.
* Defined in perpetuals.perpetual
*/

liquidityTier: number;
}
/**
* PerpetualMarketCreateEventV1 message contains all the information about a
* new Perpetual Market on the dYdX chain.
* Deprecated. See PerpetualMarketCreateEventV2 for the most up to date message
* for the event to create a new Perpetual Market.
*/

/** @deprecated */

export interface PerpetualMarketCreateEventV1SDKType {
/**
* Unique Perpetual id.
* Defined in perpetuals.perpetual
*/
id: number;
/**
* Unique clob pair Id associated with this perpetual market
* Defined in clob.clob_pair
*/

clob_pair_id: number;
/**
* The name of the `Perpetual` (e.g. `BTC-USD`).
* Defined in perpetuals.perpetual
*/

ticker: string;
/**
* Unique id of market param associated with this perpetual market.
* Defined in perpetuals.perpetual
*/

market_id: number;
/** Status of the CLOB */

status: ClobPairStatusSDKType;
/**
* `10^Exponent` gives the number of QuoteQuantums traded per BaseQuantum
* per Subtick.
* Defined in clob.clob_pair
*/

quantum_conversion_exponent: number;
/**
* The exponent for converting an atomic amount (`size = 1`)
* to a full coin. For example, if `AtomicResolution = -8`
* then a `PerpetualPosition` with `size = 1e8` is equivalent to
* a position size of one full coin.
* Defined in perpetuals.perpetual
*/

atomic_resolution: number;
/**
* Defines the tick size of the orderbook by defining how many subticks
* are in one tick. That is, the subticks of any valid order must be a
* multiple of this value. Generally this value should start `>= 100`to
* allow room for decreasing it.
* Defined in clob.clob_pair
*/

subticks_per_tick: number;
/**
* Minimum increment in the size of orders on the CLOB, in base quantums.
* Defined in clob.clob_pair
*/

step_base_quantums: Long;
/**
* The liquidity_tier that this perpetual is associated with.
* Defined in perpetuals.perpetual
*/

liquidity_tier: number;
}
/**
* PerpetualMarketCreateEventV2 message contains all the information about a
* new Perpetual Market on the dYdX chain.
*/

export interface PerpetualMarketCreateEventV2 {
/**
* Unique Perpetual id.
* Defined in perpetuals.perpetual
*/
id: number;
/**
* Unique clob pair Id associated with this perpetual market
* Defined in clob.clob_pair
*/

clobPairId: number;
/**
* The name of the `Perpetual` (e.g. `BTC-USD`).
* Defined in perpetuals.perpetual
*/

ticker: string;
/**
* Unique id of market param associated with this perpetual market.
* Defined in perpetuals.perpetual
*/

marketId: number;
/** Status of the CLOB */

status: ClobPairStatus;
/**
* `10^Exponent` gives the number of QuoteQuantums traded per BaseQuantum
Expand Down Expand Up @@ -851,11 +999,11 @@ export interface PerpetualMarketCreateEventV1 {
marketType: PerpetualMarketType;
}
/**
* PerpetualMarketCreateEventV1 message contains all the information about a
* PerpetualMarketCreateEventV2 message contains all the information about a
* new Perpetual Market on the dYdX chain.
*/

export interface PerpetualMarketCreateEventV1SDKType {
export interface PerpetualMarketCreateEventV2SDKType {
/**
* Unique Perpetual id.
* Defined in perpetuals.perpetual
Expand Down Expand Up @@ -2649,8 +2797,7 @@ function createBasePerpetualMarketCreateEventV1(): PerpetualMarketCreateEventV1
atomicResolution: 0,
subticksPerTick: 0,
stepBaseQuantums: Long.UZERO,
liquidityTier: 0,
marketType: 0
liquidityTier: 0
};
}

Expand Down Expand Up @@ -2696,17 +2843,153 @@ export const PerpetualMarketCreateEventV1 = {
writer.uint32(80).uint32(message.liquidityTier);
}

return writer;
},

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

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

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

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

case 3:
message.ticker = reader.string();
break;

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

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

case 6:
message.quantumConversionExponent = reader.sint32();
break;

case 7:
message.atomicResolution = reader.sint32();
break;

case 8:
message.subticksPerTick = reader.uint32();
break;

case 9:
message.stepBaseQuantums = (reader.uint64() as Long);
break;

case 10:
message.liquidityTier = reader.uint32();
break;

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

return message;
},

fromPartial(object: DeepPartial<PerpetualMarketCreateEventV1>): PerpetualMarketCreateEventV1 {
const message = createBasePerpetualMarketCreateEventV1();
message.id = object.id ?? 0;
message.clobPairId = object.clobPairId ?? 0;
message.ticker = object.ticker ?? "";
message.marketId = object.marketId ?? 0;
message.status = object.status ?? 0;
message.quantumConversionExponent = object.quantumConversionExponent ?? 0;
message.atomicResolution = object.atomicResolution ?? 0;
message.subticksPerTick = object.subticksPerTick ?? 0;
message.stepBaseQuantums = object.stepBaseQuantums !== undefined && object.stepBaseQuantums !== null ? Long.fromValue(object.stepBaseQuantums) : Long.UZERO;
message.liquidityTier = object.liquidityTier ?? 0;
return message;
}

};

function createBasePerpetualMarketCreateEventV2(): PerpetualMarketCreateEventV2 {
return {
id: 0,
clobPairId: 0,
ticker: "",
marketId: 0,
status: 0,
quantumConversionExponent: 0,
atomicResolution: 0,
subticksPerTick: 0,
stepBaseQuantums: Long.UZERO,
liquidityTier: 0,
marketType: 0
};
}

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

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

if (message.ticker !== "") {
writer.uint32(26).string(message.ticker);
}

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

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

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

if (message.atomicResolution !== 0) {
writer.uint32(56).sint32(message.atomicResolution);
}

if (message.subticksPerTick !== 0) {
writer.uint32(64).uint32(message.subticksPerTick);
}

if (!message.stepBaseQuantums.isZero()) {
writer.uint32(72).uint64(message.stepBaseQuantums);
}

if (message.liquidityTier !== 0) {
writer.uint32(80).uint32(message.liquidityTier);
}

if (message.marketType !== 0) {
writer.uint32(88).int32(message.marketType);
}

return writer;
},

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

while (reader.pos < end) {
const tag = reader.uint32();
Expand Down Expand Up @@ -2765,8 +3048,8 @@ export const PerpetualMarketCreateEventV1 = {
return message;
},

fromPartial(object: DeepPartial<PerpetualMarketCreateEventV1>): PerpetualMarketCreateEventV1 {
const message = createBasePerpetualMarketCreateEventV1();
fromPartial(object: DeepPartial<PerpetualMarketCreateEventV2>): PerpetualMarketCreateEventV2 {
const message = createBasePerpetualMarketCreateEventV2();
message.id = object.id ?? 0;
message.clobPairId = object.clobPairId ?? 0;
message.ticker = object.ticker ?? "";
Expand Down
Loading
Loading