-
Notifications
You must be signed in to change notification settings - Fork 161
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: added fee to price and balances query #2365
Conversation
Warning Rate Limit Exceeded@kosegor has exceeded the limit for the number of files or commits that can be reviewed per hour. Please wait 9 minutes and 59 seconds before requesting another review. How to resolve this issue?After the wait time has elapsed, a review can be triggered using the @coderabbitai review command. Alternatively, push new commits to this PR. We recommend that you space out your commits to avoid hitting the rate limit. How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. WalkthroughThe updates across various files in the codebase revolve around the introduction and handling of new financial parameters—specifically, swap and redeem fees. These changes affect the calculation of fees, the logic of transactions, and test configurations. Fields have been added and renumbered in the protobuf definition, functions updated to return new fee-related values, and experimental build constraints removed, suggesting a shift towards stabilization of features. Changes
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? TipsChat with CodeRabbit Bot (
|
There was a problem hiding this 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
Files ignored due to filter (2)
- swagger/swagger.yaml
- x/metoken/metoken.pb.go
Files selected for processing (11)
- proto/umee/metoken/v1/metoken.proto (1 hunks)
- util/coin/coin.go (1 hunks)
- x/metoken/client/tests/cli_test.go (1 hunks)
- x/metoken/client/tests/suite.go (1 hunks)
- x/metoken/client/tests/tests.go (2 hunks)
- x/metoken/keeper/fee.go (2 hunks)
- x/metoken/keeper/fee_test.go (4 hunks)
- x/metoken/keeper/grpc_query.go (2 hunks)
- x/metoken/keeper/price.go (3 hunks)
- x/metoken/keeper/redeem.go (4 hunks)
- x/metoken/keeper/swap.go (2 hunks)
Files skipped from review due to trivial changes (2)
- x/metoken/client/tests/cli_test.go
- x/metoken/client/tests/suite.go
Additional comments: 13
util/coin/coin.go (1)
- 58-61: The addition of the
One
function is correct and follows best practices for creating a new coin instance with an amount of one.x/metoken/keeper/fee_test.go (1)
- 34-55: > Note: This review was outside the patches, so it was mapped to the patch with the greatest overlap. Original lines [25-52]
The changes to the
swapFee
andredeemFee
functions, including the return of both a fraction and an amount for the fee, are correct. The tests have been updated to reflect these changes.x/metoken/keeper/fee.go (1)
- 10-37: The changes to the
swapFee
andredeemFee
functions, including the updated return types and fee calculation logic, are correct.x/metoken/client/tests/tests.go (1)
- 106-108: The removal of the experimental build tag and the addition of
SwapFee
andRedeemFee
to the data structure within theTestValidQueries
function are correct and reflect the new fee logic in test scenarios.x/metoken/keeper/grpc_query.go (1)
- 75-80: The changes to the
SwapFee
andRedeemFee
functions, including the addition of thefeeAmount
variable in the return values, are correct.x/metoken/keeper/price.go (1)
- 90-107: The addition of the
coin
package import and the new calculations forswapFee
andredeemFee
within thePrices
method are correct and follow best practices.proto/umee/metoken/v1/metoken.proto (1)
- 151-169: The addition of the
swap_fee
field and the renumbering ofredeem_rate
andredeem_fee
in theAssetPrice
message are correct and follow protocol buffer best practices.x/metoken/keeper/swap.go (1)
- 203-214: > Note: This review was outside the patches, so it was mapped to the patch with the greatest overlap. Original lines [206-221]
The changes in the
calculateSwap
function, including the replacement of thefee
variable withfeeAmount
and the adjusted access patterns, are correct.x/metoken/keeper/redeem.go (5)
93-99: The function now correctly returns an additional
sdk.Coin
value for the fee amount. However, ensure that all callers of this function are updated to handle the new return value.96-99: The introduction of
feeAmount
calculation and its error handling is consistent with the existing code structure.114-114: The calculation of
toRedeem
correctly accounts for the fee by subtractingfeeAmount.Amount
from the total redeemable amount.130-130: The update to the
balance.Fees
field correctly adds thefeeAmount.Amount
, ensuring that fee balances are updated as expected.143-147: The
newRedeemResponse
function is correctly called with the newfeeAmount
parameter, reflecting the changes made to the redemption logic.
There was a problem hiding this 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
Files selected for processing (3)
- x/metoken/keeper/intest/grpc_query_test.go (1 hunks)
- x/metoken/keeper/price.go (2 hunks)
- x/metoken/mocks/metoken.go (1 hunks)
Files skipped from review as they are similar to previous changes (1)
- x/metoken/keeper/price.go
Additional comments: 2
x/metoken/mocks/metoken.go (1)
- 127-129: The change from
USDTBaseDenom
toCMSTBaseDenom
inEmptyNonStableIndexBalances
should be verified to ensure it aligns with the new fee structures introduced in the PR. IfCMSTBaseDenom
is part of the non-stable assets that now include fees, this change is justified.x/metoken/keeper/intest/grpc_query_test.go (1)
- 371-373: The added assertions for
SwapFee
andRedeemFee
being greater than zero are appropriate and align with the PR's objective to introduce fee components. This ensures that the fees are properly implemented and non-zero in the test scenarios.
Codecov ReportAttention:
Additional details and impacted files@@ Coverage Diff @@
## main #2365 +/- ##
==========================================
- Coverage 75.38% 70.05% -5.34%
==========================================
Files 100 174 +74
Lines 8025 12987 +4962
==========================================
+ Hits 6050 9098 +3048
- Misses 1589 3282 +1693
- Partials 386 607 +221
|
There was a problem hiding this 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
Files ignored due to filter (2)
- swagger/swagger.yaml
- x/metoken/metoken.pb.go
Files selected for processing (1)
- proto/umee/metoken/v1/metoken.proto (1 hunks)
Files skipped from review as they are similar to previous changes (1)
- proto/umee/metoken/v1/metoken.proto
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Please don't forget to add Changelog entries
There was a problem hiding this 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
Files selected for processing (3)
- CHANGELOG.md (1 hunks)
- x/metoken/keeper/fee.go (2 hunks)
- x/metoken/keeper/price.go (2 hunks)
Additional comments: 3
x/metoken/keeper/price.go (2)
10-13: The addition of the
coin
package import is appropriate for the new functionality that requires creating a new coin instance with an amount of one. This is used in the calculation of swap and redeem fees.87-104: The modifications to the
Prices
method to calculate and assign swap and redeem fees are correctly implemented. The fees are calculated using theswapFee
andredeemFee
methods and assigned to the respective fields in theindexPrices.Assets
structure. This aligns with the PR's objective to include fee calculations in price and balance queries.CHANGELOG.md (1)
- 55-55: The entry for PR feat: added fee to price and balances query #2365 is correctly added under the Bug Fixes section for the v6.2.0 release, with an accurate PR number and description.
There was a problem hiding this 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
Files selected for processing (1)
- CHANGELOG.md (1 hunks)
Files skipped from review as they are similar to previous changes (1)
- CHANGELOG.md
Summary by CodeRabbit
New Features
swap_fee
field to financial transactions, affecting asset exchange and user fees.Bug Fixes
Refactor
redeem
function to include fee handling during transactions.Tests
Documentation