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: 14/21
Findings: 2
Award: $70.31
🌟 Selected for report: 3
🚀 Solo Findings: 0
robee
In the following files there are state variables that could be set immutable to save gas. The list of format <solidity file>, <state variable name that could be immutable>: There are some variables that I was not sure if are assigned actually twice in real use. I added them anyway.
TRIBERagequit.sol, preMergeCirculatingTribe TRIBERagequit.sol, claimed
#0 - elee1766
2021-12-06T04:59:06Z
#157
#1 - pauliax
2021-12-11T10:54:30Z
'claimed' is a mapping, it cannot be immutable. preMergeCirculatingTribe can be constant: #147
🌟 Selected for report: ye0lde
Also found by: GeekyLumberjack, gzeon, loop, robee
robee
Unused local variables are gas consuming, since the initial value assignment costs gas. And are a bad code practice. Removing those variables will decrease the gas cost and improve code quality. This is a full list of all the unused storage variables we found in your code base. The format is <solidity file>, <in which function we found it>, <unused local variable name>:
TRIBERagequit.sol, requery, _pcvValue
#0 - elee1766
2021-12-06T03:52:19Z
#159
#1 - pauliax
2021-12-10T18:17:54Z
A duplicate of #159
2.8506 USDC - $2.85
robee
The following functions could be set external to save gas and improve code quality. External call cost is less expensive than of public functions.
The function setExpirationBlock in PegExchanger.sol could be set external The function isEnabled in PegExchanger.sol could be set external The function party0Accept in PegExchanger.sol could be set external The function isExpired in PegExchanger.sol could be set external The function party1Accept in PegExchanger.sol could be set external The function exchange in PegExchanger.sol could be set external The function isEnabled in TRIBERagequit.sol could be set external The function ngmi in TRIBERagequit.sol could be set external The function requery in TRIBERagequit.sol could be set external The function party0Accept in TRIBERagequit.sol could be set external The function isExpired in TRIBERagequit.sol could be set external The function party1Accept in TRIBERagequit.sol could be set external The function recalculate in TRIBERagequit.sol could be set external
#0 - pauliax
2021-12-11T10:18:11Z
Valid suggestion, it is also a good practice to make your functions external if they are not intended to be called internally. But please note that 'external' is not always cheaper than 'public', see: https://ethereum.stackexchange.com/a/107939/17387
33.1103 USDC - $33.11
robee
The following functions could be set private to save gas and improve code quality: The function takeFrom in PegExchanger.sol could be set internal The function giveTo in PegExchanger.sol could be set internal The function verifyProof in TRIBERagequit.sol could be set internal The function takeFrom in TRIBERagequit.sol could be set internal The function processProof in TRIBERagequit.sol could be set internal The function giveTo in TRIBERagequit.sol could be set internal The function _startCountdown in TRIBERagequit.sol could be set internal
#0 - pauliax
2021-12-11T10:20:57Z
Valid, very similar to #27
19.8662 USDC - $19.87
robee
Reading a storage variable is gas costly (SLOAD). In cases of multiple read of a storage variable in the same scope, caching the first read (i.e saving as a local variable) can save gas and decrease the overall gas uses. The following is a list of functions and the storage variables that you read twice:
TRIBERagequit.sol Variable token1OutBase is read 2 times in the function: recalculate TRIBERagequit.sol Variable minProtocolEquity is read 5 times in the function: requery
#0 - pauliax
2021-12-11T12:04:53Z
Valid optimization.