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

Fix proto formatting #2020

Merged
merged 2 commits into from
Aug 2, 2024
Merged

Fix proto formatting #2020

merged 2 commits into from
Aug 2, 2024

Conversation

jonfung-dydx
Copy link
Contributor

@jonfung-dydx jonfung-dydx commented Aug 2, 2024

Summary by CodeRabbit

  • New Features

    • Introduced new interfaces for StreamLiquidationOrder, StreamTakerOrder, and StreamTakerOrderStatus to enhance order processing in streaming contexts.
    • Added functionalities for encoding and decoding messages related to the new order types, improving data handling during transmission.
  • Chores

    • Improved readability of comments in the StreamLiquidationOrder message for better clarity.
    • Enhanced comment formatting in the StreamTakerOrderStatus message to ensure ease of understanding.

Copy link
Contributor

coderabbitai bot commented Aug 2, 2024

Important

Review skipped

Auto reviews are limited to specific labels.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Walkthrough

The recent updates introduce new interfaces and enhancements for handling liquidation and taker orders within the protocol. Key additions include StreamLiquidationOrder, StreamTakerOrder, and StreamTakerOrderStatus, which facilitate structured representations of order data. Minor formatting changes to comments improve readability without affecting functionality. Overall, these changes enhance the clarity and usability of the codebase for streaming order processing.

Changes

File Change Summary
proto/dydxprotocol/clob/order.proto Reformatted comments in StreamLiquidationOrder for improved readability; no functional changes.
proto/dydxprotocol/clob/query.proto Enhanced comments in StreamTakerOrderStatus for clarity; no impact on functionality.
indexer/packages/v4-protos/src/codegen/dydxprotocol/clob/order.ts Introduced StreamLiquidationOrder and StreamLiquidationOrderSDKType; added encoding/decoding functions.
indexer/packages/v4-protos/src/codegen/dydxprotocol/clob/query.ts Added StreamTakerOrder, StreamTakerOrderStatus, and their SDK types; implemented serialization functions.

Poem

🐇 In the code where comments play,
Lines were long, now short they stay.
New orders hop with structured grace,
Clarity shines in every space.
With each tweak, our work's a song,
Hoppy code, where we belong! 🐇✨


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share
Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (invoked as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 7b9c6a9 and c194c38.

Files ignored due to path filters (2)
  • protocol/x/clob/types/order.pb.go is excluded by !**/*.pb.go
  • protocol/x/clob/types/query.pb.go is excluded by !**/*.pb.go
Files selected for processing (2)
  • proto/dydxprotocol/clob/order.proto (1 hunks)
  • proto/dydxprotocol/clob/query.proto (1 hunks)
Files skipped from review due to trivial changes (2)
  • proto/dydxprotocol/clob/order.proto
  • proto/dydxprotocol/clob/query.proto

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

Outside diff range, codebase verification and nitpick comments (7)
indexer/packages/v4-protos/src/codegen/dydxprotocol/clob/order.ts (3)

704-730: LGTM! Consider adding comments for clarity.

The StreamLiquidationOrder interface is well-defined. Adding comments for each property can enhance readability and maintainability.

export interface StreamLiquidationOrder {
  /** Information about this liquidation order. */
  liquidationInfo?: PerpetualLiquidationInfo;
  /**
   * CLOB pair ID of the CLOB pair the liquidation order will be matched
   * against.
   */
  clobPairId: number;
  /**
   * True if this is a buy order liquidating a short position, false if vice
   * versa.
   */
  isBuy: boolean;
  /** The number of base quantums for this liquidation order. */
  quantums: Long;
  /** The subticks this liquidation order will be submitted at. */
  subticks: Long;
}

736-756: LGTM! Consider adding comments for clarity.

The StreamLiquidationOrderSDKType interface is well-defined. Adding comments for each property can enhance readability and maintainability.

export interface StreamLiquidationOrderSDKType {
  /** Information about this liquidation order. */
  liquidation_info?: PerpetualLiquidationInfoSDKType;
  /**
   * CLOB pair ID of the CLOB pair the liquidation order will be matched
   * against.
   */
  clob_pair_id: number;
  /**
   * True if this is a buy order liquidating a short position, false if vice
   * versa.
   */
  is_buy: boolean;
  /** The number of base quantums for this liquidation order. */
  quantums: Long;
  /** The subticks this liquidation order will be submitted at. */
  subticks: Long;
}

1344-1426: LGTM! Consider adding comments for clarity.

The createBaseStreamLiquidationOrder function is well-implemented. Adding comments for each step can enhance readability and maintainability.

function createBaseStreamLiquidationOrder(): StreamLiquidationOrder {
  return {
    liquidationInfo: undefined,
    clobPairId: 0,
    isBuy: false,
    quantums: Long.UZERO,
    subticks: Long.UZERO
  };
}

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

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

    if (message.isBuy === true) {
      writer.uint32(24).bool(message.isBuy);
    }

    if (!message.quantums.isZero()) {
      writer.uint32(32).uint64(message.quantums);
    }

    if (!message.subticks.isZero()) {
      writer.uint32(40).uint64(message.subticks);
    }

    return writer;
  },

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

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

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

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

        case 3:
          message.isBuy = reader.bool();
          break;

        case 4:
          message.quantums = (reader.uint64() as Long);
          break;

        case 5:
          message.subticks = (reader.uint64() as Long);
          break;

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

    return message;
  },

  fromPartial(object: DeepPartial<StreamLiquidationOrder>): StreamLiquidationOrder {
    const message = createBaseStreamLiquidationOrder();
    message.liquidationInfo = object.liquidationInfo !== undefined && object.liquidationInfo !== null ? PerpetualLiquidationInfo.fromPartial(object.liquidationInfo) : undefined;
    message.clobPairId = object.clobPairId ?? 0;
    message.isBuy = object.isBuy ?? false;
    message.quantums = object.quantums !== undefined && object.quantums !== null ? Long.fromValue(object.quantums) : Long.UZERO;
    message.subticks = object.subticks !== undefined && object.subticks !== null ? Long.fromValue(object.subticks) : Long.UZERO;
    return message;
  }
};
indexer/packages/v4-protos/src/codegen/dydxprotocol/clob/query.ts (4)

394-409: LGTM! Consider adding comments for clarity.

The StreamTakerOrder interface is well-defined. Adding comments for each property can enhance readability and maintainability.

export interface StreamTakerOrder {
  /** The order itself. */
  order?: Order;
  /** Potential liquidation order associated with this taker order. */
  liquidationOrder?: StreamLiquidationOrder;
  /**
   * Information on the taker order after it is matched on the book,
   * either successfully or unsuccessfully.
   */
  takerOrderStatus?: StreamTakerOrderStatus;
}

416-424: LGTM! Consider adding comments for clarity.

The StreamTakerOrderSDKType interface is well-defined. Adding comments for each property can enhance readability and maintainability.

export interface StreamTakerOrderSDKType {
  /** The order itself. */
  order?: OrderSDKType;
  /** Potential liquidation order associated with this taker order. */
  liquidation_order?: StreamLiquidationOrderSDKType;
  /**
   * Information on the taker order after it is matched on the book,
   * either successfully or unsuccessfully.
   */
  taker_order_status?: StreamTakerOrderStatusSDKType;
}

426-451: LGTM! Consider adding comments for clarity.

The StreamTakerOrderStatus interface is well-defined. Adding comments for each property can enhance readability and maintainability.

export interface StreamTakerOrderStatus {
  /**
   * The state of the taker order after attempting to match it against the
   * orderbook. Possible enum values can be found here:
   * https://github.com/dydxprotocol/v4-chain/blob/main/protocol/x/clob/types/orderbook.go#L105
   */
  orderStatus: number;
  /** The amount of remaining (non-matched) base quantums of this taker order. */
  remainingQuantums: Long;
  /**
   * The amount of base quantums that were *optimistically* filled for this
   * taker order when the order is matched against the orderbook. Note that if
   * any quantums of this order were optimistically filled or filled in state
   * before this invocation of the matching loop, this value will not include
   * them.
   */
  optimisticallyFilledQuantums: Long;
}

458-476: LGTM! Consider adding comments for clarity.

The StreamTakerOrderStatusSDKType interface is well-defined. Adding comments for each property can enhance readability and maintainability.

export interface StreamTakerOrderStatusSDKType {
  /**
   * The state of the taker order after attempting to match it against the
   * orderbook. Possible enum values can be found here:
   * https://github.com/dydxprotocol/v4-chain/blob/main/protocol/x/clob/types/orderbook.go#L105
   */
  order_status: number;
  /** The amount of remaining (non-matched) base quantums of this taker order. */
  remaining_quantums: Long;
  /**
   * The amount of base quantums that were *optimistically* filled for this
   * taker order when the order is matched against the orderbook. Note that if
   * any quantums of this order were optimistically filled or filled in state
   * before this invocation of the matching loop, this value will not include
   * them.
   */
  optimistically_filled_quantums: Long;
}
Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between c194c38 and 09c2f9a.

Files selected for processing (2)
  • indexer/packages/v4-protos/src/codegen/dydxprotocol/clob/order.ts (3 hunks)
  • indexer/packages/v4-protos/src/codegen/dydxprotocol/clob/query.ts (3 hunks)

@jonfung-dydx jonfung-dydx merged commit 9608e19 into main Aug 2, 2024
32 of 33 checks passed
@jonfung-dydx jonfung-dydx deleted the jonfung/fmtProto branch August 2, 2024 20:39
jonfung-dydx added a commit that referenced this pull request Aug 15, 2024
jonfung-dydx added a commit that referenced this pull request Sep 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging this pull request may close these issues.

2 participants