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

feat: global staking overview #10

Merged
merged 1 commit into from
May 10, 2024
Merged

Conversation

yevhen-burkovskyi
Copy link
Contributor

No description provided.

Copy link

coderabbitai bot commented May 10, 2024

Walkthrough

The recent updates focus on enhancing the staking functionality across multiple services by introducing new configuration variables, updating enums with additional endpoints, and integrating new methods for fetching and caching staking-related data. Key additions include the introduction of global staking overview variables, methods for retrieving validators, total supply, and APR, as well as updates to caching mechanisms to support these new features.

Changes

Files Change Summary
.env.example Added GLOBAL_STAKING_OVERVIEW variable.
src/core/config/... Updated CacheConfig and ConfigSchema with globalStakingOverview. Added it to config.ts.
src/core/lib/okp4/..., src/core/lib/osmosis/... Added new endpoints and methods in service classes for fetching validators, total supply, and APR.
src/modules/stacking/... Introduced new DTOs, updated caching mechanisms, added new methods in services and controllers for global staking overview. Added OsmosisService to module providers.
src/core/lib/okp4/responses/supply.response.ts Introduced SupplyResponse type and Supply interface.
src/core/lib/osmosis/enums/endpoints.enum.ts Added STAKING_APR endpoint.

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

@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 f18574a and 6394f4c.
Files selected for processing (15)
  • .env.example (1 hunks)
  • src/core/config/config.dto.ts (1 hunks)
  • src/core/config/config.schema.ts (1 hunks)
  • src/core/config/config.ts (1 hunks)
  • src/core/lib/okp4/enums/endpoints.enum.ts (1 hunks)
  • src/core/lib/okp4/okp4.service.ts (2 hunks)
  • src/core/lib/okp4/responses/supply.response.ts (1 hunks)
  • src/core/lib/osmosis/enums/endpoints.enum.ts (1 hunks)
  • src/core/lib/osmosis/osmosis.service.ts (1 hunks)
  • src/modules/stacking/dtos/global-staked-overview.dto.ts (1 hunks)
  • src/modules/stacking/enums/stacking-endpoints.enum.ts (1 hunks)
  • src/modules/stacking/services/stacking.cache.ts (2 hunks)
  • src/modules/stacking/services/stacking.service.ts (3 hunks)
  • src/modules/stacking/stacking.controller.ts (1 hunks)
  • src/modules/stacking/stacking.module.ts (1 hunks)
Files skipped from review due to trivial changes (4)
  • .env.example
  • src/core/lib/osmosis/enums/endpoints.enum.ts
  • src/modules/stacking/dtos/global-staked-overview.dto.ts
  • src/modules/stacking/enums/stacking-endpoints.enum.ts
Additional comments not posted (14)
src/core/lib/okp4/responses/supply.response.ts (1)

3-8: The new SupplyResponse type and Supply interface are well-defined and align with TypeScript best practices.

src/core/lib/okp4/enums/endpoints.enum.ts (1)

7-8: The addition of VALIDATORS and TOTAL_SUPPLY endpoints to the Endpoints enum is correctly implemented and follows the established URL pattern.

src/core/config/config.dto.ts (1)

32-32: The addition of the globalStakingOverview property to the CacheConfig interface is correctly implemented and appropriately typed.

src/core/config/config.schema.ts (1)

15-15: The addition of the GLOBAL_STAKING_OVERVIEW field to the ConfigSchema is correctly defined as a required number, following Joi validation best practices.

src/core/config/config.ts (1)

23-23: The addition of the globalStakingOverview property to the config object is correctly implemented, appropriately retrieving and converting the environment variable value.

src/modules/stacking/stacking.module.ts (1)

13-13: The addition of OsmosisService to the providers in the StackingModule is correctly implemented and aligns with the module's functionalities.

src/modules/stacking/stacking.controller.ts (1)

23-26: The addition of the getGlobalOverview method to the StackingController is correctly implemented, using appropriate NestJS decorators and service calls.

src/modules/stacking/services/stacking.cache.ts (1)

Line range hint 9-46: The additions of setGlobalStakedOverview, getGlobalStakedOverview, and the globalOverviewPrefix in the StackingCache service are correctly implemented, effectively utilizing caching mechanisms and JSON serialization.

src/core/lib/osmosis/osmosis.service.ts (1)

64-68: The implementation of getStakingApr method is consistent with existing patterns and correctly uses utility functions.

src/core/lib/okp4/okp4.service.ts (2)

75-81: The implementation of getValidators method is consistent with existing patterns and correctly uses utility functions and constants.


83-87: The implementation of getTotalSupply method is consistent with existing patterns and correctly uses utility functions.

src/modules/stacking/services/stacking.service.ts (3)

68-76: The implementation of getGlobalOverview method correctly handles caching and data fetching.


79-98: The implementation of fetchAndCacheGlobalStakedOverview method is robust, correctly handling asynchronous operations and data calculations.


100-103: The implementation of calculateTotalStaked method correctly uses the Big library for precise arithmetic operations.

@dbatarin dbatarin merged commit f219c0b into main May 10, 2024
6 checks passed
@dbatarin dbatarin deleted the feat/global-staked-overview branch May 10, 2024 11:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants