@clonegod/ttd-core 2.0.27 → 2.0.29
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.
- package/dist/cache/arb_event_pub.d.ts +1 -0
- package/dist/cache/arb_event_pub.js +11 -0
- package/dist/cache/arb_event_sub.d.ts +1 -0
- package/dist/cache/arb_event_sub.js +11 -0
- package/dist/index.d.ts +8 -3
- package/dist/index.js +10 -2
- package/dist/quote/to_price_message.js +1 -1
- package/package.json +1 -1
- package/types/index.d.ts +2 -0
|
@@ -11,4 +11,5 @@ export declare class ArbEventPublisher {
|
|
|
11
11
|
publish_order_event(group_id: string, pair: string, dex_id: DEX_ID, message: RedisOrderEventMessageType): Promise<void>;
|
|
12
12
|
publish_wallet_raw_tx_event(group_id: string, wallet: string, message: any): Promise<void>;
|
|
13
13
|
publish_tx_result_event(group_id: string, pair: string, message: TradeResponseType): Promise<void>;
|
|
14
|
+
publish_new_block_event(chain_id: string, message: any): Promise<void>;
|
|
14
15
|
}
|
|
@@ -73,5 +73,16 @@ class ArbEventPublisher {
|
|
|
73
73
|
});
|
|
74
74
|
});
|
|
75
75
|
}
|
|
76
|
+
publish_new_block_event(chain_id, message) {
|
|
77
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
78
|
+
const channel = (0, index_1.get_new_block_channel_name)(chain_id);
|
|
79
|
+
yield this.redis_cmd.publish(channel, JSON.stringify(message));
|
|
80
|
+
(0, index_1.log_debug)(`publish_new_block_event, success`, {
|
|
81
|
+
channel,
|
|
82
|
+
chain_id,
|
|
83
|
+
block_number: message.block_number
|
|
84
|
+
});
|
|
85
|
+
});
|
|
86
|
+
}
|
|
76
87
|
}
|
|
77
88
|
exports.ArbEventPublisher = ArbEventPublisher;
|
|
@@ -14,4 +14,5 @@ export declare class ArbEventSubscriber {
|
|
|
14
14
|
subscribe_order_event(group_id: string, pair: string, dex_id: DEX_ID, callback: Function): Promise<void>;
|
|
15
15
|
subscribe_wallet_raw_tx_result(group_id: string, wallet: string, callback: Function): Promise<void>;
|
|
16
16
|
subscribe_tx_result(group_id: string, pair: string, callback: Function): Promise<void>;
|
|
17
|
+
subscribe_new_block(chain_id: string, callback: Function): Promise<void>;
|
|
17
18
|
}
|
|
@@ -162,5 +162,16 @@ class ArbEventSubscriber {
|
|
|
162
162
|
(0, index_1.log_info)(`subscribe_tx_result, success`, { channel });
|
|
163
163
|
});
|
|
164
164
|
}
|
|
165
|
+
subscribe_new_block(chain_id, callback) {
|
|
166
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
167
|
+
const channel = (0, index_1.get_new_block_channel_name)(chain_id);
|
|
168
|
+
const listener = (message, _channel) => {
|
|
169
|
+
(0, index_1.log_info)('subscribe_new_block => on event', { channel, message });
|
|
170
|
+
callback(message);
|
|
171
|
+
};
|
|
172
|
+
yield this.redis_cmd.subscribe(channel, listener);
|
|
173
|
+
(0, index_1.log_info)(`subscribe_new_block, success`, { channel });
|
|
174
|
+
});
|
|
175
|
+
}
|
|
165
176
|
}
|
|
166
177
|
exports.ArbEventSubscriber = ArbEventSubscriber;
|
package/dist/index.d.ts
CHANGED
|
@@ -23,7 +23,8 @@ export declare const STREAMING_TRANSACTION_CONFIRMED = "STREAMING_TRANSACTION_CO
|
|
|
23
23
|
export declare enum CHAIN_ID {
|
|
24
24
|
TRON = "TRON",
|
|
25
25
|
SOLANA = "SOLANA",
|
|
26
|
-
BSC = "BSC"
|
|
26
|
+
BSC = "BSC",
|
|
27
|
+
ETH = "ETH"
|
|
27
28
|
}
|
|
28
29
|
export declare enum DEX_ID {
|
|
29
30
|
SUNSWAP_V2 = "SUNSWAP-V2",
|
|
@@ -36,7 +37,9 @@ export declare enum DEX_ID {
|
|
|
36
37
|
METEORA_AMM = "METEORA-AMM",
|
|
37
38
|
PUMPFUN_AMM = "PUMPFUN-AMM",
|
|
38
39
|
PANCAKE_AMM = "PANCAKE-AMM",
|
|
39
|
-
PANCAKE_CLMM = "PANCAKE-CLMM"
|
|
40
|
+
PANCAKE_CLMM = "PANCAKE-CLMM",
|
|
41
|
+
UNISWAP_AMM = "UNISWAP-AMM",
|
|
42
|
+
UNISWAP_CLMM = "UNISWAP-CLMM"
|
|
40
43
|
}
|
|
41
44
|
export declare enum GROUP_ID {
|
|
42
45
|
TRON_DEV1 = "TRON-DEV1",
|
|
@@ -100,6 +103,7 @@ export declare const get_quote_channel_name: (chain_id: string) => string;
|
|
|
100
103
|
export declare const get_order_channel_name: (group_id: string, pair: string, dex_id: DEX_ID) => string;
|
|
101
104
|
export declare const get_wallet_raw_tx_channel_name: (group_id: string, wallet: string) => string;
|
|
102
105
|
export declare const get_tx_result_channel_name: (group_id: string, pair: string) => string;
|
|
106
|
+
export declare const get_new_block_channel_name: (chain_id: string) => string;
|
|
103
107
|
export declare enum REDIS_EVENT_CHANNEL {
|
|
104
108
|
CONFIG_CHANGE = "CONFIG_CHANGE",
|
|
105
109
|
QUOTE = "QUOTE",
|
|
@@ -107,7 +111,8 @@ export declare enum REDIS_EVENT_CHANNEL {
|
|
|
107
111
|
ORDER_RESULT = "ORDER_RESULT",
|
|
108
112
|
TX_RAW_DATA = "TX_RAW_DATA",
|
|
109
113
|
TX_RESULT = "TX_RESULT",
|
|
110
|
-
TRADE_INSTANCE_STATUS = "TRADE_INSTANCE_STATUS"
|
|
114
|
+
TRADE_INSTANCE_STATUS = "TRADE_INSTANCE_STATUS",
|
|
115
|
+
NEW_BLOCK = "NEW_BLOCK"
|
|
111
116
|
}
|
|
112
117
|
export declare enum REDIS_EVENT_TYPE_CONFIG_CHANGE {
|
|
113
118
|
TOKEN_CONFIG_CHANGE = "TOKEN_CONFIG_CHANGE",
|
package/dist/index.js
CHANGED
|
@@ -48,8 +48,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
48
48
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
49
49
|
};
|
|
50
50
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
51
|
-
exports.
|
|
52
|
-
exports.execute_bash = exports.inspect_arb_local_cache = exports.save_trade_execution_logs = exports.parse_trade_cmdline_args = exports.get_input_out_token_fix = exports.get_input_out_token = exports.calc_amount_in_token = exports.estimate_amount_in_token = exports.failed = exports.success = exports.home_dir = exports.postJSON = exports.deep_merge_object = exports.isArray = exports.isTrue = exports.deep_clone = exports.uuid = void 0;
|
|
51
|
+
exports.DATE_TIME_FORMAT_DEFAULT = exports.to_json_str = exports.DecimalUtil = exports.generateRandomNumber = exports.LOG = exports._active_log_level = exports.LOG_LEVEL = exports.REDIS_EVENT_TYPE_TRADE_INSTANCE_CHANGE = exports.REDIS_EVENT_TYPE_ORDER = exports.REDIS_EVENT_TYPE_QUOTE = exports.REDIS_EVENT_TYPE_CONFIG_CHANGE = exports.REDIS_EVENT_CHANNEL = exports.get_new_block_channel_name = exports.get_tx_result_channel_name = exports.get_wallet_raw_tx_channel_name = exports.get_order_channel_name = exports.get_quote_channel_name = exports.get_config_channel_name = exports.get_cache_key = exports.getArbEventSubscriber = exports.getArbEventPublisher = exports.getArbCache = exports.getRedisCommamd = exports.getLoadingCache = exports.getRedisCache = exports.format_order_lock_key = exports.format_unique_order_msg_id = exports.parse_unique_orderbook_id = exports.format_unique_orderbook_id = exports.format_symbol_name = exports.LOCAL_EVENT_NAME = exports.CACHE_KEY_TYPE = exports.OnChainDataSubscribeType = exports.TradeErrorCodeType = exports.SystemErrorCodeType = exports.TRADE_TYPE = exports.GROUP_ID = exports.DEX_ID = exports.CHAIN_ID = exports.STREAMING_TRANSACTION_CONFIRMED = exports.TRANSACTION_STATE_FAILED = exports.TRANSACTION_STATE_SUCCESS = exports.TRANSACTION_STATE_PROCESSING = exports.QUOTE_AMOUNT_USD_MAX = exports.QUOTE_AMOUNT_USD_MIN = exports.REGEX_HEX_PREFIX = exports.PROCESSING = exports.NOT_FOUND = exports.SUCCESS = exports.FAILED = void 0;
|
|
52
|
+
exports.execute_bash = exports.inspect_arb_local_cache = exports.save_trade_execution_logs = exports.parse_trade_cmdline_args = exports.get_input_out_token_fix = exports.get_input_out_token = exports.calc_amount_in_token = exports.estimate_amount_in_token = exports.failed = exports.success = exports.home_dir = exports.postJSON = exports.deep_merge_object = exports.isArray = exports.isTrue = exports.deep_clone = exports.uuid = exports.DATE_TIME_FORMAT_NO_WHITESPACE = void 0;
|
|
53
53
|
exports._caller = _caller;
|
|
54
54
|
exports.log_trace = log_trace;
|
|
55
55
|
exports.log_debug = log_debug;
|
|
@@ -106,6 +106,7 @@ var CHAIN_ID;
|
|
|
106
106
|
CHAIN_ID["TRON"] = "TRON";
|
|
107
107
|
CHAIN_ID["SOLANA"] = "SOLANA";
|
|
108
108
|
CHAIN_ID["BSC"] = "BSC";
|
|
109
|
+
CHAIN_ID["ETH"] = "ETH";
|
|
109
110
|
})(CHAIN_ID || (exports.CHAIN_ID = CHAIN_ID = {}));
|
|
110
111
|
var DEX_ID;
|
|
111
112
|
(function (DEX_ID) {
|
|
@@ -120,6 +121,8 @@ var DEX_ID;
|
|
|
120
121
|
DEX_ID["PUMPFUN_AMM"] = "PUMPFUN-AMM";
|
|
121
122
|
DEX_ID["PANCAKE_AMM"] = "PANCAKE-AMM";
|
|
122
123
|
DEX_ID["PANCAKE_CLMM"] = "PANCAKE-CLMM";
|
|
124
|
+
DEX_ID["UNISWAP_AMM"] = "UNISWAP-AMM";
|
|
125
|
+
DEX_ID["UNISWAP_CLMM"] = "UNISWAP-CLMM";
|
|
123
126
|
})(DEX_ID || (exports.DEX_ID = DEX_ID = {}));
|
|
124
127
|
var GROUP_ID;
|
|
125
128
|
(function (GROUP_ID) {
|
|
@@ -263,6 +266,10 @@ const get_tx_result_channel_name = (group_id, pair) => {
|
|
|
263
266
|
return `${REDIS_EVENT_CHANNEL.TX_RESULT}_${group_id}_${pair}`.toUpperCase();
|
|
264
267
|
};
|
|
265
268
|
exports.get_tx_result_channel_name = get_tx_result_channel_name;
|
|
269
|
+
const get_new_block_channel_name = (chain_id) => {
|
|
270
|
+
return `${REDIS_EVENT_CHANNEL.NEW_BLOCK}_${chain_id}`.toUpperCase();
|
|
271
|
+
};
|
|
272
|
+
exports.get_new_block_channel_name = get_new_block_channel_name;
|
|
266
273
|
var REDIS_EVENT_CHANNEL;
|
|
267
274
|
(function (REDIS_EVENT_CHANNEL) {
|
|
268
275
|
REDIS_EVENT_CHANNEL["CONFIG_CHANGE"] = "CONFIG_CHANGE";
|
|
@@ -272,6 +279,7 @@ var REDIS_EVENT_CHANNEL;
|
|
|
272
279
|
REDIS_EVENT_CHANNEL["TX_RAW_DATA"] = "TX_RAW_DATA";
|
|
273
280
|
REDIS_EVENT_CHANNEL["TX_RESULT"] = "TX_RESULT";
|
|
274
281
|
REDIS_EVENT_CHANNEL["TRADE_INSTANCE_STATUS"] = "TRADE_INSTANCE_STATUS";
|
|
282
|
+
REDIS_EVENT_CHANNEL["NEW_BLOCK"] = "NEW_BLOCK";
|
|
275
283
|
})(REDIS_EVENT_CHANNEL || (exports.REDIS_EVENT_CHANNEL = REDIS_EVENT_CHANNEL = {}));
|
|
276
284
|
var REDIS_EVENT_TYPE_CONFIG_CHANGE;
|
|
277
285
|
(function (REDIS_EVENT_TYPE_CONFIG_CHANGE) {
|
|
@@ -33,7 +33,7 @@ exports.get_quote_token_decimals = get_quote_token_decimals;
|
|
|
33
33
|
function to_price_message(appConfig, quote_amount_usd, tx_price, quote_ask_price, quote_bid_price, pool_info, time, slot) {
|
|
34
34
|
return __awaiter(this, void 0, void 0, function* () {
|
|
35
35
|
let { pool_address, tokenA, tokenB } = pool_info;
|
|
36
|
-
let { dex_id, pool_name, fee_rate, is_reverse_token
|
|
36
|
+
let { dex_id, pool_name, fee_rate, is_reverse_token } = yield appConfig.arb_cache.get_one_pool_info(pool_address);
|
|
37
37
|
let _dex_id = dex_id;
|
|
38
38
|
let price_id = (0, uuid_1.v4)().replace(/-/gi, '');
|
|
39
39
|
let chain_id = appConfig.env_args.chain_id;
|
package/package.json
CHANGED
package/types/index.d.ts
CHANGED
|
@@ -652,6 +652,7 @@ export declare class ArbEventPublisher {
|
|
|
652
652
|
publish_order_event(group_id: string, pair: string, dex_id: DEX_ID, message: RedisOrderEventMessageType): Promise<void>;
|
|
653
653
|
publish_wallet_raw_tx_event(group_id: string, wallet: string, message: any): Promise<void>;
|
|
654
654
|
publish_tx_result_event(group_id: string, pair: string, message: TradeResponseType): Promise<void>;
|
|
655
|
+
publish_new_block_event(chain_id: string, message: any): Promise<void>;
|
|
655
656
|
}
|
|
656
657
|
|
|
657
658
|
export declare class ArbEventSubscriber {
|
|
@@ -668,6 +669,7 @@ export declare class ArbEventSubscriber {
|
|
|
668
669
|
subscribe_order_event(group_id: string, pair: string, dex_id: DEX_ID, callback: Function): Promise<void>;
|
|
669
670
|
subscribe_wallet_raw_tx_result(group_id: string, wallet: string, callback: Function): Promise<void>;
|
|
670
671
|
subscribe_tx_result(group_id: string, pair: string, callback: Function): Promise<void>;
|
|
672
|
+
subscribe_new_block(chain_id: string, callback: Function): Promise<void>;
|
|
671
673
|
}
|
|
672
674
|
|
|
673
675
|
export declare class LoadingCache {
|