@lidofinance/lido-ethereum-sdk
Version:
<div style="display: flex;" align="center"> <h1 align="center">Lido Ethereum SDK</h1> </div>
24 lines • 997 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.calculateHealth = void 0;
const index_js_1 = require("../../consts/index.js");
const calculateHealth = (args) => {
const { totalValue, liabilitySharesInStethWei, forceRebalanceThresholdBP } = args;
const PRECISION = 10n ** 18n;
const thresholdMultiplier = ((index_js_1.BASIS_POINTS_DENOMINATOR - BigInt(forceRebalanceThresholdBP)) *
PRECISION) /
index_js_1.BASIS_POINTS_DENOMINATOR;
const adjustedValuation = (totalValue * thresholdMultiplier) / PRECISION;
const healthRatio18 = liabilitySharesInStethWei > 0n
? (adjustedValuation * PRECISION * 100n) / liabilitySharesInStethWei
: Infinity;
const healthRatio = Number(healthRatio18) / 1e18;
const isHealthy = healthRatio >= 100;
return {
healthRatio,
healthRatio18,
isHealthy,
};
};
exports.calculateHealth = calculateHealth;
//# sourceMappingURL=calculate-health.js.map