@clonegod/ttd-sol-common 1.0.60 → 1.0.62

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.
@@ -2,6 +2,7 @@ import { OrderMessageType, PriceMessageType, StandardPoolInfoType, TradeRuntimeT
2
2
  import { CHAIN_ID, DEX_ID } from "@clonegod/ttd-common/dist";
3
3
  import { Connection } from "@solana/web3.js";
4
4
  import { SolanaTradeRuntimeType } from "../../types";
5
+ import { AppConfig } from "../appconfig";
5
6
  export declare class TradeContext {
6
7
  connection: Connection;
7
8
  trade_runtime: TradeRuntimeType;
@@ -18,5 +19,5 @@ export declare class TradeContext {
18
19
  aToB: boolean;
19
20
  slippage_bps: number;
20
21
  constructor(price_msg: PriceMessageType, order_msg: OrderMessageType);
21
- init(connection: Connection, trade_runtime: TradeRuntimeType): Promise<void>;
22
+ init(appConfig: AppConfig): Promise<void>;
22
23
  }
@@ -18,10 +18,10 @@ class TradeContext {
18
18
  this.order_msg = order_msg;
19
19
  this.order_trace_id = order_msg.order_trace_id;
20
20
  }
21
- init(connection, trade_runtime) {
21
+ init(appConfig) {
22
22
  return __awaiter(this, void 0, void 0, function* () {
23
- this.connection = connection;
24
- this.trade_runtime = trade_runtime;
23
+ this.connection = appConfig.connection;
24
+ this.trade_runtime = appConfig.trade_runtime;
25
25
  let { group_id, unique_orderbook_id } = this.order_msg;
26
26
  this.group_id = group_id;
27
27
  let unique_orderbook_id_obj = (0, dist_1.parse_unique_orderbook_id)(unique_orderbook_id);
@@ -29,7 +29,7 @@ class TradeContext {
29
29
  this.dex_id = dist_1.DEX_ID[unique_orderbook_id_obj.dex_id];
30
30
  this.pool_id = unique_orderbook_id_obj.pool_id;
31
31
  this.fee_rate = unique_orderbook_id_obj.fee_rate;
32
- this.pool_info = this.trade_runtime.pair_dex.pool_info_list.find(e => e.pool_address === this.pool_id);
32
+ this.pool_info = yield appConfig.arb_cache.get_one_pool_info(this.pool_id);
33
33
  if (!this.pool_info) {
34
34
  throw new Error(`Not found pool_info! pool_id=${this.pool_id}, pool_info_list=${JSON.stringify(this.trade_runtime.pair_dex.pool_info_list)}`);
35
35
  }
@@ -485,7 +485,7 @@ class RpcClient {
485
485
  let error;
486
486
  do {
487
487
  try {
488
- const signature = yield this.connection.sendRawTransaction(transaction.serialize(), Object.assign({ maxRetries: 0, preflightCommitment: 'confirmed', skipPreflight: sendOptions.skipPreflight, minContextSlot }, sendOptions));
488
+ const signature = yield this.connection.sendRawTransaction(transaction.serialize(), Object.assign({ maxRetries: 3, preflightCommitment: 'confirmed', skipPreflight: sendOptions.skipPreflight, minContextSlot }, sendOptions));
489
489
  const abortSignal = AbortSignal.timeout(15000);
490
490
  yield this.connection.confirmTransaction({
491
491
  abortSignal,
@@ -19,7 +19,7 @@ class HeliusClient {
19
19
  this.signers = signers;
20
20
  this.sendOptions = {
21
21
  skipPreflight: true,
22
- maxRetries: 0
22
+ maxRetries: 3
23
23
  };
24
24
  let helius_api_key = process.env.HELIUS_API_KEY;
25
25
  let helius_mainnet_endpoint = `https://mainnet.helius-rpc.com/?api-key=${helius_api_key}`;
@@ -84,9 +84,9 @@ const handle_order_message = (appConfig, trade, message) => __awaiter(void 0, vo
84
84
  let txid = '';
85
85
  let order_submit_result;
86
86
  try {
87
- let { env_args, trade_runtime, connection } = appConfig;
88
87
  context = new common_1.TradeContext(price_msg, order_msg);
89
- yield context.init(connection, trade_runtime);
88
+ let { env_args } = appConfig;
89
+ yield context.init(appConfig);
90
90
  txid = yield trade.execute(context);
91
91
  order_msg.order_submit_time = Date.now();
92
92
  order_submit_result = {
@@ -93,7 +93,7 @@ class TransactionResultChecker {
93
93
  let { group_id, unique_order_msg_id, order_send_time, order_recv_time, order_submit_time, aToB } = this.order_msg;
94
94
  let order_price = aToB ? bid.price : ask.price;
95
95
  let server_info = (0, dist_1.getServerInfo)();
96
- let total_order_time = (order_block_time + 500) - order_recv_time;
96
+ let total_order_time = (order_block_time + 1000) - order_recv_time;
97
97
  let order_end_time = Date.now();
98
98
  let start_time = order_recv_time;
99
99
  let end_time = order_end_time;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@clonegod/ttd-sol-common",
3
- "version": "1.0.60",
3
+ "version": "1.0.62",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "types": "types/index.d.ts",