@clonegod/ttd-sol-common 2.0.24 → 2.0.25
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.
|
@@ -6,5 +6,5 @@ export declare class JitoUtils {
|
|
|
6
6
|
static fetchJitoTipAccounts(): Promise<string[]>;
|
|
7
7
|
}
|
|
8
8
|
export declare const getJitoTipAccount: () => string;
|
|
9
|
-
export declare const sendBundleWithJito: (
|
|
10
|
-
export declare const
|
|
9
|
+
export declare const sendBundleWithJito: (mainTx: Transaction, tipTx: Transaction) => Promise<string>;
|
|
10
|
+
export declare const sendBundleWithJitoMultiIps: (mainTx: Transaction, tipTx: Transaction) => Promise<string>;
|
package/dist/trade/send/jito.js
CHANGED
|
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.
|
|
6
|
+
exports.sendBundleWithJitoMultiIps = exports.sendBundleWithJito = exports.getJitoTipAccount = exports.JitoUtils = exports.JITO_TIP_ACCOUNTS = void 0;
|
|
7
7
|
const axios_1 = __importDefault(require("axios"));
|
|
8
8
|
const http_client_1 = require("./http_client");
|
|
9
9
|
exports.JITO_TIP_ACCOUNTS = [
|
|
@@ -45,7 +45,7 @@ const getJitoTipAccount = () => {
|
|
|
45
45
|
};
|
|
46
46
|
exports.getJitoTipAccount = getJitoTipAccount;
|
|
47
47
|
JitoUtils.init();
|
|
48
|
-
const sendBundleWithJito = async (
|
|
48
|
+
const sendBundleWithJito = async (mainTx, tipTx) => {
|
|
49
49
|
let url = process.env.JITO_SEND_BUNDLE_URL || 'https://tokyo.mainnet.block-engine.jito.wtf/api/v1/bundles';
|
|
50
50
|
const client = (0, http_client_1.getHttpClient)(url);
|
|
51
51
|
const response = await client.post(url, {
|
|
@@ -53,7 +53,7 @@ const sendBundleWithJito = async (signedTransactions) => {
|
|
|
53
53
|
id: 1,
|
|
54
54
|
method: 'sendBundle',
|
|
55
55
|
params: [
|
|
56
|
-
|
|
56
|
+
[tipTx, mainTx].map(tx => Buffer.from(tx.serialize()).toString('base64')),
|
|
57
57
|
{
|
|
58
58
|
"encoding": "base64"
|
|
59
59
|
}
|
|
@@ -62,14 +62,14 @@ const sendBundleWithJito = async (signedTransactions) => {
|
|
|
62
62
|
return response.data.result;
|
|
63
63
|
};
|
|
64
64
|
exports.sendBundleWithJito = sendBundleWithJito;
|
|
65
|
-
const
|
|
65
|
+
const sendBundleWithJitoMultiIps = async (mainTx, tipTx) => {
|
|
66
66
|
let ips = (process.env.JITO_SEND_BUNDLE_PROXY_SERVERS || '127.0.0.1').split(',');
|
|
67
|
-
let urls = ips.map(ip => `http://${ip}:
|
|
67
|
+
let urls = ips.map(ip => `http://${ip}:10429/solana/send_tx`);
|
|
68
68
|
const body = {
|
|
69
69
|
trace_id: '',
|
|
70
|
-
txid: Buffer.from(
|
|
70
|
+
txid: Buffer.from(mainTx.serialize()).toString('base64'),
|
|
71
71
|
encoding: 'base64',
|
|
72
|
-
encoded_tx:
|
|
72
|
+
encoded_tx: [tipTx, mainTx].map(tx => Buffer.from(tx.serialize()).toString('base64')).join(','),
|
|
73
73
|
max_retry: 3
|
|
74
74
|
};
|
|
75
75
|
Promise.all(urls.map(async (url) => {
|
|
@@ -84,4 +84,4 @@ const sendBundleWithJitoByMultiIps = async (signedTransactions) => {
|
|
|
84
84
|
}));
|
|
85
85
|
return 'success';
|
|
86
86
|
};
|
|
87
|
-
exports.
|
|
87
|
+
exports.sendBundleWithJitoMultiIps = sendBundleWithJitoMultiIps;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Transaction } from '@solana/web3.js';
|
|
2
2
|
export declare class TransactionSender {
|
|
3
3
|
constructor();
|
|
4
|
-
sendTransaction(
|
|
5
|
-
sendBundle(
|
|
4
|
+
sendTransaction(singedTransaction: Transaction, swqos_only: boolean): Promise<string>;
|
|
5
|
+
sendBundle(mainTx: Transaction, tipTx: Transaction, use_multi_ips?: boolean): Promise<string>;
|
|
6
6
|
}
|
|
@@ -6,16 +6,16 @@ const jito_1 = require("./jito");
|
|
|
6
6
|
class TransactionSender {
|
|
7
7
|
constructor() {
|
|
8
8
|
}
|
|
9
|
-
async sendTransaction(
|
|
10
|
-
|
|
11
|
-
|
|
9
|
+
async sendTransaction(singedTransaction, swqos_only) {
|
|
10
|
+
return await (0, helius_1.sendTxWithHelius)(singedTransaction, swqos_only);
|
|
11
|
+
}
|
|
12
|
+
async sendBundle(mainTx, tipTx, use_multi_ips = false) {
|
|
13
|
+
if (use_multi_ips) {
|
|
14
|
+
return await (0, jito_1.sendBundleWithJitoMultiIps)(mainTx, tipTx);
|
|
12
15
|
}
|
|
13
16
|
else {
|
|
14
|
-
return await
|
|
17
|
+
return await (0, jito_1.sendBundleWithJito)(mainTx, tipTx);
|
|
15
18
|
}
|
|
16
19
|
}
|
|
17
|
-
async sendBundle(signedTransactions) {
|
|
18
|
-
return await (0, jito_1.sendBundleWithJito)(signedTransactions);
|
|
19
|
-
}
|
|
20
20
|
}
|
|
21
21
|
exports.TransactionSender = TransactionSender;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@clonegod/ttd-sol-common",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.25",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "types/index.d.ts",
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
"push": "npm run build && npm publish"
|
|
14
14
|
},
|
|
15
15
|
"dependencies": {
|
|
16
|
-
"@clonegod/ttd-core": "2.1.
|
|
16
|
+
"@clonegod/ttd-core": "2.1.6",
|
|
17
17
|
"@solana/web3.js": "1.91.6",
|
|
18
18
|
"rpc-websockets": "7.10.0",
|
|
19
19
|
"axios": "^1.2.3",
|
package/src/trade/send/jito.ts
CHANGED
|
@@ -48,7 +48,7 @@ JitoUtils.init()
|
|
|
48
48
|
|
|
49
49
|
// -----------------------------------------------------------
|
|
50
50
|
|
|
51
|
-
export const sendBundleWithJito = async (
|
|
51
|
+
export const sendBundleWithJito = async (mainTx: Transaction, tipTx: Transaction): Promise<string> => {
|
|
52
52
|
let url = process.env.JITO_SEND_BUNDLE_URL || 'https://tokyo.mainnet.block-engine.jito.wtf/api/v1/bundles'
|
|
53
53
|
|
|
54
54
|
// 使用共享的 axios 实例,复用连接池
|
|
@@ -58,7 +58,7 @@ export const sendBundleWithJito = async (signedTransactions: Transaction[]): Pro
|
|
|
58
58
|
id: 1,
|
|
59
59
|
method: 'sendBundle',
|
|
60
60
|
params: [
|
|
61
|
-
|
|
61
|
+
[tipTx, mainTx].map(tx => Buffer.from(tx.serialize()).toString('base64')),
|
|
62
62
|
{
|
|
63
63
|
"encoding": "base64"
|
|
64
64
|
}
|
|
@@ -76,15 +76,15 @@ export const sendBundleWithJito = async (signedTransactions: Transaction[]): Pro
|
|
|
76
76
|
}
|
|
77
77
|
|
|
78
78
|
|
|
79
|
-
export const
|
|
79
|
+
export const sendBundleWithJitoMultiIps = async (mainTx: Transaction, tipTx: Transaction): Promise<string> => {
|
|
80
80
|
let ips = (process.env.JITO_SEND_BUNDLE_PROXY_SERVERS || '127.0.0.1').split(',')
|
|
81
|
-
let urls = ips.map(ip => `http://${ip}:
|
|
81
|
+
let urls = ips.map(ip => `http://${ip}:10429/solana/send_tx`)
|
|
82
82
|
|
|
83
83
|
const body = {
|
|
84
84
|
trace_id: '',
|
|
85
|
-
txid: Buffer.from(
|
|
85
|
+
txid: Buffer.from(mainTx.serialize()).toString('base64'),
|
|
86
86
|
encoding: 'base64', // base64
|
|
87
|
-
encoded_tx:
|
|
87
|
+
encoded_tx: [tipTx, mainTx].map(tx => Buffer.from(tx.serialize()).toString('base64')).join(','), // main tx
|
|
88
88
|
max_retry: 3
|
|
89
89
|
}
|
|
90
90
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Transaction } from '@solana/web3.js';
|
|
2
2
|
import { sendTxWithHelius } from './helius';
|
|
3
|
-
import { sendBundleWithJito } from './jito';
|
|
3
|
+
import { sendBundleWithJito, sendBundleWithJitoMultiIps } from './jito';
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
/**
|
|
@@ -11,16 +11,16 @@ export class TransactionSender {
|
|
|
11
11
|
constructor() {
|
|
12
12
|
}
|
|
13
13
|
|
|
14
|
-
async sendTransaction(
|
|
15
|
-
|
|
16
|
-
return await sendTxWithHelius(singedTransactions[0], swqos_only)
|
|
17
|
-
} else {
|
|
18
|
-
return await this.sendBundle(singedTransactions)
|
|
19
|
-
}
|
|
14
|
+
async sendTransaction(singedTransaction: Transaction, swqos_only:boolean): Promise<string> {
|
|
15
|
+
return await sendTxWithHelius(singedTransaction, swqos_only)
|
|
20
16
|
}
|
|
21
17
|
|
|
22
|
-
async sendBundle(
|
|
23
|
-
|
|
18
|
+
async sendBundle(mainTx: Transaction, tipTx:Transaction, use_multi_ips: boolean=false): Promise<string> {
|
|
19
|
+
if(use_multi_ips) {
|
|
20
|
+
return await sendBundleWithJitoMultiIps(mainTx, tipTx)
|
|
21
|
+
} else {
|
|
22
|
+
return await sendBundleWithJito(mainTx, tipTx)
|
|
23
|
+
}
|
|
24
24
|
}
|
|
25
25
|
|
|
26
26
|
}
|