@meteora-ag/dlmm 1.0.49-rc.2 → 1.0.50-rc.0
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.ts +1 -7
- package/dist/index.js +33 -33
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +33 -33
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -8485,17 +8485,6 @@ var DLMM = class {
|
|
|
8485
8485
|
);
|
|
8486
8486
|
return activeBinState;
|
|
8487
8487
|
}
|
|
8488
|
-
/**
|
|
8489
|
-
* The function get the price of a bin based on its bin ID.
|
|
8490
|
-
* @param {number} binId - The `binId` parameter is a number that represents the ID of a bin.
|
|
8491
|
-
* @returns {number} the calculated price of a bin based on the provided binId.
|
|
8492
|
-
*/
|
|
8493
|
-
getPriceOfBinByBinId(binId) {
|
|
8494
|
-
const binStepNum = new Decimal4(this.lbPair.binStep).div(
|
|
8495
|
-
new Decimal4(BASIS_POINT_MAX)
|
|
8496
|
-
);
|
|
8497
|
-
return new Decimal4(1).add(new Decimal4(binStepNum)).pow(new Decimal4(binId)).toString();
|
|
8498
|
-
}
|
|
8499
8488
|
/**
|
|
8500
8489
|
* The function get bin ID based on a given price and a boolean flag indicating whether to
|
|
8501
8490
|
* round down or up.
|
|
@@ -9704,9 +9693,15 @@ var DLMM = class {
|
|
|
9704
9693
|
}
|
|
9705
9694
|
}
|
|
9706
9695
|
}
|
|
9707
|
-
const startPrice =
|
|
9708
|
-
|
|
9709
|
-
|
|
9696
|
+
const startPrice = getPriceOfBinByBinId(
|
|
9697
|
+
startBinId.toNumber(),
|
|
9698
|
+
this.lbPair.binStep
|
|
9699
|
+
);
|
|
9700
|
+
const endPrice = getPriceOfBinByBinId(
|
|
9701
|
+
activeId.toNumber(),
|
|
9702
|
+
this.lbPair.binStep
|
|
9703
|
+
);
|
|
9704
|
+
const priceImpact = startPrice.sub(endPrice).abs().div(startPrice).mul(new Decimal4(100));
|
|
9710
9705
|
const maxInAmount = actualInAmount.mul(new BN9(BASIS_POINT_MAX).add(allowedSlippage)).div(new BN9(BASIS_POINT_MAX));
|
|
9711
9706
|
return {
|
|
9712
9707
|
inAmount: actualInAmount,
|
|
@@ -9810,6 +9805,10 @@ var DLMM = class {
|
|
|
9810
9805
|
);
|
|
9811
9806
|
const priceImpact = new Decimal4(actualOutAmount.toString()).sub(new Decimal4(outAmountWithoutSlippage.toString())).div(new Decimal4(outAmountWithoutSlippage.toString())).mul(new Decimal4(100));
|
|
9812
9807
|
const minOutAmount = actualOutAmount.mul(new BN9(BASIS_POINT_MAX).sub(allowedSlippage)).div(new BN9(BASIS_POINT_MAX));
|
|
9808
|
+
const endPrice = getPriceOfBinByBinId(
|
|
9809
|
+
activeId.toNumber(),
|
|
9810
|
+
this.lbPair.binStep
|
|
9811
|
+
);
|
|
9813
9812
|
return {
|
|
9814
9813
|
consumedInAmount: inAmount,
|
|
9815
9814
|
outAmount: actualOutAmount,
|
|
@@ -9817,7 +9816,8 @@ var DLMM = class {
|
|
|
9817
9816
|
protocolFee: protocolFeeAmount,
|
|
9818
9817
|
minOutAmount,
|
|
9819
9818
|
priceImpact,
|
|
9820
|
-
binArraysPubkey: [...binArraysForSwap.keys()]
|
|
9819
|
+
binArraysPubkey: [...binArraysForSwap.keys()],
|
|
9820
|
+
endPrice
|
|
9821
9821
|
};
|
|
9822
9822
|
}
|
|
9823
9823
|
async swapExactOut({
|
|
@@ -10738,7 +10738,7 @@ var DLMM = class {
|
|
|
10738
10738
|
}).add(syncWithMarketPriceTx);
|
|
10739
10739
|
}
|
|
10740
10740
|
async getMaxPriceInBinArrays(binArrayAccounts) {
|
|
10741
|
-
const sortedBinArrays =
|
|
10741
|
+
const sortedBinArrays = binArrayAccounts.sort(
|
|
10742
10742
|
({ account: { index: indexA } }, { account: { index: indexB } }) => indexA.toNumber() - indexB.toNumber()
|
|
10743
10743
|
);
|
|
10744
10744
|
let count = sortedBinArrays.length - 1;
|
|
@@ -10746,7 +10746,7 @@ var DLMM = class {
|
|
|
10746
10746
|
while (count >= 0) {
|
|
10747
10747
|
const binArray = sortedBinArrays[count];
|
|
10748
10748
|
if (binArray) {
|
|
10749
|
-
const bins = binArray.account.bins;
|
|
10749
|
+
const bins = binArray.account.bins.reverse();
|
|
10750
10750
|
if (bins.every(({ amountX }) => amountX.isZero())) {
|
|
10751
10751
|
count--;
|
|
10752
10752
|
} else {
|
|
@@ -10988,10 +10988,10 @@ var DLMM = class {
|
|
|
10988
10988
|
binArray.bins.forEach((bin, idx) => {
|
|
10989
10989
|
const binId = lowerBinIdForBinArray.toNumber() + idx;
|
|
10990
10990
|
if (binId >= lowerBinId && binId <= upperBinId) {
|
|
10991
|
-
const pricePerLamport =
|
|
10992
|
-
|
|
10993
|
-
|
|
10994
|
-
);
|
|
10991
|
+
const pricePerLamport = getPriceOfBinByBinId(
|
|
10992
|
+
binId,
|
|
10993
|
+
lbPair.binStep
|
|
10994
|
+
).toString();
|
|
10995
10995
|
bins.push({
|
|
10996
10996
|
binId,
|
|
10997
10997
|
xAmount: bin.amountX,
|
|
@@ -11012,10 +11012,10 @@ var DLMM = class {
|
|
|
11012
11012
|
binArray.bins.forEach((bin, idx) => {
|
|
11013
11013
|
const binId = lowerBinIdForBinArray.toNumber() + idx;
|
|
11014
11014
|
if (binId >= lowerBinId && binId <= upperBinId) {
|
|
11015
|
-
const pricePerLamport =
|
|
11016
|
-
|
|
11017
|
-
|
|
11018
|
-
);
|
|
11015
|
+
const pricePerLamport = getPriceOfBinByBinId(
|
|
11016
|
+
binId,
|
|
11017
|
+
lbPair.binStep
|
|
11018
|
+
).toString();
|
|
11019
11019
|
bins.push({
|
|
11020
11020
|
binId,
|
|
11021
11021
|
xAmount: bin.amountX,
|
|
@@ -11031,10 +11031,6 @@ var DLMM = class {
|
|
|
11031
11031
|
}
|
|
11032
11032
|
return bins;
|
|
11033
11033
|
}
|
|
11034
|
-
static getPriceOfBinByBinId(binStep, binId) {
|
|
11035
|
-
const binStepNum = new Decimal4(binStep).div(new Decimal4(BASIS_POINT_MAX));
|
|
11036
|
-
return new Decimal4(1).add(new Decimal4(binStepNum)).pow(new Decimal4(binId)).toString();
|
|
11037
|
-
}
|
|
11038
11034
|
/** Private method */
|
|
11039
11035
|
processXYAmountDistribution(xYAmountDistribution) {
|
|
11040
11036
|
let currentBinId = null;
|
|
@@ -11073,8 +11069,6 @@ var DLMM = class {
|
|
|
11073
11069
|
const [lowerBinId2, upperBinId2] = getBinArrayLowerUpperBinId(lowerBinArrayIndex);
|
|
11074
11070
|
const binArrayBins = [];
|
|
11075
11071
|
for (let i = lowerBinId2.toNumber(); i <= upperBinId2.toNumber(); i++) {
|
|
11076
|
-
const binId = new BN9(i);
|
|
11077
|
-
const pricePerLamport = this.getPriceOfBinByBinId(binId.toNumber());
|
|
11078
11072
|
binArrayBins.push({
|
|
11079
11073
|
amountX: new BN9(0),
|
|
11080
11074
|
amountY: new BN9(0),
|
|
@@ -11099,7 +11093,10 @@ var DLMM = class {
|
|
|
11099
11093
|
binArray.bins.forEach((bin, idx) => {
|
|
11100
11094
|
const binId = lowerBinIdForBinArray.toNumber() + idx;
|
|
11101
11095
|
if (binId >= lowerBinId && binId <= upperBinId) {
|
|
11102
|
-
const pricePerLamport =
|
|
11096
|
+
const pricePerLamport = getPriceOfBinByBinId(
|
|
11097
|
+
binId,
|
|
11098
|
+
this.lbPair.binStep
|
|
11099
|
+
).toString();
|
|
11103
11100
|
bins.push({
|
|
11104
11101
|
binId,
|
|
11105
11102
|
xAmount: bin.amountX,
|
|
@@ -11140,7 +11137,10 @@ var DLMM = class {
|
|
|
11140
11137
|
binArray.bins.forEach((bin, idx) => {
|
|
11141
11138
|
const binId = lowerBinIdForBinArray.toNumber() + idx;
|
|
11142
11139
|
if (binId >= lowerBinId && binId <= upperBinId) {
|
|
11143
|
-
const pricePerLamport =
|
|
11140
|
+
const pricePerLamport = getPriceOfBinByBinId(
|
|
11141
|
+
binId,
|
|
11142
|
+
this.lbPair.binStep
|
|
11143
|
+
).toString();
|
|
11144
11144
|
bins.push({
|
|
11145
11145
|
binId,
|
|
11146
11146
|
xAmount: bin.amountX,
|