Open code423n4 opened 2 years ago
Great! Except for the 2nd point, although this is valid, we're opting to keep the domain separator calculation as is, it's future-proof, but perhaps down the line in a contract upgrade we can optimize this. All in this PR: https://github.com/aave/lens-protocol/pull/80
1. Title : multiple .length call on byteHandle
Summary
It is cheaper to save the length value of the byteHandle in a local variable than call the .length in every if condition and loop
POC https://github.com/code-423n4/2022-02-aave-lens/blob/main/contracts/libraries/PublishingLogic.sol#L400-L403
2. Title : many function calculation called with the same result
Summary
this function called many times when user interacting with LensHub. therefore it is cheaper to save the value to a variable in constructor
POC https://github.com/code-423n4/2022-02-aave-lens/blob/main/contracts/core/base/LensNFTBase.sol#L173
3. Title : many boolean operation with the same result
Summary
It is cheaper to save boolean operation result in the local memory when It is going to be used many times.
POC https://github.com/code-423n4/2022-02-aave-lens/blob/main/contracts/core/FollowNFT.sol#L231-L264
before
after