Platform: Code4rena
Start Date: 10/02/2022
Pot Size: $30,000 USDC
Total HM: 5
Participants: 24
Period: 3 days
Judge: harleythedog
Total Solo HM: 3
Id: 86
League: ETH
Rank: 17/24
Findings: 1
Award: $121.76
🌟 Selected for report: 0
🚀 Solo Findings: 0
🌟 Selected for report: pauliax
Also found by: 0x1f8b, Dravee, GreyArt, Omik, ShippooorDAO, Tomio, bobi, cmichel, csanuragjain, defsec, gzeon, kenta, kenzo, m_smirnova2020, rfa, robee, sirhashalot, ye0lde
121.765 USDC - $121.76
Change to:
require(accountsLength != 0); require (accountsLength == _weights.length, "FS: INPUTS_LENGTH_MUST_MATCH");
// gas cost 35465
========================================================================
add unchecked
unchecked { return (_amount * _weight) / _totalWeights; }
// gas cost 22440
========================================================================
i = 0
because the default of uint is already 0
https://github.com/code-423n4/2022-02-nested/blob/main/contracts/FeeSplitter.sol#L126considered removing 0 value can save gas
========================================================================
SafeERC20
Gas Optimization
https://github.com/code-423n4/2022-02-nested/blob/main/contracts/NestedFactory.sol#L19
by not declaring thisusing SafeERC20 for IERC20;
and for example, use this:
SafeERC20.safeTransfer(IERC20(_inputToken)_msgSender(), _amountToSpend - amounts[1]);
========================================================================
Change to:
Shareholder[] storage shareholdersCache = shareholders;
// gas cost 24684
========================================================================
Change to:
function getAmountDue(address _account, IERC20 _token) public view returns (uint256) { TokenRecords storage _tokenRecords = tokenRecords[address(_token)]; if (_tokenRecords.totalShares != 0) { uint256 totalReceived = _tokenRecords.totalReleased + _token.balanceOf(address(this)); return (totalReceived * _tokenRecords.shares[_account]) / _tokenRecords.totalShares - _tokenRecords.released[_account]; } }
// gas cost 24919
========================================================================
#0 - adrien-supizet
2022-02-16T12:49:41Z
#1 - harleythedogC4
2022-03-13T04:03:25Z
My personal judgments:
#2 - harleythedogC4
2022-03-13T06:23:00Z
Now, here is the methodology I used for calculating a score for each gas report. I first assigned each submission to be either small-optimization (1 point), medium-optimization (5 points) or large-optimization (10 points), depending on how useful the optimization is. The score of a gas report is the sum of these points, divided by the maximum number of points achieved by a gas report. This maximum number was 10 points, achieved by #67.
The number of points achieved by this report is 3 points. Thus the final score of this gas report is (3/10)*100 = 30.