Omniscia Moby Audit
RewardTracker Code Style Findings
RewardTracker Code Style Findings
RTR-01C: Deprecated Revert Pattern
| Type | Severity | Location |
|---|---|---|
| Standard Conformity | ![]() | RewardTracker.sol:L138, L149, L167 |
Description:
The referenced revert statements will yield a textual description of the error which is an abandoned practice.
Example:
137function stake(address _depositToken, uint256 _amount) external override nonReentrant {138 if (inPrivateStakingMode) { revert("RewardTracker: action not enabled"); }139 _stake(msg.sender, msg.sender, _depositToken, _amount);140}Recommendation:
We advise custom error declarations to be introduced to the RewardTracker and consequently utilized in place of the referenced messages, optimizing the code's gas cost as well as legibility.
Alleviation (a8720219a6a97e10b8d9c6a70c6345747f0fdcb3):
The first two revert instances have been omitted from the codebase as a result of remediative actions for other exhibits, and the final revert statement within the RewardTracker::claim function is now utilizing an ActionNotEnabled error declaration.
As such, we consider this exhibit fully alleviated.
RTR-02C: Ineffectual Usage of Safe Arithmetics
| Type | Severity | Location |
|---|---|---|
| Language Specific | ![]() | RewardTracker.sol:L121, L218, L231, L279, L283 |
Description:
The linked mathematical operation is guaranteed to be performed safely by surrounding conditionals evaluated in either require checks or if-else constructs.
Example:
276uint256 stakedAmount = stakedAmounts[_account];277require(stakedAmounts[_account] >= _amount, "RewardTracker: _amount exceeds stakedAmount");278
279stakedAmounts[_account] = stakedAmount - _amount;Recommendation:
Given that safe arithmetics are toggled on by default in pragma versions of 0.8.X, we advise the linked statement to be wrapped in an unchecked code block thereby optimizing its execution cost.
Alleviation (a8720219a6a97e10b8d9c6a70c6345747f0fdcb3):
All referenced arithmetic operations have been wrapped in an unchecked code block safely, optimizing their gas cost whilst retaining their security guarantees via preceding conditionals.
RTR-03C: Inefficient mapping Lookups
| Type | Severity | Location |
|---|---|---|
| Gas Optimization | ![]() | RewardTracker.sol:L120, L121, L264, L281, L283 |
Description:
The linked statements perform key-based lookup operations on mapping declarations from storage multiple times for the same key redundantly.
Example:
120require(allowances[_sender][msg.sender] >= _amount, "RewardTracker: transfer amount exceeds allowance");121uint256 nextAllowance = allowances[_sender][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 (a8720219a6):
The recommended optimization has not been applied as expected.
In detail, the optimization specifies that mapping lookups such as depositBalances[_account][_depositToken] should either be cached in value (i.e. uint256 depositBalance = depositBalances[_account][_depositToken]) or in data location (i.e. mapping(address => uint256) storage depositsOfAccount = depositBalances[_account]).
Neither pattern is observed in the latest state of the codebase, rendering this exhibit partially addressed.
Alleviation (a95db4124c):
The latter of the two aforementioned patterns have been applied to the codebase, rendering this exhibit addressed.
RTR-04C: Loop Iterator Optimization
| Type | Severity | Location |
|---|---|---|
| Gas Optimization | ![]() | RewardTracker.sol:L71 |
Description:
The linked for loop increments / decrements the iterator "safely" due to Solidity's built-in safe arithmetics (post-0.8.X).
Example:
71for (uint256 i = 0; i < _depositTokens.length; i++) {Recommendation:
We advise the increment / decrement operation to be performed in an unchecked code block as the last statement within the for loop to optimize its execution cost.
Alleviation (a8720219a6a97e10b8d9c6a70c6345747f0fdcb3):
The loop is no longer present in the codebase, rendering this optimization inapplicable.
