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

fix!: restrict MsgWithdraw to only accept uToken inputs #1023

Merged
merged 7 commits into from
Jun 21, 2022
Merged

Conversation

toteki
Copy link
Member

@toteki toteki commented Jun 15, 2022

Description

Removes the ability of MsgWithdraw to convert base token inputs to uTokens automatically.

This fixes a very minor problem, where the double conversion of input token -> uToken -> token would result in a final token amount which had been rounded down twice as opposed to once when users input a token amount, e.g. 1000uumee -> 999u/uumee -> 998uumee.

With this fix, user input is denominated in uTokens, so the rounding is minimized to the necessary amount.

Runtime verification had mentioned this in a "functional correctness" issue at one point.


Author Checklist

All items are required. Please add a note to the item if the item is not applicable and
please add links to any relevant follow up issues.

I have...

  • included the correct type prefix in the PR title
  • added appropriate labels to the PR
  • added ! to the type prefix if API or client breaking change
  • targeted the correct branch (see PR Targeting)
  • provided a link to the relevant issue or specification
  • added a changelog entry to CHANGELOG.md
  • included comments for documenting Go code
  • updated the relevant documentation or specification
  • reviewed "Files changed" and left comments if necessary
  • confirmed all CI checks have passed

Reviewers Checklist

All items are required. Please add a note if the item is not applicable and please add
your handle next to the items reviewed if you only reviewed selected items.

I have...

  • confirmed the correct type prefix in the PR title
  • confirmed ! in the type prefix if API or client breaking change
  • confirmed all author checklist items have been addressed
  • reviewed state machine logic
  • reviewed API design and naming
  • reviewed documentation is accurate
  • reviewed tests and test coverage
  • manually tested (if applicable)

@toteki toteki requested a review from a team as a code owner June 15, 2022 15:45
@toteki
Copy link
Member Author

toteki commented Jun 15, 2022

@AgentRoberto This will impact frontend, so share any thoughts

@toteki toteki changed the title !fix: restrict MsgWithdraw to only accept uToken inputs fix!: restrict MsgWithdraw to only accept uToken inputs Jun 15, 2022
@toteki toteki added this to the Calypso milestone Jun 15, 2022
@codecov-commenter
Copy link

codecov-commenter commented Jun 15, 2022

Codecov Report

Merging #1023 (5207426) into main (30bca26) will decrease coverage by 0.02%.
The diff coverage is 68.75%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #1023      +/-   ##
==========================================
- Coverage   43.86%   43.83%   -0.03%     
==========================================
  Files          64       64              
  Lines        8337     8322      -15     
==========================================
- Hits         3657     3648       -9     
+ Misses       4424     4419       -5     
+ Partials      256      255       -1     
Impacted Files Coverage Δ
x/leverage/keeper/keeper.go 45.33% <66.66%> (-0.55%) ⬇️
x/leverage/client/tests/tests.go 100.00% <100.00%> (ø)

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.

let's rename amount.

x/leverage/keeper/keeper.go Outdated Show resolved Hide resolved

if k.IsAcceptedToken(ctx, withdrawal.Denom) {
// Automatically convert base token input to equivalent uTokens
uToken, err = k.ExchangeToken(ctx, withdrawal)
Copy link
Member

Choose a reason for hiding this comment

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

seams like we had a potential bug here if we the function doesn't handle case where uToken == withdrawal.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants