@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.
- package/README.md +3 -0
- package/dist/analyze/index.d.ts +3 -0
- package/dist/analyze/index.js +49 -0
- package/dist/app_config/app_config.d.ts +15 -0
- package/dist/app_config/app_config.js +50 -0
- package/dist/app_config/env_args.d.ts +16 -0
- package/dist/app_config/env_args.js +28 -0
- package/dist/app_config/index.d.ts +2 -0
- package/dist/app_config/index.js +18 -0
- package/dist/cache/arb_cache.d.ts +80 -0
- package/dist/cache/arb_cache.js +1010 -0
- package/dist/cache/arb_event_pub.d.ts +14 -0
- package/dist/cache/arb_event_pub.js +77 -0
- package/dist/cache/arb_event_sub.d.ts +17 -0
- package/dist/cache/arb_event_sub.js +166 -0
- package/dist/cache/index.d.ts +6 -0
- package/dist/cache/index.js +22 -0
- package/dist/cache/loading_cache.d.ts +62 -0
- package/dist/cache/loading_cache.js +233 -0
- package/dist/cache/redis_client.d.ts +3 -0
- package/dist/cache/redis_client.js +73 -0
- package/dist/cache/redis_cmd.d.ts +14 -0
- package/dist/cache/redis_cmd.js +83 -0
- package/dist/index.d.ts +216 -0
- package/dist/index.js +883 -0
- package/dist/market_price/estimate_token_amount.d.ts +4 -0
- package/dist/market_price/estimate_token_amount.js +109 -0
- package/dist/market_price/index.d.ts +1 -0
- package/dist/market_price/index.js +17 -0
- package/dist/pool/cache_pool_config.d.ts +2 -0
- package/dist/pool/cache_pool_config.js +116 -0
- package/dist/pool/index.d.ts +3 -0
- package/dist/pool/index.js +19 -0
- package/dist/pool/pool_util.d.ts +5 -0
- package/dist/pool/pool_util.js +65 -0
- package/dist/pool/types.d.ts +20 -0
- package/dist/pool/types.js +2 -0
- package/dist/quote/index.d.ts +1 -0
- package/dist/quote/index.js +17 -0
- package/dist/quote/log_quote_price.d.ts +2 -0
- package/dist/quote/log_quote_price.js +29 -0
- package/dist/quote/on_quote_response.d.ts +3 -0
- package/dist/quote/on_quote_response.js +28 -0
- package/dist/quote/publish_quote_price.d.ts +3 -0
- package/dist/quote/publish_quote_price.js +19 -0
- package/dist/quote/to_price_message.d.ts +5 -0
- package/dist/quote/to_price_message.js +103 -0
- package/dist/test/test_is_empty.d.ts +1 -0
- package/dist/test/test_is_empty.js +24 -0
- package/dist/test/test_log_level.d.ts +3 -0
- package/dist/test/test_log_level.js +29 -0
- package/dist/test/test_merge_property.d.ts +1 -0
- package/dist/test/test_merge_property.js +21 -0
- package/dist/token/cache_token_config.d.ts +2 -0
- package/dist/token/cache_token_config.js +68 -0
- package/dist/token/fixed_symbol_address.d.ts +2 -0
- package/dist/token/fixed_symbol_address.js +26 -0
- package/dist/token/index.d.ts +6 -0
- package/dist/token/index.js +22 -0
- package/dist/token/is_not_arb_token.d.ts +1 -0
- package/dist/token/is_not_arb_token.js +24 -0
- package/dist/token/price/gecko_terminal.d.ts +2 -0
- package/dist/token/price/gecko_terminal.js +69 -0
- package/dist/token/price/get_bsc_token_price.d.ts +2 -0
- package/dist/token/price/get_bsc_token_price.js +131 -0
- package/dist/token/price/get_solana_token_price.d.ts +2 -0
- package/dist/token/price/get_solana_token_price.js +17 -0
- package/dist/token/price/get_tron_token_price.d.ts +2 -0
- package/dist/token/price/get_tron_token_price.js +17 -0
- package/dist/token/price/index.d.ts +3 -0
- package/dist/token/price/index.js +19 -0
- package/dist/token/token_util.d.ts +3 -0
- package/dist/token/token_util.js +23 -0
- package/dist/token/types.d.ts +29 -0
- package/dist/token/types.js +2 -0
- package/package.json +47 -0
- package/types/index.d.ts +709 -0
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.getCache = getCache;
|
|
16
|
+
const moment_1 = __importDefault(require("moment"));
|
|
17
|
+
const redis_1 = require("redis");
|
|
18
|
+
let redisClient;
|
|
19
|
+
let isReady;
|
|
20
|
+
let ip = process.env.REDIS_HOST || '127.0.0.1';
|
|
21
|
+
let port = process.env.REDIS_PORT || '6379';
|
|
22
|
+
let url = `redis://${ip}:${port}`;
|
|
23
|
+
const cacheOptions = {
|
|
24
|
+
url
|
|
25
|
+
};
|
|
26
|
+
let current_time = () => (0, moment_1.default)().format('YYYY-MM-DD HH:mm:ss SSS');
|
|
27
|
+
console.log('\n\n');
|
|
28
|
+
console.log(current_time(), `-------> Init redis start`);
|
|
29
|
+
console.log(current_time(), `Connect to redis, url=${url}`);
|
|
30
|
+
var first_call = true;
|
|
31
|
+
let wait_redis_ready = (...args_1) => __awaiter(void 0, [...args_1], void 0, function* (module_name = '') {
|
|
32
|
+
for (let i = 1; i <= 10; i++) {
|
|
33
|
+
try {
|
|
34
|
+
if (!redisClient) {
|
|
35
|
+
console.log(current_time(), module_name, `[${i}] redis not ready`);
|
|
36
|
+
yield new Promise((r) => setTimeout(r, 1000));
|
|
37
|
+
continue;
|
|
38
|
+
}
|
|
39
|
+
console.log(current_time(), module_name, `[${i}] ping...`);
|
|
40
|
+
let res = yield redisClient.ping();
|
|
41
|
+
console.log(current_time(), module_name, `[${i}] ping, got: ${res}`);
|
|
42
|
+
break;
|
|
43
|
+
}
|
|
44
|
+
catch (err) {
|
|
45
|
+
console.error(current_time(), module_name, `[${i}] ping, got error!`, err);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
function getCache() {
|
|
50
|
+
return __awaiter(this, arguments, void 0, function* (module_name = '') {
|
|
51
|
+
if (!first_call) {
|
|
52
|
+
yield wait_redis_ready(module_name);
|
|
53
|
+
}
|
|
54
|
+
first_call = false;
|
|
55
|
+
if (!isReady) {
|
|
56
|
+
redisClient = (0, redis_1.createClient)(Object.assign({}, cacheOptions));
|
|
57
|
+
redisClient.on('error', err => console.error(`Redis Error: ${err}`));
|
|
58
|
+
redisClient.on('connect', () => console.info('Redis connected'));
|
|
59
|
+
redisClient.on('reconnecting', () => console.info('Redis reconnecting'));
|
|
60
|
+
redisClient.on('ready', () => {
|
|
61
|
+
isReady = true;
|
|
62
|
+
console.info('Redis ready!');
|
|
63
|
+
});
|
|
64
|
+
yield redisClient.connect();
|
|
65
|
+
}
|
|
66
|
+
return redisClient;
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
getCache().then(connection => {
|
|
70
|
+
redisClient = connection;
|
|
71
|
+
}).catch(err => {
|
|
72
|
+
console.error({ err }, 'Failed to connect to Redis');
|
|
73
|
+
});
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { RedisClientType } from "redis";
|
|
2
|
+
export declare class RedisCommand {
|
|
3
|
+
redis_client: RedisClientType;
|
|
4
|
+
constructor();
|
|
5
|
+
init(): Promise<void>;
|
|
6
|
+
exists(key: string): Promise<number>;
|
|
7
|
+
ttl(key: string): Promise<number>;
|
|
8
|
+
expire(key: string, ttl: number): Promise<boolean>;
|
|
9
|
+
del(key: string): Promise<number>;
|
|
10
|
+
set_nx(key: string, value: string): Promise<boolean>;
|
|
11
|
+
hinc(key: string, field: string, ttl?: number): Promise<number[]>;
|
|
12
|
+
subscribe(channel: string, listener: any): Promise<void>;
|
|
13
|
+
publish(channel: string, message: string): Promise<void>;
|
|
14
|
+
}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.RedisCommand = void 0;
|
|
13
|
+
const index_1 = require("../index");
|
|
14
|
+
const redis_client_1 = require("./redis_client");
|
|
15
|
+
class RedisCommand {
|
|
16
|
+
constructor() {
|
|
17
|
+
}
|
|
18
|
+
init() {
|
|
19
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
20
|
+
(0, index_1.log_info)('init redis client start');
|
|
21
|
+
yield (0, index_1.sleep)(1000);
|
|
22
|
+
this.redis_client = yield (0, redis_client_1.getCache)('RedisCommand');
|
|
23
|
+
(0, index_1.log_info)('init redis client done');
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
exists(key) {
|
|
27
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
28
|
+
return yield this.redis_client.exists(key);
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
ttl(key) {
|
|
32
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
33
|
+
return yield this.redis_client.ttl(key);
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
expire(key, ttl) {
|
|
37
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
38
|
+
return yield this.redis_client.expire(key, ttl);
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
del(key) {
|
|
42
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
43
|
+
return yield this.redis_client.del(key);
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
set_nx(key, value) {
|
|
47
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
48
|
+
return yield this.redis_client.setNX(key, value);
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
hinc(key_1, field_1) {
|
|
52
|
+
return __awaiter(this, arguments, void 0, function* (key, field, ttl = 3600) {
|
|
53
|
+
let res = [];
|
|
54
|
+
let res1 = yield this.redis_client.hIncrBy(key, field, 1);
|
|
55
|
+
res.push(res1);
|
|
56
|
+
if (ttl > 0) {
|
|
57
|
+
let res2 = yield this.redis_client.hExpire(key, field, ttl);
|
|
58
|
+
res.push(res2);
|
|
59
|
+
}
|
|
60
|
+
return res;
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
subscribe(channel, listener) {
|
|
64
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
65
|
+
let subscriber = this.redis_client.duplicate();
|
|
66
|
+
subscriber.on('error', (err) => __awaiter(this, void 0, void 0, function* () {
|
|
67
|
+
let mills = 3000;
|
|
68
|
+
(0, index_1.log_error)(`subscribe channel error! channel: ${channel}`, err);
|
|
69
|
+
(0, index_1.log_info)(`wait ${mills} ms, re-subscribe channel: ${channel}`);
|
|
70
|
+
yield (0, index_1.sleep)(mills);
|
|
71
|
+
this.subscribe(channel, listener);
|
|
72
|
+
}));
|
|
73
|
+
yield subscriber.connect();
|
|
74
|
+
subscriber.subscribe(channel, listener);
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
publish(channel, message) {
|
|
78
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
79
|
+
this.redis_client.publish(channel, message);
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
exports.RedisCommand = RedisCommand;
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,216 @@
|
|
|
1
|
+
import BN from 'bn.js';
|
|
2
|
+
import Decimal from 'decimal.js';
|
|
3
|
+
import fs from "fs";
|
|
4
|
+
import { ArbCache, StandardPoolInfoType, StandardTokenInfoType, TokenPriceWithAmountType, TradeCommandLineArgs, TradeResponseType, UniqueOrderbookIdType } from '../types';
|
|
5
|
+
import * as cache from './cache';
|
|
6
|
+
export * from './analyze';
|
|
7
|
+
export * from './app_config';
|
|
8
|
+
export * from './pool';
|
|
9
|
+
export * from './quote';
|
|
10
|
+
export * from './token';
|
|
11
|
+
export declare const FAILED = "FAILED";
|
|
12
|
+
export declare const SUCCESS = "SUCCESS";
|
|
13
|
+
export declare const NOT_FOUND = "NOT_FOUND";
|
|
14
|
+
export declare const PROCESSING = "PROCESSING";
|
|
15
|
+
export declare const REGEX_HEX_PREFIX: RegExp;
|
|
16
|
+
export declare const QUOTE_AMOUNT_USD_MIN = 50;
|
|
17
|
+
export declare const QUOTE_AMOUNT_USD_MAX = 500;
|
|
18
|
+
export declare const TRANSACTION_STATE_PROCESSING = "TRANSACTION_STATE_PROCESSING";
|
|
19
|
+
export declare const TRANSACTION_STATE_SUCCESS = "TRANSACTION_STATE_SUCCESS";
|
|
20
|
+
export declare const TRANSACTION_STATE_FAILED = "TRANSACTION_STATE_FAILED";
|
|
21
|
+
export declare const STREAMING_TRANSACTION_CONFIRMED = "STREAMING_TRANSACTION_CONFIRMED";
|
|
22
|
+
export declare enum CHAIN_ID {
|
|
23
|
+
TRON = "TRON",
|
|
24
|
+
SOLANA = "SOLANA",
|
|
25
|
+
BSC = "BSC"
|
|
26
|
+
}
|
|
27
|
+
export declare enum DEX_ID {
|
|
28
|
+
SUNSWAP_V2 = "SUNSWAP-V2",
|
|
29
|
+
SUNSWAP_V3 = "SUNSWAP-V3",
|
|
30
|
+
RAYDIUM_AMM = "RAYDIUM-AMM",
|
|
31
|
+
RAYDIUM_CLMM = "RAYDIUM-CLMM",
|
|
32
|
+
RAYDIUM_CPMM = "RAYDIUM-CPMM",
|
|
33
|
+
ORCA_CLMM = "ORCA-CLMM",
|
|
34
|
+
METEORA_DLMM = "METEORA-DLMM",
|
|
35
|
+
PUMPFUN_AMM = "PUMPFUN-AMM",
|
|
36
|
+
PANCAKE_AMM = "PANCAKE-AMM",
|
|
37
|
+
PANCAKE_CLMM = "PANCAKE-CLMM"
|
|
38
|
+
}
|
|
39
|
+
export declare enum GROUP_ID {
|
|
40
|
+
TRON_DEV1 = "TRON-DEV1",
|
|
41
|
+
TRON_TEST1 = "TRON-TEST1",
|
|
42
|
+
TRON_TEST2 = "TRON-TEST2",
|
|
43
|
+
TRON_TTD1 = "TRON-TTD1"
|
|
44
|
+
}
|
|
45
|
+
export declare enum TRADE_TYPE {
|
|
46
|
+
SWAP = "swap",
|
|
47
|
+
ORDERBOOK = "orderbook"
|
|
48
|
+
}
|
|
49
|
+
export declare enum SystemErrorCodeType {
|
|
50
|
+
INVALID_GROUP_ID = "INVALID_GROUP_ID",
|
|
51
|
+
SYSTEM_ERROR = "SYSTEM_ERROR",
|
|
52
|
+
UNKOWN_ERROR = "UNKOWN_ERROR"
|
|
53
|
+
}
|
|
54
|
+
export declare enum TradeErrorCodeType {
|
|
55
|
+
AmountOutBelowMinimum = "AmountOutBelowMinimum",
|
|
56
|
+
InsufficientFunds = "InsufficientFunds",
|
|
57
|
+
ExceededCUsLimit = "ExceededCUsLimit",
|
|
58
|
+
BlockhashNotFound = "BlockhashNotFound",
|
|
59
|
+
AccountNotInitialized = "AccountNotInitialized",
|
|
60
|
+
InvalidTickArraySequence = "InvalidTickArraySequence",
|
|
61
|
+
TokenNotApproved = "TokenNotApproved",
|
|
62
|
+
UNKOWN = "UNKOWN"
|
|
63
|
+
}
|
|
64
|
+
export declare enum OnChainDataSubscribeType {
|
|
65
|
+
WS = "ws",
|
|
66
|
+
GRPC = "grpc"
|
|
67
|
+
}
|
|
68
|
+
export declare enum CACHE_KEY_TYPE {
|
|
69
|
+
MARKET_TOKEN_PRICE = "m:price",
|
|
70
|
+
CONFIG_TOKEN_LIST = "c:token",
|
|
71
|
+
CONFIG_POOL_LIST = "c:pool",
|
|
72
|
+
CONFIG_PAIR_LIST = "c:pair",
|
|
73
|
+
CONFIG_COMMON_SERVICE = "c:common",
|
|
74
|
+
CONFIG_TRADE_SERVICE = "c:trade",
|
|
75
|
+
QUOTE_PRICE = "q:price",
|
|
76
|
+
ORDER_MESSAGE = "o:msg",
|
|
77
|
+
ORDER_RESULT = "o:result"
|
|
78
|
+
}
|
|
79
|
+
export declare const format_symbol_name: (symbol: string) => string;
|
|
80
|
+
export declare const format_unique_orderbook_id: (chain_id: CHAIN_ID, dex_id: DEX_ID, pool_id: string, fee_rate: number) => string;
|
|
81
|
+
export declare const parse_unique_orderbook_id: (unique_orderbook_id: string) => UniqueOrderbookIdType;
|
|
82
|
+
export declare const format_unique_order_msg_id: (group_id: string, price_id: string, order_trace_id: string) => string;
|
|
83
|
+
export declare const format_order_lock_key: (chain_id: string, group_id: string, price_id: string, order_trace_id: string) => string;
|
|
84
|
+
export declare const getRedisCache: () => Promise<import("redis").RedisClientType>;
|
|
85
|
+
export declare const getLoadingCache: () => cache.LoadingCache;
|
|
86
|
+
export declare const getRedisCommamd: () => cache.RedisCommand;
|
|
87
|
+
export declare const getArbCache: (env_args: any) => cache.ArbCache;
|
|
88
|
+
export declare const getArbEventPublisher: (arb_cache: any) => cache.ArbEventPublisher;
|
|
89
|
+
export declare const getArbEventSubscriber: (arb_cache: any) => cache.ArbEventSubscriber;
|
|
90
|
+
export declare const get_cache_key: (chain_id: CHAIN_ID, cache_type: string, id: string) => string;
|
|
91
|
+
export declare const get_config_channel_name: (chain_id: CHAIN_ID) => string;
|
|
92
|
+
export declare const get_quote_channel_name: (chain_id: string) => string;
|
|
93
|
+
export declare const get_order_channel_name: (group_id: string, pair: string, dex_id: DEX_ID) => string;
|
|
94
|
+
export declare const get_wallet_raw_tx_channel_name: (group_id: string, wallet: string) => string;
|
|
95
|
+
export declare const get_tx_result_channel_name: (group_id: string, pair: string) => string;
|
|
96
|
+
export declare enum REDIS_EVENT_CHANNEL {
|
|
97
|
+
CONFIG_CHANGE = "CONFIG_CHANGE",
|
|
98
|
+
QUOTE = "QUOTE",
|
|
99
|
+
ORDER = "ORDER",
|
|
100
|
+
ORDER_RESULT = "ORDER_RESULT",
|
|
101
|
+
TX_RAW_DATA = "TX_RAW_DATA",
|
|
102
|
+
TX_RESULT = "TX_RESULT",
|
|
103
|
+
TRADE_INSTANCE_STATUS = "TRADE_INSTANCE_STATUS"
|
|
104
|
+
}
|
|
105
|
+
export declare enum REDIS_EVENT_TYPE_CONFIG_CHANGE {
|
|
106
|
+
TOKEN_CONFIG_CHANGE = "TOKEN_CONFIG_CHANGE",
|
|
107
|
+
POOL_CONFIG_CHANGE = "POOL_CONFIG_CHANGE",
|
|
108
|
+
GROUP_CONFIG_CHANGE = "GROUP_CONFIG_CHANGE"
|
|
109
|
+
}
|
|
110
|
+
export declare enum REDIS_EVENT_TYPE_QUOTE {
|
|
111
|
+
NEW_QUOTE_PRICE = "NEW_QUOTE_PRICE"
|
|
112
|
+
}
|
|
113
|
+
export declare enum REDIS_EVENT_TYPE_ORDER {
|
|
114
|
+
NEW_ORDER = "NEW_ORDER",
|
|
115
|
+
ORDER_PROCESSING = "ORDER_PROCESSING",
|
|
116
|
+
ORDER_SUCCESS = "ORDER_SUCCESS",
|
|
117
|
+
ORDER_FAILED = "ORDER_FAILED",
|
|
118
|
+
ORDER_NOT_FOUND = "ORDER_NOT_FOUND"
|
|
119
|
+
}
|
|
120
|
+
export declare enum REDIS_EVENT_TYPE_TRADE_INSTANCE_CHANGE {
|
|
121
|
+
TRADE_INSTANCE_STARTUP = "TRADE_INSTANCE_STARTUP",
|
|
122
|
+
TRADE_INSTANCE_EXIT = "TRADE_INSTANCE_EXIT"
|
|
123
|
+
}
|
|
124
|
+
export declare function _caller(): {
|
|
125
|
+
method: string;
|
|
126
|
+
module: string;
|
|
127
|
+
};
|
|
128
|
+
export declare enum LOG_LEVEL {
|
|
129
|
+
TRACE = 1,
|
|
130
|
+
DEBUG = 2,
|
|
131
|
+
INFO = 3,
|
|
132
|
+
WARN = 4,
|
|
133
|
+
ERROR = 5
|
|
134
|
+
}
|
|
135
|
+
export declare const _active_log_level: number;
|
|
136
|
+
export declare abstract class LOG {
|
|
137
|
+
static trace: boolean;
|
|
138
|
+
static debug: boolean;
|
|
139
|
+
static info: boolean;
|
|
140
|
+
static warn: boolean;
|
|
141
|
+
}
|
|
142
|
+
export declare function log_trace(msg: string, data?: {}, traceId?: string): void;
|
|
143
|
+
export declare function log_debug(msg: string, data?: {}, traceId?: string): void;
|
|
144
|
+
export declare function log_warn(msg: string, data?: {}, traceId?: string): void;
|
|
145
|
+
export declare function log_info(msg: string, data?: {}, traceId?: string, caller?: {
|
|
146
|
+
module: string;
|
|
147
|
+
}, level?: LOG_LEVEL): void;
|
|
148
|
+
export declare function log_error(msg: string, err: Error, traceId?: string, caller?: {
|
|
149
|
+
module: string;
|
|
150
|
+
}): void;
|
|
151
|
+
export declare function new_line(lines?: number): void;
|
|
152
|
+
export declare const generateRandomNumber: (min: number, max: number) => number;
|
|
153
|
+
export declare class DecimalUtil {
|
|
154
|
+
static adjustDecimals(input: Decimal, shift?: number): Decimal;
|
|
155
|
+
static fromBN(input: BN, shift?: number): Decimal;
|
|
156
|
+
static fromNumber(input: number, shift?: number): Decimal;
|
|
157
|
+
static toBN(input: Decimal, shift?: number): BN;
|
|
158
|
+
static number_div(number1: number, number2: number, decimals?: number): number;
|
|
159
|
+
}
|
|
160
|
+
export declare const to_json_str: (value: object, space?: number) => string;
|
|
161
|
+
export declare const DATE_TIME_FORMAT_DEFAULT = "YYYY-MM-DD HH:mm:ss SSS";
|
|
162
|
+
export declare const DATE_TIME_FORMAT_NO_WHITESPACE = "YYYY_MM_DD_HH_mm_ss";
|
|
163
|
+
export declare function getCurDateTime(format?: string): string;
|
|
164
|
+
export declare function getCurTimeShort(): string;
|
|
165
|
+
export declare function parseToDateTime(milliseconds: number, format?: string): string;
|
|
166
|
+
export declare function getCurTimeInMills(): number;
|
|
167
|
+
export declare function curr_milliseconds(): number;
|
|
168
|
+
export declare function sleep(mills: any): Promise<void>;
|
|
169
|
+
export declare function parseDateTimeStrToMills(date_time_str: string, format?: string): number;
|
|
170
|
+
export declare const uuid: () => any;
|
|
171
|
+
export declare const deep_clone: (obj: object) => any;
|
|
172
|
+
export declare function isEmpty(v: any): boolean;
|
|
173
|
+
export declare const isTrue: (value: string | undefined) => boolean;
|
|
174
|
+
export declare const isArray: (arg: any) => arg is any[];
|
|
175
|
+
export declare const deep_merge_object: (default_obj: object, new_obj: object) => any;
|
|
176
|
+
export declare const postJSON: (url: any, data: any) => Promise<unknown>;
|
|
177
|
+
export declare const home_dir: () => string;
|
|
178
|
+
export declare function file_exists(filepath: string): boolean;
|
|
179
|
+
export declare function readFile(filename: string, to_json_object?: boolean, print_content?: boolean): any;
|
|
180
|
+
export declare function writeFile(filename: string, data: string): void;
|
|
181
|
+
export declare function mkdirSync(path: fs.PathLike, recursive?: boolean): void;
|
|
182
|
+
export declare function getServerInfo(): {
|
|
183
|
+
region: string;
|
|
184
|
+
ip: string;
|
|
185
|
+
name: string;
|
|
186
|
+
};
|
|
187
|
+
export declare function getIPAddress(): string;
|
|
188
|
+
export declare function load_wallet(group_id: string, only_pubkey?: boolean): {
|
|
189
|
+
public_key: string;
|
|
190
|
+
private_key: string;
|
|
191
|
+
};
|
|
192
|
+
export declare const success: (data: any) => {
|
|
193
|
+
code: number;
|
|
194
|
+
msg: string;
|
|
195
|
+
data: any;
|
|
196
|
+
};
|
|
197
|
+
export declare const failed: (err: Error, error_code?: string, code?: number) => {
|
|
198
|
+
code: number;
|
|
199
|
+
msg: string;
|
|
200
|
+
error_code: string;
|
|
201
|
+
};
|
|
202
|
+
export declare const estimate_amount_in_token: (arb_cache: ArbCache, token: StandardTokenInfoType, amount_in_usd: number, query_token_market_price_url?: string) => Promise<string>;
|
|
203
|
+
export declare const calc_amount_in_token: (amount_in_usd: number, market_price: string, token_info: StandardTokenInfoType) => TokenPriceWithAmountType;
|
|
204
|
+
export declare const get_input_out_token: (poolInfo: StandardPoolInfoType, aToB: boolean) => {
|
|
205
|
+
inputToken: StandardTokenInfoType;
|
|
206
|
+
outputToken: StandardTokenInfoType;
|
|
207
|
+
};
|
|
208
|
+
export declare const get_input_out_token_fix: (poolInfo: StandardPoolInfoType, aToB: boolean) => {
|
|
209
|
+
inputToken: StandardTokenInfoType;
|
|
210
|
+
outputToken: StandardTokenInfoType;
|
|
211
|
+
};
|
|
212
|
+
export declare const parse_trade_cmdline_args: () => TradeCommandLineArgs;
|
|
213
|
+
export declare const save_trade_execution_logs: (trade_response: TradeResponseType) => Promise<void>;
|
|
214
|
+
export declare const inspect_arb_local_cache: (express: any, appConfig: any) => void;
|
|
215
|
+
export declare const execute_bash: (command: string, parse_json?: boolean) => Promise<any>;
|
|
216
|
+
export declare function chunkArray<T>(arr: T[], chunkSize: number): T[][];
|