@gearbox-protocol/periphery-v3 1.7.0-next.82 → 1.7.0-next.84
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -261,7 +261,7 @@ contract CreditAccountCompressor is BaseCompressor, ICreditAccountCompressor {
|
|
|
261
261
|
data.totalValueUSD = cdd_.totalValueUSD;
|
|
262
262
|
data.twvUSD = cdd_.twvUSD;
|
|
263
263
|
data.totalValue = cdd_.totalValue;
|
|
264
|
-
data.healthFactor = cdd_
|
|
264
|
+
data.healthFactor = _calcHealthFactor(cdd_);
|
|
265
265
|
data.success = true;
|
|
266
266
|
} catch {}
|
|
267
267
|
|
|
@@ -328,7 +328,7 @@ contract CreditAccountCompressor is BaseCompressor, ICreditAccountCompressor {
|
|
|
328
328
|
try ICreditManagerV3(creditManager).calcDebtAndCollateral(creditAccount, CollateralCalcTask.DEBT_COLLATERAL)
|
|
329
329
|
returns (CollateralDebtData memory cdd) {
|
|
330
330
|
if (filter.reverting) return false;
|
|
331
|
-
uint256 healthFactor = cdd
|
|
331
|
+
uint256 healthFactor = _calcHealthFactor(cdd);
|
|
332
332
|
if (filter.minHealthFactor != 0 && healthFactor < filter.minHealthFactor) return false;
|
|
333
333
|
if (filter.maxHealthFactor != 0 && healthFactor > filter.maxHealthFactor) return false;
|
|
334
334
|
} catch {
|
|
@@ -338,4 +338,9 @@ contract CreditAccountCompressor is BaseCompressor, ICreditAccountCompressor {
|
|
|
338
338
|
|
|
339
339
|
return true;
|
|
340
340
|
}
|
|
341
|
+
|
|
342
|
+
/// @dev Calculates health factor with 18 decimals precision, returns `type(uint256).max` if debt is zero
|
|
343
|
+
function _calcHealthFactor(CollateralDebtData memory cdd) internal pure returns (uint256) {
|
|
344
|
+
return cdd.totalDebtUSD == 0 ? type(uint256).max : cdd.twvUSD * 1e18 / cdd.totalDebtUSD;
|
|
345
|
+
}
|
|
341
346
|
}
|
package/package.json
CHANGED