@meteora-ag/dlmm 1.3.0 → 1.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -5286,6 +5286,7 @@ type LiquidityParameterByWeight = IdlTypes<LbClmm>["LiquidityParameterByWeight"]
5286
5286
  type LiquidityOneSideParameter = IdlTypes<LbClmm>["LiquidityOneSideParameter"];
5287
5287
  type LiquidityParameterByStrategy = IdlTypes<LbClmm>["LiquidityParameterByStrategy"];
5288
5288
  type LiquidityParameterByStrategyOneSide = IdlTypes<LbClmm>["LiquidityParameterByStrategyOneSide"];
5289
+ type LiquidityParameter = IdlTypes<LbClmm>["LiquidityParameter"];
5289
5290
  type ProgramStrategyParameter = IdlTypes<LbClmm>["StrategyParameters"];
5290
5291
  type ProgramStrategyType = IdlTypes<LbClmm>["StrategyType"];
5291
5292
  type CompressedBinDepositAmount = IdlTypes<LbClmm>["CompressedBinDepositAmount"];
@@ -6003,6 +6004,22 @@ declare class DLMM {
6003
6004
  * @returns {Promise<SeedLiquidityResponse>}
6004
6005
  */
6005
6006
  seedLiquidity(owner: PublicKey, seedAmount: BN, curvature: number, minPrice: number, maxPrice: number, base: PublicKey): Promise<SeedLiquidityResponse>;
6007
+ /**
6008
+ * The `seedLiquidity` function create multiple grouped instructions. The grouped instructions will be either [initialize bin array + initialize position instructions] or [deposit instruction] combination.
6009
+ * @param
6010
+ * - `owner`: The public key of the positions owner.
6011
+ * - `base`: Base key
6012
+ * - `seedAmount`: Token X lamport amount to be seeded to the pool.
6013
+ * - `price`: TokenX/TokenY Price in UI format
6014
+ * - `roundingUp`: Whether to round up the price
6015
+ * - `feeOwner`: Position fee owner
6016
+ * - `operator`: Operator of the position. Operator able to manage the position on behalf of the position owner. However, liquidity withdrawal issue by the operator can only send to the position owner.
6017
+ * - `lockReleasePoint`: The lock release point of the position.
6018
+ *
6019
+ * The returned instructions need to be executed sequentially if it was separated into multiple transactions.
6020
+ * @returns {Promise<TransactionInstruction[]>}
6021
+ */
6022
+ seedLiquiditySingleBin(owner: PublicKey, base: PublicKey, seedAmount: BN, price: number, roundingUp: boolean, feeOwner: PublicKey, operator: PublicKey, lockReleasePoint: BN): Promise<TransactionInstruction[]>;
6006
6023
  /**
6007
6024
  * Initializes bin arrays for the given bin array indexes if it wasn't initialized.
6008
6025
  *
@@ -6503,4 +6520,4 @@ declare const MAX_BIN_PER_TX = 69;
6503
6520
  declare const MAX_ACTIVE_BIN_SLIPPAGE = 3;
6504
6521
  declare const ILM_BASE: PublicKey;
6505
6522
 
6506
- export { ADMIN, ActivationType, BASIS_POINT_MAX, BIN_ARRAY_BITMAP_SIZE, BIN_ARRAY_FEE, Bin, BinAndAmount, BinArray, BinArrayAccount, BinArrayBitmapExtension, BinArrayBitmapExtensionAccount, BinLiquidity, BinLiquidityDistribution, BinLiquidityReduction, BitmapType, ClmmProgram, Clock, ClockLayout, CompressedBinDepositAmount, CompressedBinDepositAmounts, DLMMError, DlmmSdkError, EXTENSION_BINARRAY_BITMAP_SIZE, EmissionRate, FEE_PRECISION, FeeInfo, GetOrCreateATAResponse, IAccountsCache, IDL, ILM_BASE, InitCustomizablePermissionlessPairIx, 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, PairStatus, PairType, Position, PositionBinData, PositionData, PositionInfo, PositionV2, PositionVersion, ProgramStrategyParameter, ProgramStrategyType, SCALE, SCALE_OFFSET, SIMULATION_USER, SeedLiquidityResponse, Strategy, StrategyParameters, StrategyType, SwapExactOutParams, SwapFee, SwapParams, SwapQuote, SwapQuoteExactOut, SwapWithPriceImpactParams, 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, deriveCustomizablePermissionlessLbPair, deriveLbPair, deriveLbPair2, deriveOracle, derivePermissionLbPair, derivePosition, derivePresetParameter, derivePresetParameter2, deriveReserve, findNextBinArrayIndexWithLiquidity, findNextBinArrayWithLiquidity, fromWeightDistributionToAmount, fromWeightDistributionToAmountOneSide, getBaseFee, getBinArrayLowerUpperBinId, getBinArraysRequiredByPositionRange, getBinFromBinArray, getOrCreateATAInstruction, getOutAmount, getPriceOfBinByBinId, getTokenBalance, getTokenDecimals, getTokensMintFromPoolAddress, getTotalFee, getVariableFee, isBinIdWithinBinArray, isOverflowDefaultBinArrayBitmap, parseLogs, sParameters, swapExactInQuoteAtBin, swapExactOutQuoteAtBin, toAmountAskSide, toAmountBidSide, toAmountBothSide, toAmountsBothSideByStrategy, toAmountsOneSideByStrategy, toStrategyParameters, toWeightDistribution, unwrapSOLInstruction, vParameters, wrapSOLInstruction };
6523
+ export { ADMIN, ActivationType, BASIS_POINT_MAX, BIN_ARRAY_BITMAP_SIZE, BIN_ARRAY_FEE, Bin, BinAndAmount, BinArray, BinArrayAccount, BinArrayBitmapExtension, BinArrayBitmapExtensionAccount, BinLiquidity, BinLiquidityDistribution, BinLiquidityReduction, BitmapType, ClmmProgram, Clock, ClockLayout, CompressedBinDepositAmount, CompressedBinDepositAmounts, DLMMError, DlmmSdkError, EXTENSION_BINARRAY_BITMAP_SIZE, EmissionRate, FEE_PRECISION, FeeInfo, GetOrCreateATAResponse, IAccountsCache, IDL, ILM_BASE, InitCustomizablePermissionlessPairIx, InitPermissionPairIx, LBCLMM_PROGRAM_IDS, LMRewards, LbClmm, LbPair, LbPairAccount, LbPosition, LiquidityOneSideParameter, LiquidityParameter, 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, PairStatus, PairType, Position, PositionBinData, PositionData, PositionInfo, PositionV2, PositionVersion, ProgramStrategyParameter, ProgramStrategyType, SCALE, SCALE_OFFSET, SIMULATION_USER, SeedLiquidityResponse, Strategy, StrategyParameters, StrategyType, SwapExactOutParams, SwapFee, SwapParams, SwapQuote, SwapQuoteExactOut, SwapWithPriceImpactParams, 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, deriveCustomizablePermissionlessLbPair, deriveLbPair, deriveLbPair2, deriveOracle, derivePermissionLbPair, derivePosition, derivePresetParameter, derivePresetParameter2, deriveReserve, findNextBinArrayIndexWithLiquidity, findNextBinArrayWithLiquidity, fromWeightDistributionToAmount, fromWeightDistributionToAmountOneSide, getBaseFee, getBinArrayLowerUpperBinId, getBinArraysRequiredByPositionRange, getBinFromBinArray, getOrCreateATAInstruction, getOutAmount, getPriceOfBinByBinId, getTokenBalance, getTokenDecimals, getTokensMintFromPoolAddress, getTotalFee, getVariableFee, isBinIdWithinBinArray, isOverflowDefaultBinArrayBitmap, parseLogs, sParameters, swapExactInQuoteAtBin, swapExactOutQuoteAtBin, toAmountAskSide, toAmountBidSide, toAmountBothSide, toAmountsBothSideByStrategy, toAmountsOneSideByStrategy, toStrategyParameters, toWeightDistribution, unwrapSOLInstruction, vParameters, wrapSOLInstruction };
package/dist/index.js CHANGED
@@ -10869,6 +10869,140 @@ var DLMM = class {
10869
10869
  addLiquidityIxs
10870
10870
  };
10871
10871
  }
10872
+ /**
10873
+ * The `seedLiquidity` function create multiple grouped instructions. The grouped instructions will be either [initialize bin array + initialize position instructions] or [deposit instruction] combination.
10874
+ * @param
10875
+ * - `owner`: The public key of the positions owner.
10876
+ * - `base`: Base key
10877
+ * - `seedAmount`: Token X lamport amount to be seeded to the pool.
10878
+ * - `price`: TokenX/TokenY Price in UI format
10879
+ * - `roundingUp`: Whether to round up the price
10880
+ * - `feeOwner`: Position fee owner
10881
+ * - `operator`: Operator of the position. Operator able to manage the position on behalf of the position owner. However, liquidity withdrawal issue by the operator can only send to the position owner.
10882
+ * - `lockReleasePoint`: The lock release point of the position.
10883
+ *
10884
+ * The returned instructions need to be executed sequentially if it was separated into multiple transactions.
10885
+ * @returns {Promise<TransactionInstruction[]>}
10886
+ */
10887
+ async seedLiquiditySingleBin(owner, base, seedAmount, price, roundingUp, feeOwner, operator, lockReleasePoint) {
10888
+ const pricePerLamport = DLMM.getPricePerLamport(this.tokenX.decimal, this.tokenY.decimal, price);
10889
+ const binIdNumber = DLMM.getBinIdFromPrice(pricePerLamport, this.lbPair.binStep, !roundingUp);
10890
+ const binId = new (0, _anchor.BN)(binIdNumber);
10891
+ const lowerBinArrayIndex = binIdToBinArrayIndex(binId);
10892
+ const upperBinArrayIndex = lowerBinArrayIndex.add(new (0, _anchor.BN)(1));
10893
+ const [lowerBinArray] = deriveBinArray(this.pubkey, lowerBinArrayIndex, this.program.programId);
10894
+ const [upperBinArray] = deriveBinArray(this.pubkey, upperBinArrayIndex, this.program.programId);
10895
+ const [positionPda] = derivePosition(this.pubkey, base, binId, new (0, _anchor.BN)(1), this.program.programId);
10896
+ const operatorTokenX = _spltoken.getAssociatedTokenAddressSync.call(void 0,
10897
+ this.lbPair.tokenXMint,
10898
+ operator,
10899
+ true
10900
+ );
10901
+ const ownerTokenX = _spltoken.getAssociatedTokenAddressSync.call(void 0,
10902
+ this.lbPair.tokenXMint,
10903
+ owner,
10904
+ true
10905
+ );
10906
+ const preInstructions = [];
10907
+ const [
10908
+ { ataPubKey: userTokenX, ix: createPayerTokenXIx },
10909
+ { ataPubKey: userTokenY, ix: createPayerTokenYIx }
10910
+ ] = await Promise.all([
10911
+ getOrCreateATAInstruction(
10912
+ this.program.provider.connection,
10913
+ this.tokenX.publicKey,
10914
+ owner
10915
+ ),
10916
+ getOrCreateATAInstruction(
10917
+ this.program.provider.connection,
10918
+ this.tokenY.publicKey,
10919
+ owner
10920
+ )
10921
+ ]);
10922
+ createPayerTokenXIx && preInstructions.push(createPayerTokenXIx);
10923
+ createPayerTokenYIx && preInstructions.push(createPayerTokenYIx);
10924
+ let [binArrayBitmapExtension] = deriveBinArrayBitmapExtension(this.pubkey, this.program.programId);
10925
+ const accounts = await this.program.provider.connection.getMultipleAccountsInfo([
10926
+ lowerBinArray,
10927
+ upperBinArray,
10928
+ positionPda,
10929
+ binArrayBitmapExtension
10930
+ ]);
10931
+ if (isOverflowDefaultBinArrayBitmap(lowerBinArrayIndex)) {
10932
+ const bitmapExtensionAccount = accounts[3];
10933
+ if (!bitmapExtensionAccount) {
10934
+ preInstructions.push(await this.program.methods.initializeBinArrayBitmapExtension().accounts({
10935
+ binArrayBitmapExtension,
10936
+ funder: owner,
10937
+ lbPair: this.pubkey
10938
+ }).instruction());
10939
+ }
10940
+ } else {
10941
+ binArrayBitmapExtension = this.program.programId;
10942
+ }
10943
+ const lowerBinArrayAccount = accounts[0];
10944
+ const upperBinArrayAccount = accounts[1];
10945
+ const positionAccount = accounts[2];
10946
+ if (!lowerBinArrayAccount) {
10947
+ preInstructions.push(
10948
+ await this.program.methods.initializeBinArray(lowerBinArrayIndex).accounts({
10949
+ binArray: lowerBinArray,
10950
+ funder: owner,
10951
+ lbPair: this.pubkey
10952
+ }).instruction()
10953
+ );
10954
+ }
10955
+ if (!upperBinArrayAccount) {
10956
+ preInstructions.push(
10957
+ await this.program.methods.initializeBinArray(upperBinArrayIndex).accounts({
10958
+ binArray: upperBinArray,
10959
+ funder: owner,
10960
+ lbPair: this.pubkey
10961
+ }).instruction()
10962
+ );
10963
+ }
10964
+ if (!positionAccount) {
10965
+ preInstructions.push(
10966
+ await this.program.methods.initializePositionByOperator(binId.toNumber(), 1, feeOwner, lockReleasePoint).accounts({
10967
+ payer: owner,
10968
+ base,
10969
+ position: positionPda,
10970
+ lbPair: this.pubkey,
10971
+ owner,
10972
+ operator,
10973
+ operatorTokenX,
10974
+ ownerTokenX
10975
+ }).instruction()
10976
+ );
10977
+ }
10978
+ const binLiquidityDist = {
10979
+ binId: binIdNumber,
10980
+ distributionX: BASIS_POINT_MAX,
10981
+ distributionY: 0
10982
+ };
10983
+ const addLiquidityParams = {
10984
+ amountX: seedAmount,
10985
+ amountY: new (0, _anchor.BN)(0),
10986
+ binLiquidityDist: [binLiquidityDist]
10987
+ };
10988
+ const depositLiquidityIx = await this.program.methods.addLiquidity(addLiquidityParams).accounts({
10989
+ position: positionPda,
10990
+ lbPair: this.pubkey,
10991
+ binArrayBitmapExtension,
10992
+ userTokenX,
10993
+ userTokenY,
10994
+ reserveX: this.lbPair.reserveX,
10995
+ reserveY: this.lbPair.reserveY,
10996
+ tokenXMint: this.lbPair.tokenXMint,
10997
+ tokenYMint: this.lbPair.tokenYMint,
10998
+ binArrayLower: lowerBinArray,
10999
+ binArrayUpper: upperBinArray,
11000
+ sender: owner,
11001
+ tokenXProgram: _spltoken.TOKEN_PROGRAM_ID,
11002
+ tokenYProgram: _spltoken.TOKEN_PROGRAM_ID
11003
+ }).instruction();
11004
+ return [...preInstructions, depositLiquidityIx];
11005
+ }
10872
11006
  /**
10873
11007
  * Initializes bin arrays for the given bin array indexes if it wasn't initialized.
10874
11008
  *