@clonegod/ttd-bsc-common 3.0.27 → 3.0.28
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.
|
@@ -17,6 +17,7 @@ exports.buildTradeConfig = buildTradeConfig;
|
|
|
17
17
|
const ttd_core_1 = require("@clonegod/ttd-core");
|
|
18
18
|
const caller_manager_1 = require("./caller_manager");
|
|
19
19
|
const send_tx_1 = require("../send-tx");
|
|
20
|
+
const base_tx_result_checker_1 = require("./check/base_tx_result_checker");
|
|
20
21
|
const redis_1 = require("../redis");
|
|
21
22
|
const trade_direction_1 = require("../utils/trade_direction");
|
|
22
23
|
const ethers_compat_1 = require("../utils/ethers_compat");
|
|
@@ -114,7 +115,6 @@ class AbstractDexTrade extends ttd_core_1.AbastrcatTrade {
|
|
|
114
115
|
const transfer_amount_gwei = this.getBuilderTipAmoutGwei(context);
|
|
115
116
|
context.ui_tip_amount = new decimal_js_1.default(transfer_amount_gwei).div(Math.pow(10, 9)).toNumber();
|
|
116
117
|
const mainTx = {
|
|
117
|
-
type: 0,
|
|
118
118
|
to: this.tradeConfig.vaultAddress,
|
|
119
119
|
data: vaultCalldata,
|
|
120
120
|
gasLimit: this.chainConfig.gasOptions.gasLimit,
|
|
@@ -148,6 +148,10 @@ class AbstractDexTrade extends ttd_core_1.AbastrcatTrade {
|
|
|
148
148
|
pair, direction: isBuy ? 'BUY' : 'SELL',
|
|
149
149
|
txid, attempt: i, caller: caller.address
|
|
150
150
|
}, order_trace_id);
|
|
151
|
+
try {
|
|
152
|
+
base_tx_result_checker_1.TradeResultSubscriber.getInstance().sendNonceWatch(caller.address, txid);
|
|
153
|
+
}
|
|
154
|
+
catch (_b) { }
|
|
151
155
|
return txid;
|
|
152
156
|
}
|
|
153
157
|
catch (error) {
|
|
@@ -199,8 +203,6 @@ class AbstractDexTrade extends ttd_core_1.AbastrcatTrade {
|
|
|
199
203
|
const real_transfer_amount_gwei = Math.min(Number(transfer_amount_gwei), this.chainConfig.gasOptions.maxTipAmountGwei).toString();
|
|
200
204
|
const real_gas_price_gwei = Math.min(Number(gas_price_gwei), this.chainConfig.gasOptions.maxGasPriceGwei).toString();
|
|
201
205
|
const tx_data = {
|
|
202
|
-
type: 0,
|
|
203
|
-
from: wallet.address,
|
|
204
206
|
to,
|
|
205
207
|
value: ethers_compat_1.ethersCompat.parseUnits(real_transfer_amount_gwei, 'gwei'),
|
|
206
208
|
gasLimit: 21000,
|
|
@@ -1,6 +1,17 @@
|
|
|
1
1
|
import { EnvArgs } from '@clonegod/ttd-core';
|
|
2
2
|
import { AbstractTransactionResultCheck } from "@clonegod/ttd-core/dist/trade";
|
|
3
3
|
import { EventEmitter } from 'events';
|
|
4
|
+
export declare class TradeResultSubscriber {
|
|
5
|
+
private static instance;
|
|
6
|
+
private ws;
|
|
7
|
+
private connected;
|
|
8
|
+
private listeners;
|
|
9
|
+
static getInstance(): TradeResultSubscriber;
|
|
10
|
+
listen(txHash: string, callback: (receipt: any) => void, timeoutMs?: number): void;
|
|
11
|
+
remove(txHash: string): void;
|
|
12
|
+
sendNonceWatch(caller: string, txHash: string): void;
|
|
13
|
+
private ensureConnected;
|
|
14
|
+
}
|
|
4
15
|
export declare abstract class BaseTxResultChecker extends AbstractTransactionResultCheck {
|
|
5
16
|
protected provider: any;
|
|
6
17
|
constructor(env_args: EnvArgs, event_emitter: EventEmitter);
|
|
@@ -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.BaseTxResultChecker = void 0;
|
|
12
|
+
exports.BaseTxResultChecker = exports.TradeResultSubscriber = void 0;
|
|
13
13
|
const ttd_core_1 = require("@clonegod/ttd-core");
|
|
14
14
|
const trade_1 = require("@clonegod/ttd-core/dist/trade");
|
|
15
15
|
const ethers_compat_1 = require("../../utils/ethers_compat");
|
|
@@ -36,6 +36,12 @@ class TradeResultSubscriber {
|
|
|
36
36
|
remove(txHash) {
|
|
37
37
|
this.listeners.delete(txHash.toLowerCase());
|
|
38
38
|
}
|
|
39
|
+
sendNonceWatch(caller, txHash) {
|
|
40
|
+
this.ensureConnected();
|
|
41
|
+
if (this.ws && this.connected) {
|
|
42
|
+
this.ws.send(JSON.stringify({ type: 'nonceWatch', caller, txHash }));
|
|
43
|
+
}
|
|
44
|
+
}
|
|
39
45
|
ensureConnected() {
|
|
40
46
|
if (this.ws && this.connected)
|
|
41
47
|
return;
|
|
@@ -69,6 +75,7 @@ class TradeResultSubscriber {
|
|
|
69
75
|
this.ws.connect();
|
|
70
76
|
}
|
|
71
77
|
}
|
|
78
|
+
exports.TradeResultSubscriber = TradeResultSubscriber;
|
|
72
79
|
TradeResultSubscriber.instance = null;
|
|
73
80
|
class BaseTxResultChecker extends trade_1.AbstractTransactionResultCheck {
|
|
74
81
|
constructor(env_args, event_emitter) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@clonegod/ttd-bsc-common",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.0.28",
|
|
4
4
|
"description": "BSC common library",
|
|
5
5
|
"license": "UNLICENSED",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -15,6 +15,7 @@
|
|
|
15
15
|
},
|
|
16
16
|
"dependencies": {
|
|
17
17
|
"@clonegod/ttd-core": "3.0.8",
|
|
18
|
+
"@clonegod/ttd-bsc-send-tx": "2.0.3",
|
|
18
19
|
"axios": "^1.12.0",
|
|
19
20
|
"dotenv": "^16.4.7",
|
|
20
21
|
"ethers": "^5.8.0"
|