@clonegod/ttd-bsc-common 3.0.1 → 3.0.2

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.
@@ -52,7 +52,8 @@ class AbstractDexTrade extends ttd_core_1.AbastrcatTrade {
52
52
  return __awaiter(this, void 0, void 0, function* () {
53
53
  this.provider = new ethers_1.ethers.providers.JsonRpcProvider(this.chainConfig.rpcEndpoint);
54
54
  this.transactionSender = new ttd_bsc_send_tx_1.TransactionSender(this.appConfig);
55
- const callerGroupIds = (process.env.CALLER_GROUP_IDS || '').trim().split(',').filter(Boolean);
55
+ const defaultCallerId = `${this.chainNameLower.toUpperCase()}-CALLER`;
56
+ const callerGroupIds = (process.env.CALLER_GROUP_IDS || defaultCallerId).trim().split(',').filter(Boolean);
56
57
  this.callerManager = new caller_manager_1.CallerManager({
57
58
  chainName: this.chainNameLower,
58
59
  provider: this.provider,
@@ -172,9 +173,9 @@ class AbstractDexTrade extends ttd_core_1.AbastrcatTrade {
172
173
  const wsClient = new ttd_core_1.WebSocketClient(wsUrl);
173
174
  wsClient.onOpen(() => {
174
175
  wsClient.send(JSON.stringify({
175
- vault_address: this.tradeConfig.vaultAddress,
176
+ address: this.tradeConfig.vaultAddress,
176
177
  }));
177
- (0, ttd_core_1.log_info)(`Subscribed to trade-monitor for vault=${this.tradeConfig.vaultAddress}`);
178
+ (0, ttd_core_1.log_info)(`Subscribed to trade-monitor for ${this.tradeConfig.vaultAddress}`);
178
179
  });
179
180
  wsClient.onMessage((event) => {
180
181
  if (event.type === 'TradeResult' && event.data) {
@@ -1,15 +1,14 @@
1
- export interface TokenInfo {
2
- symbol: string;
3
- address: string;
4
- decimals: number;
5
- [key: string]: any;
6
- }
7
- export interface TradeDirectionResult {
1
+ export interface TradeDirectionResult<T = any> {
8
2
  isBuy: boolean;
9
- inputToken: TokenInfo;
10
- outputToken: TokenInfo;
11
- baseToken: TokenInfo;
12
- quoteToken: TokenInfo;
3
+ inputToken: T;
4
+ outputToken: T;
5
+ baseToken: T;
6
+ quoteToken: T;
13
7
  }
14
- export declare function resolveTradeDirection(poolInfo: any, isBuy: boolean): TradeDirectionResult;
8
+ export declare function resolveTradeDirection<T = any>(poolInfo: {
9
+ tokenA: T;
10
+ tokenB: T;
11
+ quote_token: string;
12
+ [key: string]: any;
13
+ }, isBuy: boolean): TradeDirectionResult<T>;
15
14
  export declare function calculateStandardPrice(inputAmount: number, outputAmount: number, isBuy: boolean): string;
@@ -4,8 +4,8 @@ exports.resolveTradeDirection = resolveTradeDirection;
4
4
  exports.calculateStandardPrice = calculateStandardPrice;
5
5
  function resolveTradeDirection(poolInfo, isBuy) {
6
6
  const { tokenA, tokenB, quote_token } = poolInfo;
7
- const quoteToken = [tokenA, tokenB].find((t) => t.symbol === quote_token);
8
- const baseToken = [tokenA, tokenB].find((t) => t.symbol !== quote_token);
7
+ const quoteToken = [tokenA, tokenB].find(t => t.symbol === quote_token);
8
+ const baseToken = [tokenA, tokenB].find(t => t.symbol !== quote_token);
9
9
  if (!quoteToken || !baseToken) {
10
10
  throw new Error(`Cannot resolve tokens: tokenA=${tokenA === null || tokenA === void 0 ? void 0 : tokenA.symbol}, tokenB=${tokenB === null || tokenB === void 0 ? void 0 : tokenB.symbol}, quote_token=${quote_token}`);
11
11
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@clonegod/ttd-bsc-common",
3
- "version": "3.0.1",
3
+ "version": "3.0.2",
4
4
  "description": "BSC common library",
5
5
  "license": "UNLICENSED",
6
6
  "main": "dist/index.js",
@@ -14,7 +14,7 @@
14
14
  "push": "npm run build && npm publish"
15
15
  },
16
16
  "dependencies": {
17
- "@clonegod/ttd-core": "3.0.1",
17
+ "@clonegod/ttd-core": "3.0.3",
18
18
  "@clonegod/ttd-bsc-send-tx": "1.0.0",
19
19
  "axios": "^1.12.0",
20
20
  "dotenv": "^16.4.7",