@clonegod/ttd-sol-common 1.0.190 → 1.0.193
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.
|
@@ -51,11 +51,15 @@ export declare class RpcClient {
|
|
|
51
51
|
sendSmartTransactionWithTipMixed(solana_trade_runtime: SolanaTradeRuntimeType, instructions: TransactionInstruction[], signers: Signer[], lookupTables?: AddressLookupTableAccount[], tipAmount?: number, region?: JitoRegion, feePayer?: Signer, lastValidBlockHeightOffset?: number): Promise<string>;
|
|
52
52
|
sendJitoTransaction(serializedTransaction: string, jitoApiUrl: string, encoding?: string): Promise<string>;
|
|
53
53
|
get_last_blockhash_slot(connections: Connection[]): Promise<RpcResponseAndContext<BlockhashWithExpiryBlockHeight>>;
|
|
54
|
-
|
|
54
|
+
getBlockhashBySlotOffset(targetSlotOffset?: number, limit?: number): Promise<{
|
|
55
|
+
key: string;
|
|
55
56
|
context: {
|
|
56
57
|
slot: number;
|
|
57
58
|
};
|
|
58
|
-
value:
|
|
59
|
+
value: {
|
|
60
|
+
blockhash: string;
|
|
61
|
+
lastValidBlockHeight: number;
|
|
62
|
+
};
|
|
59
63
|
}>;
|
|
60
64
|
try_get_bundle_failed_result(txid: string, bundle_id: string, timeoutMs?: number): Promise<void>;
|
|
61
65
|
send_tx_to_all_jito_region(serializedTransaction: string, encoding: string): Promise<string>;
|
|
@@ -370,6 +370,23 @@ class RpcClient {
|
|
|
370
370
|
(0, dist_1.log_info)(`>>> getLatestBlockhashAndContext, start`);
|
|
371
371
|
const payerKey = feePayer ? feePayer.publicKey : signers[0].publicKey;
|
|
372
372
|
let { context: { slot: minContextSlot }, value: blockhash, } = yield this.get_last_blockhash_slot([solana_trade_runtime.connection, this.connection]);
|
|
373
|
+
let block_offset = solana_trade_runtime.settings.strategy.block_offset;
|
|
374
|
+
if (!isNaN(block_offset) && block_offset > 0) {
|
|
375
|
+
let blockhash_by_slot_offset = yield this.getBlockhashBySlotOffset(block_offset);
|
|
376
|
+
(0, dist_1.log_info)(`>>> getBlockhashBySlotOffset`, {
|
|
377
|
+
block_offset,
|
|
378
|
+
pre: {
|
|
379
|
+
minContextSlot,
|
|
380
|
+
blockhash,
|
|
381
|
+
},
|
|
382
|
+
new: {
|
|
383
|
+
minContextSlot: blockhash_by_slot_offset.context.slot,
|
|
384
|
+
blockhash: blockhash_by_slot_offset.value.blockhash,
|
|
385
|
+
}
|
|
386
|
+
});
|
|
387
|
+
blockhash = blockhash_by_slot_offset.value;
|
|
388
|
+
minContextSlot = blockhash_by_slot_offset.context.slot;
|
|
389
|
+
}
|
|
373
390
|
(0, dist_1.log_info)(`>>> getLatestBlockhashAndContext, end`);
|
|
374
391
|
const recentBlockhash = blockhash.blockhash;
|
|
375
392
|
const isVersioned = lookupTables.length > 0;
|
|
@@ -791,19 +808,18 @@ class RpcClient {
|
|
|
791
808
|
return last_blockhash_slot;
|
|
792
809
|
});
|
|
793
810
|
}
|
|
794
|
-
|
|
795
|
-
return __awaiter(this, arguments, void 0, function* (targetSlotOffset = 145) {
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
commitment: "finalized",
|
|
800
|
-
maxSupportedTransactionVersion: 0,
|
|
801
|
-
});
|
|
802
|
-
if (!block)
|
|
803
|
-
throw new Error("Failed to fetch block");
|
|
811
|
+
getBlockhashBySlotOffset() {
|
|
812
|
+
return __awaiter(this, arguments, void 0, function* (targetSlotOffset = 145, limit = 1) {
|
|
813
|
+
let appConfig = global.appConfig;
|
|
814
|
+
let { key, blocks } = yield appConfig.arb_cache.loading_cache.get_block_info(dist_1.CHAIN_ID.SOLANA, targetSlotOffset, limit);
|
|
815
|
+
let { slot, blockhash, blockHeight } = JSON.parse(blocks[0]);
|
|
804
816
|
return {
|
|
805
|
-
|
|
806
|
-
|
|
817
|
+
key,
|
|
818
|
+
context: { slot },
|
|
819
|
+
value: {
|
|
820
|
+
blockhash,
|
|
821
|
+
lastValidBlockHeight: blockHeight
|
|
822
|
+
}
|
|
807
823
|
};
|
|
808
824
|
});
|
|
809
825
|
}
|