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

Gamm code improvements #3657

Merged
merged 5 commits into from
Dec 9, 2022
Merged

Conversation

dalmirel
Copy link
Contributor

@dalmirel dalmirel commented Dec 8, 2022

What is the purpose of the change

This PR is created during the Informal Systems audit, after analysis of the existing specification and code inspection
Auditing is performed on commit hash: 42d73f1
This PR contains minor GAMM module code improvements noticed during code inspection with the aim of finding issues.

Brief Changelog

  • gamm/utils/conv.go is moved to osmoutils package and renamed to conv_helper.go - because helper functions were used not only from the GAMM module but from other modules as well
  • Some unsafe arithmetic operations were noticed -> sdk.Int values were cast to Int64 during error wrapping. This will not lead to aborting the tx because the possible issues are during returning of error (in already aborted tx), also string formatting was changed, due to sdk.Int numbers.
  • gamm/types/constants.go updated - two new constants added, holding the number of min and max possible denominations in pools
  • one issue on CLI fixed - possible index out of range in NewBuildCreateBalancerPoolMsg

Testing and Verifying

(Please pick one of the following options)

This change is a trivial rework/code cleanup without any test coverage.

Documentation and Release Note

  • Does this pull request introduces a new feature or user-facing behavior changes? no
  • Is a relevant changelog entry added to the Unreleased section in CHANGELOG.md? no
  • How is the feature or change documented? not applicable

@github-actions github-actions bot added C:CLI C:x/gamm Changes, features and bugs related to the gamm module. C:x/incentives C:x/lockup C:x/superfluid labels Dec 8, 2022
@dalmirel dalmirel added the V:state/compatible/backport State machine compatible PR, should be backported label Dec 8, 2022
@@ -360,7 +360,7 @@ func (k Keeper) JoinSwapShareAmountOut(
}

if tokenInAmount.GT(tokenInMaxAmount) {
return sdk.Int{}, sdkerrors.Wrapf(types.ErrLimitMaxAmount, "%d resulted tokens is larger than the max amount of %d", tokenInAmount.Int64(), tokenInMaxAmount.Int64())
return sdk.Int{}, sdkerrors.Wrapf(types.ErrLimitMaxAmount, "%s resulted tokens is larger than the max amount of %s", tokenInAmount, tokenInMaxAmount)
Copy link
Member

Choose a reason for hiding this comment

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

TY for fixing this 🙏

Copy link
Member

@ValarDragon ValarDragon left a comment

Choose a reason for hiding this comment

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

TY for fixing all these issues!

@ValarDragon ValarDragon added the A:backport/v13.x backport patches to v13.x branch label Dec 8, 2022
@p0mvn p0mvn merged commit c659f20 into osmosis-labs:main Dec 9, 2022
mergify bot pushed a commit that referenced this pull request Dec 9, 2022
* Added target and init weights length check on CLI

* gamm utils conv helpers moved to osmoutils

* gamm CLI typo fix

* gamm num of pool assets defined constants

* sdk.Int to Int64 cast removed from err wrapping

(cherry picked from commit c659f20)
p0mvn pushed a commit that referenced this pull request Dec 9, 2022
* Added target and init weights length check on CLI

* gamm utils conv helpers moved to osmoutils

* gamm CLI typo fix

* gamm num of pool assets defined constants

* sdk.Int to Int64 cast removed from err wrapping

(cherry picked from commit c659f20)

Co-authored-by: Mirel Dalčeković <97894739+dalmirel@users.noreply.github.com>
@dalmirel dalmirel deleted the GAMM-code-improvements branch December 12, 2022 07:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A:backport/v13.x backport patches to v13.x branch C:CLI C:x/gamm Changes, features and bugs related to the gamm module. C:x/incentives C:x/lockup C:x/superfluid V:state/compatible/backport State machine compatible PR, should be backported
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants