impermax-sdk 2.1.82 → 2.1.83

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.
@@ -91,6 +91,7 @@ class OnchainNftlpUniswapV3 extends onchainNftlp_1.default {
91
91
  const decimalA = yield this.getLendingPool().getBorrowableA().getDecimals();
92
92
  const decimalB = yield this.getLendingPool().getBorrowableB().getDecimals();
93
93
  const netDecimal = decimalA - decimalB;
94
+ // TODO round to tick precision
94
95
  return Math.log(price / Math.pow(10, netDecimal)) / Math.log(1.0001);
95
96
  });
96
97
  }
@@ -58,14 +58,23 @@ class UniswapV3Position {
58
58
  // amountX and amountY are expected to have the same sign
59
59
  getOptimalLiquidityAtMarketPrice(amountX, amountY) {
60
60
  let liquidity;
61
+ console.log("initial", amountX, amountY);
61
62
  if (amountX != 0 && amountY != 0) {
62
63
  const sampleX = this.getRealX(this.marketPrice);
63
64
  const sampleY = this.getRealY(this.marketPrice);
64
- if (Math.abs(amountX) / sampleX > Math.abs(amountY) / sampleY)
65
- amountX = amountY / sampleY * sampleX;
66
- else
67
- amountY = amountX / sampleX * sampleY;
65
+ console.log("sample", sampleX, sampleY);
66
+ if (sampleX == 0)
67
+ amountX = 0;
68
+ else if (sampleX == 0)
69
+ amountY = 0;
70
+ else {
71
+ if (Math.abs(amountX) / sampleX > Math.abs(amountY) / sampleY)
72
+ amountX = amountY / sampleY * sampleX;
73
+ else
74
+ amountY = amountX / sampleX * sampleY;
75
+ }
68
76
  }
77
+ console.log("final", amountX, amountY);
69
78
  liquidity = this.getLiquidity(this.marketPrice, amountX, amountY);
70
79
  return { liquidity, amountX, amountY };
71
80
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "impermax-sdk",
3
- "version": "2.1.82",
3
+ "version": "2.1.83",
4
4
  "description": "",
5
5
  "main": "./lib/index.js",
6
6
  "module": "./lib/index.js",