@clonegod/ttd-core 2.1.29 → 2.1.31
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.
|
@@ -6,6 +6,7 @@ export declare abstract class AbstractTradeAppConfig extends AppConfig {
|
|
|
6
6
|
is_already_subscribe_wallet_raw_txn: boolean;
|
|
7
7
|
trade_instance: AbastrcatTrade;
|
|
8
8
|
tx_result_checker: AbstractTransactionResultCheck;
|
|
9
|
+
private is_order_event_subscribed;
|
|
9
10
|
constructor();
|
|
10
11
|
init(): Promise<void>;
|
|
11
12
|
init_trade_runtime(): Promise<void>;
|
|
@@ -17,6 +17,7 @@ class AbstractTradeAppConfig extends AppConfig_1.AppConfig {
|
|
|
17
17
|
constructor() {
|
|
18
18
|
super();
|
|
19
19
|
this.is_already_subscribe_wallet_raw_txn = false;
|
|
20
|
+
this.is_order_event_subscribed = false;
|
|
20
21
|
}
|
|
21
22
|
init() {
|
|
22
23
|
const _super = Object.create(null, {
|
|
@@ -43,6 +44,11 @@ class AbstractTradeAppConfig extends AppConfig_1.AppConfig {
|
|
|
43
44
|
}
|
|
44
45
|
subscribe_order_event(trade_instance, new_tx_result_checker_factory) {
|
|
45
46
|
return __awaiter(this, void 0, void 0, function* () {
|
|
47
|
+
if (this.is_order_event_subscribed) {
|
|
48
|
+
(0, __1.log_warn)('subscribe_order_event called multiple times, skip');
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
this.is_order_event_subscribed = true;
|
|
46
52
|
let handler = (message) => (0, handle_order_message_1.handle_order_message)(this, trade_instance, new_tx_result_checker_factory, message);
|
|
47
53
|
let group_id = this.trade_runtime.group.id;
|
|
48
54
|
let pair_name = this.trade_runtime.pair_name;
|
|
@@ -120,7 +120,7 @@ function fetchPriceFromJupiter(addresses) {
|
|
|
120
120
|
if (response.data) {
|
|
121
121
|
for (const address of addresses) {
|
|
122
122
|
const key = address;
|
|
123
|
-
if (response.data[key] !== undefined) {
|
|
123
|
+
if (response.data[key] !== undefined && response.data[key]['usdPrice'] > 0) {
|
|
124
124
|
result.set(address, {
|
|
125
125
|
address: address,
|
|
126
126
|
price: response.data[key]['usdPrice'].toString(),
|
|
@@ -157,5 +157,6 @@ if (require.main === module) {
|
|
|
157
157
|
"JUPyiwrYJFskUPiHa7hkeR8VUtAeFoSYbKedZNsDvCN",
|
|
158
158
|
"MEW1gQWJ3nEXg2qgERiKu7FAFj79PHvQVREQUzScPP5",
|
|
159
159
|
];
|
|
160
|
+
console.log(yield fetchPriceFromJupiter(addresses));
|
|
160
161
|
}))();
|
|
161
162
|
}
|
|
@@ -56,6 +56,7 @@ const try_lock_order_msg = (appConfig, order_msg) => __awaiter(void 0, void 0, v
|
|
|
56
56
|
return is_lock_success;
|
|
57
57
|
});
|
|
58
58
|
exports.try_lock_order_msg = try_lock_order_msg;
|
|
59
|
+
const order_trace_id_set = new Set();
|
|
59
60
|
const handle_order_message = (trade_appconfig, trade_instance, tx_result_checker_factory, recv_order_msg) => __awaiter(void 0, void 0, void 0, function* () {
|
|
60
61
|
(0, __1.new_line)(3);
|
|
61
62
|
console.log(`=================================================================================`);
|
|
@@ -70,15 +71,11 @@ const handle_order_message = (trade_appconfig, trade_instance, tx_result_checker
|
|
|
70
71
|
let { price_msg, id_parts } = yield check_parse_order_msg(trade_appconfig, order_msg);
|
|
71
72
|
let { order_trace_id } = order_msg;
|
|
72
73
|
let { chain_id, dex_id, pool_id, fee_rate } = id_parts;
|
|
73
|
-
if (
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
(0, __1.log_warn)(`try lock order failed!`, {
|
|
77
|
-
chain_id, group_id, order_trace_id
|
|
78
|
-
});
|
|
79
|
-
return;
|
|
80
|
-
}
|
|
74
|
+
if (order_trace_id_set.has(order_trace_id)) {
|
|
75
|
+
(0, __1.log_warn)(`order_trace_id already processed, skip`, { order_trace_id });
|
|
76
|
+
return;
|
|
81
77
|
}
|
|
78
|
+
order_trace_id_set.add(order_trace_id);
|
|
82
79
|
let context;
|
|
83
80
|
let txid = '';
|
|
84
81
|
let order_submit_result;
|