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: query RegisteredTokenMarkets #2369

Merged
merged 9 commits into from
Jan 2, 2024
Merged

feat: query RegisteredTokenMarkets #2369

merged 9 commits into from
Jan 2, 2024

Conversation

toteki
Copy link
Member

@toteki toteki commented Dec 27, 2023

Summary by CodeRabbit

  • New Features

    • Introduced a new service to query registered tokens and their market summaries.
    • Users can now view token market information within the app.
  • Documentation

    • Added new message types for better querying and response structure in token market services.
  • Tests

    • Implemented tests for the new token market querying functionality.

@toteki toteki requested a review from a team as a code owner December 27, 2023 14:47
Copy link
Contributor

coderabbitai bot commented Dec 27, 2023

Walkthrough

The update introduces a new feature in the Umee leverage module, allowing users to query a list of registered tokens and their market summaries. This is achieved through a new gRPC service, along with associated message types for the request and response. The backend logic to handle these queries has been implemented, and tests have been added to ensure the functionality works as expected.

Changes

File Path Change Summary
proto/umee/leverage/v1/query.proto Introduces RegisteredTokenMarkets gRPC service, new message types, and support for querying registered tokens and their market summaries.
x/leverage/keeper/grpc_query.go Adds RegisteredTokenMarkets method to the Querier struct for fetching registered tokens and their associated markets.
x/leverage/keeper/grpc_query_test.go Includes TestQuerier_TokenMarkets in the IntegrationTestSuite to verify querying of token markets.

🐇💻✨
A leap in the code, a hop in the net,
Tokens queried, a new RPC set.
In the ledger's burrow, data aligns just right,
A rabbit's joy on a blockchain night. 🌙
🎉📈🐰

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 with CodeRabbit Bot (@coderabbitai)

  • You can directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit-tests for this file.
  • You can tag CodeRabbit on specific lines of code or entire files in the PR by tagging @coderabbitai in a comment. Examples:
    • @coderabbitai generate unit tests for this file.
    • @coderabbitai modularize this function.
  • You can tag @coderabbitai in a PR comment and ask questions about the PR and the codebase. Examples:
    • @coderabbitai generate interesting stats about this repository from git and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit tests.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid.
    • @coderabbitai read the files in the src/scheduler package and generate 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.

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.
  • The JSON schema for the configuration file is available here.
  • 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/coderabbit-overrides.v2.json

CodeRabbit Discord Community

Join our Discord Community to get help, request features, and share feedback.

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.

Review Status

Actionable comments generated: 2

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between e3a9892 and 97b4b93.
Files ignored due to filter (2)
  • x/leverage/types/query.pb.go
  • x/leverage/types/query.pb.gw.go
Files selected for processing (3)
  • proto/umee/leverage/v1/query.proto (2 hunks)
  • x/leverage/keeper/grpc_query.go (1 hunks)
  • x/leverage/keeper/grpc_query_test.go (1 hunks)
Additional comments: 4
proto/umee/leverage/v1/query.proto (4)
  • 27-31: The addition of the RegisteredTokenMarkets RPC service with its corresponding HTTP GET route is correctly implemented and follows the existing pattern of service definitions in the file.

  • 121-123: The QueryRegisteredTokenMarkets message type is correctly defined for a request that requires no parameters.

  • 125-129: The QueryRegisteredTokenMarketsResponse message type is well-defined with a repeated field of TokenMarket to encapsulate the response data for the registered token markets.

  • 131-137: The TokenMarket message type is properly structured to include both the token details and its market summary, ensuring a comprehensive response for the RegisteredTokenMarkets RPC service.

x/leverage/keeper/grpc_query_test.go Outdated Show resolved Hide resolved
x/leverage/keeper/grpc_query.go Outdated 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.

Review Status

Actionable comments generated: 0

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between 97b4b93 and 372181f.
Files selected for processing (1)
  • CHANGELOG.md (1 hunks)
Additional comments: 3
CHANGELOG.md (3)
  • 49-51: The entry for PR 2369 correctly documents the addition of the RegisteredTokenMarkets query feature. This aligns with the PR objectives and AI-generated summary.

  • 57-57: Correction of the PR number from 2215 to 2315 for the MaxBorrow and MaxWithdraw reliability improvement is noted and approved.

  • 58-58: The entry for PR 2346 correctly documents the bug fix where metokens were not included in historic data.

Copy link

codecov bot commented Dec 27, 2023

Codecov Report

Attention: 117 lines in your changes are missing coverage. Please review.

Comparison is base (7f05ad4) 75.38% compared to head (dd64996) 69.56%.
Report is 327 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #2369      +/-   ##
==========================================
- Coverage   75.38%   69.56%   -5.83%     
==========================================
  Files         100      172      +72     
  Lines        8025    12780    +4755     
==========================================
+ Hits         6050     8890    +2840     
- Misses       1589     3282    +1693     
- Partials      386      608     +222     
Files Coverage Δ
ante/ante.go 66.66% <100.00%> (+18.45%) ⬆️
ante/fee.go 80.00% <100.00%> (+1.64%) ⬆️
ante/spam_prevention.go 75.92% <ø> (ø)
app/inflation/inflation.go 100.00% <100.00%> (ø)
app/upgradev3/migrations.go 84.21% <ø> (+5.94%) ⬆️
util/coin/utoken.go 100.00% <100.00%> (ø)
util/ibc/ibc.go 58.82% <ø> (ø)
util/sdkutil/events.go 0.00% <ø> (ø)
util/store/store.go 52.06% <ø> (+10.65%) ⬆️
util/store/unmarshal.go 42.85% <ø> (ø)
... and 40 more

... and 111 files with indirect coverage changes

Copy link
Collaborator

@gsk967 gsk967 left a comment

Choose a reason for hiding this comment

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

LGTM

@gsk967
Copy link
Collaborator

gsk967 commented Jan 1, 2024

@toteki @robert-zaremba WDYT may be we can add this query as optional integration (customizable query) to binary

@toteki
Copy link
Member Author

toteki commented Jan 2, 2024

Since this doesn't iterate over users, it doesn't need to be enabled by flag like the -l queries. Should be safe as-is

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.

Review Status

Actionable comments generated: 2

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between 372181f and b5a92cc.
Files ignored due to filter (2)
  • x/leverage/types/query.pb.go
  • x/uibc/uibc.pb.go
Files selected for processing (3)
  • proto/umee/leverage/v1/query.proto (2 hunks)
  • x/leverage/keeper/grpc_query.go (1 hunks)
  • x/leverage/keeper/grpc_query_test.go (1 hunks)
Additional comments: 4
proto/umee/leverage/v1/query.proto (4)
  • 27-31: The new gRPC service RegisteredTokenMarkets is well-defined with appropriate HTTP GET path annotations. Ensure that the corresponding server implementation handles this endpoint correctly and that the endpoint is documented in any user-facing materials.

  • 121-123: The message QueryRegisteredTokenMarkets is defined without any fields. If this is intentional (e.g., the query does not require any parameters), this is fine. Otherwise, consider if any parameters should be included to filter or customize the query results.

  • 125-128: The message QueryRegisteredTokenMarketsResponse correctly uses a repeated field of TokenMarket to represent multiple market summaries. Ensure that the implementation correctly populates this message with the expected data.

  • 131-137: The TokenMarket message is well-structured, combining a Token and its market summary. Verify that the Token and QueryMarketSummaryResponse messages provide all necessary information and that there are no missing fields that might be required for a complete market summary.

Verification successful

Based on the provided output from the shell scripts, we can see the fields defined in the Token and QueryMarketSummaryResponse messages:

For Token:

  • base_denom: The base denomination of the token.
  • reserve_factor: The portion of accrued interest that goes to reserves when the token is borrowed.

For QueryMarketSummaryResponse:

  • symbol_denom: The human-readable representation of a token denom.
  • exponent: The power of ten required to get from base denom to symbol denom.
  • oracle_price: The current USD value of a token, which can be nil if the oracle is down.
  • uToken Exchange Rate: The amount of base tokens received when withdrawing 1 uToken.

These fields appear to provide a comprehensive overview of a token's parameters and its market summary. However, without domain-specific knowledge of the Umee blockchain's requirements for a market summary, it's not possible to definitively say whether all necessary information is present. The fields listed seem to cover basic financial and identification aspects of a token and its market status.

Therefore, based on the information available, the TokenMarket message structure, which includes both Token and QueryMarketSummaryResponse, seems to be well-structured and likely provides the necessary information for a market summary as per the design of the Umee blockchain's leverage module.

Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Verify that the Token and QueryMarketSummaryResponse messages are complete and provide all necessary information.
ast-grep --lang proto --pattern $'message Token {
  $$$
}'
ast-grep --lang proto --pattern $'message QueryMarketSummaryResponse {
  $$$
}'

Length of output: 362



Script:

#!/bin/bash
# Search for the definitions of `Token` and `QueryMarketSummaryResponse` messages in .proto files.
rg 'message Token {'
rg 'message QueryMarketSummaryResponse {'

Length of output: 296



Script:

#!/bin/bash
# Search for the definitions of `Token` and `QueryMarketSummaryResponse` messages in .proto files, escaping curly braces.
rg 'message Token \{'
rg 'message QueryMarketSummaryResponse \{'

Length of output: 194



Script:

#!/bin/bash
# Display the contents of the `Token` and `QueryMarketSummaryResponse` message definitions.
cat proto/umee/leverage/v1/leverage.proto | grep -A 10 'message Token {'
cat proto/umee/leverage/v1/query.proto | grep -A 10 'message QueryMarketSummaryResponse {'

Length of output: 1478

x/leverage/keeper/grpc_query_test.go Outdated Show resolved Hide resolved
x/leverage/keeper/grpc_query.go Outdated Show resolved Hide resolved
Copy link
Member

@robert-zaremba robert-zaremba left a comment

Choose a reason for hiding this comment

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

utACK. Left one comment to discuss the API

proto/umee/leverage/v1/query.proto Outdated Show resolved Hide resolved
x/leverage/keeper/grpc_query.go Show resolved Hide resolved
Co-authored-by: Robert Zaremba <robert@zaremba.ch>
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.

Review Status

Actionable comments generated: 0

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between b5a92cc and c7ff42d.
Files selected for processing (1)
  • proto/umee/leverage/v1/query.proto (2 hunks)
Files skipped from review as they are similar to previous changes (1)
  • proto/umee/leverage/v1/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.

Review Status

Actionable comments generated: 0

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between c7ff42d and dd64996.
Files ignored due to filter (2)
  • x/leverage/types/query.pb.go
  • x/leverage/types/query.pb.gw.go
Files selected for processing (3)
  • proto/umee/leverage/v1/query.proto (2 hunks)
  • x/leverage/keeper/grpc_query.go (1 hunks)
  • x/leverage/keeper/grpc_query_test.go (1 hunks)
Files skipped from review as they are similar to previous changes (3)
  • proto/umee/leverage/v1/query.proto
  • x/leverage/keeper/grpc_query.go
  • x/leverage/keeper/grpc_query_test.go

@toteki toteki enabled auto-merge January 2, 2024 13:15
@toteki toteki added this pull request to the merge queue Jan 2, 2024
Merged via the queue into main with commit c7a3e5b Jan 2, 2024
25 of 28 checks passed
@toteki toteki deleted the adam/markets branch January 2, 2024 13:26
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.

3 participants