Omniscia Steadefi Audit

GMXPerpetualDEXLongReader Manual Review Findings

GMXPerpetualDEXLongReader Manual Review Findings

GMP-01M: Potentially Incorrect Default Values

TypeSeverityLocation
Logical FaultGMXPerpetualDEXLongReader.sol:L127, L136

Description:

The default values yielded whenever either of the variables utilized in the respective divisions is zero appears to be incorrect as it is always zero even when the denominator of the division is zero.

Impact:

The impact of this exhibit cannot be assessed as it depends on how the relevant data points are utilized.

Example:

contracts/vaults/gmx/GMXPerpetualDEXLongReader.sol
122/**
123 * Returns the current leverage (asset / equity)
124 * @return leverage Current leverage in 1e18
125*/
126function leverage() public view returns (uint256) {
127 if (assetValue() == 0 || equityValue() == 0) return 0;
128 return assetValue() * SAFE_MULTIPLIER / equityValue();
129}
130
131/**
132 * Debt ratio: token debt value / total asset value
133 * @return debtRatio Current debt ratio % in 1e18
134*/
135function debtRatio() public view returns (uint256) {
136 if (assetValue() == 0) return 0;
137 return debtValue() * SAFE_MULTIPLIER / assetValue();
138}

Recommendation:

We advise the return statements to yield "infinity" (type(uint256).max) when the denominator is zero, representing that the system is in a significantly abnormal state (i.e. a non-zero GMXPerpetualDEXLongReader::debtValue and a zero GMXPerpetualDEXLongReader::assetValue).

Alleviation (7c9b2b09dbe1f75d8c5ad379e658030ecf1be3a0):

The Steadefi team evaluated this exhibit and outlined that the likelihood of a non-zero debt when the GMXPerpetualDEXLongReader::assetValue evaluates to 0 is highly improbable, rendering the exhibit's rationale incorrect. As such, we consider this exhibit nullified.