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 realX = this.getRealX();
291
- let realY = this.getRealY();
292
- if (realX === 0 && realY === 0) {
293
- realX = this.getRealXGivenLiquidity(1);
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() {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "impermax-sdk",
3
- "version": "2.1.159",
3
+ "version": "2.1.160",
4
4
  "description": "",
5
5
  "main": "./lib/index.js",
6
6
  "module": "./lib/index.js",