@meteora-ag/dlmm 1.5.0-test.0 → 1.5.1-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.js +33 -7
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +33 -7
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -8530,6 +8530,24 @@ function getPositionCount(minBinId, maxBinId) {
|
|
|
8530
8530
|
const positionCount = binDelta.div(MAX_BIN_PER_POSITION);
|
|
8531
8531
|
return positionCount.add(new (0, _anchor.BN)(1));
|
|
8532
8532
|
}
|
|
8533
|
+
function findOptimumDecompressMultiplier(binAmount, tokenDecimal) {
|
|
8534
|
+
let multiplier = new (0, _anchor.BN)(10).pow(tokenDecimal);
|
|
8535
|
+
while (!multiplier.isZero()) {
|
|
8536
|
+
let found = true;
|
|
8537
|
+
for (const [_binId, amount] of binAmount) {
|
|
8538
|
+
const compressedAmount = amount.div(multiplier);
|
|
8539
|
+
if (compressedAmount.isZero()) {
|
|
8540
|
+
multiplier = multiplier.div(new (0, _anchor.BN)(10));
|
|
8541
|
+
found = false;
|
|
8542
|
+
break;
|
|
8543
|
+
}
|
|
8544
|
+
}
|
|
8545
|
+
if (found) {
|
|
8546
|
+
return multiplier;
|
|
8547
|
+
}
|
|
8548
|
+
}
|
|
8549
|
+
throw "Couldn't find optimum multiplier";
|
|
8550
|
+
}
|
|
8533
8551
|
function compressBinAmount(binAmount, multiplier) {
|
|
8534
8552
|
const compressedBinAmount = /* @__PURE__ */ new Map();
|
|
8535
8553
|
let totalAmount = new (0, _anchor.BN)(0);
|
|
@@ -8566,6 +8584,9 @@ function generateAmountForBinRange(amount, binStep, tokenXDecimal, tokenYDecimal
|
|
|
8566
8584
|
maxPrice,
|
|
8567
8585
|
k
|
|
8568
8586
|
);
|
|
8587
|
+
if (binAmount.isZero()) {
|
|
8588
|
+
throw "bin amount is zero";
|
|
8589
|
+
}
|
|
8569
8590
|
binAmounts.set(i, binAmount);
|
|
8570
8591
|
}
|
|
8571
8592
|
return binAmounts;
|
|
@@ -10359,9 +10380,11 @@ var DLMM = class {
|
|
|
10359
10380
|
*/
|
|
10360
10381
|
static async create(connection, dlmm, opt) {
|
|
10361
10382
|
const cluster = _optionalChain([opt, 'optionalAccess', _38 => _38.cluster]) || "mainnet-beta";
|
|
10362
|
-
const provider = new (0, _anchor.AnchorProvider)(
|
|
10363
|
-
|
|
10364
|
-
|
|
10383
|
+
const provider = new (0, _anchor.AnchorProvider)(
|
|
10384
|
+
connection,
|
|
10385
|
+
{},
|
|
10386
|
+
_anchor.AnchorProvider.defaultOptions()
|
|
10387
|
+
);
|
|
10365
10388
|
const program = new (0, _anchor.Program)(
|
|
10366
10389
|
IDL,
|
|
10367
10390
|
_nullishCoalesce(_optionalChain([opt, 'optionalAccess', _39 => _39.programId]), () => ( LBCLMM_PROGRAM_IDS[cluster])),
|
|
@@ -13917,7 +13940,10 @@ var DLMM = class {
|
|
|
13917
13940
|
maxBinId,
|
|
13918
13941
|
k
|
|
13919
13942
|
);
|
|
13920
|
-
const decompressMultiplier =
|
|
13943
|
+
const decompressMultiplier = findOptimumDecompressMultiplier(
|
|
13944
|
+
binDepositAmount,
|
|
13945
|
+
new (0, _anchor.BN)(this.tokenX.mint.decimals)
|
|
13946
|
+
);
|
|
13921
13947
|
let { compressedBinAmount, compressionLoss } = compressBinAmount(
|
|
13922
13948
|
binDepositAmount,
|
|
13923
13949
|
decompressMultiplier
|
|
@@ -14080,7 +14106,7 @@ var DLMM = class {
|
|
|
14080
14106
|
}).instruction()
|
|
14081
14107
|
);
|
|
14082
14108
|
}
|
|
14083
|
-
if (instructions.length >
|
|
14109
|
+
if (instructions.length > 0) {
|
|
14084
14110
|
initializeBinArraysAndPositionIxs.push(instructions);
|
|
14085
14111
|
instructions = [];
|
|
14086
14112
|
}
|
|
@@ -14442,8 +14468,8 @@ var DLMM = class {
|
|
|
14442
14468
|
tokenXMint: this.lbPair.tokenXMint,
|
|
14443
14469
|
tokenYMint: this.lbPair.tokenYMint,
|
|
14444
14470
|
sender: operator,
|
|
14445
|
-
tokenXProgram:
|
|
14446
|
-
tokenYProgram:
|
|
14471
|
+
tokenXProgram: this.tokenX.owner,
|
|
14472
|
+
tokenYProgram: this.tokenY.owner
|
|
14447
14473
|
}).remainingAccounts([
|
|
14448
14474
|
...transferHookAccountMetas,
|
|
14449
14475
|
{
|