From a1e6fbe74cc5e60fb5d05d5c7a10393f8ca38518 Mon Sep 17 00:00:00 2001 From: Quentin Garchery Date: Wed, 5 Jul 2023 17:58:23 +0200 Subject: [PATCH] refactor: simplify isHealthy --- src/Blue.sol | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Blue.sol b/src/Blue.sol index fe1b2b1de..466f2ef71 100644 --- a/src/Blue.sol +++ b/src/Blue.sol @@ -226,10 +226,10 @@ contract Blue { function isHealthy(Market calldata market, Id id, address user) private view returns (bool) { uint borrowShares = borrowShare[id][user]; + if (borrowShares == 0) return true; // totalBorrowShares[id] > 0 when borrowShares > 0. - uint borrowValue = borrowShares != 0 - ? borrowShares.wMul(totalBorrow[id]).wDiv(totalBorrowShares[id]).wMul(market.borrowableOracle.price()) - : 0; + uint borrowValue = + borrowShares.wMul(totalBorrow[id]).wDiv(totalBorrowShares[id]).wMul(market.borrowableOracle.price()); uint collateralValue = collateral[id][user].wMul(market.collateralOracle.price()); return collateralValue.wMul(market.lLTV) >= borrowValue; }