Badger Citadel contest - nahnah's results

Bringing BTC to DeFi

General Information

Platform: Code4rena

Start Date: 14/04/2022

Pot Size: $75,000 USDC

Total HM: 8

Participants: 72

Period: 7 days

Judge: Jack the Pug

Total Solo HM: 2

Id: 110

League: ETH

BadgerDAO

Findings Distribution

Researcher Performance

Rank: 71/72

Findings: 1

Award: $52.02

🌟 Selected for report: 0

🚀 Solo Findings: 0

1.)No need to save an array value in a variable

Summary

use an array value right away without saving it to a variable first will save gas

POC

https://github.com/code-423n4/2022-04-badger-citadel/blob/main/src/lib/GlobalAccessControlManaged.sol#L49-L50

Before ...

for (uint256 i = 0; i < roles.length; i++) { bytes32 role = roles[i]; if (gac.hasRole(role, msg.sender)) { validRoleFound = true; break; } }

...

After ...

for (uint256 i = 0; i < roles.length; i++) { if (gac.hasRole(roles[i], msg.sender)) { validRoleFound = true; break; } }

...

2.)No need to save the same value to another variable

POC

https://github.com/code-423n4/2022-04-badger-citadel/blob/main/src/Funding.sol#L233-L234

Before '''

function getRemainingFundable() external view returns (uint256 limitLeft_) { uint256 assetCumulativeFunded = funding.assetCumulativeFunded; uint256 assetCap = funding.assetCap; if (assetCumulativeFunded < assetCap) { limitLeft_ = assetCap - assetCumulativeFunded; } }

''' After '''

function getRemainingFundable() external view returns (uint256 limitLeft_) { if (funding.assetCumulativeFunded < funding.assetCap) { limitLeft_ = funding.assetCap - funding.assetCumulativeFunded; } }

'''

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