-
Notifications
You must be signed in to change notification settings - Fork 5
Description
In the aforementioned function, there appears to be a potentially-incorrect assumption:
//Safe to use unchecked, as function will revert in if statement if overflow
unchecked{
dailyBorrows[msg.sender][day] += amount;
}
It is not really clear why "function will revert in if statement if overflow", since dailyBorrows is not accessed again anywhere past this point in the function.
Perhaps it is accessed in a different function called during the same flow, but in that case, a more detailed description seems imperative here.
Furthermore, the difference between a regular addition (87 gas units) and an unchecked addition (21 gas units) is by and large negligible, most certainly in the case at hand, where it is executed a single time (i.e., not inside a loop or anything like that).
The risk here seems to outweigh the gain by a magnitude, let alone due to the fact that this is a permission-less public function (can be called by anyone with no access restrictions whatsoever).