Skip to content

Commit

Permalink
[TRA-62] Add market type to the CreatePerpetual API (#1118)
Browse files Browse the repository at this point in the history
Signed-off-by: Shrenuj Bansal <shrenuj@dydx.exchange>
  • Loading branch information
shrenujb committed Feb 29, 2024
1 parent 564608e commit 7fd1d4f
Show file tree
Hide file tree
Showing 35 changed files with 523 additions and 96 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,63 @@
import * as _m0 from "protobufjs/minimal";
import { DeepPartial, Long } from "../../helpers";
export enum PerpetualMarketType {
/** PERPETUAL_MARKET_TYPE_UNSPECIFIED - Unspecified market type. */
PERPETUAL_MARKET_TYPE_UNSPECIFIED = 0,

/** PERPETUAL_MARKET_TYPE_CROSS - Market type for cross margin perpetual markets. */
PERPETUAL_MARKET_TYPE_CROSS = 1,

/** PERPETUAL_MARKET_TYPE_ISOLATED - Market type for isolated margin perpetual markets. */
PERPETUAL_MARKET_TYPE_ISOLATED = 2,
UNRECOGNIZED = -1,
}
export enum PerpetualMarketTypeSDKType {
/** PERPETUAL_MARKET_TYPE_UNSPECIFIED - Unspecified market type. */
PERPETUAL_MARKET_TYPE_UNSPECIFIED = 0,

/** PERPETUAL_MARKET_TYPE_CROSS - Market type for cross margin perpetual markets. */
PERPETUAL_MARKET_TYPE_CROSS = 1,

/** PERPETUAL_MARKET_TYPE_ISOLATED - Market type for isolated margin perpetual markets. */
PERPETUAL_MARKET_TYPE_ISOLATED = 2,
UNRECOGNIZED = -1,
}
export function perpetualMarketTypeFromJSON(object: any): PerpetualMarketType {
switch (object) {
case 0:
case "PERPETUAL_MARKET_TYPE_UNSPECIFIED":
return PerpetualMarketType.PERPETUAL_MARKET_TYPE_UNSPECIFIED;

case 1:
case "PERPETUAL_MARKET_TYPE_CROSS":
return PerpetualMarketType.PERPETUAL_MARKET_TYPE_CROSS;

case 2:
case "PERPETUAL_MARKET_TYPE_ISOLATED":
return PerpetualMarketType.PERPETUAL_MARKET_TYPE_ISOLATED;

case -1:
case "UNRECOGNIZED":
default:
return PerpetualMarketType.UNRECOGNIZED;
}
}
export function perpetualMarketTypeToJSON(object: PerpetualMarketType): string {
switch (object) {
case PerpetualMarketType.PERPETUAL_MARKET_TYPE_UNSPECIFIED:
return "PERPETUAL_MARKET_TYPE_UNSPECIFIED";

case PerpetualMarketType.PERPETUAL_MARKET_TYPE_CROSS:
return "PERPETUAL_MARKET_TYPE_CROSS";

case PerpetualMarketType.PERPETUAL_MARKET_TYPE_ISOLATED:
return "PERPETUAL_MARKET_TYPE_ISOLATED";

case PerpetualMarketType.UNRECOGNIZED:
default:
return "UNRECOGNIZED";
}
}
/** Perpetual represents a perpetual on the dYdX exchange. */

export interface Perpetual {
Expand Down Expand Up @@ -59,6 +117,9 @@ export interface PerpetualParams {
/** The liquidity_tier that this perpetual is associated with. */

liquidityTier: number;
/** The market type specifying if this perpetual is cross or isolated */

marketType: PerpetualMarketType;
}
/**
* PerpetualParams represents the parameters of a perpetual on the dYdX
Expand Down Expand Up @@ -95,6 +156,9 @@ export interface PerpetualParamsSDKType {
/** The liquidity_tier that this perpetual is associated with. */

liquidity_tier: number;
/** The market type specifying if this perpetual is cross or isolated */

market_type: PerpetualMarketTypeSDKType;
}
/** MarketPremiums stores a list of premiums for a single perpetual market. */

Expand Down Expand Up @@ -323,7 +387,8 @@ function createBasePerpetualParams(): PerpetualParams {
marketId: 0,
atomicResolution: 0,
defaultFundingPpm: 0,
liquidityTier: 0
liquidityTier: 0,
marketType: 0
};
}

Expand Down Expand Up @@ -353,6 +418,10 @@ export const PerpetualParams = {
writer.uint32(48).uint32(message.liquidityTier);
}

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

return writer;
},

Expand Down Expand Up @@ -389,6 +458,10 @@ export const PerpetualParams = {
message.liquidityTier = reader.uint32();
break;

case 7:
message.marketType = (reader.int32() as any);
break;

default:
reader.skipType(tag & 7);
break;
Expand All @@ -406,6 +479,7 @@ export const PerpetualParams = {
message.atomicResolution = object.atomicResolution ?? 0;
message.defaultFundingPpm = object.defaultFundingPpm ?? 0;
message.liquidityTier = object.liquidityTier ?? 0;
message.marketType = object.marketType ?? 0;
return message;
}

Expand Down
12 changes: 12 additions & 0 deletions proto/dydxprotocol/perpetuals/perpetual.proto
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,15 @@ message Perpetual {
];
}

enum PerpetualMarketType {
// Unspecified market type.
PERPETUAL_MARKET_TYPE_UNSPECIFIED = 0;
// Market type for cross margin perpetual markets.
PERPETUAL_MARKET_TYPE_CROSS = 1;
// Market type for isolated margin perpetual markets.
PERPETUAL_MARKET_TYPE_ISOLATED = 2;
}

// PerpetualParams represents the parameters of a perpetual on the dYdX
// exchange.
message PerpetualParams {
Expand All @@ -45,6 +54,9 @@ message PerpetualParams {

// The liquidity_tier that this perpetual is associated with.
uint32 liquidity_tier = 6;

// The market type specifying if this perpetual is cross or isolated
PerpetualMarketType market_type = 7;
}

// MarketPremiums stores a list of premiums for a single perpetual market.
Expand Down
6 changes: 3 additions & 3 deletions protocol/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -417,9 +417,9 @@ update-swagger-docs: statik

# Run at `./protocol` directory.
update-sample-pregenesis:
make build
./scripts/genesis/prod_pregenesis.sh build/dydxprotocold
cp /tmp/prod-chain/.dydxprotocol/config/sorted_genesis.json ./scripts/genesis/sample_pregenesis.json
$(MAKE) localnet-build
@docker build . -t check-sample-pregenesis -f scripts/genesis/Dockerfile --no-cache
@docker run --entrypoint ./scripts/genesis/copy_sample_pregenesis.sh -v $(CURDIR):/workspace check-sample-pregenesis
@echo "Updated ./scripts/genesis/sample_pregenesis.json"

check-sample-pregenesis-up-to-date:
Expand Down
18 changes: 9 additions & 9 deletions protocol/mocks/PerpetualsKeeper.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions protocol/scripts/genesis/copy_sample_pregenesis.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/bash

./scripts/genesis/prod_pregenesis.sh dydxprotocold
cp /tmp/prod-chain/.dydxprotocol/config/sorted_genesis.json ./scripts/genesis/sample_pregenesis.json
Loading

0 comments on commit 7fd1d4f

Please sign in to comment.