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

Bug - yourRate is sometimes parsed incorrectly #1

Open
coffee-converter opened this issue May 4, 2021 · 7 comments
Open

Bug - yourRate is sometimes parsed incorrectly #1

coffee-converter opened this issue May 4, 2021 · 7 comments

Comments

@coffee-converter
Copy link

everyElementIterator = everyElementIterator.replace(/[^0-9.]/g, "");

Since this particular element may contain the extension-injected dollar amount in parentheses, the regex isn't enough to parse the quick amount, and so it can end up including some of the digits from the dollar amount:

Screen Shot 2021-05-04 at 12 17 11 PM

@grepole121
Copy link
Owner

Thanks for bringing this up.
I have removed the regex and changed it to use a substring ignoring the first character (the emoji). parseFloat just ignores the later data after the space.
Did you actually notice this causing any issues with the extension or just in the code because I see the problem here but this shouldn't have caused any major problems as it's after multiple decimal places so the effect would be very small?

@grepole121
Copy link
Owner

Just out of curiosity, what IDE are you using here and how are you doing the debugging for the script as it would need to run in a browser wouldn't it? I mostly just used console.log() for my debugging as I don't have much experience with JavaScript and learned to build this extension

@grepole121 grepole121 reopened this May 4, 2021
@coffee-converter
Copy link
Author

Thanks for bringing this up.
I have removed the regex and changed it to use a substring ignoring the first character (the emoji). parseFloat just ignores the later data after the space.
Did you actually notice this causing any issues with the extension or just in the code because I see the problem here but this shouldn't have caused any major problems as it's after multiple decimal places so the effect would be very small?

Yeah the effect should be very small... I actually started looking into it because I noticed a large discrepancy in my "your deposits in this pool" number on a pool after a long while of having the page open and then clicking the extension to refresh...it would be a few percent too high...reloading the page and clicking the extension again corrected the value. I'm still trying to isolate that bug.

@coffee-converter
Copy link
Author

coffee-converter commented May 4, 2021

Just out of curiosity, what IDE are you using here and how are you doing the debugging for the script as it would need to run in a browser wouldn't it? I mostly just used console.log() for my debugging as I don't have much experience with JavaScript and learned to build this extension

I was just using the Chrome dev tools (Sources tab) debugger...much handier than adding console statements!

@coffee-converter
Copy link
Author

Thanks for bringing this up.
I have removed the regex and changed it to use a substring ignoring the first character (the emoji). parseFloat just ignores the later data after the space.
Did you actually notice this causing any issues with the extension or just in the code because I see the problem here but this shouldn't have caused any major problems as it's after multiple decimal places so the effect would be very small?

Yeah the effect should be very small... I actually started looking into it because I noticed a large discrepancy in my "your deposits in this pool" number on a pool after a long while of having the page open and then clicking the extension to refresh...it would be a few percent too high...reloading the page and clicking the extension again corrected the value. I'm still trying to isolate that bug.

@grepole121 I believe the main issue I noticed with occasional wrong deposit amounts is because once the extension has overwritten the textContent of the "your rate" line (to include the dollar amount), the UI no longer updates that cell with new rate info. Maybe append/update a new div with the dollar amount instead? Might fix it.

@grepole121
Copy link
Owner

So QuickSwap doesn't update "Your rate" part of the website after the script runs and puts the dollar equivalent in brackets?

@coffee-converter
Copy link
Author

So QuickSwap doesn't update "Your rate" part of the website after the script runs and puts the dollar equivalent in brackets?

Yeah, I believe that's what's happening. I didn't test it too much but that's what it looked like to me. On one tab I ran the extension once and then let it sit there as Quickswap updated values. On another tab I opened the same page but didn't trigger the extension, and the rate values there updated while the previous tab's rate values remained the same.

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

No branches or pull requests

2 participants