File: IndexTemplate.sol
491: function leverage() public view returns (uint256 _rate) {
492: //check current leverage rate
493: if (totalLiquidity() > 0) {
494: return (totalAllocatedCredit * MAGIC_SCALE_1E6) / totalLiquidity();
495: } else {
496: return 0;
497: }
498: }
Tools Used
VS Code
Recommended Mitigation Steps
If this check is at least made at some places, this means that this variable can indeed take a value of 0. Therefore, a check should always be made to prevent the div by 0
Handle
Dravee
Vulnerability details
Impact
A division by 0 could occur
Proof of Concept
While at some place, a check is made to make sure that
totalLiquidity() > 0
, it's not consistently the case, such as here:At the following place, the check is indeed made:
Tools Used
VS Code
Recommended Mitigation Steps
If this check is at least made at some places, this means that this variable can indeed take a value of 0. Therefore, a check should always be made to prevent the div by 0