Omniscia Olive Audit
Manager Code Style Findings
Manager Code Style Findings
MAN-01C: Inefficient Re-Entrancy Guard
Type | Severity | Location |
---|---|---|
Gas Optimization | Manager.sol:L70-L75 |
Description:
The linked re-entrancy guard is custom made and utilizes a bool
to signal its status.
Example:
70modifier nonReentrant() {71 require(!_entered, "ReentrancyGuard: reentrant call");72 _entered = true;73 _;74 _entered = false;75}
Recommendation:
We advise a similar paradigm to OpenZeppelin's ReentrancyGuard contract to be utilized whereby the guard value is represented at both instances (entered / not entered) by a non-zero value to ensure gas optimization.
Alleviation:
The OpenZeppelin ReentrancyGuard
implementation is now properly utilized in the codebase.
MAN-02C: Inefficient Utilization of Length
Type | Severity | Location |
---|---|---|
Gas Optimization | Manager.sol:L132, L133, L140, L141 |
Description:
The linked statements perform a storage lookup on the value of length
on each iteration of the loops.
Example:
132address[] memory returnData = new address[](pools.length());133for (uint256 i = 0; i < pools.length(); i++) {134 returnData[i] = pools.at(i);135}
Recommendation:
We advise the length
member to be cached to an in-memory variable that is consequently utilized for both the array initialization and the for
loop optimizing the codebase.
Alleviation:
The length
member is now cached to a local variable in both linked instances alleviating this exhibit.
MAN-03C: Redundant Usage of SafeMath
Type | Severity | Location |
---|---|---|
Gas Optimization | Manager.sol:L21 |
Description:
The project's code is compiled with a compiler version beyond 0.8.X
which has built-in safe arithmetics toggled on by default.
Example:
3pragma solidity 0.8.4;4pragma experimental ABIEncoderV2;5
6import "../interfaces/IManager.sol";7import "../interfaces/ILiquidityPool.sol";8import "../interfaces/IVoteOlive.sol";9import "@openzeppelin/contracts/utils/Address.sol";10import {Initializable} from "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol";11import {IERC20Upgradeable as IERC20} from "@openzeppelin/contracts-upgradeable/token/ERC20/IERC20Upgradeable.sol";12import {SafeERC20Upgradeable as SafeERC20} from "@openzeppelin/contracts-upgradeable/token/ERC20/utils/SafeERC20Upgradeable.sol";13import {EnumerableSetUpgradeable as EnumerableSet} from "@openzeppelin/contracts-upgradeable/utils/structs/EnumerableSetUpgradeable.sol";14import {SafeMathUpgradeable as SafeMath} from "@openzeppelin/contracts-upgradeable/utils/math/SafeMathUpgradeable.sol";15import {AccessControlUpgradeable as AccessControl} from "@openzeppelin/contracts-upgradeable/access/AccessControlUpgradeable.sol";16import "../interfaces/events/CycleRolloverEvent.sol";17
18import "hardhat/console.sol";19
20contract Manager is IManager, Initializable, AccessControl {21 using SafeMath for uint256;
Recommendation:
We advise the codebase to omit the usage of SafeMath
in favor of reduced gas costs.
Alleviation:
The redundant usage of SafeMath
has been safely omitted from the codebase.