@crypticdot/defituna-client 3.1.13 → 3.1.15
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.d.mts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +5 -2
- package/dist/index.mjs +5 -2
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -6819,7 +6819,7 @@ type DecreaseSpotPositionQuoteResult = {
|
|
|
6819
6819
|
priceImpact: number;
|
|
6820
6820
|
};
|
|
6821
6821
|
declare function getDecreaseSpotPositionQuote(args: DecreaseSpotPositionQuoteArgs): DecreaseSpotPositionQuoteResult;
|
|
6822
|
-
declare function getPositionSizeByCollateralAndLeverage(collateral: bigint, leverage: number, swapFeeRate: number, protocolFeeRateOnCollateral: number, protocolFeeRate: number): bigint;
|
|
6822
|
+
declare function getPositionSizeByCollateralAndLeverage(collateral: bigint, leverage: number, swapCollateral: boolean, swapFeeRate: number, protocolFeeRateOnCollateral: number, protocolFeeRate: number): bigint;
|
|
6823
6823
|
declare function getLiquidationPrice(positionToken: PoolToken, amount: number, debt: number, liquidationThreshold: number): Number;
|
|
6824
6824
|
|
|
6825
6825
|
type IncreaseTunaLpPositionOrcaInstructionsArgs = Omit<IncreaseTunaLpPositionOrcaInstructionDataArgs, "remainingAccountsInfo" | "minAddedAmountA" | "minAddedAmountB"> & {
|
package/dist/index.d.ts
CHANGED
|
@@ -6819,7 +6819,7 @@ type DecreaseSpotPositionQuoteResult = {
|
|
|
6819
6819
|
priceImpact: number;
|
|
6820
6820
|
};
|
|
6821
6821
|
declare function getDecreaseSpotPositionQuote(args: DecreaseSpotPositionQuoteArgs): DecreaseSpotPositionQuoteResult;
|
|
6822
|
-
declare function getPositionSizeByCollateralAndLeverage(collateral: bigint, leverage: number, swapFeeRate: number, protocolFeeRateOnCollateral: number, protocolFeeRate: number): bigint;
|
|
6822
|
+
declare function getPositionSizeByCollateralAndLeverage(collateral: bigint, leverage: number, swapCollateral: boolean, swapFeeRate: number, protocolFeeRateOnCollateral: number, protocolFeeRate: number): bigint;
|
|
6823
6823
|
declare function getLiquidationPrice(positionToken: PoolToken, amount: number, debt: number, liquidationThreshold: number): Number;
|
|
6824
6824
|
|
|
6825
6825
|
type IncreaseTunaLpPositionOrcaInstructionsArgs = Omit<IncreaseTunaLpPositionOrcaInstructionDataArgs, "remainingAccountsInfo" | "minAddedAmountA" | "minAddedAmountB"> & {
|
package/dist/index.js
CHANGED
|
@@ -10429,7 +10429,7 @@ function getDecreaseSpotPositionQuote(args) {
|
|
|
10429
10429
|
const increaseAmount = decreaseAmountInPositionToken - positionAmount;
|
|
10430
10430
|
if (positionToken == collateralToken) {
|
|
10431
10431
|
estimatedAmount = BigInt(Math.floor(Number(increaseAmount) * positionToOppositeTokenPrice));
|
|
10432
|
-
borrow = BigInt(Math.floor(Number(increaseAmount) * (leverage - 1)
|
|
10432
|
+
borrow = BigInt(Math.floor(Number(increaseAmount) * (leverage - 1) / leverage));
|
|
10433
10433
|
const borrowWithFeesApplied = (0, import_fusionamm_core4.tryApplySwapFee)(applyTunaProtocolFee(borrow, protocolFeeRate), fusionPool.feeRate);
|
|
10434
10434
|
collateral = increaseAmount - borrowWithFeesApplied;
|
|
10435
10435
|
if (positionDebt > 0) {
|
|
@@ -10469,7 +10469,7 @@ function getDecreaseSpotPositionQuote(args) {
|
|
|
10469
10469
|
priceImpact
|
|
10470
10470
|
};
|
|
10471
10471
|
}
|
|
10472
|
-
function getPositionSizeByCollateralAndLeverage(collateral, leverage, swapFeeRate, protocolFeeRateOnCollateral, protocolFeeRate) {
|
|
10472
|
+
function getPositionSizeByCollateralAndLeverage(collateral, leverage, swapCollateral, swapFeeRate, protocolFeeRateOnCollateral, protocolFeeRate) {
|
|
10473
10473
|
if (leverage < 1) {
|
|
10474
10474
|
throw new Error("leverage must be greater or equal than 1.0");
|
|
10475
10475
|
}
|
|
@@ -10486,6 +10486,9 @@ function getPositionSizeByCollateralAndLeverage(collateral, leverage, swapFeeRat
|
|
|
10486
10486
|
);
|
|
10487
10487
|
borrow = applyTunaProtocolFee(borrow, protocolFeeRate);
|
|
10488
10488
|
borrow = (0, import_fusionamm_core4.tryApplySwapFee)(borrow, swapFeeRate);
|
|
10489
|
+
if (swapCollateral) {
|
|
10490
|
+
collateral = (0, import_fusionamm_core4.tryApplySwapFee)(collateral, swapFeeRate);
|
|
10491
|
+
}
|
|
10489
10492
|
return collateral + borrow;
|
|
10490
10493
|
}
|
|
10491
10494
|
function getLiquidationPrice(positionToken, amount, debt, liquidationThreshold) {
|
package/dist/index.mjs
CHANGED
|
@@ -10599,7 +10599,7 @@ function getDecreaseSpotPositionQuote(args) {
|
|
|
10599
10599
|
const increaseAmount = decreaseAmountInPositionToken - positionAmount;
|
|
10600
10600
|
if (positionToken == collateralToken) {
|
|
10601
10601
|
estimatedAmount = BigInt(Math.floor(Number(increaseAmount) * positionToOppositeTokenPrice));
|
|
10602
|
-
borrow = BigInt(Math.floor(Number(increaseAmount) * (leverage - 1)
|
|
10602
|
+
borrow = BigInt(Math.floor(Number(increaseAmount) * (leverage - 1) / leverage));
|
|
10603
10603
|
const borrowWithFeesApplied = tryApplySwapFee2(applyTunaProtocolFee(borrow, protocolFeeRate), fusionPool.feeRate);
|
|
10604
10604
|
collateral = increaseAmount - borrowWithFeesApplied;
|
|
10605
10605
|
if (positionDebt > 0) {
|
|
@@ -10639,7 +10639,7 @@ function getDecreaseSpotPositionQuote(args) {
|
|
|
10639
10639
|
priceImpact
|
|
10640
10640
|
};
|
|
10641
10641
|
}
|
|
10642
|
-
function getPositionSizeByCollateralAndLeverage(collateral, leverage, swapFeeRate, protocolFeeRateOnCollateral, protocolFeeRate) {
|
|
10642
|
+
function getPositionSizeByCollateralAndLeverage(collateral, leverage, swapCollateral, swapFeeRate, protocolFeeRateOnCollateral, protocolFeeRate) {
|
|
10643
10643
|
if (leverage < 1) {
|
|
10644
10644
|
throw new Error("leverage must be greater or equal than 1.0");
|
|
10645
10645
|
}
|
|
@@ -10656,6 +10656,9 @@ function getPositionSizeByCollateralAndLeverage(collateral, leverage, swapFeeRat
|
|
|
10656
10656
|
);
|
|
10657
10657
|
borrow = applyTunaProtocolFee(borrow, protocolFeeRate);
|
|
10658
10658
|
borrow = tryApplySwapFee2(borrow, swapFeeRate);
|
|
10659
|
+
if (swapCollateral) {
|
|
10660
|
+
collateral = tryApplySwapFee2(collateral, swapFeeRate);
|
|
10661
|
+
}
|
|
10659
10662
|
return collateral + borrow;
|
|
10660
10663
|
}
|
|
10661
10664
|
function getLiquidationPrice(positionToken, amount, debt, liquidationThreshold) {
|
package/package.json
CHANGED