20,000 USDC
View results
Submission Details
Severity: gas
Valid

Named parameter mappings

Summary

There is a missed opportunity to use named parameter for public mappings

Vulnerability Details

The projects use Solidity 0.8.19 and miss that from 0.8.18 a new feature allowing named parameters for public mappings was introduced. See instances below without using them
mapping(address => uint256) public supplyIndex; //Staking.sol line 19
mapping(address => uint256) public balances; //Staking.sol line 21
mapping(address => uint256) public claimable; //Staking.sol line 24
mapping(bytes32 => Pool) public pools; // Lender.sol line 70

Impact

Informational:

  1. This improves code readability and maintanability as it,

  2. Makes the mappings syntax similar to functions and events that take parameters and,

  3. Allows setting of fields in the ABI for mapping public getter functions

Tools Used

Manual Analysis

Recommendations

Change to specify parameter names for all instances as in example below:
mapping(address user => uint256 index) public supplyIndex; //Staking.sol line 19

Support

FAQs

Can't find an answer? Chat with us on Discord, Twitter or Linkedin.