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
Rank: 71/72
Findings: 1
Award: $52.02
🌟 Selected for report: 0
🚀 Solo Findings: 0
🌟 Selected for report: Dravee
Also found by: 0v3rf10w, 0x1f8b, 0xAsm0d3us, 0xBug, 0xDjango, 0xNazgul, 0xkatana, CertoraInc, Cityscape, Funen, Hawkeye, IllIllI, MaratCerby, SolidityScan, TerrierLover, TomFrenchBlockchain, Tomio, TrungOre, bae11, berndartmueller, csanuragjain, defsec, delfin454000, ellahi, fatherOfBlocks, gs8nrv, gzeon, horsefacts, ilan, jah, joestakey, joshie, kebabsec, kenta, nahnah, oyc_109, rayn, rfa, robee, saian, securerodd, simon135, slywaters, sorrynotsorry, tchkvsky, teryanarmen, z3s
52.0246 USDC - $52.02
use an array value right away without saving it to a variable first will save gas
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; } }
...
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; } }
'''