-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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
Increase default slippage from 2% to 3%, show Advanced Options by default #10842
Conversation
CLA Signature Action: All authors have signed the CLA. You may need to manually re-run the blocking PR check if it doesn't pass in a few minutes. |
This change looks good, but actually reveals a pre-existing bug that I think should be addressed within this PR. To see this bug on this branch:
I've attached a file that shows a change that resolves that problem: However, there will still be a similar problem if a custom amount is entered. That should be resolved too, I think. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One small issue to address, otherwise this code looks good
return 1; | ||
} else if (currentSlippage === 2) { | ||
return 0; | ||
} else if (currentSlippage) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it might be best not to call setCustomValue
in the callback to useState
, as this is incidental to the purpose of this function. I think the intent of the code would be clearer if we added a callback to the useState
call that sets up the customValue
which would set the initial custom value to currentSlippage
if currentSlippage
is truthy but not equal to 2 or 3.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like that!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
Explanation:
Manual testing steps:
Swap
button in the MetaMask extensionSwap
page with Advanced Options visible and 3% slippage tolerance selected by defaultScreenshots:
Swap page: Advanced Options visible and 3% slippage tolerance selected by default
Verifying that the 3% slippage is send to the server:
Pre-popullating previously set custom value when going back to the Swap page:
All unit tests are green: