-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
Add extra check for decimal math #15419
Conversation
AER Report: CI Core ran successfully ✅AER Report: Operator UI CI ran successfully ✅ |
/// @dev This function assumes the inputs don't overflow and does no checks to avoid this. For any normal inputs, this | ||
/// should not be a problem. The only way to overflow is when the given arguments cannot be represented in the uint256 | ||
/// type, which means the inputs are invalid. | ||
/// @dev This function protects against overflows. If there is a transaction that hits the overflow check, it is |
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.
/// @dev This function protects against overflows. If there is a transaction that hits the overflow check, it is | |
/// @dev This function protects against overflows. If there is a transaction that hits the overflow check, it is |
// would overflow. | ||
if ( | ||
i_tokenDecimals - remoteDecimals > 77 | ||
|| remoteAmount > type(uint256).max / (10 ** (i_tokenDecimals - remoteDecimals)) |
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.
We do these calculations multiple times
Can we compute then once and then use it further
Example
decimalsDifference = remoteDecimals - i_tokenDecimals;
factor = 10 ** decimalsDifference;
5750d81
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!
5750d81
to
b2ec9b8
Compare
Add extra checks for decimal math in pools
Clean up USDC tests