From 21d4a323dc877af1adebb8d8d13e7aa323e7cc3d Mon Sep 17 00:00:00 2001 From: MerlinEgalite Date: Fri, 15 Sep 2023 10:11:41 +0200 Subject: [PATCH 1/3] docs: acknowledge isHealthy roundings --- src/Morpho.sol | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/Morpho.sol b/src/Morpho.sol index c0ad87915..0c71a84bc 100644 --- a/src/Morpho.sol +++ b/src/Morpho.sol @@ -486,9 +486,12 @@ contract Morpho is IMorpho { } /// @dev Returns whether the position of `borrower` in the given market `marketParams` with the given - /// `collateralPrice` - /// is healthy. + /// `collateralPrice` is healthy. /// @dev Assumes that the inputs `marketParams` and `id` match. + /// @dev The total amount of borrowed assets can be rounding up two times in a row: + /// 1. When converting the borrowed assets to shares before updating the storage. + /// 2. When converting `borrowShares` to `borrowed` in `_isHealthy`. + /// This behavior can lead an healthy position to be marked as unhealthy by 1 wei off and is acknowledged. function _isHealthy(MarketParams memory marketParams, Id id, address borrower, uint256 collateralPrice) internal view From c1411e42e36d68bed68767f0083f696a7e5926c1 Mon Sep 17 00:00:00 2001 From: MerlinEgalite Date: Sat, 16 Sep 2023 17:31:44 +0200 Subject: [PATCH 2/3] docs: simplify comment --- src/Morpho.sol | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/Morpho.sol b/src/Morpho.sol index 0c71a84bc..93a61dedd 100644 --- a/src/Morpho.sol +++ b/src/Morpho.sol @@ -488,10 +488,7 @@ contract Morpho is IMorpho { /// @dev Returns whether the position of `borrower` in the given market `marketParams` with the given /// `collateralPrice` is healthy. /// @dev Assumes that the inputs `marketParams` and `id` match. - /// @dev The total amount of borrowed assets can be rounding up two times in a row: - /// 1. When converting the borrowed assets to shares before updating the storage. - /// 2. When converting `borrowShares` to `borrowed` in `_isHealthy`. - /// This behavior can lead an healthy position to be marked as unhealthy by 1 wei off and is acknowledged. + /// @dev The precision of the inequality can vary up to 1 unit of the borrowable token. function _isHealthy(MarketParams memory marketParams, Id id, address borrower, uint256 collateralPrice) internal view From 465cb7fef165e39d33f6c7f12f62c998bed47723 Mon Sep 17 00:00:00 2001 From: Merlin Egalite <44097430+MerlinEgalite@users.noreply.github.com> Date: Tue, 19 Sep 2023 08:59:44 +0200 Subject: [PATCH 3/3] docs: apply suggestion Co-authored-by: MathisGD <74971347+MathisGD@users.noreply.github.com> Signed-off-by: Merlin Egalite <44097430+MerlinEgalite@users.noreply.github.com> --- src/Morpho.sol | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Morpho.sol b/src/Morpho.sol index 93a61dedd..56b17dee9 100644 --- a/src/Morpho.sol +++ b/src/Morpho.sol @@ -488,7 +488,7 @@ contract Morpho is IMorpho { /// @dev Returns whether the position of `borrower` in the given market `marketParams` with the given /// `collateralPrice` is healthy. /// @dev Assumes that the inputs `marketParams` and `id` match. - /// @dev The precision of the inequality can vary up to 1 unit of the borrowable token. + /// @dev Rounds in favor of the protocol, so one might not be able to borrow exactly `maxBorrow` but one unit less. function _isHealthy(MarketParams memory marketParams, Id id, address borrower, uint256 collateralPrice) internal view