Skip to content
This repository was archived by the owner on Apr 18, 2026. It is now read-only.

Commit 174140a

Browse files
authored
Merge pull request #28 from morpho-labs/refactor/compound-div-opti
Improve revert condition in Compound division
2 parents 45d1d2d + 3ac2a3e commit 174140a

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

src/math/CompoundMath.sol

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@ library CompoundMath {
2828
function div(uint256 x, uint256 y) internal pure returns (uint256 z) {
2929
assembly {
3030
z := mul(x, SCALE)
31-
// Revert when y = 0 or when both x > 0 and (x * SCALE) / x != SCALE
32-
if or(iszero(y), iszero(or(iszero(x), eq(div(z, x), SCALE)))) {
31+
// Revert if y = 0 or (x * SCALE) / SCALE < x
32+
if or(iszero(y), lt(div(z, SCALE), x)) {
3333
revert(0, 0)
3434
}
3535

0 commit comments

Comments
 (0)