Omniscia Gravita Protocol Audit

BorrowerOperations Code Style Findings

BorrowerOperations Code Style Findings

BOS-01C: Ineffectual Native Value Check

TypeSeverityLocation
Gas OptimizationBorrowerOperations.sol:L582

Description:

The BorrowerOperations::_requireNonZeroAdjustment function will evaluate whether the msg.value is non-zero, however, such a case is impossible in the codebase as the functions it is invoked in are not payable.

Example:

contracts/BorrowerOperations.sol
576function _requireNonZeroAdjustment(
577 uint256 _collWithdrawal,
578 uint256 _debtTokenChange,
579 uint256 _assetSent
580) internal view {
581 require(
582 msg.value != 0 || _collWithdrawal != 0 || _debtTokenChange != 0 || _assetSent != 0,
583 "BorrowerOps: There must be either a collateral change or a debt change"
584 );
585}

Recommendation:

We advise this part of the conditional to be safely omitted, optimizing its gas cost.

Alleviation:

The msg.value evaluation was removed from the function, optimizing its gas cost and permitting it to be set to pure.

BOS-02C: Redundant Native Value Check

TypeSeverityLocation
Gas OptimizationBorrowerOperations.sol:L291

Description:

The BorrowerOperations::_adjustVessel function will mandate that the msg.value is zero, however, it is impossible to be otherwise due to the function's invocation in non-payable contexts.

Example:

contracts/BorrowerOperations.sol
291require(msg.value == 0, "BorrowerOps: msg.value must be zero");

Recommendation:

We advise the referenced require check to be safely omitted from the code, optimizing its gas cost.

Alleviation:

The redundant require check has been safely removed from the codebase as advised.

BOS-03C: Suboptimal Struct Declaration Styles

TypeSeverityLocation
Code StyleBorrowerOperations.sol:L124, L292

Description:

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

Example:

contracts/BorrowerOperations.sol
124ContractsCache memory contractsCache = ContractsCache(vesselManager, adminContract.activePool(), debtToken);

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 both referenced instances of the exhibit, addressing it in full.