-
Notifications
You must be signed in to change notification settings - Fork 20
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
Rename math operations #107
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.
I suggested alternatives, but I think it's fine having them named wMul
and wDiv
too
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.
Agreed that current names are misleading. Not sure about the best new names.
- just
wMul
(etc) makes sense because regular solidity regular division truncates. wMul[zero,0,etc]
(etc) is more explicit and probably better since those new names will coexist withwDivDown(uint)
(etc).
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.
formatting issue it seems
conflicts :/ |
…me-math-operations
There are failing tests |
@@ -10,11 +10,13 @@ int256 constant WAD_INT = int256(WAD); | |||
/// @custom:contact security@morpho.org | |||
/// @notice Library to manage fixed-point arithmetic on signed integers. | |||
library MathLib { | |||
function wMulDown(int256 a, int256 b) internal pure returns (int256) { | |||
/// @dev Returns the multiplication of `a` by `b` (in WAD) rounded towards 0. | |||
function wMulTo0(int256 a, int256 b) internal pure returns (int256) { |
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.
My two cents/nitpick: using the full word "zero" would maybe be more clean.
- it's easy to get confused between char
0
ando
andO
. Having "zero" directly in the name is also much more explicit - probably it's not comfortable to have a number inside a function when you need to type it
Note: The solidity style guide does not have a strong opinion about having numbers inside the function's name
Fixes cantina issue #127.
The only places where this differs from rounding towards negative infinity are the following:
morpho-blue-irm/src/AdaptiveCurveIrm.sol
Line 123 in 73eddf9
morpho-blue-irm/src/AdaptiveCurveIrm.sol
Line 137 in 73eddf9
coeff.wMulDown(err)
inmorpho-blue-irm/src/AdaptiveCurveIrm.sol
Line 179 in 73eddf9
Those all have a consistent effect: under-estimating the error. This is why I think that only renaming those functions is enough