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

Use big floats #665

Merged
merged 1 commit into from
Aug 6, 2024
Merged

Use big floats #665

merged 1 commit into from
Aug 6, 2024

Conversation

lazynina
Copy link
Member

@lazynina lazynina commented Aug 6, 2024

No description provided.

@lazynina lazynina requested a review from a team as a code owner August 6, 2024 02:06
Copy link
Member Author

lazynina commented Aug 6, 2024

This stack of pull requests is managed by Graphite. Learn more about stacking.

Join @lazynina and the rest of your teammates on Graphite Graphite

Copy link
Member

@diamondhands0 diamondhands0 left a comment

Choose a reason for hiding this comment

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

I think this is good once the potential bugs are addressed.

if big.NewFloat(0.0).Add(
baseCurrencyFilled,
big.NewFloat(bid.AmountInBaseCurrency),
).Cmp(baseCurrencyToFill) > 1 {
Copy link
Member

Choose a reason for hiding this comment

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

Shouldn't this be >0 rather than >1? I can't remember but I think it returns -1 = "less than" and 1 = "greater than" so you want to Cmp to zero.

big.NewFloat(bid.AmountInBaseCurrency),
).Cmp(baseCurrencyToFill) > 1 {
baseCurrencyFromThisOrder := big.NewFloat(0).Sub(baseCurrencyToFill, baseCurrencyFilled)
quoteCurrencyReceived = big.NewFloat(0).Mul(baseCurrencyFromThisOrder, big.NewFloat(bid.PriceInQuoteCurrency))
Copy link
Member

Choose a reason for hiding this comment

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

I think this needs to be += for this case to work properly.

@lazynina lazynina force-pushed the ln/get-base-currency-price-big-float branch 2 times, most recently from f3ea4b7 to 0dcb067 Compare August 6, 2024 03:39
Copy link
Member Author

lazynina commented Aug 6, 2024

Merge activity

  • Aug 5, 11:47 PM EDT: @lazynina started a stack merge that includes this pull request via Graphite.
  • Aug 5, 11:50 PM EDT: Graphite rebased this pull request as part of a merge.
  • Aug 5, 11:51 PM EDT: @lazynina merged this pull request with Graphite.

Base automatically changed from ln/get-base-currency-price to main August 6, 2024 03:49
@lazynina lazynina force-pushed the ln/get-base-currency-price-big-float branch from 0dcb067 to 095f77f Compare August 6, 2024 03:49
@lazynina lazynina merged commit e6591a6 into main Aug 6, 2024
2 of 3 checks passed
@lazynina lazynina deleted the ln/get-base-currency-price-big-float branch August 6, 2024 03:51
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.

2 participants