@meteora-ag/dlmm 1.9.8 → 1.9.10-rc.0
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/README.md +26 -24
- package/dist/index.d.ts +40 -2
- package/dist/index.js +246 -11
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +253 -18
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -44,7 +44,7 @@ const dlmmPool = await DLMM.createMultiple(connection, [USDC_USDT_POOL, ...]);
|
|
|
44
44
|
const activeBin = await dlmmPool.getActiveBin();
|
|
45
45
|
const activeBinPriceLamport = activeBin.price;
|
|
46
46
|
const activeBinPricePerToken = dlmmPool.fromPricePerLamport(
|
|
47
|
-
Number(activeBin.price)
|
|
47
|
+
Number(activeBin.price),
|
|
48
48
|
);
|
|
49
49
|
```
|
|
50
50
|
|
|
@@ -64,7 +64,7 @@ const totalYAmount = autoFillYByStrategy(
|
|
|
64
64
|
activeBin.yAmount,
|
|
65
65
|
minBinId,
|
|
66
66
|
maxBinId,
|
|
67
|
-
StrategyType.Spot // can be StrategyType.Spot, StrategyType.BidAsk, StrategyType.Curve
|
|
67
|
+
StrategyType.Spot, // can be StrategyType.Spot, StrategyType.BidAsk, StrategyType.Curve
|
|
68
68
|
);
|
|
69
69
|
const newBalancePosition = new Keypair();
|
|
70
70
|
|
|
@@ -86,7 +86,7 @@ try {
|
|
|
86
86
|
const createBalancePositionTxHash = await sendAndConfirmTransaction(
|
|
87
87
|
connection,
|
|
88
88
|
createPositionTx,
|
|
89
|
-
[user, newBalancePosition]
|
|
89
|
+
[user, newBalancePosition],
|
|
90
90
|
);
|
|
91
91
|
} catch (error) {}
|
|
92
92
|
```
|
|
@@ -120,7 +120,7 @@ try {
|
|
|
120
120
|
const createBalancePositionTxHash = await sendAndConfirmTransaction(
|
|
121
121
|
connection,
|
|
122
122
|
createPositionTx,
|
|
123
|
-
[user, newImbalancePosition]
|
|
123
|
+
[user, newImbalancePosition],
|
|
124
124
|
);
|
|
125
125
|
} catch (error) {}
|
|
126
126
|
```
|
|
@@ -154,7 +154,7 @@ try {
|
|
|
154
154
|
const createOneSidePositionTxHash = await sendAndConfirmTransaction(
|
|
155
155
|
connection,
|
|
156
156
|
createPositionTx,
|
|
157
|
-
[user, newOneSidePosition]
|
|
157
|
+
[user, newOneSidePosition],
|
|
158
158
|
);
|
|
159
159
|
} catch (error) {}
|
|
160
160
|
```
|
|
@@ -163,7 +163,7 @@ try {
|
|
|
163
163
|
|
|
164
164
|
```ts
|
|
165
165
|
const { userPositions } = await dlmmPool.getPositionsByUserAndLbPair(
|
|
166
|
-
user.publicKey
|
|
166
|
+
user.publicKey,
|
|
167
167
|
);
|
|
168
168
|
const binData = userPositions[0].positionData.positionBinData;
|
|
169
169
|
```
|
|
@@ -184,7 +184,7 @@ const totalYAmount = autoFillYByStrategy(
|
|
|
184
184
|
activeBin.yAmount,
|
|
185
185
|
minBinId,
|
|
186
186
|
maxBinId,
|
|
187
|
-
StrategyType.Spot // can be StrategyType.Spot, StrategyType.BidAsk, StrategyType.Curve
|
|
187
|
+
StrategyType.Spot, // can be StrategyType.Spot, StrategyType.BidAsk, StrategyType.Curve
|
|
188
188
|
);
|
|
189
189
|
|
|
190
190
|
// Add Liquidity to existing position
|
|
@@ -204,7 +204,7 @@ try {
|
|
|
204
204
|
const addLiquidityTxHash = await sendAndConfirmTransaction(
|
|
205
205
|
connection,
|
|
206
206
|
addLiquidityTx,
|
|
207
|
-
[user]
|
|
207
|
+
[user],
|
|
208
208
|
);
|
|
209
209
|
} catch (error) {}
|
|
210
210
|
```
|
|
@@ -213,11 +213,11 @@ try {
|
|
|
213
213
|
|
|
214
214
|
```ts
|
|
215
215
|
const userPosition = userPositions.find(({ publicKey }) =>
|
|
216
|
-
publicKey.equals(newBalancePosition.publicKey)
|
|
216
|
+
publicKey.equals(newBalancePosition.publicKey),
|
|
217
217
|
);
|
|
218
218
|
// Remove Liquidity
|
|
219
219
|
const binIdsToRemove = userPosition.positionData.positionBinData.map(
|
|
220
|
-
(bin) => bin.binId
|
|
220
|
+
(bin) => bin.binId,
|
|
221
221
|
);
|
|
222
222
|
const removeLiquidityTx = await dlmmPool.removeLiquidity({
|
|
223
223
|
position: userPosition.publicKey,
|
|
@@ -225,7 +225,7 @@ const removeLiquidityTx = await dlmmPool.removeLiquidity({
|
|
|
225
225
|
fromBinId: binIdsToRemove[0],
|
|
226
226
|
toBinId: binIdsToRemove[binIdsToRemove.length - 1],
|
|
227
227
|
liquiditiesBpsToRemove: new Array(binIdsToRemove.length).fill(
|
|
228
|
-
new BN(100 * 100)
|
|
228
|
+
new BN(100 * 100),
|
|
229
229
|
), // 100% (range from 0 to 100)
|
|
230
230
|
shouldClaimAndClose: true, // should claim swap fee and close position together
|
|
231
231
|
});
|
|
@@ -238,7 +238,7 @@ try {
|
|
|
238
238
|
connection,
|
|
239
239
|
tx,
|
|
240
240
|
[user],
|
|
241
|
-
{ skipPreflight: false, preflightCommitment: "singleGossip" }
|
|
241
|
+
{ skipPreflight: false, preflightCommitment: "singleGossip" },
|
|
242
242
|
);
|
|
243
243
|
}
|
|
244
244
|
} catch (error) {}
|
|
@@ -258,7 +258,7 @@ async function claimFee(dlmmPool: DLMM) {
|
|
|
258
258
|
const claimFeeTxHash = await sendAndConfirmTransaction(
|
|
259
259
|
connection,
|
|
260
260
|
claimFeeTx,
|
|
261
|
-
[user]
|
|
261
|
+
[user],
|
|
262
262
|
);
|
|
263
263
|
}
|
|
264
264
|
} catch (error) {}
|
|
@@ -278,7 +278,7 @@ try {
|
|
|
278
278
|
connection,
|
|
279
279
|
closePositionTx,
|
|
280
280
|
[user],
|
|
281
|
-
{ skipPreflight: false, preflightCommitment: "singleGossip" }
|
|
281
|
+
{ skipPreflight: false, preflightCommitment: "singleGossip" },
|
|
282
282
|
);
|
|
283
283
|
} catch (error) {}
|
|
284
284
|
```
|
|
@@ -295,7 +295,7 @@ const swapQuote = await dlmmPool.swapQuote(
|
|
|
295
295
|
swapAmount,
|
|
296
296
|
swapYtoX,
|
|
297
297
|
new BN(1),
|
|
298
|
-
binArrays
|
|
298
|
+
binArrays,
|
|
299
299
|
);
|
|
300
300
|
|
|
301
301
|
// Swap
|
|
@@ -318,15 +318,17 @@ try {
|
|
|
318
318
|
|
|
319
319
|
## Static functions
|
|
320
320
|
|
|
321
|
-
| Function
|
|
322
|
-
|
|
|
323
|
-
| `create`
|
|
324
|
-
| `createMultiple`
|
|
325
|
-
| `getAllPresetParameters`
|
|
326
|
-
| `createPermissionLbPair`
|
|
327
|
-
| `getClaimableLMReward`
|
|
328
|
-
| `getClaimableSwapFee`
|
|
329
|
-
| `getAllLbPairPositionsByUser`
|
|
321
|
+
| Function | Description | Return |
|
|
322
|
+
| ----------------------------------- | ---------------------------------------------------------------------------------- | ------------------------------------ |
|
|
323
|
+
| `create` | Given the DLMM address, create an instance to access the state and functions | `Promise<DLMM>` |
|
|
324
|
+
| `createMultiple` | Given a list of DLMM addresses, create instances to access the state and functions | `Promise<Array<DLMM>>` |
|
|
325
|
+
| `getAllPresetParameters` | Get all the preset params (use to create DLMM pool) | `Promise<PresetParams>` |
|
|
326
|
+
| `createPermissionLbPair` | Create DLMM Pool | `Promise<Transcation>` |
|
|
327
|
+
| `getClaimableLMReward` | Get Claimable LM reward for a position | `Promise<LMRewards>` |
|
|
328
|
+
| `getClaimableSwapFee` | Get Claimable Swap Fee for a position | `Promise<SwapFee>` |
|
|
329
|
+
| `getAllLbPairPositionsByUser` | Get user's all positions for all DLMM pools | `Promise<Map<string, PositionInfo>>` |
|
|
330
|
+
| `getPositionsByUserAndTokenAddress` | Get user's positions across all DLMM pools that contain a given token mint | `Promise<Map<string, PositionInfo>>` |
|
|
331
|
+
| `getLimitOrdersByUserAndTokenAddress` | Get user's limit orders across all DLMM pools that contain a given token mint, grouped by LB pair | `Promise<Map<string, LimitOrderInfo>>` |
|
|
330
332
|
|
|
331
333
|
## DLMM instance functions
|
|
332
334
|
|
package/dist/index.d.ts
CHANGED
|
@@ -12302,6 +12302,13 @@ interface PositionInfo {
|
|
|
12302
12302
|
tokenY: TokenReserve;
|
|
12303
12303
|
lbPairPositionsData: Array<LbPosition>;
|
|
12304
12304
|
}
|
|
12305
|
+
interface LimitOrderInfo {
|
|
12306
|
+
publicKey: PublicKey;
|
|
12307
|
+
lbPair: LbPair;
|
|
12308
|
+
tokenX: TokenReserve;
|
|
12309
|
+
tokenY: TokenReserve;
|
|
12310
|
+
limitOrders: Array<ParsedLimitOrderWithPubkey>;
|
|
12311
|
+
}
|
|
12305
12312
|
interface FeeInfo {
|
|
12306
12313
|
baseFeeRatePercentage: Decimal;
|
|
12307
12314
|
maxFeeRatePercentage: Decimal;
|
|
@@ -13563,6 +13570,36 @@ declare class DLMM {
|
|
|
13563
13570
|
* Pair account, and the value is an object of PositionInfo
|
|
13564
13571
|
*/
|
|
13565
13572
|
static getAllLbPairPositionsByUser(connection: Connection, userPubKey: PublicKey, opt?: Opt, getPositionsOpt?: GetPositionsOpt): Promise<Map<string, PositionInfo>>;
|
|
13573
|
+
/**
|
|
13574
|
+
* The function `getPositionsByUserAndTokenAddress` retrieves all of a user's positions across every
|
|
13575
|
+
* DLMM pool that includes the given token mint as either the X or Y token.
|
|
13576
|
+
* @param {Connection} connection - The `connection` parameter is an instance of the `Connection`
|
|
13577
|
+
* class, which represents the connection to the Solana blockchain.
|
|
13578
|
+
* @param {PublicKey} userPubKey - The user's wallet public key.
|
|
13579
|
+
* @param {PublicKey} tokenMint - The token mint used to filter pools. Only positions in pools whose
|
|
13580
|
+
* `tokenXMint` or `tokenYMint` matches this mint are returned.
|
|
13581
|
+
* @param {Opt} [opt] - An optional object that contains additional options for the function.
|
|
13582
|
+
* @param {GetPositionsOpt} [getPositionsOpt] - Optional settings for chunked position fetching
|
|
13583
|
+
* @returns The function `getPositionsByUserAndTokenAddress` returns a `Promise` that resolves to a
|
|
13584
|
+
* `Map` object. The `Map` object contains key-value pairs, where the key is a string representing the
|
|
13585
|
+
* LB Pair account, and the value is an object of PositionInfo. Only pools containing `tokenMint` are
|
|
13586
|
+
* included.
|
|
13587
|
+
*/
|
|
13588
|
+
static getPositionsByUserAndTokenAddress(connection: Connection, userPubKey: PublicKey, tokenMint: PublicKey, opt?: Opt, getPositionsOpt?: GetPositionsOpt): Promise<Map<string, PositionInfo>>;
|
|
13589
|
+
/**
|
|
13590
|
+
* The function `getLimitOrdersByUserAndTokenAddress` retrieves all of a user's limit orders across
|
|
13591
|
+
* every DLMM pool that includes the given token mint as either the X or Y token.
|
|
13592
|
+
* @param {Connection} connection - The `connection` parameter is an instance of the `Connection`
|
|
13593
|
+
* class, which represents the connection to the Solana blockchain.
|
|
13594
|
+
* @param {PublicKey} userPubKey - The user's wallet public key.
|
|
13595
|
+
* @param {PublicKey} tokenMint - The token mint used to filter pools. Only limit orders in pools
|
|
13596
|
+
* whose `tokenXMint` or `tokenYMint` matches this mint are returned.
|
|
13597
|
+
* @param {Opt} [opt] - An optional object that contains additional options for the function.
|
|
13598
|
+
* @returns The function `getLimitOrdersByUserAndTokenAddress` returns a `Promise` that resolves to a
|
|
13599
|
+
* `Map` object keyed by LB Pair account (base58), where each value is a `LimitOrderInfo` containing
|
|
13600
|
+
* the LB pair state, token reserves, and the parsed limit orders for that pool.
|
|
13601
|
+
*/
|
|
13602
|
+
static getLimitOrdersByUserAndTokenAddress(connection: Connection, userPubKey: PublicKey, tokenMint: PublicKey, opt?: Opt): Promise<Map<string, LimitOrderInfo>>;
|
|
13566
13603
|
static getPricePerLamport(tokenXDecimal: number, tokenYDecimal: number, price: number): string;
|
|
13567
13604
|
static getBinIdFromPrice(price: string | number | Decimal, binStep: number, min: boolean): number;
|
|
13568
13605
|
/**
|
|
@@ -14332,7 +14369,8 @@ declare class DLMM {
|
|
|
14332
14369
|
* - `limitOrderPubkey`: The public key of the limit-order account to cancel.
|
|
14333
14370
|
* - `owner`: The owner of the limit-order account and transaction fee payer.
|
|
14334
14371
|
* - `binIds`: Bin IDs to cancel from the limit order.
|
|
14335
|
-
* @returns {Promise<Transaction>} A transaction that cancels the limit order
|
|
14372
|
+
* @returns {Promise<Transaction>} A transaction that cancels the limit order, ensures owner ATAs for both pool
|
|
14373
|
+
* mints (including idempotent creates for non-SOL legs), and unwraps SOL when applicable.
|
|
14336
14374
|
*/
|
|
14337
14375
|
cancelLimitOrder({ limitOrderPubkey, owner, rentReceiver, binIds, }: {
|
|
14338
14376
|
limitOrderPubkey: PublicKey;
|
|
@@ -26424,4 +26462,4 @@ declare const limitOrderFilter: () => GetProgramAccountsFilter;
|
|
|
26424
26462
|
declare const limitOrderOwnerFilter: (owner: PublicKey) => GetProgramAccountsFilter;
|
|
26425
26463
|
declare const limitOrderLbPairFilter: (lbPair: PublicKey) => GetProgramAccountsFilter;
|
|
26426
26464
|
|
|
26427
|
-
export { ADMIN, ALT_ADDRESS, AccountName, ActionType, ActivationType, AmountIntoBin, BASIS_POINT_MAX, BIN_ARRAY_BITMAP_FEE, BIN_ARRAY_BITMAP_FEE_BN, BIN_ARRAY_BITMAP_SIZE, BIN_ARRAY_DEFAULT_VERSION, BIN_ARRAY_FEE, BIN_ARRAY_FEE_BN, BidAskParameters, Bin, BinAndAmount, BinArray, BinArrayAccount, BinArrayBitmapExtension, BinArrayBitmapExtensionAccount, BinLiquidity, BinLiquidityDistribution, BinLiquidityReduction, BitmapType, ChunkCallback, ChunkCallbackInfo, ClmmProgram, Clock, ClockLayout, CollectFeeMode, CompressedBinDepositAmount, CompressedBinDepositAmounts, ConcreteFunctionType, CreateRebalancePositionParams, DEFAULT_BIN_PER_POSITION, DLMMError, DlmmSdkError, DynamicOracle, EXTENSION_BINARRAY_BITMAP_SIZE, EmissionRate, ExtendedPositionBinData, FEE_PRECISION, FeeInfo, FeeMode, FunctionType, GetOrCreateATAResponse, GetPositionsOpt, IAccountsCache, IDL, IDynamicOracle, ILM_BASE, IPosition, InitCustomizablePermissionlessPairIx, InitPermissionPairIx, InitializeMultiplePositionAndAddLiquidityByStrategyResponse, InitializeMultiplePositionAndAddLiquidityByStrategyResponse2, LBCLMM_PROGRAM_IDS, LIMIT_ORDER_BIN_DATA_SIZE, LIMIT_ORDER_FEE_SHARE, LIMIT_ORDER_MIN_SIZE, LMRewards, LbClmm, LbPair, LbPairAccount, LbPosition, LimitOrder, LimitOrderBinData, LimitOrderStatus, LiquidityOneSideParameter, LiquidityParameter, LiquidityParameterByStrategy, LiquidityParameterByStrategyOneSide, LiquidityParameterByWeight, LiquidityStrategyParameterBuilder, LiquidityStrategyParameters, MAX_ACTIVE_BIN_SLIPPAGE, MAX_BINS_PER_POSITION, MAX_BIN_ARRAY_SIZE, MAX_BIN_LENGTH_ALLOWED_IN_ONE_TX, MAX_BIN_PER_LIMIT_ORDER, MAX_CLAIM_ALL_ALLOWED, MAX_EXTRA_BIN_ARRAYS, MAX_FEE_RATE, MAX_RESIZE_LENGTH, MEMO_PROGRAM_ID, Network, Observation, Opt, Oracle, POOL_FEE, POOL_FEE_BN, POSITION_BIN_DATA_SIZE, POSITION_FEE, POSITION_FEE_BN, POSITION_MAX_LENGTH, POSITION_MIN_SIZE, PRECISION, PairLockInfo, PairStatus, PairType, ParsedLimitOrderWithPubkey, PlaceLimitOrderParams, PositionBinData, PositionData, PositionInfo, PositionLockInfo, PositionPermission, PositionV2, PositionV2Wrapper, PositionVersion, PresetParameter, PresetParameter2, ProgramStrategyParameter, ProgramStrategyType, REBALANCE_POSITION_PADDING, RebalanceAddLiquidityParam, RebalancePosition, RebalancePositionBinArrayRentalCostQuote, RebalancePositionResponse, RebalanceRemoveLiquidityParam, RebalanceWithDeposit, RebalanceWithWithdraw, RemainingAccountInfo, RemainingAccountsInfoSlice, ResizeSide, ResizeSideEnum, RewardInfo, RewardInfos, Rounding, SCALE, SCALE_OFFSET, SIMULATION_USER, SeedLiquidityCostBreakdown, SeedLiquidityResponse, SeedLiquiditySingleBinResponse, ShrinkMode, SimulateRebalanceResp, Strategy, StrategyParameters, StrategyType, SwapExactOutParams, SwapFee, SwapParams, SwapQuote, SwapQuoteExactOut, SwapWithPriceImpactParams, TInitializeMultiplePositionAndAddLiquidityParamsByStrategy, TInitializePositionAndAddLiquidityParams, TInitializePositionAndAddLiquidityParamsByStrategy, TOKEN_ACCOUNT_FEE, TOKEN_ACCOUNT_FEE_BN, TQuoteCreatePositionParams, TokenReserve, TwapResult, U64_MAX, UserFeeInfo, UserRewardInfo, autoFillXByStrategy, autoFillXByWeight, autoFillYByStrategy, autoFillYByWeight, binArrayLbPairFilter, binDeltaToMinMaxBinId, binIdToBinArrayIndex, buildBitFlagAndNegateStrategyParameters, buildLiquidityStrategyParameters, calculateBidAskDistribution, calculateNormalDistribution, calculatePositionSize, calculateSpotDistribution, calculateTransferFeeExcludedAmount, calculateTransferFeeIncludedAmount, capSlippagePercentage, chunkBinRange, chunkBinRangeIntoExtendedPositions, chunkDepositWithRebalanceEndpoint, chunkPositionBinRange, chunkedFetchMultipleBinArrayBitmapExtensionAccount, chunkedFetchMultiplePoolAccount, chunkedGetMultipleAccountInfos, chunkedGetProgramAccounts, chunks, compressBinAmount, computeBaseFactorFromFeeBps, computeFee, computeFeeFromAmount, computeProtocolFee, createProgram, decodeAccount, decodeExtendedPosition, decodeRewardPerTokenStored, DLMM as default, deriveBinArray, deriveBinArrayBitmapExtension, deriveCustomizablePermissionlessLbPair, deriveEventAuthority, deriveLbPair, deriveLbPair2, deriveLbPairWithPresetParamWithIndexKey, deriveOperator, deriveOracle, derivePermissionLbPair, derivePlaceHolderAccountMeta, derivePosition, derivePresetParameter, derivePresetParameter2, derivePresetParameterWithIndex, deriveReserve, deriveRewardVault, deriveTokenBadge, distributeAmountToCompressedBinsByRatio, encodePositionPermissions, enumerateBins, findNextBinArrayIndexWithLiquidity, findNextBinArrayWithLiquidity, findOptimumDecompressMultiplier, fromWeightDistributionToAmount, fromWeightDistributionToAmountOneSide, generateAmountForBinRange, generateBinAmount, getAccountDiscriminator, getAmountIn, getAmountInBinsAskSide, getAmountInBinsBidSide, getAmountOut, getAndCapMaxActiveBinSlippage, getAutoFillAmountByRebalancedPosition, getBaseFee, getBinArrayAccountMetasCoverage, getBinArrayIndexesCoverage, getBinArrayInfoForNonContiguousBinIds, getBinArrayKeysCoverage, getBinArrayLowerUpperBinId, getBinArraysRequiredByPositionRange, getBinCount, getBinFromBinArray, getBinIdIndexInBinArray, getBinMaxAmountOut, getC, getEstimatedComputeUnitIxWithBuffer, getEstimatedComputeUnitUsageWithBuffer, getExcludedFeeAmount, getExtendedPositionBinCount, getExtraAccountMetasForTransferHook, getFeeMode, getIncludedFeeAmount, getLimitOrderLiquidity, getLiquidityStrategyParameterBuilder, getMultipleMintsExtraAccountMetasForTransferHook, getOrCreateATAInstruction, getPositionCount, getPositionCountByBinCount, getPositionExpandRentExemption, getPositionLowerUpperBinIdWithLiquidity, getPositionRentExemption, getPriceOfBinByBinId, getQPriceBaseFactor, getQPriceFromId, getRebalanceBinArrayIndexesAndBitmapCoverage, getSlippageMaxAmount, getSlippageMinAmount, getTokenBalance, getTokenDecimals, getTokenProgramId, getTokensMintFromPoolAddress, getTotalFee, getVariableFee, isBinIdWithinBinArray, isOverflowDefaultBinArrayBitmap, isPositionNoFee, isPositionNoReward, isSupportLimitOrder, limitOrderFilter, limitOrderLbPairFilter, limitOrderOwnerFilter, mulDiv, mulShr, parseLogs, positionLbPairFilter, positionOwnerFilter, positionV2Filter, presetParameter2BaseFactorFilter, presetParameter2BaseFeePowerFactor, presetParameter2BinStepFilter, range, resetUninvolvedLiquidityParams, sParameters, shlDiv, splitFee, suggestBalancedXParametersFromY, suggestBalancedYParametersFromX, swapExactInQuoteAtBin, swapExactOutQuoteAtBin, toAmountAskSide, toAmountBidSide, toAmountBothSide, toAmountIntoBins, toAmountsBothSideByStrategy, toStrategyParameters, toWeightDistribution, unwrapSOLInstruction, vParameters, wrapOracle, wrapPosition, wrapSOLInstruction };
|
|
26465
|
+
export { ADMIN, ALT_ADDRESS, AccountName, ActionType, ActivationType, AmountIntoBin, BASIS_POINT_MAX, BIN_ARRAY_BITMAP_FEE, BIN_ARRAY_BITMAP_FEE_BN, BIN_ARRAY_BITMAP_SIZE, BIN_ARRAY_DEFAULT_VERSION, BIN_ARRAY_FEE, BIN_ARRAY_FEE_BN, BidAskParameters, Bin, BinAndAmount, BinArray, BinArrayAccount, BinArrayBitmapExtension, BinArrayBitmapExtensionAccount, BinLiquidity, BinLiquidityDistribution, BinLiquidityReduction, BitmapType, ChunkCallback, ChunkCallbackInfo, ClmmProgram, Clock, ClockLayout, CollectFeeMode, CompressedBinDepositAmount, CompressedBinDepositAmounts, ConcreteFunctionType, CreateRebalancePositionParams, DEFAULT_BIN_PER_POSITION, DLMMError, DlmmSdkError, DynamicOracle, EXTENSION_BINARRAY_BITMAP_SIZE, EmissionRate, ExtendedPositionBinData, FEE_PRECISION, FeeInfo, FeeMode, FunctionType, GetOrCreateATAResponse, GetPositionsOpt, IAccountsCache, IDL, IDynamicOracle, ILM_BASE, IPosition, InitCustomizablePermissionlessPairIx, InitPermissionPairIx, InitializeMultiplePositionAndAddLiquidityByStrategyResponse, InitializeMultiplePositionAndAddLiquidityByStrategyResponse2, LBCLMM_PROGRAM_IDS, LIMIT_ORDER_BIN_DATA_SIZE, LIMIT_ORDER_FEE_SHARE, LIMIT_ORDER_MIN_SIZE, LMRewards, LbClmm, LbPair, LbPairAccount, LbPosition, LimitOrder, LimitOrderBinData, LimitOrderInfo, LimitOrderStatus, LiquidityOneSideParameter, LiquidityParameter, LiquidityParameterByStrategy, LiquidityParameterByStrategyOneSide, LiquidityParameterByWeight, LiquidityStrategyParameterBuilder, LiquidityStrategyParameters, MAX_ACTIVE_BIN_SLIPPAGE, MAX_BINS_PER_POSITION, MAX_BIN_ARRAY_SIZE, MAX_BIN_LENGTH_ALLOWED_IN_ONE_TX, MAX_BIN_PER_LIMIT_ORDER, MAX_CLAIM_ALL_ALLOWED, MAX_EXTRA_BIN_ARRAYS, MAX_FEE_RATE, MAX_RESIZE_LENGTH, MEMO_PROGRAM_ID, Network, Observation, Opt, Oracle, POOL_FEE, POOL_FEE_BN, POSITION_BIN_DATA_SIZE, POSITION_FEE, POSITION_FEE_BN, POSITION_MAX_LENGTH, POSITION_MIN_SIZE, PRECISION, PairLockInfo, PairStatus, PairType, ParsedLimitOrderWithPubkey, PlaceLimitOrderParams, PositionBinData, PositionData, PositionInfo, PositionLockInfo, PositionPermission, PositionV2, PositionV2Wrapper, PositionVersion, PresetParameter, PresetParameter2, ProgramStrategyParameter, ProgramStrategyType, REBALANCE_POSITION_PADDING, RebalanceAddLiquidityParam, RebalancePosition, RebalancePositionBinArrayRentalCostQuote, RebalancePositionResponse, RebalanceRemoveLiquidityParam, RebalanceWithDeposit, RebalanceWithWithdraw, RemainingAccountInfo, RemainingAccountsInfoSlice, ResizeSide, ResizeSideEnum, RewardInfo, RewardInfos, Rounding, SCALE, SCALE_OFFSET, SIMULATION_USER, SeedLiquidityCostBreakdown, SeedLiquidityResponse, SeedLiquiditySingleBinResponse, ShrinkMode, SimulateRebalanceResp, Strategy, StrategyParameters, StrategyType, SwapExactOutParams, SwapFee, SwapParams, SwapQuote, SwapQuoteExactOut, SwapWithPriceImpactParams, TInitializeMultiplePositionAndAddLiquidityParamsByStrategy, TInitializePositionAndAddLiquidityParams, TInitializePositionAndAddLiquidityParamsByStrategy, TOKEN_ACCOUNT_FEE, TOKEN_ACCOUNT_FEE_BN, TQuoteCreatePositionParams, TokenReserve, TwapResult, U64_MAX, UserFeeInfo, UserRewardInfo, autoFillXByStrategy, autoFillXByWeight, autoFillYByStrategy, autoFillYByWeight, binArrayLbPairFilter, binDeltaToMinMaxBinId, binIdToBinArrayIndex, buildBitFlagAndNegateStrategyParameters, buildLiquidityStrategyParameters, calculateBidAskDistribution, calculateNormalDistribution, calculatePositionSize, calculateSpotDistribution, calculateTransferFeeExcludedAmount, calculateTransferFeeIncludedAmount, capSlippagePercentage, chunkBinRange, chunkBinRangeIntoExtendedPositions, chunkDepositWithRebalanceEndpoint, chunkPositionBinRange, chunkedFetchMultipleBinArrayBitmapExtensionAccount, chunkedFetchMultiplePoolAccount, chunkedGetMultipleAccountInfos, chunkedGetProgramAccounts, chunks, compressBinAmount, computeBaseFactorFromFeeBps, computeFee, computeFeeFromAmount, computeProtocolFee, createProgram, decodeAccount, decodeExtendedPosition, decodeRewardPerTokenStored, DLMM as default, deriveBinArray, deriveBinArrayBitmapExtension, deriveCustomizablePermissionlessLbPair, deriveEventAuthority, deriveLbPair, deriveLbPair2, deriveLbPairWithPresetParamWithIndexKey, deriveOperator, deriveOracle, derivePermissionLbPair, derivePlaceHolderAccountMeta, derivePosition, derivePresetParameter, derivePresetParameter2, derivePresetParameterWithIndex, deriveReserve, deriveRewardVault, deriveTokenBadge, distributeAmountToCompressedBinsByRatio, encodePositionPermissions, enumerateBins, findNextBinArrayIndexWithLiquidity, findNextBinArrayWithLiquidity, findOptimumDecompressMultiplier, fromWeightDistributionToAmount, fromWeightDistributionToAmountOneSide, generateAmountForBinRange, generateBinAmount, getAccountDiscriminator, getAmountIn, getAmountInBinsAskSide, getAmountInBinsBidSide, getAmountOut, getAndCapMaxActiveBinSlippage, getAutoFillAmountByRebalancedPosition, getBaseFee, getBinArrayAccountMetasCoverage, getBinArrayIndexesCoverage, getBinArrayInfoForNonContiguousBinIds, getBinArrayKeysCoverage, getBinArrayLowerUpperBinId, getBinArraysRequiredByPositionRange, getBinCount, getBinFromBinArray, getBinIdIndexInBinArray, getBinMaxAmountOut, getC, getEstimatedComputeUnitIxWithBuffer, getEstimatedComputeUnitUsageWithBuffer, getExcludedFeeAmount, getExtendedPositionBinCount, getExtraAccountMetasForTransferHook, getFeeMode, getIncludedFeeAmount, getLimitOrderLiquidity, getLiquidityStrategyParameterBuilder, getMultipleMintsExtraAccountMetasForTransferHook, getOrCreateATAInstruction, getPositionCount, getPositionCountByBinCount, getPositionExpandRentExemption, getPositionLowerUpperBinIdWithLiquidity, getPositionRentExemption, getPriceOfBinByBinId, getQPriceBaseFactor, getQPriceFromId, getRebalanceBinArrayIndexesAndBitmapCoverage, getSlippageMaxAmount, getSlippageMinAmount, getTokenBalance, getTokenDecimals, getTokenProgramId, getTokensMintFromPoolAddress, getTotalFee, getVariableFee, isBinIdWithinBinArray, isOverflowDefaultBinArrayBitmap, isPositionNoFee, isPositionNoReward, isSupportLimitOrder, limitOrderFilter, limitOrderLbPairFilter, limitOrderOwnerFilter, mulDiv, mulShr, parseLogs, positionLbPairFilter, positionOwnerFilter, positionV2Filter, presetParameter2BaseFactorFilter, presetParameter2BaseFeePowerFactor, presetParameter2BinStepFilter, range, resetUninvolvedLiquidityParams, sParameters, shlDiv, splitFee, suggestBalancedXParametersFromY, suggestBalancedYParametersFromX, swapExactInQuoteAtBin, swapExactOutQuoteAtBin, toAmountAskSide, toAmountBidSide, toAmountBothSide, toAmountIntoBins, toAmountsBothSideByStrategy, toStrategyParameters, toWeightDistribution, unwrapSOLInstruction, vParameters, wrapOracle, wrapPosition, wrapSOLInstruction };
|
package/dist/index.js
CHANGED
|
@@ -10266,6 +10266,7 @@ var DlmmSdkError = class extends Error {
|
|
|
10266
10266
|
|
|
10267
10267
|
|
|
10268
10268
|
|
|
10269
|
+
|
|
10269
10270
|
// src/dlmm/types/index.ts
|
|
10270
10271
|
|
|
10271
10272
|
|
|
@@ -15354,7 +15355,8 @@ async function chunkDepositWithRebalanceEndpoint(dlmm, strategy, slippagePercent
|
|
|
15354
15355
|
const initBitmapIx = await dlmm.program.methods.initializeBinArrayBitmapExtension().accountsPartial({
|
|
15355
15356
|
binArrayBitmapExtension: bitmapPubkey,
|
|
15356
15357
|
lbPair: dlmm.pubkey,
|
|
15357
|
-
funder: payer
|
|
15358
|
+
funder: payer,
|
|
15359
|
+
rent: _web3js.SYSVAR_RENT_PUBKEY
|
|
15358
15360
|
}).instruction();
|
|
15359
15361
|
initBitmapIxs.push(initBitmapIx);
|
|
15360
15362
|
binArrayOrBitmapInitTracking.add(bitmapPubkey.toBase58());
|
|
@@ -16733,6 +16735,209 @@ var DLMM = class {
|
|
|
16733
16735
|
}
|
|
16734
16736
|
return positionsMap;
|
|
16735
16737
|
}
|
|
16738
|
+
/**
|
|
16739
|
+
* The function `getPositionsByUserAndTokenAddress` retrieves all of a user's positions across every
|
|
16740
|
+
* DLMM pool that includes the given token mint as either the X or Y token.
|
|
16741
|
+
* @param {Connection} connection - The `connection` parameter is an instance of the `Connection`
|
|
16742
|
+
* class, which represents the connection to the Solana blockchain.
|
|
16743
|
+
* @param {PublicKey} userPubKey - The user's wallet public key.
|
|
16744
|
+
* @param {PublicKey} tokenMint - The token mint used to filter pools. Only positions in pools whose
|
|
16745
|
+
* `tokenXMint` or `tokenYMint` matches this mint are returned.
|
|
16746
|
+
* @param {Opt} [opt] - An optional object that contains additional options for the function.
|
|
16747
|
+
* @param {GetPositionsOpt} [getPositionsOpt] - Optional settings for chunked position fetching
|
|
16748
|
+
* @returns The function `getPositionsByUserAndTokenAddress` returns a `Promise` that resolves to a
|
|
16749
|
+
* `Map` object. The `Map` object contains key-value pairs, where the key is a string representing the
|
|
16750
|
+
* LB Pair account, and the value is an object of PositionInfo. Only pools containing `tokenMint` are
|
|
16751
|
+
* included.
|
|
16752
|
+
*/
|
|
16753
|
+
static async getPositionsByUserAndTokenAddress(connection, userPubKey, tokenMint, opt, getPositionsOpt) {
|
|
16754
|
+
const allPositions = await DLMM.getAllLbPairPositionsByUser(
|
|
16755
|
+
connection,
|
|
16756
|
+
userPubKey,
|
|
16757
|
+
opt,
|
|
16758
|
+
getPositionsOpt
|
|
16759
|
+
);
|
|
16760
|
+
const targetMint = tokenMint.toBase58();
|
|
16761
|
+
const filteredPositions = /* @__PURE__ */ new Map();
|
|
16762
|
+
for (const [lbPairKey, positionInfo] of allPositions) {
|
|
16763
|
+
const tokenXMint = positionInfo.lbPair.tokenXMint.toBase58();
|
|
16764
|
+
const tokenYMint = positionInfo.lbPair.tokenYMint.toBase58();
|
|
16765
|
+
if (tokenXMint === targetMint || tokenYMint === targetMint) {
|
|
16766
|
+
filteredPositions.set(lbPairKey, positionInfo);
|
|
16767
|
+
}
|
|
16768
|
+
}
|
|
16769
|
+
return filteredPositions;
|
|
16770
|
+
}
|
|
16771
|
+
/**
|
|
16772
|
+
* The function `getLimitOrdersByUserAndTokenAddress` retrieves all of a user's limit orders across
|
|
16773
|
+
* every DLMM pool that includes the given token mint as either the X or Y token.
|
|
16774
|
+
* @param {Connection} connection - The `connection` parameter is an instance of the `Connection`
|
|
16775
|
+
* class, which represents the connection to the Solana blockchain.
|
|
16776
|
+
* @param {PublicKey} userPubKey - The user's wallet public key.
|
|
16777
|
+
* @param {PublicKey} tokenMint - The token mint used to filter pools. Only limit orders in pools
|
|
16778
|
+
* whose `tokenXMint` or `tokenYMint` matches this mint are returned.
|
|
16779
|
+
* @param {Opt} [opt] - An optional object that contains additional options for the function.
|
|
16780
|
+
* @returns The function `getLimitOrdersByUserAndTokenAddress` returns a `Promise` that resolves to a
|
|
16781
|
+
* `Map` object keyed by LB Pair account (base58), where each value is a `LimitOrderInfo` containing
|
|
16782
|
+
* the LB pair state, token reserves, and the parsed limit orders for that pool.
|
|
16783
|
+
*/
|
|
16784
|
+
static async getLimitOrdersByUserAndTokenAddress(connection, userPubKey, tokenMint, opt) {
|
|
16785
|
+
const program = createProgram(connection, opt);
|
|
16786
|
+
const limitOrderAccounts = await chunkedGetProgramAccounts(
|
|
16787
|
+
program.provider.connection,
|
|
16788
|
+
program.programId,
|
|
16789
|
+
[limitOrderFilter(), limitOrderOwnerFilter(userPubKey)]
|
|
16790
|
+
);
|
|
16791
|
+
const limitOrderWrappers = limitOrderAccounts.map(
|
|
16792
|
+
({ pubkey, account }) => wrapLimitOrder(program, pubkey, account)
|
|
16793
|
+
);
|
|
16794
|
+
if (limitOrderWrappers.length === 0) {
|
|
16795
|
+
return /* @__PURE__ */ new Map();
|
|
16796
|
+
}
|
|
16797
|
+
const lbPairKeys = Array.from(
|
|
16798
|
+
new Set(limitOrderWrappers.map((lo) => lo.lbPair().toBase58()))
|
|
16799
|
+
).map((key) => new (0, _web3js.PublicKey)(key));
|
|
16800
|
+
const lbPairAccInfos = await chunkedGetMultipleAccountInfos(
|
|
16801
|
+
connection,
|
|
16802
|
+
lbPairKeys
|
|
16803
|
+
);
|
|
16804
|
+
const lbPairMap = /* @__PURE__ */ new Map();
|
|
16805
|
+
lbPairKeys.forEach((lbPairPubkey, i) => {
|
|
16806
|
+
const accInfo = lbPairAccInfos[i];
|
|
16807
|
+
if (!accInfo) {
|
|
16808
|
+
throw new Error(`LB Pair account ${lbPairPubkey.toBase58()} not found`);
|
|
16809
|
+
}
|
|
16810
|
+
lbPairMap.set(
|
|
16811
|
+
lbPairPubkey.toBase58(),
|
|
16812
|
+
decodeAccount(program, "lbPair", accInfo.data)
|
|
16813
|
+
);
|
|
16814
|
+
});
|
|
16815
|
+
const targetMint = tokenMint.toBase58();
|
|
16816
|
+
const matchingLbPairKeys = lbPairKeys.filter((lbPairPubkey) => {
|
|
16817
|
+
const lbPairState = lbPairMap.get(lbPairPubkey.toBase58());
|
|
16818
|
+
return lbPairState.tokenXMint.toBase58() === targetMint || lbPairState.tokenYMint.toBase58() === targetMint;
|
|
16819
|
+
});
|
|
16820
|
+
if (matchingLbPairKeys.length === 0) {
|
|
16821
|
+
return /* @__PURE__ */ new Map();
|
|
16822
|
+
}
|
|
16823
|
+
const matchingLbPairSet = new Set(
|
|
16824
|
+
matchingLbPairKeys.map((key) => key.toBase58())
|
|
16825
|
+
);
|
|
16826
|
+
const matchingLimitOrders = limitOrderWrappers.filter(
|
|
16827
|
+
(lo) => matchingLbPairSet.has(lo.lbPair().toBase58())
|
|
16828
|
+
);
|
|
16829
|
+
const reserveAndMintKeys = matchingLbPairKeys.map((lbPairPubkey) => {
|
|
16830
|
+
const { reserveX, reserveY, tokenXMint, tokenYMint } = lbPairMap.get(
|
|
16831
|
+
lbPairPubkey.toBase58()
|
|
16832
|
+
);
|
|
16833
|
+
return [reserveX, reserveY, tokenXMint, tokenYMint];
|
|
16834
|
+
}).flat();
|
|
16835
|
+
const binArrayPubkeySet = /* @__PURE__ */ new Set();
|
|
16836
|
+
matchingLimitOrders.forEach((lo) => {
|
|
16837
|
+
lo.getBinArrayKeysCoverage(program.programId).forEach((key) => {
|
|
16838
|
+
binArrayPubkeySet.add(key.toBase58());
|
|
16839
|
+
});
|
|
16840
|
+
});
|
|
16841
|
+
const binArrayKeys = Array.from(binArrayPubkeySet).map(
|
|
16842
|
+
(key) => new (0, _web3js.PublicKey)(key)
|
|
16843
|
+
);
|
|
16844
|
+
const [clockAccInfo, ...rest] = await chunkedGetMultipleAccountInfos(
|
|
16845
|
+
connection,
|
|
16846
|
+
[_web3js.SYSVAR_CLOCK_PUBKEY, ...binArrayKeys, ...reserveAndMintKeys]
|
|
16847
|
+
);
|
|
16848
|
+
const binArraysAccInfo = rest.slice(0, binArrayKeys.length);
|
|
16849
|
+
const reserveAndMintAccInfo = rest.slice(binArrayKeys.length);
|
|
16850
|
+
const clock = ClockLayout.decode(clockAccInfo.data);
|
|
16851
|
+
const binArrayMap = /* @__PURE__ */ new Map();
|
|
16852
|
+
binArrayKeys.forEach((binArrayPubkey, i) => {
|
|
16853
|
+
const accInfo = binArraysAccInfo[i];
|
|
16854
|
+
if (accInfo) {
|
|
16855
|
+
binArrayMap.set(
|
|
16856
|
+
binArrayPubkey.toBase58(),
|
|
16857
|
+
decodeAccount(program, "binArray", accInfo.data)
|
|
16858
|
+
);
|
|
16859
|
+
}
|
|
16860
|
+
});
|
|
16861
|
+
const lbPairTokenMap = /* @__PURE__ */ new Map();
|
|
16862
|
+
matchingLbPairKeys.forEach((lbPairPubkey, idx) => {
|
|
16863
|
+
const index = idx * 4;
|
|
16864
|
+
const reserveXAccount = reserveAndMintAccInfo[index];
|
|
16865
|
+
const reserveYAccount = reserveAndMintAccInfo[index + 1];
|
|
16866
|
+
const mintXAccount = reserveAndMintAccInfo[index + 2];
|
|
16867
|
+
const mintYAccount = reserveAndMintAccInfo[index + 3];
|
|
16868
|
+
if (!reserveXAccount || !reserveYAccount) {
|
|
16869
|
+
throw new Error(
|
|
16870
|
+
`Reserve account for LB Pair ${lbPairPubkey.toBase58()} not found`
|
|
16871
|
+
);
|
|
16872
|
+
}
|
|
16873
|
+
if (!mintXAccount || !mintYAccount) {
|
|
16874
|
+
throw new Error(
|
|
16875
|
+
`Mint account for LB Pair ${lbPairPubkey.toBase58()} not found`
|
|
16876
|
+
);
|
|
16877
|
+
}
|
|
16878
|
+
const lbPairState = lbPairMap.get(lbPairPubkey.toBase58());
|
|
16879
|
+
const reserveAccX = _spltoken.AccountLayout.decode(reserveXAccount.data);
|
|
16880
|
+
const reserveAccY = _spltoken.AccountLayout.decode(reserveYAccount.data);
|
|
16881
|
+
const mintX = _spltoken.unpackMint.call(void 0, reserveAccX.mint, mintXAccount, mintXAccount.owner);
|
|
16882
|
+
const mintY = _spltoken.unpackMint.call(void 0, reserveAccY.mint, mintYAccount, mintYAccount.owner);
|
|
16883
|
+
const { tokenXProgram, tokenYProgram } = getTokenProgramId(lbPairState);
|
|
16884
|
+
const tokenX = {
|
|
16885
|
+
publicKey: lbPairState.tokenXMint,
|
|
16886
|
+
reserve: lbPairState.reserveX,
|
|
16887
|
+
amount: reserveAccX.amount,
|
|
16888
|
+
mint: mintX,
|
|
16889
|
+
owner: tokenXProgram,
|
|
16890
|
+
transferHookAccountMetas: []
|
|
16891
|
+
// Not required for read-only limit order processing
|
|
16892
|
+
};
|
|
16893
|
+
const tokenY = {
|
|
16894
|
+
publicKey: lbPairState.tokenYMint,
|
|
16895
|
+
reserve: lbPairState.reserveY,
|
|
16896
|
+
amount: reserveAccY.amount,
|
|
16897
|
+
mint: mintY,
|
|
16898
|
+
owner: tokenYProgram,
|
|
16899
|
+
transferHookAccountMetas: []
|
|
16900
|
+
// Not required for read-only limit order processing
|
|
16901
|
+
};
|
|
16902
|
+
lbPairTokenMap.set(lbPairPubkey.toBase58(), {
|
|
16903
|
+
tokenX,
|
|
16904
|
+
tokenY,
|
|
16905
|
+
mintX,
|
|
16906
|
+
mintY
|
|
16907
|
+
});
|
|
16908
|
+
});
|
|
16909
|
+
const limitOrdersMap = /* @__PURE__ */ new Map();
|
|
16910
|
+
for (const lo of matchingLimitOrders) {
|
|
16911
|
+
const lbPairKey = lo.lbPair().toBase58();
|
|
16912
|
+
const lbPairState = lbPairMap.get(lbPairKey);
|
|
16913
|
+
const { tokenX, tokenY, mintX, mintY } = lbPairTokenMap.get(lbPairKey);
|
|
16914
|
+
const parsedLo = lo.parseInfo(
|
|
16915
|
+
program.programId,
|
|
16916
|
+
lbPairState,
|
|
16917
|
+
mintX,
|
|
16918
|
+
mintY,
|
|
16919
|
+
clock,
|
|
16920
|
+
binArrayMap
|
|
16921
|
+
);
|
|
16922
|
+
const entry = {
|
|
16923
|
+
publicKey: lo.address(),
|
|
16924
|
+
limitOrderData: parsedLo
|
|
16925
|
+
};
|
|
16926
|
+
const existing = limitOrdersMap.get(lbPairKey);
|
|
16927
|
+
if (existing) {
|
|
16928
|
+
existing.limitOrders.push(entry);
|
|
16929
|
+
} else {
|
|
16930
|
+
limitOrdersMap.set(lbPairKey, {
|
|
16931
|
+
publicKey: lo.lbPair(),
|
|
16932
|
+
lbPair: lbPairState,
|
|
16933
|
+
tokenX,
|
|
16934
|
+
tokenY,
|
|
16935
|
+
limitOrders: [entry]
|
|
16936
|
+
});
|
|
16937
|
+
}
|
|
16938
|
+
}
|
|
16939
|
+
return limitOrdersMap;
|
|
16940
|
+
}
|
|
16736
16941
|
static getPricePerLamport(tokenXDecimal, tokenYDecimal, price) {
|
|
16737
16942
|
return new (0, _decimaljs2.default)(price).mul(new (0, _decimaljs2.default)(10 ** (tokenYDecimal - tokenXDecimal))).toString();
|
|
16738
16943
|
}
|
|
@@ -20731,7 +20936,8 @@ var DLMM = class {
|
|
|
20731
20936
|
await this.program.methods.initializeBinArrayBitmapExtension().accountsPartial({
|
|
20732
20937
|
binArrayBitmapExtension,
|
|
20733
20938
|
funder: payer,
|
|
20734
|
-
lbPair: this.pubkey
|
|
20939
|
+
lbPair: this.pubkey,
|
|
20940
|
+
rent: _web3js.SYSVAR_RENT_PUBKEY
|
|
20735
20941
|
}).instruction()
|
|
20736
20942
|
);
|
|
20737
20943
|
appendedInitBinArrayBitmap = true;
|
|
@@ -20930,7 +21136,8 @@ var DLMM = class {
|
|
|
20930
21136
|
await this.program.methods.initializeBinArrayBitmapExtension().accountsPartial({
|
|
20931
21137
|
binArrayBitmapExtension,
|
|
20932
21138
|
funder: payer,
|
|
20933
|
-
lbPair: this.pubkey
|
|
21139
|
+
lbPair: this.pubkey,
|
|
21140
|
+
rent: _web3js.SYSVAR_RENT_PUBKEY
|
|
20934
21141
|
}).instruction()
|
|
20935
21142
|
);
|
|
20936
21143
|
binArrayBitmapLamports = binArrayBitmapLamports.add(
|
|
@@ -21346,7 +21553,8 @@ var DLMM = class {
|
|
|
21346
21553
|
const initializeBitmapExtensionIx = await this.program.methods.initializeBinArrayBitmapExtension().accountsPartial({
|
|
21347
21554
|
binArrayBitmapExtension: binArrayBitMapExtensionPubkey,
|
|
21348
21555
|
funder: owner,
|
|
21349
|
-
lbPair: this.pubkey
|
|
21556
|
+
lbPair: this.pubkey,
|
|
21557
|
+
rent: _web3js.SYSVAR_RENT_PUBKEY
|
|
21350
21558
|
}).instruction();
|
|
21351
21559
|
preInstructions.push(initializeBitmapExtensionIx);
|
|
21352
21560
|
}
|
|
@@ -21754,7 +21962,8 @@ var DLMM = class {
|
|
|
21754
21962
|
const initBitmapExtensionIx = await this.program.methods.initializeBinArrayBitmapExtension().accountsPartial({
|
|
21755
21963
|
binArrayBitmapExtension: binArrayBitmap,
|
|
21756
21964
|
funder: owner,
|
|
21757
|
-
lbPair: this.pubkey
|
|
21965
|
+
lbPair: this.pubkey,
|
|
21966
|
+
rent: _web3js.SYSVAR_RENT_PUBKEY
|
|
21758
21967
|
}).preInstructions([
|
|
21759
21968
|
_web3js.ComputeBudgetProgram.setComputeUnitLimit({
|
|
21760
21969
|
units: DEFAULT_INIT_BIN_ARRAY_CU
|
|
@@ -21970,7 +22179,8 @@ var DLMM = class {
|
|
|
21970
22179
|
const initializeBitmapExtensionIx = await this.program.methods.initializeBinArrayBitmapExtension().accountsPartial({
|
|
21971
22180
|
binArrayBitmapExtension,
|
|
21972
22181
|
funder: owner,
|
|
21973
|
-
lbPair: this.pubkey
|
|
22182
|
+
lbPair: this.pubkey,
|
|
22183
|
+
rent: _web3js.SYSVAR_RENT_PUBKEY
|
|
21974
22184
|
}).instruction();
|
|
21975
22185
|
preInstructions.push(initializeBitmapExtensionIx);
|
|
21976
22186
|
}
|
|
@@ -22062,7 +22272,8 @@ var DLMM = class {
|
|
|
22062
22272
|
* - `limitOrderPubkey`: The public key of the limit-order account to cancel.
|
|
22063
22273
|
* - `owner`: The owner of the limit-order account and transaction fee payer.
|
|
22064
22274
|
* - `binIds`: Bin IDs to cancel from the limit order.
|
|
22065
|
-
* @returns {Promise<Transaction>} A transaction that cancels the limit order
|
|
22275
|
+
* @returns {Promise<Transaction>} A transaction that cancels the limit order, ensures owner ATAs for both pool
|
|
22276
|
+
* mints (including idempotent creates for non-SOL legs), and unwraps SOL when applicable.
|
|
22066
22277
|
*/
|
|
22067
22278
|
async cancelLimitOrder({
|
|
22068
22279
|
limitOrderPubkey,
|
|
@@ -22090,7 +22301,20 @@ var DLMM = class {
|
|
|
22090
22301
|
true,
|
|
22091
22302
|
this.tokenY.owner
|
|
22092
22303
|
);
|
|
22093
|
-
if (this.tokenX.mint.address.equals(_spltoken.NATIVE_MINT)
|
|
22304
|
+
if (this.tokenX.mint.address.equals(_spltoken.NATIVE_MINT)) {
|
|
22305
|
+
if (!_optionalChain([this, 'access', _177 => _177.opt, 'optionalAccess', _178 => _178.skipSolWrappingOperation])) {
|
|
22306
|
+
preInstructions.push(
|
|
22307
|
+
_spltoken.createAssociatedTokenAccountIdempotentInstruction.call(void 0,
|
|
22308
|
+
owner,
|
|
22309
|
+
userTokenX,
|
|
22310
|
+
owner,
|
|
22311
|
+
this.tokenX.mint.address,
|
|
22312
|
+
this.tokenX.owner
|
|
22313
|
+
)
|
|
22314
|
+
);
|
|
22315
|
+
postInstructions.push(unwrapSOLInstruction(owner));
|
|
22316
|
+
}
|
|
22317
|
+
} else {
|
|
22094
22318
|
preInstructions.push(
|
|
22095
22319
|
_spltoken.createAssociatedTokenAccountIdempotentInstruction.call(void 0,
|
|
22096
22320
|
owner,
|
|
@@ -22100,9 +22324,21 @@ var DLMM = class {
|
|
|
22100
22324
|
this.tokenX.owner
|
|
22101
22325
|
)
|
|
22102
22326
|
);
|
|
22103
|
-
postInstructions.push(unwrapSOLInstruction(owner));
|
|
22104
22327
|
}
|
|
22105
|
-
if (this.tokenY.mint.address.equals(_spltoken.NATIVE_MINT)
|
|
22328
|
+
if (this.tokenY.mint.address.equals(_spltoken.NATIVE_MINT)) {
|
|
22329
|
+
if (!_optionalChain([this, 'access', _179 => _179.opt, 'optionalAccess', _180 => _180.skipSolWrappingOperation])) {
|
|
22330
|
+
preInstructions.push(
|
|
22331
|
+
_spltoken.createAssociatedTokenAccountIdempotentInstruction.call(void 0,
|
|
22332
|
+
owner,
|
|
22333
|
+
userTokenY,
|
|
22334
|
+
owner,
|
|
22335
|
+
this.tokenY.mint.address,
|
|
22336
|
+
this.tokenY.owner
|
|
22337
|
+
)
|
|
22338
|
+
);
|
|
22339
|
+
postInstructions.push(unwrapSOLInstruction(owner));
|
|
22340
|
+
}
|
|
22341
|
+
} else {
|
|
22106
22342
|
preInstructions.push(
|
|
22107
22343
|
_spltoken.createAssociatedTokenAccountIdempotentInstruction.call(void 0,
|
|
22108
22344
|
owner,
|
|
@@ -22112,7 +22348,6 @@ var DLMM = class {
|
|
|
22112
22348
|
this.tokenY.owner
|
|
22113
22349
|
)
|
|
22114
22350
|
);
|
|
22115
|
-
postInstructions.push(unwrapSOLInstruction(owner));
|
|
22116
22351
|
}
|
|
22117
22352
|
const closeLimitOrderIx = await this.program.methods.closeLimitOrderIfEmpty().accountsPartial({
|
|
22118
22353
|
limitOrder: limitOrderPubkey,
|