impermax-sdk 2.1.187 → 2.1.189
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.
|
@@ -318,17 +318,15 @@ class UniswapV3Position {
|
|
|
318
318
|
getOptimalLiquidity(amountX, amountY) {
|
|
319
319
|
const sampleX = this.getRealXGivenLiquidity(1);
|
|
320
320
|
const sampleY = this.getRealYGivenLiquidity(1);
|
|
321
|
-
if (sampleX
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
amountY = amountX / sampleX * sampleY;
|
|
331
|
-
}
|
|
321
|
+
if (sampleX == 0)
|
|
322
|
+
amountX = 0;
|
|
323
|
+
else if (sampleY == 0)
|
|
324
|
+
amountY = 0;
|
|
325
|
+
else {
|
|
326
|
+
if (Math.abs(amountX) / sampleX > Math.abs(amountY) / sampleY)
|
|
327
|
+
amountX = amountY / sampleY * sampleX;
|
|
328
|
+
else
|
|
329
|
+
amountY = amountX / sampleX * sampleY;
|
|
332
330
|
}
|
|
333
331
|
const liquidity = this.getLiquidityGivenAmounts(amountX, amountY);
|
|
334
332
|
return {
|
|
@@ -369,6 +367,8 @@ class UniswapV3Position {
|
|
|
369
367
|
getMaxWithdrawable() {
|
|
370
368
|
const depositedX = this.getDepositedX();
|
|
371
369
|
const depositedY = this.getDepositedY();
|
|
370
|
+
const additionalDepositX = this.getRealX() - this.getInitialRealX();
|
|
371
|
+
const additionalDepositY = this.getRealY() - this.getInitialRealY();
|
|
372
372
|
let percentage = 0;
|
|
373
373
|
if (!this.isLiquidatable()) {
|
|
374
374
|
if (this.debtX == 0 && this.debtY == 0) {
|
|
@@ -382,8 +382,8 @@ class UniswapV3Position {
|
|
|
382
382
|
}
|
|
383
383
|
}
|
|
384
384
|
return {
|
|
385
|
-
amountX: depositedX * percentage,
|
|
386
|
-
amountY: depositedY * percentage,
|
|
385
|
+
amountX: depositedX * percentage - additionalDepositX,
|
|
386
|
+
amountY: depositedY * percentage - additionalDepositY,
|
|
387
387
|
};
|
|
388
388
|
}
|
|
389
389
|
getMaxBorrowableX() {
|