Forgotten Runes Warrior Guild contest - 0x4non's results

16,000 Warrior NFTs sold in a phased Dutch Auction.

General Information

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

Forgotten Runes

Findings Distribution

Researcher Performance

Rank: 55/93

Findings: 2

Award: $46.80

🌟 Selected for report: 0

🚀 Solo Findings: 0

Gas optimizations

Use immutable in variables that shouldnt change

I recommend to set contract variables WETH, warriors and vault as immutable, these variables shouldnt change, then you could remove functions, setWarriorsAddress, setWethAddress, setVaultAddress. Now the constructor should be

    constructor(IForgottenRunesWarriorsGuild _warriors, address _weth) {
        warriors = _warriors;
        weth = _weth;
        vault = msg.sender;
    }

Use internal copy of array instead of using daMinters

Consider reeplacing theses lines https://github.com/code-423n4/2022-05-runes/blob/f562bc57045af5897785e2542878b01ead127775/contracts/ForgottenRunesWarriorsMinter.sol#L355-L357 For

        address[] memory _daMinters = daMinters;
        for (uint256 i = startIdx; i < endIdx + 1;) {
            _refundAddress(_daMinters[i]);
            unchecked {
                i++;
            }
        }

Use unchecked in safe operarions

Since numWarriors input is validated and lower equal than 20 you could use unchecked in this lines https://github.com/code-423n4/2022-05-runes/blob/f562bc57045af5897785e2542878b01ead127775/contracts/ForgottenRunesWarriorsMinter.sol#L152-L154

unchecked { daAmountPaid[msg.sender] += msg.value; daNumMinted[msg.sender] += numWarriors; numSold += numWarriors; }

Use unchecked in https://github.com/code-423n4/2022-05-runes/blob/f562bc57045af5897785e2542878b01ead127775/contracts/ForgottenRunesWarriorsMinter.sol#L193

unchecked{ numSold += 1; }

Use unchecked in (numWarriors is equal or less than 20 so there is no overflow issue) https://github.com/code-423n4/2022-05-runes/blob/f562bc57045af5897785e2542878b01ead127775/contracts/ForgottenRunesWarriorsMinter.sol#L219

unchecked { numSold += numWarriors; }

Use unchecked in https://github.com/code-423n4/2022-05-runes/blob/f562bc57045af5897785e2542878b01ead127775/contracts/ForgottenRunesWarriorsMinter.sol#L248

unchecked { numClaimed += 1; }

Use unchecked in https://github.com/code-423n4/2022-05-runes/blob/f562bc57045af5897785e2542878b01ead127775/contracts/ForgottenRunesWarriorsMinter.sol#L379

unchecked { daAmountRefunded[minter] += owed; }

Use unchecked in for loops

Consider to change loops pattern from;

for (uint256 i = 0; i < length; i++) { // CODE }

To

for (uint256 i = 0; i < length;) { // CODE unchecked { i++; } }

For loops:

Change this lines https://github.com/code-423n4/2022-05-runes/blob/f562bc57045af5897785e2542878b01ead127775/contracts/ForgottenRunesWarriorsMinter.sol#L162-L164 For

for (uint256 i = 0; i < numWarriors;) { _mint(msg.sender); unchecked { i++; } }

Change this lines https://github.com/code-423n4/2022-05-runes/blob/f562bc57045af5897785e2542878b01ead127775/contracts/ForgottenRunesWarriorsMinter.sol#L220-L222 For

for (uint256 i = 0; i < numWarriors;) { _mint(msg.sender); unchecked { i++; } }

Change this lines https://github.com/code-423n4/2022-05-runes/blob/f562bc57045af5897785e2542878b01ead127775/contracts/ForgottenRunesWarriorsMinter.sol#L259-L261 For

for (uint256 i = 0; i < count;) { _mint(recipient); unchecked { i++; } }

This lines https://github.com/code-423n4/2022-05-runes/blob/f562bc57045af5897785e2542878b01ead127775/contracts/ForgottenRunesWarriorsMinter.sol#L354-L358 For

{ address[] memory _daMinters = daMinters; for (uint256 i = startIdx; i < endIdx + 1;) { _refundAddress(_daMinters[i]); unchecked { i++; } } } ```
AuditHub

A portfolio for auditors, a security profile for protocols, a hub for web3 security.

Built bymalatrax © 2024

Auditors

Browse

Contests

Browse

Get in touch

ContactTwitter