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

Price incorrectly calculated when selecting large amount in TO swap: should display "not enough liquidity" #150

Open
trendzetter opened this issue Jun 30, 2021 · 2 comments · May be fixed by #152

Comments

@trendzetter
Copy link

trendzetter commented Jun 30, 2021

Scenario:

  1. select swap
  2. select ABC for FROM
  3. select KDA for TO
  4. enter TO amount 992999
  5. The system calculates the wrong FROM amount: -8309886366.268124

This issue does not occur when using a large amount in the FROM

@trendzetter
Copy link
Author

I narrowed down the cause to frontend/src/contexts/PactContext.js:1835 where a negative amount is calculated for the denominator. I think this should not happen. See image:
screen-negative-denominator

@trendzetter
Copy link
Author

trendzetter commented Jun 30, 2021

this happens because I am trying to swap more than available reserve turning the values in the calculations negative giving strange values in the gui.
This requires more than a 1 line fix. "No enough liquidity" should be displayed.

@trendzetter trendzetter changed the title Price incorrectly calculated when selecting large amount in TO swap Price incorrectly calculated when selecting large amount in TO swap: should display "not enough liquidity" Jun 30, 2021
trendzetter added a commit to trendzetter/kadenaswap that referenced this issue Jul 1, 2021
Show a warning instead of negative numbers when not enough liquidity to fulfill the requested amount in the to field.
Fixes kadena-io#150
@trendzetter trendzetter linked a pull request Jul 1, 2021 that will close this issue
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 a pull request may close this issue.

1 participant