Platform: Code4rena
Start Date: 03/05/2022
Pot Size: $30,000 USDC
Total HM: 6
Participants: 93
Period: 3 days
Judge: gzeon
Id: 118
League: ETH
Rank: 85/93
Findings: 1
Award: $15.49
🌟 Selected for report: 0
🚀 Solo Findings: 0
🌟 Selected for report: BowTiedWardens
Also found by: 0v3rf10w, 0x1f8b, 0x4non, 0xDjango, 0xNazgul, 0xProf, 0xc0ffEE, 0xf15ers, 0xkatana, 0xliumin, ACai, AlleyCat, CertoraInc, Cityscape, Cr4ckM3, DavidGialdi, Dinddle, FSchmoede, Funen, GimelSec, Hawkeye, IllIllI, Kulk0, M0ndoHEHE, MaratCerby, MiloTruck, Picodes, RoiEvenHaim, Tadashi, TerrierLover, TrungOre, VAD37, WatchPug, antonttc, catchup, defsec, delfin454000, dirk_y, eccentricexit, ellahi, fatherOfBlocks, gzeon, hake, hansfriese, hickuphh3, horsefacts, ilan, joestakey, kebabsec, kenta, kenzo, marximimus, minhquanym, noobie, oyc_109, p4st13r4, pauliax, rajatbeladiya, reassor, rfa, robee, rotcivegaf, saian, samruna, shenwilly, shung, simon135, slywaters, sorrynotsorry, throttle, unforgiven, z3s
15.491 USDC - $15.49
function mint(address recipient,uint256 amount) external nonReentrant { require(numMinted + amount <= MAX_WARRIORS); require(_msgSender() == minter); for(unt256 i = 0; i < amount ; ++i){ _safeMint(recipient, numMinted + i); } numMinted += amount; }
ForgottenRunesWarriorMinter.sol#[L162:L164] and ForgottenRunesWarriorMinter.sol#[L220:L222] could be replaced by warriors.mint(msg.sender, numWarriors)
ForgottenRunesWarriorGuild.sol#L24 No need assignment of numMinted = 0
Recommendation: Manage ForgottenRunesWarriorMinter.sol#L73 as a set data structure to save gas for both bidSummon
and issueRefund
execution, i.e using EnumerableSet library from OpenZeppelin, such that:
using Enumberable.AddressSet daMinters
instead of address[] daMinters
By using OpenZeppelin EnumerableSet, ForgottenRunesWarriorMinter.sol#L151 could be replaced by daMinters.add(msg.sender)
. This could costs more gas for the first time that user execute bidSummon(uint256)
than using push(msg.sender)
but the next times that user executes bidSummon(uin256)
, the gas cost is lower because the address is already in the set.
Similarly, issueRefunds(uint256,uint256)
will cost lower by just process an address just once because this decreases the number of operations with storage. Moreover, consider removing the address processed from set to release storage and get negative gas cost if there is no need for retrieving daMinters
.
Underflow condition not met at ForgottenRunesWarriorMinter.sol#L288 and ForgottenRunesWarriorMinter.sol#L296, so consider using unchecked for gas saving