@meteora-ag/dlmm 1.3.3 → 1.3.5

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
@@ -1,4 +1,16 @@
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
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
2
+ var _anchor = require('@coral-xyz/anchor');
3
+ var _bytes = require('@coral-xyz/anchor/dist/cjs/utils/bytes');
4
+
5
+
6
+
7
+
8
+
9
+
10
+
11
+
12
+ var _spltoken = require('@solana/spl-token');
13
+
2
14
 
3
15
 
4
16
 
@@ -6,6 +18,10 @@
6
18
 
7
19
 
8
20
  var _web3js = require('@solana/web3.js');
21
+ var _decimaljs = require('decimal.js'); var _decimaljs2 = _interopRequireDefault(_decimaljs);
22
+
23
+ // src/dlmm/constants/index.ts
24
+
9
25
 
10
26
  // src/dlmm/idl.ts
11
27
  var IDL = {
@@ -5260,7 +5276,6 @@ var IDL = {
5260
5276
 
5261
5277
  // src/dlmm/constants/index.ts
5262
5278
 
5263
- var _anchor = require('@coral-xyz/anchor');
5264
5279
  var LBCLMM_PROGRAM_IDS = {
5265
5280
  devnet: "LBUZKhRxPF3XUpBCjp4YzTKgLccjZhTSDM9YuVaPwxo",
5266
5281
  localhost: "LbVRzDTvBDEcrthxfZ4RL6yiq3uZw8bS6MwtdY6UhFQ",
@@ -5309,66 +5324,48 @@ var ILM_BASE = new (0, _web3js.PublicKey)(
5309
5324
  "MFGQxwAmB91SwuYX36okv2Qmdc9aMuHTwWGUrp4AtB1"
5310
5325
  );
5311
5326
 
5312
- // src/dlmm/types/index.ts
5313
- var _borsh = require('@coral-xyz/borsh');
5314
- var PositionVersion = /* @__PURE__ */ ((PositionVersion2) => {
5315
- PositionVersion2[PositionVersion2["V1"] = 0] = "V1";
5316
- PositionVersion2[PositionVersion2["V2"] = 1] = "V2";
5317
- return PositionVersion2;
5318
- })(PositionVersion || {});
5319
- var PairType = /* @__PURE__ */ ((PairType2) => {
5320
- PairType2[PairType2["Permissionless"] = 0] = "Permissionless";
5321
- PairType2[PairType2["Permissioned"] = 1] = "Permissioned";
5322
- return PairType2;
5323
- })(PairType || {});
5324
- var Strategy = {
5325
- SpotOneSide: { spotOneSide: {} },
5326
- CurveOneSide: { curveOneSide: {} },
5327
- BidAskOneSide: { bidAskOneSide: {} },
5328
- SpotBalanced: { spotBalanced: {} },
5329
- CurveBalanced: { curveBalanced: {} },
5330
- BidAskBalanced: { bidAskBalanced: {} },
5331
- SpotImBalanced: { spotImBalanced: {} },
5332
- CurveImBalanced: { curveImBalanced: {} },
5333
- BidAskImBalanced: { bidAskImBalanced: {} }
5334
- };
5335
- var StrategyType = /* @__PURE__ */ ((StrategyType2) => {
5336
- StrategyType2[StrategyType2["SpotOneSide"] = 0] = "SpotOneSide";
5337
- StrategyType2[StrategyType2["CurveOneSide"] = 1] = "CurveOneSide";
5338
- StrategyType2[StrategyType2["BidAskOneSide"] = 2] = "BidAskOneSide";
5339
- StrategyType2[StrategyType2["SpotImBalanced"] = 3] = "SpotImBalanced";
5340
- StrategyType2[StrategyType2["CurveImBalanced"] = 4] = "CurveImBalanced";
5341
- StrategyType2[StrategyType2["BidAskImBalanced"] = 5] = "BidAskImBalanced";
5342
- StrategyType2[StrategyType2["SpotBalanced"] = 6] = "SpotBalanced";
5343
- StrategyType2[StrategyType2["CurveBalanced"] = 7] = "CurveBalanced";
5344
- StrategyType2[StrategyType2["BidAskBalanced"] = 8] = "BidAskBalanced";
5345
- return StrategyType2;
5346
- })(StrategyType || {});
5347
- var ActivationType = /* @__PURE__ */ ((ActivationType2) => {
5348
- ActivationType2[ActivationType2["Slot"] = 0] = "Slot";
5349
- ActivationType2[ActivationType2["Timestamp"] = 1] = "Timestamp";
5350
- return ActivationType2;
5351
- })(ActivationType || {});
5352
- var BitmapType = /* @__PURE__ */ ((BitmapType2) => {
5353
- BitmapType2[BitmapType2["U1024"] = 0] = "U1024";
5354
- BitmapType2[BitmapType2["U512"] = 1] = "U512";
5355
- return BitmapType2;
5356
- })(BitmapType || {});
5357
- var ClockLayout = _borsh.struct.call(void 0, [
5358
- _borsh.u64.call(void 0, "slot"),
5359
- _borsh.i64.call(void 0, "epochStartTimestamp"),
5360
- _borsh.u64.call(void 0, "epoch"),
5361
- _borsh.u64.call(void 0, "leaderScheduleEpoch"),
5362
- _borsh.i64.call(void 0, "unixTimestamp")
5363
- ]);
5364
- var PairStatus = /* @__PURE__ */ ((PairStatus2) => {
5365
- PairStatus2[PairStatus2["Enabled"] = 0] = "Enabled";
5366
- PairStatus2[PairStatus2["Disabled"] = 1] = "Disabled";
5367
- return PairStatus2;
5368
- })(PairStatus || {});
5369
-
5370
- // src/dlmm/index.ts
5327
+ // src/dlmm/error.ts
5371
5328
 
5329
+ var DLMMError = class extends Error {
5330
+
5331
+
5332
+
5333
+ constructor(error) {
5334
+ let _errorCode = 0;
5335
+ let _errorName = "Something went wrong";
5336
+ let _errorMessage = "Something went wrong";
5337
+ if (error instanceof Error) {
5338
+ const anchorError = _anchor.AnchorError.parse(
5339
+ JSON.parse(JSON.stringify(error)).logs
5340
+ );
5341
+ if (_optionalChain([anchorError, 'optionalAccess', _18 => _18.program, 'access', _19 => _19.toBase58, 'call', _20 => _20()]) === LBCLMM_PROGRAM_IDS["mainnet-beta"]) {
5342
+ _errorCode = anchorError.error.errorCode.number;
5343
+ _errorName = anchorError.error.errorCode.code;
5344
+ _errorMessage = anchorError.error.errorMessage;
5345
+ }
5346
+ } else {
5347
+ const idlError = IDL.errors.find((err) => err.code === error);
5348
+ if (idlError) {
5349
+ _errorCode = idlError.code;
5350
+ _errorName = idlError.name;
5351
+ _errorMessage = idlError.msg;
5352
+ }
5353
+ }
5354
+ super(_errorMessage);
5355
+ this.errorCode = _errorCode;
5356
+ this.errorName = _errorName;
5357
+ this.errorMessage = _errorMessage;
5358
+ }
5359
+ };
5360
+ var DlmmSdkError = class extends Error {
5361
+
5362
+
5363
+ constructor(name, message) {
5364
+ super();
5365
+ this.name = name;
5366
+ this.message = message;
5367
+ }
5368
+ };
5372
5369
 
5373
5370
  // src/dlmm/helpers/index.ts
5374
5371
 
@@ -5381,7 +5378,7 @@ var PairStatus = /* @__PURE__ */ ((PairStatus2) => {
5381
5378
 
5382
5379
 
5383
5380
 
5384
- var _spltoken = require('@solana/spl-token');
5381
+
5385
5382
 
5386
5383
 
5387
5384
 
@@ -5390,7 +5387,7 @@ var _spltoken = require('@solana/spl-token');
5390
5387
 
5391
5388
  // src/dlmm/helpers/math.ts
5392
5389
 
5393
- var _decimaljs = require('decimal.js'); var _decimaljs2 = _interopRequireDefault(_decimaljs);
5390
+
5394
5391
 
5395
5392
  // src/dlmm/helpers/u64xu64_math.ts
5396
5393
  var _bnjs = require('bn.js'); var _bnjs2 = _interopRequireDefault(_bnjs);
@@ -6344,6 +6341,14 @@ function generateBinAmount(amount, binStep, binId, tokenXDecimal, tokenYDecimal,
6344
6341
  return new (0, _anchor.BN)(c1.sub(c0).floor().toString());
6345
6342
  }
6346
6343
 
6344
+ // src/dlmm/helpers/index.ts
6345
+ var _helpers = require('@solana-developers/helpers');
6346
+
6347
+ // src/dlmm/helpers/computeUnit.ts
6348
+ var DEFAULT_ADD_LIQUIDITY_CU = 8e5;
6349
+ var MIN_CU_BUFFER = 5e4;
6350
+ var MAX_CU_BUFFER = 2e5;
6351
+
6347
6352
  // src/dlmm/helpers/derive.ts
6348
6353
 
6349
6354
  function sortTokenMints(tokenX, tokenY) {
@@ -6461,6 +6466,105 @@ function deriveReserve(token, lbPair, programId) {
6461
6466
  // src/dlmm/helpers/binArray.ts
6462
6467
 
6463
6468
 
6469
+
6470
+ // src/dlmm/types/index.ts
6471
+
6472
+
6473
+
6474
+
6475
+ var _borsh = require('@coral-xyz/borsh');
6476
+ var PositionVersion = /* @__PURE__ */ ((PositionVersion2) => {
6477
+ PositionVersion2[PositionVersion2["V1"] = 0] = "V1";
6478
+ PositionVersion2[PositionVersion2["V2"] = 1] = "V2";
6479
+ return PositionVersion2;
6480
+ })(PositionVersion || {});
6481
+ var PairType = /* @__PURE__ */ ((PairType2) => {
6482
+ PairType2[PairType2["Permissionless"] = 0] = "Permissionless";
6483
+ PairType2[PairType2["Permissioned"] = 1] = "Permissioned";
6484
+ return PairType2;
6485
+ })(PairType || {});
6486
+ var Strategy = {
6487
+ SpotOneSide: { spotOneSide: {} },
6488
+ CurveOneSide: { curveOneSide: {} },
6489
+ BidAskOneSide: { bidAskOneSide: {} },
6490
+ SpotBalanced: { spotBalanced: {} },
6491
+ CurveBalanced: { curveBalanced: {} },
6492
+ BidAskBalanced: { bidAskBalanced: {} },
6493
+ SpotImBalanced: { spotImBalanced: {} },
6494
+ CurveImBalanced: { curveImBalanced: {} },
6495
+ BidAskImBalanced: { bidAskImBalanced: {} }
6496
+ };
6497
+ var StrategyType = /* @__PURE__ */ ((StrategyType2) => {
6498
+ StrategyType2[StrategyType2["SpotOneSide"] = 0] = "SpotOneSide";
6499
+ StrategyType2[StrategyType2["CurveOneSide"] = 1] = "CurveOneSide";
6500
+ StrategyType2[StrategyType2["BidAskOneSide"] = 2] = "BidAskOneSide";
6501
+ StrategyType2[StrategyType2["SpotImBalanced"] = 3] = "SpotImBalanced";
6502
+ StrategyType2[StrategyType2["CurveImBalanced"] = 4] = "CurveImBalanced";
6503
+ StrategyType2[StrategyType2["BidAskImBalanced"] = 5] = "BidAskImBalanced";
6504
+ StrategyType2[StrategyType2["SpotBalanced"] = 6] = "SpotBalanced";
6505
+ StrategyType2[StrategyType2["CurveBalanced"] = 7] = "CurveBalanced";
6506
+ StrategyType2[StrategyType2["BidAskBalanced"] = 8] = "BidAskBalanced";
6507
+ return StrategyType2;
6508
+ })(StrategyType || {});
6509
+ var ActivationType = /* @__PURE__ */ ((ActivationType2) => {
6510
+ ActivationType2[ActivationType2["Slot"] = 0] = "Slot";
6511
+ ActivationType2[ActivationType2["Timestamp"] = 1] = "Timestamp";
6512
+ return ActivationType2;
6513
+ })(ActivationType || {});
6514
+ var BinLiquidity;
6515
+ ((BinLiquidity3) => {
6516
+ function fromBin(bin, binId, binStep, baseTokenDecimal, quoteTokenDecimal, version) {
6517
+ const pricePerLamport = getPriceOfBinByBinId(
6518
+ binId,
6519
+ binStep
6520
+ ).toString();
6521
+ return {
6522
+ binId,
6523
+ xAmount: bin.amountX,
6524
+ yAmount: bin.amountY,
6525
+ supply: bin.liquiditySupply,
6526
+ price: pricePerLamport,
6527
+ version,
6528
+ pricePerToken: new (0, _decimaljs2.default)(pricePerLamport).mul(new (0, _decimaljs2.default)(10 ** (baseTokenDecimal - quoteTokenDecimal))).toString()
6529
+ };
6530
+ }
6531
+ BinLiquidity3.fromBin = fromBin;
6532
+ function empty(binId, binStep, baseTokenDecimal, quoteTokenDecimal, version) {
6533
+ const pricePerLamport = getPriceOfBinByBinId(
6534
+ binId,
6535
+ binStep
6536
+ ).toString();
6537
+ return {
6538
+ binId,
6539
+ xAmount: new (0, _anchor.BN)(0),
6540
+ yAmount: new (0, _anchor.BN)(0),
6541
+ supply: new (0, _anchor.BN)(0),
6542
+ price: pricePerLamport,
6543
+ version,
6544
+ pricePerToken: new (0, _decimaljs2.default)(pricePerLamport).mul(new (0, _decimaljs2.default)(10 ** (baseTokenDecimal - quoteTokenDecimal))).toString()
6545
+ };
6546
+ }
6547
+ BinLiquidity3.empty = empty;
6548
+ })(BinLiquidity || (BinLiquidity = exports.BinLiquidity = {}));
6549
+ var BitmapType = /* @__PURE__ */ ((BitmapType2) => {
6550
+ BitmapType2[BitmapType2["U1024"] = 0] = "U1024";
6551
+ BitmapType2[BitmapType2["U512"] = 1] = "U512";
6552
+ return BitmapType2;
6553
+ })(BitmapType || {});
6554
+ var ClockLayout = _borsh.struct.call(void 0, [
6555
+ _borsh.u64.call(void 0, "slot"),
6556
+ _borsh.i64.call(void 0, "epochStartTimestamp"),
6557
+ _borsh.u64.call(void 0, "epoch"),
6558
+ _borsh.u64.call(void 0, "leaderScheduleEpoch"),
6559
+ _borsh.i64.call(void 0, "unixTimestamp")
6560
+ ]);
6561
+ var PairStatus = /* @__PURE__ */ ((PairStatus2) => {
6562
+ PairStatus2[PairStatus2["Enabled"] = 0] = "Enabled";
6563
+ PairStatus2[PairStatus2["Disabled"] = 1] = "Disabled";
6564
+ return PairStatus2;
6565
+ })(PairStatus || {});
6566
+
6567
+ // src/dlmm/helpers/binArray.ts
6464
6568
  function internalBitmapRange() {
6465
6569
  const lowerBinArrayIndex = BIN_ARRAY_BITMAP_SIZE.neg();
6466
6570
  const upperBinArrayIndex = BIN_ARRAY_BITMAP_SIZE.sub(new (0, _anchor.BN)(1));
@@ -6708,6 +6812,16 @@ function getBinArraysRequiredByPositionRange(pair, fromBinId, toBinId, programId
6708
6812
  index
6709
6813
  }));
6710
6814
  }
6815
+ function* enumerateBins(binsById, lowerBinId, upperBinId, binStep, baseTokenDecimal, quoteTokenDecimal, version) {
6816
+ for (let currentBinId = lowerBinId; currentBinId <= upperBinId; currentBinId++) {
6817
+ const bin = binsById.get(currentBinId);
6818
+ if (bin != null) {
6819
+ yield BinLiquidity.fromBin(bin, currentBinId, binStep, baseTokenDecimal, quoteTokenDecimal, version);
6820
+ } else {
6821
+ yield BinLiquidity.empty(currentBinId, binStep, baseTokenDecimal, quoteTokenDecimal, version);
6822
+ }
6823
+ }
6824
+ }
6711
6825
 
6712
6826
  // src/dlmm/helpers/fee.ts
6713
6827
 
@@ -7449,7 +7563,7 @@ async function getTokensMintFromPoolAddress(connection, poolAddress, opt) {
7449
7563
  );
7450
7564
  const program = new (0, _anchor.Program)(
7451
7565
  IDL,
7452
- LBCLMM_PROGRAM_IDS[_nullishCoalesce(_optionalChain([opt, 'optionalAccess', _18 => _18.cluster]), () => ( "mainnet-beta"))],
7566
+ LBCLMM_PROGRAM_IDS[_nullishCoalesce(_optionalChain([opt, 'optionalAccess', _21 => _21.cluster]), () => ( "mainnet-beta"))],
7453
7567
  provider
7454
7568
  );
7455
7569
  const poolAccount = await program.account.lbPair.fetchNullable(
@@ -7469,6 +7583,10 @@ function chunks(array, size) {
7469
7583
  (_, index) => array.slice(index * size, (index + 1) * size)
7470
7584
  );
7471
7585
  }
7586
+ function range(min, max, mapfn) {
7587
+ const length = max - min + 1;
7588
+ return Array.from({ length }, (_, i) => mapfn(min + i));
7589
+ }
7472
7590
  async function chunkedFetchMultiplePoolAccount(program, pks, chunkSize = 100) {
7473
7591
  const accounts = (await Promise.all(
7474
7592
  chunks(pks, chunkSize).map(
@@ -7523,7 +7641,7 @@ async function getTokenBalance(conn, tokenAccount) {
7523
7641
  var parseLogs = (eventParser, logs) => {
7524
7642
  if (!logs.length)
7525
7643
  throw new Error("No logs found");
7526
- for (const event of _optionalChain([eventParser, 'optionalAccess', _19 => _19.parseLogs, 'call', _20 => _20(logs)])) {
7644
+ for (const event of _optionalChain([eventParser, 'optionalAccess', _22 => _22.parseLogs, 'call', _23 => _23(logs)])) {
7527
7645
  return event.data;
7528
7646
  }
7529
7647
  throw new Error("No events found");
@@ -7574,66 +7692,37 @@ async function chunkedGetMultipleAccountInfos(connection, pks, chunkSize = 100)
7574
7692
  )).flat();
7575
7693
  return accountInfos;
7576
7694
  }
7577
- var computeBudgetIx = () => {
7578
- return _web3js.ComputeBudgetProgram.setComputeUnitLimit({
7579
- units: 14e5
7580
- });
7581
- };
7582
-
7583
- // src/dlmm/index.ts
7584
- var _bytes = require('@coral-xyz/anchor/dist/cjs/utils/bytes');
7585
-
7586
-
7587
-
7588
-
7589
-
7590
-
7591
-
7592
-
7593
-
7594
-
7595
-
7596
- // src/dlmm/error.ts
7597
-
7598
- var DLMMError = class extends Error {
7599
-
7600
-
7601
-
7602
- constructor(error) {
7603
- let _errorCode = 0;
7604
- let _errorName = "Something went wrong";
7605
- let _errorMessage = "Something went wrong";
7606
- if (error instanceof Error) {
7607
- const anchorError = _anchor.AnchorError.parse(
7608
- JSON.parse(JSON.stringify(error)).logs
7609
- );
7610
- if (_optionalChain([anchorError, 'optionalAccess', _21 => _21.program, 'access', _22 => _22.toBase58, 'call', _23 => _23()]) === LBCLMM_PROGRAM_IDS["mainnet-beta"]) {
7611
- _errorCode = anchorError.error.errorCode.number;
7612
- _errorName = anchorError.error.errorCode.code;
7613
- _errorMessage = anchorError.error.errorMessage;
7614
- }
7615
- } else {
7616
- const idlError = IDL.errors.find((err) => err.code === error);
7617
- if (idlError) {
7618
- _errorCode = idlError.code;
7619
- _errorName = idlError.name;
7620
- _errorMessage = idlError.msg;
7621
- }
7622
- }
7623
- super(_errorMessage);
7624
- this.errorCode = _errorCode;
7625
- this.errorName = _errorName;
7626
- this.errorMessage = _errorMessage;
7695
+ var getEstimatedComputeUnitUsageWithBuffer = async (connection, instructions, feePayer, buffer) => {
7696
+ if (!buffer) {
7697
+ buffer = 0.1;
7627
7698
  }
7628
- };
7629
- var DlmmSdkError = class extends Error {
7630
-
7631
-
7632
- constructor(name, message) {
7633
- super();
7634
- this.name = name;
7635
- this.message = message;
7699
+ buffer = Math.max(0, buffer);
7700
+ buffer = Math.min(1, buffer);
7701
+ const estimatedComputeUnitUsage = await _helpers.getSimulationComputeUnits.call(void 0,
7702
+ connection,
7703
+ instructions,
7704
+ feePayer,
7705
+ []
7706
+ );
7707
+ let extraComputeUnitBuffer = estimatedComputeUnitUsage * buffer;
7708
+ if (extraComputeUnitBuffer > MAX_CU_BUFFER) {
7709
+ extraComputeUnitBuffer = MAX_CU_BUFFER;
7710
+ } else if (extraComputeUnitBuffer < MIN_CU_BUFFER) {
7711
+ extraComputeUnitBuffer = MIN_CU_BUFFER;
7636
7712
  }
7713
+ return estimatedComputeUnitUsage + extraComputeUnitBuffer;
7714
+ };
7715
+ var getEstimatedComputeUnitIxWithBuffer = async (connection, instructions, feePayer, buffer) => {
7716
+ const units = await getEstimatedComputeUnitUsageWithBuffer(
7717
+ connection,
7718
+ instructions,
7719
+ feePayer,
7720
+ buffer
7721
+ ).catch((error) => {
7722
+ console.error("Error::getEstimatedComputeUnitUsageWithBuffer", error);
7723
+ return 14e5;
7724
+ });
7725
+ return _web3js.ComputeBudgetProgram.setComputeUnitLimit({ units });
7637
7726
  };
7638
7727
 
7639
7728
  // src/dlmm/index.ts
@@ -8785,15 +8874,15 @@ var DLMM = class {
8785
8874
  * @returns an object with two properties: "activeBin" and "bins". The value of "activeBin" is the
8786
8875
  * active bin ID of the lbPair, and the value of "bins" is an array of BinLiquidity objects.
8787
8876
  */
8788
- async getBinsBetweenLowerAndUpperBound(lowerBinId, upperBinId, lowerBinArrays, upperBinArrays) {
8877
+ async getBinsBetweenLowerAndUpperBound(lowerBinId, upperBinId, lowerBinArray, upperBinArray) {
8789
8878
  const bins = await this.getBins(
8790
8879
  this.pubkey,
8791
8880
  lowerBinId,
8792
8881
  upperBinId,
8793
8882
  this.tokenX.decimal,
8794
8883
  this.tokenY.decimal,
8795
- lowerBinArrays,
8796
- upperBinArrays
8884
+ lowerBinArray,
8885
+ upperBinArray
8797
8886
  );
8798
8887
  return { activeBin: this.lbPair.activeId, bins };
8799
8888
  }
@@ -9099,7 +9188,6 @@ var DLMM = class {
9099
9188
  maxBinId,
9100
9189
  user
9101
9190
  }) {
9102
- const setComputeUnitLimitIx = computeBudgetIx();
9103
9191
  const createPositionIx = await this.program.methods.initializePosition(minBinId, maxBinId - minBinId + 1).accounts({
9104
9192
  payer: user,
9105
9193
  position: positionPubKey,
@@ -9116,12 +9204,18 @@ var DLMM = class {
9116
9204
  lowerBinArrayIndex,
9117
9205
  user
9118
9206
  );
9207
+ const instructions = [createPositionIx, ...createBinArrayIxs];
9208
+ const setCUIx = await getEstimatedComputeUnitIxWithBuffer(
9209
+ this.program.provider.connection,
9210
+ instructions,
9211
+ user
9212
+ );
9119
9213
  const { blockhash, lastValidBlockHeight } = await this.program.provider.connection.getLatestBlockhash("confirmed");
9120
9214
  return new (0, _web3js.Transaction)({
9121
9215
  blockhash,
9122
9216
  lastValidBlockHeight,
9123
9217
  feePayer: user
9124
- }).add(setComputeUnitLimitIx, createPositionIx, ...createBinArrayIxs);
9218
+ }).add(setCUIx, ...instructions);
9125
9219
  }
9126
9220
  /**
9127
9221
  * The function `initializePositionAndAddLiquidityByStrategy` function is used to initializes a position and adds liquidity
@@ -9145,8 +9239,7 @@ var DLMM = class {
9145
9239
  }) {
9146
9240
  const { maxBinId, minBinId } = strategy;
9147
9241
  const maxActiveBinSlippage = slippage ? Math.ceil(slippage / (this.lbPair.binStep / 100)) : MAX_ACTIVE_BIN_SLIPPAGE;
9148
- const setComputeUnitLimitIx = computeBudgetIx();
9149
- const preInstructions = [setComputeUnitLimitIx];
9242
+ const preInstructions = [];
9150
9243
  const initializePositionIx = await this.program.methods.initializePosition(minBinId, maxBinId - minBinId + 1).accounts({
9151
9244
  payer: user,
9152
9245
  position: positionPubKey,
@@ -9246,13 +9339,24 @@ var DLMM = class {
9246
9339
  tokenYProgram: _spltoken.TOKEN_PROGRAM_ID
9247
9340
  };
9248
9341
  const programMethod = this.program.methods.addLiquidityByStrategy(liquidityParams);
9249
- const createPositionTx = await programMethod.accounts(addLiquidityAccounts).preInstructions(preInstructions).postInstructions(postInstructions).transaction();
9342
+ const addLiquidityIx = await programMethod.accounts(addLiquidityAccounts).instruction();
9343
+ const instructions = [
9344
+ ...preInstructions,
9345
+ addLiquidityIx,
9346
+ ...postInstructions
9347
+ ];
9348
+ const setCUIx = await getEstimatedComputeUnitIxWithBuffer(
9349
+ this.program.provider.connection,
9350
+ instructions,
9351
+ user
9352
+ );
9353
+ instructions.unshift(setCUIx);
9250
9354
  const { blockhash, lastValidBlockHeight } = await this.program.provider.connection.getLatestBlockhash("confirmed");
9251
9355
  return new (0, _web3js.Transaction)({
9252
9356
  blockhash,
9253
9357
  lastValidBlockHeight,
9254
9358
  feePayer: user
9255
- }).add(createPositionTx);
9359
+ }).add(...instructions);
9256
9360
  }
9257
9361
  /**
9258
9362
  * The function `initializePositionAndAddLiquidityByWeight` function is used to initializes a position and adds liquidity
@@ -9351,7 +9455,6 @@ var DLMM = class {
9351
9455
  const closeWrappedSOLIx = await unwrapSOLInstruction(user);
9352
9456
  closeWrappedSOLIx && postInstructions.push(closeWrappedSOLIx);
9353
9457
  }
9354
- const setComputeUnitLimitIx = computeBudgetIx();
9355
9458
  const minBinId = Math.min(...binIds);
9356
9459
  const maxBinId = Math.max(...binIds);
9357
9460
  const minBinArrayIndex = binIdToBinArrayIndex(new (0, _anchor.BN)(minBinId));
@@ -9416,19 +9519,34 @@ var DLMM = class {
9416
9519
  const isOneSideDeposit = totalXAmount.isZero() || totalYAmount.isZero();
9417
9520
  const programMethod = isOneSideDeposit ? this.program.methods.addLiquidityOneSide(oneSideLiquidityParams) : this.program.methods.addLiquidityByWeight(liquidityParams);
9418
9521
  if (xYAmountDistribution.length < MAX_BIN_LENGTH_ALLOWED_IN_ONE_TX) {
9419
- const addLiqTx2 = await programMethod.accounts(
9522
+ const addLiqIx2 = await programMethod.accounts(
9420
9523
  isOneSideDeposit ? oneSideAddLiquidityAccounts : addLiquidityAccounts
9421
- ).preInstructions([setComputeUnitLimitIx, ...preInstructions]).postInstructions(postInstructions).transaction();
9524
+ ).instruction();
9525
+ const instructions = [...preInstructions, addLiqIx2, ...postInstructions];
9526
+ const setCUIx2 = await getEstimatedComputeUnitIxWithBuffer(
9527
+ this.program.provider.connection,
9528
+ instructions,
9529
+ user
9530
+ );
9531
+ instructions.unshift(setCUIx2);
9422
9532
  const { blockhash: blockhash2, lastValidBlockHeight: lastValidBlockHeight2 } = await this.program.provider.connection.getLatestBlockhash("confirmed");
9423
9533
  return new (0, _web3js.Transaction)({
9424
9534
  blockhash: blockhash2,
9425
9535
  lastValidBlockHeight: lastValidBlockHeight2,
9426
9536
  feePayer: user
9427
- }).add(addLiqTx2);
9537
+ }).add(...instructions);
9428
9538
  }
9429
- const addLiqTx = await programMethod.accounts(
9539
+ const addLiqIx = await programMethod.accounts(
9430
9540
  isOneSideDeposit ? oneSideAddLiquidityAccounts : addLiquidityAccounts
9431
- ).preInstructions([setComputeUnitLimitIx]).transaction();
9541
+ ).instruction();
9542
+ const setCUIx = await getEstimatedComputeUnitIxWithBuffer(
9543
+ this.program.provider.connection,
9544
+ [addLiqIx],
9545
+ user,
9546
+ DEFAULT_ADD_LIQUIDITY_CU
9547
+ // The function return multiple transactions that dependent on each other, simulation will fail
9548
+ );
9549
+ const mainInstructions = [setCUIx, addLiqIx];
9432
9550
  const transactions = [];
9433
9551
  const { blockhash, lastValidBlockHeight } = await this.program.provider.connection.getLatestBlockhash("confirmed");
9434
9552
  if (preInstructions.length) {
@@ -9443,7 +9561,7 @@ var DLMM = class {
9443
9561
  blockhash,
9444
9562
  lastValidBlockHeight,
9445
9563
  feePayer: user
9446
- }).add(addLiqTx);
9564
+ }).add(...mainInstructions);
9447
9565
  transactions.push(mainTx);
9448
9566
  if (postInstructions.length) {
9449
9567
  const postInstructionsTx = new (0, _web3js.Transaction)({
@@ -9478,8 +9596,6 @@ var DLMM = class {
9478
9596
  const { maxBinId, minBinId } = strategy;
9479
9597
  const maxActiveBinSlippage = slippage ? Math.ceil(slippage / (this.lbPair.binStep / 100)) : MAX_ACTIVE_BIN_SLIPPAGE;
9480
9598
  const preInstructions = [];
9481
- const setComputeUnitLimitIx = computeBudgetIx();
9482
- preInstructions.push(setComputeUnitLimitIx);
9483
9599
  const minBinArrayIndex = binIdToBinArrayIndex(new (0, _anchor.BN)(minBinId));
9484
9600
  const maxBinArrayIndex = binIdToBinArrayIndex(new (0, _anchor.BN)(maxBinId));
9485
9601
  const useExtension = isOverflowDefaultBinArrayBitmap(minBinArrayIndex) || isOverflowDefaultBinArrayBitmap(maxBinArrayIndex);
@@ -9573,13 +9689,24 @@ var DLMM = class {
9573
9689
  tokenYProgram: _spltoken.TOKEN_PROGRAM_ID
9574
9690
  };
9575
9691
  const programMethod = this.program.methods.addLiquidityByStrategy(liquidityParams);
9576
- const createPositionTx = await programMethod.accounts(addLiquidityAccounts).preInstructions(preInstructions).postInstructions(postInstructions).transaction();
9692
+ const addLiquidityIx = await programMethod.accounts(addLiquidityAccounts).instruction();
9693
+ const instructions = [
9694
+ ...preInstructions,
9695
+ addLiquidityIx,
9696
+ ...postInstructions
9697
+ ];
9698
+ const setCUIx = await getEstimatedComputeUnitIxWithBuffer(
9699
+ this.program.provider.connection,
9700
+ instructions,
9701
+ user
9702
+ );
9703
+ instructions.unshift(setCUIx);
9577
9704
  const { blockhash, lastValidBlockHeight } = await this.program.provider.connection.getLatestBlockhash("confirmed");
9578
9705
  return new (0, _web3js.Transaction)({
9579
9706
  blockhash,
9580
9707
  lastValidBlockHeight,
9581
9708
  feePayer: user
9582
- }).add(createPositionTx);
9709
+ }).add(...instructions);
9583
9710
  }
9584
9711
  /**
9585
9712
  * The `addLiquidityByWeight` function is used to add liquidity to existing position
@@ -9699,7 +9826,6 @@ var DLMM = class {
9699
9826
  const closeWrappedSOLIx = await unwrapSOLInstruction(user);
9700
9827
  closeWrappedSOLIx && postInstructions.push(closeWrappedSOLIx);
9701
9828
  }
9702
- const setComputeUnitLimitIx = computeBudgetIx();
9703
9829
  const liquidityParams = {
9704
9830
  amountX: totalXAmount,
9705
9831
  amountY: totalYAmount,
@@ -9744,19 +9870,32 @@ var DLMM = class {
9744
9870
  const isOneSideDeposit = totalXAmount.isZero() || totalYAmount.isZero();
9745
9871
  const programMethod = isOneSideDeposit ? this.program.methods.addLiquidityOneSide(oneSideLiquidityParams) : this.program.methods.addLiquidityByWeight(liquidityParams);
9746
9872
  if (xYAmountDistribution.length < MAX_BIN_LENGTH_ALLOWED_IN_ONE_TX) {
9747
- const addLiqTx2 = await programMethod.accounts(
9873
+ const addLiqIx2 = await programMethod.accounts(
9748
9874
  isOneSideDeposit ? oneSideAddLiquidityAccounts : addLiquidityAccounts
9749
- ).preInstructions([setComputeUnitLimitIx, ...preInstructions]).postInstructions(postInstructions).transaction();
9875
+ ).instruction();
9876
+ const instructions = [...preInstructions, addLiqIx2, ...postInstructions];
9877
+ const setCUIx2 = await getEstimatedComputeUnitIxWithBuffer(
9878
+ this.program.provider.connection,
9879
+ instructions,
9880
+ user
9881
+ );
9882
+ instructions.unshift(setCUIx2);
9750
9883
  const { blockhash: blockhash2, lastValidBlockHeight: lastValidBlockHeight2 } = await this.program.provider.connection.getLatestBlockhash("confirmed");
9751
9884
  return new (0, _web3js.Transaction)({
9752
9885
  blockhash: blockhash2,
9753
9886
  lastValidBlockHeight: lastValidBlockHeight2,
9754
9887
  feePayer: user
9755
- }).add(addLiqTx2);
9888
+ }).add(...instructions);
9756
9889
  }
9757
- const addLiqTx = await programMethod.accounts(
9890
+ const addLiqIx = await programMethod.accounts(
9758
9891
  isOneSideDeposit ? oneSideAddLiquidityAccounts : addLiquidityAccounts
9759
- ).preInstructions([setComputeUnitLimitIx]).transaction();
9892
+ ).instruction();
9893
+ const setCUIx = await getEstimatedComputeUnitIxWithBuffer(
9894
+ this.program.provider.connection,
9895
+ [addLiqIx],
9896
+ user
9897
+ );
9898
+ const mainInstructions = [setCUIx, addLiqIx];
9760
9899
  const transactions = [];
9761
9900
  const { blockhash, lastValidBlockHeight } = await this.program.provider.connection.getLatestBlockhash("confirmed");
9762
9901
  if (preInstructions.length) {
@@ -9771,7 +9910,7 @@ var DLMM = class {
9771
9910
  blockhash,
9772
9911
  lastValidBlockHeight,
9773
9912
  feePayer: user
9774
- }).add(addLiqTx);
9913
+ }).add(...mainInstructions);
9775
9914
  transactions.push(mainTx);
9776
9915
  if (postInstructions.length) {
9777
9916
  const postInstructionsTx = new (0, _web3js.Transaction)({
@@ -9816,8 +9955,6 @@ var DLMM = class {
9816
9955
  this.program.programId
9817
9956
  );
9818
9957
  const preInstructions = [];
9819
- const setComputeUnitLimitIx = computeBudgetIx();
9820
- preInstructions.push(setComputeUnitLimitIx);
9821
9958
  const walletToReceiveFee = feeOwner.equals(_web3js.PublicKey.default) ? user : feeOwner;
9822
9959
  const [
9823
9960
  { ataPubKey: userTokenX, ix: createPayerTokenXIx },
@@ -9925,7 +10062,7 @@ var DLMM = class {
9925
10062
  const maxBinArrayIndex = binIdToBinArrayIndex(new (0, _anchor.BN)(maxBinId));
9926
10063
  const useExtension = isOverflowDefaultBinArrayBitmap(minBinArrayIndex) || isOverflowDefaultBinArrayBitmap(maxBinArrayIndex);
9927
10064
  const binArrayBitmapExtension = useExtension ? deriveBinArrayBitmapExtension(this.pubkey, this.program.programId)[0] : null;
9928
- const removeLiquidityTx = await this.program.methods.removeLiquidityByRange(minBinId, maxBinId, bps.toNumber()).accounts({
10065
+ const removeLiquidityIx = await this.program.methods.removeLiquidityByRange(minBinId, maxBinId, bps.toNumber()).accounts({
9929
10066
  position,
9930
10067
  lbPair,
9931
10068
  userTokenX,
@@ -9940,26 +10077,43 @@ var DLMM = class {
9940
10077
  tokenXProgram: _spltoken.TOKEN_PROGRAM_ID,
9941
10078
  tokenYProgram: _spltoken.TOKEN_PROGRAM_ID,
9942
10079
  sender: user
9943
- }).preInstructions(preInstructions).postInstructions(postInstructions).transaction();
9944
- const { blockhash, lastValidBlockHeight } = await this.program.provider.connection.getLatestBlockhash("confirmed");
10080
+ }).instruction();
10081
+ const instructions = [
10082
+ ...preInstructions,
10083
+ removeLiquidityIx,
10084
+ ...postInstructions
10085
+ ];
10086
+ const setCUIx = await getEstimatedComputeUnitIxWithBuffer(
10087
+ this.program.provider.connection,
10088
+ instructions,
10089
+ user
10090
+ );
10091
+ instructions.unshift(setCUIx);
9945
10092
  if (secondTransactionsIx.length) {
10093
+ const setCUIx2 = await getEstimatedComputeUnitIxWithBuffer(
10094
+ this.program.provider.connection,
10095
+ secondTransactionsIx,
10096
+ user
10097
+ );
10098
+ const { blockhash, lastValidBlockHeight } = await this.program.provider.connection.getLatestBlockhash("confirmed");
9946
10099
  const claimRewardsTx = new (0, _web3js.Transaction)({
9947
10100
  blockhash,
9948
10101
  lastValidBlockHeight,
9949
10102
  feePayer: user
9950
- }).add(...secondTransactionsIx);
10103
+ }).add(setCUIx2, ...secondTransactionsIx);
9951
10104
  const mainTx = new (0, _web3js.Transaction)({
9952
10105
  blockhash,
9953
10106
  lastValidBlockHeight,
9954
10107
  feePayer: user
9955
- }).add(removeLiquidityTx);
10108
+ }).add(...instructions);
9956
10109
  return [mainTx, claimRewardsTx];
9957
10110
  } else {
10111
+ const { blockhash, lastValidBlockHeight } = await this.program.provider.connection.getLatestBlockhash("confirmed");
9958
10112
  return new (0, _web3js.Transaction)({
9959
10113
  blockhash,
9960
10114
  lastValidBlockHeight,
9961
10115
  feePayer: user
9962
- }).add(removeLiquidityTx);
10116
+ }).add(...instructions);
9963
10117
  }
9964
10118
  }
9965
10119
  /**
@@ -10237,7 +10391,7 @@ var DLMM = class {
10237
10391
  binArraysPubkey
10238
10392
  }) {
10239
10393
  const { tokenXMint, tokenYMint, reserveX, reserveY, activeId, oracle } = await this.program.account.lbPair.fetch(lbPair);
10240
- const preInstructions = [computeBudgetIx()];
10394
+ const preInstructions = [];
10241
10395
  const postInstructions = [];
10242
10396
  const [
10243
10397
  { ataPubKey: userTokenIn, ix: createInTokenAccountIx },
@@ -10280,7 +10434,7 @@ var DLMM = class {
10280
10434
  pubkey
10281
10435
  };
10282
10436
  });
10283
- const swapTx = await this.program.methods.swapExactOut(maxInAmount, outAmount).accounts({
10437
+ const swapIx = await this.program.methods.swapExactOut(maxInAmount, outAmount).accounts({
10284
10438
  lbPair,
10285
10439
  reserveX,
10286
10440
  reserveY,
@@ -10294,13 +10448,20 @@ var DLMM = class {
10294
10448
  binArrayBitmapExtension: this.binArrayBitmapExtension ? this.binArrayBitmapExtension.publicKey : null,
10295
10449
  oracle,
10296
10450
  hostFeeIn: null
10297
- }).remainingAccounts(binArrays).preInstructions(preInstructions).postInstructions(postInstructions).transaction();
10451
+ }).remainingAccounts(binArrays).instruction();
10452
+ const instructions = [...preInstructions, swapIx, ...postInstructions];
10453
+ const setCUIx = await getEstimatedComputeUnitIxWithBuffer(
10454
+ this.program.provider.connection,
10455
+ instructions,
10456
+ user
10457
+ );
10458
+ instructions.unshift(setCUIx);
10298
10459
  const { blockhash, lastValidBlockHeight } = await this.program.provider.connection.getLatestBlockhash("confirmed");
10299
10460
  return new (0, _web3js.Transaction)({
10300
10461
  blockhash,
10301
10462
  lastValidBlockHeight,
10302
10463
  feePayer: user
10303
- }).add(swapTx);
10464
+ }).add(...instructions);
10304
10465
  }
10305
10466
  /**
10306
10467
  * Returns a transaction to be signed and sent by user performing swap.
@@ -10324,7 +10485,7 @@ var DLMM = class {
10324
10485
  binArraysPubkey
10325
10486
  }) {
10326
10487
  const { tokenXMint, tokenYMint, reserveX, reserveY, activeId, oracle } = await this.program.account.lbPair.fetch(lbPair);
10327
- const preInstructions = [computeBudgetIx()];
10488
+ const preInstructions = [];
10328
10489
  const postInstructions = [];
10329
10490
  const [
10330
10491
  { ataPubKey: userTokenIn, ix: createInTokenAccountIx },
@@ -10367,7 +10528,7 @@ var DLMM = class {
10367
10528
  pubkey
10368
10529
  };
10369
10530
  });
10370
- const swapTx = await this.program.methods.swapWithPriceImpact(
10531
+ const swapIx = await this.program.methods.swapWithPriceImpact(
10371
10532
  inAmount,
10372
10533
  this.lbPair.activeId,
10373
10534
  priceImpact.toNumber()
@@ -10385,13 +10546,20 @@ var DLMM = class {
10385
10546
  binArrayBitmapExtension: this.binArrayBitmapExtension ? this.binArrayBitmapExtension.publicKey : null,
10386
10547
  oracle,
10387
10548
  hostFeeIn: null
10388
- }).remainingAccounts(binArrays).preInstructions(preInstructions).postInstructions(postInstructions).transaction();
10549
+ }).remainingAccounts(binArrays).instruction();
10550
+ const instructions = [...preInstructions, swapIx, ...postInstructions];
10551
+ const setCUIx = await getEstimatedComputeUnitIxWithBuffer(
10552
+ this.program.provider.connection,
10553
+ instructions,
10554
+ user
10555
+ );
10556
+ instructions.unshift(setCUIx);
10389
10557
  const { blockhash, lastValidBlockHeight } = await this.program.provider.connection.getLatestBlockhash("confirmed");
10390
10558
  return new (0, _web3js.Transaction)({
10391
10559
  blockhash,
10392
10560
  lastValidBlockHeight,
10393
10561
  feePayer: user
10394
- }).add(swapTx);
10562
+ }).add(...instructions);
10395
10563
  }
10396
10564
  /**
10397
10565
  * Returns a transaction to be signed and sent by user performing swap.
@@ -10415,7 +10583,7 @@ var DLMM = class {
10415
10583
  binArraysPubkey
10416
10584
  }) {
10417
10585
  const { tokenXMint, tokenYMint, reserveX, reserveY, activeId, oracle } = await this.program.account.lbPair.fetch(lbPair);
10418
- const preInstructions = [computeBudgetIx()];
10586
+ const preInstructions = [];
10419
10587
  const postInstructions = [];
10420
10588
  const [
10421
10589
  { ataPubKey: userTokenIn, ix: createInTokenAccountIx },
@@ -10458,7 +10626,7 @@ var DLMM = class {
10458
10626
  pubkey
10459
10627
  };
10460
10628
  });
10461
- const swapTx = await this.program.methods.swap(inAmount, minOutAmount).accounts({
10629
+ const swapIx = await this.program.methods.swap(inAmount, minOutAmount).accounts({
10462
10630
  lbPair,
10463
10631
  reserveX,
10464
10632
  reserveY,
@@ -10474,13 +10642,20 @@ var DLMM = class {
10474
10642
  binArrayBitmapExtension: this.binArrayBitmapExtension ? this.binArrayBitmapExtension.publicKey : null,
10475
10643
  oracle,
10476
10644
  hostFeeIn: null
10477
- }).remainingAccounts(binArrays).preInstructions(preInstructions).postInstructions(postInstructions).transaction();
10645
+ }).remainingAccounts(binArrays).instruction();
10646
+ const instructions = [...preInstructions, swapIx, ...postInstructions];
10647
+ const setCUIx = await getEstimatedComputeUnitIxWithBuffer(
10648
+ this.program.provider.connection,
10649
+ instructions,
10650
+ user
10651
+ );
10652
+ instructions.unshift(setCUIx);
10478
10653
  const { blockhash, lastValidBlockHeight } = await this.program.provider.connection.getLatestBlockhash("confirmed");
10479
10654
  return new (0, _web3js.Transaction)({
10480
10655
  blockhash,
10481
10656
  lastValidBlockHeight,
10482
10657
  feePayer: user
10483
- }).add(swapTx);
10658
+ }).add(...instructions);
10484
10659
  }
10485
10660
  /**
10486
10661
  * The claimLMReward function is used to claim rewards for a specific position owned by a specific owner.
@@ -10499,12 +10674,18 @@ var DLMM = class {
10499
10674
  });
10500
10675
  if (!claimTransactions.length)
10501
10676
  return;
10677
+ const instructions = claimTransactions.map((t) => t.instructions).flat();
10678
+ const setCUIx = await getEstimatedComputeUnitIxWithBuffer(
10679
+ this.program.provider.connection,
10680
+ instructions,
10681
+ owner
10682
+ );
10502
10683
  const { blockhash, lastValidBlockHeight } = await this.program.provider.connection.getLatestBlockhash("confirmed");
10503
10684
  return new (0, _web3js.Transaction)({
10504
10685
  blockhash,
10505
10686
  lastValidBlockHeight,
10506
10687
  feePayer: owner
10507
- }).add(...claimTransactions);
10688
+ }).add(setCUIx, ...claimTransactions);
10508
10689
  }
10509
10690
  /**
10510
10691
  * The `claimAllLMRewards` function is used to claim all liquidity mining rewards for a given owner
@@ -10530,6 +10711,14 @@ var DLMM = class {
10530
10711
  })
10531
10712
  )).flat();
10532
10713
  const chunkedClaimAllTx = chunks(claimAllTxs, MAX_CLAIM_ALL_ALLOWED);
10714
+ if (chunkedClaimAllTx.length === 0)
10715
+ return [];
10716
+ const setCUIx = await getEstimatedComputeUnitIxWithBuffer(
10717
+ this.program.provider.connection,
10718
+ // First tx simulation will success because it will create all the ATA. Then, we use the simulated CU as references for the rest
10719
+ chunkedClaimAllTx[0].map((t) => t.instructions).flat(),
10720
+ owner
10721
+ );
10533
10722
  const { blockhash, lastValidBlockHeight } = await this.program.provider.connection.getLatestBlockhash("confirmed");
10534
10723
  return Promise.all(
10535
10724
  chunkedClaimAllTx.map(async (claimAllTx) => {
@@ -10537,7 +10726,7 @@ var DLMM = class {
10537
10726
  feePayer: owner,
10538
10727
  blockhash,
10539
10728
  lastValidBlockHeight
10540
- }).add(computeBudgetIx()).add(...claimAllTx);
10729
+ }).add(setCUIx).add(...claimAllTx);
10541
10730
  })
10542
10731
  );
10543
10732
  }
@@ -10596,14 +10785,22 @@ var DLMM = class {
10596
10785
  })
10597
10786
  )).flat();
10598
10787
  const chunkedClaimAllTx = chunks(claimAllTxs, MAX_CLAIM_ALL_ALLOWED);
10788
+ if (chunkedClaimAllTx.length === 0)
10789
+ return [];
10790
+ const setCUIx = await getEstimatedComputeUnitIxWithBuffer(
10791
+ this.program.provider.connection,
10792
+ // First tx simulation will success because it will create all the ATA. Then, we use the simulated CU as references for the rest
10793
+ chunkedClaimAllTx[0].map((t) => t.instructions).flat(),
10794
+ owner
10795
+ );
10796
+ const { blockhash, lastValidBlockHeight } = await this.program.provider.connection.getLatestBlockhash("confirmed");
10599
10797
  return Promise.all(
10600
10798
  chunkedClaimAllTx.map(async (claimAllTx) => {
10601
- const { recentBlockhash, lastValidBlockHeight } = claimAllTx[0];
10602
10799
  return new (0, _web3js.Transaction)({
10603
10800
  feePayer: owner,
10604
- blockhash: recentBlockhash,
10801
+ blockhash,
10605
10802
  lastValidBlockHeight
10606
- }).add(computeBudgetIx()).add(...claimAllTx);
10803
+ }).add(setCUIx).add(...claimAllTx);
10607
10804
  })
10608
10805
  );
10609
10806
  }
@@ -10670,11 +10867,22 @@ var DLMM = class {
10670
10867
  const { blockhash, lastValidBlockHeight } = await this.program.provider.connection.getLatestBlockhash("confirmed");
10671
10868
  return Promise.all(
10672
10869
  claimAllTxs.map(async (claimAllTx) => {
10870
+ const mainInstructions = claimAllTx.map((t) => t.instructions).flat();
10871
+ const instructions = [
10872
+ ...preInstructions,
10873
+ ...mainInstructions,
10874
+ ...postInstructions
10875
+ ];
10876
+ const setCUIx = await getEstimatedComputeUnitIxWithBuffer(
10877
+ this.program.provider.connection,
10878
+ instructions,
10879
+ owner
10880
+ );
10673
10881
  const tx = new (0, _web3js.Transaction)({
10674
10882
  feePayer: owner,
10675
10883
  blockhash,
10676
10884
  lastValidBlockHeight
10677
- }).add(computeBudgetIx());
10885
+ }).add(setCUIx);
10678
10886
  if (preInstructions.length)
10679
10887
  tx.add(...preInstructions);
10680
10888
  tx.add(...claimAllTx);
@@ -10773,7 +10981,7 @@ var DLMM = class {
10773
10981
  upperBinArray,
10774
10982
  positionPda
10775
10983
  ]);
10776
- let instructions = [computeBudgetIx()];
10984
+ let instructions = [];
10777
10985
  const lowerBinArrayAccount = accounts[0];
10778
10986
  if (!lowerBinArrayAccount && !appendedInitBinArrayIx.has(lowerBinArray.toBase58())) {
10779
10987
  instructions.push(
@@ -10812,8 +11020,15 @@ var DLMM = class {
10812
11020
  );
10813
11021
  }
10814
11022
  if (instructions.length > 1) {
11023
+ instructions.push(
11024
+ await getEstimatedComputeUnitIxWithBuffer(
11025
+ this.program.provider.connection,
11026
+ instructions,
11027
+ owner
11028
+ )
11029
+ );
10815
11030
  initializeBinArraysAndPositionIxs.push(instructions);
10816
- instructions = [computeBudgetIx()];
11031
+ instructions = [];
10817
11032
  }
10818
11033
  const positionDeposited = positionAccount && this.program.coder.accounts.decode("positionV2", positionAccount.data).liquidityShares.reduce((total, cur) => total.add(cur), new (0, _anchor.BN)(0)).gt(new (0, _anchor.BN)(0));
10819
11034
  if (!positionDeposited) {
@@ -10869,7 +11084,12 @@ var DLMM = class {
10869
11084
  }).instruction()
10870
11085
  );
10871
11086
  }
10872
- addLiquidityIxs.push(instructions);
11087
+ addLiquidityIxs.push([
11088
+ _web3js.ComputeBudgetProgram.setComputeUnitLimit({
11089
+ units: DEFAULT_ADD_LIQUIDITY_CU
11090
+ }),
11091
+ ...instructions
11092
+ ]);
10873
11093
  }
10874
11094
  }
10875
11095
  return {
@@ -11114,7 +11334,7 @@ var DLMM = class {
11114
11334
  owner,
11115
11335
  true
11116
11336
  );
11117
- let initializePositionByOperatorTx = await this.program.methods.initializePositionByOperator(
11337
+ const initializePositionByOperatorTx = await this.program.methods.initializePositionByOperator(
11118
11338
  lowerBinId.toNumber(),
11119
11339
  MAX_BIN_PER_POSITION.toNumber(),
11120
11340
  feeOwner,
@@ -11222,11 +11442,22 @@ var DLMM = class {
11222
11442
  const { blockhash, lastValidBlockHeight } = await this.program.provider.connection.getLatestBlockhash("confirmed");
11223
11443
  return Promise.all(
11224
11444
  chunkedClaimAllTx.map(async (claimAllTx) => {
11445
+ const mainIxs = claimAllTx.map((t) => t.instructions).flat();
11446
+ const instructions = [
11447
+ ...preInstructions,
11448
+ ...mainIxs,
11449
+ ...postInstructions
11450
+ ];
11451
+ const setCUIx = await getEstimatedComputeUnitIxWithBuffer(
11452
+ this.program.provider.connection,
11453
+ instructions,
11454
+ owner
11455
+ );
11225
11456
  const tx = new (0, _web3js.Transaction)({
11226
11457
  feePayer: owner,
11227
11458
  blockhash,
11228
11459
  lastValidBlockHeight
11229
- }).add(computeBudgetIx());
11460
+ }).add(setCUIx);
11230
11461
  if (preInstructions.length)
11231
11462
  tx.add(...preInstructions);
11232
11463
  tx.add(...claimAllTx);
@@ -11787,106 +12018,39 @@ var DLMM = class {
11787
12018
  binIds
11788
12019
  };
11789
12020
  }
11790
- async getBins(lbPairPubKey, lowerBinId, upperBinId, baseTokenDecimal, quoteTokenDecimal, lowerBinArrays, upperBinArrays) {
12021
+ async getBins(lbPairPubKey, lowerBinId, upperBinId, baseTokenDecimal, quoteTokenDecimal, lowerBinArray, upperBinArray) {
11791
12022
  const lowerBinArrayIndex = binIdToBinArrayIndex(new (0, _anchor.BN)(lowerBinId));
11792
12023
  const upperBinArrayIndex = binIdToBinArrayIndex(new (0, _anchor.BN)(upperBinId));
11793
- let bins = [];
11794
- if (lowerBinArrayIndex.eq(upperBinArrayIndex)) {
11795
- const [binArrayPubKey] = deriveBinArray(
11796
- lbPairPubKey,
11797
- lowerBinArrayIndex,
11798
- this.program.programId
11799
- );
11800
- const binArray = await _asyncNullishCoalesce(lowerBinArrays, async () => ( await this.program.account.binArray.fetch(binArrayPubKey).catch(() => {
11801
- const [lowerBinId2, upperBinId2] = getBinArrayLowerUpperBinId(lowerBinArrayIndex);
11802
- const binArrayBins = [];
11803
- for (let i = lowerBinId2.toNumber(); i <= upperBinId2.toNumber(); i++) {
11804
- binArrayBins.push({
11805
- amountX: new (0, _anchor.BN)(0),
11806
- amountY: new (0, _anchor.BN)(0),
11807
- liquiditySupply: new (0, _anchor.BN)(0),
11808
- rewardPerTokenStored: [new (0, _anchor.BN)(0), new (0, _anchor.BN)(0)],
11809
- amountXIn: new (0, _anchor.BN)(0),
11810
- amountYIn: new (0, _anchor.BN)(0),
11811
- feeAmountXPerTokenStored: new (0, _anchor.BN)(0),
11812
- feeAmountYPerTokenStored: new (0, _anchor.BN)(0),
11813
- price: new (0, _anchor.BN)(0)
11814
- });
11815
- }
11816
- return {
11817
- bins: binArrayBins,
11818
- index: lowerBinArrayIndex,
11819
- version: 1
11820
- };
11821
- })));
11822
- const [lowerBinIdForBinArray] = getBinArrayLowerUpperBinId(
11823
- binArray.index
11824
- );
11825
- binArray.bins.forEach((bin, idx) => {
11826
- const binId = lowerBinIdForBinArray.toNumber() + idx;
11827
- if (binId >= lowerBinId && binId <= upperBinId) {
11828
- const pricePerLamport = getPriceOfBinByBinId(
11829
- binId,
11830
- this.lbPair.binStep
11831
- ).toString();
11832
- bins.push({
11833
- binId,
11834
- xAmount: bin.amountX,
11835
- yAmount: bin.amountY,
11836
- supply: bin.liquiditySupply,
11837
- price: pricePerLamport,
11838
- version: binArray.version,
11839
- pricePerToken: new (0, _decimaljs2.default)(pricePerLamport).mul(new (0, _decimaljs2.default)(10 ** (baseTokenDecimal - quoteTokenDecimal))).toString()
11840
- });
11841
- }
11842
- });
11843
- } else {
11844
- const [lowerBinArrayPubKey] = deriveBinArray(
11845
- lbPairPubKey,
11846
- lowerBinArrayIndex,
11847
- this.program.programId
11848
- );
11849
- const [upperBinArrayPubKey] = deriveBinArray(
11850
- lbPairPubKey,
11851
- upperBinArrayIndex,
11852
- this.program.programId
11853
- );
11854
- const binArrays = await (async () => {
11855
- if (!lowerBinArrays || !upperBinArrays) {
11856
- return (await this.program.account.binArray.fetchMultiple([
11857
- lowerBinArrayPubKey,
11858
- upperBinArrayPubKey
11859
- ])).filter((binArray) => binArray !== null);
11860
- }
11861
- return [lowerBinArrays, upperBinArrays];
11862
- })();
11863
- binArrays.forEach((binArray) => {
11864
- if (!binArray)
11865
- return;
11866
- const [lowerBinIdForBinArray] = getBinArrayLowerUpperBinId(
11867
- binArray.index
11868
- );
11869
- binArray.bins.forEach((bin, idx) => {
11870
- const binId = lowerBinIdForBinArray.toNumber() + idx;
11871
- if (binId >= lowerBinId && binId <= upperBinId) {
11872
- const pricePerLamport = getPriceOfBinByBinId(
11873
- binId,
11874
- this.lbPair.binStep
11875
- ).toString();
11876
- bins.push({
11877
- binId,
11878
- xAmount: bin.amountX,
11879
- yAmount: bin.amountY,
11880
- supply: bin.liquiditySupply,
11881
- price: pricePerLamport,
11882
- version: binArray.version,
11883
- pricePerToken: new (0, _decimaljs2.default)(pricePerLamport).mul(new (0, _decimaljs2.default)(10 ** (baseTokenDecimal - quoteTokenDecimal))).toString()
11884
- });
11885
- }
11886
- });
11887
- });
11888
- }
11889
- return bins;
12024
+ const hasCachedLowerBinArray = lowerBinArray != null;
12025
+ const hasCachedUpperBinArray = upperBinArray != null;
12026
+ const isSingleBinArray = lowerBinArrayIndex.eq(upperBinArrayIndex);
12027
+ const lowerBinArrayIndexOffset = hasCachedLowerBinArray ? 1 : 0;
12028
+ const upperBinArrayIndexOffset = hasCachedUpperBinArray ? -1 : 0;
12029
+ const binArrayPubkeys = range(
12030
+ lowerBinArrayIndex.toNumber() + lowerBinArrayIndexOffset,
12031
+ upperBinArrayIndex.toNumber() + upperBinArrayIndexOffset,
12032
+ (i) => deriveBinArray(lbPairPubKey, new (0, _anchor.BN)(i), this.program.programId)[0]
12033
+ );
12034
+ const fetchedBinArrays = binArrayPubkeys.length !== 0 ? await this.program.account.binArray.fetchMultiple(binArrayPubkeys) : [];
12035
+ const binArrays = [
12036
+ ...hasCachedLowerBinArray ? [lowerBinArray] : [],
12037
+ ...fetchedBinArrays,
12038
+ ...hasCachedUpperBinArray && !isSingleBinArray ? [upperBinArray] : []
12039
+ ];
12040
+ const binsById = new Map(binArrays.filter((x) => x != null).flatMap(({ bins, index }) => {
12041
+ const [lowerBinId2] = getBinArrayLowerUpperBinId(index);
12042
+ return bins.map((b, i) => [lowerBinId2.toNumber() + i, b]);
12043
+ }));
12044
+ const version = _nullishCoalesce(_optionalChain([binArrays, 'access', _83 => _83.find, 'call', _84 => _84((binArray) => binArray != null), 'optionalAccess', _85 => _85.version]), () => ( 1));
12045
+ return Array.from(enumerateBins(
12046
+ binsById,
12047
+ lowerBinId,
12048
+ upperBinId,
12049
+ this.lbPair.binStep,
12050
+ baseTokenDecimal,
12051
+ quoteTokenDecimal,
12052
+ version
12053
+ ));
11890
12054
  }
11891
12055
  async binArraysToBeCreate(lowerBinArrayIndex, upperBinArrayIndex) {
11892
12056
  const binArrayIndexes = Array.from(
@@ -12167,5 +12331,9 @@ var src_default = DLMM;
12167
12331
 
12168
12332
 
12169
12333
 
12170
- exports.ADMIN = ADMIN; exports.ActivationType = ActivationType; exports.BASIS_POINT_MAX = BASIS_POINT_MAX; exports.BIN_ARRAY_BITMAP_SIZE = BIN_ARRAY_BITMAP_SIZE; exports.BIN_ARRAY_FEE = BIN_ARRAY_FEE; exports.BitmapType = BitmapType; exports.ClockLayout = ClockLayout; exports.DLMMError = DLMMError; exports.DlmmSdkError = DlmmSdkError; exports.EXTENSION_BINARRAY_BITMAP_SIZE = EXTENSION_BINARRAY_BITMAP_SIZE; exports.FEE_PRECISION = FEE_PRECISION; exports.IDL = IDL; exports.ILM_BASE = ILM_BASE; exports.LBCLMM_PROGRAM_IDS = LBCLMM_PROGRAM_IDS; exports.MAX_ACTIVE_BIN_SLIPPAGE = MAX_ACTIVE_BIN_SLIPPAGE; exports.MAX_BIN_ARRAY_SIZE = MAX_BIN_ARRAY_SIZE; exports.MAX_BIN_LENGTH_ALLOWED_IN_ONE_TX = MAX_BIN_LENGTH_ALLOWED_IN_ONE_TX; exports.MAX_BIN_PER_POSITION = MAX_BIN_PER_POSITION; exports.MAX_BIN_PER_TX = MAX_BIN_PER_TX; exports.MAX_CLAIM_ALL_ALLOWED = MAX_CLAIM_ALL_ALLOWED; exports.MAX_FEE_RATE = MAX_FEE_RATE; exports.Network = Network; exports.POSITION_FEE = POSITION_FEE; exports.PRECISION = PRECISION; exports.PairStatus = PairStatus; exports.PairType = PairType; exports.PositionVersion = PositionVersion; exports.SCALE = SCALE; exports.SCALE_OFFSET = SCALE_OFFSET; exports.SIMULATION_USER = SIMULATION_USER; exports.Strategy = Strategy; exports.StrategyType = StrategyType; exports.autoFillXByStrategy = autoFillXByStrategy; exports.autoFillXByWeight = autoFillXByWeight; exports.autoFillYByStrategy = autoFillYByStrategy; exports.autoFillYByWeight = autoFillYByWeight; exports.binIdToBinArrayIndex = binIdToBinArrayIndex; exports.calculateBidAskDistribution = calculateBidAskDistribution; exports.calculateNormalDistribution = calculateNormalDistribution; exports.calculateSpotDistribution = calculateSpotDistribution; exports.chunkedFetchMultipleBinArrayBitmapExtensionAccount = chunkedFetchMultipleBinArrayBitmapExtensionAccount; exports.chunkedFetchMultiplePoolAccount = chunkedFetchMultiplePoolAccount; exports.chunkedGetMultipleAccountInfos = chunkedGetMultipleAccountInfos; exports.chunks = chunks; exports.computeBudgetIx = computeBudgetIx; exports.computeFee = computeFee; exports.computeFeeFromAmount = computeFeeFromAmount; exports.computeProtocolFee = computeProtocolFee; exports.default = src_default; exports.deriveBinArray = deriveBinArray; exports.deriveBinArrayBitmapExtension = deriveBinArrayBitmapExtension; exports.deriveCustomizablePermissionlessLbPair = deriveCustomizablePermissionlessLbPair; exports.deriveLbPair = deriveLbPair; exports.deriveLbPair2 = deriveLbPair2; exports.deriveOracle = deriveOracle; exports.derivePermissionLbPair = derivePermissionLbPair; exports.derivePosition = derivePosition; exports.derivePresetParameter = derivePresetParameter; exports.derivePresetParameter2 = derivePresetParameter2; exports.deriveReserve = deriveReserve; exports.findNextBinArrayIndexWithLiquidity = findNextBinArrayIndexWithLiquidity; exports.findNextBinArrayWithLiquidity = findNextBinArrayWithLiquidity; exports.fromWeightDistributionToAmount = fromWeightDistributionToAmount; exports.fromWeightDistributionToAmountOneSide = fromWeightDistributionToAmountOneSide; exports.getBaseFee = getBaseFee; exports.getBinArrayLowerUpperBinId = getBinArrayLowerUpperBinId; exports.getBinArraysRequiredByPositionRange = getBinArraysRequiredByPositionRange; exports.getBinFromBinArray = getBinFromBinArray; exports.getOrCreateATAInstruction = getOrCreateATAInstruction; exports.getOutAmount = getOutAmount; exports.getPriceOfBinByBinId = getPriceOfBinByBinId; exports.getTokenBalance = getTokenBalance; exports.getTokenDecimals = getTokenDecimals; exports.getTokensMintFromPoolAddress = getTokensMintFromPoolAddress; exports.getTotalFee = getTotalFee; exports.getVariableFee = getVariableFee; exports.isBinIdWithinBinArray = isBinIdWithinBinArray; exports.isOverflowDefaultBinArrayBitmap = isOverflowDefaultBinArrayBitmap; exports.parseLogs = parseLogs; exports.swapExactInQuoteAtBin = swapExactInQuoteAtBin; exports.swapExactOutQuoteAtBin = swapExactOutQuoteAtBin; exports.toAmountAskSide = toAmountAskSide; exports.toAmountBidSide = toAmountBidSide; exports.toAmountBothSide = toAmountBothSide; exports.toAmountsBothSideByStrategy = toAmountsBothSideByStrategy; exports.toAmountsOneSideByStrategy = toAmountsOneSideByStrategy; exports.toStrategyParameters = toStrategyParameters; exports.toWeightDistribution = toWeightDistribution; exports.unwrapSOLInstruction = unwrapSOLInstruction; exports.wrapSOLInstruction = wrapSOLInstruction;
12334
+
12335
+
12336
+
12337
+
12338
+ exports.ADMIN = ADMIN; exports.ActivationType = ActivationType; exports.BASIS_POINT_MAX = BASIS_POINT_MAX; exports.BIN_ARRAY_BITMAP_SIZE = BIN_ARRAY_BITMAP_SIZE; exports.BIN_ARRAY_FEE = BIN_ARRAY_FEE; exports.BinLiquidity = BinLiquidity; exports.BitmapType = BitmapType; exports.ClockLayout = ClockLayout; exports.DLMMError = DLMMError; exports.DlmmSdkError = DlmmSdkError; exports.EXTENSION_BINARRAY_BITMAP_SIZE = EXTENSION_BINARRAY_BITMAP_SIZE; exports.FEE_PRECISION = FEE_PRECISION; exports.IDL = IDL; exports.ILM_BASE = ILM_BASE; exports.LBCLMM_PROGRAM_IDS = LBCLMM_PROGRAM_IDS; exports.MAX_ACTIVE_BIN_SLIPPAGE = MAX_ACTIVE_BIN_SLIPPAGE; exports.MAX_BIN_ARRAY_SIZE = MAX_BIN_ARRAY_SIZE; exports.MAX_BIN_LENGTH_ALLOWED_IN_ONE_TX = MAX_BIN_LENGTH_ALLOWED_IN_ONE_TX; exports.MAX_BIN_PER_POSITION = MAX_BIN_PER_POSITION; exports.MAX_BIN_PER_TX = MAX_BIN_PER_TX; exports.MAX_CLAIM_ALL_ALLOWED = MAX_CLAIM_ALL_ALLOWED; exports.MAX_FEE_RATE = MAX_FEE_RATE; exports.Network = Network; exports.POSITION_FEE = POSITION_FEE; exports.PRECISION = PRECISION; exports.PairStatus = PairStatus; exports.PairType = PairType; exports.PositionVersion = PositionVersion; exports.SCALE = SCALE; exports.SCALE_OFFSET = SCALE_OFFSET; exports.SIMULATION_USER = SIMULATION_USER; exports.Strategy = Strategy; exports.StrategyType = StrategyType; exports.autoFillXByStrategy = autoFillXByStrategy; exports.autoFillXByWeight = autoFillXByWeight; exports.autoFillYByStrategy = autoFillYByStrategy; exports.autoFillYByWeight = autoFillYByWeight; exports.binIdToBinArrayIndex = binIdToBinArrayIndex; exports.calculateBidAskDistribution = calculateBidAskDistribution; exports.calculateNormalDistribution = calculateNormalDistribution; exports.calculateSpotDistribution = calculateSpotDistribution; exports.chunkedFetchMultipleBinArrayBitmapExtensionAccount = chunkedFetchMultipleBinArrayBitmapExtensionAccount; exports.chunkedFetchMultiplePoolAccount = chunkedFetchMultiplePoolAccount; exports.chunkedGetMultipleAccountInfos = chunkedGetMultipleAccountInfos; exports.chunks = chunks; exports.computeFee = computeFee; exports.computeFeeFromAmount = computeFeeFromAmount; exports.computeProtocolFee = computeProtocolFee; exports.default = src_default; exports.deriveBinArray = deriveBinArray; exports.deriveBinArrayBitmapExtension = deriveBinArrayBitmapExtension; exports.deriveCustomizablePermissionlessLbPair = deriveCustomizablePermissionlessLbPair; exports.deriveLbPair = deriveLbPair; exports.deriveLbPair2 = deriveLbPair2; exports.deriveOracle = deriveOracle; exports.derivePermissionLbPair = derivePermissionLbPair; exports.derivePosition = derivePosition; exports.derivePresetParameter = derivePresetParameter; exports.derivePresetParameter2 = derivePresetParameter2; exports.deriveReserve = deriveReserve; exports.enumerateBins = enumerateBins; exports.findNextBinArrayIndexWithLiquidity = findNextBinArrayIndexWithLiquidity; exports.findNextBinArrayWithLiquidity = findNextBinArrayWithLiquidity; exports.fromWeightDistributionToAmount = fromWeightDistributionToAmount; exports.fromWeightDistributionToAmountOneSide = fromWeightDistributionToAmountOneSide; exports.getBaseFee = getBaseFee; exports.getBinArrayLowerUpperBinId = getBinArrayLowerUpperBinId; exports.getBinArraysRequiredByPositionRange = getBinArraysRequiredByPositionRange; exports.getBinFromBinArray = getBinFromBinArray; exports.getEstimatedComputeUnitIxWithBuffer = getEstimatedComputeUnitIxWithBuffer; exports.getEstimatedComputeUnitUsageWithBuffer = getEstimatedComputeUnitUsageWithBuffer; exports.getOrCreateATAInstruction = getOrCreateATAInstruction; exports.getOutAmount = getOutAmount; exports.getPriceOfBinByBinId = getPriceOfBinByBinId; exports.getTokenBalance = getTokenBalance; exports.getTokenDecimals = getTokenDecimals; exports.getTokensMintFromPoolAddress = getTokensMintFromPoolAddress; exports.getTotalFee = getTotalFee; exports.getVariableFee = getVariableFee; exports.isBinIdWithinBinArray = isBinIdWithinBinArray; exports.isOverflowDefaultBinArrayBitmap = isOverflowDefaultBinArrayBitmap; exports.parseLogs = parseLogs; exports.range = range; exports.swapExactInQuoteAtBin = swapExactInQuoteAtBin; exports.swapExactOutQuoteAtBin = swapExactOutQuoteAtBin; exports.toAmountAskSide = toAmountAskSide; exports.toAmountBidSide = toAmountBidSide; exports.toAmountBothSide = toAmountBothSide; exports.toAmountsBothSideByStrategy = toAmountsBothSideByStrategy; exports.toAmountsOneSideByStrategy = toAmountsOneSideByStrategy; exports.toStrategyParameters = toStrategyParameters; exports.toWeightDistribution = toWeightDistribution; exports.unwrapSOLInstruction = unwrapSOLInstruction; exports.wrapSOLInstruction = wrapSOLInstruction;
12171
12339
  //# sourceMappingURL=index.js.map