Aave Lens contest - rfa's results

Web3 permissionless, composable & decentralized social graph

General Information

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

Aave Lens

Findings Distribution

Researcher Performance

Rank: 21/21

Findings: 1

Award: $199.00

🌟 Selected for report: 0

🚀 Solo Findings: 0

Findings Information

🌟 Selected for report: Dravee

Also found by: 0x0x0x, 0x1f8b, IllIllI, Jujic, csanuragjain, d4rk, defsec, gzeon, nahnah, pauliax, rfa

Labels

bug
G (Gas Optimization)

Awards

198.9996 USDC - $199.00

External Links

#AAVEGasFindings 1-- -using storage instead memory to declare snapshot struct https://github.com/code-423n4/2022-02-aave-lens/blob/main/contracts/core/FollowNFT.sol#L135 https://github.com/code-423n4/2022-02-aave-lens/blob/main/contracts/core/FollowNFT.sol#L177 instead of caching snapshot per loop just read it directly from storage. Its just called at most three times (or may be once) per loop and read it from storage cost less gas:

Snapshot storage snapshot = _snapshots[user][center];

2-- -unnecesary previous var declaration https://github.com/code-423n4/2022-02-aave-lens/blob/main/contracts/core/FollowNFT.sol#L257 previous just used once. just pass _snapshots[to][toSnapshotCount - 1].value; directly below it and remove line 257

// remove this line (L 257) uint128 newValue = uint128(_snapshots[to][toSnapshotCount - 1].value + amount);

3-- -using require() for gas optimisation https://github.com/code-423n4/2022-02-aave-lens/blob/main/contracts/core/FollowNFT.sol#L261-L264 instead of using else and if to check the condition, using require() to replace if and removing else can save gas

require(from != address(0));

4-- -declare delSupplySnapshotCount & previousDelSupply once instead of twice https://github.com/code-423n4/2022-02-aave-lens/blob/main/contracts/core/FollowNFT.sol#L231-L274 by declaring delSupplySnapshotCount & previousDelSupply once at line 243 and removing all of them inside if & else can save gas(better declare it once instead twice since they have the same value)

if(to!=address(0)){ uint256 delSupplySnapshotCount = _delSupplySnapshotCount; uint128 previousDelSupply = _delSupplySnapshots[delSupplySnapshotCount - 1].value; ...

5-- -unused interface https://github.com/code-423n4/2022-02-aave-lens/blob/main/contracts/core/FollowNFT.sol#L12 IERC721Metadata.sol is never used in FollowNFTcontract

#0 - Zer0dot

2022-03-18T17:28:29Z

Variable declarations like "previous" in this QA report help code readability. 4th point is invalid as well because in cases where neither the from or to addresses are the zero address, then we would be declaring the variables and reading from storage for nothing. 5th point is valid though!

#1 - Zer0dot

2022-03-18T17:36:23Z

AuditHub

A portfolio for auditors, a security profile for protocols, a hub for web3 security.

Built bymalatrax © 2024

Auditors

Browse

Contests

Browse

Get in touch

ContactTwitter