Open code423n4 opened 2 years ago
calldata
here is better than memory
it is more in pattern to remove the memory order
and simply use o[i]
throughout. this applies to every function called by these as well as changing the call to them with a memory order
would require changing those signatures as wellthat being said, marking this as resolved because pointing out order
vs o[i]
here is worth recognizing
1) State variables which are read more than once should be cached to save gas.
ZcToken.sol
2) Remove Identical functions in
ZcToken.sol
.convertToUnderlying
andpreviewRedeem
functions are identical.convertToPrincipal
andpreviewWithdraw
functions are identical.3) Convert frequenctly used revert checks into a modifier.
ZcToken.sol
has the following revert check which repeats twice.4) Simplify formula for better readability and gas saving.
There are 6 functions in VaultTracker.sol ( addNotional, removeNotional, redeemInterest, transferNotionalFrom, transferNotionalFee and removeNotional ) which calculate
interest
in the following way:These can be re-written as below:
5) Use already cached variable instead of indexing again.
There are two instances of this:
order
. So use it inside the following if-else statements instead of freshly indexing again.