@meteora-ag/dlmm 1.0.33 → 1.0.34

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
@@ -1768,39 +1768,6 @@ type LbClmm = {
1768
1768
  }
1769
1769
  ];
1770
1770
  },
1771
- {
1772
- name: "initializePresetParameterV2";
1773
- accounts: [
1774
- {
1775
- name: "presetParameter";
1776
- isMut: true;
1777
- isSigner: false;
1778
- },
1779
- {
1780
- name: "admin";
1781
- isMut: true;
1782
- isSigner: true;
1783
- },
1784
- {
1785
- name: "systemProgram";
1786
- isMut: false;
1787
- isSigner: false;
1788
- },
1789
- {
1790
- name: "rent";
1791
- isMut: false;
1792
- isSigner: false;
1793
- }
1794
- ];
1795
- args: [
1796
- {
1797
- name: "ix";
1798
- type: {
1799
- defined: "InitPresetParametersIx";
1800
- };
1801
- }
1802
- ];
1803
- },
1804
1771
  {
1805
1772
  name: "closePresetParameter";
1806
1773
  accounts: [
@@ -2540,10 +2507,20 @@ type LbClmm = {
2540
2507
  docs: ["Status of the pair. Check PairStatus enum."];
2541
2508
  type: "u8";
2542
2509
  },
2510
+ {
2511
+ name: "requireBaseFactorSeed";
2512
+ type: "u8";
2513
+ },
2514
+ {
2515
+ name: "baseFactorSeed";
2516
+ type: {
2517
+ array: ["u8", 2];
2518
+ };
2519
+ },
2543
2520
  {
2544
2521
  name: "padding1";
2545
2522
  type: {
2546
- array: ["u8", 5];
2523
+ array: ["u8", 2];
2547
2524
  };
2548
2525
  },
2549
2526
  {
@@ -4870,6 +4847,7 @@ declare class DLMM {
4870
4847
  * `LbPairAccount` objects.
4871
4848
  */
4872
4849
  static getLbPairs(connection: Connection, opt?: Opt): Promise<LbPairAccount[]>;
4850
+ static checkPoolExists(connection: Connection, tokenX: PublicKey, tokenY: PublicKey, binStep: BN, baseFactor: BN, opt?: Opt): Promise<boolean>;
4873
4851
  /**
4874
4852
  * The `create` function is a static method that creates a new instance of the `DLMM` class
4875
4853
  * @param {Connection} connection - The `connection` parameter is an instance of the `Connection`
@@ -4919,7 +4897,7 @@ declare class DLMM {
4919
4897
  static getBinIdFromPrice(price: string | number | Decimal, binStep: number, min: boolean): number;
4920
4898
  /** Public methods */
4921
4899
  static createPermissionLbPair(connection: Connection, binStep: BN, tokenX: PublicKey, tokenY: PublicKey, activeId: BN, baseKey: PublicKey, creatorKey: PublicKey, feeBps: BN, lockDurationInSlot: BN, opt?: Opt): Promise<Transaction>;
4922
- static createLbPair(connection: Connection, funder: PublicKey, tokenX: PublicKey, tokenY: PublicKey, presetParameter: PublicKey, activeId: BN, opt?: Opt): Promise<Transaction>;
4900
+ static createLbPair(connection: Connection, funder: PublicKey, tokenX: PublicKey, tokenY: PublicKey, binStep: BN, baseFactor: BN, presetParameter: PublicKey, activeId: BN, opt?: Opt): Promise<Transaction>;
4923
4901
  /**
4924
4902
  * The function `refetchStates` retrieves and updates various states and data related to bin arrays
4925
4903
  * and lb pairs.
@@ -5294,9 +5272,18 @@ declare class DLMM {
5294
5272
  }
5295
5273
 
5296
5274
  /** private */
5275
+ /**
5276
+ *
5277
+ * @deprecated Use derivePresetParameter2
5278
+ */
5297
5279
  declare function derivePresetParameter(binStep: BN, programId: PublicKey): [PublicKey, number];
5280
+ declare function derivePresetParameter2(binStep: BN, baseFactor: BN, programId: PublicKey): [PublicKey, number];
5281
+ declare function deriveLbPair2(tokenX: PublicKey, tokenY: PublicKey, binStep: BN, baseFactor: BN, programId: PublicKey): [PublicKey, number];
5282
+ /**
5283
+ *
5284
+ * @deprecated Use deriveLbPair2
5285
+ */
5298
5286
  declare function deriveLbPair(tokenX: PublicKey, tokenY: PublicKey, binStep: BN, programId: PublicKey): [PublicKey, number];
5299
- declare function checkPoolExists(connection: Connection, tokenX: PublicKey, tokenY: PublicKey, binStep: BN, programId: PublicKey): Promise<PublicKey | false>;
5300
5287
  declare function derivePermissionLbPair(baseKey: PublicKey, tokenX: PublicKey, tokenY: PublicKey, binStep: BN, programId: PublicKey): [PublicKey, number];
5301
5288
  declare function deriveOracle(lbPair: PublicKey, programId: PublicKey): [PublicKey, number];
5302
5289
  declare function derivePosition(mint: PublicKey, programId: PublicKey): [PublicKey, number];
@@ -5581,6 +5568,8 @@ declare function chunkedFetchMultiplePoolAccount(program: ClmmProgram, pks: Publ
5581
5568
  activeId: number;
5582
5569
  binStep: number;
5583
5570
  status: number;
5571
+ requireBaseFactorSeed: number;
5572
+ baseFactorSeed: number[];
5584
5573
  padding1: number[];
5585
5574
  tokenXMint: PublicKey;
5586
5575
  tokenYMint: PublicKey;
@@ -5669,4 +5658,4 @@ declare const MAX_BIN_LENGTH_ALLOWED_IN_ONE_TX = 26;
5669
5658
  declare const MAX_BIN_PER_TX = 69;
5670
5659
  declare const MAX_ACTIVE_BIN_SLIPPAGE = 3;
5671
5660
 
5672
- export { ADMIN, BASIS_POINT_MAX, BIN_ARRAY_BITMAP_SIZE, BIN_ARRAY_FEE, Bin, BinAndAmount, BinArray, BinArrayAccount, BinArrayBitmapExtension, BinArrayBitmapExtensionAccount, BinLiquidity, BinLiquidityDistribution, BinLiquidityReduction, BitmapType, ClmmProgram, DLMMError, EXTENSION_BINARRAY_BITMAP_SIZE, EmissionRate, FEE_PRECISION, FeeInfo, GetOrCreateATAResponse, IAccountsCache, IDL, InitPermissionPairIx, LBCLMM_PROGRAM_IDS, LMRewards, LbClmm, LbPair, LbPairAccount, LbPosition, LiquidityOneSideParameter, LiquidityParameterByStrategy, LiquidityParameterByStrategyOneSide, LiquidityParameterByWeight, MAX_ACTIVE_BIN_SLIPPAGE, MAX_BIN_ARRAY_SIZE, MAX_BIN_LENGTH_ALLOWED_IN_ONE_TX, MAX_BIN_PER_POSITION, MAX_BIN_PER_TX, MAX_CLAIM_ALL_ALLOWED, MAX_FEE_RATE, Network, POSITION_FEE, PRECISION, PairType, Position, PositionBinData, PositionData, PositionInfo, PositionVersion, ProgramStrategyParameter, ProgramStrategyType, SCALE, SCALE_OFFSET, SIMULATION_USER, Strategy, StrategyParameters, StrategyType, SwapFee, SwapParams, SwapQuote, TInitializePositionAndAddLiquidityParams, TInitializePositionAndAddLiquidityParamsByStrategy, TQuoteCreatePositionParams, TokenReserve, autoFillXByStrategy, autoFillXByWeight, autoFillYByStrategy, autoFillYByWeight, binIdToBinArrayIndex, calculateBidAskDistribution, calculateNormalDistribution, calculateSpotDistribution, checkPoolExists, chunkedFetchMultipleBinArrayBitmapExtensionAccount, chunkedFetchMultiplePoolAccount, chunkedGetMultipleAccountInfos, chunks, computeBudgetIx, computeFee, computeFeeFromAmount, computeProtocolFee, DLMM as default, deriveBinArray, deriveBinArrayBitmapExtension, deriveLbPair, deriveOracle, derivePermissionLbPair, derivePosition, derivePresetParameter, deriveReserve, findNextBinArrayIndexWithLiquidity, findNextBinArrayWithLiquidity, fromWeightDistributionToAmount, fromWeightDistributionToAmountOneSide, getBaseFee, getBinArrayLowerUpperBinId, getBinFromBinArray, getOrCreateATAInstruction, getOutAmount, getPriceOfBinByBinId, getTokenBalance, getTokenDecimals, getTotalFee, getVariableFee, isBinIdWithinBinArray, isOverflowDefaultBinArrayBitmap, parseLogs, sParameters, swapQuoteAtBin, swapQuoteAtBinWithCap, toAmountAskSide, toAmountBidSide, toAmountBothSide, toAmountsBothSideByStrategy, toAmountsOneSideByStrategy, toStrategyParameters, toWeightDistribution, unwrapSOLInstruction, vParameters, wrapSOLInstruction };
5661
+ export { ADMIN, BASIS_POINT_MAX, BIN_ARRAY_BITMAP_SIZE, BIN_ARRAY_FEE, Bin, BinAndAmount, BinArray, BinArrayAccount, BinArrayBitmapExtension, BinArrayBitmapExtensionAccount, BinLiquidity, BinLiquidityDistribution, BinLiquidityReduction, BitmapType, ClmmProgram, DLMMError, EXTENSION_BINARRAY_BITMAP_SIZE, EmissionRate, FEE_PRECISION, FeeInfo, GetOrCreateATAResponse, IAccountsCache, IDL, InitPermissionPairIx, LBCLMM_PROGRAM_IDS, LMRewards, LbClmm, LbPair, LbPairAccount, LbPosition, LiquidityOneSideParameter, LiquidityParameterByStrategy, LiquidityParameterByStrategyOneSide, LiquidityParameterByWeight, MAX_ACTIVE_BIN_SLIPPAGE, MAX_BIN_ARRAY_SIZE, MAX_BIN_LENGTH_ALLOWED_IN_ONE_TX, MAX_BIN_PER_POSITION, MAX_BIN_PER_TX, MAX_CLAIM_ALL_ALLOWED, MAX_FEE_RATE, Network, POSITION_FEE, PRECISION, PairType, Position, PositionBinData, PositionData, PositionInfo, PositionVersion, ProgramStrategyParameter, ProgramStrategyType, SCALE, SCALE_OFFSET, SIMULATION_USER, Strategy, StrategyParameters, StrategyType, SwapFee, SwapParams, SwapQuote, TInitializePositionAndAddLiquidityParams, TInitializePositionAndAddLiquidityParamsByStrategy, TQuoteCreatePositionParams, TokenReserve, autoFillXByStrategy, autoFillXByWeight, autoFillYByStrategy, autoFillYByWeight, binIdToBinArrayIndex, calculateBidAskDistribution, calculateNormalDistribution, calculateSpotDistribution, chunkedFetchMultipleBinArrayBitmapExtensionAccount, chunkedFetchMultiplePoolAccount, chunkedGetMultipleAccountInfos, chunks, computeBudgetIx, computeFee, computeFeeFromAmount, computeProtocolFee, DLMM as default, deriveBinArray, deriveBinArrayBitmapExtension, deriveLbPair, deriveLbPair2, deriveOracle, derivePermissionLbPair, derivePosition, derivePresetParameter, derivePresetParameter2, deriveReserve, findNextBinArrayIndexWithLiquidity, findNextBinArrayWithLiquidity, fromWeightDistributionToAmount, fromWeightDistributionToAmountOneSide, getBaseFee, getBinArrayLowerUpperBinId, getBinFromBinArray, getOrCreateATAInstruction, getOutAmount, getPriceOfBinByBinId, getTokenBalance, getTokenDecimals, getTotalFee, getVariableFee, isBinIdWithinBinArray, isOverflowDefaultBinArrayBitmap, parseLogs, sParameters, swapQuoteAtBin, swapQuoteAtBinWithCap, toAmountAskSide, toAmountBidSide, toAmountBothSide, toAmountsBothSideByStrategy, toAmountsOneSideByStrategy, toStrategyParameters, toWeightDistribution, unwrapSOLInstruction, vParameters, wrapSOLInstruction };
package/dist/index.js CHANGED
@@ -1772,39 +1772,6 @@ var IDL = {
1772
1772
  }
1773
1773
  ]
1774
1774
  },
1775
- {
1776
- name: "initializePresetParameterV2",
1777
- accounts: [
1778
- {
1779
- name: "presetParameter",
1780
- isMut: true,
1781
- isSigner: false
1782
- },
1783
- {
1784
- name: "admin",
1785
- isMut: true,
1786
- isSigner: true
1787
- },
1788
- {
1789
- name: "systemProgram",
1790
- isMut: false,
1791
- isSigner: false
1792
- },
1793
- {
1794
- name: "rent",
1795
- isMut: false,
1796
- isSigner: false
1797
- }
1798
- ],
1799
- args: [
1800
- {
1801
- name: "ix",
1802
- type: {
1803
- defined: "InitPresetParametersIx"
1804
- }
1805
- }
1806
- ]
1807
- },
1808
1775
  {
1809
1776
  name: "closePresetParameter",
1810
1777
  accounts: [
@@ -2544,10 +2511,20 @@ var IDL = {
2544
2511
  docs: ["Status of the pair. Check PairStatus enum."],
2545
2512
  type: "u8"
2546
2513
  },
2514
+ {
2515
+ name: "requireBaseFactorSeed",
2516
+ type: "u8"
2517
+ },
2518
+ {
2519
+ name: "baseFactorSeed",
2520
+ type: {
2521
+ array: ["u8", 2]
2522
+ }
2523
+ },
2547
2524
  {
2548
2525
  name: "padding1",
2549
2526
  type: {
2550
- array: ["u8", 5]
2527
+ array: ["u8", 2]
2551
2528
  }
2552
2529
  },
2553
2530
  {
@@ -4928,6 +4905,28 @@ function derivePresetParameter(binStep, programId) {
4928
4905
  programId
4929
4906
  );
4930
4907
  }
4908
+ function derivePresetParameter2(binStep, baseFactor, programId) {
4909
+ return _web3js.PublicKey.findProgramAddressSync(
4910
+ [
4911
+ Buffer.from("preset_parameter"),
4912
+ new Uint8Array(binStep.toArrayLike(Buffer, "le", 2)),
4913
+ new Uint8Array(baseFactor.toArrayLike(Buffer, "le", 2))
4914
+ ],
4915
+ programId
4916
+ );
4917
+ }
4918
+ function deriveLbPair2(tokenX, tokenY, binStep, baseFactor, programId) {
4919
+ const [minKey, maxKey] = sortTokenMints(tokenX, tokenY);
4920
+ return _web3js.PublicKey.findProgramAddressSync(
4921
+ [
4922
+ minKey.toBuffer(),
4923
+ maxKey.toBuffer(),
4924
+ new Uint8Array(binStep.toArrayLike(Buffer, "le", 2)),
4925
+ new Uint8Array(baseFactor.toArrayLike(Buffer, "le", 2))
4926
+ ],
4927
+ programId
4928
+ );
4929
+ }
4931
4930
  function deriveLbPair(tokenX, tokenY, binStep, programId) {
4932
4931
  const [minKey, maxKey] = sortTokenMints(tokenX, tokenY);
4933
4932
  return _web3js.PublicKey.findProgramAddressSync(
@@ -4939,19 +4938,15 @@ function deriveLbPair(tokenX, tokenY, binStep, programId) {
4939
4938
  programId
4940
4939
  );
4941
4940
  }
4942
- async function checkPoolExists(connection, tokenX, tokenY, binStep, programId) {
4943
- try {
4944
- const [lbPairKey] = deriveLbPair(tokenX, tokenY, binStep, programId);
4945
- await DLMM.create(connection, lbPairKey);
4946
- return lbPairKey;
4947
- } catch (e2) {
4948
- return false;
4949
- }
4950
- }
4951
4941
  function derivePermissionLbPair(baseKey, tokenX, tokenY, binStep, programId) {
4952
4942
  const [minKey, maxKey] = sortTokenMints(tokenX, tokenY);
4953
4943
  return _web3js.PublicKey.findProgramAddressSync(
4954
- [baseKey.toBuffer(), minKey.toBuffer(), maxKey.toBuffer(), new Uint8Array(binStep.toArrayLike(Buffer, "le", 2))],
4944
+ [
4945
+ baseKey.toBuffer(),
4946
+ minKey.toBuffer(),
4947
+ maxKey.toBuffer(),
4948
+ new Uint8Array(binStep.toArrayLike(Buffer, "le", 2))
4949
+ ],
4955
4950
  programId
4956
4951
  );
4957
4952
  }
@@ -6523,6 +6518,28 @@ var DLMM = class {
6523
6518
  );
6524
6519
  return program.account.lbPair.all();
6525
6520
  }
6521
+ static async checkPoolExists(connection, tokenX, tokenY, binStep, baseFactor, opt) {
6522
+ const cluster = _optionalChain([opt, 'optionalAccess', _21 => _21.cluster]) || "mainnet-beta";
6523
+ const provider = new (0, _anchor.AnchorProvider)(
6524
+ connection,
6525
+ {},
6526
+ _anchor.AnchorProvider.defaultOptions()
6527
+ );
6528
+ const program = new (0, _anchor.Program)(IDL, LBCLMM_PROGRAM_IDS[cluster], provider);
6529
+ try {
6530
+ const [lbPairKey] = deriveLbPair2(
6531
+ tokenX,
6532
+ tokenY,
6533
+ binStep,
6534
+ baseFactor,
6535
+ program.programId
6536
+ );
6537
+ await program.account.lbPair.fetch(lbPairKey);
6538
+ return true;
6539
+ } catch (e2) {
6540
+ return false;
6541
+ }
6542
+ }
6526
6543
  /**
6527
6544
  * The `create` function is a static method that creates a new instance of the `DLMM` class
6528
6545
  * @param {Connection} connection - The `connection` parameter is an instance of the `Connection`
@@ -6533,7 +6550,7 @@ var DLMM = class {
6533
6550
  * @returns The `create` function returns a `Promise` that resolves to a `DLMM` object.
6534
6551
  */
6535
6552
  static async create(connection, dlmm, opt) {
6536
- const cluster = _optionalChain([opt, 'optionalAccess', _21 => _21.cluster]) || "mainnet-beta";
6553
+ const cluster = _optionalChain([opt, 'optionalAccess', _22 => _22.cluster]) || "mainnet-beta";
6537
6554
  const provider = new (0, _anchor.AnchorProvider)(
6538
6555
  connection,
6539
6556
  {},
@@ -6549,14 +6566,14 @@ var DLMM = class {
6549
6566
  connection,
6550
6567
  accountsToFetch
6551
6568
  );
6552
- const lbPairAccountInfoBuffer = _optionalChain([accountsInfo, 'access', _22 => _22[0], 'optionalAccess', _23 => _23.data]);
6569
+ const lbPairAccountInfoBuffer = _optionalChain([accountsInfo, 'access', _23 => _23[0], 'optionalAccess', _24 => _24.data]);
6553
6570
  if (!lbPairAccountInfoBuffer)
6554
6571
  throw new Error(`LB Pair account ${dlmm.toBase58()} not found`);
6555
6572
  const lbPairAccInfo = program.coder.accounts.decode(
6556
6573
  "lbPair",
6557
6574
  lbPairAccountInfoBuffer
6558
6575
  );
6559
- const binArrayBitMapAccountInfoBuffer = _optionalChain([accountsInfo, 'access', _24 => _24[1], 'optionalAccess', _25 => _25.data]);
6576
+ const binArrayBitMapAccountInfoBuffer = _optionalChain([accountsInfo, 'access', _25 => _25[1], 'optionalAccess', _26 => _26.data]);
6560
6577
  let binArrayBitMapExtensionAccInfo = null;
6561
6578
  if (binArrayBitMapAccountInfoBuffer) {
6562
6579
  binArrayBitMapExtensionAccInfo = program.coder.accounts.decode(
@@ -6620,7 +6637,7 @@ var DLMM = class {
6620
6637
  * objects.
6621
6638
  */
6622
6639
  static async createMultiple(connection, dlmmList, opt) {
6623
- const cluster = _optionalChain([opt, 'optionalAccess', _26 => _26.cluster]) || "mainnet-beta";
6640
+ const cluster = _optionalChain([opt, 'optionalAccess', _27 => _27.cluster]) || "mainnet-beta";
6624
6641
  const provider = new (0, _anchor.AnchorProvider)(
6625
6642
  connection,
6626
6643
  {},
@@ -6638,7 +6655,7 @@ var DLMM = class {
6638
6655
  const lbPairArraysMap = /* @__PURE__ */ new Map();
6639
6656
  for (let i = 0; i < dlmmList.length; i++) {
6640
6657
  const lbPairPubKey = dlmmList[i];
6641
- const lbPairAccountInfoBuffer = _optionalChain([accountsInfo, 'access', _27 => _27[i], 'optionalAccess', _28 => _28.data]);
6658
+ const lbPairAccountInfoBuffer = _optionalChain([accountsInfo, 'access', _28 => _28[i], 'optionalAccess', _29 => _29.data]);
6642
6659
  if (!lbPairAccountInfoBuffer)
6643
6660
  throw new Error(`LB Pair account ${lbPairPubKey.toBase58()} not found`);
6644
6661
  const binArrayAccInfo = program.coder.accounts.decode(
@@ -6651,7 +6668,7 @@ var DLMM = class {
6651
6668
  for (let i = dlmmList.length; i < accountsInfo.length; i++) {
6652
6669
  const index = i - dlmmList.length;
6653
6670
  const lbPairPubkey = dlmmList[index];
6654
- const binArrayBitMapAccountInfoBuffer = _optionalChain([accountsInfo, 'access', _29 => _29[i], 'optionalAccess', _30 => _30.data]);
6671
+ const binArrayBitMapAccountInfoBuffer = _optionalChain([accountsInfo, 'access', _30 => _30[i], 'optionalAccess', _31 => _31.data]);
6655
6672
  if (binArrayBitMapAccountInfoBuffer) {
6656
6673
  const binArrayBitMapExtensionAccInfo = program.coder.accounts.decode(
6657
6674
  "binArrayBitmapExtension",
@@ -6734,7 +6751,7 @@ var DLMM = class {
6734
6751
  );
6735
6752
  const program = new (0, _anchor.Program)(
6736
6753
  IDL,
6737
- LBCLMM_PROGRAM_IDS[_nullishCoalesce(_optionalChain([opt, 'optionalAccess', _31 => _31.cluster]), () => ( "mainnet-beta"))],
6754
+ LBCLMM_PROGRAM_IDS[_nullishCoalesce(_optionalChain([opt, 'optionalAccess', _32 => _32.cluster]), () => ( "mainnet-beta"))],
6738
6755
  provider
6739
6756
  );
6740
6757
  const presetParameter = await program.account.presetParameter.all();
@@ -6752,7 +6769,7 @@ var DLMM = class {
6752
6769
  * Pair account, and the value is an object of PositionInfo
6753
6770
  */
6754
6771
  static async getAllLbPairPositionsByUser(connection, userPubKey, opt) {
6755
- const cluster = _optionalChain([opt, 'optionalAccess', _32 => _32.cluster]) || "mainnet-beta";
6772
+ const cluster = _optionalChain([opt, 'optionalAccess', _33 => _33.cluster]) || "mainnet-beta";
6756
6773
  const provider = new (0, _anchor.AnchorProvider)(
6757
6774
  connection,
6758
6775
  {},
@@ -6987,8 +7004,8 @@ var DLMM = class {
6987
7004
  const { mintXDecimal, mintYDecimal } = lbPairMintMap.get(
6988
7005
  lbPair.toBase58()
6989
7006
  );
6990
- const reserveXBalance = _nullishCoalesce(_optionalChain([lbPairReserveMap, 'access', _33 => _33.get, 'call', _34 => _34(lbPair.toBase58()), 'optionalAccess', _35 => _35.reserveX]), () => ( BigInt(0)));
6991
- const reserveYBalance = _nullishCoalesce(_optionalChain([lbPairReserveMap, 'access', _36 => _36.get, 'call', _37 => _37(lbPair.toBase58()), 'optionalAccess', _38 => _38.reserveY]), () => ( BigInt(0)));
7007
+ const reserveXBalance = _nullishCoalesce(_optionalChain([lbPairReserveMap, 'access', _34 => _34.get, 'call', _35 => _35(lbPair.toBase58()), 'optionalAccess', _36 => _36.reserveX]), () => ( BigInt(0)));
7008
+ const reserveYBalance = _nullishCoalesce(_optionalChain([lbPairReserveMap, 'access', _37 => _37.get, 'call', _38 => _38(lbPair.toBase58()), 'optionalAccess', _39 => _39.reserveY]), () => ( BigInt(0)));
6992
7009
  const tokenX = {
6993
7010
  publicKey: lbPairAcc.tokenXMint,
6994
7011
  reserve: lbPairAcc.reserveX,
@@ -7020,7 +7037,7 @@ var DLMM = class {
7020
7037
  tokenX,
7021
7038
  tokenY,
7022
7039
  lbPairPositionsData: [
7023
- ..._nullishCoalesce(_optionalChain([positionsMap, 'access', _39 => _39.get, 'call', _40 => _40(lbPair.toBase58()), 'optionalAccess', _41 => _41.lbPairPositionsData]), () => ( [])),
7040
+ ..._nullishCoalesce(_optionalChain([positionsMap, 'access', _40 => _40.get, 'call', _41 => _41(lbPair.toBase58()), 'optionalAccess', _42 => _42.lbPairPositionsData]), () => ( [])),
7024
7041
  {
7025
7042
  publicKey: positionPubKey,
7026
7043
  positionData,
@@ -7056,8 +7073,8 @@ var DLMM = class {
7056
7073
  getTokenDecimals(program.provider.connection, lbPairAcc.tokenXMint),
7057
7074
  getTokenDecimals(program.provider.connection, lbPairAcc.tokenYMint)
7058
7075
  ]);
7059
- const reserveXBalance = _nullishCoalesce(_optionalChain([lbPairReserveMapV2, 'access', _42 => _42.get, 'call', _43 => _43(lbPair.toBase58()), 'optionalAccess', _44 => _44.reserveX]), () => ( BigInt(0)));
7060
- const reserveYBalance = _nullishCoalesce(_optionalChain([lbPairReserveMapV2, 'access', _45 => _45.get, 'call', _46 => _46(lbPair.toBase58()), 'optionalAccess', _47 => _47.reserveY]), () => ( BigInt(0)));
7076
+ const reserveXBalance = _nullishCoalesce(_optionalChain([lbPairReserveMapV2, 'access', _43 => _43.get, 'call', _44 => _44(lbPair.toBase58()), 'optionalAccess', _45 => _45.reserveX]), () => ( BigInt(0)));
7077
+ const reserveYBalance = _nullishCoalesce(_optionalChain([lbPairReserveMapV2, 'access', _46 => _46.get, 'call', _47 => _47(lbPair.toBase58()), 'optionalAccess', _48 => _48.reserveY]), () => ( BigInt(0)));
7061
7078
  const tokenX = {
7062
7079
  publicKey: lbPairAcc.tokenXMint,
7063
7080
  reserve: lbPairAcc.reserveX,
@@ -7089,7 +7106,7 @@ var DLMM = class {
7089
7106
  tokenX,
7090
7107
  tokenY,
7091
7108
  lbPairPositionsData: [
7092
- ..._nullishCoalesce(_optionalChain([positionsMap, 'access', _48 => _48.get, 'call', _49 => _49(lbPair.toBase58()), 'optionalAccess', _50 => _50.lbPairPositionsData]), () => ( [])),
7109
+ ..._nullishCoalesce(_optionalChain([positionsMap, 'access', _49 => _49.get, 'call', _50 => _50(lbPair.toBase58()), 'optionalAccess', _51 => _51.lbPairPositionsData]), () => ( [])),
7093
7110
  {
7094
7111
  publicKey: positionPubKey,
7095
7112
  positionData,
@@ -7102,7 +7119,7 @@ var DLMM = class {
7102
7119
  return positionsMap;
7103
7120
  }
7104
7121
  static async migratePosition(connection, positions, newPositions, walletPubkey, opt) {
7105
- const cluster = _optionalChain([opt, 'optionalAccess', _51 => _51.cluster]) || "mainnet-beta";
7122
+ const cluster = _optionalChain([opt, 'optionalAccess', _52 => _52.cluster]) || "mainnet-beta";
7106
7123
  const provider = new (0, _anchor.AnchorProvider)(
7107
7124
  connection,
7108
7125
  {},
@@ -7201,18 +7218,20 @@ var DLMM = class {
7201
7218
  base: baseKey
7202
7219
  }).transaction();
7203
7220
  }
7204
- static async createLbPair(connection, funder, tokenX, tokenY, presetParameter, activeId, opt) {
7221
+ static async createLbPair(connection, funder, tokenX, tokenY, binStep, baseFactor, presetParameter, activeId, opt) {
7205
7222
  const provider = new (0, _anchor.AnchorProvider)(
7206
7223
  connection,
7207
7224
  {},
7208
7225
  _anchor.AnchorProvider.defaultOptions()
7209
7226
  );
7210
7227
  const program = new (0, _anchor.Program)(IDL, LBCLMM_PROGRAM_IDS[opt.cluster], provider);
7211
- const presetParameterState = await program.account.presetParameter.fetch(
7212
- presetParameter
7228
+ const [lbPair] = deriveLbPair2(
7229
+ tokenX,
7230
+ tokenY,
7231
+ binStep,
7232
+ baseFactor,
7233
+ program.programId
7213
7234
  );
7214
- const binStep = new (0, _anchor.BN)(presetParameterState.binStep);
7215
- const [lbPair] = deriveLbPair(tokenX, tokenY, binStep, program.programId);
7216
7235
  const [reserveX] = deriveReserve(tokenX, lbPair, program.programId);
7217
7236
  const [reserveY] = deriveReserve(tokenY, lbPair, program.programId);
7218
7237
  const [oracle] = deriveOracle(lbPair, program.programId);
@@ -7329,7 +7348,7 @@ var DLMM = class {
7329
7348
  swapForY,
7330
7349
  new (0, _anchor.BN)(activeIdToLoop),
7331
7350
  this.lbPair,
7332
- _nullishCoalesce(_optionalChain([this, 'access', _52 => _52.binArrayBitmapExtension, 'optionalAccess', _53 => _53.account]), () => ( null))
7351
+ _nullishCoalesce(_optionalChain([this, 'access', _53 => _53.binArrayBitmapExtension, 'optionalAccess', _54 => _54.account]), () => ( null))
7333
7352
  );
7334
7353
  if (binArrayIndex === null)
7335
7354
  shouldStop = true;
@@ -8764,7 +8783,7 @@ var DLMM = class {
8764
8783
  swapForY,
8765
8784
  activeId,
8766
8785
  this.lbPair,
8767
- _optionalChain([this, 'access', _54 => _54.binArrayBitmapExtension, 'optionalAccess', _55 => _55.account]),
8786
+ _optionalChain([this, 'access', _55 => _55.binArrayBitmapExtension, 'optionalAccess', _56 => _56.account]),
8768
8787
  binArrays
8769
8788
  );
8770
8789
  if (binArrayAccountToSwap == null) {
@@ -8871,7 +8890,7 @@ var DLMM = class {
8871
8890
  swapForY,
8872
8891
  activeId,
8873
8892
  this.lbPair,
8874
- _optionalChain([this, 'access', _56 => _56.binArrayBitmapExtension, 'optionalAccess', _57 => _57.account]),
8893
+ _optionalChain([this, 'access', _57 => _57.binArrayBitmapExtension, 'optionalAccess', _58 => _58.account]),
8875
8894
  binArrays
8876
8895
  );
8877
8896
  if (binArrayAccountToSwap == null) {
@@ -9360,7 +9379,7 @@ var DLMM = class {
9360
9379
  swapForY,
9361
9380
  new (0, _anchor.BN)(activeBinId),
9362
9381
  this.lbPair,
9363
- _nullishCoalesce(_optionalChain([this, 'access', _58 => _58.binArrayBitmapExtension, 'optionalAccess', _59 => _59.account]), () => ( null))
9382
+ _nullishCoalesce(_optionalChain([this, 'access', _59 => _59.binArrayBitmapExtension, 'optionalAccess', _60 => _60.account]), () => ( null))
9364
9383
  );
9365
9384
  if (toBinArrayIndex === null)
9366
9385
  return true;
@@ -9397,7 +9416,7 @@ var DLMM = class {
9397
9416
  swapForY,
9398
9417
  new (0, _anchor.BN)(activeBinId),
9399
9418
  this.lbPair,
9400
- _nullishCoalesce(_optionalChain([this, 'access', _60 => _60.binArrayBitmapExtension, 'optionalAccess', _61 => _61.account]), () => ( null))
9419
+ _nullishCoalesce(_optionalChain([this, 'access', _61 => _61.binArrayBitmapExtension, 'optionalAccess', _62 => _62.account]), () => ( null))
9401
9420
  );
9402
9421
  const accountsToFetch = [];
9403
9422
  const [binArrayBitMapExtensionPubkey] = deriveBinArrayBitmapExtension(
@@ -9428,13 +9447,13 @@ var DLMM = class {
9428
9447
  let fromBinArray = null;
9429
9448
  let toBinArray = null;
9430
9449
  let binArrayBitmapExtension = null;
9431
- if (!!_optionalChain([binArrayAccounts, 'optionalAccess', _62 => _62[0]])) {
9450
+ if (!!_optionalChain([binArrayAccounts, 'optionalAccess', _63 => _63[0]])) {
9432
9451
  binArrayBitmapExtension = binArrayBitMapExtensionPubkey;
9433
9452
  }
9434
- if (!!_optionalChain([binArrayAccounts, 'optionalAccess', _63 => _63[1]])) {
9453
+ if (!!_optionalChain([binArrayAccounts, 'optionalAccess', _64 => _64[1]])) {
9435
9454
  fromBinArray = fromBinArrayPubkey;
9436
9455
  }
9437
- if (!!_optionalChain([binArrayAccounts, 'optionalAccess', _64 => _64[2]]) && !!toBinArrayIndex) {
9456
+ if (!!_optionalChain([binArrayAccounts, 'optionalAccess', _65 => _65[2]]) && !!toBinArrayIndex) {
9438
9457
  toBinArray = toBinArrayPubkey;
9439
9458
  }
9440
9459
  const { blockhash, lastValidBlockHeight } = await this.program.provider.connection.getLatestBlockhash("confirmed");
@@ -10046,7 +10065,7 @@ var DLMMError = class extends Error {
10046
10065
  const anchorError = _anchor.AnchorError.parse(
10047
10066
  JSON.parse(JSON.stringify(error)).logs
10048
10067
  );
10049
- if (_optionalChain([anchorError, 'optionalAccess', _65 => _65.program, 'access', _66 => _66.toBase58, 'call', _67 => _67()]) === LBCLMM_PROGRAM_IDS["mainnet-beta"]) {
10068
+ if (_optionalChain([anchorError, 'optionalAccess', _66 => _66.program, 'access', _67 => _67.toBase58, 'call', _68 => _68()]) === LBCLMM_PROGRAM_IDS["mainnet-beta"]) {
10050
10069
  _errorCode = anchorError.error.errorCode.number;
10051
10070
  _errorName = anchorError.error.errorCode.code;
10052
10071
  _errorMessage = anchorError.error.errorMessage;
@@ -10150,5 +10169,6 @@ var src_default = DLMM;
10150
10169
 
10151
10170
 
10152
10171
 
10153
- exports.ADMIN = ADMIN; 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.DLMMError = DLMMError; exports.EXTENSION_BINARRAY_BITMAP_SIZE = EXTENSION_BINARRAY_BITMAP_SIZE; exports.FEE_PRECISION = FEE_PRECISION; exports.IDL = IDL; 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.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.checkPoolExists = checkPoolExists; 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.deriveLbPair = deriveLbPair; exports.deriveOracle = deriveOracle; exports.derivePermissionLbPair = derivePermissionLbPair; exports.derivePosition = derivePosition; exports.derivePresetParameter = derivePresetParameter; exports.deriveReserve = deriveReserve; exports.findNextBinArrayIndexWithLiquidity = findNextBinArrayIndexWithLiquidity; exports.findNextBinArrayWithLiquidity = findNextBinArrayWithLiquidity; exports.fromWeightDistributionToAmount = fromWeightDistributionToAmount; exports.fromWeightDistributionToAmountOneSide = fromWeightDistributionToAmountOneSide; exports.getBaseFee = getBaseFee; exports.getBinArrayLowerUpperBinId = getBinArrayLowerUpperBinId; exports.getBinFromBinArray = getBinFromBinArray; exports.getOrCreateATAInstruction = getOrCreateATAInstruction; exports.getOutAmount = getOutAmount; exports.getPriceOfBinByBinId = getPriceOfBinByBinId; exports.getTokenBalance = getTokenBalance; exports.getTokenDecimals = getTokenDecimals; exports.getTotalFee = getTotalFee; exports.getVariableFee = getVariableFee; exports.isBinIdWithinBinArray = isBinIdWithinBinArray; exports.isOverflowDefaultBinArrayBitmap = isOverflowDefaultBinArrayBitmap; exports.parseLogs = parseLogs; exports.swapQuoteAtBin = swapQuoteAtBin; exports.swapQuoteAtBinWithCap = swapQuoteAtBinWithCap; 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;
10172
+
10173
+ exports.ADMIN = ADMIN; 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.DLMMError = DLMMError; exports.EXTENSION_BINARRAY_BITMAP_SIZE = EXTENSION_BINARRAY_BITMAP_SIZE; exports.FEE_PRECISION = FEE_PRECISION; exports.IDL = IDL; 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.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.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.getBinFromBinArray = getBinFromBinArray; exports.getOrCreateATAInstruction = getOrCreateATAInstruction; exports.getOutAmount = getOutAmount; exports.getPriceOfBinByBinId = getPriceOfBinByBinId; exports.getTokenBalance = getTokenBalance; exports.getTokenDecimals = getTokenDecimals; exports.getTotalFee = getTotalFee; exports.getVariableFee = getVariableFee; exports.isBinIdWithinBinArray = isBinIdWithinBinArray; exports.isOverflowDefaultBinArrayBitmap = isOverflowDefaultBinArrayBitmap; exports.parseLogs = parseLogs; exports.swapQuoteAtBin = swapQuoteAtBin; exports.swapQuoteAtBinWithCap = swapQuoteAtBinWithCap; 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;
10154
10174
  //# sourceMappingURL=index.js.map