Omniscia Steadefi Audit
GMXPerpetualDEXLongReader Code Style Findings
GMXPerpetualDEXLongReader Code Style Findings
GMP-01C: Ineffectual Usage of Safe Arithmetics
Type | Severity | Location |
---|---|---|
Language Specific | GMXPerpetualDEXLongReader.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:
90function equityValue() public view returns (uint256) {91 uint256 _assetValue = assetValue();92 uint256 _debtValue = debtValue();93 // in underflow condition return 094 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
Type | Severity | Location |
---|---|---|
Code Style | GMXPerpetualDEXLongReader.sol:L65, L75, L164, L166, L168 |
Description:
The linked value literals are repeated across the codebase multiple times.
Example:
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)
Type | Severity | Location |
---|---|---|
Gas Optimization | GMXPerpetualDEXLongReader.sol:L40-L43 |
Description:
The linked variables are assigned to only once during the contract's constructor
.
Example:
34constructor(35 IGMXPerpetualDEXLongVault _vault,36 IGMXPerpetualDEXLongManager _manager,37 IChainLinkOracle _priceOracle,38 IGMXGLPManager _glpManager39) {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.