@meteora-ag/dlmm 1.5.0-rc.1 → 1.5.0-rc.4

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  import * as _coral_xyz_anchor from '@coral-xyz/anchor';
2
2
  import { BN, Program, IdlAccounts, ProgramAccount, IdlTypes, EventParser } from '@coral-xyz/anchor';
3
3
  import * as _solana_web3_js from '@solana/web3.js';
4
- import { PublicKey, AccountMeta, TransactionInstruction, Connection, Cluster, Transaction, Keypair } from '@solana/web3.js';
4
+ import { PublicKey, AccountMeta, Keypair, TransactionInstruction, Connection, Cluster, Transaction } from '@solana/web3.js';
5
5
  import Decimal from 'decimal.js';
6
6
  import { Mint } from '@solana/spl-token';
7
7
  import { AllAccountsMap } from '@coral-xyz/anchor/dist/cjs/program/namespace/types';
@@ -8952,6 +8952,7 @@ interface TInitializeMultiplePositionAndAddLiquidityParamsByStrategy {
8952
8952
  strategy: StrategyParameters;
8953
8953
  user: PublicKey;
8954
8954
  slippage?: number;
8955
+ customKeyPairGenerator?: () => Promise<Keypair>;
8955
8956
  }
8956
8957
  interface BinLiquidity {
8957
8958
  binId: number;
@@ -9963,7 +9964,7 @@ declare class DLMM {
9963
9964
  * - `addLiquidityIxs`: An array of `Transaction`s, each of which contains the instructions to add liquidity to a position.
9964
9965
  * - `positionKeypairs`: An array of `Keypair`s, each of which is the keypair of a position.
9965
9966
  */
9966
- initializeMultiplePositionAndAddLiquidityByStrategy({ totalXAmount, totalYAmount, strategy, user, slippage, }: TInitializeMultiplePositionAndAddLiquidityParamsByStrategy): Promise<{
9967
+ initializeMultiplePositionAndAddLiquidityByStrategy({ totalXAmount, totalYAmount, strategy, user, slippage, customKeyPairGenerator, }: TInitializeMultiplePositionAndAddLiquidityParamsByStrategy): Promise<{
9967
9968
  initPositionIxs: Transaction[];
9968
9969
  addLiquidityIxs: Transaction[];
9969
9970
  positionKeypairs: Keypair[];
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }// src/dlmm/index.ts
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } async function _asyncNullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return await rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }// src/dlmm/index.ts
2
2
  var _anchor = require('@coral-xyz/anchor');
3
3
 
4
4
 
@@ -14417,7 +14417,9 @@ var DLMM = class {
14417
14417
  tokenBadgeX,
14418
14418
  tokenBadgeY
14419
14419
  ]);
14420
- const presetParameterState = await program.account.presetParameter2.fetch(presetParameter);
14420
+ const presetParameterState = await program.account.presetParameter2.fetch(
14421
+ presetParameter
14422
+ );
14421
14423
  const existsPool = await this.getPairPubkeyIfExists(
14422
14424
  connection,
14423
14425
  tokenX,
@@ -15446,7 +15448,8 @@ var DLMM = class {
15446
15448
  totalYAmount,
15447
15449
  strategy,
15448
15450
  user,
15449
- slippage
15451
+ slippage,
15452
+ customKeyPairGenerator
15450
15453
  }) {
15451
15454
  const { maxBinId, minBinId } = strategy;
15452
15455
  const activeBin = await this.getActiveBin();
@@ -15473,7 +15476,7 @@ var DLMM = class {
15473
15476
  const initPositionIxs = [];
15474
15477
  const addLiquidityIxs = [];
15475
15478
  for (let i = 0; i < chunkedPositionBinRange.length; i++) {
15476
- const positionKeypair = _web3js.Keypair.generate();
15479
+ const positionKeypair = await _asyncNullishCoalesce(await _optionalChain([customKeyPairGenerator, 'optionalCall', _78 => _78()]), async () => ( _web3js.Keypair.generate()));
15477
15480
  positionKeypairs.push(positionKeypair);
15478
15481
  const { lowerBinId, upperBinId } = chunkedPositionBinRange[i];
15479
15482
  let width = upperBinId - lowerBinId + 1;
@@ -15648,14 +15651,14 @@ var DLMM = class {
15648
15651
  return {
15649
15652
  initPositionIxs: initPositionIxs.map((ixs) => {
15650
15653
  return new (0, _web3js.Transaction)({
15651
- feePayer: this.lbPair.creator,
15654
+ feePayer: user,
15652
15655
  blockhash,
15653
15656
  lastValidBlockHeight
15654
15657
  }).add(...ixs);
15655
15658
  }),
15656
15659
  addLiquidityIxs: addLiquidityIxs.map((ixs) => {
15657
15660
  return new (0, _web3js.Transaction)({
15658
- feePayer: this.lbPair.creator,
15661
+ feePayer: user,
15659
15662
  blockhash,
15660
15663
  lastValidBlockHeight
15661
15664
  }).add(...ixs);
@@ -16103,7 +16106,9 @@ var DLMM = class {
16103
16106
  slippage
16104
16107
  }) {
16105
16108
  const maxActiveBinSlippage = slippage ? Math.ceil(slippage / (this.lbPair.binStep / 100)) : MAX_ACTIVE_BIN_SLIPPAGE;
16106
- const positionAccount = await this.program.account.positionV2.fetch(positionPubKey);
16109
+ const positionAccount = await this.program.account.positionV2.fetch(
16110
+ positionPubKey
16111
+ );
16107
16112
  const { lowerBinId, upperBinId, binIds } = this.processXYAmountDistribution(xYAmountDistribution);
16108
16113
  if (lowerBinId < positionAccount.lowerBinId)
16109
16114
  throw new Error(
@@ -16623,7 +16628,7 @@ var DLMM = class {
16623
16628
  swapForY,
16624
16629
  activeId,
16625
16630
  this.lbPair,
16626
- _nullishCoalesce(_optionalChain([this, 'access', _78 => _78.binArrayBitmapExtension, 'optionalAccess', _79 => _79.account]), () => ( null)),
16631
+ _nullishCoalesce(_optionalChain([this, 'access', _79 => _79.binArrayBitmapExtension, 'optionalAccess', _80 => _80.account]), () => ( null)),
16627
16632
  binArrays
16628
16633
  );
16629
16634
  if (binArrayAccountToSwap == null) {
@@ -16688,7 +16693,7 @@ var DLMM = class {
16688
16693
  swapForY,
16689
16694
  activeId,
16690
16695
  this.lbPair,
16691
- _nullishCoalesce(_optionalChain([this, 'access', _80 => _80.binArrayBitmapExtension, 'optionalAccess', _81 => _81.account]), () => ( null)),
16696
+ _nullishCoalesce(_optionalChain([this, 'access', _81 => _81.binArrayBitmapExtension, 'optionalAccess', _82 => _82.account]), () => ( null)),
16692
16697
  binArrays
16693
16698
  );
16694
16699
  if (binArrayAccountToSwap == null) {
@@ -16785,7 +16790,7 @@ var DLMM = class {
16785
16790
  swapForY,
16786
16791
  activeId,
16787
16792
  this.lbPair,
16788
- _nullishCoalesce(_optionalChain([this, 'access', _82 => _82.binArrayBitmapExtension, 'optionalAccess', _83 => _83.account]), () => ( null)),
16793
+ _nullishCoalesce(_optionalChain([this, 'access', _83 => _83.binArrayBitmapExtension, 'optionalAccess', _84 => _84.account]), () => ( null)),
16789
16794
  binArrays
16790
16795
  );
16791
16796
  if (binArrayAccountToSwap == null) {
@@ -16873,7 +16878,7 @@ var DLMM = class {
16873
16878
  swapForY,
16874
16879
  activeId,
16875
16880
  this.lbPair,
16876
- _nullishCoalesce(_optionalChain([this, 'access', _84 => _84.binArrayBitmapExtension, 'optionalAccess', _85 => _85.account]), () => ( null)),
16881
+ _nullishCoalesce(_optionalChain([this, 'access', _85 => _85.binArrayBitmapExtension, 'optionalAccess', _86 => _86.account]), () => ( null)),
16877
16882
  binArrays
16878
16883
  );
16879
16884
  if (binArrayAccountToSwap == null) {
@@ -18216,7 +18221,7 @@ var DLMM = class {
18216
18221
  swapForY,
18217
18222
  new (0, _anchor.BN)(activeBinId),
18218
18223
  this.lbPair,
18219
- _nullishCoalesce(_optionalChain([this, 'access', _86 => _86.binArrayBitmapExtension, 'optionalAccess', _87 => _87.account]), () => ( null))
18224
+ _nullishCoalesce(_optionalChain([this, 'access', _87 => _87.binArrayBitmapExtension, 'optionalAccess', _88 => _88.account]), () => ( null))
18220
18225
  );
18221
18226
  if (toBinArrayIndex === null)
18222
18227
  return true;
@@ -18253,7 +18258,7 @@ var DLMM = class {
18253
18258
  swapForY,
18254
18259
  new (0, _anchor.BN)(activeBinId),
18255
18260
  this.lbPair,
18256
- _nullishCoalesce(_optionalChain([this, 'access', _88 => _88.binArrayBitmapExtension, 'optionalAccess', _89 => _89.account]), () => ( null))
18261
+ _nullishCoalesce(_optionalChain([this, 'access', _89 => _89.binArrayBitmapExtension, 'optionalAccess', _90 => _90.account]), () => ( null))
18257
18262
  );
18258
18263
  const marketPriceBinArrayIndex = binIdToBinArrayIndex(
18259
18264
  new (0, _anchor.BN)(marketPriceBinId)
@@ -18289,7 +18294,7 @@ var DLMM = class {
18289
18294
  let binArrayBitmapExtension = null;
18290
18295
  if (binArrayBitMapExtensionPubkey) {
18291
18296
  binArrayBitmapExtension = binArrayBitMapExtensionPubkey;
18292
- if (!_optionalChain([binArrayAccounts, 'optionalAccess', _90 => _90[0]])) {
18297
+ if (!_optionalChain([binArrayAccounts, 'optionalAccess', _91 => _91[0]])) {
18293
18298
  const initializeBitmapExtensionIx = await this.program.methods.initializeBinArrayBitmapExtension().accountsPartial({
18294
18299
  binArrayBitmapExtension: binArrayBitMapExtensionPubkey,
18295
18300
  funder: owner,
@@ -18298,10 +18303,10 @@ var DLMM = class {
18298
18303
  preInstructions.push(initializeBitmapExtensionIx);
18299
18304
  }
18300
18305
  }
18301
- if (!!_optionalChain([binArrayAccounts, 'optionalAccess', _91 => _91[1]])) {
18306
+ if (!!_optionalChain([binArrayAccounts, 'optionalAccess', _92 => _92[1]])) {
18302
18307
  fromBinArray = fromBinArrayPubkey;
18303
18308
  }
18304
- if (!!_optionalChain([binArrayAccounts, 'optionalAccess', _92 => _92[2]]) && !!toBinArrayIndex) {
18309
+ if (!!_optionalChain([binArrayAccounts, 'optionalAccess', _93 => _93[2]]) && !!toBinArrayIndex) {
18305
18310
  toBinArray = toBinArrayPubkey;
18306
18311
  }
18307
18312
  const { blockhash, lastValidBlockHeight } = await this.program.provider.connection.getLatestBlockhash("confirmed");
@@ -18807,7 +18812,7 @@ var DLMM = class {
18807
18812
  );
18808
18813
  })
18809
18814
  );
18810
- const version = _nullishCoalesce(_optionalChain([binArrays, 'access', _93 => _93.find, 'call', _94 => _94((binArray) => binArray != null), 'optionalAccess', _95 => _95.version]), () => ( 1));
18815
+ const version = _nullishCoalesce(_optionalChain([binArrays, 'access', _94 => _94.find, 'call', _95 => _95((binArray) => binArray != null), 'optionalAccess', _96 => _96.version]), () => ( 1));
18811
18816
  return Array.from(
18812
18817
  enumerateBins(
18813
18818
  binsById,