Popcorn contest - eyexploit's results

A multi-chain regenerative yield-optimizing protocol.

General Information

Platform: Code4rena

Start Date: 31/01/2023

Pot Size: $90,500 USDC

Total HM: 47

Participants: 169

Period: 7 days

Judge: LSDan

Total Solo HM: 9

Id: 211

League: ETH

Popcorn

Findings Distribution

Researcher Performance

Rank: 88/169

Findings: 1

Award: $69.82

Gas:
grade-b

🌟 Selected for report: 0

🚀 Solo Findings: 0

Awards

69.8247 USDC - $69.82

Labels

bug
G (Gas Optimization)
grade-b
G-17

External Links

Finding 1 : Use cached state variable instead

function accruedPerformanceFee() public view returns (uint256) {
        uint256 highWaterMark_ = highWaterMark;
        uint256 shareValue = convertToAssets(1e18);
        uint256 performanceFee = fees.performance;

        return
            performanceFee > 0 && shareValue > highWaterMark
                ? performanceFee.mulDiv(
                    (shareValue - highWaterMark) * totalSupply(),
                    1e36,
                    Math.Rounding.Down
                )
                : 0;
    }

Above state variable highWaterMark is cached into highWaterMark_ but not used anywhere in the function. Each read from storage is expensive and cost 100 gas, caching it to the local variable can save good amount of gas.

Gas per sload = 100 Total gas on n sload = 100n where n, is times of state variable used.

Gas that could be saved by caching = 100(n-1)

Recommendation : Consider using the highWaterMark_

#0 - c4-judge

2023-03-01T00:09:26Z

dmvt marked the issue as grade-b

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