sol-ihor-lab 1.0.3 → 1.0.5
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/lib/cjs/global.d.ts +0 -1
- package/lib/cjs/index.js +0 -1
- package/lib/cjs/transaction/execute-rpc.js +0 -2
- package/lib/cjs/transaction/transaction-exectue.js +0 -2
- package/lib/cjs/utils/util.js +0 -1
- package/lib/esm/index.d.ts +0 -1
- package/lib/esm/index.js +0 -1
- package/lib/esm/transaction/bundle.js +0 -2
- package/lib/esm/transaction/execute-rpc.js +0 -2
- package/lib/esm/transaction/transaction-exectue.js +0 -2
- package/package.json +1 -1
- package/src/transaction/execute-rpc.ts +0 -2
- package/src/transaction/transaction-exectue.ts +1 -11
- package/src/transaction/bundle.ts +0 -116
package/lib/cjs/global.d.ts
CHANGED
|
@@ -49,7 +49,6 @@ export declare class EnvironmentManager {
|
|
|
49
49
|
static getRpcNetUrl(): string;
|
|
50
50
|
static setNetUrls(main_url: string, dev_url: string, test_url?: string): void;
|
|
51
51
|
static getBundlrUrl(): string;
|
|
52
|
-
static getCheckUrl(): string;
|
|
53
52
|
static getProgramID(): ProgramId;
|
|
54
53
|
static setQuoteTokenInfo(token_info: TOKEN_INFO): void;
|
|
55
54
|
static getQuoteTokenInfo(): TOKEN_INFO;
|
package/lib/cjs/index.js
CHANGED
|
@@ -21,7 +21,6 @@ __exportStar(require("./instructions/createATA-instruction"), exports);
|
|
|
21
21
|
__exportStar(require("./instructions/sol-transfer-instruction"), exports);
|
|
22
22
|
__exportStar(require("./instructions/transfer-instruction"), exports);
|
|
23
23
|
__exportStar(require("./transaction/execute-rpc"), exports);
|
|
24
|
-
__exportStar(require("./transaction/sign-tx"), exports);
|
|
25
24
|
__exportStar(require("./transaction/transaction-exectue"), exports);
|
|
26
25
|
__exportStar(require("./utils/budget"), exports);
|
|
27
26
|
__exportStar(require("./utils/error-helper"), exports);
|
|
@@ -10,13 +10,11 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
exports.confirmTx = exports.sendTx = void 0;
|
|
13
|
-
const sign_tx_1 = require("./sign-tx");
|
|
14
13
|
const errors_1 = require("../errors");
|
|
15
14
|
function sendTx(connection, tx, option) {
|
|
16
15
|
return __awaiter(this, void 0, void 0, function* () {
|
|
17
16
|
try {
|
|
18
17
|
tx.txn.message.recentBlockhash = (yield connection.getLatestBlockhash("finalized")).blockhash;
|
|
19
|
-
(0, sign_tx_1.signTransaction)(tx);
|
|
20
18
|
return yield connection.sendTransaction(tx.txn, option);
|
|
21
19
|
}
|
|
22
20
|
catch (error) {
|
|
@@ -13,7 +13,6 @@ exports.TransactionExecuter = exports.ExectuerStatus = void 0;
|
|
|
13
13
|
const errors_1 = require("../errors");
|
|
14
14
|
const budget_1 = require("../utils/budget");
|
|
15
15
|
const execute_rpc_1 = require("./execute-rpc");
|
|
16
|
-
const bundle_1 = require("./bundle");
|
|
17
16
|
var ExectuerStatus;
|
|
18
17
|
(function (ExectuerStatus) {
|
|
19
18
|
ExectuerStatus[ExectuerStatus["EXE_STATUS_NONE"] = 0] = "EXE_STATUS_NONE";
|
|
@@ -65,7 +64,6 @@ class TransactionExecuter {
|
|
|
65
64
|
return __awaiter(this, void 0, void 0, function* () {
|
|
66
65
|
try {
|
|
67
66
|
this.setExecuterStatus(ExectuerStatus.EXE_STATUS_RUN);
|
|
68
|
-
yield (0, bundle_1.createAndSendBundle)(this.connection, this.transactions, this.jitoFeepair, this.jitoBlockEngine, this.jitoAuther, this.jitoFee);
|
|
69
67
|
this.setExecuterError(undefined);
|
|
70
68
|
this.setExecuterStatus(ExectuerStatus.EXE_STATUS_END);
|
|
71
69
|
}
|
package/lib/cjs/utils/util.js
CHANGED
|
@@ -22,7 +22,6 @@ const { compileInstToVersioned } = require('../instructions/build-instruction')
|
|
|
22
22
|
const { getCreateAccountTransactionInst } = require('../instructions/createATA-instruction')
|
|
23
23
|
const { generateBuyInst } = require('../instructions/buy-instruction')
|
|
24
24
|
const { TransactionExecuter, ExectuerStatus } = require('../transaction/transaction-exectue')
|
|
25
|
-
const { signTransaction } = require('../transaction/sign-tx')
|
|
26
25
|
const { TOKEN_PROGRAM_ID, Token, TokenAmount, ONE,
|
|
27
26
|
jsonInfo2PoolKeys, LiquidityPoolKeys } = require("@raydium-io/raydium-sdk");
|
|
28
27
|
const { getATAAddress, xWeiAmount } = require('./get-balance')
|
package/lib/esm/index.d.ts
CHANGED
|
@@ -8,7 +8,6 @@ export * from "./instructions/transfer-instruction";
|
|
|
8
8
|
export * from "./pool/pool-manager";
|
|
9
9
|
export * from "./transaction/bundle";
|
|
10
10
|
export * from "./transaction/execute-rpc";
|
|
11
|
-
export * from "./transaction/sign-tx";
|
|
12
11
|
export * from "./transaction/transaction-exectue";
|
|
13
12
|
export * from "./utils/budget";
|
|
14
13
|
export * from "./utils/error-helper";
|
package/lib/esm/index.js
CHANGED
|
@@ -8,7 +8,6 @@ export * from "./instructions/transfer-instruction";
|
|
|
8
8
|
export * from "./pool/pool-manager";
|
|
9
9
|
export * from "./transaction/bundle";
|
|
10
10
|
export * from "./transaction/execute-rpc";
|
|
11
|
-
export * from "./transaction/sign-tx";
|
|
12
11
|
export * from "./transaction/transaction-exectue";
|
|
13
12
|
export * from "./utils/budget";
|
|
14
13
|
export * from "./utils/error-helper";
|
|
@@ -13,7 +13,6 @@ import { Bundle } from "jito-ts/dist/sdk/block-engine/types";
|
|
|
13
13
|
import base58 from "bs58";
|
|
14
14
|
import { TransactionExecuteError } from "../errors";
|
|
15
15
|
import { sleep } from "../utils/util";
|
|
16
|
-
import { signTransaction } from "./sign-tx";
|
|
17
16
|
export function createAndSendBundle(connection, bundleTranasction, payer, jitoBlockEngine, jitoAuther, fee) {
|
|
18
17
|
return __awaiter(this, void 0, void 0, function* () {
|
|
19
18
|
const searcher = searcherClient(jitoBlockEngine, jitoAuther);
|
|
@@ -25,7 +24,6 @@ export function createAndSendBundle(connection, bundleTranasction, payer, jitoBl
|
|
|
25
24
|
const realForBundle = [];
|
|
26
25
|
for (let i = 0; i < bundleTranasction.length; i++) {
|
|
27
26
|
bundleTranasction[i].txn.message.recentBlockhash = (yield connection.getLatestBlockhash("finalized")).blockhash;
|
|
28
|
-
signTransaction(bundleTranasction[i]);
|
|
29
27
|
realForBundle.push(bundleTranasction[i].txn);
|
|
30
28
|
}
|
|
31
29
|
let bundleTx = new Bundle(realForBundle, 5);
|
|
@@ -7,13 +7,11 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
7
7
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
8
|
});
|
|
9
9
|
};
|
|
10
|
-
import { signTransaction } from "./sign-tx";
|
|
11
10
|
import { TransactionExecuteError } from "../errors";
|
|
12
11
|
export function sendTx(connection, tx, option) {
|
|
13
12
|
return __awaiter(this, void 0, void 0, function* () {
|
|
14
13
|
try {
|
|
15
14
|
tx.txn.message.recentBlockhash = (yield connection.getLatestBlockhash("finalized")).blockhash;
|
|
16
|
-
signTransaction(tx);
|
|
17
15
|
return yield connection.sendTransaction(tx.txn, option);
|
|
18
16
|
}
|
|
19
17
|
catch (error) {
|
|
@@ -10,7 +10,6 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
10
10
|
import { TransactionExecuteError } from "../errors";
|
|
11
11
|
import { setTransactionBudget } from "../utils/budget";
|
|
12
12
|
import { confirmTx, sendTx } from "./execute-rpc";
|
|
13
|
-
import { createAndSendBundle } from "./bundle";
|
|
14
13
|
export var ExectuerStatus;
|
|
15
14
|
(function (ExectuerStatus) {
|
|
16
15
|
ExectuerStatus[ExectuerStatus["EXE_STATUS_NONE"] = 0] = "EXE_STATUS_NONE";
|
|
@@ -62,7 +61,6 @@ export class TransactionExecuter {
|
|
|
62
61
|
return __awaiter(this, void 0, void 0, function* () {
|
|
63
62
|
try {
|
|
64
63
|
this.setExecuterStatus(ExectuerStatus.EXE_STATUS_RUN);
|
|
65
|
-
yield createAndSendBundle(this.connection, this.transactions, this.jitoFeepair, this.jitoBlockEngine, this.jitoAuther, this.jitoFee);
|
|
66
64
|
this.setExecuterError(undefined);
|
|
67
65
|
this.setExecuterStatus(ExectuerStatus.EXE_STATUS_END);
|
|
68
66
|
}
|
package/package.json
CHANGED
|
@@ -4,7 +4,6 @@ import {
|
|
|
4
4
|
TransactionConfirmationStrategy
|
|
5
5
|
} from "@solana/web3.js";
|
|
6
6
|
import { TransactionInfo } from "../instructions/build-instruction";
|
|
7
|
-
import { signTransaction } from "./sign-tx";
|
|
8
7
|
import { TransactionExecuteError } from "../errors";
|
|
9
8
|
|
|
10
9
|
export async function sendTx(
|
|
@@ -16,7 +15,6 @@ export async function sendTx(
|
|
|
16
15
|
tx.txn.message.recentBlockhash = (
|
|
17
16
|
await connection.getLatestBlockhash("finalized")
|
|
18
17
|
).blockhash;
|
|
19
|
-
signTransaction(tx);
|
|
20
18
|
return await connection.sendTransaction(tx.txn, option);
|
|
21
19
|
} catch (error) {
|
|
22
20
|
throw new TransactionExecuteError(`sendTx: ${error}`);
|
|
@@ -3,8 +3,6 @@ import { TransactionInfo } from "../instructions/build-instruction";
|
|
|
3
3
|
import { TransactionExecuteError } from "../errors";
|
|
4
4
|
import { setTransactionBudget } from "../utils/budget";
|
|
5
5
|
import { confirmTx, sendTx } from "./execute-rpc";
|
|
6
|
-
import { createAndSendBundle } from "./bundle";
|
|
7
|
-
import { connect } from "http2";
|
|
8
6
|
|
|
9
7
|
export enum ExectuerStatus {
|
|
10
8
|
EXE_STATUS_NONE,
|
|
@@ -73,15 +71,7 @@ export class TransactionExecuter {
|
|
|
73
71
|
|
|
74
72
|
public async executeBundle() {
|
|
75
73
|
try {
|
|
76
|
-
this.setExecuterStatus(ExectuerStatus.EXE_STATUS_RUN);
|
|
77
|
-
await createAndSendBundle(
|
|
78
|
-
this.connection,
|
|
79
|
-
this.transactions,
|
|
80
|
-
this.jitoFeepair!,
|
|
81
|
-
this.jitoBlockEngine!,
|
|
82
|
-
this.jitoAuther!,
|
|
83
|
-
this.jitoFee
|
|
84
|
-
);
|
|
74
|
+
this.setExecuterStatus(ExectuerStatus.EXE_STATUS_RUN);
|
|
85
75
|
this.setExecuterError(undefined);
|
|
86
76
|
this.setExecuterStatus(ExectuerStatus.EXE_STATUS_END);
|
|
87
77
|
} catch (error) {
|
|
@@ -1,116 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
Connection,
|
|
3
|
-
Keypair,
|
|
4
|
-
LAMPORTS_PER_SOL,
|
|
5
|
-
PublicKey
|
|
6
|
-
} from "@solana/web3.js";
|
|
7
|
-
import { TransactionInfo } from "../instructions/build-instruction";
|
|
8
|
-
import { searcherClient } from "jito-ts/dist/sdk/block-engine/searcher";
|
|
9
|
-
import { Bundle } from "jito-ts/dist/sdk/block-engine/types";
|
|
10
|
-
import base58 from "bs58";
|
|
11
|
-
import { TransactionExecuteError } from "../errors";
|
|
12
|
-
import { sleep } from "../utils/util";
|
|
13
|
-
import { signTransaction } from "./sign-tx";
|
|
14
|
-
|
|
15
|
-
export async function createAndSendBundle(
|
|
16
|
-
connection: Connection,
|
|
17
|
-
bundleTranasction: TransactionInfo[],
|
|
18
|
-
payer: Keypair,
|
|
19
|
-
jitoBlockEngine: string,
|
|
20
|
-
jitoAuther: Keypair,
|
|
21
|
-
fee: number
|
|
22
|
-
) {
|
|
23
|
-
const searcher = searcherClient(jitoBlockEngine, jitoAuther);
|
|
24
|
-
|
|
25
|
-
let txnConfirmResult: boolean = false;
|
|
26
|
-
let breakCheckTransactionStatus: boolean = false;
|
|
27
|
-
|
|
28
|
-
try {
|
|
29
|
-
const blockhash = (await connection.getLatestBlockhash("finalized"))
|
|
30
|
-
.blockhash;
|
|
31
|
-
const realForBundle: any[] = [];
|
|
32
|
-
for (let i = 0; i < bundleTranasction.length; i++) {
|
|
33
|
-
bundleTranasction[i].txn.message.recentBlockhash = (
|
|
34
|
-
await connection.getLatestBlockhash("finalized")
|
|
35
|
-
).blockhash;
|
|
36
|
-
signTransaction(bundleTranasction[i]);
|
|
37
|
-
realForBundle.push(bundleTranasction[i].txn);
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
let bundleTx = new Bundle(realForBundle, 5);
|
|
41
|
-
if (payer) {
|
|
42
|
-
const tipAccount = new PublicKey((await searcher.getTipAccounts())[0]);
|
|
43
|
-
bundleTx.addTipTx(payer, fee * LAMPORTS_PER_SOL, tipAccount, blockhash);
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
searcher.onBundleResult(
|
|
47
|
-
async (bundleResult: any) => {
|
|
48
|
-
console.log(bundleResult);
|
|
49
|
-
|
|
50
|
-
if (bundleResult.rejected) {
|
|
51
|
-
try {
|
|
52
|
-
if (
|
|
53
|
-
bundleResult.rejected.simulationFailure.msg.includes(
|
|
54
|
-
"custom program error"
|
|
55
|
-
) ||
|
|
56
|
-
bundleResult.rejected.simulationFailure.msg.includes(
|
|
57
|
-
"Error processing Instruction"
|
|
58
|
-
)
|
|
59
|
-
) {
|
|
60
|
-
breakCheckTransactionStatus = true;
|
|
61
|
-
} else if (
|
|
62
|
-
bundleResult.rejected.simulationFailure.msg.includes(
|
|
63
|
-
"This transaction has already been processed"
|
|
64
|
-
) ||
|
|
65
|
-
bundleResult.rejected.droppedBundle.msg.includes(
|
|
66
|
-
"Bundle partially processed"
|
|
67
|
-
)
|
|
68
|
-
) {
|
|
69
|
-
txnConfirmResult = true;
|
|
70
|
-
breakCheckTransactionStatus = true;
|
|
71
|
-
}
|
|
72
|
-
} catch (error) {}
|
|
73
|
-
}
|
|
74
|
-
},
|
|
75
|
-
(error) => {
|
|
76
|
-
breakCheckTransactionStatus = false;
|
|
77
|
-
}
|
|
78
|
-
);
|
|
79
|
-
|
|
80
|
-
console.log("Send");
|
|
81
|
-
await searcher.sendBundle(bundleTx);
|
|
82
|
-
console.log("Finish send");
|
|
83
|
-
setTimeout(() => {
|
|
84
|
-
breakCheckTransactionStatus = true;
|
|
85
|
-
}, 20000);
|
|
86
|
-
|
|
87
|
-
const txnHash = base58.encode(
|
|
88
|
-
realForBundle[realForBundle.length - 1].signatures[0]
|
|
89
|
-
);
|
|
90
|
-
|
|
91
|
-
console.log(txnHash);
|
|
92
|
-
while (!breakCheckTransactionStatus) {
|
|
93
|
-
await sleep(1000);
|
|
94
|
-
try {
|
|
95
|
-
const result = await connection.getSignatureStatus(txnHash, {
|
|
96
|
-
searchTransactionHistory: true
|
|
97
|
-
});
|
|
98
|
-
if (result && result.value && result.value.confirmationStatus) {
|
|
99
|
-
txnConfirmResult = true;
|
|
100
|
-
breakCheckTransactionStatus = true;
|
|
101
|
-
}
|
|
102
|
-
} catch (error) {
|
|
103
|
-
txnConfirmResult = false;
|
|
104
|
-
breakCheckTransactionStatus = false;
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
if (txnConfirmResult) {
|
|
109
|
-
return true;
|
|
110
|
-
} else {
|
|
111
|
-
throw new TransactionExecuteError(`Bundle Error: failed`);
|
|
112
|
-
}
|
|
113
|
-
} catch (error) {
|
|
114
|
-
throw new TransactionExecuteError(`Bundle Error: ${error}`);
|
|
115
|
-
}
|
|
116
|
-
}
|