@clonegod/ttd-core 2.0.33 → 2.0.35
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 +2 -2
- package/dist/cache/arb_cache.js +5 -5
- package/dist/index.d.ts +2 -1
- package/dist/index.js +27 -0
- package/package.json +1 -1
|
@@ -48,7 +48,7 @@ export declare class ArbCache {
|
|
|
48
48
|
cache_trade_group(update_group_id?: string): Promise<void>;
|
|
49
49
|
update_trade_group(input_trade_config: TradeServiceConfigType): Promise<void>;
|
|
50
50
|
get_trade_group_id_list(): Promise<string[]>;
|
|
51
|
-
get_trade_service_by_group_id(group_id: string): Promise<TradeServiceConfigType>;
|
|
51
|
+
get_trade_service_by_group_id(group_id: string, force_refresh?: boolean): Promise<TradeServiceConfigType>;
|
|
52
52
|
get_trade_service_by_group_id_no_cache(group_id: string): Promise<TradeServiceConfigType>;
|
|
53
53
|
create_trade_runtime(chain_id: string, group_id: string, dex_id: string, pair_name: string): Promise<TradeRuntimeType>;
|
|
54
54
|
find_pair_in_trade_config(pair_name: string, trade_config: TradeServiceConfigType): TradePairType;
|
|
@@ -75,6 +75,6 @@ export declare class ArbCache {
|
|
|
75
75
|
get_pair_dex_pool_list(quote_pair_list: string[], dex_id_list: string[]): Promise<StandardPoolInfoType[]>;
|
|
76
76
|
get_trade_dex_pool_list(dex_id_list: string[], trade_runtime: TradeRuntimeType): Promise<StandardPoolInfoType[]>;
|
|
77
77
|
get_group_trade_pair_info(chain_id: CHAIN_ID, group_id: string, pair: string): Promise<Map<string, StandardPairType>>;
|
|
78
|
-
get_all_trade_tokens(): Promise<StandardTokenInfoType[]>;
|
|
78
|
+
get_all_trade_tokens(force_refresh?: boolean): Promise<StandardTokenInfoType[]>;
|
|
79
79
|
get_all_trade_pools(group_id?: string): Promise<StandardPoolInfoType[]>;
|
|
80
80
|
}
|
package/dist/cache/arb_cache.js
CHANGED
|
@@ -591,10 +591,10 @@ class ArbCache {
|
|
|
591
591
|
return value;
|
|
592
592
|
});
|
|
593
593
|
}
|
|
594
|
-
get_trade_service_by_group_id(
|
|
595
|
-
return __awaiter(this,
|
|
594
|
+
get_trade_service_by_group_id(group_id_1) {
|
|
595
|
+
return __awaiter(this, arguments, void 0, function* (group_id, force_refresh = false) {
|
|
596
596
|
let trade_group_config;
|
|
597
|
-
if (this.trade_config_map.has(group_id)) {
|
|
597
|
+
if (this.trade_config_map.has(group_id) && !force_refresh) {
|
|
598
598
|
trade_group_config = this.trade_config_map.get(group_id);
|
|
599
599
|
}
|
|
600
600
|
else {
|
|
@@ -947,11 +947,11 @@ class ArbCache {
|
|
|
947
947
|
});
|
|
948
948
|
}
|
|
949
949
|
get_all_trade_tokens() {
|
|
950
|
-
return __awaiter(this,
|
|
950
|
+
return __awaiter(this, arguments, void 0, function* (force_refresh = false) {
|
|
951
951
|
let token_address_set = new Set();
|
|
952
952
|
let group_id_list = yield this.get_trade_group_id_list();
|
|
953
953
|
for (let group_id of group_id_list) {
|
|
954
|
-
let trade_group_conifg = yield this.get_trade_service_by_group_id(group_id);
|
|
954
|
+
let trade_group_conifg = yield this.get_trade_service_by_group_id(group_id, force_refresh);
|
|
955
955
|
let { pair_list } = trade_group_conifg;
|
|
956
956
|
let trade_group_pool_id_list = [];
|
|
957
957
|
for (let trade_pair of pair_list) {
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import BN from 'bn.js';
|
|
2
2
|
import Decimal from 'decimal.js';
|
|
3
3
|
import fs from "fs";
|
|
4
|
-
import { ArbCache, StandardPoolInfoType, StandardTokenInfoType, TokenPriceWithAmountType, TradeCommandLineArgs, TradeResponseType, UniqueOrderbookIdType } from '../types';
|
|
4
|
+
import { ArbCache, StandardPoolInfoType, StandardTokenInfoType, TokenPriceWithAmountType, TradeCommandLineArgs, TradeResponseType, UniqueOrderbookIdType, WalletInfoType } from '../types';
|
|
5
5
|
import * as cache from './cache';
|
|
6
6
|
export * from './analyze';
|
|
7
7
|
export * from './app_config';
|
|
@@ -201,6 +201,7 @@ export declare function load_wallet(group_id: string, only_pubkey?: boolean): {
|
|
|
201
201
|
public_key: string;
|
|
202
202
|
private_key: string;
|
|
203
203
|
};
|
|
204
|
+
export declare function load_wallet_multi(group_ids: string[], only_pubkey?: boolean): WalletInfoType[];
|
|
204
205
|
export declare const success: (data: any) => {
|
|
205
206
|
code: number;
|
|
206
207
|
msg: string;
|
package/dist/index.js
CHANGED
|
@@ -72,6 +72,7 @@ exports.mkdirSync = mkdirSync;
|
|
|
72
72
|
exports.getServerInfo = getServerInfo;
|
|
73
73
|
exports.getIPAddress = getIPAddress;
|
|
74
74
|
exports.load_wallet = load_wallet;
|
|
75
|
+
exports.load_wallet_multi = load_wallet_multi;
|
|
75
76
|
exports.chunkArray = chunkArray;
|
|
76
77
|
require('dotenv').config();
|
|
77
78
|
const bn_js_1 = __importDefault(require("bn.js"));
|
|
@@ -630,6 +631,32 @@ function load_wallet(group_id, only_pubkey = true) {
|
|
|
630
631
|
}
|
|
631
632
|
return wallet;
|
|
632
633
|
}
|
|
634
|
+
function load_wallet_multi(group_ids, only_pubkey = true) {
|
|
635
|
+
if (!group_ids || group_ids.length < 1) {
|
|
636
|
+
throw new Error('Invalid param: group_ids is empty or null !');
|
|
637
|
+
}
|
|
638
|
+
let wallet_dir = process.env.WALLET_DIR;
|
|
639
|
+
if (!wallet_dir) {
|
|
640
|
+
wallet_dir = path_1.default.join((0, exports.home_dir)(), 'data', 'keypairs');
|
|
641
|
+
}
|
|
642
|
+
let wallets = [];
|
|
643
|
+
for (let group_id of group_ids) {
|
|
644
|
+
let file_path = path_1.default.join(wallet_dir, `${group_id}.json`);
|
|
645
|
+
log_info(`Load wallet, group_id=${group_id}, file_path=${file_path}`);
|
|
646
|
+
let wallet = readFile(file_path, true, false);
|
|
647
|
+
if (only_pubkey) {
|
|
648
|
+
wallets.push({
|
|
649
|
+
public_key: wallet.public_key,
|
|
650
|
+
private_key: ''
|
|
651
|
+
});
|
|
652
|
+
}
|
|
653
|
+
else {
|
|
654
|
+
wallets.push(wallet);
|
|
655
|
+
}
|
|
656
|
+
}
|
|
657
|
+
return wallets;
|
|
658
|
+
}
|
|
659
|
+
console.log(load_wallet_multi(['BSC-DEV', 'BSC-DEV2'], false));
|
|
633
660
|
const success = (data) => {
|
|
634
661
|
return {
|
|
635
662
|
code: 200,
|