@meteora-ag/dlmm 1.3.17-rc.3 → 1.4.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/README.md +158 -60
- package/dist/index.d.ts +3 -51
- package/dist/index.js +26 -57
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +26 -57
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
package/dist/index.mjs
CHANGED
|
@@ -6643,7 +6643,7 @@ function derivePosition(lbPair, base, lowerBinId, width, programId) {
|
|
|
6643
6643
|
lbPair.toBuffer(),
|
|
6644
6644
|
base.toBuffer(),
|
|
6645
6645
|
lowerBinIdBytes,
|
|
6646
|
-
new Uint8Array(width.
|
|
6646
|
+
new Uint8Array(width.toBuffer("le", 4))
|
|
6647
6647
|
],
|
|
6648
6648
|
programId
|
|
6649
6649
|
);
|
|
@@ -6698,12 +6698,9 @@ var Strategy = {
|
|
|
6698
6698
|
BidAskImBalanced: { bidAskImBalanced: {} }
|
|
6699
6699
|
};
|
|
6700
6700
|
var StrategyType = /* @__PURE__ */ ((StrategyType2) => {
|
|
6701
|
-
StrategyType2[StrategyType2["
|
|
6702
|
-
StrategyType2[StrategyType2["
|
|
6703
|
-
StrategyType2[StrategyType2["
|
|
6704
|
-
StrategyType2[StrategyType2["SpotBalanced"] = 3] = "SpotBalanced";
|
|
6705
|
-
StrategyType2[StrategyType2["CurveBalanced"] = 4] = "CurveBalanced";
|
|
6706
|
-
StrategyType2[StrategyType2["BidAskBalanced"] = 5] = "BidAskBalanced";
|
|
6701
|
+
StrategyType2[StrategyType2["Spot"] = 0] = "Spot";
|
|
6702
|
+
StrategyType2[StrategyType2["Curve"] = 1] = "Curve";
|
|
6703
|
+
StrategyType2[StrategyType2["BidAsk"] = 2] = "BidAsk";
|
|
6707
6704
|
return StrategyType2;
|
|
6708
6705
|
})(StrategyType || {});
|
|
6709
6706
|
var ActivationType = /* @__PURE__ */ ((ActivationType2) => {
|
|
@@ -7258,7 +7255,7 @@ function toWeightBidAsk(minBinId, maxBinId, activeId) {
|
|
|
7258
7255
|
function toAmountsBothSideByStrategy(activeId, binStep, minBinId, maxBinId, amountX, amountY, amountXInActiveBin, amountYInActiveBin, strategyType) {
|
|
7259
7256
|
const isSingleSideX = amountY.isZero();
|
|
7260
7257
|
switch (strategyType) {
|
|
7261
|
-
case 0 /*
|
|
7258
|
+
case 0 /* Spot */: {
|
|
7262
7259
|
if (activeId < minBinId || activeId > maxBinId) {
|
|
7263
7260
|
const weights = toWeightSpotBalanced(minBinId, maxBinId);
|
|
7264
7261
|
return toAmountBothSide(
|
|
@@ -7330,7 +7327,7 @@ function toAmountsBothSideByStrategy(activeId, binStep, minBinId, maxBinId, amou
|
|
|
7330
7327
|
}
|
|
7331
7328
|
return amountsInBin;
|
|
7332
7329
|
}
|
|
7333
|
-
case 1 /*
|
|
7330
|
+
case 1 /* Curve */: {
|
|
7334
7331
|
if (activeId < minBinId) {
|
|
7335
7332
|
let weights = toWeightDecendingOrder(minBinId, maxBinId);
|
|
7336
7333
|
return toAmountBothSide(
|
|
@@ -7414,7 +7411,7 @@ function toAmountsBothSideByStrategy(activeId, binStep, minBinId, maxBinId, amou
|
|
|
7414
7411
|
}
|
|
7415
7412
|
return amountsInBin;
|
|
7416
7413
|
}
|
|
7417
|
-
case 2 /*
|
|
7414
|
+
case 2 /* BidAsk */: {
|
|
7418
7415
|
if (activeId < minBinId) {
|
|
7419
7416
|
const weights = toWeightAscendingOrder(minBinId, maxBinId);
|
|
7420
7417
|
return toAmountBothSide(
|
|
@@ -7498,7 +7495,7 @@ function toAmountsBothSideByStrategy(activeId, binStep, minBinId, maxBinId, amou
|
|
|
7498
7495
|
}
|
|
7499
7496
|
return amountsInBin;
|
|
7500
7497
|
}
|
|
7501
|
-
case
|
|
7498
|
+
case 0 /* Spot */: {
|
|
7502
7499
|
let weights = toWeightSpotBalanced(minBinId, maxBinId);
|
|
7503
7500
|
return toAmountBothSide(
|
|
7504
7501
|
activeId,
|
|
@@ -7510,7 +7507,7 @@ function toAmountsBothSideByStrategy(activeId, binStep, minBinId, maxBinId, amou
|
|
|
7510
7507
|
weights
|
|
7511
7508
|
);
|
|
7512
7509
|
}
|
|
7513
|
-
case
|
|
7510
|
+
case 1 /* Curve */: {
|
|
7514
7511
|
let weights = toWeightCurve(minBinId, maxBinId, activeId);
|
|
7515
7512
|
return toAmountBothSide(
|
|
7516
7513
|
activeId,
|
|
@@ -7522,7 +7519,7 @@ function toAmountsBothSideByStrategy(activeId, binStep, minBinId, maxBinId, amou
|
|
|
7522
7519
|
weights
|
|
7523
7520
|
);
|
|
7524
7521
|
}
|
|
7525
|
-
case
|
|
7522
|
+
case 2 /* BidAsk */: {
|
|
7526
7523
|
let weights = toWeightBidAsk(minBinId, maxBinId, activeId);
|
|
7527
7524
|
return toAmountBothSide(
|
|
7528
7525
|
activeId,
|
|
@@ -7538,12 +7535,7 @@ function toAmountsBothSideByStrategy(activeId, binStep, minBinId, maxBinId, amou
|
|
|
7538
7535
|
}
|
|
7539
7536
|
function autoFillYByStrategy(activeId, binStep, amountX, amountXInActiveBin, amountYInActiveBin, minBinId, maxBinId, strategyType) {
|
|
7540
7537
|
switch (strategyType) {
|
|
7541
|
-
case 0 /*
|
|
7542
|
-
case 1 /* CurveImBalanced */:
|
|
7543
|
-
case 2 /* BidAskImBalanced */: {
|
|
7544
|
-
throw "Invalid Strategy Parameters";
|
|
7545
|
-
}
|
|
7546
|
-
case 3 /* SpotBalanced */: {
|
|
7538
|
+
case 0 /* Spot */: {
|
|
7547
7539
|
let weights = toWeightSpotBalanced(minBinId, maxBinId);
|
|
7548
7540
|
return autoFillYByWeight(
|
|
7549
7541
|
activeId,
|
|
@@ -7554,7 +7546,7 @@ function autoFillYByStrategy(activeId, binStep, amountX, amountXInActiveBin, amo
|
|
|
7554
7546
|
weights
|
|
7555
7547
|
);
|
|
7556
7548
|
}
|
|
7557
|
-
case
|
|
7549
|
+
case 1 /* Curve */: {
|
|
7558
7550
|
let weights = toWeightCurve(minBinId, maxBinId, activeId);
|
|
7559
7551
|
return autoFillYByWeight(
|
|
7560
7552
|
activeId,
|
|
@@ -7565,7 +7557,7 @@ function autoFillYByStrategy(activeId, binStep, amountX, amountXInActiveBin, amo
|
|
|
7565
7557
|
weights
|
|
7566
7558
|
);
|
|
7567
7559
|
}
|
|
7568
|
-
case
|
|
7560
|
+
case 2 /* BidAsk */: {
|
|
7569
7561
|
let weights = toWeightBidAsk(minBinId, maxBinId, activeId);
|
|
7570
7562
|
return autoFillYByWeight(
|
|
7571
7563
|
activeId,
|
|
@@ -7580,12 +7572,7 @@ function autoFillYByStrategy(activeId, binStep, amountX, amountXInActiveBin, amo
|
|
|
7580
7572
|
}
|
|
7581
7573
|
function autoFillXByStrategy(activeId, binStep, amountY, amountXInActiveBin, amountYInActiveBin, minBinId, maxBinId, strategyType) {
|
|
7582
7574
|
switch (strategyType) {
|
|
7583
|
-
case 0 /*
|
|
7584
|
-
case 1 /* CurveImBalanced */:
|
|
7585
|
-
case 2 /* BidAskImBalanced */: {
|
|
7586
|
-
throw "Invalid Strategy Parameters";
|
|
7587
|
-
}
|
|
7588
|
-
case 3 /* SpotBalanced */: {
|
|
7575
|
+
case 0 /* Spot */: {
|
|
7589
7576
|
let weights = toWeightSpotBalanced(minBinId, maxBinId);
|
|
7590
7577
|
return autoFillXByWeight(
|
|
7591
7578
|
activeId,
|
|
@@ -7596,7 +7583,7 @@ function autoFillXByStrategy(activeId, binStep, amountY, amountXInActiveBin, amo
|
|
|
7596
7583
|
weights
|
|
7597
7584
|
);
|
|
7598
7585
|
}
|
|
7599
|
-
case
|
|
7586
|
+
case 1 /* Curve */: {
|
|
7600
7587
|
let weights = toWeightCurve(minBinId, maxBinId, activeId);
|
|
7601
7588
|
return autoFillXByWeight(
|
|
7602
7589
|
activeId,
|
|
@@ -7607,7 +7594,7 @@ function autoFillXByStrategy(activeId, binStep, amountY, amountXInActiveBin, amo
|
|
|
7607
7594
|
weights
|
|
7608
7595
|
);
|
|
7609
7596
|
}
|
|
7610
|
-
case
|
|
7597
|
+
case 2 /* BidAsk */: {
|
|
7611
7598
|
let weights = toWeightBidAsk(minBinId, maxBinId, activeId);
|
|
7612
7599
|
return autoFillXByWeight(
|
|
7613
7600
|
activeId,
|
|
@@ -7628,31 +7615,7 @@ function toStrategyParameters({
|
|
|
7628
7615
|
}) {
|
|
7629
7616
|
const parameters = [singleSidedX ? 1 : 0, ...new Array(63).fill(0)];
|
|
7630
7617
|
switch (strategyType) {
|
|
7631
|
-
case
|
|
7632
|
-
return {
|
|
7633
|
-
minBinId,
|
|
7634
|
-
maxBinId,
|
|
7635
|
-
strategyType: { spotBalanced: {} },
|
|
7636
|
-
parameteres: Buffer.from(parameters).toJSON().data
|
|
7637
|
-
};
|
|
7638
|
-
}
|
|
7639
|
-
case 4 /* CurveBalanced */: {
|
|
7640
|
-
return {
|
|
7641
|
-
minBinId,
|
|
7642
|
-
maxBinId,
|
|
7643
|
-
strategyType: { curveBalanced: {} },
|
|
7644
|
-
parameteres: Buffer.from(parameters).toJSON().data
|
|
7645
|
-
};
|
|
7646
|
-
}
|
|
7647
|
-
case 5 /* BidAskBalanced */: {
|
|
7648
|
-
return {
|
|
7649
|
-
minBinId,
|
|
7650
|
-
maxBinId,
|
|
7651
|
-
strategyType: { bidAskBalanced: {} },
|
|
7652
|
-
parameteres: Buffer.from(parameters).toJSON().data
|
|
7653
|
-
};
|
|
7654
|
-
}
|
|
7655
|
-
case 0 /* SpotImBalanced */: {
|
|
7618
|
+
case 0 /* Spot */: {
|
|
7656
7619
|
return {
|
|
7657
7620
|
minBinId,
|
|
7658
7621
|
maxBinId,
|
|
@@ -7660,7 +7623,7 @@ function toStrategyParameters({
|
|
|
7660
7623
|
parameteres: Buffer.from(parameters).toJSON().data
|
|
7661
7624
|
};
|
|
7662
7625
|
}
|
|
7663
|
-
case 1 /*
|
|
7626
|
+
case 1 /* Curve */: {
|
|
7664
7627
|
return {
|
|
7665
7628
|
minBinId,
|
|
7666
7629
|
maxBinId,
|
|
@@ -7668,7 +7631,7 @@ function toStrategyParameters({
|
|
|
7668
7631
|
parameteres: Buffer.from(parameters).toJSON().data
|
|
7669
7632
|
};
|
|
7670
7633
|
}
|
|
7671
|
-
case 2 /*
|
|
7634
|
+
case 2 /* BidAsk */: {
|
|
7672
7635
|
return {
|
|
7673
7636
|
minBinId,
|
|
7674
7637
|
maxBinId,
|
|
@@ -11218,6 +11181,13 @@ var DLMM = class {
|
|
|
11218
11181
|
);
|
|
11219
11182
|
}
|
|
11220
11183
|
if (instructions.length > 1) {
|
|
11184
|
+
instructions.push(
|
|
11185
|
+
await getEstimatedComputeUnitIxWithBuffer(
|
|
11186
|
+
this.program.provider.connection,
|
|
11187
|
+
instructions,
|
|
11188
|
+
payer
|
|
11189
|
+
)
|
|
11190
|
+
);
|
|
11221
11191
|
initializeBinArraysAndPositionIxs.push(instructions);
|
|
11222
11192
|
instructions = [];
|
|
11223
11193
|
}
|
|
@@ -11283,7 +11253,6 @@ var DLMM = class {
|
|
|
11283
11253
|
]);
|
|
11284
11254
|
}
|
|
11285
11255
|
}
|
|
11286
|
-
console.log("let return");
|
|
11287
11256
|
return {
|
|
11288
11257
|
sendPositionOwnerTokenProveIxs,
|
|
11289
11258
|
initializeBinArraysAndPositionIxs,
|