impermax-sdk 2.1.159 → 2.1.160
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.
|
@@ -287,12 +287,13 @@ class UniswapV3Position {
|
|
|
287
287
|
if (this.isLiquidatable())
|
|
288
288
|
return currentLeverage;
|
|
289
289
|
const highLeverage = 100; // we assume the position is liquidatable with this leverage
|
|
290
|
-
let
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
realY = this.getRealYGivenLiquidity(1);
|
|
290
|
+
let setLiquidityToZero = false;
|
|
291
|
+
if (this.liquidity === 0) {
|
|
292
|
+
this.liquidity = 0.000001;
|
|
293
|
+
setLiquidityToZero = true;
|
|
295
294
|
}
|
|
295
|
+
const realX = this.getRealX();
|
|
296
|
+
const realY = this.getRealY();
|
|
296
297
|
const projectedRealX = realX * highLeverage / currentLeverage;
|
|
297
298
|
const projectedRealY = realY * highLeverage / currentLeverage;
|
|
298
299
|
const projectedDebtX = this.debtX + projectedRealX - realX;
|
|
@@ -303,6 +304,8 @@ class UniswapV3Position {
|
|
|
303
304
|
const collateralValue = this.getCollateralValue();
|
|
304
305
|
const debtValue = this.getValueGivenAmounts(this.debtX + deltaDebtX, this.debtY + deltaDebtY);
|
|
305
306
|
const equityValue = collateralValue - debtValue;
|
|
307
|
+
if (setLiquidityToZero)
|
|
308
|
+
this.liquidity = 0;
|
|
306
309
|
return collateralValue / equityValue;
|
|
307
310
|
}
|
|
308
311
|
getMinLeverage() {
|