impermax-sdk 2.1.178 → 2.1.180

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.
@@ -146,10 +146,10 @@ class UniswapV2Position {
146
146
  return this.isLiquidatableGivenPriceAndDebt(this.marketPrice, debtX, debtY);
147
147
  }
148
148
  isLiquidatableGivenPrice(price) {
149
- return this.getEquityValueGivenPrice(price / this.safetyMargin) < 0 || this.getEquityValueGivenPrice(price * this.safetyMargin) < 0;
149
+ return this.isLiquidatableGivenPriceAndDebt(price, this.debtX, this.debtY);
150
150
  }
151
151
  isUnderwaterGivenPrice(price) {
152
- return this.getEquityValueGivenPrice(price) < 0;
152
+ return this.getLiquidityPostLiquidationValueGivenPriceAndDebt(price, this.debtX, this.debtY) < 0;
153
153
  }
154
154
  getLiquidationPriceInRange(lowPrice, highPrice, lowIsLiquidatable, highIsLiquidatable) {
155
155
  if (lowIsLiquidatable == highIsLiquidatable)
@@ -227,6 +227,8 @@ class UniswapV2Position {
227
227
  const isLiquidatable = this.isLiquidatable();
228
228
  if (isLiquidatable)
229
229
  return undefined;
230
+ if (this.marketPrice < LOWEST_PRICE || this.marketPrice > HIGHEST_PRICE)
231
+ return undefined;
230
232
  const lowIsLiquidatable = this.isLiquidatableGivenPrice(LOWEST_PRICE);
231
233
  const highIsLiquidatable = this.isLiquidatableGivenPrice(HIGHEST_PRICE);
232
234
  const priceA = this.getLiquidationPriceInRange(LOWEST_PRICE, this.marketPrice, lowIsLiquidatable, isLiquidatable);
@@ -293,6 +293,8 @@ class UniswapV3Position {
293
293
  const isLiquidatable = this.isLiquidatable();
294
294
  if (isLiquidatable)
295
295
  return undefined;
296
+ if (this.marketPrice < LOWEST_PRICE || this.marketPrice > HIGHEST_PRICE)
297
+ return undefined;
296
298
  const lowIsLiquidatable = this.isLiquidatableGivenPrice(LOWEST_PRICE);
297
299
  const highIsLiquidatable = this.isLiquidatableGivenPrice(HIGHEST_PRICE);
298
300
  const priceA = this.getLiquidationPriceInRange(LOWEST_PRICE, this.marketPrice, lowIsLiquidatable, isLiquidatable);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "impermax-sdk",
3
- "version": "2.1.178",
3
+ "version": "2.1.180",
4
4
  "description": "",
5
5
  "main": "./lib/index.js",
6
6
  "module": "./lib/index.js",