Omniscia Gravita Protocol Audit

VesselManagerOperations Code Style Findings

VesselManagerOperations Code Style Findings

VMO-01C: Loop Iterator Optimizations

TypeSeverityLocation
Gas OptimizationVesselManagerOperations.sol:L485, L548, L594, L782

Description:

The linked for loops increment / decrement their iterator "safely" due to Solidity's built - in safe arithmetics (post-0.8.X).

Example:

contracts/VesselManagerOperations.sol
485for (vars.i = 0; vars.i < _vesselArray.length; vars.i++) {

Recommendation:

We advise the increment / decrement operations to be performed in an unchecked code block as the last statement within each for loop to optimize their execution cost.

Alleviation:

The loop iterator increments have been optimized as advised where applicable, however, their i++ counterpart is utilized instead of ++i. We advise the latter to be set in use as it is more optimal than the present code.

VMO-02C: Redundant Initialization Paradigm

TypeSeverityLocation
Gas OptimizationVesselManagerOperations.sol:L66-L67, L75

Description:

The VesselManagerOperations contract inherits the OpenZeppelin OwnableUpgradeable implementation which contains the Initializable implementation, put in use within the VesselManagerOperations::setAddresses function. As such, the manual isInitialized flag is redundant.

Example:

contracts/VesselManagerOperations.sol
59function setAddresses(
60 address _vesselManagerAddress,
61 address _sortedVesselsAddress,
62 address _stabilityPoolAddress,
63 address _collSurplusPoolAddress,
64 address _debtTokenAddress,
65 address _adminContractAddress
66) external initializer {
67 require(!isInitialized, "Already initialized");
68 __Ownable_init();
69 vesselManager = IVesselManager(_vesselManagerAddress);
70 sortedVessels = ISortedVessels(_sortedVesselsAddress);
71 stabilityPool = IStabilityPool(_stabilityPoolAddress);
72 collSurplusPool = ICollSurplusPool(_collSurplusPoolAddress);
73 debtToken = IDebtToken(_debtTokenAddress);
74 adminContract = IAdminContract(_adminContractAddress);
75 isInitialized = true;
76}

Recommendation:

We advise it and its validations to be omitted from the codebase as it is ineffectual and duplicates the purpose of the Initializable::initializer modifier.

Alleviation:

The manual initialization methodology has been removed from the contract as advised.

VMO-03C: Suboptimal Struct Declaration Styles

TypeSeverityLocation
Code StyleVesselManagerOperations.sol:L97-L101, L347, L770

Description:

The linked declaration styles of the referenced structs are using index-based argument initialization.

Example:

contracts/VesselManagerOperations.sol
97LiquidationContractsCache memory contractsCache = LiquidationContractsCache(
98 adminContract.activePool(),
99 adminContract.defaultPool(),
100 sortedVessels
101);

Recommendation:

We advise the key-value declaration format to be utilized instead in each instance, greatly increasing the legibility of the codebase.

Alleviation:

The key-value declaration style is now in use in all referenced instances of the exhibit, addressing it in full.