Platform: Code4rena
Start Date: 25/01/2023
Pot Size: $36,500 USDC
Total HM: 11
Participants: 173
Period: 5 days
Judge: kirk-baird
Total Solo HM: 1
Id: 208
League: ETH
Rank: 140/173
Findings: 1
Award: $11.33
🌟 Selected for report: 0
🚀 Solo Findings: 0
🌟 Selected for report: IllIllI
Also found by: 0x1f8b, 0x4non, 0xAgro, 0xSmartContract, 0xhacksmithh, 0xngndev, Aymen0909, Bnke0x0, Breeje, Deivitto, Diana, Dug, Iurii3, LethL, MiniGlome, NoamYakov, RaymondFam, ReyAdmirado, Rolezn, SAAJ, adriro, ali, arialblack14, atharvasama, c3phas, carlitox477, catellatech, chaduke, cryptonue, cryptostellar5, ddimitrov22, dharma09, doublesharp, favelanky, georgits, glcanvas, gzeon, halden, horsefacts, jasonxiale, joestakey, karanctf, lukris02, matrix_0wl, nadin, navinavu, saneryee, shark, thekmj
11.3269 USDC - $11.33
keccak256
Constant expressions are re-calculated each time it is in use, costing an extra 97
gas than a constant every time they are called.
Mark these as immutable
 instead of constant
There are 1 instances of this issue:
Affected source code:
17: bytes32 public constant CREATE_QUEST_ROLE = keccak256('CREATE_QUEST_ROLE');
IMMUTABLE
Avoids a Gsset (20000 gas) in the constructor, and replaces the first access in each transaction (Gcoldsload - 2100 gas) and each access thereafter (Gwarmacces - 100 gas) with a PUSH32
 (3 gas).
There are 1 instances of this issue:
Affected source code:
21: string public questId;
true
 or false
) is a bit more expensiveComparing to a constant (true
 or false
) is a bit more expensive than directly checking the returned boolean value.I suggest using if(directValue)
 instead of if(directValue == true)
 and if(!directValue)
 instead of if(directValue == false)
Â
There are 1 instances of this issue:
Affected source code:
To help the optimizer, go from:
220: if (quests[questId_].numberMinted + 1 > quests[questId_].totalParticipants) revert OverMaxAllowedToMint(); 221: if (quests[questId_].addressMinted[msg.sender] == true) revert AddressAlreadyMinted(); 222: if (keccak256(abi.encodePacked(msg.sender, questId_)) != hash_) revert InvalidHash(); 223: if (recoverSigner(hash_, signature_) != claimSignerAddress) revert AddressNotSigned(); 224: 225: quests[questId_].addressMinted[msg.sender] = true; 226: quests[questId_].numberMinted++;
to
220: bool storage _checkAddress = quests[questId_].addressMinted[msg.sender]; 221: uint storage _checkMax = quests[questId_].numberMinted; 222: if ( _checkMax + 1 > quests[questId_].totalParticipants) revert OverMaxAllowedToMint(); 223: if ( _checkAddress == true) revert AddressAlreadyMinted(); 224: if (keccak256(abi.encodePacked(msg.sender, questId_)) != hash_) revert InvalidHash(); 225: if (recoverSigner(hash_, signature_) != claimSignerAddress) revert AddressNotSigned(); 226: 227: _checkAddress = true; 228: unchecked { 229: _checkMax++; 230: }
and mark _checkMax unchecked
X = X + Y costs less gass than X += Y for state variables
There are 1 instances of this issue:
Affected source code:
/Quest.sol 115: redeemedTokens += redeemableTokenCount;
#0 - c4-judge
2023-02-05T04:30:35Z
kirk-baird marked the issue as grade-b