Open code423n4 opened 2 years ago
not worth the extra complexity for the first suggestion, but agreed on caching that mapping read
While impractical the first finding is valid and each jump avoided would save 8 gas, 32
Saving a SLOAD would save 100 gas at the cost of 6 for using a memory cache, 94
126
Gas Optimizations
inline some functions to save gas
In the ERC4626, there are multiple functions that their code can be inlined to save the gas spending on calling them.
For example, the
previewDeposit
function. It is used in thedeposit
function:Instead of calling that function, shares can be calculated by inlining the function, something like this:
This can be sone to all of the other functions I attached before (
previewMint
,previewWithdraw
,previewRedeem
).Save mapping values instead of accessing it twice
Save the
getTotalFeiBoostedForVault[vault]
in theslurp
function of theTurboSafe
instead of accessing it twice for reading. It will look something like this: