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

Combine Multiple Address Mappings

Summary

Combine multiple address mappings

Vulnerability Details

Staking.sol 3 mappings can be combined
mapping(address => uint256) public supplyIndex;
/// @notice mapping of user balances
mapping(address => uint256) public balances;
/// @notice mapping of user claimable rewards
mapping(address => uint256) public claimable;

Impact

Gas: Instead of having 3 mappings we can combine into a single mapping of struct for the address user and their info on claims, balances et.
We will make use on a single mapping instead of 3 saving the computation, hashing of mapping storage slots computations and saving storage costs.

Tools Used

Manual Analysis

Recommendations

Staking.sol change to something similar to the below
struct User {
address user;
uint256 supplyIndex;
uint256 balances;
uint256 claimable;
}
mapping(address => User) userInfo;

Support

FAQs

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