@clonegod/ttd-core 3.1.9 → 3.1.11
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_cache.d.ts +3 -2
- package/dist/cache/arb_cache.js +1 -1
- package/dist/cache/arb_event_pub.d.ts +3 -2
- package/dist/cache/arb_event_sub.d.ts +4 -2
- package/dist/cache/loading_cache.js +2 -2
- package/dist/index.d.ts +1 -4
- package/dist/index.js +4 -13
- package/dist/redis/index.d.ts +1 -2
- package/dist/redis/index.js +3 -16
- package/dist/redis/redis_client.d.ts +0 -1
- package/dist/redis/redis_client.js +3 -4
- package/dist/redis/redis_connection.d.ts +2 -2
- package/dist/redis/redis_connection.js +2 -2
- package/package.json +1 -1
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { EventEmitter } from 'events';
|
|
2
|
-
import { CommonServiceType, LoadingCache, OrderMessageType, PriceMessageType,
|
|
2
|
+
import { CommonServiceType, LoadingCache, OrderMessageType, PriceMessageType, StandardDexPoolConfigType, StandardPairType, StandardPoolInfoType, StandardTokenInfoType, TradePairDexPoolsType, TradePairType, TradeResponseType, TradeRuntimeType, TradeServiceConfigType } from "../../types";
|
|
3
|
+
import { RedisClient } from "../redis";
|
|
3
4
|
import { CHAIN_ID } from "../index";
|
|
4
5
|
import { ArbEventPublisher } from './arb_event_pub';
|
|
5
6
|
export declare class ArbCache {
|
|
6
7
|
chain_id: CHAIN_ID;
|
|
7
8
|
loading_cache: LoadingCache;
|
|
8
|
-
redis_cmd:
|
|
9
|
+
redis_cmd: RedisClient;
|
|
9
10
|
redis_event_publisher: ArbEventPublisher;
|
|
10
11
|
token_list: StandardTokenInfoType[];
|
|
11
12
|
token_symbol_map: Map<string, StandardTokenInfoType>;
|
package/dist/cache/arb_cache.js
CHANGED
|
@@ -20,7 +20,7 @@ class ArbCache {
|
|
|
20
20
|
constructor(env_args) {
|
|
21
21
|
this.chain_id = env_args.chain_id;
|
|
22
22
|
this.loading_cache = (0, index_1.getLoadingCache)();
|
|
23
|
-
this.redis_cmd = (0, index_1.
|
|
23
|
+
this.redis_cmd = (0, index_1.getRedisClient)();
|
|
24
24
|
this.token_list = [];
|
|
25
25
|
this.token_symbol_map = new Map();
|
|
26
26
|
this.token_address_map = new Map();
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { RedisConfigChangeEventMessageType, RedisOrderEventMessageType, RedisQuoteEventMessageType, TradeResponseType } from "../../types";
|
|
2
|
+
import { RedisClient } from "../redis";
|
|
2
3
|
import { CHAIN_ID, DEX_ID } from "../index";
|
|
3
4
|
import { ArbCache } from "./arb_cache";
|
|
4
5
|
export declare class ArbEventPublisher {
|
|
5
6
|
arb_cache: ArbCache;
|
|
6
7
|
chain_id: CHAIN_ID;
|
|
7
|
-
redis_cmd:
|
|
8
|
+
redis_cmd: RedisClient;
|
|
8
9
|
constructor(arb_cache: ArbCache);
|
|
9
10
|
publish_config_change_event(message: RedisConfigChangeEventMessageType): Promise<void>;
|
|
10
11
|
publish_quote_price_event(chain_id: string, message: RedisQuoteEventMessageType): Promise<void>;
|
|
@@ -1,9 +1,11 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { RedisConfigChangeEventMessageType } from "../../types";
|
|
2
|
+
import { RedisClient } from "../redis";
|
|
3
|
+
import { ArbCache } from "./arb_cache";
|
|
2
4
|
import { CHAIN_ID, DEX_ID } from "../index";
|
|
3
5
|
export declare class ArbEventSubscriber {
|
|
4
6
|
arb_cache: ArbCache;
|
|
5
7
|
chain_id: CHAIN_ID;
|
|
6
|
-
redis_cmd:
|
|
8
|
+
redis_cmd: RedisClient;
|
|
7
9
|
constructor(arb_cache: ArbCache);
|
|
8
10
|
pre_load_config_cache(): Promise<void>;
|
|
9
11
|
subscribe_config_change_event(callback?: Function): Promise<void>;
|
|
@@ -11,7 +11,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
exports.LoadingCache = void 0;
|
|
13
13
|
const index_1 = require("../index");
|
|
14
|
-
const
|
|
14
|
+
const redis_connection_1 = require("../redis/redis_connection");
|
|
15
15
|
class LoadingCache {
|
|
16
16
|
constructor() {
|
|
17
17
|
}
|
|
@@ -19,7 +19,7 @@ class LoadingCache {
|
|
|
19
19
|
return __awaiter(this, void 0, void 0, function* () {
|
|
20
20
|
this.local_cache = new Map();
|
|
21
21
|
this.refresh_cache_timer = new Map();
|
|
22
|
-
this.redis_client = yield (0,
|
|
22
|
+
this.redis_client = yield (0, redis_connection_1.getRedisConnection)('LoadingCache');
|
|
23
23
|
(0, index_1.log_info)('[LoadingCache] init done');
|
|
24
24
|
});
|
|
25
25
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -135,10 +135,7 @@ export declare const format_unique_orderbook_id: (chain_id: CHAIN_ID, dex_id: DE
|
|
|
135
135
|
export declare const parse_unique_orderbook_id: (unique_orderbook_id: string) => UniqueOrderbookIdType;
|
|
136
136
|
export declare const format_unique_order_msg_id: (group_id: string, price_id: string, order_trace_id: string) => string;
|
|
137
137
|
export declare const format_order_lock_key: (chain_id: string, group_id: string, price_id: string, order_trace_id: string) => string;
|
|
138
|
-
export declare const getRedisClient: () =>
|
|
139
|
-
export declare const getRedisCache: () => Promise<import("redis").RedisClientType>;
|
|
140
|
-
export declare const createRedisClient: (lockPrefix?: string) => redis.RedisClient;
|
|
141
|
-
export declare const getRedisCommamd: () => redis.RedisClient;
|
|
138
|
+
export declare const getRedisClient: (lockPrefix?: string) => redis.RedisClient;
|
|
142
139
|
export declare const getLoadingCache: () => cache.LoadingCache;
|
|
143
140
|
export declare const getArbCache: (env_args: any) => cache.ArbCache;
|
|
144
141
|
export declare const getArbEventPublisher: (arb_cache: any) => cache.ArbEventPublisher;
|
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.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.getLoadingCache = 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 =
|
|
51
|
+
exports.DATE_TIME_FORMAT_NO_WHITESPACE = 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.getLoadingCache = exports.getRedisClient = 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 = void 0;
|
|
53
53
|
exports._caller = _caller;
|
|
54
54
|
exports.log_trace = log_trace;
|
|
55
55
|
exports.log_debug = log_debug;
|
|
@@ -256,19 +256,10 @@ const format_order_lock_key = (chain_id, group_id, price_id, order_trace_id) =>
|
|
|
256
256
|
return `${chain_id}:lock:${group_id}:${price_id}:${order_trace_id}`;
|
|
257
257
|
};
|
|
258
258
|
exports.format_order_lock_key = format_order_lock_key;
|
|
259
|
-
const getRedisClient = () =>
|
|
260
|
-
return redis.getRedisClient();
|
|
261
|
-
});
|
|
262
|
-
exports.getRedisClient = getRedisClient;
|
|
263
|
-
exports.getRedisCache = exports.getRedisClient;
|
|
264
|
-
const createRedisClient = (lockPrefix = '') => {
|
|
259
|
+
const getRedisClient = (lockPrefix = '') => {
|
|
265
260
|
return new redis.RedisClient(lockPrefix);
|
|
266
261
|
};
|
|
267
|
-
exports.
|
|
268
|
-
const getRedisCommamd = () => {
|
|
269
|
-
return new redis.RedisClient();
|
|
270
|
-
};
|
|
271
|
-
exports.getRedisCommamd = getRedisCommamd;
|
|
262
|
+
exports.getRedisClient = getRedisClient;
|
|
272
263
|
const getLoadingCache = () => {
|
|
273
264
|
return new cache.LoadingCache();
|
|
274
265
|
};
|
package/dist/redis/index.d.ts
CHANGED
|
@@ -1,2 +1 @@
|
|
|
1
|
-
export
|
|
2
|
-
export * from './redis_client';
|
|
1
|
+
export { RedisClient } from './redis_client';
|
package/dist/redis/index.js
CHANGED
|
@@ -1,18 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
|
|
18
|
-
|
|
3
|
+
exports.RedisClient = void 0;
|
|
4
|
+
var redis_client_1 = require("./redis_client");
|
|
5
|
+
Object.defineProperty(exports, "RedisClient", { enumerable: true, get: function () { return redis_client_1.RedisClient; } });
|
|
@@ -9,7 +9,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.
|
|
12
|
+
exports.RedisClient = void 0;
|
|
13
13
|
const index_1 = require("../index");
|
|
14
14
|
const redis_connection_1 = require("./redis_connection");
|
|
15
15
|
const MAX_SUBSCRIBE_RECONNECT = 10;
|
|
@@ -22,14 +22,14 @@ class RedisClient {
|
|
|
22
22
|
}
|
|
23
23
|
init() {
|
|
24
24
|
return __awaiter(this, void 0, void 0, function* () {
|
|
25
|
-
this.redis_client = yield (0, redis_connection_1.
|
|
25
|
+
this.redis_client = yield (0, redis_connection_1.getRedisConnection)('RedisClient');
|
|
26
26
|
(0, index_1.log_info)('[RedisClient] init done');
|
|
27
27
|
});
|
|
28
28
|
}
|
|
29
29
|
ensureClient() {
|
|
30
30
|
return __awaiter(this, void 0, void 0, function* () {
|
|
31
31
|
if (!this.redis_client) {
|
|
32
|
-
this.redis_client = yield (0, redis_connection_1.
|
|
32
|
+
this.redis_client = yield (0, redis_connection_1.getRedisConnection)('RedisClient');
|
|
33
33
|
}
|
|
34
34
|
return this.redis_client;
|
|
35
35
|
});
|
|
@@ -282,4 +282,3 @@ class RedisClient {
|
|
|
282
282
|
}
|
|
283
283
|
}
|
|
284
284
|
exports.RedisClient = RedisClient;
|
|
285
|
-
exports.RedisCommand = RedisClient;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import type { RedisClientType } from 'redis';
|
|
2
|
-
declare function
|
|
3
|
-
export {
|
|
2
|
+
declare function getRedisConnection(module_name?: string): Promise<RedisClientType>;
|
|
3
|
+
export { getRedisConnection, };
|
|
@@ -9,7 +9,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.
|
|
12
|
+
exports.getRedisConnection = getRedisConnection;
|
|
13
13
|
const redis_1 = require("redis");
|
|
14
14
|
let redisClient = null;
|
|
15
15
|
let connectPromise = null;
|
|
@@ -33,7 +33,7 @@ function createConnection() {
|
|
|
33
33
|
throw err;
|
|
34
34
|
});
|
|
35
35
|
}
|
|
36
|
-
function
|
|
36
|
+
function getRedisConnection() {
|
|
37
37
|
return __awaiter(this, arguments, void 0, function* (module_name = '') {
|
|
38
38
|
if (redisClient)
|
|
39
39
|
return redisClient;
|