@clonegod/ttd-sol-common 1.0.193 → 1.1.0
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.
|
@@ -45,6 +45,7 @@ export declare class RpcClient {
|
|
|
45
45
|
sendJitoBundle(serializedTransactions: string[], encoding: string, jitoApiUrl: string): Promise<string>;
|
|
46
46
|
getBundleStatuses(bundleIds: string[], jitoApiUrl: string): Promise<any>;
|
|
47
47
|
sendSmartTransactionWithTip(solana_trade_runtime: SolanaTradeRuntimeType, instructions: TransactionInstruction[], signers: Signer[], lookupTables?: AddressLookupTableAccount[], tipAmount?: number, region?: JitoRegion, feePayer?: Signer, lastValidBlockHeightOffset?: number): Promise<string>;
|
|
48
|
+
send_jup_ag_tx_by_jito(solana_trade_runtime: SolanaTradeRuntimeType, transaction: VersionedTransaction, tipAmount?: number, region?: JitoRegion): Promise<string>;
|
|
48
49
|
getNftEditions(params: DAS.GetNftEditionsRequest): Promise<DAS.GetNftEditionsResponse>;
|
|
49
50
|
getTokenAccounts(params: DAS.GetTokenAccountsRequest): Promise<DAS.GetTokenAccountsResponse>;
|
|
50
51
|
sendTransaction(transaction: Transaction | VersionedTransaction, options?: HeliusSendOptions): Promise<TransactionSignature>;
|
|
@@ -641,6 +641,59 @@ class RpcClient {
|
|
|
641
641
|
return txid;
|
|
642
642
|
});
|
|
643
643
|
}
|
|
644
|
+
send_jup_ag_tx_by_jito(solana_trade_runtime_1, transaction_1) {
|
|
645
|
+
return __awaiter(this, arguments, void 0, function* (solana_trade_runtime, transaction, tipAmount = 1000, region = 'Default') {
|
|
646
|
+
let txid = (0, get_signature_1.getSignature)(transaction);
|
|
647
|
+
setTimeout(() => __awaiter(this, void 0, void 0, function* () {
|
|
648
|
+
let block_offset = solana_trade_runtime.settings.strategy.block_offset;
|
|
649
|
+
if (isNaN(block_offset) || block_offset < 0) {
|
|
650
|
+
throw new Error('block_offset must be a positive integer');
|
|
651
|
+
}
|
|
652
|
+
let blockhash_by_slot_offset = yield this.getBlockhashBySlotOffset(block_offset);
|
|
653
|
+
let blockhash = blockhash_by_slot_offset.value.blockhash;
|
|
654
|
+
const encoding = 'base64';
|
|
655
|
+
const serializedMainTx = Buffer.from(transaction.serialize()).toString(encoding);
|
|
656
|
+
let jito_region = process.env.JITO_REGION || region;
|
|
657
|
+
let jitoApiUrl = `${types_1.JITO_API_URLS[jito_region]}/api/v1/bundles`;
|
|
658
|
+
const send_tx_jito_url = process.env.SEND_TX_JITO_URL || '';
|
|
659
|
+
const send_tx_jito_stratgy = process.env.SEND_TX_JITO_STRATEGY || '';
|
|
660
|
+
if (!(0, dist_1.isEmpty)(send_tx_jito_url) && send_tx_jito_stratgy === 'mul_ips') {
|
|
661
|
+
let { jito_use_separate_tx } = solana_trade_runtime;
|
|
662
|
+
let group_id = solana_trade_runtime.group.id;
|
|
663
|
+
let recent_blockhash = blockhash;
|
|
664
|
+
let encoded_tx = serializedMainTx;
|
|
665
|
+
if (jito_use_separate_tx) {
|
|
666
|
+
let serializedTipTx = (yield axios_1.default.get(`${process.env.JITO_CREATE_TIP_TX_URL}?group_id=${group_id}&blockhash=${recent_blockhash}&encoding=${encoding}&tip_amount=${tipAmount}`)).data.data;
|
|
667
|
+
encoded_tx = [
|
|
668
|
+
serializedMainTx,
|
|
669
|
+
serializedTipTx
|
|
670
|
+
].join(',');
|
|
671
|
+
}
|
|
672
|
+
const send_result = yield (0, dist_1.postJSON)(send_tx_jito_url, {
|
|
673
|
+
encoding,
|
|
674
|
+
encoded_tx,
|
|
675
|
+
txid,
|
|
676
|
+
trace_id: '',
|
|
677
|
+
group_id
|
|
678
|
+
});
|
|
679
|
+
(0, dist_1.log_info)(`sendJitoBundle (mul_ips)`, {
|
|
680
|
+
txid,
|
|
681
|
+
jito_use_separate_tx,
|
|
682
|
+
send_result
|
|
683
|
+
});
|
|
684
|
+
return;
|
|
685
|
+
}
|
|
686
|
+
let bundleId = yield this.sendJitoBundle([serializedMainTx], encoding, jitoApiUrl);
|
|
687
|
+
(0, dist_1.log_info)(`sendJitoBundle`, {
|
|
688
|
+
txid,
|
|
689
|
+
jitoApiUrl,
|
|
690
|
+
encoding,
|
|
691
|
+
bundleId
|
|
692
|
+
});
|
|
693
|
+
}), 0);
|
|
694
|
+
return txid;
|
|
695
|
+
});
|
|
696
|
+
}
|
|
644
697
|
getNftEditions(params) {
|
|
645
698
|
return __awaiter(this, void 0, void 0, function* () {
|
|
646
699
|
try {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AddressLookupTableAccount, SendOptions, Signer, TransactionInstruction } from "@solana/web3.js";
|
|
1
|
+
import { AddressLookupTableAccount, SendOptions, Signer, TransactionInstruction, VersionedTransaction } from "@solana/web3.js";
|
|
2
2
|
import { SolanaTradeRuntimeType } from '../../types';
|
|
3
3
|
import { Helius } from "../helius_sdk_v1.4.0";
|
|
4
4
|
export declare class HeliusClient {
|
|
@@ -9,6 +9,7 @@ export declare class HeliusClient {
|
|
|
9
9
|
helius_staked: Helius;
|
|
10
10
|
constructor(signers: Signer[]);
|
|
11
11
|
send_transaction(solana_trade_runtime: SolanaTradeRuntimeType, instructions: TransactionInstruction[], addressLookupTableAccounts?: AddressLookupTableAccount[]): Promise<string>;
|
|
12
|
+
send_transaction_jup_ag_with_jito(solana_trade_runtime: SolanaTradeRuntimeType, transaction: VersionedTransaction): Promise<string>;
|
|
12
13
|
private send_smart_transaction;
|
|
13
14
|
private send_transaction_by_jito;
|
|
14
15
|
private send_transaction_mixed;
|
|
@@ -48,6 +48,24 @@ class HeliusClient {
|
|
|
48
48
|
return txid;
|
|
49
49
|
});
|
|
50
50
|
}
|
|
51
|
+
send_transaction_jup_ag_with_jito(solana_trade_runtime, transaction) {
|
|
52
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
53
|
+
(0, dist_1.log_info)(`send_transaction_jup_ag_with_jito, start`);
|
|
54
|
+
let start_time = Date.now();
|
|
55
|
+
let { tip_amount: jito_tip_fee, priority_fee } = solana_trade_runtime;
|
|
56
|
+
let jito_region = (0, strategy_util_1.get_jito_region)();
|
|
57
|
+
let rpc = this.helius_mainnet.rpc;
|
|
58
|
+
let txid = yield rpc.send_jup_ag_tx_by_jito(solana_trade_runtime, transaction, jito_tip_fee, jito_region);
|
|
59
|
+
(0, sol_gas_cache_1.set_sol_gas_fee)(txid, { priority_fee, jito_tip_fee });
|
|
60
|
+
(0, dist_1.log_info)(`send_transaction_jup_ag_with_jito, end`, {
|
|
61
|
+
jito_tip_fee,
|
|
62
|
+
jito_region,
|
|
63
|
+
txid,
|
|
64
|
+
take_time: Date.now() - start_time
|
|
65
|
+
});
|
|
66
|
+
return txid;
|
|
67
|
+
});
|
|
68
|
+
}
|
|
51
69
|
send_smart_transaction(solana_trade_runtime_1, instructions_1, use_staked_endpint_1) {
|
|
52
70
|
return __awaiter(this, arguments, void 0, function* (solana_trade_runtime, instructions, use_staked_endpint, addressLookupTableAccounts = []) {
|
|
53
71
|
(0, dist_1.log_info)(`send_smart_transaction, start`);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@clonegod/ttd-sol-common",
|
|
3
|
-
"version": "1.0
|
|
3
|
+
"version": "1.1.0",
|
|
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-common": "1.1.
|
|
16
|
+
"@clonegod/ttd-common": "1.1.48",
|
|
17
17
|
"@metaplex-foundation/mpl-token-metadata": "^2.5.2",
|
|
18
18
|
"@solana/web3.js": "1.91.6",
|
|
19
19
|
"rpc-websockets": "7.10.0",
|