@meteora-ag/dlmm 1.6.0-rc.24 → 1.6.0-rc.26

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 CHANGED
@@ -13567,7 +13567,7 @@ function createProgram(connection, opt) {
13567
13567
  _anchor.AnchorProvider.defaultOptions()
13568
13568
  );
13569
13569
  return new (0, _anchor.Program)(
13570
- { ...dlmm_default, address: LBCLMM_PROGRAM_IDS[cluster] },
13570
+ { ...dlmm_default, address: _nullishCoalesce(_optionalChain([opt, 'optionalAccess', _44 => _44.programId]), () => ( LBCLMM_PROGRAM_IDS[cluster])) },
13571
13571
  provider
13572
13572
  );
13573
13573
  }
@@ -13575,9 +13575,9 @@ function decodeAccount(program, accountName, buffer) {
13575
13575
  return program.coder.accounts.decode(accountName, buffer);
13576
13576
  }
13577
13577
  function getAccountDiscriminator(accountName) {
13578
- return _optionalChain([dlmm_default, 'access', _44 => _44.accounts, 'access', _45 => _45.find, 'call', _46 => _46(
13578
+ return _optionalChain([dlmm_default, 'access', _45 => _45.accounts, 'access', _46 => _46.find, 'call', _47 => _47(
13579
13579
  (acc) => acc.name.toLowerCase() === accountName.toLowerCase()
13580
- ), 'optionalAccess', _47 => _47.discriminator]);
13580
+ ), 'optionalAccess', _48 => _48.discriminator]);
13581
13581
  }
13582
13582
  function capSlippagePercentage(slippage) {
13583
13583
  if (slippage > 100) {
@@ -14124,7 +14124,7 @@ var DLMM = class {
14124
14124
  connection,
14125
14125
  accountsToFetch
14126
14126
  );
14127
- const lbPairAccountInfoBuffer = _optionalChain([accountsInfo, 'access', _48 => _48[0], 'optionalAccess', _49 => _49.data]);
14127
+ const lbPairAccountInfoBuffer = _optionalChain([accountsInfo, 'access', _49 => _49[0], 'optionalAccess', _50 => _50.data]);
14128
14128
  if (!lbPairAccountInfoBuffer)
14129
14129
  throw new Error(`LB Pair account ${dlmm.toBase58()} not found`);
14130
14130
  const lbPairAccInfo = decodeAccount(
@@ -14132,7 +14132,7 @@ var DLMM = class {
14132
14132
  "lbPair",
14133
14133
  lbPairAccountInfoBuffer
14134
14134
  );
14135
- const binArrayBitMapAccountInfoBuffer = _optionalChain([accountsInfo, 'access', _50 => _50[1], 'optionalAccess', _51 => _51.data]);
14135
+ const binArrayBitMapAccountInfoBuffer = _optionalChain([accountsInfo, 'access', _51 => _51[1], 'optionalAccess', _52 => _52.data]);
14136
14136
  let binArrayBitMapExtensionAccInfo = null;
14137
14137
  if (binArrayBitMapAccountInfoBuffer) {
14138
14138
  binArrayBitMapExtensionAccInfo = decodeAccount(
@@ -14141,7 +14141,7 @@ var DLMM = class {
14141
14141
  binArrayBitMapAccountInfoBuffer
14142
14142
  );
14143
14143
  }
14144
- const clockAccountInfoBuffer = _optionalChain([accountsInfo, 'access', _52 => _52[2], 'optionalAccess', _53 => _53.data]);
14144
+ const clockAccountInfoBuffer = _optionalChain([accountsInfo, 'access', _53 => _53[2], 'optionalAccess', _54 => _54.data]);
14145
14145
  if (!clockAccountInfoBuffer)
14146
14146
  throw new Error(`Clock account not found`);
14147
14147
  const clock = ClockLayout.decode(clockAccountInfoBuffer);
@@ -14294,14 +14294,14 @@ var DLMM = class {
14294
14294
  accountsToFetch
14295
14295
  );
14296
14296
  const clockAccount = accountsInfo.pop();
14297
- const clockAccountInfoBuffer = _optionalChain([clockAccount, 'optionalAccess', _54 => _54.data]);
14297
+ const clockAccountInfoBuffer = _optionalChain([clockAccount, 'optionalAccess', _55 => _55.data]);
14298
14298
  if (!clockAccountInfoBuffer)
14299
14299
  throw new Error(`Clock account not found`);
14300
14300
  const clock = ClockLayout.decode(clockAccountInfoBuffer);
14301
14301
  const lbPairArraysMap = /* @__PURE__ */ new Map();
14302
14302
  for (let i = 0; i < dlmmList.length; i++) {
14303
14303
  const lbPairPubKey = dlmmList[i];
14304
- const lbPairAccountInfoBuffer = _optionalChain([accountsInfo, 'access', _55 => _55[i], 'optionalAccess', _56 => _56.data]);
14304
+ const lbPairAccountInfoBuffer = _optionalChain([accountsInfo, 'access', _56 => _56[i], 'optionalAccess', _57 => _57.data]);
14305
14305
  if (!lbPairAccountInfoBuffer)
14306
14306
  throw new Error(`LB Pair account ${lbPairPubKey.toBase58()} not found`);
14307
14307
  const lbPairAccInfo = decodeAccount(
@@ -14315,7 +14315,7 @@ var DLMM = class {
14315
14315
  for (let i = dlmmList.length; i < accountsInfo.length; i++) {
14316
14316
  const index = i - dlmmList.length;
14317
14317
  const lbPairPubkey = dlmmList[index];
14318
- const binArrayBitMapAccountInfoBuffer = _optionalChain([accountsInfo, 'access', _57 => _57[i], 'optionalAccess', _58 => _58.data]);
14318
+ const binArrayBitMapAccountInfoBuffer = _optionalChain([accountsInfo, 'access', _58 => _58[i], 'optionalAccess', _59 => _59.data]);
14319
14319
  if (binArrayBitMapAccountInfoBuffer) {
14320
14320
  const binArrayBitMapExtensionAccInfo = decodeAccount(
14321
14321
  program,
@@ -14645,8 +14645,8 @@ var DLMM = class {
14645
14645
  const { mintX, mintY, rewardMint0, rewardMint1 } = lbPairMintMap.get(
14646
14646
  lbPair.toBase58()
14647
14647
  );
14648
- const reserveXBalance = _nullishCoalesce(_optionalChain([lbPairReserveMap, 'access', _59 => _59.get, 'call', _60 => _60(lbPair.toBase58()), 'optionalAccess', _61 => _61.reserveX]), () => ( BigInt(0)));
14649
- const reserveYBalance = _nullishCoalesce(_optionalChain([lbPairReserveMap, 'access', _62 => _62.get, 'call', _63 => _63(lbPair.toBase58()), 'optionalAccess', _64 => _64.reserveY]), () => ( BigInt(0)));
14648
+ const reserveXBalance = _nullishCoalesce(_optionalChain([lbPairReserveMap, 'access', _60 => _60.get, 'call', _61 => _61(lbPair.toBase58()), 'optionalAccess', _62 => _62.reserveX]), () => ( BigInt(0)));
14649
+ const reserveYBalance = _nullishCoalesce(_optionalChain([lbPairReserveMap, 'access', _63 => _63.get, 'call', _64 => _64(lbPair.toBase58()), 'optionalAccess', _65 => _65.reserveY]), () => ( BigInt(0)));
14650
14650
  const { tokenXProgram, tokenYProgram } = getTokenProgramId(lbPairAcc);
14651
14651
  const tokenX = {
14652
14652
  publicKey: lbPairAcc.tokenXMint,
@@ -14684,7 +14684,7 @@ var DLMM = class {
14684
14684
  tokenX,
14685
14685
  tokenY,
14686
14686
  lbPairPositionsData: [
14687
- ..._nullishCoalesce(_optionalChain([positionsMap, 'access', _65 => _65.get, 'call', _66 => _66(lbPair.toBase58()), 'optionalAccess', _67 => _67.lbPairPositionsData]), () => ( [])),
14687
+ ..._nullishCoalesce(_optionalChain([positionsMap, 'access', _66 => _66.get, 'call', _67 => _67(lbPair.toBase58()), 'optionalAccess', _68 => _68.lbPairPositionsData]), () => ( [])),
14688
14688
  {
14689
14689
  publicKey: positionPubkey,
14690
14690
  positionData,
@@ -15258,13 +15258,12 @@ var DLMM = class {
15258
15258
  const binArraysPubkey = /* @__PURE__ */ new Set();
15259
15259
  let shouldStop = false;
15260
15260
  let activeIdToLoop = this.lbPair.activeId;
15261
- console.log(this.program.programId.toBase58());
15262
15261
  while (!shouldStop) {
15263
15262
  const binArrayIndex = findNextBinArrayIndexWithLiquidity(
15264
15263
  swapForY,
15265
15264
  new (0, _anchor.BN)(activeIdToLoop),
15266
15265
  this.lbPair,
15267
- _nullishCoalesce(_optionalChain([this, 'access', _68 => _68.binArrayBitmapExtension, 'optionalAccess', _69 => _69.account]), () => ( null))
15266
+ _nullishCoalesce(_optionalChain([this, 'access', _69 => _69.binArrayBitmapExtension, 'optionalAccess', _70 => _70.account]), () => ( null))
15268
15267
  );
15269
15268
  if (binArrayIndex === null)
15270
15269
  shouldStop = true;
@@ -15284,10 +15283,10 @@ var DLMM = class {
15284
15283
  const accountsToFetch = Array.from(binArraysPubkey).map(
15285
15284
  (pubkey) => new (0, _web3js.PublicKey)(pubkey)
15286
15285
  );
15287
- const binArraysAccInfoBuffer = (await chunkedGetMultipleAccountInfos(
15286
+ const binArraysAccInfoBuffer = await chunkedGetMultipleAccountInfos(
15288
15287
  this.program.provider.connection,
15289
15288
  accountsToFetch
15290
- )).filter(Boolean);
15289
+ );
15291
15290
  const binArrays = await Promise.all(
15292
15291
  binArraysAccInfoBuffer.map(async (accInfo, idx) => {
15293
15292
  const account = decodeAccount(
@@ -15595,8 +15594,8 @@ var DLMM = class {
15595
15594
  position,
15596
15595
  this.tokenX.mint,
15597
15596
  this.tokenY.mint,
15598
- _optionalChain([this, 'access', _70 => _70.rewards, 'access', _71 => _71[0], 'optionalAccess', _72 => _72.mint]),
15599
- _optionalChain([this, 'access', _73 => _73.rewards, 'access', _74 => _74[1], 'optionalAccess', _75 => _75.mint]),
15597
+ _optionalChain([this, 'access', _71 => _71.rewards, 'access', _72 => _72[0], 'optionalAccess', _73 => _73.mint]),
15598
+ _optionalChain([this, 'access', _74 => _74.rewards, 'access', _75 => _75[1], 'optionalAccess', _76 => _76.mint]),
15600
15599
  positionBinArraysMapV2
15601
15600
  ),
15602
15601
  version: position.version()
@@ -15749,8 +15748,8 @@ var DLMM = class {
15749
15748
  position,
15750
15749
  this.tokenX.mint,
15751
15750
  this.tokenY.mint,
15752
- _optionalChain([this, 'access', _76 => _76.rewards, 'access', _77 => _77[0], 'optionalAccess', _78 => _78.mint]),
15753
- _optionalChain([this, 'access', _79 => _79.rewards, 'access', _80 => _80[1], 'optionalAccess', _81 => _81.mint]),
15751
+ _optionalChain([this, 'access', _77 => _77.rewards, 'access', _78 => _78[0], 'optionalAccess', _79 => _79.mint]),
15752
+ _optionalChain([this, 'access', _80 => _80.rewards, 'access', _81 => _81[1], 'optionalAccess', _82 => _82.mint]),
15754
15753
  binArrayMap
15755
15754
  ),
15756
15755
  version: position.version()
@@ -16807,7 +16806,9 @@ var DLMM = class {
16807
16806
  const setCUIx = await getEstimatedComputeUnitIxWithBuffer(
16808
16807
  this.program.provider.connection,
16809
16808
  ixs,
16810
- user
16809
+ user,
16810
+ 0.3
16811
+ // Extra 30% buffer CU
16811
16812
  );
16812
16813
  return [setCUIx, ...ixs];
16813
16814
  })
@@ -16924,7 +16925,7 @@ var DLMM = class {
16924
16925
  swapForY,
16925
16926
  activeId,
16926
16927
  this.lbPair,
16927
- _nullishCoalesce(_optionalChain([this, 'access', _82 => _82.binArrayBitmapExtension, 'optionalAccess', _83 => _83.account]), () => ( null)),
16928
+ _nullishCoalesce(_optionalChain([this, 'access', _83 => _83.binArrayBitmapExtension, 'optionalAccess', _84 => _84.account]), () => ( null)),
16928
16929
  binArrays
16929
16930
  );
16930
16931
  if (binArrayAccountToSwap == null) {
@@ -16989,7 +16990,7 @@ var DLMM = class {
16989
16990
  swapForY,
16990
16991
  activeId,
16991
16992
  this.lbPair,
16992
- _nullishCoalesce(_optionalChain([this, 'access', _84 => _84.binArrayBitmapExtension, 'optionalAccess', _85 => _85.account]), () => ( null)),
16993
+ _nullishCoalesce(_optionalChain([this, 'access', _85 => _85.binArrayBitmapExtension, 'optionalAccess', _86 => _86.account]), () => ( null)),
16993
16994
  binArrays
16994
16995
  );
16995
16996
  if (binArrayAccountToSwap == null) {
@@ -17086,7 +17087,7 @@ var DLMM = class {
17086
17087
  swapForY,
17087
17088
  activeId,
17088
17089
  this.lbPair,
17089
- _nullishCoalesce(_optionalChain([this, 'access', _86 => _86.binArrayBitmapExtension, 'optionalAccess', _87 => _87.account]), () => ( null)),
17090
+ _nullishCoalesce(_optionalChain([this, 'access', _87 => _87.binArrayBitmapExtension, 'optionalAccess', _88 => _88.account]), () => ( null)),
17090
17091
  binArrays
17091
17092
  );
17092
17093
  if (binArrayAccountToSwap == null) {
@@ -17174,7 +17175,7 @@ var DLMM = class {
17174
17175
  swapForY,
17175
17176
  activeId,
17176
17177
  this.lbPair,
17177
- _nullishCoalesce(_optionalChain([this, 'access', _88 => _88.binArrayBitmapExtension, 'optionalAccess', _89 => _89.account]), () => ( null)),
17178
+ _nullishCoalesce(_optionalChain([this, 'access', _89 => _89.binArrayBitmapExtension, 'optionalAccess', _90 => _90.account]), () => ( null)),
17178
17179
  binArrays
17179
17180
  );
17180
17181
  if (binArrayAccountToSwap == null) {
@@ -18520,7 +18521,7 @@ var DLMM = class {
18520
18521
  swapForY,
18521
18522
  new (0, _anchor.BN)(activeBinId),
18522
18523
  this.lbPair,
18523
- _nullishCoalesce(_optionalChain([this, 'access', _90 => _90.binArrayBitmapExtension, 'optionalAccess', _91 => _91.account]), () => ( null))
18524
+ _nullishCoalesce(_optionalChain([this, 'access', _91 => _91.binArrayBitmapExtension, 'optionalAccess', _92 => _92.account]), () => ( null))
18524
18525
  );
18525
18526
  if (toBinArrayIndex === null)
18526
18527
  return true;
@@ -18557,7 +18558,7 @@ var DLMM = class {
18557
18558
  swapForY,
18558
18559
  new (0, _anchor.BN)(activeBinId),
18559
18560
  this.lbPair,
18560
- _nullishCoalesce(_optionalChain([this, 'access', _92 => _92.binArrayBitmapExtension, 'optionalAccess', _93 => _93.account]), () => ( null))
18561
+ _nullishCoalesce(_optionalChain([this, 'access', _93 => _93.binArrayBitmapExtension, 'optionalAccess', _94 => _94.account]), () => ( null))
18561
18562
  );
18562
18563
  const marketPriceBinArrayIndex = binIdToBinArrayIndex(
18563
18564
  new (0, _anchor.BN)(marketPriceBinId)
@@ -18593,7 +18594,7 @@ var DLMM = class {
18593
18594
  let binArrayBitmapExtension = null;
18594
18595
  if (binArrayBitMapExtensionPubkey) {
18595
18596
  binArrayBitmapExtension = binArrayBitMapExtensionPubkey;
18596
- if (!_optionalChain([binArrayAccounts, 'optionalAccess', _94 => _94[0]])) {
18597
+ if (!_optionalChain([binArrayAccounts, 'optionalAccess', _95 => _95[0]])) {
18597
18598
  const initializeBitmapExtensionIx = await this.program.methods.initializeBinArrayBitmapExtension().accountsPartial({
18598
18599
  binArrayBitmapExtension: binArrayBitMapExtensionPubkey,
18599
18600
  funder: owner,
@@ -18602,10 +18603,10 @@ var DLMM = class {
18602
18603
  preInstructions.push(initializeBitmapExtensionIx);
18603
18604
  }
18604
18605
  }
18605
- if (!!_optionalChain([binArrayAccounts, 'optionalAccess', _95 => _95[1]])) {
18606
+ if (!!_optionalChain([binArrayAccounts, 'optionalAccess', _96 => _96[1]])) {
18606
18607
  fromBinArray = fromBinArrayPubkey;
18607
18608
  }
18608
- if (!!_optionalChain([binArrayAccounts, 'optionalAccess', _96 => _96[2]]) && !!toBinArrayIndex) {
18609
+ if (!!_optionalChain([binArrayAccounts, 'optionalAccess', _97 => _97[2]]) && !!toBinArrayIndex) {
18609
18610
  toBinArray = toBinArrayPubkey;
18610
18611
  }
18611
18612
  const { blockhash, lastValidBlockHeight } = await this.program.provider.connection.getLatestBlockhash("confirmed");
@@ -19511,7 +19512,7 @@ var DLMM = class {
19511
19512
  );
19512
19513
  })
19513
19514
  );
19514
- const version = _nullishCoalesce(_optionalChain([binArrays, 'access', _97 => _97.find, 'call', _98 => _98((binArray) => binArray != null), 'optionalAccess', _99 => _99.version]), () => ( 1));
19515
+ const version = _nullishCoalesce(_optionalChain([binArrays, 'access', _98 => _98.find, 'call', _99 => _99((binArray) => binArray != null), 'optionalAccess', _100 => _100.version]), () => ( 1));
19515
19516
  return Array.from(
19516
19517
  enumerateBins(
19517
19518
  binsById,