Platform: Code4rena
Start Date: 30/11/2021
Pot Size: $30,000 USDC
Total HM: 0
Participants: 21
Period: 3 days
Judge: pauliax
Id: 63
League: ETH
Rank: 16/21
Findings: 1
Award: $28.96
🌟 Selected for report: 3
🚀 Solo Findings: 0
ye0lde
"preMergeCirculatingTribe" can be made a constant to save gas.
preMergeCirculatingTribe is defined here: https://github.com/code-423n4/2021-11-fei/blob/add34324513b863f58e4ef7b3cd0c12d776dbb7f/contracts/TRIBERagequit.sol#L28
And used here: https://github.com/code-423n4/2021-11-fei/blob/add34324513b863f58e4ef7b3cd0c12d776dbb7f/contracts/TRIBERagequit.sol#L101
Visual Studio Code, Remix
Change "preMergeCirculatingTribe" to a constant.
#0 - elee1766
2021-12-06T03:35:29Z
#147
#1 - pauliax
2021-12-10T17:49:13Z
A duplicate of #147
7.2412 USDC - $7.24
ye0lde
Gas savings and code clarity
Below are several occurrences of comparison with literal boolean values of true or false: https://github.com/code-423n4/2021-11-fei/blob/add34324513b863f58e4ef7b3cd0c12d776dbb7f/contracts/PegExchanger.sol#L37-L38 https://github.com/code-423n4/2021-11-fei/blob/add34324513b863f58e4ef7b3cd0c12d776dbb7f/contracts/PegExchanger.sol#L111
https://github.com/code-423n4/2021-11-fei/blob/add34324513b863f58e4ef7b3cd0c12d776dbb7f/contracts/TRIBERagequit.sol#L64-L65 https://github.com/code-423n4/2021-11-fei/blob/add34324513b863f58e4ef7b3cd0c12d776dbb7f/contracts/TRIBERagequit.sol#L69 https://github.com/code-423n4/2021-11-fei/blob/add34324513b863f58e4ef7b3cd0c12d776dbb7f/contracts/TRIBERagequit.sol#L118
Visual Studio Code, Remix
Use the compared expression itself in place of comparison with a boolean literal. The expression can be replaced as is when the expression is expected to evaluate to true and negation can be used when the expression is expected to have a false value.
#0 - elee1766
2021-12-06T03:28:31Z
+ack
no change b/c of loss in code clarity
#1 - pauliax
2021-12-10T18:21:17Z
Valid optimization, even though the sponsor decided not to implement these suggestions.
7.2412 USDC - $7.24
ye0lde
State variables are being explicitly assigned their default value when defined which is unnecessary. Removing the assignment will save gas when deploying.
https://github.com/code-423n4/2021-11-fei/blob/add34324513b863f58e4ef7b3cd0c12d776dbb7f/contracts/PegExchanger.sol#L14-L15 https://github.com/code-423n4/2021-11-fei/blob/add34324513b863f58e4ef7b3cd0c12d776dbb7f/contracts/PegExchanger.sol#L22
https://github.com/code-423n4/2021-11-fei/blob/add34324513b863f58e4ef7b3cd0c12d776dbb7f/contracts/TRIBERagequit.sol#L20 https://github.com/code-423n4/2021-11-fei/blob/add34324513b863f58e4ef7b3cd0c12d776dbb7f/contracts/TRIBERagequit.sol#L22-L23 https://github.com/code-423n4/2021-11-fei/blob/add34324513b863f58e4ef7b3cd0c12d776dbb7f/contracts/TRIBERagequit.sol#L26 https://github.com/code-423n4/2021-11-fei/blob/add34324513b863f58e4ef7b3cd0c12d776dbb7f/contracts/TRIBERagequit.sol#L31 https://github.com/code-423n4/2021-11-fei/blob/add34324513b863f58e4ef7b3cd0c12d776dbb7f/contracts/TRIBERagequit.sol#L40
Visual Studio Code, Remix
Remove the assignments.
Or if you feel it is important to show the default assignment will occur then replace the assignments with a comment.
#0 - elee1766
2021-12-06T03:31:27Z
ack'd
not changing
#1 - pauliax
2021-12-11T09:54:50Z
Valid optimization, even though the sponsor decided not to implement the changes.
🌟 Selected for report: ye0lde
Also found by: GeekyLumberjack, gzeon, loop, robee
7.2412 USDC - $7.24
ye0lde
Gas savings and code clarity
The local variables on the lines below are declared to store the return values from requery
yet some of these
local variables are never used within the code.
https://github.com/code-423n4/2021-11-fei/blob/add34324513b863f58e4ef7b3cd0c12d776dbb7f/contracts/TRIBERagequit.sol#L112-L113 https://github.com/code-423n4/2021-11-fei/blob/add34324513b863f58e4ef7b3cd0c12d776dbb7f/contracts/TRIBERagequit.sol#L115
Visual Studio Code, Remix
Change this: https://github.com/code-423n4/2021-11-fei/blob/add34324513b863f58e4ef7b3cd0c12d776dbb7f/contracts/TRIBERagequit.sol#L112-L115 to
, // pcv value , // user fei int256 newProtocolEquity, // validity ) = oracle.pcvStats();
#0 - pauliax
2021-12-10T18:13:48Z
Valid optimization.