@clonegod/ttd-sol-common 1.0.190 → 1.0.192

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
- getOldBlockhash(targetSlotOffset?: number): Promise<{
54
+ getBlockhashBySlotOffset(targetSlotOffset?: number, limit?: number): Promise<{
55
+ key: string;
55
56
  context: {
56
57
  slot: number;
57
58
  };
58
- value: string;
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,22 @@ 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
+ pre: {
378
+ minContextSlot,
379
+ blockhash,
380
+ },
381
+ new: {
382
+ minContextSlot: blockhash_by_slot_offset.context.slot,
383
+ blockhash: blockhash_by_slot_offset.value.blockhash,
384
+ }
385
+ });
386
+ blockhash = blockhash_by_slot_offset.value;
387
+ minContextSlot = blockhash_by_slot_offset.context.slot;
388
+ }
373
389
  (0, dist_1.log_info)(`>>> getLatestBlockhashAndContext, end`);
374
390
  const recentBlockhash = blockhash.blockhash;
375
391
  const isVersioned = lookupTables.length > 0;
@@ -791,19 +807,18 @@ class RpcClient {
791
807
  return last_blockhash_slot;
792
808
  });
793
809
  }
794
- getOldBlockhash() {
795
- return __awaiter(this, arguments, void 0, function* (targetSlotOffset = 145) {
796
- const latestBlockHeight = yield this.connection.getBlockHeight("finalized");
797
- const targetBlockHeight = latestBlockHeight - targetSlotOffset;
798
- const block = yield this.connection.getBlock(targetBlockHeight, {
799
- commitment: "finalized",
800
- maxSupportedTransactionVersion: 0,
801
- });
802
- if (!block)
803
- throw new Error("Failed to fetch block");
810
+ getBlockhashBySlotOffset() {
811
+ return __awaiter(this, arguments, void 0, function* (targetSlotOffset = 145, limit = 1) {
812
+ let appConfig = global.appConfig;
813
+ let { key, blocks } = yield appConfig.arb_cache.loading_cache.get_block_info(dist_1.CHAIN_ID.SOLANA, targetSlotOffset, limit);
814
+ let { slot, blockhash, blockHeight } = JSON.parse(blocks[0]);
804
815
  return {
805
- context: { slot: block.parentSlot },
806
- value: block.blockhash
816
+ key,
817
+ context: { slot },
818
+ value: {
819
+ blockhash,
820
+ lastValidBlockHeight: blockHeight
821
+ }
807
822
  };
808
823
  });
809
824
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@clonegod/ttd-sol-common",
3
- "version": "1.0.190",
3
+ "version": "1.0.192",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "types": "types/index.d.ts",