Omniscia Steadefi Audit

GMXPerpetualDEXLongReader Code Style Findings

GMXPerpetualDEXLongReader Code Style Findings

GMP-01C: Ineffectual Usage of Safe Arithmetics

TypeSeverityLocation
Language SpecificGMXPerpetualDEXLongReader.sol:L95

Description:

The linked mathematical operations are guaranteed to be performed safely by surrounding conditionals evaluated in either require checks or if-else constructs.

Example:

contracts/vaults/gmx/GMXPerpetualDEXLongReader.sol
90function equityValue() public view returns (uint256) {
91 uint256 _assetValue = assetValue();
92 uint256 _debtValue = debtValue();
93 // in underflow condition return 0
94 if (_debtValue > _assetValue) return 0;
95 return (_assetValue - _debtValue);
96}

Recommendation:

Given that safe arithmetics are toggled on by default in pragma versions of 0.8.X, we advise the linked statements to be wrapped in unchecked code blocks thereby optimizing their execution cost.

Alleviation (4325253d6de0ea91c1e9fb9e01d2e7e98f3d83a9):

The referenced subtraction is now wrapped in an unchecked code block, optimizing its execution cost.

GMP-02C: Repetitive Value Literals

TypeSeverityLocation
Code StyleGMXPerpetualDEXLongReader.sol:L65, L75, L164, L166, L168

Description:

The linked value literals are repeated across the codebase multiple times.

Example:

contracts/vaults/gmx/GMXPerpetualDEXLongReader.sol
65return (glpManager.getPrice(false) / 1e12 * tokenAssetAmt / SAFE_MULTIPLIER);

Recommendation:

We advise each to be set to its dedicated constant variable instead optimizing the legibility of the codebase.

Alleviation (4325253d6d):

While the latter three referenced lines that contained the same value literal were optimized in legibility, the 1e12 literal remains in use by the codebase.

Alleviation (7c9b2b09db):

The 1e12 value literal has been relocated to its dedicated GLP_PRICE_DIVIDER constant variable as originally advised, addressing this exhibit in full.

GMP-03C: Variable Mutability Specifiers (Immutable)

TypeSeverityLocation
Gas OptimizationGMXPerpetualDEXLongReader.sol:L40-L43

Description:

The linked variables are assigned to only once during the contract's constructor.

Example:

contracts/vaults/gmx/GMXPerpetualDEXLongReader.sol
34constructor(
35 IGMXPerpetualDEXLongVault _vault,
36 IGMXPerpetualDEXLongManager _manager,
37 IChainLinkOracle _priceOracle,
38 IGMXGLPManager _glpManager
39) {
40 vault = _vault;
41 manager = _manager;
42 priceOracle = _priceOracle;
43 glpManager = _glpManager;
44}

Recommendation:

We advise them to be set as immutable greatly optimizing their read-access gas cost.

Alleviation (4325253d6de0ea91c1e9fb9e01d2e7e98f3d83a9):

All variables have been set as immutable per our recommendation, greatly reducing their read-access gas cost.