@hawksightco/hawk-sdk 1.1.28 → 1.1.30
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/src/addresses.d.ts +1 -0
- package/dist/src/addresses.d.ts.map +1 -1
- package/dist/src/addresses.js +2 -1
- package/dist/src/classes/Transactions.d.ts.map +1 -1
- package/dist/src/classes/Transactions.js +7 -7
- package/dist/src/classes/TxGenerator.d.ts.map +1 -1
- package/dist/src/classes/TxGenerator.js +2 -0
- package/dist/src/functions.d.ts +17 -1
- package/dist/src/functions.d.ts.map +1 -1
- package/dist/src/functions.js +47 -1
- package/dist/src/index.d.ts +1 -0
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +1 -0
- package/dist/src/meteora.d.ts +53 -0
- package/dist/src/meteora.d.ts.map +1 -1
- package/dist/src/meteora.js +207 -1
- package/package.json +1 -1
package/dist/src/addresses.d.ts
CHANGED
|
@@ -11,6 +11,7 @@ export declare const SITE_FEE_OWNER: web3.PublicKey;
|
|
|
11
11
|
export declare const USDC_FARM: web3.PublicKey;
|
|
12
12
|
export declare const SOME_METEORA_DLMM_POOL: web3.PublicKey;
|
|
13
13
|
export declare const METEORA_DLMM_PROGRAM: web3.PublicKey;
|
|
14
|
+
export declare const METEORA_EVENT_AUTHORITY: web3.PublicKey;
|
|
14
15
|
export declare const COMPUTE_BUDGET: web3.PublicKey;
|
|
15
16
|
export declare const HS_AUTHORITY: web3.PublicKey;
|
|
16
17
|
export declare const ORCA_WHIRLPOOL_PROGRAM: web3.PublicKey;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"addresses.d.ts","sourceRoot":"","sources":["../../src/addresses.ts"],"names":[],"mappings":";AAAA,OAAO,KAAK,IAAI,MAAM,iBAAiB,CAAC;AAExC,eAAO,MAAM,UAAU,UAYtB,CAAC;AAEF,eAAO,MAAM,QAAQ,gBAAqE,CAAC;AAC3F,eAAO,MAAM,aAAa,gBAAqE,C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sB,gBAAoE,CAAC;AACxG,eAAO,MAAM,SAAS,gBAAoE,CAAC;AAC3F,eAAO,MAAM,eAAe,gBAAoE,CAAC"}
|
package/dist/src/addresses.js
CHANGED
|
@@ -23,7 +23,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
23
23
|
return result;
|
|
24
24
|
};
|
|
25
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
exports.JUPITER_PROGRAM = exports.WSOL_MINT = exports.ORCA_WHIRLPOOL_PROGRAM = exports.HS_AUTHORITY = exports.COMPUTE_BUDGET = exports.METEORA_DLMM_PROGRAM = exports.SOME_METEORA_DLMM_POOL = exports.USDC_FARM = exports.SITE_FEE_OWNER = exports.ASSOCIATED_TOKEN_PROGRAM = exports.TOKEN_PROGRAM_ID = exports.STABLEMINT_2 = exports.STABLEMINT_1 = exports.IYF_EXTENSION = exports.IYF_MAIN = exports.GLOBAL_ALT = void 0;
|
|
26
|
+
exports.JUPITER_PROGRAM = exports.WSOL_MINT = exports.ORCA_WHIRLPOOL_PROGRAM = exports.HS_AUTHORITY = exports.COMPUTE_BUDGET = exports.METEORA_EVENT_AUTHORITY = exports.METEORA_DLMM_PROGRAM = exports.SOME_METEORA_DLMM_POOL = exports.USDC_FARM = exports.SITE_FEE_OWNER = exports.ASSOCIATED_TOKEN_PROGRAM = exports.TOKEN_PROGRAM_ID = exports.STABLEMINT_2 = exports.STABLEMINT_1 = exports.IYF_EXTENSION = exports.IYF_MAIN = exports.GLOBAL_ALT = void 0;
|
|
27
27
|
const web3 = __importStar(require("@solana/web3.js"));
|
|
28
28
|
exports.GLOBAL_ALT = [
|
|
29
29
|
"AC3t5k5PUTJirxGEHgGGQStafu1vXkvddPyqVNDrRQDt",
|
|
@@ -48,6 +48,7 @@ exports.SITE_FEE_OWNER = new web3.PublicKey("4K3a2ucXiGvuMJMPNneRDyzmNp6i4RdzXJm
|
|
|
48
48
|
exports.USDC_FARM = new web3.PublicKey("7jLQhREMxXjKdpwVuN6gwsWt3BNfAg9WqbepffPbi4ww");
|
|
49
49
|
exports.SOME_METEORA_DLMM_POOL = new web3.PublicKey("7eexH14UjhNxJe6zTT3f1Vb1E8iACsBMVaWheDEmxdT2");
|
|
50
50
|
exports.METEORA_DLMM_PROGRAM = new web3.PublicKey("LBUZKhRxPF3XUpBCjp4YzTKgLccjZhTSDM9YuVaPwxo");
|
|
51
|
+
exports.METEORA_EVENT_AUTHORITY = new web3.PublicKey("D1ZN9Wj1fRSUQfCjhvnu1hqDMT7hzjzBBpi12nVniYD6");
|
|
51
52
|
exports.COMPUTE_BUDGET = new web3.PublicKey("ComputeBudget111111111111111111111111111111");
|
|
52
53
|
exports.HS_AUTHORITY = new web3.PublicKey("dche7M2764e8AxNihBdn7uffVzZvTBNeL8x4LZg5E2c");
|
|
53
54
|
exports.ORCA_WHIRLPOOL_PROGRAM = new web3.PublicKey("whirLbMiicVdio4qvUfM5KAg6Ct8VwpYzGff3uctyCc");
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Transactions.d.ts","sourceRoot":"","sources":["../../../src/classes/Transactions.ts"],"names":[],"mappings":";AACA,OAAO,KAAK,IAAI,MAAM,iBAAiB,CAAC;
|
|
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,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,EAC5B,MAAM,UAAU,CAAC;AA2BlB,qBAAa,YAAY;IACvB;;;;;;OAMG;IACH,eAAe,CACb,UAAU,EAAE,IAAI,CAAC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AC,6BAA6B,CAAC,GAAG,OAAO,CACrD,2BAA2B,GAAG,EAAE,CACjC;IAgEK,sBAAsB,CAAC,EAC3B,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;IAkDrH;;;;;;;OAOG;IACG,WAAW,CAAC,EAAE,UAAU,EAAE,MAAM,EAAE,EAAE,WAAW,CAAC,WAAW,CAAC,GAAG,OAAO,CAAC,2BAA2B,CAAC;IAuHzG;;;;;;;OAOG;IACG,YAAY,CAAC,EAAE,UAAU,EAAE,MAAM,EAAE,EAAE,WAAW,CAAC,YAAY,CAAC,GAAG,OAAO,CAAC,2BAA2B,CAAC;IAyF3G;;;;;;;OAOG;IACG,gBAAgB,CAAC,EAAE,UAAU,EAAE,MAAM,EAAE,EAAE,WAAW,CAAC,gBAAgB,CAAC,GAAG,OAAO,CAAC,2BAA2B,CAAC;CAqGpH;AAED,eAAO,MAAM,KAAK,cAAqB,CAAC"}
|
|
@@ -287,29 +287,29 @@ class Transactions {
|
|
|
287
287
|
*/
|
|
288
288
|
meteoraClaim(_a) {
|
|
289
289
|
return __awaiter(this, arguments, void 0, function* ({ connection, params, }) {
|
|
290
|
-
const program = yield meteora_1.MeteoraDLMM.program(connection);
|
|
291
290
|
let lbPair;
|
|
292
291
|
if (params.fastGeneration !== undefined) {
|
|
293
292
|
lbPair = params.fastGeneration.pool;
|
|
294
293
|
}
|
|
295
294
|
else {
|
|
295
|
+
const program = yield meteora_1.MeteoraDLMM.program(connection);
|
|
296
296
|
const position = yield program.account.positionV2.fetch(params.position);
|
|
297
297
|
lbPair = position.lbPair;
|
|
298
298
|
}
|
|
299
|
-
const dlmmPool = yield meteora_1.MeteoraDLMM.create(connection, lbPair);
|
|
300
299
|
const userPda = (0, functions_1.generateUserPda)(params.userWallet);
|
|
301
|
-
const
|
|
302
|
-
const
|
|
303
|
-
const mainInstructions = (yield dlmmPool.claimAllRewardsByPosition(params.userWallet, params.userWallet, {
|
|
300
|
+
const fn = new meteora_1.MeteoraFunctions();
|
|
301
|
+
const mainInstructions = (yield fn.claimAllRewardsByPosition(connection, params.userWallet, params.userWallet, {
|
|
304
302
|
owner: userPda,
|
|
305
|
-
position:
|
|
303
|
+
position: params.position,
|
|
304
|
+
lbPair,
|
|
306
305
|
}, hsToMeteora_1.meteoraToHawksight)).default();
|
|
307
|
-
|
|
306
|
+
const txMeta = (0, functions_1.createTransactionMeta)({
|
|
308
307
|
payer: params.userWallet,
|
|
309
308
|
description: "Claim fees / rewards from Meteora DLMM Position",
|
|
310
309
|
addressLookupTableAddresses: addresses_1.GLOBAL_ALT,
|
|
311
310
|
mainInstructions,
|
|
312
311
|
});
|
|
312
|
+
return txMeta;
|
|
313
313
|
});
|
|
314
314
|
}
|
|
315
315
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TxGenerator.d.ts","sourceRoot":"","sources":["../../../src/classes/TxGenerator.ts"],"names":[],"mappings":";AAAA,OAAO,KAAK,IAAI,MAAM,iBAAiB,CAAC;AACxC,OAAO,KAAK,OAAO,MAAM,6BAA6B,CAAC;AACvD,OAAO,EAAE,kBAAkB,EAAE,mBAAmB,EAAkE,YAAY,EAAE,WAAW,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AACrN,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAElC,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAKlD;;;;GAIG;AACH,qBAA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,EAAE,IAAI,CAAC,UAAU,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,CAAC,yBAAyB,GAAG,OAAO,CAAC,kBAAkB,CAAC,mBAAmB,CAAC,CAAC;IAkC3K;;;;;;;OAOG;IACG,gBAAgB,CAAC,UAAU,EAAE,IAAI,CAAC,UAAU,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,gBAAgB,GAAG,OAAO,CAAC,kBAAkB,CAAC,mBAAmB,CAAC,CAAC;IAmC9I;;;;;;;OAOG;IACG,iBAAiB,CAAC,UAAU,EAAE,IAAI,CAAC,UAAU,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,iBAAiB,GAAG,OAAO,CAAC,kBAAkB,CAAC,mBAAmB,CAAC,CAAC;IAgChJ;;;;;;;OAOG;IACG,WAAW,CAAC,UAAU,EAAE,IAAI,CAAC,UAAU,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,WAAW,GAAG,OAAO,CAAC,kBAAkB,CAAC,mBAAmB,CAAC,CAAC;IAkCpI;;;;;;;OAOG;IACG,YAAY,CAAC,UAAU,EAAE,IAAI,CAAC,UAAU,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,YAAY,GAAG,OAAO,CAAC,kBAAkB,CAAC,mBAAmB,CAAC,CAAC;IAiCtI;;;;;;;OAOG;IACG,gBAAgB,CAAC,UAAU,EAAE,IAAI,CAAC,UAAU,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,gBAAgB,GAAG,OAAO,CAAC,kBAAkB,CAAC,mBAAmB,CAAC,CAAC;CA+B/I"}
|
|
@@ -203,6 +203,7 @@ class TxGenerator {
|
|
|
203
203
|
anchor_1.Anchor.initialize(connection);
|
|
204
204
|
try {
|
|
205
205
|
const startTime = new Date().getTime() / 1000;
|
|
206
|
+
console.log(`meteoraClaim: Benchmarking txgen.meteoraClaim`);
|
|
206
207
|
const result = yield Transactions_1.txgen.meteoraClaim({
|
|
207
208
|
connection,
|
|
208
209
|
params: {
|
|
@@ -215,6 +216,7 @@ class TxGenerator {
|
|
|
215
216
|
: undefined,
|
|
216
217
|
},
|
|
217
218
|
});
|
|
219
|
+
console.log(`meteoraClaim: await txgen.meteoraClaim: ${new Date().getTime() / 1000 - startTime}`);
|
|
218
220
|
return {
|
|
219
221
|
status: 200,
|
|
220
222
|
data: yield (0, functions_1.createTxMetadata)(this.generalUtility, connection, payer, result),
|
package/dist/src/functions.d.ts
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
/// <reference types="@meteora-ag/dlmm/node_modules/@solana/web3.js" />
|
|
3
3
|
import * as client from "@hawksightco/swagger-client";
|
|
4
4
|
import * as web3 from "@solana/web3.js";
|
|
5
|
-
import { MeteoraPoolInfo, ResponseWithStatus, TransactionMetadata, TransactionMetadataResponse, TokenAccountData, CreateAtaIdempotentParams, GetMintsFromInstructionParams } from "./types";
|
|
5
|
+
import { MeteoraPoolInfo, ResponseWithStatus, TransactionMetadata, TransactionMetadataResponse, TokenAccountData, CreateAtaIdempotentParams, GetMintsFromInstructionParams, Instruction } from "./types";
|
|
6
6
|
import { GeneralUtility } from "./classes/GeneralUtility";
|
|
7
7
|
import BN from "bn.js";
|
|
8
8
|
export declare const METEORA_API_URL = "https://dlmm-api.meteora.ag";
|
|
@@ -253,5 +253,21 @@ type JupiterRouteIxParams = {
|
|
|
253
253
|
* @param data
|
|
254
254
|
*/
|
|
255
255
|
export declare function getJupiterRouteIxParams(data: Buffer): JupiterRouteIxParams;
|
|
256
|
+
/**
|
|
257
|
+
* Converts tx metadata to versioned transaction
|
|
258
|
+
*
|
|
259
|
+
* @param txMessage
|
|
260
|
+
*/
|
|
261
|
+
export declare function toVersionedTransaction(connection: web3.Connection, txMessage: TransactionMetadataResponse): Promise<web3.VersionedTransaction>;
|
|
262
|
+
export declare function ixStrToWeb3Ix(ix: Instruction): {
|
|
263
|
+
keys: {
|
|
264
|
+
isSigner: boolean;
|
|
265
|
+
isWritable: boolean;
|
|
266
|
+
pubkey: web3.PublicKey;
|
|
267
|
+
}[];
|
|
268
|
+
data: Buffer;
|
|
269
|
+
programId: web3.PublicKey;
|
|
270
|
+
};
|
|
271
|
+
export declare function stringToAlt(connection: web3.Connection, alts: string[]): Promise<web3.AddressLookupTableAccount[]>;
|
|
256
272
|
export {};
|
|
257
273
|
//# sourceMappingURL=functions.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"functions.d.ts","sourceRoot":"","sources":["../../src/functions.ts"],"names":[],"mappings":";;AAAA,OAAO,KAAK,MAAM,MAAM,6BAA6B,CAAC;AACtD,OAAO,KAAK,IAAI,MAAM,iBAAiB,CAAC;AAExC,OAAO,EACL,eAAe,EACf,kBAAkB,EAClB,mBAAmB,EACnB,2BAA2B,EAC3B,gBAAgB,EAChB,yBAAyB,EACzB,6BAA6B,
|
|
1
|
+
{"version":3,"file":"functions.d.ts","sourceRoot":"","sources":["../../src/functions.ts"],"names":[],"mappings":";;AAAA,OAAO,KAAK,MAAM,MAAM,6BAA6B,CAAC;AACtD,OAAO,KAAK,IAAI,MAAM,iBAAiB,CAAC;AAExC,OAAO,EACL,eAAe,EACf,kBAAkB,EAClB,mBAAmB,EACnB,2BAA2B,EAC3B,gBAAgB,EAChB,yBAAyB,EACzB,6BAA6B,EAC7B,WAAW,EACZ,MAAM,SAAS,CAAC;AACjB,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAM1D,OAAO,EAAE,MAAM,OAAO,CAAC;AAGvB,eAAO,MAAM,eAAe,gCAAgC,CAAC;AAE7D;;;;;;;;;;;;;;GAcG;AACH,wBAAsB,gBAAgB,CACpC,cAAc,EAAE,cAAc,EAC9B,UAAU,EAAE,IAAI,CAAC,UAAU,EAC3B,KAAK,EAAE,MAAM,EACb,IAAI,EAAE,2BAA2B,GAChC,OAAO,CAAC,mBAAmB,CAAC,CAO9B;AAED;;;;;;;GAOG;AACH,wBAAsB,aAAa,CAA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AAU,EAAE,SAAS,EAAE,2BAA2B,sCAU/G;AAED,wBAAgB,aAAa,CAAC,EAAE,EAAE,WAAW;;;;;;;;EAY5C;AAGD,wBAAsB,WAAW,CAC/B,UAAU,EAAE,IAAI,CAAC,UAAU,EAC3B,IAAI,EAAE,MAAM,EAAE,GACb,OAAO,CAAC,IAAI,CAAC,yBAAyB,EAAE,CAAC,CAa3C"}
|
package/dist/src/functions.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.getJupiterRouteIxParams = exports.inputTokenExists = exports.unwrapWsolToSol = exports.unwrapSolIfMintIsWsol = exports.wrapSolToWsol = exports.wrapSolIfMintIsWsol = exports.getMintsFromInstruction = exports.createAtaIdempotentIxs = exports.parseTokenAccountData = exports.tokenAccountExists = exports.sighash = exports.sighashMatch = exports.getIxs = exports.generateUserPdaStorageAccount = exports.generateOrcaPositionPDA = exports.generateAta = exports.generateUserPda = exports.createTransactionMeta = exports.getMeteoraPool = exports.getFeeEstimate = exports.resultOrError = exports.createTxMetadata = exports.METEORA_API_URL = void 0;
|
|
38
|
+
exports.stringToAlt = exports.ixStrToWeb3Ix = exports.toVersionedTransaction = exports.getJupiterRouteIxParams = exports.inputTokenExists = exports.unwrapWsolToSol = exports.unwrapSolIfMintIsWsol = exports.wrapSolToWsol = exports.wrapSolIfMintIsWsol = exports.getMintsFromInstruction = exports.createAtaIdempotentIxs = exports.parseTokenAccountData = exports.tokenAccountExists = exports.sighash = exports.sighashMatch = exports.getIxs = exports.generateUserPdaStorageAccount = exports.generateOrcaPositionPDA = exports.generateAta = exports.generateUserPda = exports.createTransactionMeta = exports.getMeteoraPool = exports.getFeeEstimate = exports.resultOrError = exports.createTxMetadata = exports.METEORA_API_URL = void 0;
|
|
39
39
|
const client = __importStar(require("@hawksightco/swagger-client"));
|
|
40
40
|
const web3 = __importStar(require("@solana/web3.js"));
|
|
41
41
|
const axios_1 = __importDefault(require("axios"));
|
|
@@ -578,3 +578,49 @@ function getJupiterRouteIxParams(data) {
|
|
|
578
578
|
};
|
|
579
579
|
}
|
|
580
580
|
exports.getJupiterRouteIxParams = getJupiterRouteIxParams;
|
|
581
|
+
/**
|
|
582
|
+
* Converts tx metadata to versioned transaction
|
|
583
|
+
*
|
|
584
|
+
* @param txMessage
|
|
585
|
+
*/
|
|
586
|
+
function toVersionedTransaction(connection, txMessage) {
|
|
587
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
588
|
+
const alts = yield stringToAlt(connection, txMessage.addressLookupTableAddresses);
|
|
589
|
+
const result = new web3.VersionedTransaction(new web3.TransactionMessage({
|
|
590
|
+
instructions: txMessage.mainInstructions.map((ix) => ixStrToWeb3Ix(ix)),
|
|
591
|
+
payerKey: new web3.PublicKey(txMessage.payer),
|
|
592
|
+
recentBlockhash: web3.PublicKey.default.toString(),
|
|
593
|
+
}).compileToV0Message(alts));
|
|
594
|
+
return result;
|
|
595
|
+
});
|
|
596
|
+
}
|
|
597
|
+
exports.toVersionedTransaction = toVersionedTransaction;
|
|
598
|
+
function ixStrToWeb3Ix(ix) {
|
|
599
|
+
return {
|
|
600
|
+
keys: ix.accounts.map((account) => {
|
|
601
|
+
return {
|
|
602
|
+
isSigner: account.isSigner,
|
|
603
|
+
isWritable: account.isWritable,
|
|
604
|
+
pubkey: new web3.PublicKey(account.pubkey),
|
|
605
|
+
};
|
|
606
|
+
}),
|
|
607
|
+
data: Buffer.from(ix.data, "base64"),
|
|
608
|
+
programId: new web3.PublicKey(ix.programId),
|
|
609
|
+
};
|
|
610
|
+
}
|
|
611
|
+
exports.ixStrToWeb3Ix = ixStrToWeb3Ix;
|
|
612
|
+
function stringToAlt(connection, alts) {
|
|
613
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
614
|
+
const _alts = [];
|
|
615
|
+
const pubkeys = alts.map(alt => new web3.PublicKey(alt));
|
|
616
|
+
const accountInfos = yield connection.getMultipleAccountsInfo(pubkeys);
|
|
617
|
+
for (let i = 0; i < accountInfos.length; i++) {
|
|
618
|
+
_alts.push(new web3.AddressLookupTableAccount({
|
|
619
|
+
key: pubkeys[i],
|
|
620
|
+
state: web3.AddressLookupTableAccount.deserialize(accountInfos[i].data)
|
|
621
|
+
}));
|
|
622
|
+
}
|
|
623
|
+
return _alts;
|
|
624
|
+
});
|
|
625
|
+
}
|
|
626
|
+
exports.stringToAlt = stringToAlt;
|
package/dist/src/index.d.ts
CHANGED
package/dist/src/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC;AACxB,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAC5C,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACpD,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAC1C,OAAO,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC;AACxB,cAAc,aAAa,CAAC;AAC5B,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAC5C,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACpD,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAC1C,OAAO,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAC"}
|
package/dist/src/index.js
CHANGED
|
@@ -16,6 +16,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
exports.CreateTxMetadata = exports.Client = exports.TxGenerator = exports.HawkAPI = void 0;
|
|
18
18
|
__exportStar(require("./types"), exports);
|
|
19
|
+
__exportStar(require("./functions"), exports);
|
|
19
20
|
var HawkAPI_1 = require("./classes/HawkAPI");
|
|
20
21
|
Object.defineProperty(exports, "HawkAPI", { enumerable: true, get: function () { return HawkAPI_1.HawkAPI; } });
|
|
21
22
|
var TxGenerator_1 = require("./classes/TxGenerator");
|
package/dist/src/meteora.d.ts
CHANGED
|
@@ -161,6 +161,59 @@ export declare class MeteoraDLMM {
|
|
|
161
161
|
position: LbPosition;
|
|
162
162
|
}, meteoraToHawksight: MeteoraToHawksightFn): Promise<web3.TransactionInstruction[]>;
|
|
163
163
|
}
|
|
164
|
+
/**
|
|
165
|
+
* Meteora functions / transaction generators that we re-written for performance improvement purposes
|
|
166
|
+
*/
|
|
167
|
+
export declare class MeteoraFunctions {
|
|
168
|
+
/**
|
|
169
|
+
* Claims all rewards for a specified position.
|
|
170
|
+
*
|
|
171
|
+
* This method communicates with the DLMM (Dynamic Liquidity Market Maker) to claim all rewards
|
|
172
|
+
* for a given position. It filters the transaction instructions to include only those relevant
|
|
173
|
+
* to the Meteora DLMM program. The method returns a `ClaimAllRewardsByPositionBuilder` object
|
|
174
|
+
* which provides a structured way to build the necessary transaction instructions for the reward
|
|
175
|
+
* claiming process.
|
|
176
|
+
*
|
|
177
|
+
* @param {web3.PublicKey} userWallet - The public key of the user's wallet executing the transaction.
|
|
178
|
+
* @param {web3.PublicKey} payer - The public key of the transaction payer.
|
|
179
|
+
* @param {Object} params - The parameters for claiming rewards.
|
|
180
|
+
* @param {web3.PublicKey} params.owner - The public key of the owner of the position.
|
|
181
|
+
* @param {LbPosition} params.position - The position object representing the liquidity position.
|
|
182
|
+
* @param {Function} meteoraToHawksight - A function to convert Meteora instructions to Hawksight instructions.
|
|
183
|
+
*
|
|
184
|
+
* @returns {Promise<ClaimAllRewardsByPositionBuilder>} - A promise that resolves to a `ClaimAllRewardsByPositionBuilder` object.
|
|
185
|
+
*/
|
|
186
|
+
claimAllRewardsByPosition(connection: web3.Connection, userWallet: web3.PublicKey, payer: web3.PublicKey, params: {
|
|
187
|
+
owner: web3.PublicKey;
|
|
188
|
+
lbPair: web3.PublicKey;
|
|
189
|
+
position: web3.PublicKey;
|
|
190
|
+
}, meteoraToHawksight: MeteoraToHawksightFn): Promise<ClaimAllRewardsByPositionBuilder>;
|
|
191
|
+
constants(program: any): {
|
|
192
|
+
MAX_BIN_ARRAY_SIZE: BN;
|
|
193
|
+
MAX_BIN_PER_POSITION: BN;
|
|
194
|
+
BIN_ARRAY_BITMAP_SIZE: BN;
|
|
195
|
+
EXTENSION_BINARRAY_BITMAP_SIZE: BN;
|
|
196
|
+
};
|
|
197
|
+
deriveReserve(token: web3.PublicKey, lbPair: web3.PublicKey): web3.PublicKey;
|
|
198
|
+
deriveBinArray(lbPair: web3.PublicKey, index: BN): web3.PublicKey;
|
|
199
|
+
binIdToBinArrayIndex(MAX_BIN_ARRAY_SIZE: BN, binId: BN): BN;
|
|
200
|
+
getPositionAndLbPair(connection: web3.Connection, lbPair: web3.PublicKey, position: web3.PublicKey): Promise<{
|
|
201
|
+
lbPairAccount: any;
|
|
202
|
+
positionAccount: any;
|
|
203
|
+
constants: any;
|
|
204
|
+
}>;
|
|
205
|
+
claimFeeAndRewardIxs(connection: web3.Connection, lbPair: web3.PublicKey, position: web3.PublicKey, userPda: web3.PublicKey): Promise<web3.TransactionInstruction[]>;
|
|
206
|
+
claimFeeIx(lbPair: web3.PublicKey, position: web3.PublicKey, userPda: web3.PublicKey, getPositionAndLbPairResult: {
|
|
207
|
+
lbPairAccount: any;
|
|
208
|
+
positionAccount: any;
|
|
209
|
+
constants: any;
|
|
210
|
+
}): web3.TransactionInstruction;
|
|
211
|
+
claimRewardIxs(lbPair: web3.PublicKey, position: web3.PublicKey, userPda: web3.PublicKey, getPositionAndLbPairResult: {
|
|
212
|
+
lbPairAccount: any;
|
|
213
|
+
positionAccount: any;
|
|
214
|
+
constants: any;
|
|
215
|
+
}): web3.TransactionInstruction[];
|
|
216
|
+
}
|
|
164
217
|
/**
|
|
165
218
|
* A builder class for constructing transaction instructions to claim all rewards by position.
|
|
166
219
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"meteora.d.ts","sourceRoot":"","sources":["../../src/meteora.ts"],"names":[],"mappings":";AAAA,OAAO,IAAI,EAAE,EAAuF,WAAW,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AACpK,OAAO,EAAE,MAAM,OAAO,CAAC;AACvB,OAAO,KAAK,IAAI,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"meteora.d.ts","sourceRoot":"","sources":["../../src/meteora.ts"],"names":[],"mappings":";AAAA,OAAO,IAAI,EAAE,EAAuF,WAAW,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AACpK,OAAO,EAAE,MAAM,OAAO,CAAC;AACvB,OAAO,KAAK,IAAI,MAAM,iBAAiB,CAAC;AAUxC,OAAO,EAAE,oBAAoB,EAAE,MAAM,SAAS,CAAC;AAG/C,qBAAa,WAAW;aACc,IAAI,EAAE,IAAI;IAA9C,OAAO;IAEP,QAAQ,CAAC,MAAM,iBAAoB;WAEtB,MAAM,CACjB,UAAU,EAAE,IAAI,CAAC,UAAU,EAC3B,WAAW,EAAE,IAAI,CAAC,SAAS;IAM7B;;;;OAIG;WACU,OAAO,CAAC,UAAU,EAAE,IAAI,CAAC,UAAU,GAAG,OAAO,CAAC,WAAW,CAAC;IAKvE,uBAAuB,CACrB,YAAY,EAAE,MAAM,GAAG,OAAO,GAAG,SAAS,EAC1C,SAAS,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,EAC3C,UAAU,EAAE,MAAM,EAClB,UAAU,EAAE,MAAM;;;;;IA0Bd,YAAY;IAIZ,2BAA2B,CAAC,UAAU,EAAE,IAAI,CAAC,SAAS;;;;IAI5D;;;;;;;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EAAE;CAkBzC"}
|
package/dist/src/meteora.js
CHANGED
|
@@ -31,9 +31,14 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
31
31
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
32
32
|
});
|
|
33
33
|
};
|
|
34
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
35
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
36
|
+
};
|
|
34
37
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
35
|
-
exports.InitializePositionAndAddLiquidityByStrategyBuilder = exports.RemoveLiquidityBuilder = exports.AddLiquidityByStrategyBuilder = exports.ClaimAllRewardsByPositionBuilder = exports.MeteoraDLMM = void 0;
|
|
38
|
+
exports.InitializePositionAndAddLiquidityByStrategyBuilder = exports.RemoveLiquidityBuilder = exports.AddLiquidityByStrategyBuilder = exports.ClaimAllRewardsByPositionBuilder = exports.MeteoraFunctions = exports.MeteoraDLMM = void 0;
|
|
36
39
|
const dlmm_1 = __importStar(require("@meteora-ag/dlmm"));
|
|
40
|
+
const bn_js_1 = __importDefault(require("bn.js"));
|
|
41
|
+
const web3 = __importStar(require("@solana/web3.js"));
|
|
37
42
|
const errors_1 = require("./errors");
|
|
38
43
|
const addresses_1 = require("./addresses");
|
|
39
44
|
const functions_1 = require("./functions");
|
|
@@ -417,6 +422,207 @@ class MeteoraDLMM {
|
|
|
417
422
|
}
|
|
418
423
|
}
|
|
419
424
|
exports.MeteoraDLMM = MeteoraDLMM;
|
|
425
|
+
/**
|
|
426
|
+
* Meteora functions / transaction generators that we re-written for performance improvement purposes
|
|
427
|
+
*/
|
|
428
|
+
class MeteoraFunctions {
|
|
429
|
+
/**
|
|
430
|
+
* Claims all rewards for a specified position.
|
|
431
|
+
*
|
|
432
|
+
* This method communicates with the DLMM (Dynamic Liquidity Market Maker) to claim all rewards
|
|
433
|
+
* for a given position. It filters the transaction instructions to include only those relevant
|
|
434
|
+
* to the Meteora DLMM program. The method returns a `ClaimAllRewardsByPositionBuilder` object
|
|
435
|
+
* which provides a structured way to build the necessary transaction instructions for the reward
|
|
436
|
+
* claiming process.
|
|
437
|
+
*
|
|
438
|
+
* @param {web3.PublicKey} userWallet - The public key of the user's wallet executing the transaction.
|
|
439
|
+
* @param {web3.PublicKey} payer - The public key of the transaction payer.
|
|
440
|
+
* @param {Object} params - The parameters for claiming rewards.
|
|
441
|
+
* @param {web3.PublicKey} params.owner - The public key of the owner of the position.
|
|
442
|
+
* @param {LbPosition} params.position - The position object representing the liquidity position.
|
|
443
|
+
* @param {Function} meteoraToHawksight - A function to convert Meteora instructions to Hawksight instructions.
|
|
444
|
+
*
|
|
445
|
+
* @returns {Promise<ClaimAllRewardsByPositionBuilder>} - A promise that resolves to a `ClaimAllRewardsByPositionBuilder` object.
|
|
446
|
+
*/
|
|
447
|
+
claimAllRewardsByPosition(connection, userWallet, payer, params, meteoraToHawksight) {
|
|
448
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
449
|
+
// Generate claim fee and reward instruction (fast generator)
|
|
450
|
+
const ixs = yield this.claimFeeAndRewardIxs(connection, params.lbPair, params.position, params.owner);
|
|
451
|
+
// Find mint from meteora instructions
|
|
452
|
+
const mints = (0, functions_1.getMintsFromInstruction)({
|
|
453
|
+
instructions: ixs,
|
|
454
|
+
find: {
|
|
455
|
+
ClaimFee: {
|
|
456
|
+
programId: addresses_1.METEORA_DLMM_PROGRAM.toBase58(),
|
|
457
|
+
mintIndices: [9, 10],
|
|
458
|
+
},
|
|
459
|
+
ClaimReward: {
|
|
460
|
+
programId: addresses_1.METEORA_DLMM_PROGRAM.toBase58(),
|
|
461
|
+
mintIndices: [6],
|
|
462
|
+
},
|
|
463
|
+
},
|
|
464
|
+
});
|
|
465
|
+
return new ClaimAllRewardsByPositionBuilder(
|
|
466
|
+
// Step 1: Init ATA prior to withdrawal
|
|
467
|
+
(0, functions_1.createAtaIdempotentIxs)({
|
|
468
|
+
accounts: mints.map((mint) => {
|
|
469
|
+
return { owner: params.owner, payer, mint };
|
|
470
|
+
}),
|
|
471
|
+
}),
|
|
472
|
+
// Step 2: Claim fees and/or rewards, remove liquidity, and possibly close position (if set)
|
|
473
|
+
yield meteoraToHawksight({
|
|
474
|
+
ixs,
|
|
475
|
+
userPda: params.owner,
|
|
476
|
+
authority: userWallet,
|
|
477
|
+
}),
|
|
478
|
+
// Step 3: Withdraw tokens to user wallet
|
|
479
|
+
yield (0, hawksight_1.withdrawMultipleToken)({
|
|
480
|
+
payer: userWallet,
|
|
481
|
+
withdraw: mints.map((mint) => {
|
|
482
|
+
return { mint };
|
|
483
|
+
}),
|
|
484
|
+
}),
|
|
485
|
+
// Step 4: Close wSOL account (if there's any)
|
|
486
|
+
(0, functions_1.unwrapSolIfMintIsWsol)(userWallet, mints));
|
|
487
|
+
});
|
|
488
|
+
}
|
|
489
|
+
constants(program) {
|
|
490
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
491
|
+
const CONSTANTS = Object.entries(program.idl.constants);
|
|
492
|
+
const MAX_BIN_ARRAY_SIZE = new bn_js_1.default((_b = ((_a = CONSTANTS.find(([k, v]) => v.name == "MAX_BIN_PER_ARRAY")) === null || _a === void 0 ? void 0 : _a[1]).value) !== null && _b !== void 0 ? _b : 0);
|
|
493
|
+
const MAX_BIN_PER_POSITION = new bn_js_1.default((_d = ((_c = CONSTANTS.find(([k, v]) => v.name == "MAX_BIN_PER_POSITION")) === null || _c === void 0 ? void 0 : _c[1]).value) !== null && _d !== void 0 ? _d : 0);
|
|
494
|
+
const BIN_ARRAY_BITMAP_SIZE = new bn_js_1.default((_f = ((_e = CONSTANTS.find(([k, v]) => v.name == "BIN_ARRAY_BITMAP_SIZE")) === null || _e === void 0 ? void 0 : _e[1]).value) !== null && _f !== void 0 ? _f : 0);
|
|
495
|
+
const EXTENSION_BINARRAY_BITMAP_SIZE = new bn_js_1.default((_h = ((_g = CONSTANTS.find(([k, v]) => v.name == "EXTENSION_BINARRAY_BITMAP_SIZE")) === null || _g === void 0 ? void 0 : _g[1])
|
|
496
|
+
.value) !== null && _h !== void 0 ? _h : 0);
|
|
497
|
+
return {
|
|
498
|
+
MAX_BIN_ARRAY_SIZE,
|
|
499
|
+
MAX_BIN_PER_POSITION,
|
|
500
|
+
BIN_ARRAY_BITMAP_SIZE,
|
|
501
|
+
EXTENSION_BINARRAY_BITMAP_SIZE,
|
|
502
|
+
};
|
|
503
|
+
}
|
|
504
|
+
deriveReserve(token, lbPair) {
|
|
505
|
+
const [reserve] = web3.PublicKey.findProgramAddressSync([
|
|
506
|
+
lbPair.toBuffer(),
|
|
507
|
+
token.toBuffer(),
|
|
508
|
+
], addresses_1.METEORA_DLMM_PROGRAM);
|
|
509
|
+
return reserve;
|
|
510
|
+
}
|
|
511
|
+
deriveBinArray(lbPair, index) {
|
|
512
|
+
let binArrayBytes;
|
|
513
|
+
if (index.isNeg()) {
|
|
514
|
+
binArrayBytes = new Uint8Array(index.toTwos(64).toArrayLike(Buffer, "le", 8));
|
|
515
|
+
}
|
|
516
|
+
else {
|
|
517
|
+
binArrayBytes = new Uint8Array(index.toArrayLike(Buffer, "le", 8));
|
|
518
|
+
}
|
|
519
|
+
const [binArray] = web3.PublicKey.findProgramAddressSync([Buffer.from("bin_array"), lbPair.toBytes(), binArrayBytes], addresses_1.METEORA_DLMM_PROGRAM);
|
|
520
|
+
return binArray;
|
|
521
|
+
}
|
|
522
|
+
binIdToBinArrayIndex(MAX_BIN_ARRAY_SIZE, binId) {
|
|
523
|
+
const { div: idx, mod } = binId.divmod(MAX_BIN_ARRAY_SIZE);
|
|
524
|
+
return binId.isNeg() && !mod.isZero() ? idx.sub(new bn_js_1.default(1)) : idx;
|
|
525
|
+
}
|
|
526
|
+
getPositionAndLbPair(connection, lbPair, position) {
|
|
527
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
528
|
+
const program = yield MeteoraDLMM.program(connection);
|
|
529
|
+
const constants = this.constants(program);
|
|
530
|
+
const [lbPairInfo, positionInfo] = yield connection.getMultipleAccountsInfo([lbPair, position]);
|
|
531
|
+
const lbPairAccount = program.coder.accounts.decode('lbPair', lbPairInfo.data);
|
|
532
|
+
const positionAccount = program.coder.accounts.decode('positionV2', positionInfo.data);
|
|
533
|
+
return {
|
|
534
|
+
lbPairAccount,
|
|
535
|
+
positionAccount,
|
|
536
|
+
constants,
|
|
537
|
+
};
|
|
538
|
+
});
|
|
539
|
+
}
|
|
540
|
+
claimFeeAndRewardIxs(connection, lbPair, position, userPda) {
|
|
541
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
542
|
+
const result = yield this.getPositionAndLbPair(connection, lbPair, position);
|
|
543
|
+
const claimFeeIx = this.claimFeeIx(lbPair, position, userPda, result);
|
|
544
|
+
const claimRewardIxs = this.claimRewardIxs(lbPair, position, userPda, result);
|
|
545
|
+
return [
|
|
546
|
+
claimFeeIx,
|
|
547
|
+
...claimRewardIxs
|
|
548
|
+
];
|
|
549
|
+
});
|
|
550
|
+
}
|
|
551
|
+
claimFeeIx(lbPair, position, userPda, getPositionAndLbPairResult) {
|
|
552
|
+
const tokenMintX = getPositionAndLbPairResult.lbPairAccount.tokenXMint;
|
|
553
|
+
const tokenMintY = getPositionAndLbPairResult.lbPairAccount.tokenYMint;
|
|
554
|
+
const { lowerBinId } = getPositionAndLbPairResult.positionAccount;
|
|
555
|
+
const MAX_BIN_ARRAY_SIZE = getPositionAndLbPairResult.constants.MAX_BIN_ARRAY_SIZE;
|
|
556
|
+
const lowerBinArrayIndex = this.binIdToBinArrayIndex(MAX_BIN_ARRAY_SIZE, new bn_js_1.default(lowerBinId));
|
|
557
|
+
const binArrayLower = this.deriveBinArray(lbPair, lowerBinArrayIndex);
|
|
558
|
+
const upperBinArrayIndex = lowerBinArrayIndex.add(new bn_js_1.default(1));
|
|
559
|
+
const binArrayUpper = this.deriveBinArray(lbPair, upperBinArrayIndex);
|
|
560
|
+
const userTokenX = (0, functions_1.generateAta)(userPda, tokenMintX);
|
|
561
|
+
const userTokenY = (0, functions_1.generateAta)(userPda, tokenMintY);
|
|
562
|
+
const reserveX = this.deriveReserve(tokenMintX, lbPair);
|
|
563
|
+
const reserveY = this.deriveReserve(tokenMintX, lbPair);
|
|
564
|
+
const ix = new web3.TransactionInstruction({
|
|
565
|
+
programId: addresses_1.METEORA_DLMM_PROGRAM,
|
|
566
|
+
keys: [
|
|
567
|
+
{ pubkey: lbPair, isSigner: false, isWritable: true },
|
|
568
|
+
{ pubkey: position, isSigner: false, isWritable: true },
|
|
569
|
+
{ pubkey: binArrayLower, isSigner: false, isWritable: true },
|
|
570
|
+
{ pubkey: binArrayUpper, isSigner: false, isWritable: true },
|
|
571
|
+
{ pubkey: userPda, isSigner: false, isWritable: false },
|
|
572
|
+
{ pubkey: reserveX, isSigner: false, isWritable: true },
|
|
573
|
+
{ pubkey: reserveY, isSigner: false, isWritable: true },
|
|
574
|
+
{ pubkey: userTokenX, isSigner: false, isWritable: true },
|
|
575
|
+
{ pubkey: userTokenY, isSigner: false, isWritable: true },
|
|
576
|
+
{ pubkey: tokenMintX, isSigner: false, isWritable: false },
|
|
577
|
+
{ pubkey: tokenMintY, isSigner: false, isWritable: false },
|
|
578
|
+
{ pubkey: addresses_1.TOKEN_PROGRAM_ID, isSigner: false, isWritable: false },
|
|
579
|
+
{ pubkey: addresses_1.METEORA_EVENT_AUTHORITY, isSigner: false, isWritable: false },
|
|
580
|
+
{ pubkey: addresses_1.METEORA_DLMM_PROGRAM, isSigner: false, isWritable: false },
|
|
581
|
+
],
|
|
582
|
+
data: Buffer.concat([
|
|
583
|
+
(0, functions_1.sighash)('ClaimFee')
|
|
584
|
+
]),
|
|
585
|
+
});
|
|
586
|
+
return ix;
|
|
587
|
+
}
|
|
588
|
+
claimRewardIxs(lbPair, position, userPda, getPositionAndLbPairResult) {
|
|
589
|
+
const { lowerBinId } = getPositionAndLbPairResult.positionAccount;
|
|
590
|
+
const MAX_BIN_ARRAY_SIZE = getPositionAndLbPairResult.constants.MAX_BIN_ARRAY_SIZE;
|
|
591
|
+
const lowerBinArrayIndex = this.binIdToBinArrayIndex(MAX_BIN_ARRAY_SIZE, new bn_js_1.default(lowerBinId));
|
|
592
|
+
const binArrayLower = this.deriveBinArray(lbPair, lowerBinArrayIndex);
|
|
593
|
+
const upperBinArrayIndex = lowerBinArrayIndex.add(new bn_js_1.default(1));
|
|
594
|
+
const binArrayUpper = this.deriveBinArray(lbPair, upperBinArrayIndex);
|
|
595
|
+
const ixs = [];
|
|
596
|
+
for (const rewardInfo of getPositionAndLbPairResult.lbPairAccount.rewardInfos) {
|
|
597
|
+
if (!rewardInfo || rewardInfo.mint.equals(web3.PublicKey.default))
|
|
598
|
+
continue;
|
|
599
|
+
const userTokenAccount = (0, functions_1.generateAta)(userPda, rewardInfo.mint);
|
|
600
|
+
const ix = new web3.TransactionInstruction({
|
|
601
|
+
programId: addresses_1.METEORA_DLMM_PROGRAM,
|
|
602
|
+
keys: [
|
|
603
|
+
{ pubkey: lbPair, isSigner: false, isWritable: true },
|
|
604
|
+
{ pubkey: position, isSigner: false, isWritable: true },
|
|
605
|
+
{ pubkey: binArrayLower, isSigner: false, isWritable: true },
|
|
606
|
+
{ pubkey: binArrayUpper, isSigner: false, isWritable: true },
|
|
607
|
+
{ pubkey: userPda, isSigner: false, isWritable: false },
|
|
608
|
+
{ pubkey: rewardInfo.vault, isSigner: false, isWritable: true },
|
|
609
|
+
{ pubkey: rewardInfo.mint, isSigner: false, isWritable: true },
|
|
610
|
+
{ pubkey: userTokenAccount, isSigner: false, isWritable: true },
|
|
611
|
+
{ pubkey: addresses_1.TOKEN_PROGRAM_ID, isSigner: false, isWritable: false },
|
|
612
|
+
{ pubkey: addresses_1.METEORA_EVENT_AUTHORITY, isSigner: false, isWritable: false },
|
|
613
|
+
{ pubkey: addresses_1.METEORA_DLMM_PROGRAM, isSigner: false, isWritable: false },
|
|
614
|
+
],
|
|
615
|
+
data: Buffer.concat([
|
|
616
|
+
(0, functions_1.sighash)('ClaimReward')
|
|
617
|
+
]),
|
|
618
|
+
});
|
|
619
|
+
ixs.push(ix);
|
|
620
|
+
}
|
|
621
|
+
console.log(`Reward ixs count: ` + ixs.length);
|
|
622
|
+
return ixs;
|
|
623
|
+
}
|
|
624
|
+
}
|
|
625
|
+
exports.MeteoraFunctions = MeteoraFunctions;
|
|
420
626
|
/**
|
|
421
627
|
* A builder class for constructing transaction instructions to claim all rewards by position.
|
|
422
628
|
*
|