@clonegod/ttd-core 2.0.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.
Files changed (77) hide show
  1. package/README.md +3 -0
  2. package/dist/analyze/index.d.ts +3 -0
  3. package/dist/analyze/index.js +49 -0
  4. package/dist/app_config/app_config.d.ts +15 -0
  5. package/dist/app_config/app_config.js +50 -0
  6. package/dist/app_config/env_args.d.ts +16 -0
  7. package/dist/app_config/env_args.js +28 -0
  8. package/dist/app_config/index.d.ts +2 -0
  9. package/dist/app_config/index.js +18 -0
  10. package/dist/cache/arb_cache.d.ts +80 -0
  11. package/dist/cache/arb_cache.js +1010 -0
  12. package/dist/cache/arb_event_pub.d.ts +14 -0
  13. package/dist/cache/arb_event_pub.js +77 -0
  14. package/dist/cache/arb_event_sub.d.ts +17 -0
  15. package/dist/cache/arb_event_sub.js +166 -0
  16. package/dist/cache/index.d.ts +6 -0
  17. package/dist/cache/index.js +22 -0
  18. package/dist/cache/loading_cache.d.ts +62 -0
  19. package/dist/cache/loading_cache.js +233 -0
  20. package/dist/cache/redis_client.d.ts +3 -0
  21. package/dist/cache/redis_client.js +73 -0
  22. package/dist/cache/redis_cmd.d.ts +14 -0
  23. package/dist/cache/redis_cmd.js +83 -0
  24. package/dist/index.d.ts +216 -0
  25. package/dist/index.js +883 -0
  26. package/dist/market_price/estimate_token_amount.d.ts +4 -0
  27. package/dist/market_price/estimate_token_amount.js +109 -0
  28. package/dist/market_price/index.d.ts +1 -0
  29. package/dist/market_price/index.js +17 -0
  30. package/dist/pool/cache_pool_config.d.ts +2 -0
  31. package/dist/pool/cache_pool_config.js +116 -0
  32. package/dist/pool/index.d.ts +3 -0
  33. package/dist/pool/index.js +19 -0
  34. package/dist/pool/pool_util.d.ts +5 -0
  35. package/dist/pool/pool_util.js +65 -0
  36. package/dist/pool/types.d.ts +20 -0
  37. package/dist/pool/types.js +2 -0
  38. package/dist/quote/index.d.ts +1 -0
  39. package/dist/quote/index.js +17 -0
  40. package/dist/quote/log_quote_price.d.ts +2 -0
  41. package/dist/quote/log_quote_price.js +29 -0
  42. package/dist/quote/on_quote_response.d.ts +3 -0
  43. package/dist/quote/on_quote_response.js +28 -0
  44. package/dist/quote/publish_quote_price.d.ts +3 -0
  45. package/dist/quote/publish_quote_price.js +19 -0
  46. package/dist/quote/to_price_message.d.ts +5 -0
  47. package/dist/quote/to_price_message.js +103 -0
  48. package/dist/test/test_is_empty.d.ts +1 -0
  49. package/dist/test/test_is_empty.js +24 -0
  50. package/dist/test/test_log_level.d.ts +3 -0
  51. package/dist/test/test_log_level.js +29 -0
  52. package/dist/test/test_merge_property.d.ts +1 -0
  53. package/dist/test/test_merge_property.js +21 -0
  54. package/dist/token/cache_token_config.d.ts +2 -0
  55. package/dist/token/cache_token_config.js +68 -0
  56. package/dist/token/fixed_symbol_address.d.ts +2 -0
  57. package/dist/token/fixed_symbol_address.js +26 -0
  58. package/dist/token/index.d.ts +6 -0
  59. package/dist/token/index.js +22 -0
  60. package/dist/token/is_not_arb_token.d.ts +1 -0
  61. package/dist/token/is_not_arb_token.js +24 -0
  62. package/dist/token/price/gecko_terminal.d.ts +2 -0
  63. package/dist/token/price/gecko_terminal.js +69 -0
  64. package/dist/token/price/get_bsc_token_price.d.ts +2 -0
  65. package/dist/token/price/get_bsc_token_price.js +131 -0
  66. package/dist/token/price/get_solana_token_price.d.ts +2 -0
  67. package/dist/token/price/get_solana_token_price.js +17 -0
  68. package/dist/token/price/get_tron_token_price.d.ts +2 -0
  69. package/dist/token/price/get_tron_token_price.js +17 -0
  70. package/dist/token/price/index.d.ts +3 -0
  71. package/dist/token/price/index.js +19 -0
  72. package/dist/token/token_util.d.ts +3 -0
  73. package/dist/token/token_util.js +23 -0
  74. package/dist/token/types.d.ts +29 -0
  75. package/dist/token/types.js +2 -0
  76. package/package.json +47 -0
  77. package/types/index.d.ts +709 -0
@@ -0,0 +1,709 @@
1
+ /*********************************************************************
2
+ * CONFIG - COMMON SERVICE CONFIG TYPE *
3
+ * *******************************************************************/
4
+ export interface CommonServiceType {
5
+ config_center: ConfigCenterServiceType
6
+ quote: QuoteServiceType[]
7
+ orderbook: OrderbookServiceType
8
+ trade_proxy: TradeProxyServiceType
9
+ }
10
+
11
+ // Service
12
+ export interface ConfigCenterServiceType {
13
+ http_port: number
14
+ }
15
+
16
+ // Service
17
+ export interface QuoteServiceType {
18
+ dex_id: string
19
+ http_port: number
20
+ ws_port: number
21
+ enable: boolean
22
+ }
23
+
24
+ // Service
25
+ export interface OrderbookServiceType {
26
+ http_port: number
27
+ ws_port: number
28
+ }
29
+
30
+ // Service
31
+ export interface TradeProxyServiceType {
32
+ http_port: number
33
+ ws_port: number
34
+ }
35
+
36
+
37
+
38
+ /*********************************************************************
39
+ * CONFIG - TOKEN CONFIG TYPE *
40
+ * *******************************************************************/
41
+ export interface StandardTokenConfigType {
42
+ desc: string
43
+ version: string
44
+ url: string
45
+ token_list: StandardTokenInfoType[]
46
+ }
47
+
48
+ export interface StandardTokenInfoType {
49
+ symbol: string
50
+ address: string
51
+ address_hex: string
52
+ decimals: number
53
+ name: string
54
+ is_token2022?: boolean
55
+ enable: boolean
56
+ market_price?: string
57
+ reserve?: string // 某个时刻,token在POOL中的储备数量
58
+ update_time?: string
59
+ alias?: string // cex上的名称
60
+ }
61
+
62
+ /*********************************************************************
63
+ * CONFIG - POOL CONFIG TYPE *
64
+ * *******************************************************************/
65
+ export interface StandardPoolConfigType {
66
+ desc: string
67
+ url: string
68
+ dex_list: StandardDexPoolConfigType[]
69
+ }
70
+
71
+ export interface StandardDexPoolConfigType {
72
+ dex_id: string
73
+ pool_list: StandardPoolInfoType[]
74
+ }
75
+
76
+ export interface StandardPoolInfoType {
77
+ program_id?: string // Raydium Liquidity Pool V4
78
+ authority?: string // Vault owner
79
+ subscribe_type?: string // ws, grpc
80
+
81
+ dex_id: string
82
+ pool_name: string
83
+ pool_address: string
84
+ pool_address_hex: string
85
+ tokenA: StandardTokenInfoType
86
+ tokenB: StandardTokenInfoType
87
+ vaultA?: string
88
+ vaultB?: string
89
+ router_id: string
90
+ fee_rate: number
91
+ quote_token: string
92
+ quote_amount_usd: number
93
+ quote_price_decimals?: number
94
+ pair: string
95
+ is_reverse_token: boolean
96
+ enable: boolean
97
+ cu_limit?: number
98
+ tvl?: string|number
99
+ vol_24h?: string|number
100
+ update_time?: string
101
+ }
102
+
103
+
104
+ /*********************************************************************
105
+ * TOKEN PAIR *
106
+ * *******************************************************************/
107
+ export interface StandardPairType {
108
+ pair: string
109
+ price_decimals: number // 价格的精度(注意:跟token的精度不同!)
110
+ tokenA?: StandardTokenInfoType
111
+ tokenB?: StandardTokenInfoType
112
+ pool_list: string[]
113
+ }
114
+
115
+
116
+
117
+ /*********************************************************************
118
+ * CONFIG - TRADE SERVICE CONFIG TYPE *
119
+ * *******************************************************************/
120
+ export interface TradeServiceConfigType {
121
+ group: TradeGroupType
122
+ pair_list: TradePairType[]
123
+ settings: TradeSettingsType
124
+ }
125
+
126
+ export interface TradeGroupType {
127
+ id: string
128
+ desc: string
129
+ enable: boolean
130
+ wallet: string
131
+ }
132
+
133
+ export interface TradePairType {
134
+ name: string,
135
+ enable: boolean
136
+ auto_approve: boolean
137
+ settings: TradeSettingsType
138
+ dex_list: TradePairDexPoolsType[]
139
+ }
140
+
141
+ export interface TradePairDexPoolsType {
142
+ pair: string
143
+ dex_id: string
144
+ pool_list: string[]
145
+ pool_info_list: StandardPoolInfoType[]
146
+ }
147
+
148
+ export interface TradeSettingsType {
149
+ trade_process_count: number
150
+ slippage_bps: number
151
+ rpc: RpcInfoType
152
+ strategy: TradeStrategyType
153
+ }
154
+
155
+ export interface RpcInfoType {
156
+ read: string // 查询使用的RPC
157
+ write: string // 提交交易使用的RPC
158
+ }
159
+
160
+
161
+ export interface TradeStrategyType {
162
+ broadcast_type: 'rpc' | 'jito' | 'mixed' // 提交交易的通道
163
+ speed: 'fast' | 'turbo' | 'ultra' // fee_mode='MAX_CAP' 模式下,费用:x1, x2, x4
164
+ fee_mode: 'exact' | 'max_cap' // GAS支出模式
165
+ fee_exact: number, // 固定GAS
166
+ fee_max_cap: number, // 动态GAS的上限
167
+ tip_ratio: number // tip 占总gas的比例(gas=priority_fee + tip_fee)
168
+ tip_up_ratio: number // tip上浮比例
169
+ }
170
+
171
+
172
+ /*********************************************************************
173
+ * TRADE INSTANCE TYPE *
174
+ * *******************************************************************/
175
+
176
+ export interface TradeCommandLineArgs {
177
+ // chain_id 在 .env 中设置
178
+ chain_id: string
179
+
180
+ // 通过命令行参数传入
181
+ input_dex_id: string
182
+ input_pair: string
183
+ input_group_id: string
184
+
185
+
186
+ }
187
+
188
+ // 构建Group 单币对的运行环境
189
+ // ${chain_id}_${group_id}_${dex_id}_${pair}
190
+ export interface TradeRuntimeType {
191
+ group: TradeGroupType
192
+ wallet: WalletInfoType
193
+
194
+ wallet_token_accounts?: Map<string,string>
195
+
196
+ chain_id: string
197
+ dex_id: string
198
+ pair_name: string
199
+ auto_approve: boolean
200
+ pair_dex: TradePairDexPoolsType
201
+ settings: TradeSettingsType
202
+ }
203
+
204
+
205
+ export interface TradeProcessInstanceType {
206
+ instance_id: number,
207
+ pair: string,
208
+ http_port: number,
209
+ start_time: string,
210
+ tx_count: number,
211
+ tx_time_min: number,
212
+ tx_time_max: number
213
+ }
214
+
215
+ //-------------------------------------------------------------------//
216
+ //-------------------------------------------------------------------//
217
+ //-------------------------------------------------------------------//
218
+
219
+
220
+
221
+ /*********************************************************************
222
+ * QUOTE PRICE TYPE *
223
+ * *******************************************************************/
224
+ export declare class EstimateAmountInToken {
225
+ // market_price => amount_in_token
226
+ static estimate_amount_in_token(
227
+ arb_cache: ArbCache,
228
+ token: StandardTokenInfoType,
229
+ amount_in_usd: number,
230
+ query_token_price_url?: string
231
+ ): Promise<string>
232
+ }
233
+
234
+
235
+ export interface TokenPriceWithAmountType {
236
+ token_info: StandardTokenInfoType
237
+ market_price: string
238
+ amount_in_usd: number
239
+ amount_in_token: number
240
+ }
241
+
242
+ export interface QuoteResultType {
243
+ inputToken: StandardTokenInfoType
244
+ outputToken: StandardTokenInfoType
245
+ slippageBps: number
246
+ amountIn: number
247
+ amountOut: number
248
+ amountOutMin: number
249
+ priceImpact: number // 当前quote size对pool价格的影响程度
250
+ price: string
251
+ }
252
+
253
+
254
+ /*********************************************************************
255
+ * PRICE MESSAGE TYPE *
256
+ * *******************************************************************/
257
+ export interface PriceMessageType {
258
+ chain_id: string
259
+ dex_id: string
260
+ pool_id: string
261
+ pool_name: string
262
+ fee_rate: number
263
+ pair: string // 标准化的币对名称
264
+ unique_orderbook_id: string // ${chain_id}_${dex_id}_${pool_id}_${fee_rate}
265
+ is_reverse_token: boolean // 是否反转币对进行交易(按USDT,SOL,TRX等作为计价币)
266
+ tokenA?: StandardTokenInfoType
267
+ tokenB?: StandardTokenInfoType
268
+ price_id: string // 价格消息的唯一id
269
+ tx_price?: string // 链上交易的执行价格
270
+ quote_amount_usd: number // quote size,按多少U价值的Token数量进行询价
271
+ ask: PriceType
272
+ bid: PriceType
273
+ time: QuoteTimeInfoType // quote 耗时数据
274
+ slot: string // 询价生成的价格,所对应的slot (account, vaultA, vaultB)
275
+ quote_source?: QuoteSourceType // 触发本次询价的事件源信息
276
+ }
277
+
278
+ export interface QuoteSourceType {
279
+ slot: string
280
+ block: string
281
+ txid: string
282
+ }
283
+
284
+ export interface UniqueOrderbookIdType {
285
+ chain_id: string,
286
+ dex_id: string,
287
+ pool_id: string,
288
+ fee_rate: string
289
+ }
290
+
291
+ export interface PriceType {
292
+ price: string
293
+ quantity: number // ask: baseToken的挂单数量 bid: quoteToken的挂单数量
294
+ }
295
+
296
+ export interface QuoteTimeInfoType {
297
+ block_time: number, // 触发本次quote询价的交易,链上的出块时间
298
+ stream_time: number, // 接收到链上发生交易的时间(stream, webhook)
299
+ quote_start_time: number // 询价开始时间
300
+ quote_end_time: number // 询价结束时间
301
+ price_time: number // 生成价格的时间
302
+ total_quote_time: number // 询价总耗时:price_time - stream_time
303
+ }
304
+
305
+ /*********************************************************************
306
+ * ORDERBOOK PRICE TYPE *
307
+ * *******************************************************************/
308
+ export interface OrderbookPriceType {
309
+ chain_id: string
310
+ pair: string
311
+ quote_amount_usd: number
312
+ asks: Ladder[]
313
+ bids: Ladder[]
314
+ }
315
+
316
+ export interface Ladder {
317
+ unique_orderbook_id: string
318
+ price: string
319
+ quantity: string
320
+
321
+ // 询价生成的价格,所对应的slot (account, vaultA, vaultB)
322
+ slot: string
323
+
324
+ // unique_orderbook_id 价格更新时间
325
+ price_id: string
326
+ price_time: string
327
+ }
328
+
329
+
330
+ /*********************************************************************
331
+ * ORDER MESSAGE TYPE *
332
+ * *******************************************************************/
333
+ export interface OrderMessageType {
334
+ c_id: string // cex order id
335
+ pair?: string // 新增:新模式不传unique_orderbook_id,改传标准币对名称
336
+
337
+ // 下单参数
338
+ group_id: string // 分组编号
339
+ chain_id: string
340
+ unique_orderbook_id: string
341
+ price_id: string
342
+ aToB: boolean // 交易方向,相对USDT/SOL/TRX等标准代币而言,买/卖
343
+ amount: string // 交易的币的数量
344
+ order_send_time: number // cex 发送下单消息的时间
345
+ price?:string // cex 提供的下单参考价格
346
+
347
+ // 兼容运营操作
348
+ order_source?: string // 下单来源 - admin
349
+ order_action?: string // 交易方向 - buy/sell
350
+
351
+ // 以下字段在dex赋值
352
+ unique_order_msg_id: string // order msg 唯一标识
353
+ order_recv_time: number // trade-proxy 接收到下单消息的时间
354
+ order_trace_id: string // trade-proxy (price_id + order_trace_id -> unique_order_msg_id)
355
+ order_submit_time: number // trade 提交交易的时间
356
+ order_submit_result: OrderSubmitResultType // trade 提交交易的结果:txid
357
+ }
358
+
359
+
360
+ export interface OrderSubmitResultType {
361
+ success: boolean
362
+ msg: 'SUCCESS' | 'FAILED'
363
+ txid: string
364
+ }
365
+
366
+ // 返回Order提交结果
367
+ export interface OrderSubmitResponseType {
368
+ chain_id: string,
369
+ group_id: string,
370
+ pair: string,
371
+ txid: string
372
+ }
373
+
374
+ /*********************************************************************
375
+ * TRADE RESULT TYPE *
376
+ * *******************************************************************/
377
+ // 返回Trade执行结果
378
+ export interface TradeResponseType {
379
+ code: 100 | 200 | 404 | 500
380
+ msg: 'PROCESSING' | 'SUCCESS' | 'NOT_FOUND' | 'FAILED'
381
+ data: TradeResultType,
382
+ error_code?: string
383
+ }
384
+
385
+ export interface TradeResultType {
386
+ success: boolean
387
+ error_code: string
388
+
389
+ start_time: number
390
+ end_time: number
391
+ total_time: number
392
+
393
+ group_id: string
394
+ wallet: string
395
+
396
+ chain_id: string
397
+ pair: string
398
+ dex_id: string
399
+ txid: string
400
+
401
+ unique_orderbook_id: string
402
+ unique_order_msg_id: string
403
+
404
+ aToB: boolean
405
+ order_price: string
406
+ tx_price: string
407
+
408
+ balance: TradeResultBalanceChangeType
409
+
410
+ execution: TradeExecutionInfoType
411
+
412
+ c_id: string // cex order id
413
+ }
414
+
415
+ // 余额变化
416
+ export interface TradeResultBalanceChangeType {
417
+ tokenA: TokenBalanceChangeType
418
+ tokenB: TokenBalanceChangeType
419
+ }
420
+
421
+ // Token的余额变化
422
+ export interface TokenBalanceChangeType {
423
+ symbol: string
424
+ address: string
425
+ pre_bal: number
426
+ post_bal: number
427
+ change: number
428
+ decimals: number
429
+ }
430
+
431
+ // 交易执行附加信息
432
+ export interface TradeExecutionInfoType {
433
+ broadcast: TradeBroadcastType[]
434
+ time: TradeTimeFlowType
435
+ server_info: ServerInfoType
436
+ }
437
+
438
+
439
+ // 耗时
440
+ export interface TradeTimeFlowType extends QuoteTimeInfoType {
441
+ order_send_time: number // cex 发送下单消息的时间
442
+ order_recv_time: number // dex 接收到下单消息的时间
443
+ order_submit_time: number // dex 提交交易时间
444
+ order_end_time: number // dex 解析得到交易结果的时间
445
+ order_block_time: number // dex 交易所在区块的出块时间
446
+ total_order_time: number // dex 交易耗时: order_end_time - order_recv_time
447
+ }
448
+
449
+ // TRANSACTION BROADCASTING
450
+ export interface TradeBroadcastType {
451
+ rpc: RpcInfoType // quicknode | helius
452
+ type: string // main-net | jito | mixed
453
+ fee: TradeGasFeeType // gas
454
+ }
455
+
456
+ // GAS
457
+ export interface TradeGasFeeType {
458
+ base_fee: number // 上链基础费用 - 固定收
459
+ priority_fee: number // 优先级费用 - 自愿给
460
+ total_fee: number
461
+ }
462
+
463
+ // 执行环境
464
+ export interface ServerInfoType {
465
+ ip: string
466
+ name: string
467
+ region: string
468
+ }
469
+
470
+ // 发送交易的日志,分析限流用
471
+ export interface SendTxLogType {
472
+ server_id: string // 服务器id
473
+ send_time: number|string // 发送交易的时间
474
+ txid: string // transaction id
475
+ index: number // 第几次发送(retry的index)
476
+ ip: string // 发送交易使用的IP
477
+ region: string // jito的region
478
+ res_time: number|string // 响应时间
479
+ res_code: number // http 响应码
480
+ res_data: string // jito bundle id
481
+ duration: number // 发送交易 -> 获取到响应码的耗时
482
+ }
483
+
484
+ /*********************************************************************
485
+ * WALLET TYPE *
486
+ * *******************************************************************/
487
+ export interface WalletInfoType {
488
+ public_key: string
489
+ private_key: string
490
+ }
491
+
492
+ export interface WalletTokenBalanceInfoType {
493
+ symbol: string
494
+ address: string
495
+ uiAmount: string
496
+ price?: string
497
+ balance?: string
498
+ }
499
+
500
+
501
+ /*********************************************************************
502
+ * REDIS EVENT TYPE *
503
+ * *******************************************************************/
504
+ export interface RedisConfigChangeEventMessageType {
505
+ event_type: string
506
+ event_time: number
507
+ group_id?: string,
508
+ data?: any
509
+ }
510
+
511
+ export interface RedisOrderEventMessageType {
512
+ event_type: string
513
+ event_time: number
514
+ group_id: string,
515
+ data: OrderMessageType
516
+ }
517
+
518
+
519
+ export interface RedisQuoteEventMessageType {
520
+ event_type: string
521
+ event_time: number
522
+ chain_id: string,
523
+ data: PriceMessageType
524
+ }
525
+
526
+ /*********************************************************************
527
+ * Cache TYPE *
528
+ * *******************************************************************/
529
+ export declare class ArbCache {
530
+ chain_id: CHAIN_ID;
531
+ loading_cache: LoadingCache;
532
+ redis_cmd: RedisCommand;
533
+ redis_event_publisher: ArbEventPublisher;
534
+ token_list: StandardTokenInfoType[];
535
+ token_symbol_map: Map<string, StandardTokenInfoType>;
536
+ token_address_map: Map<string, StandardTokenInfoType>;
537
+ token_list_cache_last_update_time: string;
538
+ pool_list: StandardPoolInfoType[];
539
+ pool_address_map: Map<string, StandardPoolInfoType>;
540
+ pool_list_cahce_last_update_time: string;
541
+ trade_config_list: TradeServiceConfigType[];
542
+ trade_config_map: Map<string, TradeServiceConfigType>;
543
+ trade_config_cache_last_update_time: string;
544
+ event_emitter: EventEmitter;
545
+ constructor(env_args: any);
546
+ init(): Promise<void>;
547
+ init_configs(): Promise<void>;
548
+ get_config_filepath(suffix: string): string;
549
+ get_bak_config_filepath(suffix: string): string;
550
+ refresh_local_cache_token_list(token_list: StandardTokenInfoType[]): void;
551
+ refresh_local_cache_pool_list(pool_list: StandardPoolInfoType[]): void;
552
+ refresh_local_cache_group_map(trade_config: TradeServiceConfigType): void;
553
+ cache_token_list(): Promise<void>;
554
+ update_token_list(input_token_list: StandardTokenInfoType[]): Promise<void>;
555
+ get_token_list(): Promise<StandardTokenInfoType[]>;
556
+ get_token_list_no_cache(): Promise<StandardTokenInfoType[]>;
557
+ get_one_token_info_by_symbol(symbol: string): Promise<StandardTokenInfoType>;
558
+ publish_token_change_event(): Promise<void>;
559
+ cache_pool_list(): Promise<void>;
560
+ set_pool_token_info(pool: StandardPoolInfoType, token_info_list: StandardTokenInfoType[]): void;
561
+ set_pool_extra(pool: StandardPoolInfoType): void;
562
+ update_pool_list(input_dex_pool_list: StandardDexPoolConfigType[]): Promise<void>;
563
+ get_pool_list_by_pair(pair: string): Promise<StandardPoolInfoType[]>;
564
+ get_pool_list(): Promise<StandardPoolInfoType[]>;
565
+ get_pool_list_no_cache(): Promise<StandardPoolInfoType[]>;
566
+ get_one_pool_info(pool_address: string, refresh_cache_if_not_found?: boolean): Promise<StandardPoolInfoType>;
567
+ publish_pool_change_event(): Promise<void>;
568
+ get_one_pair(input_pair: string): Promise<StandardPairType>;
569
+ get_pair_list(input_pair?: string): Promise<StandardPairType[]>;
570
+ cache_common_service(): Promise<void>;
571
+ get_common_service(): Promise<CommonServiceType>;
572
+ cache_trade_group(update_group_id?: string): Promise<void>;
573
+ update_trade_group(input_trade_config: TradeServiceConfigType): Promise<void>;
574
+ get_trade_group_id_list(): Promise<string[]>;
575
+ get_trade_service_by_group_id(group_id: string): Promise<TradeServiceConfigType>;
576
+ get_trade_service_by_group_id_no_cache(group_id: string): Promise<TradeServiceConfigType>;
577
+ create_trade_runtime(chain_id: string, group_id: string, dex_id: string, pair_name: string): Promise<TradeRuntimeType>;
578
+ find_pair_in_trade_config(pair_name: string, trade_config: TradeServiceConfigType): TradePairType;
579
+ find_pair_dex_in_trade_config(dex_id: string, pair_config: TradePairType): TradePairDexPoolsType;
580
+ cache_token_market_price(token_with_price: StandardTokenInfoType, ttl?: number): Promise<void>;
581
+ get_token_market_price(symbol: string): Promise<StandardTokenInfoType>;
582
+ cache_price_message(price_msg: PriceMessageType, ttl?: number): Promise<void>;
583
+ get_price_message(price_id: string): Promise<PriceMessageType>;
584
+ cache_order_message(order_msg: OrderMessageType, ttl?: number): Promise<{
585
+ key: string;
586
+ field: string;
587
+ res: number[];
588
+ ttl: number;
589
+ }>;
590
+ get_order_message(group_id: string, price_id: string, order_trace_id: string): Promise<OrderMessageType>;
591
+ cache_trade_result(trade_result: TradeResponseType, ttl?: number): Promise<{
592
+ key: string;
593
+ field: string;
594
+ res: number[];
595
+ ttl: number;
596
+ }>;
597
+ get_trade_result(group_id: string, txid: string): Promise<TradeResponseType>;
598
+ listen_trade_result(event_emitter: EventEmitter): void;
599
+ get_pair_dex_pool_list(quote_pair_list: string[], dex_id_list: string[]): Promise<StandardPoolInfoType[]>;
600
+ get_trade_dex_pool_list(dex_id_list: string[], trade_runtime: TradeRuntimeType): Promise<StandardPoolInfoType[]>;
601
+ get_group_trade_pair_info(chain_id: CHAIN_ID, group_id: string, pair: string): Promise<Map<string, StandardPairType>>;
602
+ get_all_trade_tokens(): Promise<StandardTokenInfoType[]>;
603
+ get_all_trade_pools(group_id?: string): Promise<StandardPoolInfoType[]>;
604
+ }
605
+
606
+ export declare class ArbEventPublisher {
607
+ arb_cache: ArbCache;
608
+ chain_id: CHAIN_ID;
609
+ redis_cmd: RedisCommand;
610
+ constructor(arb_cache: ArbCache);
611
+ publish_config_change_event(message: RedisConfigChangeEventMessageType): Promise<void>;
612
+ publish_quote_price_event(chain_id: string, message: RedisQuoteEventMessageType): Promise<void>;
613
+ publish_order_event(group_id: string, pair: string, dex_id: DEX_ID, message: RedisOrderEventMessageType): Promise<void>;
614
+ publish_wallet_raw_tx_event(group_id: string, wallet: string, message: any): Promise<void>;
615
+ publish_tx_result_event(group_id: string, pair: string, message: TradeResponseType): Promise<void>;
616
+ }
617
+
618
+ export declare class ArbEventSubscriber {
619
+ arb_cache: ArbCache;
620
+ chain_id: CHAIN_ID;
621
+ redis_cmd: RedisCommand;
622
+ constructor(arb_cache: ArbCache);
623
+ pre_load_config_cache(): Promise<void>;
624
+ subscribe_config_change_event(callback?: Function): Promise<void>;
625
+ on_config_token_change_event(message: RedisConfigChangeEventMessageType): Promise<boolean>;
626
+ on_config_pool_change_event(message: RedisConfigChangeEventMessageType): Promise<boolean>;
627
+ on_config_group_change_event(message: RedisConfigChangeEventMessageType): Promise<boolean>;
628
+ subscribe_quote_event(chain_id: string, callback: Function): Promise<void>;
629
+ subscribe_order_event(group_id: string, pair: string, dex_id: DEX_ID, callback: Function): Promise<void>;
630
+ subscribe_wallet_raw_tx_result(group_id: string, wallet: string, callback: Function): Promise<void>;
631
+ subscribe_tx_result(group_id: string, pair: string, callback: Function): Promise<void>;
632
+ }
633
+
634
+ export declare class LoadingCache {
635
+ redis_client: RedisClientType;
636
+ local_cache: Map<string, string>;
637
+ refresh_cache_timer: Map<string, any>;
638
+ constructor();
639
+ init(): Promise<void>;
640
+ get_key(chain_id: CHAIN_ID, cache_type: string, id: string): string;
641
+ set(chain_id: CHAIN_ID, cache_type: string, id: string, value: string): Promise<{
642
+ key: string;
643
+ res: string;
644
+ }>;
645
+ get(chain_id: CHAIN_ID, cache_type: string, id: string, skip_local?: boolean, auto_refresh?: boolean, refresh_interval_seconds?: number): Promise<{
646
+ key: string;
647
+ value: string;
648
+ }>;
649
+ refresh(key: string, interval_seconds: number): Promise<void>;
650
+ set_ex(chain_id: CHAIN_ID, cache_type: string, id: string, value: string, ttl: number): Promise<{
651
+ key: string;
652
+ res: string;
653
+ ttl: number;
654
+ }>;
655
+ get_hash_key(chain_id: CHAIN_ID, cache_type: string): string;
656
+ hset(chain_id: CHAIN_ID, cache_type: string, field: string, value: string): Promise<{
657
+ key: string;
658
+ field: string;
659
+ res: number[];
660
+ ttl: number;
661
+ }>;
662
+ hset_ex(chain_id: CHAIN_ID, cache_type: string, field: string, value: string, ttl?: number): Promise<{
663
+ key: string;
664
+ field: string;
665
+ res: number[];
666
+ ttl: number;
667
+ }>;
668
+ hdel(chain_id: CHAIN_ID, cache_type: string, field: string): Promise<number>;
669
+ hlen(chain_id: CHAIN_ID, cache_type: string): Promise<{
670
+ key: string;
671
+ value: number;
672
+ }>;
673
+ hkeys(chain_id: CHAIN_ID, cache_type: string): Promise<{
674
+ key: string;
675
+ value: string[];
676
+ }>;
677
+ hget(chain_id: CHAIN_ID, cache_type: string, field: string): Promise<{
678
+ key: string;
679
+ field: string;
680
+ value: string;
681
+ }>;
682
+ hmget(chain_id: CHAIN_ID, cache_type: string, fields: string[]): Promise<{
683
+ key: string;
684
+ fields: string[];
685
+ value: string[];
686
+ }>;
687
+ hget_all(chain_id: CHAIN_ID, cache_type: string): Promise<{
688
+ key: string;
689
+ value: {
690
+ [x: string]: string;
691
+ };
692
+ }>;
693
+ }
694
+
695
+ export declare class RedisCommand {
696
+ redis_client: RedisClientType;
697
+ constructor();
698
+ init(): Promise<void>;
699
+ exists(key: string): Promise<number>;
700
+ ttl(key: string): Promise<number>;
701
+ expire(key: string, ttl: number): Promise<boolean>;
702
+ del(key: string): Promise<number>;
703
+ set_nx(key: string, value: string): Promise<boolean>;
704
+ hinc(key: string, field: string, ttl?: number): Promise<number[]>;
705
+ subscribe(channel: string, listener: any): Promise<void>;
706
+ publish(channel: string, message: string): Promise<void>;
707
+ }
708
+
709
+