@clonegod/ttd-sol-common 1.1.0 → 1.1.1
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.
|
@@ -41,11 +41,13 @@ export declare class RpcClient {
|
|
|
41
41
|
lastValidBlockHeightOffset?: number;
|
|
42
42
|
}): Promise<TransactionSignature>;
|
|
43
43
|
addTipInstruction(instructions: TransactionInstruction[], feePayer: PublicKey, tipAccount: string, tipAmount: number): void;
|
|
44
|
+
getTipTransaction(singers: Signer[], tipAccount: string, tipAmount: number, blockhash: string): Transaction;
|
|
44
45
|
createSmartTransactionWithTip(solana_trade_runtime: SolanaTradeRuntimeType, instructions: TransactionInstruction[], signers: Signer[], lookupTables?: AddressLookupTableAccount[], tipAmount?: number, feePayer?: Signer): Promise<SmartTransactionContext>;
|
|
45
46
|
sendJitoBundle(serializedTransactions: string[], encoding: string, jitoApiUrl: string): Promise<string>;
|
|
46
47
|
getBundleStatuses(bundleIds: string[], jitoApiUrl: string): Promise<any>;
|
|
47
48
|
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>;
|
|
49
|
+
send_jup_ag_tx_by_jito(solana_trade_runtime: SolanaTradeRuntimeType, transaction: VersionedTransaction, signers: Signer[], tipAmount?: number, region?: JitoRegion): Promise<string>;
|
|
50
|
+
getSerializedTipTransaction(signers: Signer[], tipAmount: number, blockhash: string, encoding?: BufferEncoding): Promise<string>;
|
|
49
51
|
getNftEditions(params: DAS.GetNftEditionsRequest): Promise<DAS.GetNftEditionsResponse>;
|
|
50
52
|
getTokenAccounts(params: DAS.GetTokenAccountsRequest): Promise<DAS.GetTokenAccountsResponse>;
|
|
51
53
|
sendTransaction(transaction: Transaction | VersionedTransaction, options?: HeliusSendOptions): Promise<TransactionSignature>;
|
|
@@ -531,6 +531,19 @@ class RpcClient {
|
|
|
531
531
|
});
|
|
532
532
|
instructions.push(tipInstruction);
|
|
533
533
|
}
|
|
534
|
+
getTipTransaction(singers, tipAccount, tipAmount, blockhash) {
|
|
535
|
+
const feePayer = singers[0];
|
|
536
|
+
const tipInstruction = web3_js_1.SystemProgram.transfer({
|
|
537
|
+
fromPubkey: feePayer.publicKey,
|
|
538
|
+
toPubkey: new web3_js_1.PublicKey(tipAccount),
|
|
539
|
+
lamports: tipAmount,
|
|
540
|
+
});
|
|
541
|
+
const transaction = new web3_js_1.Transaction().add(tipInstruction);
|
|
542
|
+
transaction.recentBlockhash = blockhash;
|
|
543
|
+
transaction.feePayer = feePayer.publicKey;
|
|
544
|
+
transaction.sign(feePayer);
|
|
545
|
+
return transaction;
|
|
546
|
+
}
|
|
534
547
|
createSmartTransactionWithTip(solana_trade_runtime_1, instructions_1, signers_1) {
|
|
535
548
|
return __awaiter(this, arguments, void 0, function* (solana_trade_runtime, instructions, signers, lookupTables = [], tipAmount = 1000, feePayer) {
|
|
536
549
|
if (!signers.length) {
|
|
@@ -641,8 +654,8 @@ class RpcClient {
|
|
|
641
654
|
return txid;
|
|
642
655
|
});
|
|
643
656
|
}
|
|
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') {
|
|
657
|
+
send_jup_ag_tx_by_jito(solana_trade_runtime_1, transaction_1, signers_1) {
|
|
658
|
+
return __awaiter(this, arguments, void 0, function* (solana_trade_runtime, transaction, signers, tipAmount = 1000, region = 'Default') {
|
|
646
659
|
let txid = (0, get_signature_1.getSignature)(transaction);
|
|
647
660
|
setTimeout(() => __awaiter(this, void 0, void 0, function* () {
|
|
648
661
|
let block_offset = solana_trade_runtime.settings.strategy.block_offset;
|
|
@@ -657,18 +670,22 @@ class RpcClient {
|
|
|
657
670
|
let jitoApiUrl = `${types_1.JITO_API_URLS[jito_region]}/api/v1/bundles`;
|
|
658
671
|
const send_tx_jito_url = process.env.SEND_TX_JITO_URL || '';
|
|
659
672
|
const send_tx_jito_stratgy = process.env.SEND_TX_JITO_STRATEGY || '';
|
|
673
|
+
let serializedTipTx = '';
|
|
660
674
|
if (!(0, dist_1.isEmpty)(send_tx_jito_url) && send_tx_jito_stratgy === 'mul_ips') {
|
|
661
675
|
let { jito_use_separate_tx } = solana_trade_runtime;
|
|
662
676
|
let group_id = solana_trade_runtime.group.id;
|
|
663
677
|
let recent_blockhash = blockhash;
|
|
664
678
|
let encoded_tx = serializedMainTx;
|
|
665
679
|
if (jito_use_separate_tx) {
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
].join(',');
|
|
680
|
+
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;
|
|
681
|
+
}
|
|
682
|
+
else {
|
|
683
|
+
serializedTipTx = yield this.getSerializedTipTransaction(signers, tipAmount, blockhash, encoding);
|
|
671
684
|
}
|
|
685
|
+
encoded_tx = [
|
|
686
|
+
serializedTipTx,
|
|
687
|
+
serializedMainTx
|
|
688
|
+
].join(',');
|
|
672
689
|
const send_result = yield (0, dist_1.postJSON)(send_tx_jito_url, {
|
|
673
690
|
encoding,
|
|
674
691
|
encoded_tx,
|
|
@@ -683,7 +700,8 @@ class RpcClient {
|
|
|
683
700
|
});
|
|
684
701
|
return;
|
|
685
702
|
}
|
|
686
|
-
|
|
703
|
+
serializedTipTx = yield this.getSerializedTipTransaction(signers, tipAmount, blockhash, encoding);
|
|
704
|
+
let bundleId = yield this.sendJitoBundle([serializedMainTx, serializedTipTx], encoding, jitoApiUrl);
|
|
687
705
|
(0, dist_1.log_info)(`sendJitoBundle`, {
|
|
688
706
|
txid,
|
|
689
707
|
jitoApiUrl,
|
|
@@ -694,6 +712,13 @@ class RpcClient {
|
|
|
694
712
|
return txid;
|
|
695
713
|
});
|
|
696
714
|
}
|
|
715
|
+
getSerializedTipTransaction(signers_1, tipAmount_1, blockhash_1) {
|
|
716
|
+
return __awaiter(this, arguments, void 0, function* (signers, tipAmount, blockhash, encoding = 'base64') {
|
|
717
|
+
const randomTipAccount = types_1.JITO_TIP_ACCOUNTS[Math.floor(Math.random() * types_1.JITO_TIP_ACCOUNTS.length)];
|
|
718
|
+
let tipTransaction = this.getTipTransaction(signers, randomTipAccount, tipAmount, blockhash);
|
|
719
|
+
return tipTransaction.serialize({ verifySignatures: false }).toString(encoding);
|
|
720
|
+
});
|
|
721
|
+
}
|
|
697
722
|
getNftEditions(params) {
|
|
698
723
|
return __awaiter(this, void 0, void 0, function* () {
|
|
699
724
|
try {
|
|
@@ -55,7 +55,7 @@ class HeliusClient {
|
|
|
55
55
|
let { tip_amount: jito_tip_fee, priority_fee } = solana_trade_runtime;
|
|
56
56
|
let jito_region = (0, strategy_util_1.get_jito_region)();
|
|
57
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);
|
|
58
|
+
let txid = yield rpc.send_jup_ag_tx_by_jito(solana_trade_runtime, transaction, this.signers, jito_tip_fee, jito_region);
|
|
59
59
|
(0, sol_gas_cache_1.set_sol_gas_fee)(txid, { priority_fee, jito_tip_fee });
|
|
60
60
|
(0, dist_1.log_info)(`send_transaction_jup_ag_with_jito, end`, {
|
|
61
61
|
jito_tip_fee,
|