Omniscia Vector Finance Audit
BaseRewardPool Code Style Findings
BaseRewardPool Code Style Findings
BRP-01C: Inefficient Usage of Reward Tokens
Type | Severity | Location |
---|---|---|
Gas Optimization | Informational | BaseRewardPool.sol:L123, L125, L127, L129 |
Description:
The linked statements read the value of rewardTokens[index]
multiple times redundantly.
Example:
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 _account129 ] = 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
Type | Severity | Location |
---|---|---|
Gas Optimization | Informational | BaseRewardPool.sol:L122, L145, L213 |
Description:
The linked for
loops redundantly retrieve the value of length
from storage on each iteration.
Example:
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
Type | Severity | Location |
---|---|---|
Code Style | Informational | BaseRewardPool.sol:L230-L236 |
Description:
The linked require
check has no error message explicitly defined.
Example:
230require(231 IERC20(_rewardToken).transferFrom(232 msg.sender,233 address(this),234 _amountReward235 )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
Type | Severity | Location |
---|---|---|
Gas Optimization | Informational | BaseRewardPool.sol:L50-L52, L85, L86, L94 |
Description:
The linked variables are assigned to only once during the contract's constructor
.
Example:
79constructor(80 address _stakingToken,81 address _rewardToken,82 address _operator,83 address _rewardManager84) {85 stakingToken = _stakingToken;86 operator = _operator;87 rewards[_rewardToken] = Reward({88 rewardToken: _rewardToken,89 rewardPerTokenStored: 0,90 queuedRewards: 0,91 historicalRewards: 092 });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
.