@meteora-ag/dlmm 1.3.12 → 1.3.13
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 +19 -1
- package/dist/index.js +111 -0
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +111 -0
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -5688,6 +5688,16 @@ declare enum PairStatus {
|
|
|
5688
5688
|
Enabled = 0,
|
|
5689
5689
|
Disabled = 1
|
|
5690
5690
|
}
|
|
5691
|
+
interface PairLockInfo {
|
|
5692
|
+
positions: Array<PositionLockInfo>;
|
|
5693
|
+
}
|
|
5694
|
+
interface PositionLockInfo {
|
|
5695
|
+
positionAddress: PublicKey;
|
|
5696
|
+
owner: PublicKey;
|
|
5697
|
+
tokenXAmount: string;
|
|
5698
|
+
tokenYAmount: string;
|
|
5699
|
+
lockReleasePoint: number;
|
|
5700
|
+
}
|
|
5691
5701
|
|
|
5692
5702
|
type Opt = {
|
|
5693
5703
|
cluster?: Cluster | "localhost";
|
|
@@ -5762,6 +5772,14 @@ declare class DLMM {
|
|
|
5762
5772
|
static getAllLbPairPositionsByUser(connection: Connection, userPubKey: PublicKey, opt?: Opt): Promise<Map<string, PositionInfo>>;
|
|
5763
5773
|
static getPricePerLamport(tokenXDecimal: number, tokenYDecimal: number, price: number): string;
|
|
5764
5774
|
static getBinIdFromPrice(price: string | number | Decimal, binStep: number, min: boolean): number;
|
|
5775
|
+
/**
|
|
5776
|
+
* The function `getLbPairLockInfo` retrieves all pair positions that has locked liquidity.
|
|
5777
|
+
* @param {number} [lockDurationOpt] - An optional value indicating the minimum position lock duration that the function should return.
|
|
5778
|
+
* Depending on the lbPair activationType, the param should be a number of seconds or a number of slots.
|
|
5779
|
+
* @returns The function `getLbPairLockInfo` returns a `Promise` that resolves to a `PairLockInfo`
|
|
5780
|
+
* object. The `PairLockInfo` object contains an array of `PositionLockInfo` objects.
|
|
5781
|
+
*/
|
|
5782
|
+
getLbPairLockInfo(lockDurationOpt?: number): Promise<PairLockInfo>;
|
|
5765
5783
|
/** Public methods */
|
|
5766
5784
|
static createPermissionLbPair(connection: Connection, binStep: BN, tokenX: PublicKey, tokenY: PublicKey, activeId: BN, baseKey: PublicKey, creatorKey: PublicKey, feeBps: BN, activationType: ActivationType, opt?: Opt): Promise<Transaction>;
|
|
5767
5785
|
static createCustomizablePermissionlessLbPair(connection: Connection, binStep: BN, tokenX: PublicKey, tokenY: PublicKey, activeId: BN, feeBps: BN, activationType: ActivationType, hasAlphaVault: boolean, creatorKey: PublicKey, activationPoint?: BN, opt?: Opt): Promise<Transaction>;
|
|
@@ -6611,4 +6629,4 @@ declare const MAX_BIN_PER_TX = 69;
|
|
|
6611
6629
|
declare const MAX_ACTIVE_BIN_SLIPPAGE = 3;
|
|
6612
6630
|
declare const ILM_BASE: PublicKey;
|
|
6613
6631
|
|
|
6614
|
-
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, computeFee, computeFeeFromAmount, computeProtocolFee, DLMM as default, deriveBinArray, deriveBinArrayBitmapExtension, deriveCustomizablePermissionlessLbPair, deriveLbPair, deriveLbPair2, deriveOracle, derivePermissionLbPair, derivePosition, derivePresetParameter, derivePresetParameter2, deriveReserve, enumerateBins, findNextBinArrayIndexWithLiquidity, findNextBinArrayWithLiquidity, fromWeightDistributionToAmount, fromWeightDistributionToAmountOneSide, getBaseFee, getBinArrayLowerUpperBinId, getBinArraysRequiredByPositionRange, getBinFromBinArray, getEstimatedComputeUnitIxWithBuffer, getEstimatedComputeUnitUsageWithBuffer, getOrCreateATAInstruction, getOutAmount, getPriceOfBinByBinId, getTokenBalance, getTokenDecimals, getTokensMintFromPoolAddress, getTotalFee, getVariableFee, isBinIdWithinBinArray, isOverflowDefaultBinArrayBitmap, parseLogs, range, sParameters, swapExactInQuoteAtBin, swapExactOutQuoteAtBin, toAmountAskSide, toAmountBidSide, toAmountBothSide, toAmountsBothSideByStrategy, toStrategyParameters, toWeightDistribution, unwrapSOLInstruction, vParameters, wrapSOLInstruction };
|
|
6632
|
+
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, PairLockInfo, PairStatus, PairType, Position, PositionBinData, PositionData, PositionInfo, PositionLockInfo, 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, computeFee, computeFeeFromAmount, computeProtocolFee, DLMM as default, deriveBinArray, deriveBinArrayBitmapExtension, deriveCustomizablePermissionlessLbPair, deriveLbPair, deriveLbPair2, deriveOracle, derivePermissionLbPair, derivePosition, derivePresetParameter, derivePresetParameter2, deriveReserve, enumerateBins, findNextBinArrayIndexWithLiquidity, findNextBinArrayWithLiquidity, fromWeightDistributionToAmount, fromWeightDistributionToAmountOneSide, getBaseFee, getBinArrayLowerUpperBinId, getBinArraysRequiredByPositionRange, getBinFromBinArray, getEstimatedComputeUnitIxWithBuffer, getEstimatedComputeUnitUsageWithBuffer, getOrCreateATAInstruction, getOutAmount, getPriceOfBinByBinId, getTokenBalance, getTokenDecimals, getTokensMintFromPoolAddress, getTotalFee, getVariableFee, isBinIdWithinBinArray, isOverflowDefaultBinArrayBitmap, parseLogs, range, sParameters, swapExactInQuoteAtBin, swapExactOutQuoteAtBin, toAmountAskSide, toAmountBidSide, toAmountBothSide, toAmountsBothSideByStrategy, toStrategyParameters, toWeightDistribution, unwrapSOLInstruction, vParameters, wrapSOLInstruction };
|
package/dist/index.js
CHANGED
|
@@ -8345,6 +8345,117 @@ var DLMM = class {
|
|
|
8345
8345
|
const binId = new (0, _decimaljs2.default)(price).log().dividedBy(new (0, _decimaljs2.default)(1).add(binStepNum).log());
|
|
8346
8346
|
return (min ? binId.floor() : binId.ceil()).toNumber();
|
|
8347
8347
|
}
|
|
8348
|
+
/**
|
|
8349
|
+
* The function `getLbPairLockInfo` retrieves all pair positions that has locked liquidity.
|
|
8350
|
+
* @param {number} [lockDurationOpt] - An optional value indicating the minimum position lock duration that the function should return.
|
|
8351
|
+
* Depending on the lbPair activationType, the param should be a number of seconds or a number of slots.
|
|
8352
|
+
* @returns The function `getLbPairLockInfo` returns a `Promise` that resolves to a `PairLockInfo`
|
|
8353
|
+
* object. The `PairLockInfo` object contains an array of `PositionLockInfo` objects.
|
|
8354
|
+
*/
|
|
8355
|
+
async getLbPairLockInfo(lockDurationOpt) {
|
|
8356
|
+
const lockDuration = lockDurationOpt | 0;
|
|
8357
|
+
const lbPairPositions = await this.program.account.positionV2.all([
|
|
8358
|
+
{
|
|
8359
|
+
memcmp: {
|
|
8360
|
+
bytes: _bytes.bs58.encode(this.pubkey.toBuffer()),
|
|
8361
|
+
offset: 8
|
|
8362
|
+
}
|
|
8363
|
+
}
|
|
8364
|
+
]);
|
|
8365
|
+
const clockAccInfo = await this.program.provider.connection.getAccountInfo(_web3js.SYSVAR_CLOCK_PUBKEY);
|
|
8366
|
+
const clock = ClockLayout.decode(clockAccInfo.data);
|
|
8367
|
+
const currentPoint = this.lbPair.activationType == 0 /* Slot */ ? clock.slot : clock.unixTimestamp;
|
|
8368
|
+
const minLockReleasePoint = currentPoint.add(new (0, _anchor.BN)(lockDuration));
|
|
8369
|
+
const positionsWithLock = lbPairPositions.filter((p) => p.account.lockReleasePoint.gt(minLockReleasePoint));
|
|
8370
|
+
if (positionsWithLock.length == 0) {
|
|
8371
|
+
return {
|
|
8372
|
+
positions: []
|
|
8373
|
+
};
|
|
8374
|
+
}
|
|
8375
|
+
const binArrayPubkeySetV2 = /* @__PURE__ */ new Set();
|
|
8376
|
+
positionsWithLock.forEach(({ account: { upperBinId, lowerBinId, lbPair } }) => {
|
|
8377
|
+
const lowerBinArrayIndex = binIdToBinArrayIndex(new (0, _anchor.BN)(lowerBinId));
|
|
8378
|
+
const upperBinArrayIndex = binIdToBinArrayIndex(new (0, _anchor.BN)(upperBinId));
|
|
8379
|
+
const [lowerBinArrayPubKey] = deriveBinArray(
|
|
8380
|
+
this.pubkey,
|
|
8381
|
+
lowerBinArrayIndex,
|
|
8382
|
+
this.program.programId
|
|
8383
|
+
);
|
|
8384
|
+
const [upperBinArrayPubKey] = deriveBinArray(
|
|
8385
|
+
this.pubkey,
|
|
8386
|
+
upperBinArrayIndex,
|
|
8387
|
+
this.program.programId
|
|
8388
|
+
);
|
|
8389
|
+
binArrayPubkeySetV2.add(lowerBinArrayPubKey.toBase58());
|
|
8390
|
+
binArrayPubkeySetV2.add(upperBinArrayPubKey.toBase58());
|
|
8391
|
+
});
|
|
8392
|
+
const binArrayPubkeyArrayV2 = Array.from(binArrayPubkeySetV2).map(
|
|
8393
|
+
(pubkey) => new (0, _web3js.PublicKey)(pubkey)
|
|
8394
|
+
);
|
|
8395
|
+
const binArraysAccInfo = await chunkedGetMultipleAccountInfos(
|
|
8396
|
+
this.program.provider.connection,
|
|
8397
|
+
binArrayPubkeyArrayV2
|
|
8398
|
+
);
|
|
8399
|
+
const positionBinArraysMapV2 = /* @__PURE__ */ new Map();
|
|
8400
|
+
for (let i = 0; i < binArraysAccInfo.length; i++) {
|
|
8401
|
+
const binArrayPubkey = binArrayPubkeyArrayV2[i];
|
|
8402
|
+
const binArrayAccBufferV2 = binArraysAccInfo[i];
|
|
8403
|
+
if (!binArrayAccBufferV2)
|
|
8404
|
+
throw new Error(
|
|
8405
|
+
`Bin Array account ${binArrayPubkey.toBase58()} not found`
|
|
8406
|
+
);
|
|
8407
|
+
const binArrayAccInfo = this.program.coder.accounts.decode(
|
|
8408
|
+
"binArray",
|
|
8409
|
+
binArrayAccBufferV2.data
|
|
8410
|
+
);
|
|
8411
|
+
positionBinArraysMapV2.set(binArrayPubkey.toBase58(), binArrayAccInfo);
|
|
8412
|
+
}
|
|
8413
|
+
const positionsLockInfo = await Promise.all(
|
|
8414
|
+
positionsWithLock.map(async ({ publicKey, account }) => {
|
|
8415
|
+
const { lowerBinId, upperBinId, feeOwner } = account;
|
|
8416
|
+
const lowerBinArrayIndex = binIdToBinArrayIndex(new (0, _anchor.BN)(lowerBinId));
|
|
8417
|
+
const upperBinArrayIndex = binIdToBinArrayIndex(new (0, _anchor.BN)(upperBinId));
|
|
8418
|
+
const [lowerBinArrayPubKey] = deriveBinArray(
|
|
8419
|
+
this.pubkey,
|
|
8420
|
+
lowerBinArrayIndex,
|
|
8421
|
+
this.program.programId
|
|
8422
|
+
);
|
|
8423
|
+
const [upperBinArrayPubKey] = deriveBinArray(
|
|
8424
|
+
this.pubkey,
|
|
8425
|
+
upperBinArrayIndex,
|
|
8426
|
+
this.program.programId
|
|
8427
|
+
);
|
|
8428
|
+
const lowerBinArray = positionBinArraysMapV2.get(
|
|
8429
|
+
lowerBinArrayPubKey.toBase58()
|
|
8430
|
+
);
|
|
8431
|
+
const upperBinArray = positionBinArraysMapV2.get(
|
|
8432
|
+
upperBinArrayPubKey.toBase58()
|
|
8433
|
+
);
|
|
8434
|
+
const positionData = await DLMM.processPosition(
|
|
8435
|
+
this.program,
|
|
8436
|
+
1 /* V2 */,
|
|
8437
|
+
this.lbPair,
|
|
8438
|
+
clock.unixTimestamp.toNumber(),
|
|
8439
|
+
account,
|
|
8440
|
+
this.tokenX.decimal,
|
|
8441
|
+
this.tokenY.decimal,
|
|
8442
|
+
lowerBinArray,
|
|
8443
|
+
upperBinArray,
|
|
8444
|
+
feeOwner
|
|
8445
|
+
);
|
|
8446
|
+
return {
|
|
8447
|
+
positionAddress: publicKey,
|
|
8448
|
+
owner: account.owner,
|
|
8449
|
+
lockReleasePoint: account.lockReleasePoint.toNumber(),
|
|
8450
|
+
tokenXAmount: positionData.totalXAmount,
|
|
8451
|
+
tokenYAmount: positionData.totalYAmount
|
|
8452
|
+
};
|
|
8453
|
+
})
|
|
8454
|
+
);
|
|
8455
|
+
return {
|
|
8456
|
+
positions: positionsLockInfo
|
|
8457
|
+
};
|
|
8458
|
+
}
|
|
8348
8459
|
/** Public methods */
|
|
8349
8460
|
static async createPermissionLbPair(connection, binStep, tokenX, tokenY, activeId, baseKey, creatorKey, feeBps, activationType, opt) {
|
|
8350
8461
|
const provider = new (0, _anchor.AnchorProvider)(
|