@hawksightco/hawk-sdk 1.3.9 → 1.3.11
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/CHANGELOG.md +135 -0
- package/README.md +306 -10
- package/dist/src/addresses.d.ts +3 -0
- package/dist/src/addresses.d.ts.map +1 -1
- package/dist/src/addresses.js +21 -8
- package/dist/src/anchor.d.ts +1 -0
- package/dist/src/anchor.d.ts.map +1 -1
- package/dist/src/anchor.js +17 -7
- package/dist/src/classes/Atomicity.d.ts.map +1 -1
- package/dist/src/classes/Client.js +17 -7
- package/dist/src/classes/CombineTransactions.js +17 -7
- package/dist/src/classes/CreateTxMetadata.js +17 -7
- package/dist/src/classes/General.js +17 -7
- package/dist/src/classes/HawkAPI.d.ts.map +1 -1
- package/dist/src/classes/JupiterAlts.js +17 -7
- package/dist/src/classes/Logging.js +2 -3
- package/dist/src/classes/MultiTransaction.js +19 -9
- package/dist/src/classes/RaydiumSDK.js +3 -3
- package/dist/src/classes/SimpleIxGenerator.d.ts.map +1 -1
- package/dist/src/classes/SimpleIxGenerator.js +1 -1
- package/dist/src/classes/Transaction.js +17 -7
- package/dist/src/classes/Transaction2.js +17 -7
- package/dist/src/classes/Transaction3.js +17 -7
- package/dist/src/classes/TransactionBatchExecute.d.ts.map +1 -1
- package/dist/src/classes/TransactionBatchExecute.js +17 -7
- package/dist/src/classes/TransactionBatchExecute2.js +17 -7
- package/dist/src/classes/Transactions.d.ts +4 -0
- package/dist/src/classes/Transactions.d.ts.map +1 -1
- package/dist/src/classes/Transactions.js +53 -26
- package/dist/src/classes/TxGenerator.d.ts.map +1 -1
- package/dist/src/classes/TxGenerator.js +20 -7
- package/dist/src/classes/TxGeneratorAutomations.js +17 -7
- package/dist/src/classes/account-cache/AccountCache.d.ts +0 -1
- package/dist/src/classes/account-cache/AccountCache.d.ts.map +1 -1
- package/dist/src/classes/account-cache/AccountCache.js +17 -7
- package/dist/src/functions.d.ts +5 -6
- package/dist/src/functions.d.ts.map +1 -1
- package/dist/src/functions.js +76 -72
- package/dist/src/hawksight.js +24 -15
- package/dist/src/hsToMeteora.js +429 -13
- package/dist/src/idl/iyf-extension-idl.d.ts +1582 -571
- package/dist/src/idl/iyf-extension-idl.d.ts.map +1 -1
- package/dist/src/idl/iyf-extension-idl.js +1582 -571
- package/dist/src/idl/iyf-main-idl.d.ts +121 -0
- package/dist/src/idl/iyf-main-idl.d.ts.map +1 -1
- package/dist/src/idl/iyf-main-idl.js +121 -0
- package/dist/src/idl/jupiter-idl.d.ts +58 -5
- package/dist/src/idl/jupiter-idl.d.ts.map +1 -1
- package/dist/src/idl/jupiter-idl.js +58 -5
- package/dist/src/ixGenerator/IyfExtensionIxGenerator.d.ts.map +1 -1
- package/dist/src/ixGenerator/IyfExtensionIxGenerator.js +17 -7
- package/dist/src/ixGenerator/IyfMainIxGenerator.d.ts +7 -1
- package/dist/src/ixGenerator/IyfMainIxGenerator.d.ts.map +1 -1
- package/dist/src/ixGenerator/IyfMainIxGenerator.js +40 -7
- package/dist/src/ixGenerator/MeteoraDlmmIxGenerator.js +17 -7
- package/dist/src/ixGenerator/OrcaIxGenerator.d.ts +67 -2
- package/dist/src/ixGenerator/OrcaIxGenerator.d.ts.map +1 -1
- package/dist/src/ixGenerator/OrcaIxGenerator.js +232 -10
- package/dist/src/ixGenerator/RaydiumIxGenerator.js +20 -10
- package/dist/src/meteora.d.ts +1 -1
- package/dist/src/meteora.js +17 -7
- package/dist/src/orca.js +23 -13
- package/dist/src/pdaGenerator/HawksightPdaGenerator.js +17 -7
- package/dist/src/pdaGenerator/OrcaPdaGenerator.d.ts +8 -0
- package/dist/src/pdaGenerator/OrcaPdaGenerator.d.ts.map +1 -1
- package/dist/src/pdaGenerator/OrcaPdaGenerator.js +30 -7
- package/dist/src/pdaGenerator/RaydiumPdaGenerator.js +17 -7
- package/dist/src/pdaGenerator/UtilPdaGenerator.js +17 -7
- package/dist/src/types.d.ts +4 -0
- package/dist/src/types.d.ts.map +1 -1
- package/package.json +20 -3
package/dist/src/functions.js
CHANGED
|
@@ -15,13 +15,23 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
|
|
|
15
15
|
}) : function(o, v) {
|
|
16
16
|
o["default"] = v;
|
|
17
17
|
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
};
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
25
35
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
26
36
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
27
37
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -35,8 +45,64 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
35
45
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
36
46
|
};
|
|
37
47
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
38
|
-
exports.
|
|
39
|
-
exports.
|
|
48
|
+
exports.benchmark = exports.METEORA_API_URL = void 0;
|
|
49
|
+
exports.createTxMetadata = createTxMetadata;
|
|
50
|
+
exports.createTxMetadata2 = createTxMetadata2;
|
|
51
|
+
exports.resultOrError = resultOrError;
|
|
52
|
+
exports.getFeeEstimate = getFeeEstimate;
|
|
53
|
+
exports.getMeteoraPool = getMeteoraPool;
|
|
54
|
+
exports.createTransactionMeta = createTransactionMeta;
|
|
55
|
+
exports.legacyTxMetadata = legacyTxMetadata;
|
|
56
|
+
exports.generateUserPda = generateUserPda;
|
|
57
|
+
exports.generateUserPdaLamport = generateUserPdaLamport;
|
|
58
|
+
exports.generateAta = generateAta;
|
|
59
|
+
exports.generateLimitToken = generateLimitToken;
|
|
60
|
+
exports.generateFuelAccount = generateFuelAccount;
|
|
61
|
+
exports.generateAta2022 = generateAta2022;
|
|
62
|
+
exports.generateOrcaPositionPDA = generateOrcaPositionPDA;
|
|
63
|
+
exports.generateUserPdaStorageAccount = generateUserPdaStorageAccount;
|
|
64
|
+
exports.getIxs = getIxs;
|
|
65
|
+
exports.sighashMatch = sighashMatch;
|
|
66
|
+
exports.sighash = sighash;
|
|
67
|
+
exports.tokenAccountExists = tokenAccountExists;
|
|
68
|
+
exports.parseTokenAccountData = parseTokenAccountData;
|
|
69
|
+
exports.createAtaIdempotentIxs = createAtaIdempotentIxs;
|
|
70
|
+
exports.getMintsFromInstruction = getMintsFromInstruction;
|
|
71
|
+
exports.wrapSolIfMintIsWsol = wrapSolIfMintIsWsol;
|
|
72
|
+
exports.wrapSolToWsol = wrapSolToWsol;
|
|
73
|
+
exports.unwrapSolIfMintIsWsol = unwrapSolIfMintIsWsol;
|
|
74
|
+
exports.unwrapWsolToSol = unwrapWsolToSol;
|
|
75
|
+
exports.inputTokenExists = inputTokenExists;
|
|
76
|
+
exports.getJupiterRouteIxParams = getJupiterRouteIxParams;
|
|
77
|
+
exports.toVersionedTransaction = toVersionedTransaction;
|
|
78
|
+
exports.ixStrToWeb3Ix = ixStrToWeb3Ix;
|
|
79
|
+
exports.stringToAlt = stringToAlt;
|
|
80
|
+
exports.getPriorityFeeEstimate = getPriorityFeeEstimate;
|
|
81
|
+
exports.getPriorityFeeEstimate2 = getPriorityFeeEstimate2;
|
|
82
|
+
exports.mid = mid;
|
|
83
|
+
exports.generateNonceAddressFromIndex = generateNonceAddressFromIndex;
|
|
84
|
+
exports.generateNonceAddressesOwnedBy = generateNonceAddressesOwnedBy;
|
|
85
|
+
exports.findNonceOwnedBy = findNonceOwnedBy;
|
|
86
|
+
exports.tokenizer = tokenizer;
|
|
87
|
+
exports.deserializeParametersFromIDL = deserializeParametersFromIDL;
|
|
88
|
+
exports.extractValue = extractValue;
|
|
89
|
+
exports.resolveStruct = resolveStruct;
|
|
90
|
+
exports.resolveEnum = resolveEnum;
|
|
91
|
+
exports.resolveOption = resolveOption;
|
|
92
|
+
exports.resolveVec = resolveVec;
|
|
93
|
+
exports.resolveArray = resolveArray;
|
|
94
|
+
exports.resolveDefined = resolveDefined;
|
|
95
|
+
exports.extractPrimitives = extractPrimitives;
|
|
96
|
+
exports.simulateTransaction = simulateTransaction;
|
|
97
|
+
exports.createAssociatedTokenAccountIdempotentInstruction = createAssociatedTokenAccountIdempotentInstruction;
|
|
98
|
+
exports.raydiumStartTickIndex = raydiumStartTickIndex;
|
|
99
|
+
exports.i32ToBeBuffer = i32ToBeBuffer;
|
|
100
|
+
exports.findUserAlts = findUserAlts;
|
|
101
|
+
exports.pubkeysInAlt = pubkeysInAlt;
|
|
102
|
+
exports.getBatchedMultipleAccountsInfo = getBatchedMultipleAccountsInfo;
|
|
103
|
+
exports.getTokenProgramForMints = getTokenProgramForMints;
|
|
104
|
+
exports.getTokenProgramMapForMints = getTokenProgramMapForMints;
|
|
105
|
+
exports.getMeteoraStrategyType = getMeteoraStrategyType;
|
|
40
106
|
const client = __importStar(require("@hawksightco/swagger-client"));
|
|
41
107
|
const web3 = __importStar(require("@solana/web3.js"));
|
|
42
108
|
const axios_1 = __importDefault(require("axios"));
|
|
@@ -73,13 +139,11 @@ function createTxMetadata(generalUtility, connection, payer, data) {
|
|
|
73
139
|
return yield CreateTxMetadata_1.CreateTxMetadata.instance().createTxMetadata(generalUtility, connection, payer, data);
|
|
74
140
|
});
|
|
75
141
|
}
|
|
76
|
-
exports.createTxMetadata = createTxMetadata;
|
|
77
142
|
function createTxMetadata2(generalUtility, connection, payer, data) {
|
|
78
143
|
return __awaiter(this, void 0, void 0, function* () {
|
|
79
144
|
return yield CreateTxMetadata_1.CreateTxMetadata.instance().createTxMetadata2(generalUtility, connection, payer, data);
|
|
80
145
|
});
|
|
81
146
|
}
|
|
82
|
-
exports.createTxMetadata2 = createTxMetadata2;
|
|
83
147
|
/**
|
|
84
148
|
* Wraps the result of an API call or operation in an object containing status information.
|
|
85
149
|
* If the result status is 200, applies a success function to the data.
|
|
@@ -104,7 +168,6 @@ function resultOrError(result, successFn) {
|
|
|
104
168
|
}
|
|
105
169
|
});
|
|
106
170
|
}
|
|
107
|
-
exports.resultOrError = resultOrError;
|
|
108
171
|
/**
|
|
109
172
|
* Retrieves an estimate of the priority fee for a transaction using the provided connection.
|
|
110
173
|
*
|
|
@@ -139,7 +202,6 @@ function getFeeEstimate(generalUtility, priority, transaction) {
|
|
|
139
202
|
}))).data;
|
|
140
203
|
});
|
|
141
204
|
}
|
|
142
|
-
exports.getFeeEstimate = getFeeEstimate;
|
|
143
205
|
/**
|
|
144
206
|
* Returns a meteora pool
|
|
145
207
|
*
|
|
@@ -159,7 +221,6 @@ function getMeteoraPool(poolAddress) {
|
|
|
159
221
|
}
|
|
160
222
|
});
|
|
161
223
|
}
|
|
162
|
-
exports.getMeteoraPool = getMeteoraPool;
|
|
163
224
|
/**
|
|
164
225
|
* Generate transaction meta object
|
|
165
226
|
*
|
|
@@ -198,7 +259,6 @@ function createTransactionMeta(params) {
|
|
|
198
259
|
};
|
|
199
260
|
});
|
|
200
261
|
}
|
|
201
|
-
exports.createTransactionMeta = createTransactionMeta;
|
|
202
262
|
function legacyTxMetadata(_a) {
|
|
203
263
|
return __awaiter(this, arguments, void 0, function* ({ connection, generalUtility, payer, description, ixs, additionalAlt, }) {
|
|
204
264
|
// Create transaction meta
|
|
@@ -214,7 +274,6 @@ function legacyTxMetadata(_a) {
|
|
|
214
274
|
};
|
|
215
275
|
});
|
|
216
276
|
}
|
|
217
|
-
exports.legacyTxMetadata = legacyTxMetadata;
|
|
218
277
|
/**
|
|
219
278
|
* Generate UserPDA
|
|
220
279
|
*
|
|
@@ -226,7 +285,6 @@ function generateUserPda(userWallet, farm = new web3.PublicKey("7jLQhREMxXjKdpwV
|
|
|
226
285
|
const [pda] = web3.PublicKey.findProgramAddressSync([Buffer.from("multi-user"), farm.toBuffer(), userWallet.toBuffer()], new web3.PublicKey("FqGg2Y1FNxMiGd51Q6UETixQWkF5fB92MysbYogRJb3P"));
|
|
227
286
|
return pda;
|
|
228
287
|
}
|
|
229
|
-
exports.generateUserPda = generateUserPda;
|
|
230
288
|
/**
|
|
231
289
|
* Generate UserPDA Lamport Account
|
|
232
290
|
*
|
|
@@ -239,7 +297,6 @@ function generateUserPdaLamport(userWallet, farm = new web3.PublicKey("7jLQhREMx
|
|
|
239
297
|
const [pda] = web3.PublicKey.findProgramAddressSync([Buffer.from("user-pda-lamport"), userPda.toBuffer()], new web3.PublicKey("FqGg2Y1FNxMiGd51Q6UETixQWkF5fB92MysbYogRJb3P"));
|
|
240
298
|
return pda;
|
|
241
299
|
}
|
|
242
|
-
exports.generateUserPdaLamport = generateUserPdaLamport;
|
|
243
300
|
/**
|
|
244
301
|
* Generate ATA
|
|
245
302
|
*
|
|
@@ -256,7 +313,6 @@ function generateAta(owner, mint, programId = addresses_1.TOKEN_PROGRAM_ID) {
|
|
|
256
313
|
], new web3.PublicKey("ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL"));
|
|
257
314
|
return pda;
|
|
258
315
|
}
|
|
259
|
-
exports.generateAta = generateAta;
|
|
260
316
|
function generateLimitToken(userPda, mint) {
|
|
261
317
|
const [pda] = web3.PublicKey.findProgramAddressSync([
|
|
262
318
|
Buffer.from("limit-token", "utf-8"),
|
|
@@ -265,7 +321,6 @@ function generateLimitToken(userPda, mint) {
|
|
|
265
321
|
], new web3.PublicKey("FqGg2Y1FNxMiGd51Q6UETixQWkF5fB92MysbYogRJb3P"));
|
|
266
322
|
return pda;
|
|
267
323
|
}
|
|
268
|
-
exports.generateLimitToken = generateLimitToken;
|
|
269
324
|
function generateFuelAccount(userWallet) {
|
|
270
325
|
const [pda] = web3.PublicKey.findProgramAddressSync([
|
|
271
326
|
Buffer.from("fuel", "utf-8"),
|
|
@@ -273,16 +328,9 @@ function generateFuelAccount(userWallet) {
|
|
|
273
328
|
], new web3.PublicKey("FqGg2Y1FNxMiGd51Q6UETixQWkF5fB92MysbYogRJb3P"));
|
|
274
329
|
return pda;
|
|
275
330
|
}
|
|
276
|
-
exports.generateFuelAccount = generateFuelAccount;
|
|
277
331
|
function generateAta2022(owner, mint) {
|
|
278
|
-
|
|
279
|
-
owner.toBuffer(),
|
|
280
|
-
addresses_1.TOKEN_2022.toBuffer(),
|
|
281
|
-
mint.toBuffer(),
|
|
282
|
-
], new web3.PublicKey("ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL"));
|
|
283
|
-
return pda;
|
|
332
|
+
return generateAta(owner, mint, addresses_1.TOKEN_2022);
|
|
284
333
|
}
|
|
285
|
-
exports.generateAta2022 = generateAta2022;
|
|
286
334
|
/**
|
|
287
335
|
* Generate Orca Position PDA
|
|
288
336
|
*
|
|
@@ -294,7 +342,6 @@ function generateOrcaPositionPDA(positionMint) {
|
|
|
294
342
|
const [pda] = web3.PublicKey.findProgramAddressSync([Buffer.from("position", "utf-8"), positionMint.toBuffer()], addresses_1.ORCA_WHIRLPOOL_PROGRAM);
|
|
295
343
|
return pda;
|
|
296
344
|
}
|
|
297
|
-
exports.generateOrcaPositionPDA = generateOrcaPositionPDA;
|
|
298
345
|
/**
|
|
299
346
|
* Generate the PDA for the userPda's storage account
|
|
300
347
|
*
|
|
@@ -306,7 +353,6 @@ function generateUserPdaStorageAccount(userPda, mint) {
|
|
|
306
353
|
const [storageAccount] = web3.PublicKey.findProgramAddressSync([Buffer.from("storage-token"), mint.toBuffer(), userPda.toBuffer()], addresses_1.IYF_MAIN);
|
|
307
354
|
return storageAccount;
|
|
308
355
|
}
|
|
309
|
-
exports.generateUserPdaStorageAccount = generateUserPdaStorageAccount;
|
|
310
356
|
/**
|
|
311
357
|
* Convert transaction to instructions
|
|
312
358
|
*
|
|
@@ -327,7 +373,6 @@ function getIxs(txns) {
|
|
|
327
373
|
}
|
|
328
374
|
return ixs;
|
|
329
375
|
}
|
|
330
|
-
exports.getIxs = getIxs;
|
|
331
376
|
/**
|
|
332
377
|
* Check if anchor instruction matches
|
|
333
378
|
*
|
|
@@ -354,7 +399,6 @@ function sighashMatch(data, compareTo, prefix, noSnakeCase, skipDataLengthCheck)
|
|
|
354
399
|
}
|
|
355
400
|
return true;
|
|
356
401
|
}
|
|
357
|
-
exports.sighashMatch = sighashMatch;
|
|
358
402
|
/**
|
|
359
403
|
* Anchor sighash function
|
|
360
404
|
*
|
|
@@ -366,7 +410,6 @@ function sighash(ixName, prefix = "global", noSnakeCase = false) {
|
|
|
366
410
|
const preimage = `${prefix}:${name}`;
|
|
367
411
|
return Buffer.from(js_sha256_1.sha256.digest(preimage)).subarray(0, 8);
|
|
368
412
|
}
|
|
369
|
-
exports.sighash = sighash;
|
|
370
413
|
/**
|
|
371
414
|
* Determine whether given token account exists
|
|
372
415
|
* @param publicKeys
|
|
@@ -398,7 +441,6 @@ function tokenAccountExists(connection, params) {
|
|
|
398
441
|
return result;
|
|
399
442
|
});
|
|
400
443
|
}
|
|
401
|
-
exports.tokenAccountExists = tokenAccountExists;
|
|
402
444
|
/**
|
|
403
445
|
* Decodes a buffer into an object describing the token account.
|
|
404
446
|
* @param data - The buffer containing raw account data.
|
|
@@ -411,7 +453,6 @@ function parseTokenAccountData(data) {
|
|
|
411
453
|
amount: new bn_js_1.default(data.subarray(64, 72), "le"),
|
|
412
454
|
};
|
|
413
455
|
}
|
|
414
|
-
exports.parseTokenAccountData = parseTokenAccountData;
|
|
415
456
|
/**
|
|
416
457
|
* Creates an array of idempotent associated token account creation instructions.
|
|
417
458
|
*
|
|
@@ -444,7 +485,6 @@ function createAtaIdempotentIxs({ accounts, }) {
|
|
|
444
485
|
}
|
|
445
486
|
return result;
|
|
446
487
|
}
|
|
447
|
-
exports.createAtaIdempotentIxs = createAtaIdempotentIxs;
|
|
448
488
|
/**
|
|
449
489
|
* Extracts unique mint addresses from a list of Solana instructions based on specific criteria.
|
|
450
490
|
*
|
|
@@ -496,7 +536,6 @@ function getMintsFromInstruction({ instructions, find, }) {
|
|
|
496
536
|
}
|
|
497
537
|
return result;
|
|
498
538
|
}
|
|
499
|
-
exports.getMintsFromInstruction = getMintsFromInstruction;
|
|
500
539
|
/**
|
|
501
540
|
* Creates instructions to wrap SOL to wSOL if the provided mint matches the wrapped SOL mint.
|
|
502
541
|
*
|
|
@@ -521,7 +560,6 @@ function wrapSolIfMintIsWsol(userWallet, payer, params) {
|
|
|
521
560
|
.map((v) => wrapSolToWsol({ payer, owner: userWallet, amount: v.amount }))
|
|
522
561
|
.flat();
|
|
523
562
|
}
|
|
524
|
-
exports.wrapSolIfMintIsWsol = wrapSolIfMintIsWsol;
|
|
525
563
|
function wrapSolToWsol({ payer, owner, amount, }) {
|
|
526
564
|
const wSolAccount = generateAta(owner, addresses_1.WSOL_MINT);
|
|
527
565
|
// Step 1: Create ATA account IX
|
|
@@ -544,7 +582,6 @@ function wrapSolToWsol({ payer, owner, amount, }) {
|
|
|
544
582
|
// Just return ATA creation
|
|
545
583
|
return [ataIx];
|
|
546
584
|
}
|
|
547
|
-
exports.wrapSolToWsol = wrapSolToWsol;
|
|
548
585
|
/**
|
|
549
586
|
* Creates instructions to unwrap wSOL to SOL if the provided mint matches the wrapped SOL mint.
|
|
550
587
|
*
|
|
@@ -566,7 +603,6 @@ function unwrapSolIfMintIsWsol(userWallet, mints) {
|
|
|
566
603
|
.map(() => unwrapWsolToSol({ authority: userWallet }))
|
|
567
604
|
.flat();
|
|
568
605
|
}
|
|
569
|
-
exports.unwrapSolIfMintIsWsol = unwrapSolIfMintIsWsol;
|
|
570
606
|
function unwrapWsolToSol({ authority, }) {
|
|
571
607
|
const wSolAccount = generateAta(authority, addresses_1.WSOL_MINT);
|
|
572
608
|
// account: PublicKey,
|
|
@@ -579,7 +615,6 @@ function unwrapWsolToSol({ authority, }) {
|
|
|
579
615
|
// Return instructions
|
|
580
616
|
return closeIx;
|
|
581
617
|
}
|
|
582
|
-
exports.unwrapWsolToSol = unwrapWsolToSol;
|
|
583
618
|
/**
|
|
584
619
|
* Checks if token accounts for specified mints exist for a given user wallet.
|
|
585
620
|
*
|
|
@@ -614,7 +649,6 @@ function inputTokenExists(connection, userWallet, mints) {
|
|
|
614
649
|
});
|
|
615
650
|
});
|
|
616
651
|
}
|
|
617
|
-
exports.inputTokenExists = inputTokenExists;
|
|
618
652
|
/**
|
|
619
653
|
* Get Jupiter route ix parameters
|
|
620
654
|
*
|
|
@@ -633,7 +667,6 @@ function getJupiterRouteIxParams(data) {
|
|
|
633
667
|
platformFeeBps,
|
|
634
668
|
};
|
|
635
669
|
}
|
|
636
|
-
exports.getJupiterRouteIxParams = getJupiterRouteIxParams;
|
|
637
670
|
/**
|
|
638
671
|
* Converts tx metadata to versioned transaction
|
|
639
672
|
*
|
|
@@ -650,7 +683,6 @@ function toVersionedTransaction(connection, txMessage) {
|
|
|
650
683
|
return result;
|
|
651
684
|
});
|
|
652
685
|
}
|
|
653
|
-
exports.toVersionedTransaction = toVersionedTransaction;
|
|
654
686
|
function ixStrToWeb3Ix(ix) {
|
|
655
687
|
return {
|
|
656
688
|
keys: ix.accounts.map((account) => {
|
|
@@ -664,7 +696,6 @@ function ixStrToWeb3Ix(ix) {
|
|
|
664
696
|
programId: new web3.PublicKey(ix.programId),
|
|
665
697
|
};
|
|
666
698
|
}
|
|
667
|
-
exports.ixStrToWeb3Ix = ixStrToWeb3Ix;
|
|
668
699
|
function stringToAlt(connection, alts) {
|
|
669
700
|
return __awaiter(this, void 0, void 0, function* () {
|
|
670
701
|
const c = CreateTxMetadata_1.CreateTxMetadata.instance();
|
|
@@ -672,7 +703,6 @@ function stringToAlt(connection, alts) {
|
|
|
672
703
|
return yield c.stringToAlt(alts);
|
|
673
704
|
});
|
|
674
705
|
}
|
|
675
|
-
exports.stringToAlt = stringToAlt;
|
|
676
706
|
let previousHeliusFeeLevels = {
|
|
677
707
|
priorityFeeLevels: {
|
|
678
708
|
high: 9327508,
|
|
@@ -709,7 +739,6 @@ function getPriorityFeeEstimate(priorityLevel, transaction, rpcUrl) {
|
|
|
709
739
|
feeLevels,
|
|
710
740
|
};
|
|
711
741
|
}
|
|
712
|
-
exports.getPriorityFeeEstimate = getPriorityFeeEstimate;
|
|
713
742
|
function getPriorityFeeEstimate2(transaction, options, url) {
|
|
714
743
|
return __awaiter(this, void 0, void 0, function* () {
|
|
715
744
|
const response = yield fetch(url, {
|
|
@@ -731,11 +760,9 @@ function getPriorityFeeEstimate2(transaction, options, url) {
|
|
|
731
760
|
return data.result;
|
|
732
761
|
});
|
|
733
762
|
}
|
|
734
|
-
exports.getPriorityFeeEstimate2 = getPriorityFeeEstimate2;
|
|
735
763
|
function mid(min, max) {
|
|
736
764
|
return min + (max - min) / 2;
|
|
737
765
|
}
|
|
738
|
-
exports.mid = mid;
|
|
739
766
|
/**
|
|
740
767
|
* Find all nonce pubkey owned by given owner and index
|
|
741
768
|
*
|
|
@@ -746,7 +773,6 @@ function generateNonceAddressFromIndex(owner, index) {
|
|
|
746
773
|
return yield web3.PublicKey.createWithSeed(owner, `hs-nonce-${index}`, web3.SystemProgram.programId);
|
|
747
774
|
});
|
|
748
775
|
}
|
|
749
|
-
exports.generateNonceAddressFromIndex = generateNonceAddressFromIndex;
|
|
750
776
|
/**
|
|
751
777
|
* Find all nonce pubkey owned by given owner
|
|
752
778
|
*
|
|
@@ -761,7 +787,6 @@ function generateNonceAddressesOwnedBy(owner, count) {
|
|
|
761
787
|
return nonceAddresses;
|
|
762
788
|
});
|
|
763
789
|
}
|
|
764
|
-
exports.generateNonceAddressesOwnedBy = generateNonceAddressesOwnedBy;
|
|
765
790
|
/**
|
|
766
791
|
* Find all nonce pubkey owned by given owner
|
|
767
792
|
*
|
|
@@ -791,7 +816,6 @@ function findNonceOwnedBy(connection, owner, count) {
|
|
|
791
816
|
return result;
|
|
792
817
|
});
|
|
793
818
|
}
|
|
794
|
-
exports.findNonceOwnedBy = findNonceOwnedBy;
|
|
795
819
|
exports.benchmark = (() => {
|
|
796
820
|
let startTime;
|
|
797
821
|
return ({ end, name, msg }) => {
|
|
@@ -826,7 +850,6 @@ function tokenizer(buffer) {
|
|
|
826
850
|
}
|
|
827
851
|
};
|
|
828
852
|
}
|
|
829
|
-
exports.tokenizer = tokenizer;
|
|
830
853
|
function deserializeParametersFromIDL(idl, instruction, data) {
|
|
831
854
|
const tokens = tokenizer(data);
|
|
832
855
|
const discriminator = tokens.readBuffer(8);
|
|
@@ -844,7 +867,6 @@ function deserializeParametersFromIDL(idl, instruction, data) {
|
|
|
844
867
|
params,
|
|
845
868
|
};
|
|
846
869
|
}
|
|
847
|
-
exports.deserializeParametersFromIDL = deserializeParametersFromIDL;
|
|
848
870
|
function extractValue(idl, type, tokens) {
|
|
849
871
|
if (typeof type === 'object') {
|
|
850
872
|
if (typeof type.option !== 'undefined') {
|
|
@@ -875,7 +897,6 @@ function extractValue(idl, type, tokens) {
|
|
|
875
897
|
throw new Error(`extractValue: Unexpected error: Unexpected type: ${type}, debug: ${tokens.debug()}`);
|
|
876
898
|
}
|
|
877
899
|
}
|
|
878
|
-
exports.extractValue = extractValue;
|
|
879
900
|
function resolveStruct(idl, fields, tokens) {
|
|
880
901
|
const values = [];
|
|
881
902
|
for (let i = 0; i < fields.length; i++) {
|
|
@@ -885,7 +906,6 @@ function resolveStruct(idl, fields, tokens) {
|
|
|
885
906
|
}
|
|
886
907
|
return Buffer.concat(values);
|
|
887
908
|
}
|
|
888
|
-
exports.resolveStruct = resolveStruct;
|
|
889
909
|
function resolveEnum(idl, variants, tokens) {
|
|
890
910
|
let index;
|
|
891
911
|
const values = [];
|
|
@@ -911,7 +931,6 @@ function resolveEnum(idl, variants, tokens) {
|
|
|
911
931
|
}
|
|
912
932
|
return Buffer.concat(values);
|
|
913
933
|
}
|
|
914
|
-
exports.resolveEnum = resolveEnum;
|
|
915
934
|
function resolveOption(idl, type, tokens) {
|
|
916
935
|
const isSet = tokens.readBuffer(1);
|
|
917
936
|
if (isSet[0] === 0) {
|
|
@@ -924,7 +943,6 @@ function resolveOption(idl, type, tokens) {
|
|
|
924
943
|
throw new Error(`resolveOption: Value can only be 1 or 0. Actual value: ${isSet[0]}, debug: ${tokens.debug()}`);
|
|
925
944
|
}
|
|
926
945
|
}
|
|
927
|
-
exports.resolveOption = resolveOption;
|
|
928
946
|
function resolveVec(idl, type, tokens) {
|
|
929
947
|
const vectorSize = tokens.readBuffer(4);
|
|
930
948
|
const size = vectorSize.readUint32LE();
|
|
@@ -935,7 +953,6 @@ function resolveVec(idl, type, tokens) {
|
|
|
935
953
|
}
|
|
936
954
|
return Buffer.concat(values);
|
|
937
955
|
}
|
|
938
|
-
exports.resolveVec = resolveVec;
|
|
939
956
|
function resolveArray(idl, type, tokens) {
|
|
940
957
|
const _type = type[0];
|
|
941
958
|
const count = type[1];
|
|
@@ -959,7 +976,6 @@ function resolveArray(idl, type, tokens) {
|
|
|
959
976
|
}
|
|
960
977
|
return Buffer.concat(values);
|
|
961
978
|
}
|
|
962
|
-
exports.resolveArray = resolveArray;
|
|
963
979
|
function resolveDefined(idl, typeName, tokens) {
|
|
964
980
|
const type = idl.types.find((t) => t.name === typeName);
|
|
965
981
|
if (type === undefined) {
|
|
@@ -975,7 +991,6 @@ function resolveDefined(idl, typeName, tokens) {
|
|
|
975
991
|
throw new Error(`resolveDefined: Unexpected error: Unexpected type: ${type.type.kind}, debug: ${tokens.debug()}`);
|
|
976
992
|
}
|
|
977
993
|
}
|
|
978
|
-
exports.resolveDefined = resolveDefined;
|
|
979
994
|
function extractPrimitives(type, tokens) {
|
|
980
995
|
if (type === 'u8' || type === 'i8' || type === 'bool') {
|
|
981
996
|
return tokens.readBuffer(1);
|
|
@@ -993,7 +1008,6 @@ function extractPrimitives(type, tokens) {
|
|
|
993
1008
|
return tokens.readBuffer(16);
|
|
994
1009
|
}
|
|
995
1010
|
}
|
|
996
|
-
exports.extractPrimitives = extractPrimitives;
|
|
997
1011
|
function simulateTransaction(_a) {
|
|
998
1012
|
return __awaiter(this, arguments, void 0, function* ({ connection, instructions, payerKey, alts, signers, addresses, }) {
|
|
999
1013
|
const testVersionedTxn = new web3.VersionedTransaction(new web3.TransactionMessage({
|
|
@@ -1024,7 +1038,6 @@ function simulateTransaction(_a) {
|
|
|
1024
1038
|
};
|
|
1025
1039
|
});
|
|
1026
1040
|
}
|
|
1027
|
-
exports.simulateTransaction = simulateTransaction;
|
|
1028
1041
|
/**
|
|
1029
1042
|
* Construct a CreateAssociatedTokenAccountIdempotent instruction
|
|
1030
1043
|
*
|
|
@@ -1040,7 +1053,6 @@ exports.simulateTransaction = simulateTransaction;
|
|
|
1040
1053
|
function createAssociatedTokenAccountIdempotentInstruction(payer, associatedToken, owner, mint, programId = addresses_1.TOKEN_PROGRAM_ID, associatedTokenProgramId = addresses_1.ASSOCIATED_TOKEN_PROGRAM) {
|
|
1041
1054
|
return buildAssociatedTokenAccountInstruction(payer, associatedToken, owner, mint, Buffer.from([1]), programId, associatedTokenProgramId);
|
|
1042
1055
|
}
|
|
1043
|
-
exports.createAssociatedTokenAccountIdempotentInstruction = createAssociatedTokenAccountIdempotentInstruction;
|
|
1044
1056
|
function buildAssociatedTokenAccountInstruction(payer, associatedToken, owner, mint, instructionData, programId = addresses_1.TOKEN_PROGRAM_ID, associatedTokenProgramId = addresses_1.ASSOCIATED_TOKEN_PROGRAM) {
|
|
1045
1057
|
const keys = [
|
|
1046
1058
|
{ pubkey: payer, isSigner: true, isWritable: true },
|
|
@@ -1085,7 +1097,6 @@ function raydiumStartTickIndex(tick_index, tick_spacing) {
|
|
|
1085
1097
|
return Math.floor(start_index) * tick_count;
|
|
1086
1098
|
}
|
|
1087
1099
|
}
|
|
1088
|
-
exports.raydiumStartTickIndex = raydiumStartTickIndex;
|
|
1089
1100
|
function i32ToBeBuffer(value) {
|
|
1090
1101
|
// Let's manually convert a number to a buffer (4-bytes)
|
|
1091
1102
|
// Input is signed 32-bit integer
|
|
@@ -1094,7 +1105,6 @@ function i32ToBeBuffer(value) {
|
|
|
1094
1105
|
buffer.writeInt32BE(value, 0);
|
|
1095
1106
|
return buffer;
|
|
1096
1107
|
}
|
|
1097
|
-
exports.i32ToBeBuffer = i32ToBeBuffer;
|
|
1098
1108
|
function findUserAlts(userWallet_1, connection_1) {
|
|
1099
1109
|
return __awaiter(this, arguments, void 0, function* (userWallet, connection, filterDeactivated = true) {
|
|
1100
1110
|
const alts = yield connection.getProgramAccounts(web3.AddressLookupTableProgram.programId, {
|
|
@@ -1114,7 +1124,6 @@ function findUserAlts(userWallet_1, connection_1) {
|
|
|
1114
1124
|
return filterDeactivated ? _alts.filter(alt => alt.isActive()) : _alts;
|
|
1115
1125
|
});
|
|
1116
1126
|
}
|
|
1117
|
-
exports.findUserAlts = findUserAlts;
|
|
1118
1127
|
/**
|
|
1119
1128
|
* Filters the list of pubkeys to only include pubkeys that are in the alt.
|
|
1120
1129
|
*
|
|
@@ -1138,7 +1147,6 @@ function pubkeysInAlt(pubkeys, alt) {
|
|
|
1138
1147
|
});
|
|
1139
1148
|
return pubkeysInAlt;
|
|
1140
1149
|
}
|
|
1141
|
-
exports.pubkeysInAlt = pubkeysInAlt;
|
|
1142
1150
|
/**
|
|
1143
1151
|
* The goal of this function is to batch 100 accounts at a time as it is the max number of accounts that can be fetched at once.
|
|
1144
1152
|
* @param pubkeys - The accounts to fetch.
|
|
@@ -1155,7 +1163,6 @@ function getBatchedMultipleAccountsInfo(connection_1, pubkeys_1) {
|
|
|
1155
1163
|
return batch.flat();
|
|
1156
1164
|
});
|
|
1157
1165
|
}
|
|
1158
|
-
exports.getBatchedMultipleAccountsInfo = getBatchedMultipleAccountsInfo;
|
|
1159
1166
|
function getTokenProgramForMints(connection, mints) {
|
|
1160
1167
|
return __awaiter(this, void 0, void 0, function* () {
|
|
1161
1168
|
const mintCache = yield MintCache_1.MintCache
|
|
@@ -1184,7 +1191,6 @@ function getTokenProgramForMints(connection, mints) {
|
|
|
1184
1191
|
return tokenProgram;
|
|
1185
1192
|
});
|
|
1186
1193
|
}
|
|
1187
|
-
exports.getTokenProgramForMints = getTokenProgramForMints;
|
|
1188
1194
|
function getTokenProgramMapForMints(connection, mints) {
|
|
1189
1195
|
return __awaiter(this, void 0, void 0, function* () {
|
|
1190
1196
|
if (mints.length === 0) {
|
|
@@ -1204,7 +1210,6 @@ function getTokenProgramMapForMints(connection, mints) {
|
|
|
1204
1210
|
return tokenProgramMap;
|
|
1205
1211
|
});
|
|
1206
1212
|
}
|
|
1207
|
-
exports.getTokenProgramMapForMints = getTokenProgramMapForMints;
|
|
1208
1213
|
function getMeteoraStrategyType(strategyType, totalXAmount, totalYAmount) {
|
|
1209
1214
|
let singleSidedX;
|
|
1210
1215
|
const [_strategyType, oneSide] = types_1.StrategyTypeMap2[strategyType];
|
|
@@ -1221,4 +1226,3 @@ function getMeteoraStrategyType(strategyType, totalXAmount, totalYAmount) {
|
|
|
1221
1226
|
}
|
|
1222
1227
|
return [_strategyType, singleSidedX];
|
|
1223
1228
|
}
|
|
1224
|
-
exports.getMeteoraStrategyType = getMeteoraStrategyType;
|
package/dist/src/hawksight.js
CHANGED
|
@@ -15,13 +15,23 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
|
|
|
15
15
|
}) : function(o, v) {
|
|
16
16
|
o["default"] = v;
|
|
17
17
|
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
};
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
25
35
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
26
36
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
27
37
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -32,7 +42,13 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
32
42
|
});
|
|
33
43
|
};
|
|
34
44
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
35
|
-
exports.
|
|
45
|
+
exports.depositMultipleToken = depositMultipleToken;
|
|
46
|
+
exports.depositMultipleTokenV2 = depositMultipleTokenV2;
|
|
47
|
+
exports.withdrawMultipleToken = withdrawMultipleToken;
|
|
48
|
+
exports.withdrawMultipleTokenV2 = withdrawMultipleTokenV2;
|
|
49
|
+
exports.setTransactionSlot = setTransactionSlot;
|
|
50
|
+
exports.verifyTransactionSlot = verifyTransactionSlot;
|
|
51
|
+
exports.storeToken = storeToken;
|
|
36
52
|
const web3 = __importStar(require("@solana/web3.js"));
|
|
37
53
|
const anchor_1 = require("./anchor");
|
|
38
54
|
const addresses_1 = require("./addresses");
|
|
@@ -88,7 +104,6 @@ function depositMultipleToken(params) {
|
|
|
88
104
|
return ix;
|
|
89
105
|
});
|
|
90
106
|
}
|
|
91
|
-
exports.depositMultipleToken = depositMultipleToken;
|
|
92
107
|
function depositMultipleTokenV2(params) {
|
|
93
108
|
return __awaiter(this, void 0, void 0, function* () {
|
|
94
109
|
const farm = addresses_1.USDC_FARM;
|
|
@@ -151,7 +166,6 @@ function depositMultipleTokenV2(params) {
|
|
|
151
166
|
return ix;
|
|
152
167
|
});
|
|
153
168
|
}
|
|
154
|
-
exports.depositMultipleTokenV2 = depositMultipleTokenV2;
|
|
155
169
|
function withdrawMultipleToken(params) {
|
|
156
170
|
return __awaiter(this, void 0, void 0, function* () {
|
|
157
171
|
const farm = addresses_1.USDC_FARM;
|
|
@@ -201,7 +215,6 @@ function withdrawMultipleToken(params) {
|
|
|
201
215
|
return ix;
|
|
202
216
|
});
|
|
203
217
|
}
|
|
204
|
-
exports.withdrawMultipleToken = withdrawMultipleToken;
|
|
205
218
|
function withdrawMultipleTokenV2(params) {
|
|
206
219
|
return __awaiter(this, void 0, void 0, function* () {
|
|
207
220
|
const farm = addresses_1.USDC_FARM;
|
|
@@ -264,7 +277,6 @@ function withdrawMultipleTokenV2(params) {
|
|
|
264
277
|
return ix;
|
|
265
278
|
});
|
|
266
279
|
}
|
|
267
|
-
exports.withdrawMultipleTokenV2 = withdrawMultipleTokenV2;
|
|
268
280
|
function setTransactionSlot(_a) {
|
|
269
281
|
return __awaiter(this, arguments, void 0, function* ({ userWallet }) {
|
|
270
282
|
const ix = yield anchor_1.Anchor
|
|
@@ -278,7 +290,6 @@ function setTransactionSlot(_a) {
|
|
|
278
290
|
return ix;
|
|
279
291
|
});
|
|
280
292
|
}
|
|
281
|
-
exports.setTransactionSlot = setTransactionSlot;
|
|
282
293
|
function verifyTransactionSlot(_a) {
|
|
283
294
|
return __awaiter(this, arguments, void 0, function* ({ userWallet }) {
|
|
284
295
|
const ix = yield anchor_1.Anchor
|
|
@@ -292,7 +303,6 @@ function verifyTransactionSlot(_a) {
|
|
|
292
303
|
return ix;
|
|
293
304
|
});
|
|
294
305
|
}
|
|
295
|
-
exports.verifyTransactionSlot = verifyTransactionSlot;
|
|
296
306
|
function storeToken(connection, params) {
|
|
297
307
|
return __awaiter(this, void 0, void 0, function* () {
|
|
298
308
|
const userPda = util.generateUserPda(params.userWallet);
|
|
@@ -316,4 +326,3 @@ function storeToken(connection, params) {
|
|
|
316
326
|
return ix;
|
|
317
327
|
});
|
|
318
328
|
}
|
|
319
|
-
exports.storeToken = storeToken;
|