Open code423n4 opened 3 years ago
The memory location of those variables are intentionally set to be memory
to only load the data from storage once, in order to save gas. If changed to storage
there will be multiple SLOAD
s for accessing the same variable, which is expensive.
In case of withdrawableAmountOfDeposit
function, warden is right. _getDeposit
makes 7 SLOAD
calls in this case because it's pulling whole object from storage. Using storage would make only 5 SLOAD
calls.
In case of _getVestWithdrawableAmount
, either way uses 6 SLOAD
calls.
Warden is right in at least one case so the reports stands.
Handle
a_delamo
Vulnerability details
Impact
Some functions are using memory to read state variables when using storage is more gas efficient.
The following functions contains memory than could be changed to storage:
https://docs.soliditylang.org/en/v0.4.21/types.html#reference-types
Recommended Mitigation Steps