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

[OTE-272] update DB and APIs to add OI caps info #1305

Merged
merged 12 commits into from
Apr 9, 2024

Conversation

affanv14
Copy link
Contributor

@affanv14 affanv14 commented Apr 1, 2024

Changelist

  • Adds OI caps handling on ender
  • Adds db updates to store OI caps
  • Updates api to send back OI caps with perp market info

Test Plan

[Describe how this PR was tested (if applicable)]

Author/Reviewer Checklist

  • If this PR has changes that result in a different app state given the same prior state and transaction list, manually add the state-breaking label.
  • If the PR has breaking postgres changes to the indexer add the indexer-postgres-breaking label.
  • If this PR isn't state-breaking but has changes that modify behavior in PrepareProposal or ProcessProposal, manually add the label proposal-breaking.
  • If this PR is one of many that implement a specific feature, manually label them all feature:[feature-name].
  • If you wish to for mergify-bot to automatically create a PR to backport your change to a release branch, manually add the label backport/[branch-name].
  • Manually add any of the following labels: refactor, chore, bug.

Summary by CodeRabbit

  • New Features

    • Introduced LiquidityTierUpsertEventV2 with enhanced data fields for margin fractions, position sizes, and open interest caps.
  • Improvements

    • Improved accuracy in liquidity tier calculations and event handling.
    • Updated event parsing methods to support new and deprecated versions of liquidity tier events.
  • Bug Fixes

    • Fixed parsing issue in LiquidityTierHandler to correctly interpret liquidity tier data.
  • Tests

    • Enhanced tests for liquidity tier handling with direct property comparisons and numerical conversions.
  • Deprecations

    • Deprecated LiquidityTierUpsertEventV1 in favor of the new version to reflect updated data fields.

Copy link
Contributor

coderabbitai bot commented Apr 1, 2024

Walkthrough

The recent updates involve enhancing the comparison method for liquidity tier properties in tests, refining data parsing in the LiquidityTierHandler class, and introducing a new version of the LiquidityTierUpsertEvent. These changes improve the accuracy of property comparisons by focusing on individual attributes and ensuring proper data type handling. Furthermore, the system's adaptability is enhanced by supporting multiple versions of liquidity tier events, accommodating evolving data structures.

Changes

File Path Change Summary
.../ender/__tests__/handlers/... Updated property comparison methods and added number conversions for caps in tests.
.../ender/__tests__/helpers/constants.ts Changed openInterestUpperCap value in defaultLiquidityTierUpsertEvent to 1_000_000_000_000.
.../ender/__tests__/validators/liquidity-tier-validator.test.ts Updated usage of validator and event structures to newer versions.
.../ender/src/handlers/liquidity-tier-handler.ts Refined data parsing to use LiquidityTiersFromDatabase with improved casting clarity.
.../ender/src/lib/helper.ts Introduced LiquidityTierUpsertEventV2 and updated event handling to support multiple versions.
.../packages/v4-protos/src/codegen/dydxprotocol/indexer/events/events.ts Deprecated old interfaces, introduced new versions with additional fields.
.../proto/dydxprotocol/indexer/events/events.proto Updated message to LiquidityTierUpsertEventV2 with new fields and optional open_interest_lower_cap.
.../protocol/indexer/events/liquidity_tier.go Updated NewLiquidityTierUpsertEvent to return LiquidityTierUpsertEventV2 with revised struct fields.

Recent Review Status

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between 77c010a and 667ae13.
Files selected for processing (3)
  • indexer/services/ender/tests/handlers/liquidity-tier-handler.test.ts (6 hunks)
  • indexer/services/ender/tests/helpers/constants.ts (2 hunks)
  • indexer/services/ender/tests/validators/liquidity-tier-validator.test.ts (5 hunks)
Files skipped from review as they are similar to previous changes (3)
  • indexer/services/ender/tests/handlers/liquidity-tier-handler.test.ts
  • indexer/services/ender/tests/helpers/constants.ts
  • indexer/services/ender/tests/validators/liquidity-tier-validator.test.ts

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.

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 a review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai help to get help.

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

CodeRabbit Configration 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 Status

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between e953077 and 70bccb8.
Files ignored due to path filters (1)
  • indexer/services/comlink/public/swagger.json is excluded by !**/*.json
Files selected for processing (17)
  • indexer/packages/postgres/tests/helpers/constants.ts (1 hunks)
  • indexer/packages/postgres/src/db/migrations/migration_files/20240329154240_liquidity_tier_update.ts (1 hunks)
  • indexer/packages/postgres/src/models/liquidity-tiers-model.ts (4 hunks)
  • indexer/packages/postgres/src/types/db-model-types.ts (1 hunks)
  • indexer/packages/postgres/src/types/liquidity-tiers-types.ts (1 hunks)
  • indexer/packages/postgres/src/types/websocket-message-types.ts (1 hunks)
  • indexer/services/comlink/tests/controllers/api/v4/perpetual-markets-controller.test.ts (1 hunks)
  • indexer/services/comlink/tests/lib/request-helpers/request-transformer.test.ts (1 hunks)
  • indexer/services/comlink/public/api-documentation.md (6 hunks)
  • indexer/services/comlink/src/request-helpers/request-transformer.ts (1 hunks)
  • indexer/services/comlink/src/types.ts (1 hunks)
  • indexer/services/ender/tests/handlers/liquidity-tier-handler.test.ts (2 hunks)
  • indexer/services/ender/tests/helpers/constants.ts (1 hunks)
  • indexer/services/ender/src/handlers/liquidity-tier-handler.ts (1 hunks)
  • indexer/services/ender/src/helpers/kafka-helper.ts (1 hunks)
  • indexer/services/ender/src/lib/block-processor.ts (1 hunks)
  • indexer/services/ender/src/scripts/handlers/dydx_liquidity_tier_handler.sql (2 hunks)
Files skipped from review due to trivial changes (2)
  • indexer/services/comlink/tests/controllers/api/v4/perpetual-markets-controller.test.ts
  • indexer/services/ender/src/lib/block-processor.ts
Additional Context Used
Path-based Instructions (15)
indexer/packages/postgres/src/db/migrations/migration_files/20240329154240_liquidity_tier_update.ts (1)

**/**:
Do not include a walkthrough. For all comments on line changes that are longer than 15 lines, add a prefix to the comment of what lines you are commenting on (for example: "The changes from lines 100 to 200...". Add your comment to be on the last 15 lines of the chunk rather than adding your comment to the entire chunk.

indexer/packages/postgres/src/types/liquidity-tiers-types.ts (1)

**/**:
Do not include a walkthrough. For all comments on line changes that are longer than 15 lines, add a prefix to the comment of what lines you are commenting on (for example: "The changes from lines 100 to 200...". Add your comment to be on the last 15 lines of the chunk rather than adding your comment to the entire chunk.

indexer/services/ender/src/handlers/liquidity-tier-handler.ts (1)

**/**:
Do not include a walkthrough. For all comments on line changes that are longer than 15 lines, add a prefix to the comment of what lines you are commenting on (for example: "The changes from lines 100 to 200...". Add your comment to be on the last 15 lines of the chunk rather than adding your comment to the entire chunk.

indexer/packages/postgres/src/models/liquidity-tiers-model.ts (1)

**/**:
Do not include a walkthrough. For all comments on line changes that are longer than 15 lines, add a prefix to the comment of what lines you are commenting on (for example: "The changes from lines 100 to 200...". Add your comment to be on the last 15 lines of the chunk rather than adding your comment to the entire chunk.

indexer/services/ender/src/scripts/handlers/dydx_liquidity_tier_handler.sql (1)

**/**:
Do not include a walkthrough. For all comments on line changes that are longer than 15 lines, add a prefix to the comment of what lines you are commenting on (for example: "The changes from lines 100 to 200...". Add your comment to be on the last 15 lines of the chunk rather than adding your comment to the entire chunk.

indexer/packages/postgres/src/types/websocket-message-types.ts (1)

**/**:
Do not include a walkthrough. For all comments on line changes that are longer than 15 lines, add a prefix to the comment of what lines you are commenting on (for example: "The changes from lines 100 to 200...". Add your comment to be on the last 15 lines of the chunk rather than adding your comment to the entire chunk.

indexer/packages/postgres/src/types/db-model-types.ts (1)

**/**:
Do not include a walkthrough. For all comments on line changes that are longer than 15 lines, add a prefix to the comment of what lines you are commenting on (for example: "The changes from lines 100 to 200...". Add your comment to be on the last 15 lines of the chunk rather than adding your comment to the entire chunk.

indexer/services/ender/__tests__/handlers/liquidity-tier-handler.test.ts (1)

**/**:
Do not include a walkthrough. For all comments on line changes that are longer than 15 lines, add a prefix to the comment of what lines you are commenting on (for example: "The changes from lines 100 to 200...". Add your comment to be on the last 15 lines of the chunk rather than adding your comment to the entire chunk.

indexer/services/ender/src/helpers/kafka-helper.ts (1)

**/**:
Do not include a walkthrough. For all comments on line changes that are longer than 15 lines, add a prefix to the comment of what lines you are commenting on (for example: "The changes from lines 100 to 200...". Add your comment to be on the last 15 lines of the chunk rather than adding your comment to the entire chunk.

indexer/services/comlink/__tests__/lib/request-helpers/request-transformer.test.ts (1)

**/**:
Do not include a walkthrough. For all comments on line changes that are longer than 15 lines, add a prefix to the comment of what lines you are commenting on (for example: "The changes from lines 100 to 200...". Add your comment to be on the last 15 lines of the chunk rather than adding your comment to the entire chunk.

indexer/services/ender/__tests__/helpers/constants.ts (1)

**/**:
Do not include a walkthrough. For all comments on line changes that are longer than 15 lines, add a prefix to the comment of what lines you are commenting on (for example: "The changes from lines 100 to 200...". Add your comment to be on the last 15 lines of the chunk rather than adding your comment to the entire chunk.

indexer/services/comlink/src/types.ts (1)

**/**:
Do not include a walkthrough. For all comments on line changes that are longer than 15 lines, add a prefix to the comment of what lines you are commenting on (for example: "The changes from lines 100 to 200...". Add your comment to be on the last 15 lines of the chunk rather than adding your comment to the entire chunk.

indexer/services/comlink/src/request-helpers/request-transformer.ts (1)

**/**:
Do not include a walkthrough. For all comments on line changes that are longer than 15 lines, add a prefix to the comment of what lines you are commenting on (for example: "The changes from lines 100 to 200...". Add your comment to be on the last 15 lines of the chunk rather than adding your comment to the entire chunk.

indexer/packages/postgres/__tests__/helpers/constants.ts (1)

**/**:
Do not include a walkthrough. For all comments on line changes that are longer than 15 lines, add a prefix to the comment of what lines you are commenting on (for example: "The changes from lines 100 to 200...". Add your comment to be on the last 15 lines of the chunk rather than adding your comment to the entire chunk.

indexer/services/comlink/public/api-documentation.md (1)

**/**:
Do not include a walkthrough. For all comments on line changes that are longer than 15 lines, add a prefix to the comment of what lines you are commenting on (for example: "The changes from lines 100 to 200...". Add your comment to be on the last 15 lines of the chunk rather than adding your comment to the entire chunk.

Learnings (1)
indexer/services/ender/__tests__/handlers/liquidity-tier-handler.test.ts (1)
The `stats` import was not entirely removed; only the `STATS_FUNCTION_NAME` was removed from the import. This led to an incorrect comment about the `stats` object usage.
Additional comments not posted (22)
indexer/packages/postgres/src/db/migrations/migration_files/20240329154240_liquidity_tier_update.ts (1)

3-17: The migration script correctly adds openInterestLowerCap and openInterestUpperCap columns to the liquidity_tiers table and provides a way to revert these changes. It follows best practices for database migrations, ensuring that the new columns are nullable and have a default value of null.

indexer/packages/postgres/src/types/liquidity-tiers-types.ts (3)

8-9: The addition of openInterestLowerCap and openInterestUpperCap as optional fields in the LiquidityTiersCreateObject interface is correctly implemented, following the established patterns for optional fields.


17-18: The addition of openInterestLowerCap and openInterestUpperCap as optional fields in the LiquidityTiersUpdateObject interface is correctly implemented, following the established patterns for optional fields.


26-27: The update to the LiquidityTiersColumns enum to include openInterestLowerCap and openInterestUpperCap is consistent with the naming and structure of existing entries.

indexer/services/ender/src/handlers/liquidity-tier-handler.ts (1)

26-27: The adjustment in casting resultRow.liquidity_tier to LiquidityTiersFromDatabase using LiquidityTiersModel.fromJson enhances clarity and ensures type safety by correctly parsing and validating the data.

indexer/packages/postgres/src/models/liquidity-tiers-model.ts (3)

30-32: The addition of openInterestLowerCap and openInterestUpperCap to the JSON schema with nullable string types and NumericPattern validation is correctly implemented, ensuring appropriate data validation and consistency with other numeric fields.


49-50: The updates to the sqlToJsonConversions for openInterestLowerCap and openInterestUpperCap ensure correct data conversion from SQL to JSON, aligning with best practices for database models.


64-66: The inclusion of openInterestLowerCap and openInterestUpperCap as optional class properties is correctly implemented, following the established patterns for optional fields in models.

indexer/services/ender/src/scripts/handlers/dydx_liquidity_tier_handler.sql (2)

18-19: The use of dydx_from_jsonlib_long to extract openInterestLowerCap and openInterestUpperCap from the event data is appropriate, assuming this function correctly handles the conversion from JSON to the expected data type.


28-30: The update to the INSERT INTO statement to include openInterestLowerCap and openInterestUpperCap ensures that these new fields are correctly updated in the database.

indexer/packages/postgres/src/types/websocket-message-types.ts (1)

215-216: The addition of openInterestLowerCap and openInterestUpperCap as optional fields in the TradingPerpetualMarketMessage interface is correctly implemented, enhancing the system's functionality and information accuracy regarding Open Interest caps.

indexer/packages/postgres/src/types/db-model-types.ts (1)

183-184: The addition of openInterestLowerCap and openInterestUpperCap as optional fields in the LiquidityTiersFromDatabase interface is correctly implemented, accurately representing the Open Interest caps information at the database model level.

indexer/services/ender/__tests__/handlers/liquidity-tier-handler.test.ts (2)

172-177: The updates to the expectLiquidityTier function to directly compare openInterestLowerCap and openInterestUpperCap by converting these fields to numbers for comparison are correctly implemented, ensuring accurate verification of the data handling.


233-238: The updates to the validateLiquidityTierRefresher function to directly compare openInterestLowerCap and openInterestUpperCap by converting these fields to numbers for comparison are correctly implemented, ensuring accurate verification of the data handling.

indexer/services/ender/src/helpers/kafka-helper.ts (1)

329-330: The addition of openInterestLowerCap and openInterestUpperCap fields to the generatePerpetualMarketMessage function aligns with the PR's objectives. Ensure that downstream components that consume this message can handle these new fields appropriately.

Verification successful

The review of the provided script outputs indicates that the downstream components are using the updated generatePerpetualMarketMessage function. While direct evidence of how openInterestLowerCap and openInterestUpperCap fields are specifically handled within these components is not provided, the usage of the function suggests that any messages generated will include these fields, assuming the function itself correctly incorporates them. Further verification of the specific handling within each component would require a more detailed inspection or additional test outputs.

Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Verify that downstream components handle the new fields correctly.
# This is a placeholder for a more specific verification script.
echo "Verify downstream components for handling of openInterestLowerCap and openInterestUpperCap fields."

Length of output: 206



Script:

#!/bin/bash
# Search for references to generatePerpetualMarketMessage to identify downstream components
rg "generatePerpetualMarketMessage"

Length of output: 1483



Script:

#!/bin/bash
# Display contents of handlers and test files to check for updates related to new fields
cat indexer/services/ender/__tests__/helpers/indexer-proto-helpers.ts
cat indexer/services/ender/src/handlers/liquidity-tier-handler.ts
cat indexer/services/ender/src/handlers/update-perpetual-handler.ts
cat indexer/services/ender/src/handlers/update-clob-pair-handler.ts
cat indexer/services/ender/src/handlers/perpetual-market-handler.ts

Length of output: 30076

indexer/services/comlink/__tests__/lib/request-helpers/request-transformer.test.ts (1)

80-81: The update to include openInterestLowerCap and openInterestUpperCap fields in the request-transformer test is appropriate and ensures that the new fields are correctly integrated into the system.

indexer/services/ender/__tests__/helpers/constants.ts (1)

152-152: The update to the openInterestUpperCap value in the defaultLiquidityTierUpsertEvent is noted. Ensure that this new value aligns with the system's requirements for open interest limits.

indexer/services/comlink/src/types.ts (1)

270-271: The addition of openInterestLowerCap and openInterestUpperCap fields to the PerpetualMarketResponseObject interface is appropriate and aligns with the PR's objectives to integrate Open Interest caps information. Ensuring these fields are optional maintains backward compatibility.

indexer/services/comlink/src/request-helpers/request-transformer.ts (1)

357-358: The addition of openInterestLowerCap and openInterestUpperCap to the perpetualMarketToResponseObject function aligns well with the PR's objectives to integrate Open Interest caps information. This ensures the API responses will now include these new fields, enhancing the system's functionality and information accuracy regarding Open Interest caps.

indexer/packages/postgres/__tests__/helpers/constants.ts (1)

665-666: The addition of openInterestLowerCap and openInterestUpperCap to the defaultLiquidityTier2 object in the test constants file is a logical step towards integrating Open Interest caps information into the system. The provided initial values seem appropriate for testing purposes, assuming they align with expected system ranges.

indexer/services/comlink/public/api-documentation.md (2)

1724-1725: The addition of openInterestLowerCap and openInterestUpperCap fields to the PerpetualMarketResponse object is consistent with the PR objectives to enhance the system's functionality by incorporating Open Interest (OI) caps information. This change ensures that the API documentation accurately reflects the new fields in the system, allowing API consumers to understand and utilize the new OI caps information effectively.


1745-1746: The addition of openInterestLowerCap and openInterestUpperCap fields to another instance of the PerpetualMarketResponse object further ensures consistency across the documentation. It's important that all instances of this object in the documentation are updated to reflect these new fields, providing a comprehensive and accurate representation of the API's capabilities.

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 Status

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between 70bccb8 and 16cb198.
Files ignored due to path filters (1)
  • indexer/services/comlink/public/swagger.json is excluded by !**/*.json
Files selected for processing (7)
  • indexer/packages/postgres/tests/helpers/constants.ts (1 hunks)
  • indexer/packages/postgres/src/types/db-model-types.ts (1 hunks)
  • indexer/packages/postgres/src/types/websocket-message-types.ts (1 hunks)
  • indexer/services/comlink/tests/lib/request-helpers/request-transformer.test.ts (1 hunks)
  • indexer/services/comlink/public/api-documentation.md (6 hunks)
  • indexer/services/comlink/src/request-helpers/request-transformer.ts (1 hunks)
  • indexer/services/comlink/src/types.ts (1 hunks)
Files skipped from review as they are similar to previous changes (6)
  • indexer/packages/postgres/tests/helpers/constants.ts
  • indexer/packages/postgres/src/types/db-model-types.ts
  • indexer/packages/postgres/src/types/websocket-message-types.ts
  • indexer/services/comlink/tests/lib/request-helpers/request-transformer.test.ts
  • indexer/services/comlink/src/request-helpers/request-transformer.ts
  • indexer/services/comlink/src/types.ts
Additional Context Used
Path-based Instructions (1)
indexer/services/comlink/public/api-documentation.md (1)

**/**:
Do not include a walkthrough. For all comments on line changes that are longer than 15 lines, add a prefix to the comment of what lines you are commenting on (for example: "The changes from lines 100 to 200...". Add your comment to be on the last 15 lines of the chunk rather than adding your comment to the entire chunk.

Additional comments not posted (1)
indexer/services/comlink/public/api-documentation.md (1)

1733-1735: The addition of openInterestLowerCap and openInterestUpperCap fields to the PerpetualMarketResponse object is consistent with the PR's objective to incorporate Open Interest caps information across the system. This change enhances the API's ability to provide detailed market data, including the newly introduced Open Interest limits.

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 Status

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between 16cb198 and 04fd566.
Files selected for processing (2)
  • indexer/services/ender/tests/handlers/liquidity-tier-handler.test.ts (3 hunks)
  • indexer/services/ender/src/scripts/handlers/dydx_liquidity_tier_handler.sql (2 hunks)
Files skipped from review as they are similar to previous changes (2)
  • indexer/services/ender/tests/handlers/liquidity-tier-handler.test.ts
  • indexer/services/ender/src/scripts/handlers/dydx_liquidity_tier_handler.sql

@affanv14 affanv14 requested a review from Christopher-Li April 4, 2024 16:51
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 Status

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between 04fd566 and 8532b18.
Files selected for processing (5)
  • indexer/packages/postgres/src/db/migrations/migration_files/20240329154240_liquidity_tier_update.ts (1 hunks)
  • indexer/packages/postgres/src/models/liquidity-tiers-model.ts (4 hunks)
  • indexer/services/ender/tests/handlers/liquidity-tier-handler.test.ts (3 hunks)
  • indexer/services/ender/src/handlers/liquidity-tier-handler.ts (1 hunks)
  • indexer/services/ender/src/scripts/handlers/dydx_liquidity_tier_handler.sql (2 hunks)
Files skipped from review as they are similar to previous changes (5)
  • indexer/packages/postgres/src/db/migrations/migration_files/20240329154240_liquidity_tier_update.ts
  • indexer/packages/postgres/src/models/liquidity-tiers-model.ts
  • indexer/services/ender/tests/handlers/liquidity-tier-handler.test.ts
  • indexer/services/ender/src/handlers/liquidity-tier-handler.ts
  • indexer/services/ender/src/scripts/handlers/dydx_liquidity_tier_handler.sql

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: 1

Review Status

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between 8532b18 and 49156c1.
Files ignored due to path filters (1)
  • protocol/indexer/events/events.pb.go is excluded by !**/*.pb.go, !**/*.pb.go
Files selected for processing (13)
  • indexer/packages/v4-protos/src/codegen/dydxprotocol/indexer/events/events.ts (8 hunks)
  • indexer/services/ender/tests/handlers/liquidity-tier-handler.test.ts (9 hunks)
  • indexer/services/ender/tests/helpers/constants.ts (2 hunks)
  • indexer/services/ender/tests/validators/liquidity-tier-validator.test.ts (6 hunks)
  • indexer/services/ender/src/handlers/liquidity-tier-handler.ts (2 hunks)
  • indexer/services/ender/src/lib/block-processor.ts (2 hunks)
  • indexer/services/ender/src/lib/helper.ts (2 hunks)
  • indexer/services/ender/src/lib/types.ts (2 hunks)
  • indexer/services/ender/src/validators/liquidity-tier-validator.ts (2 hunks)
  • proto/dydxprotocol/indexer/events/events.proto (2 hunks)
  • protocol/indexer/events/constants.go (1 hunks)
  • protocol/indexer/events/liquidity_tier.go (1 hunks)
  • protocol/indexer/events/liquidity_tier_test.go (1 hunks)
Files skipped from review as they are similar to previous changes (4)
  • indexer/services/ender/tests/handlers/liquidity-tier-handler.test.ts
  • indexer/services/ender/tests/helpers/constants.ts
  • indexer/services/ender/src/handlers/liquidity-tier-handler.ts
  • indexer/services/ender/src/lib/block-processor.ts
Additional Context Used
Path-based Instructions (9)
protocol/indexer/events/liquidity_tier_test.go (1)

Pattern **/**: Do not include a walkthrough. For all comments on line changes that are longer than 15 lines, add a prefix to the comment of what lines you are commenting on (for example: "The changes from lines 100 to 200...". Add your comment to be on the last 15 lines of the chunk rather than adding your comment to the entire chunk.

protocol/indexer/events/liquidity_tier.go (1)

Pattern **/**: Do not include a walkthrough. For all comments on line changes that are longer than 15 lines, add a prefix to the comment of what lines you are commenting on (for example: "The changes from lines 100 to 200...". Add your comment to be on the last 15 lines of the chunk rather than adding your comment to the entire chunk.

protocol/indexer/events/constants.go (1)

Pattern **/**: Do not include a walkthrough. For all comments on line changes that are longer than 15 lines, add a prefix to the comment of what lines you are commenting on (for example: "The changes from lines 100 to 200...". Add your comment to be on the last 15 lines of the chunk rather than adding your comment to the entire chunk.

indexer/services/ender/src/validators/liquidity-tier-validator.ts (1)

Pattern **/**: Do not include a walkthrough. For all comments on line changes that are longer than 15 lines, add a prefix to the comment of what lines you are commenting on (for example: "The changes from lines 100 to 200...". Add your comment to be on the last 15 lines of the chunk rather than adding your comment to the entire chunk.

indexer/services/ender/__tests__/validators/liquidity-tier-validator.test.ts (1)

Pattern **/**: Do not include a walkthrough. For all comments on line changes that are longer than 15 lines, add a prefix to the comment of what lines you are commenting on (for example: "The changes from lines 100 to 200...". Add your comment to be on the last 15 lines of the chunk rather than adding your comment to the entire chunk.

indexer/services/ender/src/lib/types.ts (1)

Pattern **/**: Do not include a walkthrough. For all comments on line changes that are longer than 15 lines, add a prefix to the comment of what lines you are commenting on (for example: "The changes from lines 100 to 200...". Add your comment to be on the last 15 lines of the chunk rather than adding your comment to the entire chunk.

indexer/services/ender/src/lib/helper.ts (1)

Pattern **/**: Do not include a walkthrough. For all comments on line changes that are longer than 15 lines, add a prefix to the comment of what lines you are commenting on (for example: "The changes from lines 100 to 200...". Add your comment to be on the last 15 lines of the chunk rather than adding your comment to the entire chunk.

proto/dydxprotocol/indexer/events/events.proto (1)

Pattern **/**: Do not include a walkthrough. For all comments on line changes that are longer than 15 lines, add a prefix to the comment of what lines you are commenting on (for example: "The changes from lines 100 to 200...". Add your comment to be on the last 15 lines of the chunk rather than adding your comment to the entire chunk.

indexer/packages/v4-protos/src/codegen/dydxprotocol/indexer/events/events.ts (1)

Pattern **/**: Do not include a walkthrough. For all comments on line changes that are longer than 15 lines, add a prefix to the comment of what lines you are commenting on (for example: "The changes from lines 100 to 200...". Add your comment to be on the last 15 lines of the chunk rather than adding your comment to the entire chunk.

Additional comments not posted (8)
protocol/indexer/events/liquidity_tier_test.go (1)

18-18: Ensure the test TestNewLiquidityTierUpsertEvent_Success adequately covers the new fields OpenInterestLowerCap and OpenInterestUpperCap introduced in LiquidityTierUpsertEventV2.

protocol/indexer/events/constants.go (1)

33-33: Confirm the update of LiquidityTierEventVersion to 2 aligns with the intended versioning strategy and that all references to this constant have been appropriately updated throughout the codebase.

indexer/services/ender/src/validators/liquidity-tier-validator.ts (1)

51-91: Ensure the LiquidityTierValidatorV2 class correctly validates the new fields openInterestLowerCap and openInterestUpperCap in LiquidityTierUpsertEventV2. Consider adding validation logic for these fields if necessary.

indexer/services/ender/__tests__/validators/liquidity-tier-validator.test.ts (1)

45-63: > 📝 NOTE

This review was outside the diff hunks and was mapped to the diff hunk with the greatest overlap. Original lines [17-102]

Ensure the test suite for LiquidityTierValidatorV2 includes tests for the new fields openInterestLowerCap and openInterestUpperCap in LiquidityTierUpsertEventV2. Adding tests for these fields will help ensure their validation logic is correctly implemented.

indexer/services/ender/src/lib/types.ts (1)

119-130: > 📝 NOTE

This review was outside the diff hunks and was mapped to the diff hunk with the greatest overlap. Original lines [31-127]

Confirm the addition of LiquidityTierUpsertEventV2 to EventProtoWithTypeAndVersion correctly integrates with the rest of the system and that all necessary handling for this new event version has been implemented.

indexer/services/ender/src/lib/helper.ts (1)

177-192: Verify the indexerTendermintEventToEventProtoWithType function correctly decodes and handles both LiquidityTierUpsertEventV1 and LiquidityTierUpsertEventV2 based on the version parameter. Ensure this logic aligns with the intended handling of different event versions throughout the system.

proto/dydxprotocol/indexer/events/events.proto (1)

462-489: Confirm the definition of LiquidityTierUpsertEventV2 in events.proto correctly includes all necessary fields and aligns with the intended functionality for handling Open Interest caps. Ensure the use of field options, such as marking open_interest_lower_cap as optional, aligns with the system's requirements.

indexer/packages/v4-protos/src/codegen/dydxprotocol/indexer/events/events.ts (1)

1196-1267: The introduction of LiquidityTierUpsertEventV2 with openInterestLowerCap and openInterestUpperCap fields aligns with the PR's objectives to add OI caps info. The deprecated basePositionNotional field is correctly marked.

protocol/indexer/events/liquidity_tier.go Show resolved Hide resolved
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 Status

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between 49156c1 and cfbffa2.
Files selected for processing (3)
  • indexer/services/ender/tests/handlers/liquidity-tier-handler.test.ts (9 hunks)
  • indexer/services/ender/src/handlers/liquidity-tier-handler.ts (2 hunks)
  • indexer/services/ender/src/lib/helper.ts (2 hunks)
Files skipped from review as they are similar to previous changes (3)
  • indexer/services/ender/tests/handlers/liquidity-tier-handler.test.ts
  • indexer/services/ender/src/handlers/liquidity-tier-handler.ts
  • indexer/services/ender/src/lib/helper.ts

@affanv14 affanv14 force-pushed the affan/liquidity-tier-update branch from 9dc26e0 to ce70536 Compare April 5, 2024 19:01
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 Status

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between cfbffa2 and ce70536.
Files ignored due to path filters (1)
  • protocol/indexer/events/events.pb.go is excluded by !**/*.pb.go, !**/*.pb.go
Files selected for processing (3)
  • indexer/packages/v4-protos/src/codegen/dydxprotocol/indexer/events/events.ts (8 hunks)
  • proto/dydxprotocol/indexer/events/events.proto (2 hunks)
  • protocol/indexer/events/liquidity_tier.go (1 hunks)
Files skipped from review as they are similar to previous changes (3)
  • indexer/packages/v4-protos/src/codegen/dydxprotocol/indexer/events/events.ts
  • proto/dydxprotocol/indexer/events/events.proto
  • protocol/indexer/events/liquidity_tier.go

@affanv14 affanv14 merged commit 3eb18f0 into main Apr 9, 2024
32 of 33 checks passed
@affanv14 affanv14 deleted the affan/liquidity-tier-update branch April 9, 2024 19:25
@affanv14 affanv14 changed the title update DB and APIs to add OI caps info [OTE-272] update DB and APIs to add OI caps info Apr 9, 2024
Copy link

linear bot commented Apr 9, 2024

@affanv14
Copy link
Contributor Author

affanv14 commented Apr 9, 2024

https://github.com/Mergifyio backport release/protocol/v5.x

@affanv14
Copy link
Contributor Author

affanv14 commented Apr 9, 2024

https://github.com/Mergifyio backport release/indexer/v5.x

Copy link
Contributor

mergify bot commented Apr 9, 2024

backport release/protocol/v5.x

✅ Backports have been created

Copy link
Contributor

mergify bot commented Apr 9, 2024

backport release/indexer/v5.x

✅ Backports have been created

mergify bot pushed a commit that referenced this pull request Apr 9, 2024
mergify bot pushed a commit that referenced this pull request Apr 9, 2024
affanv14 added a commit that referenced this pull request Apr 9, 2024
(cherry picked from commit 3eb18f0)

Co-authored-by: Mohammed Affan <[email protected]>
affanv14 added a commit that referenced this pull request Apr 9, 2024
(cherry picked from commit 3eb18f0)

Co-authored-by: Mohammed Affan <[email protected]>
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.

3 participants