@crypticdot/defituna-client 3.1.7 → 3.1.8
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.
- package/dist/index.js +9 -11
- package/dist/index.mjs +9 -11
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -10401,19 +10401,18 @@ function getDecreaseSpotPositionQuote(args) {
|
|
|
10401
10401
|
let newPositionToken = positionToken;
|
|
10402
10402
|
let decreasePercent;
|
|
10403
10403
|
const price = (0, import_fusionamm_core4.sqrtPriceToPrice)(fusionPool.sqrtPrice, 1, 1);
|
|
10404
|
-
|
|
10405
|
-
|
|
10406
|
-
|
|
10407
|
-
|
|
10408
|
-
|
|
10409
|
-
|
|
10410
|
-
|
|
10411
|
-
);
|
|
10412
|
-
}
|
|
10404
|
+
let decreaseAmountInPositionToken = collateralToken == positionToken ? decreaseAmount : BigInt(
|
|
10405
|
+
Math.floor(collateralToken == 0 /* A */ ? Number(decreaseAmount) * price : Number(decreaseAmount) / price)
|
|
10406
|
+
);
|
|
10407
|
+
if (reduceOnly && decreaseAmountInPositionToken > positionAmount) {
|
|
10408
|
+
decreaseAmountInPositionToken = positionAmount;
|
|
10409
|
+
}
|
|
10410
|
+
if (decreaseAmountInPositionToken <= positionAmount) {
|
|
10413
10411
|
decreasePercent = Math.min(
|
|
10414
10412
|
Math.floor(Number(decreaseAmountInPositionToken) * HUNDRED_PERCENT / Number(positionAmount)),
|
|
10415
10413
|
HUNDRED_PERCENT
|
|
10416
10414
|
);
|
|
10415
|
+
estimatedAmount = positionAmount - decreaseAmountInPositionToken;
|
|
10417
10416
|
if (collateralToken == positionToken) {
|
|
10418
10417
|
if (positionDebt > 0) {
|
|
10419
10418
|
const swapOut = BigInt(Math.floor(Number(positionDebt) * decreasePercent / HUNDRED_PERCENT));
|
|
@@ -10431,12 +10430,11 @@ function getDecreaseSpotPositionQuote(args) {
|
|
|
10431
10430
|
tickArrays
|
|
10432
10431
|
).nextSqrtPrice;
|
|
10433
10432
|
}
|
|
10434
|
-
estimatedAmount = decreaseAmountInPositionToken <= positionAmount ? positionAmount - decreaseAmountInPositionToken : 0n;
|
|
10435
10433
|
} else {
|
|
10436
10434
|
decreasePercent = HUNDRED_PERCENT;
|
|
10437
10435
|
const posTokenIsA = positionToken == 0 /* A */;
|
|
10438
10436
|
newPositionToken = positionToken == 0 /* A */ ? 1 /* B */ : 0 /* A */;
|
|
10439
|
-
const increaseAmount =
|
|
10437
|
+
const increaseAmount = decreaseAmountInPositionToken - positionAmount;
|
|
10440
10438
|
if (positionToken == collateralToken) {
|
|
10441
10439
|
estimatedAmount = BigInt(
|
|
10442
10440
|
Math.floor(posTokenIsA ? Number(increaseAmount) * price : Number(increaseAmount) / price)
|
package/dist/index.mjs
CHANGED
|
@@ -10570,19 +10570,18 @@ function getDecreaseSpotPositionQuote(args) {
|
|
|
10570
10570
|
let newPositionToken = positionToken;
|
|
10571
10571
|
let decreasePercent;
|
|
10572
10572
|
const price = sqrtPriceToPrice(fusionPool.sqrtPrice, 1, 1);
|
|
10573
|
-
|
|
10574
|
-
|
|
10575
|
-
|
|
10576
|
-
|
|
10577
|
-
|
|
10578
|
-
|
|
10579
|
-
|
|
10580
|
-
);
|
|
10581
|
-
}
|
|
10573
|
+
let decreaseAmountInPositionToken = collateralToken == positionToken ? decreaseAmount : BigInt(
|
|
10574
|
+
Math.floor(collateralToken == 0 /* A */ ? Number(decreaseAmount) * price : Number(decreaseAmount) / price)
|
|
10575
|
+
);
|
|
10576
|
+
if (reduceOnly && decreaseAmountInPositionToken > positionAmount) {
|
|
10577
|
+
decreaseAmountInPositionToken = positionAmount;
|
|
10578
|
+
}
|
|
10579
|
+
if (decreaseAmountInPositionToken <= positionAmount) {
|
|
10582
10580
|
decreasePercent = Math.min(
|
|
10583
10581
|
Math.floor(Number(decreaseAmountInPositionToken) * HUNDRED_PERCENT / Number(positionAmount)),
|
|
10584
10582
|
HUNDRED_PERCENT
|
|
10585
10583
|
);
|
|
10584
|
+
estimatedAmount = positionAmount - decreaseAmountInPositionToken;
|
|
10586
10585
|
if (collateralToken == positionToken) {
|
|
10587
10586
|
if (positionDebt > 0) {
|
|
10588
10587
|
const swapOut = BigInt(Math.floor(Number(positionDebt) * decreasePercent / HUNDRED_PERCENT));
|
|
@@ -10600,12 +10599,11 @@ function getDecreaseSpotPositionQuote(args) {
|
|
|
10600
10599
|
tickArrays
|
|
10601
10600
|
).nextSqrtPrice;
|
|
10602
10601
|
}
|
|
10603
|
-
estimatedAmount = decreaseAmountInPositionToken <= positionAmount ? positionAmount - decreaseAmountInPositionToken : 0n;
|
|
10604
10602
|
} else {
|
|
10605
10603
|
decreasePercent = HUNDRED_PERCENT;
|
|
10606
10604
|
const posTokenIsA = positionToken == 0 /* A */;
|
|
10607
10605
|
newPositionToken = positionToken == 0 /* A */ ? 1 /* B */ : 0 /* A */;
|
|
10608
|
-
const increaseAmount =
|
|
10606
|
+
const increaseAmount = decreaseAmountInPositionToken - positionAmount;
|
|
10609
10607
|
if (positionToken == collateralToken) {
|
|
10610
10608
|
estimatedAmount = BigInt(
|
|
10611
10609
|
Math.floor(posTokenIsA ? Number(increaseAmount) * price : Number(increaseAmount) / price)
|
package/package.json
CHANGED