@meteora-ag/dlmm 1.6.0-rc.0 → 1.6.0-rc.1

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
@@ -10305,28 +10305,6 @@ declare class DLMM {
10305
10305
  positionCount: number;
10306
10306
  positionCost: number;
10307
10307
  }>;
10308
- /**
10309
- * Estimates the cost to create a new position based on the given strategy.
10310
- *
10311
- * This function calculates the costs associated with creating bin arrays, positions
10312
- * and extending positions for a specified range of bins.
10313
- *
10314
- * @param {TQuoteCreatePositionParams} param0 - The settings of the requested new position,
10315
- * including the strategy with minimum and maximum bin IDs.
10316
- * @returns An object containing:
10317
- * - binArraysCount: The number of bin arrays required.
10318
- * - binArrayCost: The estimated cost for creating bin arrays.
10319
- * - positionCount: The number of positions required.
10320
- * - positionCost: The fee cost for creating positions.
10321
- * - positionExtendCost: The rent cost in lamports for extending positions.
10322
- */
10323
- quoteCreateMultiplePositions({ strategy, }: TQuoteCreatePositionParams): Promise<{
10324
- binArraysCount: number;
10325
- binArrayCost: Decimal;
10326
- positionCount: number;
10327
- positionCost: Decimal;
10328
- positionExtendCost: Decimal;
10329
- }>;
10330
10308
  /**
10331
10309
  * Creates an empty position and initializes the corresponding bin arrays if needed.
10332
10310
  * @param param0 The settings of the requested new position.
@@ -10338,24 +10316,6 @@ declare class DLMM {
10338
10316
  maxBinId: number;
10339
10317
  user: PublicKey;
10340
10318
  }): Promise<Transaction>;
10341
- /**
10342
- * Creates multiple empty positions for a user in specified bin ranges with necessary bin arrays.
10343
- *
10344
- * @param {number} minBinId - The minimum bin ID for the positions.
10345
- * @param {number} maxBinId - The maximum bin ID for the positions.
10346
- * @param {PublicKey} user - The public key of the user for whom the positions are created.
10347
- *
10348
- * @returns An object containing arrays of transactions for initializing positions, extending positions and initialzing bin arrays.
10349
- */
10350
- createMultipleEmptyPositions({ minBinId, maxBinId, user, }: {
10351
- minBinId: number;
10352
- maxBinId: number;
10353
- user: PublicKey;
10354
- }): Promise<{
10355
- positionKeypairs: Keypair[];
10356
- initPositionTxs: Transaction[];
10357
- initBinArrayTxs: Transaction[];
10358
- }>;
10359
10319
  /**
10360
10320
  * The function `getPosition` retrieves position information for a given public key and processes it
10361
10321
  * using various data to return a `LbPosition` object.
@@ -10725,6 +10685,16 @@ declare class DLMM {
10725
10685
  initBinArrayInstructions: TransactionInstruction[];
10726
10686
  rebalancePositionInstruction: TransactionInstruction[];
10727
10687
  }>;
10688
+ /**
10689
+ * Create an extended empty position.
10690
+ *
10691
+ * @param lowerBinid The lowest bin of the position.
10692
+ * @param upperBinId The highest bin of the position.
10693
+ * @param position The public key of the position.
10694
+ * @param owner The owner of the position.
10695
+ * @returns The instructions to create the extended empty position.
10696
+ */
10697
+ createExtendedEmptyPosition(lowerBinid: number, upperBinId: number, position: PublicKey, owner: PublicKey): Promise<Transaction>;
10728
10698
  private createInitAndExtendPositionIx;
10729
10699
  private increasePositionLengthIxs;
10730
10700
  /** Private static method */
package/dist/index.js CHANGED
@@ -18,7 +18,6 @@ var _spltoken = require('@solana/spl-token');
18
18
 
19
19
 
20
20
 
21
-
22
21
  var _web3js = require('@solana/web3.js');
23
22
  var _decimaljs = require('decimal.js'); var _decimaljs2 = _interopRequireDefault(_decimaljs);
24
23
 
@@ -12180,20 +12179,6 @@ function isPositionNoFee(position) {
12180
12179
  function isPositionNoReward(position) {
12181
12180
  return position.rewardOne.isZero() && position.rewardTwo.isZero();
12182
12181
  }
12183
- function chunkBinRangeIntoExtendedPositions(minBinId, maxBinId) {
12184
- const chunkedBinRange = [];
12185
- for (let currentMinBinId = minBinId; currentMinBinId <= maxBinId; currentMinBinId += POSITION_MAX_LENGTH.toNumber()) {
12186
- const currentMaxBinId = Math.min(
12187
- currentMinBinId + POSITION_MAX_LENGTH.toNumber() - 1,
12188
- maxBinId
12189
- );
12190
- chunkedBinRange.push({
12191
- lowerBinId: currentMinBinId,
12192
- upperBinId: currentMaxBinId
12193
- });
12194
- }
12195
- return chunkedBinRange;
12196
- }
12197
12182
  function chunkBinRange(minBinId, maxBinId) {
12198
12183
  const chunkedBinRange = [];
12199
12184
  let startBinId = minBinId;
@@ -15134,68 +15119,6 @@ var DLMM = class {
15134
15119
  positionCost
15135
15120
  };
15136
15121
  }
15137
- /**
15138
- * Estimates the cost to create a new position based on the given strategy.
15139
- *
15140
- * This function calculates the costs associated with creating bin arrays, positions
15141
- * and extending positions for a specified range of bins.
15142
- *
15143
- * @param {TQuoteCreatePositionParams} param0 - The settings of the requested new position,
15144
- * including the strategy with minimum and maximum bin IDs.
15145
- * @returns An object containing:
15146
- * - binArraysCount: The number of bin arrays required.
15147
- * - binArrayCost: The estimated cost for creating bin arrays.
15148
- * - positionCount: The number of positions required.
15149
- * - positionCost: The fee cost for creating positions.
15150
- * - positionExtendCost: The rent cost in lamports for extending positions.
15151
- */
15152
- async quoteCreateMultiplePositions({
15153
- strategy
15154
- }) {
15155
- const { minBinId, maxBinId } = strategy;
15156
- const minBinIdBN = new (0, _anchor.BN)(minBinId);
15157
- const maxBinIdBN = new (0, _anchor.BN)(maxBinId);
15158
- const lowerBinArrayIndex = binIdToBinArrayIndex(minBinIdBN);
15159
- const upperBinArrayIndex = binIdToBinArrayIndex(maxBinIdBN);
15160
- const binArraysCount = (await this.binArraysToBeCreate(lowerBinArrayIndex, upperBinArrayIndex)).length;
15161
- const binArrayCost = new (0, _decimaljs2.default)(binArraysCount).mul(
15162
- new (0, _decimaljs2.default)(BIN_ARRAY_FEE)
15163
- );
15164
- let positionCost = new (0, _decimaljs2.default)(0);
15165
- let positionExtendCost = new (0, _decimaljs2.default)(0);
15166
- const chunkedPositionBinRange = chunkBinRangeIntoExtendedPositions(
15167
- minBinId,
15168
- maxBinId
15169
- );
15170
- const positionCount = chunkedPositionBinRange.length;
15171
- for (const { lowerBinId, upperBinId } of chunkedPositionBinRange) {
15172
- positionCost = positionCost.add(new (0, _decimaljs2.default)(POSITION_FEE));
15173
- const lowerBinIdBN = new (0, _anchor.BN)(lowerBinId);
15174
- const upperBinIdBN = new (0, _anchor.BN)(upperBinId);
15175
- const extendedBinCount = getExtendedPositionBinCount(
15176
- lowerBinIdBN,
15177
- upperBinIdBN
15178
- );
15179
- const upperBinIdBeforeExtend = upperBinIdBN.sub(extendedBinCount);
15180
- positionExtendCost = positionExtendCost.add(
15181
- await getPositionExpandRentExemption(
15182
- lowerBinIdBN,
15183
- upperBinIdBeforeExtend,
15184
- this.program.provider.connection,
15185
- extendedBinCount
15186
- ).then(
15187
- (lamports) => new (0, _decimaljs2.default)(lamports).div(new (0, _decimaljs2.default)(_web3js.LAMPORTS_PER_SOL))
15188
- )
15189
- );
15190
- }
15191
- return {
15192
- binArraysCount,
15193
- binArrayCost,
15194
- positionCount,
15195
- positionCost,
15196
- positionExtendCost
15197
- };
15198
- }
15199
15122
  /**
15200
15123
  * Creates an empty position and initializes the corresponding bin arrays if needed.
15201
15124
  * @param param0 The settings of the requested new position.
@@ -15234,84 +15157,6 @@ var DLMM = class {
15234
15157
  feePayer: user
15235
15158
  }).add(setCUIx, ...instructions);
15236
15159
  }
15237
- /**
15238
- * Creates multiple empty positions for a user in specified bin ranges with necessary bin arrays.
15239
- *
15240
- * @param {number} minBinId - The minimum bin ID for the positions.
15241
- * @param {number} maxBinId - The maximum bin ID for the positions.
15242
- * @param {PublicKey} user - The public key of the user for whom the positions are created.
15243
- *
15244
- * @returns An object containing arrays of transactions for initializing positions, extending positions and initialzing bin arrays.
15245
- */
15246
- async createMultipleEmptyPositions({
15247
- minBinId,
15248
- maxBinId,
15249
- user
15250
- }) {
15251
- const chunkedBinRange = chunkBinRangeIntoExtendedPositions(
15252
- minBinId,
15253
- maxBinId
15254
- );
15255
- const positionCount = chunkedBinRange.length;
15256
- const positionKeypairs = [];
15257
- const initPositionIxs = [];
15258
- const initBinArrayIxs = [];
15259
- const binArrayIndexSet = /* @__PURE__ */ new Set();
15260
- for (let i = 0; i < positionCount; i++) {
15261
- const positionKeypair = _web3js.Keypair.generate();
15262
- positionKeypairs.push(positionKeypair);
15263
- const { lowerBinId, upperBinId } = chunkedBinRange[i];
15264
- let width = upperBinId - lowerBinId + 1;
15265
- width = Math.min(width, DEFAULT_BIN_PER_POSITION.toNumber());
15266
- const initPositionIx = await this.createInitAndExtendPositionIx(
15267
- lowerBinId,
15268
- upperBinId,
15269
- width,
15270
- user,
15271
- positionKeypair.publicKey
15272
- );
15273
- initPositionIxs.push(initPositionIx);
15274
- const binArrayIndexes = getBinArrayIndexesCoverage(
15275
- new (0, _anchor.BN)(lowerBinId),
15276
- new (0, _anchor.BN)(upperBinId)
15277
- ).filter((idx) => !binArrayIndexSet.has(idx.toNumber()));
15278
- const createBinArrayIxs = await this.createBinArraysIfNeeded(
15279
- binArrayIndexes,
15280
- user
15281
- ).then(
15282
- (ixs) => ixs.map((ix) => [
15283
- _web3js.ComputeBudgetProgram.setComputeUnitLimit({
15284
- units: DEFAULT_INIT_BIN_ARRAY_CU
15285
- }),
15286
- ix
15287
- ])
15288
- );
15289
- binArrayIndexes.map((idx) => {
15290
- binArrayIndexSet.add(idx.toNumber());
15291
- });
15292
- initBinArrayIxs.push(...createBinArrayIxs);
15293
- }
15294
- const { blockhash, lastValidBlockHeight } = await this.program.provider.connection.getLatestBlockhash("confirmed");
15295
- const initPositionTxs = initPositionIxs.map((ix) => {
15296
- return new (0, _web3js.Transaction)({
15297
- blockhash,
15298
- lastValidBlockHeight,
15299
- feePayer: user
15300
- }).add(...ix);
15301
- });
15302
- const initBinArrayTxs = initBinArrayIxs.map((ix) => {
15303
- return new (0, _web3js.Transaction)({
15304
- blockhash,
15305
- lastValidBlockHeight,
15306
- feePayer: user
15307
- }).add(...ix);
15308
- });
15309
- return {
15310
- positionKeypairs,
15311
- initPositionTxs,
15312
- initBinArrayTxs
15313
- };
15314
- }
15315
15160
  /**
15316
15161
  * The function `getPosition` retrieves position information for a given public key and processes it
15317
15162
  * using various data to return a `LbPosition` object.
@@ -18602,6 +18447,34 @@ var DLMM = class {
18602
18447
  rebalancePositionInstruction
18603
18448
  };
18604
18449
  }
18450
+ /**
18451
+ * Create an extended empty position.
18452
+ *
18453
+ * @param lowerBinid The lowest bin of the position.
18454
+ * @param upperBinId The highest bin of the position.
18455
+ * @param position The public key of the position.
18456
+ * @param owner The owner of the position.
18457
+ * @returns The instructions to create the extended empty position.
18458
+ */
18459
+ async createExtendedEmptyPosition(lowerBinid, upperBinId, position, owner) {
18460
+ const positionWidth = upperBinId - lowerBinid + 1;
18461
+ const basePositionWidth = Math.min(
18462
+ positionWidth,
18463
+ DEFAULT_BIN_PER_POSITION.toNumber()
18464
+ );
18465
+ const ixs = await this.createInitAndExtendPositionIx(
18466
+ lowerBinid,
18467
+ upperBinId,
18468
+ basePositionWidth,
18469
+ owner,
18470
+ position
18471
+ );
18472
+ const latestBlockhashInfo = await this.program.provider.connection.getLatestBlockhash();
18473
+ const tx = new (0, _web3js.Transaction)({
18474
+ ...latestBlockhashInfo
18475
+ }).add(...ixs);
18476
+ return tx;
18477
+ }
18605
18478
  async createInitAndExtendPositionIx(lowerBinId, upperBinId, basePositionWidth, user, position) {
18606
18479
  const createPositionIx = await this.program.methods.initializePosition(lowerBinId, basePositionWidth).accountsPartial({
18607
18480
  payer: user,