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

[CLOB-1007] add protos for final settlement clob pair status and removal reason #828

Merged
merged 6 commits into from
Dec 5, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
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 @@ -33,6 +33,12 @@ export enum ClobPair_Status {
* both short-term and post-only.
*/
STATUS_INITIALIZING = 5,

/**
* STATUS_FINAL_SETTLEMENT - STATUS_FINAL_SETTLEMENT represents a clob pair which is deactivated
* and trading has ceased. All open positions will be closed by the protocol.option
Copy link
Contributor

Choose a reason for hiding this comment

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

There appears to be a typo in the comment. "protocol.option" should be corrected to "protocol."

-  * and trading has ceased. All open positions will be closed by the protocol.option
+  * and trading has ceased. All open positions will be closed by the protocol.

Committable suggestion

IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.

Suggested change
* and trading has ceased. All open positions will be closed by the protocol.option
* and trading has ceased. All open positions will be closed by the protocol.

*/
STATUS_FINAL_SETTLEMENT = 6,
UNRECOGNIZED = -1,
}
/** Status of the CLOB. */
Expand Down Expand Up @@ -68,6 +74,12 @@ export enum ClobPair_StatusSDKType {
* both short-term and post-only.
*/
STATUS_INITIALIZING = 5,

/**
* STATUS_FINAL_SETTLEMENT - STATUS_FINAL_SETTLEMENT represents a clob pair which is deactivated
* and trading has ceased. All open positions will be closed by the protocol.option
*/
STATUS_FINAL_SETTLEMENT = 6,
UNRECOGNIZED = -1,
}
export function clobPair_StatusFromJSON(object: any): ClobPair_Status {
Expand Down Expand Up @@ -96,6 +108,10 @@ export function clobPair_StatusFromJSON(object: any): ClobPair_Status {
case "STATUS_INITIALIZING":
return ClobPair_Status.STATUS_INITIALIZING;

case 6:
case "STATUS_FINAL_SETTLEMENT":
return ClobPair_Status.STATUS_FINAL_SETTLEMENT;

case -1:
case "UNRECOGNIZED":
default:
Expand All @@ -122,6 +138,9 @@ export function clobPair_StatusToJSON(object: ClobPair_Status): string {
case ClobPair_Status.STATUS_INITIALIZING:
return "STATUS_INITIALIZING";

case ClobPair_Status.STATUS_FINAL_SETTLEMENT:
return "STATUS_FINAL_SETTLEMENT";

case ClobPair_Status.UNRECOGNIZED:
default:
return "UNRECOGNIZED";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,14 @@ export enum ClobPairStatus {
* both short-term and post-only.
*/
CLOB_PAIR_STATUS_INITIALIZING = 5,

/**
* CLOB_PAIR_STATUS_FINAL_SETTLEMENT - CLOB_PAIR_STATUS_FINAL_SETTLEMENT represents a clob pair that has been
* deactivated. Clob pairs in this state do not accept new orders and trading
* is blocked. All open positions are closed by the protocol when the clob pair
* gains this status.
*/
CLOB_PAIR_STATUS_FINAL_SETTLEMENT = 6,
UNRECOGNIZED = -1,
}
/**
Expand Down Expand Up @@ -348,6 +356,14 @@ export enum ClobPairStatusSDKType {
* both short-term and post-only.
*/
CLOB_PAIR_STATUS_INITIALIZING = 5,

/**
* CLOB_PAIR_STATUS_FINAL_SETTLEMENT - CLOB_PAIR_STATUS_FINAL_SETTLEMENT represents a clob pair that has been
* deactivated. Clob pairs in this state do not accept new orders and trading
* is blocked. All open positions are closed by the protocol when the clob pair
* gains this status.
*/
CLOB_PAIR_STATUS_FINAL_SETTLEMENT = 6,
UNRECOGNIZED = -1,
}
export function clobPairStatusFromJSON(object: any): ClobPairStatus {
Expand Down Expand Up @@ -376,6 +392,10 @@ export function clobPairStatusFromJSON(object: any): ClobPairStatus {
case "CLOB_PAIR_STATUS_INITIALIZING":
return ClobPairStatus.CLOB_PAIR_STATUS_INITIALIZING;

case 6:
case "CLOB_PAIR_STATUS_FINAL_SETTLEMENT":
return ClobPairStatus.CLOB_PAIR_STATUS_FINAL_SETTLEMENT;

case -1:
case "UNRECOGNIZED":
default:
Expand All @@ -402,6 +422,9 @@ export function clobPairStatusToJSON(object: ClobPairStatus): string {
case ClobPairStatus.CLOB_PAIR_STATUS_INITIALIZING:
return "CLOB_PAIR_STATUS_INITIALIZING";

case ClobPairStatus.CLOB_PAIR_STATUS_FINAL_SETTLEMENT:
return "CLOB_PAIR_STATUS_FINAL_SETTLEMENT";

case ClobPairStatus.UNRECOGNIZED:
default:
return "UNRECOGNIZED";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,9 @@ export enum OrderRemovalReason {
* equity tier requirements.
*/
ORDER_REMOVAL_REASON_EQUITY_TIER = 13,

/** ORDER_REMOVAL_REASON_FINAL_SETTLEMENT - The order has been removed since its ClobPair has entered final settlement. */
ORDER_REMOVAL_REASON_FINAL_SETTLEMENT = 14,
UNRECOGNIZED = -1,
}
/** OrderRemovalReason is an enum of all the reasons an order was removed. */
Expand Down Expand Up @@ -155,6 +158,9 @@ export enum OrderRemovalReasonSDKType {
* equity tier requirements.
*/
ORDER_REMOVAL_REASON_EQUITY_TIER = 13,

/** ORDER_REMOVAL_REASON_FINAL_SETTLEMENT - The order has been removed since its ClobPair has entered final settlement. */
Copy link
Contributor

Choose a reason for hiding this comment

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

The comment for ORDER_REMOVAL_REASON_FINAL_SETTLEMENT in the OrderRemovalReasonSDKType enum should be updated to match the new wording in the OrderRemovalReason enum for consistency.

-  /** ORDER_REMOVAL_REASON_FINAL_SETTLEMENT - The order has been removed since its ClobPair has entered final settlement. */
+  /** ORDER_REMOVAL_REASON_FINAL_SETTLEMENT - The order has been removed due to final settlement of its ClobPair. */

Committable suggestion

IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.

Suggested change
/** ORDER_REMOVAL_REASON_FINAL_SETTLEMENT - The order has been removed since its ClobPair has entered final settlement. */
/** ORDER_REMOVAL_REASON_FINAL_SETTLEMENT - The order has been removed due to final settlement of its ClobPair. */

ORDER_REMOVAL_REASON_FINAL_SETTLEMENT = 14,
UNRECOGNIZED = -1,
}
export function orderRemovalReasonFromJSON(object: any): OrderRemovalReason {
Expand Down Expand Up @@ -215,6 +221,10 @@ export function orderRemovalReasonFromJSON(object: any): OrderRemovalReason {
case "ORDER_REMOVAL_REASON_EQUITY_TIER":
return OrderRemovalReason.ORDER_REMOVAL_REASON_EQUITY_TIER;

case 14:
case "ORDER_REMOVAL_REASON_FINAL_SETTLEMENT":
Copy link
Contributor

Choose a reason for hiding this comment

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

The comment for ORDER_REMOVAL_REASON_FINAL_SETTLEMENT in the orderRemovalReasonFromJSON and orderRemovalReasonToJSON functions should be updated to match the new wording in the OrderRemovalReason enum for consistency.

-    case "ORDER_REMOVAL_REASON_FINAL_SETTLEMENT":
+    case "ORDER_REMOVAL_REASON_FINAL_SETTLEMENT - The order has been removed due to final settlement of its ClobPair.":

Committable suggestion

IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.

Suggested change
case "ORDER_REMOVAL_REASON_FINAL_SETTLEMENT":
case "ORDER_REMOVAL_REASON_FINAL_SETTLEMENT - The order has been removed due to final settlement of its ClobPair.":

return OrderRemovalReason.ORDER_REMOVAL_REASON_FINAL_SETTLEMENT;

case -1:
case "UNRECOGNIZED":
default:
Expand Down Expand Up @@ -265,6 +275,9 @@ export function orderRemovalReasonToJSON(object: OrderRemovalReason): string {
case OrderRemovalReason.ORDER_REMOVAL_REASON_EQUITY_TIER:
return "ORDER_REMOVAL_REASON_EQUITY_TIER";

case OrderRemovalReason.ORDER_REMOVAL_REASON_FINAL_SETTLEMENT:
return "ORDER_REMOVAL_REASON_FINAL_SETTLEMENT";

case OrderRemovalReason.UNRECOGNIZED:
default:
return "UNRECOGNIZED";
Expand Down
3 changes: 3 additions & 0 deletions proto/dydxprotocol/clob/clob_pair.proto
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,9 @@ message ClobPair {
// Clob pairs in this state only accept orders which are
// both short-term and post-only.
STATUS_INITIALIZING = 5;
// STATUS_FINAL_SETTLEMENT represents a clob pair which is deactivated
// and trading has ceased. All open positions will be closed by the protocol.option
Copy link
Contributor

Choose a reason for hiding this comment

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

There appears to be a typo in the comment on line 69. The word 'option' should be removed as it seems to be out of place.

-    // and trading has ceased. All open positions will be closed by the protocol.option
+    // and trading has ceased. All open positions will be closed by the protocol.

Committable suggestion

IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.

Suggested change
// and trading has ceased. All open positions will be closed by the protocol.option
// and trading has ceased. All open positions will be closed by the protocol.

STATUS_FINAL_SETTLEMENT = 6;
}

Status status = 7;
Expand Down
5 changes: 5 additions & 0 deletions proto/dydxprotocol/indexer/protocol/v1/clob.proto
Original file line number Diff line number Diff line change
Expand Up @@ -173,4 +173,9 @@ enum ClobPairStatus {
// Clob pairs in this state only accept orders which are
// both short-term and post-only.
CLOB_PAIR_STATUS_INITIALIZING = 5;
// CLOB_PAIR_STATUS_FINAL_SETTLEMENT represents a clob pair that has been
// deactivated. Clob pairs in this state do not accept new orders and trading
// is blocked. All open positions are closed by the protocol when the clob pair
// gains this status.
CLOB_PAIR_STATUS_FINAL_SETTLEMENT = 6;
}
2 changes: 2 additions & 0 deletions proto/dydxprotocol/indexer/shared/removal_reason.proto
Original file line number Diff line number Diff line change
Expand Up @@ -51,4 +51,6 @@ enum OrderRemovalReason {
// The order has been removed since the subaccount does not satisfy the
// equity tier requirements.
ORDER_REMOVAL_REASON_EQUITY_TIER = 13;
// The order has been removed since its ClobPair has entered final settlement.
ORDER_REMOVAL_REASON_FINAL_SETTLEMENT = 14;
}
122 changes: 65 additions & 57 deletions protocol/indexer/protocol/v1/clob.pb.go

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

2 changes: 2 additions & 0 deletions protocol/indexer/protocol/v1/v1_mappers.go
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,8 @@ func ConvertToClobPairStatus(status clobtypes.ClobPair_Status) ClobPairStatus {
return ClobPairStatus_CLOB_PAIR_STATUS_POST_ONLY
case clobtypes.ClobPair_STATUS_INITIALIZING:
return ClobPairStatus_CLOB_PAIR_STATUS_INITIALIZING
case clobtypes.ClobPair_STATUS_FINAL_SETTLEMENT:
return ClobPairStatus_CLOB_PAIR_STATUS_FINAL_SETTLEMENT
default:
panic("invalid clob pair status")
Copy link
Contributor

Choose a reason for hiding this comment

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

Using panic in the default case of the switch statement can be dangerous as it will cause the application to crash if an unexpected status is encountered. Consider handling this case more gracefully, possibly by returning an error that can be handled by the caller, to avoid crashing the entire application.

jakob-dydx marked this conversation as resolved.
Show resolved Hide resolved
}
Expand Down
Loading
Loading