Platform: Code4rena
Start Date: 01/07/2022
Pot Size: $75,000 USDC
Total HM: 17
Participants: 105
Period: 7 days
Judge: Jack the Pug
Total Solo HM: 5
Id: 143
League: ETH
Rank: 95/105
Findings: 1
Award: $38.23
🌟 Selected for report: 0
🚀 Solo Findings: 0
🌟 Selected for report: 0xA5DF
Also found by: 0v3rf10w, 0x09GTO, 0x1f8b, 0x29A, 0xDjango, 0xKitsune, 0xNazgul, 0xdanial, 0xf15ers, Aymen0909, Bnke0x0, Ch_301, Cheeezzyyyy, Chom, ElKu, Funen, Hawkeye, IllIllI, JC, JohnSmith, Kaiziron, Lambda, Limbooo, Meera, Metatron, MiloTruck, Noah3o6, Picodes, Randyyy, RedOneN, ReyAdmirado, Rohan16, Saintcode_, Sm4rty, TomJ, Tomio, Tutturu, UnusualTurtle, Waze, _Adam, __141345__, ajtra, apostle0x01, asutorufos, brgltd, c3phas, cRat1st0s, codexploder, defsec, delfin454000, djxploit, durianSausage, exd0tpy, fatherOfBlocks, hake, horsefacts, ignacio, jayfromthe13th, joestakey, jonatascm, kaden, kebabsec, m_Rassska, mektigboy, mrpathfindr, oyc_109, rajatbeladiya, rbserver, rfa, robee, sach1r0, sashik_eth, simon135
38.2308 USDC - $38.23
The prefix increment expression is cheaper in terms of gas.
Consider using the prefix increment expression whenever the return value is not needed.
Instances Include:
Mitigation:
Do
for (uint256 _i = 0; _i < _permissionIndexes.length; ++_i) {}
Instead of
for (uint256 _i = 0; _i < _permissionIndexes.length; _i++) {}
Description: Caching the array length outside a loop saves reading it on each iteration, as long as the array's length is not changed during the loop.
Instances Include:
Mitigation:
Define the length of the array outside of the loop
Do
uint256 len = _splits.length; for (uint256 _i = 0; _i < len; _i++) { // Get a reference to the split being iterated on. JBSplit memory _split = _splits[_i]; // The amount to send towards the split. uint256 _tokenCount = PRBMath.mulDiv( _amount, _split.percent, JBConstants.SPLITS_TOTAL_PERCENT );
Instead of
for (uint256 _i = 0; _i < _splits.length; _i++) { // Get a reference to the split being iterated on. JBSplit memory _split = _splits[_i]; // The amount to send towards the split. uint256 _tokenCount = PRBMath.mulDiv( _amount, _split.percent, JBConstants.SPLITS_TOTAL_PERCENT );
Description:
Background info:
https://gus-tavo-guim.medium.com/public-vs-external-functions-in-solidity-b46bcf0ba3ac https://ethereum.stackexchange.com/questions/107578/does-using-external-over-public-in-a-library-reduce-any-gas-costs/107939#107939
instances Include:
Mitigation
Do
function isTerminalOf(uint256 _projectId, IJBPaymentTerminal _terminal) external view override returns (bool) { for (uint256 _i; _i < _terminalsOf[_projectId].length; _i++) if (_terminalsOf[_projectId][_i] == _terminal) return true; return false; }
Instead of
function isTerminalOf(uint256 _projectId, IJBPaymentTerminal _terminal) public view override returns (bool) { for (uint256 _i; _i < _terminalsOf[_projectId].length; _i++) if (_terminalsOf[_projectId][_i] == _terminal) return true; return false; }