Omniscia Gravita Protocol Audit
GravitaMath Code Style Findings
GravitaMath Code Style Findings
GMH-01C: Illegible Representation of Value Literal
Type | Severity | Location |
---|---|---|
Code Style | ![]() | GravitaMath.sol:L101 |
Description:
The GravitaMath::_computeNominalCR
function will yield a value of 2 ** 256 - 1
, representing the maximum value of a uint256
variable, when an "infinite" collateral ratio is meant to be yielded by it.
Example:
94function _computeNominalCR(uint256 _coll, uint256 _debt) internal pure returns (uint256) {95 if (_debt > 0) {96 return _coll.mul(NICR_PRECISION).div(_debt);97 }98 // Return the maximal value for uint256 if the Vessel has a debt of 0. Represents "infinite" CR.99 else {100 // if (_debt == 0)101 return 2 ** 256 - 1;102 }103}104
105function _computeCR(106 uint256 _coll,107 uint256 _debt,108 uint256 _price109) internal pure returns (uint256) {110 if (_debt > 0) {111 uint256 newCollRatio = _coll.mul(_price).div(_debt);112
113 return newCollRatio;114 }115 // Return the maximal value for uint256 if the Vessel has a debt of 0. Represents "infinite" CR.116 else {117 // if (_debt == 0)118 return type(uint256).max;119 }120}
Recommendation:
We advise the same syntax as GravitaMath::_computeCR
to be used, yielding type(uint256).max
and increasing the legibility of the codebase.
Alleviation:
The representation of the value literal has been standardized in the code utilizing type(uint256).max
as advised.
GMH-02C: Repetitive Value Literal
Type | Severity | Location |
---|---|---|
Code Style | ![]() | GravitaMath.sol:L62, L63 |
Description:
The linked value literal is repeated across the codebase multiple times.
Example:
62if (_minutes > 525600000) {
Recommendation:
We advise it to be set to a constant
variable instead optimizing the legibility of the codebase.
Alleviation:
The referenced repetitive value literal has been relocated to a constant
variable declaration labelled EXPONENT_CAP
, optimizing the legibility of the codebase.