Omniscia Vector Finance Audit

BaseRewardPool Code Style Findings

BaseRewardPool Code Style Findings

BRP-01C: Inefficient Usage of Reward Tokens

TypeSeverityLocation
Gas OptimizationInformationalBaseRewardPool.sol:L123, L125, L127, L129

Description:

The linked statements read the value of rewardTokens[index] multiple times redundantly.

Example:

contracts/BaseRewardPool.sol
121modifier updateReward(address _account) {
122 for (uint256 index = 0; index < rewardTokens.length; ++index) {
123 userRewards[rewardTokens[index]][_account] = earned(
124 _account,
125 rewardTokens[index]
126 );
127 userRewardPerTokenPaid[rewardTokens[index]][
128 _account
129 ] = rewardPerToken(rewardTokens[index]);
130 }
131 _;
132}

Recommendation:

We advise it to be stored to an in-memory variable that is consequently utilized similarly to the other segments in the codebase.

Alleviation:

The value of the array is now cached to an in-memory variable thereby optimizing the codebase.

BRP-02C: Inefficient Variable Utilization

TypeSeverityLocation
Gas OptimizationInformationalBaseRewardPool.sol:L122, L145, L213

Description:

The linked for loops redundantly retrieve the value of length from storage on each iteration.

Example:

contracts/BaseRewardPool.sol
121modifier updateReward(address _account) {
122 for (uint256 index = 0; index < rewardTokens.length; ++index) {

Recommendation:

We advise the length member to be stored to an in-memory variable that is consequently utilized to greatly optimize the code's gas cost.

Alleviation:

The code was optimized only for the first linked instance.

BRP-03C: Inexistent Error Message

TypeSeverityLocation
Code StyleInformationalBaseRewardPool.sol:L230-L236

Description:

The linked require check has no error message explicitly defined.

Example:

contracts/BaseRewardPool.sol
230require(
231 IERC20(_rewardToken).transferFrom(
232 msg.sender,
233 address(this),
234 _amountReward
235 )
236);

Recommendation:

We advise it to be set so to aid in the validation of the require's condition as well as the legibility of the codebase.

Alleviation:

The linked require statement no longer exists in the codebase rendering this exhibit null.

BRP-04C: Variable Mutability Optimization

TypeSeverityLocation
Gas OptimizationInformationalBaseRewardPool.sol:L50-L52, L85, L86, L94

Description:

The linked variables are assigned to only once during the contract's constructor.

Example:

contracts/BaseRewardPool.sol
79constructor(
80 address _stakingToken,
81 address _rewardToken,
82 address _operator,
83 address _rewardManager
84) {
85 stakingToken = _stakingToken;
86 operator = _operator;
87 rewards[_rewardToken] = Reward({
88 rewardToken: _rewardToken,
89 rewardPerTokenStored: 0,
90 queuedRewards: 0,
91 historicalRewards: 0
92 });
93 rewardTokens.push(_rewardToken);
94 rewardManager = _rewardManager;
95}

Recommendation:

We advise them to be set as immutable greatly optimizing their gas cost.

Alleviation:

All linked variables were properly optimized as immutable.