impermax-sdk 2.1.186 → 2.1.188
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.
|
@@ -81,7 +81,6 @@ class OnchainInteractionsNftlpUniswapV3 extends onchainInteractionsNftlp_1.defau
|
|
|
81
81
|
// Borrow and mint
|
|
82
82
|
if ((borrowADelta > 0 && depositADelta > 0) || (borrowBDelta > 0 && depositBDelta > 0)) {
|
|
83
83
|
// slightly increase borrowDelta in order to avoid amountUser to be dust
|
|
84
|
-
// TODO what if one of these is negative?
|
|
85
84
|
const actualBorrowADelta = Math.max(borrowADelta * this.getDust(), 0);
|
|
86
85
|
const actualBorrowBDelta = Math.max(borrowBDelta * this.getDust(), 0);
|
|
87
86
|
const amountAUser = Math.max(depositADelta - actualBorrowADelta, 0);
|
|
@@ -316,9 +316,9 @@ class UniswapV3Position {
|
|
|
316
316
|
}
|
|
317
317
|
// amountX and amountY are expected to have the same sign
|
|
318
318
|
getOptimalLiquidity(amountX, amountY) {
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
319
|
+
const sampleX = this.getRealXGivenLiquidity(1);
|
|
320
|
+
const sampleY = this.getRealYGivenLiquidity(1);
|
|
321
|
+
if (sampleX != 0 && sampleY != 0) {
|
|
322
322
|
if (sampleX == 0)
|
|
323
323
|
amountX = 0;
|
|
324
324
|
else if (sampleY == 0)
|
|
@@ -369,6 +369,8 @@ class UniswapV3Position {
|
|
|
369
369
|
getMaxWithdrawable() {
|
|
370
370
|
const depositedX = this.getDepositedX();
|
|
371
371
|
const depositedY = this.getDepositedY();
|
|
372
|
+
const additionalDepositX = this.getRealX() - this.getInitialRealX();
|
|
373
|
+
const additionalDepositY = this.getRealY() - this.getInitialRealY();
|
|
372
374
|
let percentage = 0;
|
|
373
375
|
if (!this.isLiquidatable()) {
|
|
374
376
|
if (this.debtX == 0 && this.debtY == 0) {
|
|
@@ -382,8 +384,8 @@ class UniswapV3Position {
|
|
|
382
384
|
}
|
|
383
385
|
}
|
|
384
386
|
return {
|
|
385
|
-
amountX: depositedX * percentage,
|
|
386
|
-
amountY: depositedY * percentage,
|
|
387
|
+
amountX: depositedX * percentage - additionalDepositX,
|
|
388
|
+
amountY: depositedY * percentage - additionalDepositY,
|
|
387
389
|
};
|
|
388
390
|
}
|
|
389
391
|
getMaxBorrowableX() {
|