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

Fixed marketBaseIncrement for zero ndigits #194

Merged
merged 2 commits into from
May 16, 2021
Merged

Conversation

Sekuiya
Copy link
Contributor

@Sekuiya Sekuiya commented May 15, 2021

Description

The function marketBaseIncrement for base increments of 1, like in XLM case, were rounding up, making that a bigger value than the funds available was returned.

This should fix the "Insufficient funds" errors and the "size is too accurate" errors, the later one indirectly since the bought value would no longer different than the base increment.

Solution based on a comment by @horamarques in issue #185.

Fixes #185 and #187

Type of change

Please make your selection.

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update
  • This change requires a new dependency
  • Code Maintainability / comments
  • Code Refactoring / future-proofing

How Has This Been Tested?

Run the function with different amounts and base increments.

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added pytest unit tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published in downstream modules
  • I have checked my code and corrected any misspellings

Copy link
Collaborator

@iThom iThom left a comment

Choose a reason for hiding this comment

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

Thanks for your PR, there was effectively a bug, I reproduce it with amount 20.383 and nb_digits = 1, it give 20.4 instead of 20.3.

Please move the from math import floor to the top and the PR is OK for me.
It would be good that we add a unit test to this.

@iThom iThom added the bug Something isn't working label May 15, 2021
@Sekuiya Sekuiya requested a review from iThom May 15, 2021 21:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

balance before order - round up issue
3 participants