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

Allow NAVs to have a greater volume than the marker's supply. #1883

Merged
merged 3 commits into from
Mar 19, 2024

Conversation

SpicyLemon
Copy link
Contributor

@SpicyLemon SpicyLemon commented Mar 19, 2024

Description

This PR makes it so that NAVs can be recorded with a volume that's greater than the marker's supply.

There are some markers that list the supply as zero (e.g. fixed_supply = false). That limitation was preventing any NAV info for being recorded for them.
There's also a legitimate case where the NAV is the sum of info over a period of time in which it's possible that the volume is being reported as greater than the supply.


Before we can merge this PR, please make sure that all the following items have been
checked off. If any of the checklist items are not applicable, please leave them but
write a little note why.

  • Targeted PR against correct branch (see CONTRIBUTING.md)
  • Linked to Github issue with discussion and accepted design OR link to spec that describes this work.
  • Wrote unit and integration tests
  • Updated relevant documentation (docs/) or specification (x/<module>/spec/)
  • Added relevant godoc comments.
  • Added a relevant changelog entry to the Unreleased section in CHANGELOG.md
  • Re-reviewed Files changed in the Github PR explorer
  • Review Codecov Report in the comment section below once CI passes

Summary by CodeRabbit

  • New Features
    • Introduced a new gas field for specifying gas amounts in CLI transactions.
    • Added an upgrade handler for tourmaline-rc3.
  • Bug Fixes
    • Removed a startup warning and switched to cometbft-db v0.7.0 for enhanced stability.
  • Refactor
    • Adjusted volume validation logic in the Keeper struct to allow NAV volume to exceed a marker's supply.
    • Optimized error handling and test cases in marker management.

@SpicyLemon SpicyLemon requested a review from a team as a code owner March 19, 2024 18:27
Copy link
Contributor

coderabbitai bot commented Mar 19, 2024

Walkthrough

The recent updates involve enhancing command-line interface testing by introducing a gas parameter for transaction tests and refining the asset valuation logic within the marker module. These changes aim to provide more flexibility in testing and streamline asset management by ensuring volume validations are accurate and error feedback is precise.

Changes

Files Summary
x/exchange/client/cli/cli_test.go, x/exchange/client/cli/tx_test.go Added gas field to txCmdTestCase for specifying gas amount in CLI tests; updated logic for handling gas in tests.
x/marker/keeper/keeper.go, x/marker/keeper/keeper_test.go Removed math package import; refined volume validation in asset valuation; updated error messages and test expectations accordingly.

🐇✨
In the code's vast meadow, under the silicon sky,
A rabbit hopped, with a twinkle in its eye.
"A dash of gas," it whispered, "for the tests to fly,
And a touch of logic, for values not awry."
With each leap and bound, bugs waved goodbye,
In the digital fields, where our codes lie. 🌼💻

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-tests 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 tests 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 tests.
    • @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.
  • 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.

@SpicyLemon SpicyLemon enabled auto-merge (squash) March 19, 2024 18:32
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: 13

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between 2d21a84 and add9b05.
Files selected for processing (4)
  • x/exchange/client/cli/cli_test.go (2 hunks)
  • x/exchange/client/cli/tx_test.go (1 hunks)
  • x/marker/keeper/keeper.go (2 hunks)
  • x/marker/keeper/keeper_test.go (4 hunks)
Additional comments: 4
x/marker/keeper/keeper.go (1)
  • 315-315: The change in the SetNetAssetValue function to allow NAVs to be recorded with volumes exceeding the marker's supply is aligned with the PR's objectives. However, it's crucial to ensure comprehensive testing around this logic change to prevent potential issues, such as the setting of invalid NAVs or unintended consequences on financial reporting and analysis.
x/exchange/client/cli/cli_test.go (2)
  • 536-537: The addition of the gas field to the txCmdTestCase struct is a good enhancement, allowing for more precise control over gas amounts in test cases.
  • 568-572: The handling of the gas field, including its default value and usage in constructing command arguments, is correctly implemented.
x/exchange/client/cli/tx_test.go (1)
  • 450-450: The addition of a gas field with a value of 300_000 to the test case in TestCmdTxMarketSettle is a good practice for specifying the gas amount for the transaction being tested. This ensures that the test accurately reflects the conditions under which the transaction will be executed in a live environment.

x/marker/keeper/keeper_test.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.

Review Status

Actionable comments generated: 0

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between add9b05 and 515e0da.
Files selected for processing (1)
  • CHANGELOG.md (1 hunks)
Additional comments: 1
CHANGELOG.md (1)
  • 52-52: The addition of allowing NAV volume to exceed a marker's supply is a significant change that enhances the system's flexibility in handling various financial reporting scenarios. This change aligns with the PR objectives and addresses the limitations previously faced with markers having zero supply or cumulative NAVs exceeding supply.

@SpicyLemon SpicyLemon merged commit 46c3431 into main Mar 19, 2024
35 checks passed
@SpicyLemon SpicyLemon deleted the dwedul/rem-nav-limit branch March 19, 2024 18:41
SpicyLemon added a commit that referenced this pull request Mar 19, 2024
* Remove the NAV restriction that volume is at most the supply.

* Fix an exchange unit test that started to fail because the NAV is now being recorded, which takes more gas.

* Add changelog entry.
SpicyLemon added a commit that referenced this pull request Mar 19, 2024
…#1884)

* Remove the NAV restriction that volume is at most the supply.

* Fix an exchange unit test that started to fail because the NAV is now being recorded, which takes more gas.

* Add changelog entry.
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.

4 participants