@meteora-ag/dlmm 1.3.6 → 1.3.8-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 +14 -20
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +15 -21
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -7621,7 +7621,7 @@ var getOrCreateATAInstruction = async (connection, tokenMint, owner, payer = own
|
|
|
7621
7621
|
return { ataPubKey: toAccount, ix: void 0 };
|
|
7622
7622
|
} catch (e) {
|
|
7623
7623
|
if (e instanceof _spltoken.TokenAccountNotFoundError || e instanceof _spltoken.TokenInvalidAccountOwnerError) {
|
|
7624
|
-
const ix = _spltoken.
|
|
7624
|
+
const ix = _spltoken.createAssociatedTokenAccountIdempotentInstruction.call(void 0,
|
|
7625
7625
|
payer,
|
|
7626
7626
|
toAccount,
|
|
7627
7627
|
owner,
|
|
@@ -10092,6 +10092,7 @@ var DLMM = class {
|
|
|
10092
10092
|
let actualOutAmount = new (0, _anchor.BN)(0);
|
|
10093
10093
|
let feeAmount = new (0, _anchor.BN)(0);
|
|
10094
10094
|
let protocolFeeAmount = new (0, _anchor.BN)(0);
|
|
10095
|
+
let lastFilledActiveBinId = activeId;
|
|
10095
10096
|
while (!inAmountLeft.isZero()) {
|
|
10096
10097
|
let binArrayAccountToSwap = findNextBinArrayWithLiquidity(
|
|
10097
10098
|
swapForY,
|
|
@@ -10137,6 +10138,7 @@ var DLMM = class {
|
|
|
10137
10138
|
if (!startBin) {
|
|
10138
10139
|
startBin = bin;
|
|
10139
10140
|
}
|
|
10141
|
+
lastFilledActiveBinId = activeId;
|
|
10140
10142
|
}
|
|
10141
10143
|
}
|
|
10142
10144
|
if (!inAmountLeft.isZero()) {
|
|
@@ -10164,7 +10166,7 @@ var DLMM = class {
|
|
|
10164
10166
|
const priceImpact = new (0, _decimaljs2.default)(actualOutAmount.toString()).sub(new (0, _decimaljs2.default)(outAmountWithoutSlippage.toString())).div(new (0, _decimaljs2.default)(outAmountWithoutSlippage.toString())).mul(new (0, _decimaljs2.default)(100));
|
|
10165
10167
|
const minOutAmount = actualOutAmount.mul(new (0, _anchor.BN)(BASIS_POINT_MAX).sub(allowedSlippage)).div(new (0, _anchor.BN)(BASIS_POINT_MAX));
|
|
10166
10168
|
const endPrice = getPriceOfBinByBinId(
|
|
10167
|
-
|
|
10169
|
+
lastFilledActiveBinId.toNumber(),
|
|
10168
10170
|
this.lbPair.binStep
|
|
10169
10171
|
);
|
|
10170
10172
|
return {
|
|
@@ -10281,7 +10283,6 @@ var DLMM = class {
|
|
|
10281
10283
|
priceImpact,
|
|
10282
10284
|
binArraysPubkey
|
|
10283
10285
|
}) {
|
|
10284
|
-
const { tokenXMint, tokenYMint, reserveX, reserveY, activeId, oracle } = await this.program.account.lbPair.fetch(lbPair);
|
|
10285
10286
|
const preInstructions = [];
|
|
10286
10287
|
const postInstructions = [];
|
|
10287
10288
|
const [
|
|
@@ -10315,9 +10316,6 @@ var DLMM = class {
|
|
|
10315
10316
|
const closeWrappedSOLIx = await unwrapSOLInstruction(user);
|
|
10316
10317
|
closeWrappedSOLIx && postInstructions.push(closeWrappedSOLIx);
|
|
10317
10318
|
}
|
|
10318
|
-
let swapForY = true;
|
|
10319
|
-
if (outToken.equals(tokenXMint))
|
|
10320
|
-
swapForY = false;
|
|
10321
10319
|
const binArrays = binArraysPubkey.map((pubkey) => {
|
|
10322
10320
|
return {
|
|
10323
10321
|
isSigner: false,
|
|
@@ -10331,17 +10329,17 @@ var DLMM = class {
|
|
|
10331
10329
|
priceImpact.toNumber()
|
|
10332
10330
|
).accounts({
|
|
10333
10331
|
lbPair,
|
|
10334
|
-
reserveX,
|
|
10335
|
-
reserveY,
|
|
10336
|
-
tokenXMint,
|
|
10337
|
-
tokenYMint,
|
|
10332
|
+
reserveX: this.lbPair.reserveX,
|
|
10333
|
+
reserveY: this.lbPair.reserveY,
|
|
10334
|
+
tokenXMint: this.lbPair.tokenXMint,
|
|
10335
|
+
tokenYMint: this.lbPair.tokenYMint,
|
|
10338
10336
|
tokenXProgram: _spltoken.TOKEN_PROGRAM_ID,
|
|
10339
10337
|
tokenYProgram: _spltoken.TOKEN_PROGRAM_ID,
|
|
10340
10338
|
user,
|
|
10341
10339
|
userTokenIn,
|
|
10342
10340
|
userTokenOut,
|
|
10343
10341
|
binArrayBitmapExtension: this.binArrayBitmapExtension ? this.binArrayBitmapExtension.publicKey : null,
|
|
10344
|
-
oracle,
|
|
10342
|
+
oracle: this.lbPair.oracle,
|
|
10345
10343
|
hostFeeIn: null
|
|
10346
10344
|
}).remainingAccounts(binArrays).instruction();
|
|
10347
10345
|
const instructions = [...preInstructions, swapIx, ...postInstructions];
|
|
@@ -10379,7 +10377,6 @@ var DLMM = class {
|
|
|
10379
10377
|
user,
|
|
10380
10378
|
binArraysPubkey
|
|
10381
10379
|
}) {
|
|
10382
|
-
const { tokenXMint, tokenYMint, reserveX, reserveY, activeId, oracle } = await this.program.account.lbPair.fetch(lbPair);
|
|
10383
10380
|
const preInstructions = [];
|
|
10384
10381
|
const postInstructions = [];
|
|
10385
10382
|
const [
|
|
@@ -10413,9 +10410,6 @@ var DLMM = class {
|
|
|
10413
10410
|
const closeWrappedSOLIx = await unwrapSOLInstruction(user);
|
|
10414
10411
|
closeWrappedSOLIx && postInstructions.push(closeWrappedSOLIx);
|
|
10415
10412
|
}
|
|
10416
|
-
let swapForY = true;
|
|
10417
|
-
if (outToken.equals(tokenXMint))
|
|
10418
|
-
swapForY = false;
|
|
10419
10413
|
const binArrays = binArraysPubkey.map((pubkey) => {
|
|
10420
10414
|
return {
|
|
10421
10415
|
isSigner: false,
|
|
@@ -10425,10 +10419,10 @@ var DLMM = class {
|
|
|
10425
10419
|
});
|
|
10426
10420
|
const swapIx = await this.program.methods.swap(inAmount, minOutAmount).accounts({
|
|
10427
10421
|
lbPair,
|
|
10428
|
-
reserveX,
|
|
10429
|
-
reserveY,
|
|
10430
|
-
tokenXMint,
|
|
10431
|
-
tokenYMint,
|
|
10422
|
+
reserveX: this.lbPair.reserveX,
|
|
10423
|
+
reserveY: this.lbPair.reserveY,
|
|
10424
|
+
tokenXMint: this.lbPair.tokenXMint,
|
|
10425
|
+
tokenYMint: this.lbPair.tokenYMint,
|
|
10432
10426
|
tokenXProgram: _spltoken.TOKEN_PROGRAM_ID,
|
|
10433
10427
|
// dont use 2022 first; lack familiarity
|
|
10434
10428
|
tokenYProgram: _spltoken.TOKEN_PROGRAM_ID,
|
|
@@ -10437,7 +10431,7 @@ var DLMM = class {
|
|
|
10437
10431
|
userTokenIn,
|
|
10438
10432
|
userTokenOut,
|
|
10439
10433
|
binArrayBitmapExtension: this.binArrayBitmapExtension ? this.binArrayBitmapExtension.publicKey : null,
|
|
10440
|
-
oracle,
|
|
10434
|
+
oracle: this.lbPair.oracle,
|
|
10441
10435
|
hostFeeIn: null
|
|
10442
10436
|
}).remainingAccounts(binArrays).instruction();
|
|
10443
10437
|
const instructions = [...preInstructions, swapIx, ...postInstructions];
|