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 panic caused by division by zero #39

Merged
merged 1 commit into from
Nov 22, 2022
Merged

Fix panic caused by division by zero #39

merged 1 commit into from
Nov 22, 2022

Conversation

MartinquaXD
Copy link
Contributor

Fixes panics caused by dividing by zero in the slippage calculation.

@fedgiac
Copy link

fedgiac commented Nov 22, 2022

If I understand the code correctly, it converts absolute slippage into relative slippage and returns the minimum between this computed relative slippage and the relative slippage from another part of the code. As the zero case means that relative slippage from absolute slippage is infinity, maybe it would be better to just return the relative slippage at this point?

@nlordell
Copy link
Contributor

Is this a fix for #37?

@nlordell
Copy link
Contributor

nlordell commented Nov 22, 2022

Why is it trying to compute the slippage for a 0 amount though 🤔.

Anyway, the fix looks correct to me, although it may be the symptom of a different bug/problem.

@MartinquaXD MartinquaXD merged commit cbc083d into main Nov 22, 2022
@MartinquaXD MartinquaXD deleted the fix-math-panic branch November 22, 2022 21:33
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.

5 participants