@clonegod/ttd-core 3.0.11 → 3.0.13
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.
|
@@ -59,7 +59,8 @@ const try_lock_order_msg = (appConfig, order_msg) => __awaiter(void 0, void 0, v
|
|
|
59
59
|
exports.try_lock_order_msg = try_lock_order_msg;
|
|
60
60
|
const order_trace_id_set = new Set();
|
|
61
61
|
const handle_order_message = (trade_appconfig, trade_instance, tx_result_checker_factory, recv_order_msg) => __awaiter(void 0, void 0, void 0, function* () {
|
|
62
|
-
|
|
62
|
+
(0, __1.new_line)(2);
|
|
63
|
+
console.log(`================================== NEW ORDER ==================================`);
|
|
63
64
|
let order_event_message;
|
|
64
65
|
try {
|
|
65
66
|
order_event_message = JSON.parse(recv_order_msg);
|
|
@@ -86,7 +87,6 @@ const handle_order_message = (trade_appconfig, trade_instance, tx_result_checker
|
|
|
86
87
|
let order_submit_result;
|
|
87
88
|
try {
|
|
88
89
|
context = new trade_context_1.TradeContext(price_msg, order_msg);
|
|
89
|
-
let { env_args } = trade_appconfig;
|
|
90
90
|
yield context.init(trade_appconfig);
|
|
91
91
|
txid = yield trade_instance.execute(context);
|
|
92
92
|
order_msg.order_submit_time = Date.now();
|
|
@@ -32,14 +32,14 @@ class TradeContext {
|
|
|
32
32
|
if (!this.pool_info) {
|
|
33
33
|
throw new Error(`Not found pool_info! pool_id=${this.pool_id}, pool_info_list=${JSON.stringify(this.trade_runtime.pair_dex.pool_info_list)}`);
|
|
34
34
|
}
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
if (
|
|
39
|
-
let
|
|
40
|
-
|
|
41
|
-
this.order_msg.amount =
|
|
42
|
-
(0, __1.log_warn)(`Fix input token's amount decimal: from ${amount} to ${
|
|
35
|
+
const { inputToken, outputToken } = (0, __1.get_input_out_token)(this.pool_info, this.order_msg.aToB);
|
|
36
|
+
const amount = this.order_msg.amount;
|
|
37
|
+
const dotIdx = amount.indexOf('.');
|
|
38
|
+
if (dotIdx !== -1 && amount.length - dotIdx - 1 > inputToken.decimals) {
|
|
39
|
+
let truncated = amount.substring(0, dotIdx + inputToken.decimals + 1);
|
|
40
|
+
truncated = truncated.replace(/0+$/, '').replace(/\.$/, '');
|
|
41
|
+
this.order_msg.amount = truncated;
|
|
42
|
+
(0, __1.log_warn)(`Fix input token's amount decimal: from ${amount} to ${truncated}`);
|
|
43
43
|
}
|
|
44
44
|
this.slippage_bps = Math.min(300, Math.max(0, this.trade_runtime.settings.slippage_bps));
|
|
45
45
|
this.aToB = this.pool_info.is_reverse_token ? !this.order_msg.aToB : this.order_msg.aToB;
|