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

Improve numeric precision in reclaim escrow #281

Merged
merged 2 commits into from
Aug 5, 2022
Merged

Conversation

lukaw3d
Copy link
Member

@lukaw3d lukaw3d commented Aug 5, 2022

This doesn't change reclaiming with ALL button, but still related to #165 and #153

@lukaw3d lukaw3d requested a review from buberdds August 5, 2022 00:18
@lukaw3d lukaw3d marked this pull request as ready for review August 5, 2022 00:18
@@ -906,9 +906,9 @@ class SendPage extends React.Component {
if(!isNumber(inputAmount) || !new BigNumber(inputAmount).gt(0)){
return 0
}
const {amount ,shares} = this.props.nodeDetail
const {amount, shares} = this.props.nodeDetail
let sharePerAmount = new BigNumber(shares).dividedBy(amount).toString()
Copy link
Contributor

Choose a reason for hiding this comment

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

what precision does this division use?

Copy link
Member Author

Choose a reason for hiding this comment

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

It defaults to 20 decimal places https://mikemcl.github.io/bignumber.js/#decimal-places

Good that you brought it up, BigNumber(inputAmount).multipliedBy(shares).dividedBy(amount) would be better

let sharePerAmount = new BigNumber(shares).dividedBy(amount).toString()
let realShare = new BigNumber(inputAmount).multipliedBy(sharePerAmount).toFixed(4,1).toString()
let realShare = new BigNumber(inputAmount).multipliedBy(sharePerAmount).toFixed(cointypes.decimals, BigNumber.ROUND_DOWN)
Copy link
Contributor

Choose a reason for hiding this comment

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

here's one place we might not have to use ROUND_DOWN

Copy link
Member Author

Choose a reason for hiding this comment

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

+1

@lukaw3d lukaw3d merged commit f3b9e30 into master Aug 5, 2022
@lukaw3d lukaw3d deleted the lw/reclaim-precision branch August 5, 2022 19:07
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 this pull request may close these issues.

None yet

4 participants