@hawksightco/hawk-sdk 1.1.45 → 1.1.46
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.
|
@@ -49,6 +49,15 @@ export declare class Transactions {
|
|
|
49
49
|
* @returns A ResponseWithStatus containing either TransactionMetadataResponse.
|
|
50
50
|
*/
|
|
51
51
|
meteoraCreatePositionAndDeposit({ connection, params, }: TxgenParams<MeteoraCreatePositionAndDeposit>): Promise<TransactionMetadataResponse>;
|
|
52
|
+
/**
|
|
53
|
+
* Creates meteora instruction that creates new position and deposit.
|
|
54
|
+
*
|
|
55
|
+
* @param connection The Solana web3 connection object for blockchain interactions.
|
|
56
|
+
* @param payer The public key of the payer for transaction fees.
|
|
57
|
+
* @param params Parameters required
|
|
58
|
+
* @returns A ResponseWithStatus containing either TransactionMetadataResponse.
|
|
59
|
+
*/
|
|
60
|
+
meteoraCreatePositionAndDeposiPda({ connection, params, }: TxgenParams<MeteoraCreatePositionAndDeposit>): Promise<TransactionMetadataResponse>;
|
|
52
61
|
/**
|
|
53
62
|
* Creates meteora instruction that initializes bin arrays.
|
|
54
63
|
*
|
|
@@ -76,6 +85,15 @@ export declare class Transactions {
|
|
|
76
85
|
* @returns A ResponseWithStatus containing either TransactionMetadataResponse.
|
|
77
86
|
*/
|
|
78
87
|
meteoraWithdraw({ connection, params, }: TxgenParams<MeteoraWithdraw>): Promise<TransactionMetadataResponse>;
|
|
88
|
+
/**
|
|
89
|
+
* Creates meteora instruction withdraws from a position.
|
|
90
|
+
*
|
|
91
|
+
* @param connection The Solana web3 connection object for blockchain interactions.
|
|
92
|
+
* @param payer The public key of the payer for transaction fees.
|
|
93
|
+
* @param params Parameters required
|
|
94
|
+
* @returns A ResponseWithStatus containing either TransactionMetadataResponse.
|
|
95
|
+
*/
|
|
96
|
+
meteoraWithdrawPda({ connection, params, }: TxgenParams<MeteoraWithdraw>): Promise<TransactionMetadataResponse>;
|
|
79
97
|
/**
|
|
80
98
|
* Creates meteora instruction that claims fees and rewards.
|
|
81
99
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Transactions.d.ts","sourceRoot":"","sources":["../../../src/classes/Transactions.ts"],"names":[],"mappings":";AACA,OAAO,KAAK,IAAI,MAAM,iBAAiB,CAAC;AAiBxC,OAAO,EACL,YAAY,EACZ,eAAe,EACf,YAAY,EACZ,eAAe,EACf,+BAA+B,EAC/B,cAAc,EACd,0BAA0B,EAC1B,gBAAgB,EAChB,eAAe,EACf,QAAQ,EAER,WAAW,EACX,6BAA6B,EAC7B,2BAA2B,EAC3B,gBAAgB,EAChB,iBAAiB,EACjB,WAAW,EACX,YAAY,EACZ,gBAAgB,EAChB,2BAA2B,EAC3B,iBAAiB,EAClB,MAAM,UAAU,CAAC;AA8BlB,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAExD,qBAAa,YAAY;IAEvB;;OAEG;IACH,OAAO;IAIP;;OAEG;IACH,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAe;IAEtC;;OAEG;IACI,EAAE,EAAE,iBAAiB,CAAC;IAE7B;;;;OAIG;IACH,MAAM,CAAC,WAAW,IAAI,YAAY;IAOlC;;;;;;OAMG;IACH,eAAe,CACb,UAAU,EAAE,IAAI,CAAC,SAAS,EAC1B,IAAI,GAAE,IAAI,CAAC,SAAqB,GAC/B,IAAI,CAAC,SAAS;IAIjB;;;;;;;OAOG;IACG,QAAQ,CAAC,EACb,UAAU,EACV,MAAM,GACP,EAAE,WAAW,CAAC,QAAQ,CAAC,GAAG,OAAO,CAAC,2BAA2B,CAAC;IAqD/D;;;;;;;OAOG;IACG,+BAA+B,CAAC,EACpC,UAAU,EACV,MAAM,GACP,EAAE,WAAW,CAAC,+BAA+B,CAAC,GAAG,OAAO,CAAC,2BAA2B,C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C3B,UAAU,EACV,MAAM,GACP,EAAE,WAAW,CAAC,2BAA2B,CAAC;IA+H3C,OAAO,CAAC,0BAA0B;IAkClC;;;;;;;OAOG;IACG,gBAAgB,CAAC,EAAE,UAAU,EAAE,MAAM,EAAE,EAAE,WAAW,CAAC,gBAAgB,CAAC,GAAG,OAAO,CAAC,2BAA2B,CAAC;IA2DnH;;;;;;;OAOG;IACG,iBAAiB,CAAC,EAAE,UAAU,EAAE,MAAM,EAAE,EAAE,WAAW,CAAC,iBAAiB,CAAC,GAAG,OAAO,CAAC,2BAA2B,CAAC;IAqDrH;;;;;;;OAOG;IACG,WAAW,CAAC,EAAE,UAAU,EAAE,MAAM,EAAE,EAAE,WAAW,CAAC,WAAW,CAAC,GAAG,OAAO,CAAC,2BAA2B,CAAC;IA4IzG;;;;;;;OAOG;IACG,YAAY,CAAC,EAAE,UAAU,EAAE,MAAM,EAAE,EAAE,WAAW,CAAC,YAAY,CAAC,GAAG,OAAO,CAAC,2BAA2B,CAAC;IA2F3G;;;;;;;OAOG;IACG,gBAAgB,CAAC,EAAE,UAAU,EAAE,MAAM,EAAE,EAAE,WAAW,CAAC,gBAAgB,CAAC,GAAG,OAAO,CAAC,2BAA2B,CAAC;CAoGpH;AAED,eAAO,MAAM,KAAK,cAA6B,CAAC"}
|
|
@@ -168,6 +168,39 @@ class Transactions {
|
|
|
168
168
|
});
|
|
169
169
|
});
|
|
170
170
|
}
|
|
171
|
+
/**
|
|
172
|
+
* Creates meteora instruction that creates new position and deposit.
|
|
173
|
+
*
|
|
174
|
+
* @param connection The Solana web3 connection object for blockchain interactions.
|
|
175
|
+
* @param payer The public key of the payer for transaction fees.
|
|
176
|
+
* @param params Parameters required
|
|
177
|
+
* @returns A ResponseWithStatus containing either TransactionMetadataResponse.
|
|
178
|
+
*/
|
|
179
|
+
meteoraCreatePositionAndDeposiPda(_a) {
|
|
180
|
+
return __awaiter(this, arguments, void 0, function* ({ connection, params, }) {
|
|
181
|
+
const dlmmPool = yield meteora_1.MeteoraDLMM.create(connection, new web3.PublicKey(params.pool));
|
|
182
|
+
const userPda = (0, functions_1.generateUserPda)(params.userWallet);
|
|
183
|
+
const mainInstructions = (yield dlmmPool.initializePositionAndAddLiquidityByStrategyPda(params.userWallet, params.userWallet, {
|
|
184
|
+
positionPubKey: params.position,
|
|
185
|
+
user: userPda,
|
|
186
|
+
totalXAmount: params.totalXAmount,
|
|
187
|
+
totalYAmount: params.totalYAmount,
|
|
188
|
+
strategy: {
|
|
189
|
+
maxBinId: params.binRange.upperRange,
|
|
190
|
+
minBinId: params.binRange.lowerRange,
|
|
191
|
+
strategyType: types_1.StrategyTypeMap[params.distribution],
|
|
192
|
+
},
|
|
193
|
+
slippage: params.slippage,
|
|
194
|
+
skipInputTokenCheck: params.skipInputTokenCheck,
|
|
195
|
+
}, hsToMeteora_1.meteoraToHawksight)).default();
|
|
196
|
+
return (0, functions_1.createTransactionMeta)({
|
|
197
|
+
payer: params.userWallet,
|
|
198
|
+
description: "Create position and deposit to Meteora DLMM",
|
|
199
|
+
addressLookupTableAddresses: addresses_1.GLOBAL_ALT,
|
|
200
|
+
mainInstructions,
|
|
201
|
+
});
|
|
202
|
+
});
|
|
203
|
+
}
|
|
171
204
|
/**
|
|
172
205
|
* Creates meteora instruction that initializes bin arrays.
|
|
173
206
|
*
|
|
@@ -298,6 +331,68 @@ class Transactions {
|
|
|
298
331
|
});
|
|
299
332
|
});
|
|
300
333
|
}
|
|
334
|
+
/**
|
|
335
|
+
* Creates meteora instruction withdraws from a position.
|
|
336
|
+
*
|
|
337
|
+
* @param connection The Solana web3 connection object for blockchain interactions.
|
|
338
|
+
* @param payer The public key of the payer for transaction fees.
|
|
339
|
+
* @param params Parameters required
|
|
340
|
+
* @returns A ResponseWithStatus containing either TransactionMetadataResponse.
|
|
341
|
+
*/
|
|
342
|
+
meteoraWithdrawPda(_a) {
|
|
343
|
+
return __awaiter(this, arguments, void 0, function* ({ connection, params, }) {
|
|
344
|
+
const userPda = (0, functions_1.generateUserPda)(params.userWallet);
|
|
345
|
+
const program = yield meteora_1.MeteoraDLMM.program(connection);
|
|
346
|
+
let lbPair, binIdsToRemove;
|
|
347
|
+
if (params.fastGeneration !== undefined) {
|
|
348
|
+
lbPair = params.fastGeneration.pool;
|
|
349
|
+
}
|
|
350
|
+
else {
|
|
351
|
+
const position = yield program.account.positionV2.fetch(params.position);
|
|
352
|
+
lbPair = position.lbPair;
|
|
353
|
+
}
|
|
354
|
+
const dlmmPool = yield meteora_1.MeteoraDLMM.create(connection, lbPair);
|
|
355
|
+
if (params.fastGeneration === undefined) {
|
|
356
|
+
const { userPositions } = yield dlmmPool.getPositionsByUserAndLbPair(userPda);
|
|
357
|
+
const userPosition = userPositions.find((userPosition) => userPosition.publicKey.toString() === params.position.toString());
|
|
358
|
+
if (userPosition === undefined) {
|
|
359
|
+
throw new Error("Position does not exist."); // this error should not happen...
|
|
360
|
+
}
|
|
361
|
+
binIdsToRemove = userPosition.positionData.positionBinData.map((bin) => bin.binId);
|
|
362
|
+
}
|
|
363
|
+
else {
|
|
364
|
+
binIdsToRemove = params.fastGeneration.binIdsToRemove;
|
|
365
|
+
}
|
|
366
|
+
const amountBps = params.shouldClaimAndClose
|
|
367
|
+
? new bn_js_1.default(10000)
|
|
368
|
+
: params.amountBps;
|
|
369
|
+
const mainInstructions = (yield dlmmPool.removeLiquidityPda(params.userWallet, params.userWallet, {
|
|
370
|
+
user: userPda,
|
|
371
|
+
position: params.position,
|
|
372
|
+
binIds: binIdsToRemove,
|
|
373
|
+
bps: amountBps,
|
|
374
|
+
shouldClaimAndClose: params.shouldClaimAndClose,
|
|
375
|
+
}, hsToMeteora_1.meteoraToHawksight)).default();
|
|
376
|
+
let description;
|
|
377
|
+
if (params.shouldClaimAndClose) {
|
|
378
|
+
description =
|
|
379
|
+
"Full position withdrawal with claim and close instructisons from Meteora DLMM";
|
|
380
|
+
}
|
|
381
|
+
else if (amountBps.eq(new bn_js_1.default(10000))) {
|
|
382
|
+
description =
|
|
383
|
+
"Full position withdrawal without claim and close instructions from Meteora DLMM";
|
|
384
|
+
}
|
|
385
|
+
else {
|
|
386
|
+
description = "Partial position withdrawal from Meteora DLMM";
|
|
387
|
+
}
|
|
388
|
+
return (0, functions_1.createTransactionMeta)({
|
|
389
|
+
payer: params.userWallet,
|
|
390
|
+
description,
|
|
391
|
+
addressLookupTableAddresses: addresses_1.GLOBAL_ALT,
|
|
392
|
+
mainInstructions,
|
|
393
|
+
});
|
|
394
|
+
});
|
|
395
|
+
}
|
|
301
396
|
/**
|
|
302
397
|
* Creates meteora instruction that claims fees and rewards.
|
|
303
398
|
*
|
package/dist/src/meteora.d.ts
CHANGED
|
@@ -65,6 +65,40 @@ export declare class MeteoraDLMM {
|
|
|
65
65
|
slippage?: number;
|
|
66
66
|
skipInputTokenCheck?: boolean;
|
|
67
67
|
}, meteoraToHawksight: MeteoraToHawksightFn): Promise<InitializePositionAndAddLiquidityByStrategyBuilder>;
|
|
68
|
+
/**
|
|
69
|
+
* Initializes a position and adds liquidity to the specified strategy, with various steps including
|
|
70
|
+
* handling wrapped SOL tokens, depositing tokens, adding liquidity, and handling dust withdrawals.
|
|
71
|
+
*
|
|
72
|
+
* @param {web3.PublicKey} userWallet - The public key of the user's wallet executing the transaction.
|
|
73
|
+
* @param {web3.PublicKey} payer - The public key of the transaction payer.
|
|
74
|
+
* @param {Object} params - The parameters for initializing the position and adding liquidity.
|
|
75
|
+
* @param {web3.PublicKey} params.positionPubKey - The public key of the position to be initialized.
|
|
76
|
+
* @param {BN} params.totalXAmount - The total amount of X tokens to be used for liquidity.
|
|
77
|
+
* @param {BN} params.totalYAmount - The total amount of Y tokens to be used for liquidity.
|
|
78
|
+
* @param {Object} params.strategy - The strategy details for adding liquidity.
|
|
79
|
+
* @param {number} params.strategy.maxBinId - The maximum bin ID for the strategy.
|
|
80
|
+
* @param {number} params.strategy.minBinId - The minimum bin ID for the strategy.
|
|
81
|
+
* @param {StrategyType} params.strategy.strategyType - The type of strategy to be applied.
|
|
82
|
+
* @param {web3.PublicKey} params.user - The public key of the user executing the transaction.
|
|
83
|
+
* @param {number} [params.slippage] - Optional slippage tolerance for the transaction.
|
|
84
|
+
*
|
|
85
|
+
* @returns {Promise<web3.TransactionInstruction[]>} - A promise that resolves to an array of transaction instructions.
|
|
86
|
+
*
|
|
87
|
+
* @throws {Error} - Throws an error if input token(s) do not exist on the blockchain.
|
|
88
|
+
*/
|
|
89
|
+
initializePositionAndAddLiquidityByStrategyPda(userWallet: web3.PublicKey, payer: web3.PublicKey, params: {
|
|
90
|
+
positionPubKey: web3.PublicKey;
|
|
91
|
+
totalXAmount: BN;
|
|
92
|
+
totalYAmount: BN;
|
|
93
|
+
strategy: {
|
|
94
|
+
maxBinId: number;
|
|
95
|
+
minBinId: number;
|
|
96
|
+
strategyType: StrategyType;
|
|
97
|
+
};
|
|
98
|
+
user: web3.PublicKey;
|
|
99
|
+
slippage?: number;
|
|
100
|
+
skipInputTokenCheck?: boolean;
|
|
101
|
+
}, meteoraToHawksight: MeteoraToHawksightFn): Promise<InitializePositionAndAddLiquidityByStrategyPdaBuilder>;
|
|
68
102
|
/**
|
|
69
103
|
* Adds liquidity to an existing position according to a specified strategy.
|
|
70
104
|
*
|
|
@@ -126,6 +160,31 @@ export declare class MeteoraDLMM {
|
|
|
126
160
|
bps: BN;
|
|
127
161
|
shouldClaimAndClose?: boolean;
|
|
128
162
|
}, meteoraToHawksight: MeteoraToHawksightFn): Promise<RemoveLiquidityBuilder>;
|
|
163
|
+
/**
|
|
164
|
+
* Removes liquidity from an existing position to the user pda.
|
|
165
|
+
*
|
|
166
|
+
* This method communicates with the DLMM (Dynamic Liquidity Market Maker) to remove liquidity
|
|
167
|
+
* from a specified trading position. It filters the transaction instructions to include only those
|
|
168
|
+
* relevant to the Meteora DLMM program.
|
|
169
|
+
*
|
|
170
|
+
* @param {web3.PublicKey} userWallet - The public key of the user's wallet executing the transaction.
|
|
171
|
+
* @param {web3.PublicKey} payer - The public key of the transaction payer.
|
|
172
|
+
* @param {Object} params - The parameters for removing liquidity from the position.
|
|
173
|
+
* @param {web3.PublicKey} params.user - The public key of the user executing the transaction.
|
|
174
|
+
* @param {web3.PublicKey} params.position - The public key of the position from which liquidity is being removed.
|
|
175
|
+
* @param {number[]} params.binIds - An array of bin IDs indicating which bins to remove liquidity from.
|
|
176
|
+
* @param {BN} params.bps - The basis points (in BN) indicating the proportion of liquidity to remove.
|
|
177
|
+
* @param {boolean} [params.shouldClaimAndClose] - Optional flag to indicate whether the position should be claimed and closed after removing liquidity.
|
|
178
|
+
*
|
|
179
|
+
* @returns {Promise<web3.TransactionInstruction[]>} - A promise that resolves to an array of transaction instructions relevant to the Meteora DLMM program.
|
|
180
|
+
*/
|
|
181
|
+
removeLiquidityPda(userWallet: web3.PublicKey, payer: web3.PublicKey, params: {
|
|
182
|
+
user: web3.PublicKey;
|
|
183
|
+
position: web3.PublicKey;
|
|
184
|
+
binIds: number[];
|
|
185
|
+
bps: BN;
|
|
186
|
+
shouldClaimAndClose?: boolean;
|
|
187
|
+
}, meteoraToHawksight: MeteoraToHawksightFn): Promise<RemoveLiquidityPdaBuilder>;
|
|
129
188
|
/**
|
|
130
189
|
* Claims all rewards for a specified position.
|
|
131
190
|
*
|
|
@@ -376,6 +435,45 @@ export declare class RemoveLiquidityBuilder {
|
|
|
376
435
|
*/
|
|
377
436
|
replaceClaimRewardToATA(): void;
|
|
378
437
|
}
|
|
438
|
+
/**
|
|
439
|
+
* A builder class for constructing transaction instructions to remove liquidity from a position to the pda.
|
|
440
|
+
*
|
|
441
|
+
* This class provides a structured way to build the necessary transaction instructions for removing liquidity
|
|
442
|
+
* from a position, handling operations such as creating associated token accounts (ATAs), claiming rewards,
|
|
443
|
+
* withdrawing tokens, and managing wrapped SOL (wSOL) accounts.
|
|
444
|
+
*/
|
|
445
|
+
export declare class RemoveLiquidityPdaBuilder {
|
|
446
|
+
readonly createAtaIxs: web3.TransactionInstruction[];
|
|
447
|
+
readonly mainIxs: web3.TransactionInstruction[];
|
|
448
|
+
/**
|
|
449
|
+
* Constructs an instance of the RemoveLiquidityBuilder class.
|
|
450
|
+
*
|
|
451
|
+
* @param {web3.TransactionInstruction[]} createAtaIxs - Instructions to create associated token accounts (ATAs) prior to withdrawal.
|
|
452
|
+
* @param {web3.TransactionInstruction[]} mainIxs - Main instructions for claiming fees/rewards, removing liquidity, and possibly closing the position.
|
|
453
|
+
* @param {web3.TransactionInstruction[]} unwrapWsolIxs - Instructions to close wSOL accounts, if any.
|
|
454
|
+
*/
|
|
455
|
+
constructor(createAtaIxs: web3.TransactionInstruction[], mainIxs: web3.TransactionInstruction[]);
|
|
456
|
+
/**
|
|
457
|
+
* Builds the default sequence of transaction instructions for removing liquidity from a position.
|
|
458
|
+
*
|
|
459
|
+
* This method returns an array of transaction instructions that includes:
|
|
460
|
+
* - Initializing associated token accounts (ATAs) prior to withdrawal
|
|
461
|
+
* - Claiming fees and/or rewards, removing liquidity, and possibly closing the position
|
|
462
|
+
* - Withdrawing tokens to the user wallet
|
|
463
|
+
* - Closing wSOL accounts, if any
|
|
464
|
+
*
|
|
465
|
+
* @returns {web3.TransactionInstruction[]} - An array of transaction instructions in the required order.
|
|
466
|
+
*/
|
|
467
|
+
default(): web3.TransactionInstruction[];
|
|
468
|
+
/**
|
|
469
|
+
* Replaces claim fee token ixs into storage token account
|
|
470
|
+
*/
|
|
471
|
+
replaceClaimFeeTokenToSTA(): void;
|
|
472
|
+
/**
|
|
473
|
+
* Replaces reward token into storage token account
|
|
474
|
+
*/
|
|
475
|
+
replaceClaimRewardToSTA(): void;
|
|
476
|
+
}
|
|
379
477
|
/**
|
|
380
478
|
* A builder class for constructing transaction instructions to remove liquidity from a position.
|
|
381
479
|
*
|
|
@@ -412,4 +510,36 @@ export declare class InitializePositionAndAddLiquidityByStrategyBuilder {
|
|
|
412
510
|
*/
|
|
413
511
|
default(): web3.TransactionInstruction[];
|
|
414
512
|
}
|
|
513
|
+
/**
|
|
514
|
+
* A builder class for constructing transaction instructions to remove liquidity from a position.
|
|
515
|
+
*
|
|
516
|
+
* This class provides a structured way to build the necessary transaction instructions for removing liquidity
|
|
517
|
+
* from a position, handling operations such as creating associated token accounts (ATAs), claiming rewards,
|
|
518
|
+
* withdrawing tokens, and managing wrapped SOL (wSOL) accounts.
|
|
519
|
+
*/
|
|
520
|
+
export declare class InitializePositionAndAddLiquidityByStrategyPdaBuilder {
|
|
521
|
+
readonly mainIxs: web3.TransactionInstruction[];
|
|
522
|
+
/**
|
|
523
|
+
* Constructs an instance of the InitializePositionAndAddLiquidityByStrategyBuilder class.
|
|
524
|
+
*
|
|
525
|
+
* @param {web3.TransactionInstruction[]} wrapSolIxs - Instructions to wrap SOL to wSOL if needed.
|
|
526
|
+
* @param {web3.TransactionInstruction} depositToPdaIxs - Instruction to deposit X and Y tokens to the UserPDA.
|
|
527
|
+
* @param {web3.TransactionInstruction[]} mainIxs - Main instructions for adding liquidity by strategy.
|
|
528
|
+
* @param {web3.TransactionInstruction} refundDustIxs - Instruction to refund dust tokens to the user wallet.
|
|
529
|
+
* @param {web3.TransactionInstruction[]} unwrapWsolIxs - Instructions to unwrap wSOL to SOL if any.
|
|
530
|
+
*/
|
|
531
|
+
constructor(mainIxs: web3.TransactionInstruction[]);
|
|
532
|
+
/**
|
|
533
|
+
* Builds the default sequence of transaction instructions for removing liquidity from a position.
|
|
534
|
+
*
|
|
535
|
+
* This method returns an array of transaction instructions that includes:
|
|
536
|
+
* - Initializing associated token accounts (ATAs) prior to withdrawal
|
|
537
|
+
* - Claiming fees and/or rewards, removing liquidity, and possibly closing the position
|
|
538
|
+
* - Withdrawing tokens to the user wallet
|
|
539
|
+
* - Closing wSOL accounts, if any
|
|
540
|
+
*
|
|
541
|
+
* @returns {web3.TransactionInstruction[]} - An array of transaction instructions in the required order.
|
|
542
|
+
*/
|
|
543
|
+
default(): web3.TransactionInstruction[];
|
|
544
|
+
}
|
|
415
545
|
//# sourceMappingURL=meteora.d.ts.map
|
|
@@ -1 +1 @@
|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AACH,qBAAa,qDAAqD;IAY9D,QAAQ,CAAC,OAAO,EAAE,IAAI,CAAC,sBAAsB,EAAE;IAVjD;;;;;;;;OAQG;gBAEQ,OAAO,EAAE,IAAI,CAAC,sBAAsB,EAAE;IAGjD;;;;;;;;;;OAUG;IACH,OAAO,IAAI,IAAI,CAAC,sBAAsB,EAAE;CAkBzC"}
|
package/dist/src/meteora.js
CHANGED
|
@@ -35,7 +35,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
35
35
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
36
36
|
};
|
|
37
37
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
38
|
-
exports.InitializePositionAndAddLiquidityByStrategyBuilder = exports.RemoveLiquidityBuilder = exports.AddLiquidityByStrategyBuilder = exports.ClaimAllRewardsByPositionBuilder = exports.MeteoraFunctions = exports.MeteoraDLMM = void 0;
|
|
38
|
+
exports.InitializePositionAndAddLiquidityByStrategyPdaBuilder = exports.InitializePositionAndAddLiquidityByStrategyBuilder = exports.RemoveLiquidityPdaBuilder = exports.RemoveLiquidityBuilder = exports.AddLiquidityByStrategyBuilder = exports.ClaimAllRewardsByPositionBuilder = exports.MeteoraFunctions = exports.MeteoraDLMM = void 0;
|
|
39
39
|
const dlmm_1 = __importStar(require("@meteora-ag/dlmm"));
|
|
40
40
|
const bn_js_1 = __importDefault(require("bn.js"));
|
|
41
41
|
const web3 = __importStar(require("@solana/web3.js"));
|
|
@@ -188,6 +188,76 @@ class MeteoraDLMM {
|
|
|
188
188
|
(0, functions_1.unwrapSolIfMintIsWsol)(userWallet, mints));
|
|
189
189
|
});
|
|
190
190
|
}
|
|
191
|
+
/**
|
|
192
|
+
* Initializes a position and adds liquidity to the specified strategy, with various steps including
|
|
193
|
+
* handling wrapped SOL tokens, depositing tokens, adding liquidity, and handling dust withdrawals.
|
|
194
|
+
*
|
|
195
|
+
* @param {web3.PublicKey} userWallet - The public key of the user's wallet executing the transaction.
|
|
196
|
+
* @param {web3.PublicKey} payer - The public key of the transaction payer.
|
|
197
|
+
* @param {Object} params - The parameters for initializing the position and adding liquidity.
|
|
198
|
+
* @param {web3.PublicKey} params.positionPubKey - The public key of the position to be initialized.
|
|
199
|
+
* @param {BN} params.totalXAmount - The total amount of X tokens to be used for liquidity.
|
|
200
|
+
* @param {BN} params.totalYAmount - The total amount of Y tokens to be used for liquidity.
|
|
201
|
+
* @param {Object} params.strategy - The strategy details for adding liquidity.
|
|
202
|
+
* @param {number} params.strategy.maxBinId - The maximum bin ID for the strategy.
|
|
203
|
+
* @param {number} params.strategy.minBinId - The minimum bin ID for the strategy.
|
|
204
|
+
* @param {StrategyType} params.strategy.strategyType - The type of strategy to be applied.
|
|
205
|
+
* @param {web3.PublicKey} params.user - The public key of the user executing the transaction.
|
|
206
|
+
* @param {number} [params.slippage] - Optional slippage tolerance for the transaction.
|
|
207
|
+
*
|
|
208
|
+
* @returns {Promise<web3.TransactionInstruction[]>} - A promise that resolves to an array of transaction instructions.
|
|
209
|
+
*
|
|
210
|
+
* @throws {Error} - Throws an error if input token(s) do not exist on the blockchain.
|
|
211
|
+
*/
|
|
212
|
+
initializePositionAndAddLiquidityByStrategyPda(userWallet, payer, params, meteoraToHawksight) {
|
|
213
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
214
|
+
if (!!!params.skipInputTokenCheck) {
|
|
215
|
+
// Throw error if input token(s) do not exist on blockchain
|
|
216
|
+
yield (0, functions_1.inputTokenExists)(anchor_1.Anchor.instance().connection, userWallet, [
|
|
217
|
+
this.dlmm.tokenX.publicKey,
|
|
218
|
+
this.dlmm.tokenY.publicKey,
|
|
219
|
+
]);
|
|
220
|
+
}
|
|
221
|
+
// Generate InitializePosition and AddLiquidityByStrategy instruction from Meteora API
|
|
222
|
+
const txn = yield this.dlmm.initializePositionAndAddLiquidityByStrategy(params);
|
|
223
|
+
// Filter out non-meteora instructions
|
|
224
|
+
const ixs = (0, functions_1.getIxs)(txn).filter((ix) => ix.programId.equals(addresses_1.METEORA_DLMM_PROGRAM));
|
|
225
|
+
// Find mint from meteora instructions
|
|
226
|
+
const mints = (0, functions_1.getMintsFromInstruction)({
|
|
227
|
+
instructions: ixs,
|
|
228
|
+
find: {
|
|
229
|
+
AddLiquidityByStrategy: {
|
|
230
|
+
programId: addresses_1.METEORA_DLMM_PROGRAM.toBase58(),
|
|
231
|
+
mintIndices: [7, 8],
|
|
232
|
+
},
|
|
233
|
+
AddLiquidityByStrategyOneSide: {
|
|
234
|
+
programId: addresses_1.METEORA_DLMM_PROGRAM.toBase58(),
|
|
235
|
+
mintIndices: [5],
|
|
236
|
+
},
|
|
237
|
+
},
|
|
238
|
+
});
|
|
239
|
+
return new InitializePositionAndAddLiquidityByStrategyPdaBuilder(
|
|
240
|
+
// // Step 1: Init wSOL token account for user wallet (if X or Y token is wSOL)
|
|
241
|
+
// wrapSolIfMintIsWsol(userWallet, payer, [
|
|
242
|
+
// { mint: this.dlmm.tokenX.publicKey, amount: params.totalXAmount },
|
|
243
|
+
// { mint: this.dlmm.tokenY.publicKey, amount: params.totalYAmount },
|
|
244
|
+
// ]),
|
|
245
|
+
// // Step 2: Deposit X and Y token to UserPDA
|
|
246
|
+
// await depositMultipleToken({
|
|
247
|
+
// payer: userWallet,
|
|
248
|
+
// deposit: [
|
|
249
|
+
// { mint: this.dlmm.tokenX.publicKey, amount: params.totalXAmount },
|
|
250
|
+
// { mint: this.dlmm.tokenY.publicKey, amount: params.totalYAmount },
|
|
251
|
+
// ],
|
|
252
|
+
// }),
|
|
253
|
+
// Step 3: Initialize position and add liquidity by strategy
|
|
254
|
+
yield meteoraToHawksight({
|
|
255
|
+
ixs,
|
|
256
|
+
userPda: params.user,
|
|
257
|
+
authority: userWallet,
|
|
258
|
+
}));
|
|
259
|
+
});
|
|
260
|
+
}
|
|
191
261
|
/**
|
|
192
262
|
* Adds liquidity to an existing position according to a specified strategy.
|
|
193
263
|
*
|
|
@@ -339,6 +409,67 @@ class MeteoraDLMM {
|
|
|
339
409
|
(0, functions_1.unwrapSolIfMintIsWsol)(userWallet, mints));
|
|
340
410
|
});
|
|
341
411
|
}
|
|
412
|
+
/**
|
|
413
|
+
* Removes liquidity from an existing position to the user pda.
|
|
414
|
+
*
|
|
415
|
+
* This method communicates with the DLMM (Dynamic Liquidity Market Maker) to remove liquidity
|
|
416
|
+
* from a specified trading position. It filters the transaction instructions to include only those
|
|
417
|
+
* relevant to the Meteora DLMM program.
|
|
418
|
+
*
|
|
419
|
+
* @param {web3.PublicKey} userWallet - The public key of the user's wallet executing the transaction.
|
|
420
|
+
* @param {web3.PublicKey} payer - The public key of the transaction payer.
|
|
421
|
+
* @param {Object} params - The parameters for removing liquidity from the position.
|
|
422
|
+
* @param {web3.PublicKey} params.user - The public key of the user executing the transaction.
|
|
423
|
+
* @param {web3.PublicKey} params.position - The public key of the position from which liquidity is being removed.
|
|
424
|
+
* @param {number[]} params.binIds - An array of bin IDs indicating which bins to remove liquidity from.
|
|
425
|
+
* @param {BN} params.bps - The basis points (in BN) indicating the proportion of liquidity to remove.
|
|
426
|
+
* @param {boolean} [params.shouldClaimAndClose] - Optional flag to indicate whether the position should be claimed and closed after removing liquidity.
|
|
427
|
+
*
|
|
428
|
+
* @returns {Promise<web3.TransactionInstruction[]>} - A promise that resolves to an array of transaction instructions relevant to the Meteora DLMM program.
|
|
429
|
+
*/
|
|
430
|
+
removeLiquidityPda(userWallet, payer, params, meteoraToHawksight) {
|
|
431
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
432
|
+
// Claim fees and/or rewards, remove liquidity, and possibly close position from Meteora API (if set)
|
|
433
|
+
const txn = yield this.dlmm.removeLiquidity(params);
|
|
434
|
+
// Filter out non-meteora instructions
|
|
435
|
+
const ixs = (0, functions_1.getIxs)(txn).filter((ix) => ix.programId.equals(addresses_1.METEORA_DLMM_PROGRAM));
|
|
436
|
+
// Find mint from meteora instructions
|
|
437
|
+
const mints = (0, functions_1.getMintsFromInstruction)({
|
|
438
|
+
instructions: ixs,
|
|
439
|
+
find: {
|
|
440
|
+
RemoveLiquidity: {
|
|
441
|
+
programId: addresses_1.METEORA_DLMM_PROGRAM.toBase58(),
|
|
442
|
+
mintIndices: [7, 8],
|
|
443
|
+
},
|
|
444
|
+
RemoveLiquidityByRange: {
|
|
445
|
+
programId: addresses_1.METEORA_DLMM_PROGRAM.toBase58(),
|
|
446
|
+
mintIndices: [7, 8],
|
|
447
|
+
},
|
|
448
|
+
ClaimFee: {
|
|
449
|
+
programId: addresses_1.METEORA_DLMM_PROGRAM.toBase58(),
|
|
450
|
+
mintIndices: [9, 10],
|
|
451
|
+
},
|
|
452
|
+
ClaimReward: {
|
|
453
|
+
programId: addresses_1.METEORA_DLMM_PROGRAM.toBase58(),
|
|
454
|
+
mintIndices: [6],
|
|
455
|
+
},
|
|
456
|
+
},
|
|
457
|
+
});
|
|
458
|
+
return new RemoveLiquidityPdaBuilder(
|
|
459
|
+
// Step 1: Init ATA prior to withdrawal
|
|
460
|
+
(0, functions_1.createAtaIdempotentIxs)({
|
|
461
|
+
accounts: mints.map((mint) => {
|
|
462
|
+
return { owner: params.user, payer, mint };
|
|
463
|
+
}),
|
|
464
|
+
}),
|
|
465
|
+
// Step 2: Claim fees and/or rewards, remove liquidity, and possibly close position (if set)
|
|
466
|
+
yield meteoraToHawksight({
|
|
467
|
+
ixs,
|
|
468
|
+
userPda: params.user,
|
|
469
|
+
authority: userWallet,
|
|
470
|
+
}));
|
|
471
|
+
});
|
|
472
|
+
}
|
|
342
473
|
/**
|
|
343
474
|
* Claims all rewards for a specified position.
|
|
344
475
|
*
|
|
@@ -1058,6 +1189,87 @@ class RemoveLiquidityBuilder {
|
|
|
1058
1189
|
}
|
|
1059
1190
|
}
|
|
1060
1191
|
exports.RemoveLiquidityBuilder = RemoveLiquidityBuilder;
|
|
1192
|
+
/**
|
|
1193
|
+
* A builder class for constructing transaction instructions to remove liquidity from a position to the pda.
|
|
1194
|
+
*
|
|
1195
|
+
* This class provides a structured way to build the necessary transaction instructions for removing liquidity
|
|
1196
|
+
* from a position, handling operations such as creating associated token accounts (ATAs), claiming rewards,
|
|
1197
|
+
* withdrawing tokens, and managing wrapped SOL (wSOL) accounts.
|
|
1198
|
+
*/
|
|
1199
|
+
class RemoveLiquidityPdaBuilder {
|
|
1200
|
+
/**
|
|
1201
|
+
* Constructs an instance of the RemoveLiquidityBuilder class.
|
|
1202
|
+
*
|
|
1203
|
+
* @param {web3.TransactionInstruction[]} createAtaIxs - Instructions to create associated token accounts (ATAs) prior to withdrawal.
|
|
1204
|
+
* @param {web3.TransactionInstruction[]} mainIxs - Main instructions for claiming fees/rewards, removing liquidity, and possibly closing the position.
|
|
1205
|
+
* @param {web3.TransactionInstruction[]} unwrapWsolIxs - Instructions to close wSOL accounts, if any.
|
|
1206
|
+
*/
|
|
1207
|
+
constructor(createAtaIxs, mainIxs) {
|
|
1208
|
+
this.createAtaIxs = createAtaIxs;
|
|
1209
|
+
this.mainIxs = mainIxs;
|
|
1210
|
+
}
|
|
1211
|
+
/**
|
|
1212
|
+
* Builds the default sequence of transaction instructions for removing liquidity from a position.
|
|
1213
|
+
*
|
|
1214
|
+
* This method returns an array of transaction instructions that includes:
|
|
1215
|
+
* - Initializing associated token accounts (ATAs) prior to withdrawal
|
|
1216
|
+
* - Claiming fees and/or rewards, removing liquidity, and possibly closing the position
|
|
1217
|
+
* - Withdrawing tokens to the user wallet
|
|
1218
|
+
* - Closing wSOL accounts, if any
|
|
1219
|
+
*
|
|
1220
|
+
* @returns {web3.TransactionInstruction[]} - An array of transaction instructions in the required order.
|
|
1221
|
+
*/
|
|
1222
|
+
default() {
|
|
1223
|
+
return [
|
|
1224
|
+
// Step 1: Init ATA prior to withdrawal
|
|
1225
|
+
...this.createAtaIxs,
|
|
1226
|
+
// Step 2: Claim fees and/or rewards, remove liquidity, and possibly close position (if set)
|
|
1227
|
+
...this.mainIxs,
|
|
1228
|
+
// // Step 3: Withdraw tokens to user wallet
|
|
1229
|
+
// this.withdrawMultipleTokenIx,
|
|
1230
|
+
// // Step 4: Close wSOL account (if there's any)
|
|
1231
|
+
// ...this.unwrapWsolIxs,
|
|
1232
|
+
];
|
|
1233
|
+
}
|
|
1234
|
+
/**
|
|
1235
|
+
* Replaces claim fee token ixs into storage token account
|
|
1236
|
+
*/
|
|
1237
|
+
replaceClaimFeeTokenToSTA() {
|
|
1238
|
+
const index = this.mainIxs.findIndex(mainIx => {
|
|
1239
|
+
const dataWithoutIyfExtensionExecute = mainIx.data.subarray(12);
|
|
1240
|
+
return (0, functions_1.sighashMatch)(dataWithoutIyfExtensionExecute, "MeteoraDlmmClaimFeeAutomation");
|
|
1241
|
+
});
|
|
1242
|
+
if (index === -1) {
|
|
1243
|
+
console.warn(`Warn: claim fee instruction not found! This should not happen if \`shouldClaimAndClose\` is set to true.`);
|
|
1244
|
+
return;
|
|
1245
|
+
}
|
|
1246
|
+
const userPda = this.mainIxs[index].keys[1].pubkey;
|
|
1247
|
+
const tokenXMint = this.mainIxs[index].keys[14].pubkey;
|
|
1248
|
+
const tokenYMint = this.mainIxs[index].keys[15].pubkey;
|
|
1249
|
+
const staTokenX = (0, functions_1.generateUserPdaStorageAccount)(userPda, tokenXMint);
|
|
1250
|
+
const staTokenY = (0, functions_1.generateUserPdaStorageAccount)(userPda, tokenYMint);
|
|
1251
|
+
this.mainIxs[index].keys[12].pubkey = staTokenX;
|
|
1252
|
+
this.mainIxs[index].keys[13].pubkey = staTokenY;
|
|
1253
|
+
}
|
|
1254
|
+
/**
|
|
1255
|
+
* Replaces reward token into storage token account
|
|
1256
|
+
*/
|
|
1257
|
+
replaceClaimRewardToSTA() {
|
|
1258
|
+
const index = this.mainIxs.findIndex(mainIx => {
|
|
1259
|
+
const dataWithoutIyfExtensionExecute = mainIx.data.subarray(12);
|
|
1260
|
+
return (0, functions_1.sighashMatch)(dataWithoutIyfExtensionExecute, "MeteoraDlmmClaimRewardAutomation");
|
|
1261
|
+
});
|
|
1262
|
+
if (index === -1) {
|
|
1263
|
+
console.warn(`Warn: Reward instruction not found! This may happen if pool has no rewards`);
|
|
1264
|
+
return;
|
|
1265
|
+
}
|
|
1266
|
+
const userPda = this.mainIxs[index].keys[1].pubkey;
|
|
1267
|
+
const tokenMint = this.mainIxs[index].keys[10].pubkey;
|
|
1268
|
+
const staToken = (0, functions_1.generateUserPdaStorageAccount)(userPda, tokenMint);
|
|
1269
|
+
this.mainIxs[index].keys[11].pubkey = staToken;
|
|
1270
|
+
}
|
|
1271
|
+
}
|
|
1272
|
+
exports.RemoveLiquidityPdaBuilder = RemoveLiquidityPdaBuilder;
|
|
1061
1273
|
/**
|
|
1062
1274
|
* A builder class for constructing transaction instructions to remove liquidity from a position.
|
|
1063
1275
|
*
|
|
@@ -1109,3 +1321,50 @@ class InitializePositionAndAddLiquidityByStrategyBuilder {
|
|
|
1109
1321
|
}
|
|
1110
1322
|
}
|
|
1111
1323
|
exports.InitializePositionAndAddLiquidityByStrategyBuilder = InitializePositionAndAddLiquidityByStrategyBuilder;
|
|
1324
|
+
/**
|
|
1325
|
+
* A builder class for constructing transaction instructions to remove liquidity from a position.
|
|
1326
|
+
*
|
|
1327
|
+
* This class provides a structured way to build the necessary transaction instructions for removing liquidity
|
|
1328
|
+
* from a position, handling operations such as creating associated token accounts (ATAs), claiming rewards,
|
|
1329
|
+
* withdrawing tokens, and managing wrapped SOL (wSOL) accounts.
|
|
1330
|
+
*/
|
|
1331
|
+
class InitializePositionAndAddLiquidityByStrategyPdaBuilder {
|
|
1332
|
+
/**
|
|
1333
|
+
* Constructs an instance of the InitializePositionAndAddLiquidityByStrategyBuilder class.
|
|
1334
|
+
*
|
|
1335
|
+
* @param {web3.TransactionInstruction[]} wrapSolIxs - Instructions to wrap SOL to wSOL if needed.
|
|
1336
|
+
* @param {web3.TransactionInstruction} depositToPdaIxs - Instruction to deposit X and Y tokens to the UserPDA.
|
|
1337
|
+
* @param {web3.TransactionInstruction[]} mainIxs - Main instructions for adding liquidity by strategy.
|
|
1338
|
+
* @param {web3.TransactionInstruction} refundDustIxs - Instruction to refund dust tokens to the user wallet.
|
|
1339
|
+
* @param {web3.TransactionInstruction[]} unwrapWsolIxs - Instructions to unwrap wSOL to SOL if any.
|
|
1340
|
+
*/
|
|
1341
|
+
constructor(mainIxs) {
|
|
1342
|
+
this.mainIxs = mainIxs;
|
|
1343
|
+
}
|
|
1344
|
+
/**
|
|
1345
|
+
* Builds the default sequence of transaction instructions for removing liquidity from a position.
|
|
1346
|
+
*
|
|
1347
|
+
* This method returns an array of transaction instructions that includes:
|
|
1348
|
+
* - Initializing associated token accounts (ATAs) prior to withdrawal
|
|
1349
|
+
* - Claiming fees and/or rewards, removing liquidity, and possibly closing the position
|
|
1350
|
+
* - Withdrawing tokens to the user wallet
|
|
1351
|
+
* - Closing wSOL accounts, if any
|
|
1352
|
+
*
|
|
1353
|
+
* @returns {web3.TransactionInstruction[]} - An array of transaction instructions in the required order.
|
|
1354
|
+
*/
|
|
1355
|
+
default() {
|
|
1356
|
+
return [
|
|
1357
|
+
// // Step 1: Init wSOL token account for user wallet (if X or Y token is wSOL)
|
|
1358
|
+
// ...this.wrapSolIxs,
|
|
1359
|
+
// // Step 2: Deposit X and Y token to UserPDA
|
|
1360
|
+
// this.depositToPdaIxs,
|
|
1361
|
+
// Step 3: Add liquidity by strategy
|
|
1362
|
+
...this.mainIxs,
|
|
1363
|
+
// // Step 4: Refund dust to user wallet
|
|
1364
|
+
// this.refundDustIxs,
|
|
1365
|
+
// // Step 5: Close wSOL account (if there's any)
|
|
1366
|
+
// ...this.unwrapWsolIxs,
|
|
1367
|
+
];
|
|
1368
|
+
}
|
|
1369
|
+
}
|
|
1370
|
+
exports.InitializePositionAndAddLiquidityByStrategyPdaBuilder = InitializePositionAndAddLiquidityByStrategyPdaBuilder;
|