Omniscia Redacted Cartel Audit

Mariposa Code Style Findings

Mariposa Code Style Findings

MAR-01C: Misleading Contract Language

TypeSeverityLocation
Code StyleMariposa.sol:L65, L75, L77

Description:

The linked request function hints that a mint has been requested, however, the function directly fulfils the mint request by minting the relevant tokens to the intended recipient.

Example:

contracts/core/Mariposa.sol
60/**
61 @notice Mints tokens for recipient
62 @param recipient address To receive minted tokens
63 @param amount uint256 Amount
64 */
65function request(address recipient, uint256 amount) external whenNotPaused {
66 if (!isMinter[msg.sender]) revert NotMinter();
67 if (amount == 0) revert ZeroAmount();
68 if (recipient == address(0)) revert ZeroAddress();
69 if (amount > mintAllowances[msg.sender]) revert ExceedsAllowance();
70
71 emissions += amount;
72 mintAllowances[msg.sender] -= amount;
73 totalAllowances -= amount;
74
75 emit Requested(msg.sender, recipient, amount);
76
77 btrflyV2.mint(recipient, amount);
78}

Recommendation:

We advise the language around the function and the corresponding event emitted within it to be changed as it currently is misleading.

Alleviation:

The request function and associated language have been properly adjusted to mintFor and similar language thereby increasing the code's clarity.

MAR-02C: Generic Typographic Mistake

TypeSeverityLocation
Code StyleMariposa.sol:L50

Description:

The referenced line contains a typographical mistake or generic documentational error (i.e. copy-paste) that should be corrected.

Example:

contracts/core/Mariposa.sol
50@param _supplyCap uint256 Max number of tokens contract can emmit

Recommendation:

We advise this to be done so to enhance the legibility of the codebase.

Alleviation:

The typographic mistake has been corrected properly.

MAR-03C: Inefficient Variable Reads

Description:

The linked statements read variables from storage redundantly twice instead of caching them to local variables.

Example:

contracts/core/Mariposa.sol
105if (emissions + totalAllowances + amount > supplyCap)
106 revert ExceedsSupplyCap();
107
108totalAllowances += amount;

Recommendation:

Given that the relevant variables are not meant to change between read operations, we advise each variable that is read repeatedly to be read once and stored to a local variable that is consequently utilized optimizing the gas cost of all linked statements.

Alleviation:

An optimization has been applied albeit not to the maximum level possible. The t variable should hold the result of totalAllowances + amount which is consequently evaluated in the if conditional (emissions + t > supplyCap) and ultimately assigned to the totalAllowances variable after the conditional has been evaluated properly.

MAR-04C: Inefficient mapping Lookups

Description:

The linked statements perform key-based lookup operations on mapping declarations from storage multiple times for the same key redundantly.

Example:

contracts/core/Mariposa.sol
69if (amount > mintAllowances[msg.sender]) revert ExceedsAllowance();
70
71emissions += amount;
72mintAllowances[msg.sender] -= amount;

Recommendation:

As the lookups internally perform an expensive keccak256 operation, we advise the lookups to be cached wherever possible to a single local declaration that either holds the value of the mapping in case of primitive types or holds a storage pointer to the struct contained.

Alleviation:

The former of the two referenced variable read pairs is no longer present in the codebase whereas the latter still exists and has not been remediated. We advise the value of mintAllowances[minter] to be stored to a local variable that is utilized for the if conditional and used in the assignment to mintAllowances[minter] without a compound operator which indirectly reads the variable again.