Fix edge case calculation errors in remove liquidity screen#586
Conversation
|
This pull request is being automatically deployed with Vercel (learn more). 🔍 Inspect: https://vercel.com/oceanprotocol/market/6i5WZM6VZbpMJBUfmH5b8Sru5ZJN |
|
In my tests it looked like using Or any reason why |
|
Based on documentation we should use |
|
Using
Also, it seems that when adding a low amount of liquidity and when trying to remove it we get another conversion error with |
|
toPrecision converts in scientific notation, use http://mikemcl.github.io/decimal.js/#toExpPos |
|
Actually i think we need http://mikemcl.github.io/decimal.js/#toExpNeg |
|
Neither of the two works and I keep getting the same error over and over again. I tested it with
Best way to test:
Using |
|
ok, i'll take a look at it |
Signed-off-by: mihaisc <mihai.scarlat@smartcontrol.ro>
|
@DimitarSD please test this, it works for me |
|
@mihaisc I'm getting only converting to wei error. Btw I'm testing by adding the min allowed amount for liquidity - |
|
When are you substracting? Can you show me the code? |
|
I didn't change anything in the code. I made a pull and ran the code with your latest changes. The only thing I did was to add 0.00001 liquidity to Maritime Word List on Polygon and then tried to remove it (hence the error) |
|
Ok, i seem to replicate this as well. It looks like sometimes precision is ignored |
|
It's not ignored, If we have Every time we have 0s after the decimal point, and the total number of digits is close to 18 it will break (most of the time in edge cases and very small amounts) |
Signed-off-by: mihaisc <mihai.scarlat@smartcontrol.ro>
Signed-off-by: mihaisc <mihai.scarlat@smartcontrol.ro>
|
Not the best solution, but at the end of the day it's a form of rounding down. |
Signed-off-by: mihaisc <mihai.scarlat@smartcontrol.ro>
|
Ok, good catch. It was because ocean and dt values. Now it should be ok. |
|
@mihaisc I get the same first error again if I try to remove 1% of 0.00001 (I don't have problems if I try to remove 100%). Also I noticed that certain percentages (like 9%) doesn't calculate properly and it basically add nothing: |
|
Code Climate has analyzed commit 294c570 and detected 2 issues on this pull request. Here's the issue category breakdown:
View more on Code Climate. |
|
@mihaisc after the last updates I didn't manage to reproduce any of the bugs so far. |
kremalicious
left a comment
There was a problem hiding this comment.
could not break it anymore in my limited manual test cases so looks like we made it 🥳



Fixes #584 .
Changes proposed in this PR:
toPrecision()alone led to errors in certain edge cases