-
Notifications
You must be signed in to change notification settings - Fork 84
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
audit(1): Missing min < max check #299
Conversation
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.
nice! two comments
@@ -34,6 +34,7 @@ library MathExt { | |||
/// @param max The maximum bound for the result. | |||
/// @return r The result of the bounded subtraction. | |||
function boundedSub(uint256 a, int256 b, uint256 min, uint256 max) internal pure returns (uint256 r) { | |||
require(min <= max, "MathExt: min must be less than or equal to max"); |
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 wonder if this is better to check in the SDK to save the additional gas.
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.
If we're going to keep it, we should switch to using a custom revert error:
https://www.notion.so/uniswaplabs/Protocols-Research-Team-Homepage-e55da9af622047b5b289b7b63e7d899e?pvs=4#b2048399e4664f6ebb1b6ddbec507a39
Require that
boundedSub
follows the invariant of:min <= max