Platform: Code4rena
Start Date: 10/02/2022
Pot Size: $100,000 USDC
Total HM: 13
Participants: 21
Period: 7 days
Judge: leastwood
Total Solo HM: 10
Id: 85
League: ETH
Rank: 19/21
Findings: 1
Award: $242.67
🌟 Selected for report: 0
🚀 Solo Findings: 0
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
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
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
function _moveDelegate( address from, address to, uint256 amount ) internal { unchecked { if (from != address(0)) { //statement } if (to != address(0)) { if (from == address(0)) { //statement } } else{ if(from != address(0)){ //statement } } } }
after
function _moveDelegate( address from, address to, uint256 amount ) internal { unchecked { bool fromZero = from == address(0); if (!fromZero) { //statement } if (to != address(0)) { if (fromZero) { //statement } } else{ if(!fromZero){ //statement } } } }
#0 - Zer0dot
2022-03-24T19:59:04Z
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