@haven-fi/solauto-sdk 1.0.415 → 1.0.417
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/transactions/transactionUtils.js +1 -1
- package/dist/utils/jitoUtils.d.ts +7 -2
- package/dist/utils/jitoUtils.d.ts.map +1 -1
- package/dist/utils/jitoUtils.js +27 -9
- package/dist/utils/jupiterUtils.js +1 -1
- package/local/logPositions.ts +3 -1
- package/package.json +1 -1
- package/src/transactions/transactionUtils.ts +1 -1
- package/src/utils/jitoUtils.ts +36 -11
- package/src/utils/jupiterUtils.ts +1 -1
@@ -431,7 +431,7 @@ async function convertReferralFeesToDestination(referralManager, tokenAccount, d
|
|
431
431
|
let tx = (0, umi_1.transactionBuilder)()
|
432
432
|
.add(setupInstructions)
|
433
433
|
.add((0, generated_1.convertReferralFees)(referralManager.umi, {
|
434
|
-
signer: referralManager.
|
434
|
+
signer: referralManager.signer,
|
435
435
|
intermediaryTa: (0, umi_1.publicKey)((0, accountUtils_1.getTokenAccount)((0, umi_web3js_adapters_1.toWeb3JsPublicKey)(referralManager.umi.identity.publicKey), tokenAccountData.mint)),
|
436
436
|
ixsSysvar: (0, umi_1.publicKey)(web3_js_1.SYSVAR_INSTRUCTIONS_PUBKEY),
|
437
437
|
referralState: (0, umi_1.publicKey)(referralManager.referralState),
|
@@ -1,6 +1,11 @@
|
|
1
|
-
import { Connection, PublicKey } from "@solana/web3.js";
|
1
|
+
import { Connection, PublicKey, VersionedMessage } from "@solana/web3.js";
|
2
2
|
import { Signer, TransactionBuilder, Umi } from "@metaplex-foundation/umi";
|
3
3
|
import { PriorityFeeSetting, TransactionRunType } from "../types";
|
4
|
-
export declare function getRandomTipAccount():
|
4
|
+
export declare function getRandomTipAccount(): PublicKey;
|
5
|
+
export declare function getRequiredSigners(message: VersionedMessage): {
|
6
|
+
index: number;
|
7
|
+
publicKey: string;
|
8
|
+
isWritable: boolean;
|
9
|
+
}[];
|
5
10
|
export declare function sendJitoBundledTransactions(umi: Umi, connection: Connection, signer: Signer, txs: TransactionBuilder[], txType?: TransactionRunType, priorityFeeSetting?: PriorityFeeSetting, onAwaitingSign?: () => void): Promise<string[] | undefined>;
|
6
11
|
//# sourceMappingURL=jitoUtils.d.ts.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"jitoUtils.d.ts","sourceRoot":"","sources":["../../src/utils/jitoUtils.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,UAAU,EACV,SAAS,
|
1
|
+
{"version":3,"file":"jitoUtils.d.ts","sourceRoot":"","sources":["../../src/utils/jitoUtils.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,UAAU,EACV,SAAS,EAGT,gBAAgB,EAEjB,MAAM,iBAAiB,CAAC;AAGzB,OAAO,EACL,MAAM,EACN,kBAAkB,EAClB,GAAG,EAEJ,MAAM,0BAA0B,CAAC;AAQlC,OAAO,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAC;AAMlE,wBAAgB,mBAAmB,IAAI,SAAS,CAa/C;AAqND,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,gBAAgB;;;;IAoB3D;AAED,wBAAsB,2BAA2B,CAC/C,GAAG,EAAE,GAAG,EACR,UAAU,EAAE,UAAU,EACtB,MAAM,EAAE,MAAM,EACd,GAAG,EAAE,kBAAkB,EAAE,EACzB,MAAM,CAAC,EAAE,kBAAkB,EAC3B,kBAAkB,GAAE,kBAA2C,EAC/D,cAAc,CAAC,EAAE,MAAM,IAAI,GAC1B,OAAO,CAAC,MAAM,EAAE,GAAG,SAAS,CAAC,CAkG/B"}
|
package/dist/utils/jitoUtils.js
CHANGED
@@ -4,6 +4,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
4
4
|
};
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
6
6
|
exports.getRandomTipAccount = getRandomTipAccount;
|
7
|
+
exports.getRequiredSigners = getRequiredSigners;
|
7
8
|
exports.sendJitoBundledTransactions = sendJitoBundledTransactions;
|
8
9
|
const web3_js_1 = require("@solana/web3.js");
|
9
10
|
const umi_web3js_adapters_1 = require("@metaplex-foundation/umi-web3js-adapters");
|
@@ -15,7 +16,7 @@ const axios_1 = __importDefault(require("axios"));
|
|
15
16
|
const bs58_1 = __importDefault(require("bs58"));
|
16
17
|
const transactions_1 = require("../types/transactions");
|
17
18
|
const bytes_1 = require("@coral-xyz/anchor/dist/cjs/utils/bytes");
|
18
|
-
|
19
|
+
function getRandomTipAccount() {
|
19
20
|
const tipAccounts = [
|
20
21
|
"96gYZGLnJYVFmbjzopPSU6QiEV5fGqZNyN9nmNhvrZU5",
|
21
22
|
"HFqU5x63VTqvQss8hp11i4wVV8bD44PvwucfZ2bU7gRe",
|
@@ -29,8 +30,8 @@ async function getRandomTipAccount() {
|
|
29
30
|
const randomInt = Math.floor(Math.random() * tipAccounts.length);
|
30
31
|
return new web3_js_1.PublicKey(tipAccounts[randomInt]);
|
31
32
|
}
|
32
|
-
|
33
|
-
return (0, solanaUtils_1.systemTransferUmiIx)(signer,
|
33
|
+
function getTipInstruction(signer, tipLamports) {
|
34
|
+
return (0, solanaUtils_1.systemTransferUmiIx)(signer, getRandomTipAccount(), BigInt(tipLamports));
|
34
35
|
}
|
35
36
|
function parseJitoErrorMessage(message) {
|
36
37
|
const regex = /Error processing Instruction (\d+): custom program error: (0x[0-9A-Fa-f]+|\d+)/;
|
@@ -175,6 +176,23 @@ async function sendJitoBundle(umi, transactions) {
|
|
175
176
|
(0, generalUtils_1.consoleLog)("Bundle ID:", bundleId);
|
176
177
|
return bundleId ? await pollBundleStatus(bundleId) : [];
|
177
178
|
}
|
179
|
+
function getRequiredSigners(message) {
|
180
|
+
const { numRequiredSignatures, numReadonlySignedAccounts } = message.header;
|
181
|
+
// Among the required signers, some are writable and some are read-only.
|
182
|
+
// "numRequiredSignatures - numReadonlySignedAccounts" tells us how many signers are writable.
|
183
|
+
const numWritableSigners = numRequiredSignatures - numReadonlySignedAccounts;
|
184
|
+
const signersInfo = [];
|
185
|
+
for (let i = 0; i < numRequiredSignatures; i++) {
|
186
|
+
const publicKey = message.staticAccountKeys[i].toBase58();
|
187
|
+
const isWritable = i < numWritableSigners;
|
188
|
+
signersInfo.push({
|
189
|
+
index: i,
|
190
|
+
publicKey,
|
191
|
+
isWritable,
|
192
|
+
});
|
193
|
+
}
|
194
|
+
return signersInfo;
|
195
|
+
}
|
178
196
|
async function sendJitoBundledTransactions(umi, connection, signer, txs, txType, priorityFeeSetting = types_1.PriorityFeeSetting.Min, onAwaitingSign) {
|
179
197
|
if (txs.length === 1) {
|
180
198
|
const resp = await (0, solanaUtils_1.sendSingleOptimizedTransaction)(umi, connection, txs[0], txType, priorityFeeSetting, onAwaitingSign);
|
@@ -184,16 +202,12 @@ async function sendJitoBundledTransactions(umi, connection, signer, txs, txType,
|
|
184
202
|
(0, generalUtils_1.consoleLog)("Transactions: ", txs.length);
|
185
203
|
(0, generalUtils_1.consoleLog)(txs.map((tx) => tx.getInstructions().map((x) => x.programId.toString())));
|
186
204
|
(0, generalUtils_1.consoleLog)("Transaction sizes: ", txs.map((x) => x.getTransactionSize(umi)));
|
187
|
-
txs[0] = txs[0].prepend(
|
205
|
+
txs[0] = txs[0].prepend(getTipInstruction(signer, 150000));
|
188
206
|
const feeEstimates = priorityFeeSetting !== types_1.PriorityFeeSetting.None
|
189
207
|
? await Promise.all(txs.map(async (x) => (await (0, solanaUtils_1.getComputeUnitPriceEstimate)(umi, x, priorityFeeSetting, true)) ?? 1000000))
|
190
208
|
: undefined;
|
191
209
|
const latestBlockhash = (await umi.rpc.getLatestBlockhash({ commitment: "confirmed" })).blockhash;
|
192
|
-
|
193
|
-
txs.forEach((tx) => {
|
194
|
-
tx.getSigners(umi).map((x) => x.publicKey.toString());
|
195
|
-
});
|
196
|
-
let builtTxs;
|
210
|
+
let builtTxs = [];
|
197
211
|
let simulationResults;
|
198
212
|
if (txType !== "skip-simulation") {
|
199
213
|
builtTxs = await umiToVersionedTransactions(umi, latestBlockhash, signer, txs, false, feeEstimates);
|
@@ -202,9 +216,13 @@ async function sendJitoBundledTransactions(umi, connection, signer, txs, txType,
|
|
202
216
|
}
|
203
217
|
if (txType !== "only-simulate") {
|
204
218
|
onAwaitingSign?.();
|
219
|
+
console.log("Signers expected:");
|
220
|
+
(0, generalUtils_1.consoleLog)(builtTxs.map((tx) => getRequiredSigners(tx.message)));
|
205
221
|
builtTxs = await umiToVersionedTransactions(umi, latestBlockhash, signer, txs, true, feeEstimates, simulationResults
|
206
222
|
? simulationResults.map((x) => x.unitsConsumed * 1.15)
|
207
223
|
: undefined);
|
224
|
+
console.log("Signers expected:");
|
225
|
+
(0, generalUtils_1.consoleLog)(builtTxs.map((tx) => getRequiredSigners(tx.message)));
|
208
226
|
const serializedTxs = builtTxs.map((x) => x.serialize());
|
209
227
|
if (serializedTxs.find((x) => x.length > 1232)) {
|
210
228
|
throw new Error("A transaction is too large");
|
@@ -35,7 +35,7 @@ async function getJupSwapTransaction(signer, swapDetails, attemptNum) {
|
|
35
35
|
? "ExactIn"
|
36
36
|
: undefined,
|
37
37
|
slippageBps: memecoinSwap ? 500 : 200,
|
38
|
-
maxAccounts: !swapDetails.exactOut ?
|
38
|
+
maxAccounts: !swapDetails.exactOut ? 50 : undefined,
|
39
39
|
}), 4, 200);
|
40
40
|
const priceImpactBps = Math.round((0, numberUtils_1.toBps)(parseFloat(quoteResponse.priceImpactPct))) + 1;
|
41
41
|
const finalPriceSlippageBps = Math.round(Math.max(50, quoteResponse.slippageBps, priceImpactBps) *
|
package/local/logPositions.ts
CHANGED
@@ -14,7 +14,7 @@ import {
|
|
14
14
|
TOKEN_INFO,
|
15
15
|
USD_DECIMALS,
|
16
16
|
} from "../src";
|
17
|
-
import { PublicKey, VersionedTransaction } from "@solana/web3.js";
|
17
|
+
import { PublicKey, SystemProgram, VersionedTransaction } from "@solana/web3.js";
|
18
18
|
import { NATIVE_MINT } from "@solana/spl-token";
|
19
19
|
import { toWeb3JsPublicKey } from "@metaplex-foundation/umi-web3js-adapters";
|
20
20
|
import { fromBaseUnit } from "../dist";
|
@@ -253,3 +253,5 @@ console.log(
|
|
253
253
|
"e6uLxBWUSbPnkYKPWoyoR6YZw7Qt4NnZcabGwaAChdAN4N4GFwvxMxwq3mrxoRM3CDzPHhAh7rbEmzAzyA8pJAhGAaDWfCG3CjnVoWbpdDQvpwUxRffK3xFDGqJeoQvQBvQtZidwaDvDnnkJ6xRgsnpujS65jcGP5AsECsaJ2uRMSsLt8ucynZjQzVw24jqaYRRmUN4otF2mSgbgkXLu9G82g8sfcj3VQuZxoA9Hrpm9kTMNu28R9wRG9yZKCQozSJjL4GGwe3ZMDRdfggbq9xPddNcHFgUGk6PYHgLvVWTr8GSLQpj8HLdtekxdywwXYcK3oS8RNmgrnbm6o7PADSWRYZhAHJLD8G92N5yCnFy8sRGHhMosdgQ5TjF8d5uG92tMfmS67VkjSJqMsX6pZnhnN9K5EFmdZxutaHMuyo5kv9DoXivrCdQrku5yfYbfCPgPY3Ei25tBYN1kTLYXoJvdUuxehjLkR2pVseae2TbApigLAhdvrxGNHLZTncunfp18c2kmWVrwLqc7UPANuKSmNAyy4ntU9nL1zkA9WTxFLsNK5xZukZi8vsK8XoM8f1wyyoiGHPHCF5i2QAat1kwEZ71GdRodeumYb96GwLyskbJJo8g8Yp5oVQhLeKopTSezEgJ3awQCgpd4xqg3rd9ijvRUq5g3aR2NbmrtEZUxumuf5G2RfPK5Nx7MFUuJeT2Pn6LHShsGCzsKt1GewgErWSJMNktBgkJkAyWMQkxt6No8ZSKjDbrnyQEGuuXLKCeMhdFFC6dm8oMgiWC6KLJjzLkG5T4iySKnYcM7pCKtfZLLXXTEGJ8Zz3rqspCGozrwzUGeL86FFqqNNCHFY2Zx2de75krrPo5QfiLMQ1ECgMkLbrmYTx8owsPeM3nDgmMTpooKoVp94GZi22XCda9F3M7HTHrMXsAjNHm7C26VSUbKJCySneNnKzpZ3wP88Kf8qmq6B392k3HdaUyoWXMTaBHKnkzhyMECXSzxbpZPoNa4ra6bscXUSqQijSg2uh6TR7X7hLEmDQKuDTbTVL62oMvw1qgNtsQmkeZFhrumLHj4askbDFzV8ghK15T6GDDnN9gEaFKZU7LbyWscJjdb4RGHy79LCYB2iAg6kJw4efc6p16gqKqnYPBJdXbJjXHKZpUhrJa8YcSwbFWM3YabHNFxwjNHzXJydEg37DpAjjaLVfBhcVCXEBh8K7FcojQ9yT6u3HMjFZwV4fvrBBBSMiNrhvgFVUAQtUaFVmx4BhMvkJTPsR6UrXp4HCPXgohUEUtFEJeyGQPEibBqwgjUpMLWyKUAxjKpYQ3AmdjnseE23njArKaEwrRQA4NnxpUUazzsWJqHymHPJG73GQhQtxNtvfDDMVSj95UkiscssHNEpkt6dqLeohDR1rP2kg41EBGQMNEdeYtUt1JkzdjZBsvU1oV81GG1tEQoSUR1skjq9tWpfoiSPVN9QTQC3kQUgZQQPR9arK5XWqj6y5iPnusQk8zdzoHJt5EFm7aagfLG3uJxdd9ZF7Gk4tMzijx5d1fV1uGhcxAyb5B5m8nkCdap"
|
254
254
|
)
|
255
255
|
);
|
256
|
+
|
257
|
+
console.log(SystemProgram.programId.toString());
|
package/package.json
CHANGED
@@ -808,7 +808,7 @@ export async function convertReferralFeesToDestination(
|
|
808
808
|
.add(setupInstructions)
|
809
809
|
.add(
|
810
810
|
convertReferralFees(referralManager.umi, {
|
811
|
-
signer: referralManager.
|
811
|
+
signer: referralManager.signer,
|
812
812
|
intermediaryTa: publicKey(
|
813
813
|
getTokenAccount(
|
814
814
|
toWeb3JsPublicKey(referralManager.umi.identity.publicKey),
|
package/src/utils/jitoUtils.ts
CHANGED
@@ -3,6 +3,7 @@ import {
|
|
3
3
|
PublicKey,
|
4
4
|
SimulatedTransactionResponse,
|
5
5
|
TransactionExpiredBlockheightExceededError,
|
6
|
+
VersionedMessage,
|
6
7
|
VersionedTransaction,
|
7
8
|
} from "@solana/web3.js";
|
8
9
|
import { toWeb3JsTransaction } from "@metaplex-foundation/umi-web3js-adapters";
|
@@ -26,7 +27,7 @@ import base58 from "bs58";
|
|
26
27
|
import { BundleSimulationError } from "../types/transactions";
|
27
28
|
import { bs58 } from "@coral-xyz/anchor/dist/cjs/utils/bytes";
|
28
29
|
|
29
|
-
export
|
30
|
+
export function getRandomTipAccount(): PublicKey {
|
30
31
|
const tipAccounts = [
|
31
32
|
"96gYZGLnJYVFmbjzopPSU6QiEV5fGqZNyN9nmNhvrZU5",
|
32
33
|
"HFqU5x63VTqvQss8hp11i4wVV8bD44PvwucfZ2bU7gRe",
|
@@ -41,13 +42,13 @@ export async function getRandomTipAccount(): Promise<PublicKey> {
|
|
41
42
|
return new PublicKey(tipAccounts[randomInt]);
|
42
43
|
}
|
43
44
|
|
44
|
-
|
45
|
+
function getTipInstruction(
|
45
46
|
signer: Signer,
|
46
47
|
tipLamports: number
|
47
|
-
):
|
48
|
+
): WrappedInstruction {
|
48
49
|
return systemTransferUmiIx(
|
49
50
|
signer,
|
50
|
-
|
51
|
+
getRandomTipAccount(),
|
51
52
|
BigInt(tipLamports)
|
52
53
|
);
|
53
54
|
}
|
@@ -252,6 +253,28 @@ async function sendJitoBundle(
|
|
252
253
|
return bundleId ? await pollBundleStatus(bundleId) : [];
|
253
254
|
}
|
254
255
|
|
256
|
+
export function getRequiredSigners(message: VersionedMessage) {
|
257
|
+
const { numRequiredSignatures, numReadonlySignedAccounts } = message.header;
|
258
|
+
// Among the required signers, some are writable and some are read-only.
|
259
|
+
// "numRequiredSignatures - numReadonlySignedAccounts" tells us how many signers are writable.
|
260
|
+
|
261
|
+
const numWritableSigners = numRequiredSignatures - numReadonlySignedAccounts;
|
262
|
+
|
263
|
+
const signersInfo = [];
|
264
|
+
for (let i = 0; i < numRequiredSignatures; i++) {
|
265
|
+
const publicKey = message.staticAccountKeys[i].toBase58();
|
266
|
+
const isWritable = i < numWritableSigners;
|
267
|
+
|
268
|
+
signersInfo.push({
|
269
|
+
index: i,
|
270
|
+
publicKey,
|
271
|
+
isWritable,
|
272
|
+
});
|
273
|
+
}
|
274
|
+
|
275
|
+
return signersInfo;
|
276
|
+
}
|
277
|
+
|
255
278
|
export async function sendJitoBundledTransactions(
|
256
279
|
umi: Umi,
|
257
280
|
connection: Connection,
|
@@ -283,7 +306,7 @@ export async function sendJitoBundledTransactions(
|
|
283
306
|
txs.map((x) => x.getTransactionSize(umi))
|
284
307
|
);
|
285
308
|
|
286
|
-
txs[0] = txs[0].prepend(
|
309
|
+
txs[0] = txs[0].prepend(getTipInstruction(signer, 150_000));
|
287
310
|
const feeEstimates =
|
288
311
|
priorityFeeSetting !== PriorityFeeSetting.None
|
289
312
|
? await Promise.all(
|
@@ -303,12 +326,7 @@ export async function sendJitoBundledTransactions(
|
|
303
326
|
await umi.rpc.getLatestBlockhash({ commitment: "confirmed" })
|
304
327
|
).blockhash;
|
305
328
|
|
306
|
-
|
307
|
-
txs.forEach((tx) => {
|
308
|
-
tx.getSigners(umi).map((x) => x.publicKey.toString());
|
309
|
-
});
|
310
|
-
|
311
|
-
let builtTxs: VersionedTransaction[];
|
329
|
+
let builtTxs: VersionedTransaction[] = [];
|
312
330
|
let simulationResults: SimulatedTransactionResponse[] | undefined;
|
313
331
|
if (txType !== "skip-simulation") {
|
314
332
|
builtTxs = await umiToVersionedTransactions(
|
@@ -331,6 +349,10 @@ export async function sendJitoBundledTransactions(
|
|
331
349
|
|
332
350
|
if (txType !== "only-simulate") {
|
333
351
|
onAwaitingSign?.();
|
352
|
+
|
353
|
+
console.log("Signers expected:");
|
354
|
+
consoleLog(builtTxs.map((tx) => getRequiredSigners(tx.message)));
|
355
|
+
|
334
356
|
builtTxs = await umiToVersionedTransactions(
|
335
357
|
umi,
|
336
358
|
latestBlockhash,
|
@@ -343,6 +365,9 @@ export async function sendJitoBundledTransactions(
|
|
343
365
|
: undefined
|
344
366
|
);
|
345
367
|
|
368
|
+
console.log("Signers expected:");
|
369
|
+
consoleLog(builtTxs.map((tx) => getRequiredSigners(tx.message)));
|
370
|
+
|
346
371
|
const serializedTxs = builtTxs.map((x) => x.serialize());
|
347
372
|
if (serializedTxs.find((x) => x.length > 1232)) {
|
348
373
|
throw new Error("A transaction is too large");
|