@crypticdot/defituna-client 3.1.8 → 3.1.10

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 CHANGED
@@ -10439,7 +10439,7 @@ function getDecreaseSpotPositionQuote(args) {
10439
10439
  estimatedAmount = BigInt(
10440
10440
  Math.floor(posTokenIsA ? Number(increaseAmount) * price : Number(increaseAmount) / price)
10441
10441
  );
10442
- collateral = leverage > 1 ? BigInt(Math.floor(Number(increaseAmount) / leverage)) : estimatedAmount;
10442
+ collateral = BigInt(Math.floor(Number(increaseAmount) / leverage));
10443
10443
  borrow = increaseAmount - collateral;
10444
10444
  if (positionDebt > 0) {
10445
10445
  const swapQuote = (0, import_fusionamm_core4.swapQuoteByOutputToken)(positionDebt, !posTokenIsA, 0, fusionPool, tickArrays);
@@ -10448,24 +10448,19 @@ function getDecreaseSpotPositionQuote(args) {
10448
10448
  swapInputAmount += increaseAmount;
10449
10449
  nextSqrtPrice = (0, import_fusionamm_core4.swapQuoteByInputToken)(swapInputAmount, posTokenIsA, 0, fusionPool, tickArrays).nextSqrtPrice;
10450
10450
  } else {
10451
- if (leverage > 1) {
10452
- const collateralInPositionToken = BigInt(Math.floor(Number(increaseAmount) / leverage));
10453
- borrow = increaseAmount - collateralInPositionToken;
10454
- collateral = BigInt(
10455
- Math.floor(
10456
- positionToken == 0 /* A */ ? Number(collateralInPositionToken) * price : Number(collateralInPositionToken) / price
10457
- )
10458
- );
10459
- const borrowInNewPositionToken = BigInt(
10460
- Math.floor(newPositionToken == 1 /* B */ ? Number(borrow) * price : Number(borrow) / price)
10461
- );
10462
- estimatedAmount = collateral + borrowInNewPositionToken;
10463
- swapInputAmount = positionAmount + borrow;
10464
- nextSqrtPrice = (0, import_fusionamm_core4.swapQuoteByInputToken)(swapInputAmount, posTokenIsA, 0, fusionPool, tickArrays).nextSqrtPrice;
10465
- } else {
10466
- collateral = increaseAmount;
10467
- borrow = 0n;
10468
- }
10451
+ const collateralInPositionToken = BigInt(Math.floor(Number(increaseAmount) / leverage));
10452
+ borrow = increaseAmount - collateralInPositionToken;
10453
+ collateral = BigInt(
10454
+ Math.floor(
10455
+ positionToken == 0 /* A */ ? Number(collateralInPositionToken) * price : Number(collateralInPositionToken) / price
10456
+ )
10457
+ );
10458
+ const borrowInNewPositionToken = BigInt(
10459
+ Math.floor(newPositionToken == 1 /* B */ ? Number(borrow) * price : Number(borrow) / price)
10460
+ );
10461
+ estimatedAmount = collateral + borrowInNewPositionToken;
10462
+ swapInputAmount = positionAmount + borrow;
10463
+ nextSqrtPrice = (0, import_fusionamm_core4.swapQuoteByInputToken)(swapInputAmount, posTokenIsA, 0, fusionPool, tickArrays).nextSqrtPrice;
10469
10464
  }
10470
10465
  }
10471
10466
  const collateralExcludingFee = collateral;
package/dist/index.mjs CHANGED
@@ -10608,7 +10608,7 @@ function getDecreaseSpotPositionQuote(args) {
10608
10608
  estimatedAmount = BigInt(
10609
10609
  Math.floor(posTokenIsA ? Number(increaseAmount) * price : Number(increaseAmount) / price)
10610
10610
  );
10611
- collateral = leverage > 1 ? BigInt(Math.floor(Number(increaseAmount) / leverage)) : estimatedAmount;
10611
+ collateral = BigInt(Math.floor(Number(increaseAmount) / leverage));
10612
10612
  borrow = increaseAmount - collateral;
10613
10613
  if (positionDebt > 0) {
10614
10614
  const swapQuote = swapQuoteByOutputToken(positionDebt, !posTokenIsA, 0, fusionPool, tickArrays);
@@ -10617,24 +10617,19 @@ function getDecreaseSpotPositionQuote(args) {
10617
10617
  swapInputAmount += increaseAmount;
10618
10618
  nextSqrtPrice = swapQuoteByInputToken(swapInputAmount, posTokenIsA, 0, fusionPool, tickArrays).nextSqrtPrice;
10619
10619
  } else {
10620
- if (leverage > 1) {
10621
- const collateralInPositionToken = BigInt(Math.floor(Number(increaseAmount) / leverage));
10622
- borrow = increaseAmount - collateralInPositionToken;
10623
- collateral = BigInt(
10624
- Math.floor(
10625
- positionToken == 0 /* A */ ? Number(collateralInPositionToken) * price : Number(collateralInPositionToken) / price
10626
- )
10627
- );
10628
- const borrowInNewPositionToken = BigInt(
10629
- Math.floor(newPositionToken == 1 /* B */ ? Number(borrow) * price : Number(borrow) / price)
10630
- );
10631
- estimatedAmount = collateral + borrowInNewPositionToken;
10632
- swapInputAmount = positionAmount + borrow;
10633
- nextSqrtPrice = swapQuoteByInputToken(swapInputAmount, posTokenIsA, 0, fusionPool, tickArrays).nextSqrtPrice;
10634
- } else {
10635
- collateral = increaseAmount;
10636
- borrow = 0n;
10637
- }
10620
+ const collateralInPositionToken = BigInt(Math.floor(Number(increaseAmount) / leverage));
10621
+ borrow = increaseAmount - collateralInPositionToken;
10622
+ collateral = BigInt(
10623
+ Math.floor(
10624
+ positionToken == 0 /* A */ ? Number(collateralInPositionToken) * price : Number(collateralInPositionToken) / price
10625
+ )
10626
+ );
10627
+ const borrowInNewPositionToken = BigInt(
10628
+ Math.floor(newPositionToken == 1 /* B */ ? Number(borrow) * price : Number(borrow) / price)
10629
+ );
10630
+ estimatedAmount = collateral + borrowInNewPositionToken;
10631
+ swapInputAmount = positionAmount + borrow;
10632
+ nextSqrtPrice = swapQuoteByInputToken(swapInputAmount, posTokenIsA, 0, fusionPool, tickArrays).nextSqrtPrice;
10638
10633
  }
10639
10634
  }
10640
10635
  const collateralExcludingFee = collateral;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@crypticdot/defituna-client",
3
3
  "description": "Typescript client to interact with DefiTuna's on-chain program.",
4
- "version": "3.1.8",
4
+ "version": "3.1.10",
5
5
  "private": false,
6
6
  "license": "SEE LICENSE IN LICENSE",
7
7
  "main": "./dist/index.js",