@clonegod/ttd-sol-common 2.0.73 → 2.0.75

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.
@@ -12,12 +12,15 @@ function subscribe_pool_account_update(dex_id, pool_list, callback) {
12
12
  });
13
13
  });
14
14
  ws_client.onMessage(((eventData) => {
15
+ if (eventData.type === 'subscribed') {
16
+ (0, dist_1.log_info)(`subscribe_pool_account_update: ACK ${eventData.ws_id || eventData.pool_address || ''}`);
17
+ return;
18
+ }
15
19
  if (!eventData.data) {
16
20
  (0, dist_1.log_warn)(`subscribe_pool_account_update: no data`, eventData);
21
+ return;
17
22
  }
18
- else {
19
- callback(eventData);
20
- }
23
+ callback(eventData);
21
24
  }));
22
25
  ws_client.connect();
23
26
  }
@@ -74,7 +74,9 @@ class AbstractDexQuote {
74
74
  return true;
75
75
  }
76
76
  async handleBlockUpdateEvent(eventData) {
77
- const { slot, blockTime } = JSON.parse(eventData);
77
+ const parsed = JSON.parse(eventData);
78
+ const slot = Number(parsed.slot);
79
+ const blockTime = Number(parsed.blockTime);
78
80
  this.assertValidBlockNumber(slot, `${this.dexId} block-event`);
79
81
  this.latestBlockSlot = slot;
80
82
  for (const poolInfo of this.poolInfoMap.values()) {
@@ -7,8 +7,8 @@ function toSolPoolEvent(data) {
7
7
  pool_address: data.pool_address,
8
8
  dex_id: data.dex_id,
9
9
  pool_name: data.pool_name,
10
- blockNumber: d.slot,
11
- writeVersion: d.write_version,
10
+ blockNumber: Number(d.slot),
11
+ writeVersion: d.write_version != null ? Number(d.write_version) : undefined,
12
12
  txHash: d.tx_hash || 'account',
13
13
  blockTime: data.event_time || 0,
14
14
  poolAccountData: d.pool_account_data,
@@ -23,6 +23,7 @@ export interface SolanaBlockMetaUpdateEvent {
23
23
  slot: number;
24
24
  blockHash: string;
25
25
  blockTime: number;
26
+ recvBlockTime: number;
26
27
  blockHeight: number;
27
28
  parentSlot: number;
28
29
  parentBlockhash: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@clonegod/ttd-sol-common",
3
- "version": "2.0.73",
3
+ "version": "2.0.75",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -13,10 +13,10 @@
13
13
  "push": "npm run build && npm publish"
14
14
  },
15
15
  "dependencies": {
16
- "@clonegod/ttd-core": "3.1.87",
16
+ "@clonegod/ttd-core": "3.1.88",
17
17
  "@solana/web3.js": "1.91.6",
18
18
  "rpc-websockets": "7.10.0",
19
- "axios": "^1.2.3",
19
+ "axios": "1.17.0",
20
20
  "bn.js": "^4.12.1",
21
21
  "bs58": "^6.0.0",
22
22
  "helius-laserstream": "^0.4.0"
@@ -1,5 +1,5 @@
1
1
  import { StandardPoolInfoType } from "@clonegod/ttd-core";
2
- import { DEX_ID, log_warn, SERVICE_PORT, WebSocketClient } from "@clonegod/ttd-core/dist";
2
+ import { DEX_ID, log_info, log_warn, SERVICE_PORT, WebSocketClient } from "@clonegod/ttd-core/dist";
3
3
  import { SolanaPoolAccountUpdateEventData } from "../types";
4
4
 
5
5
  /**
@@ -17,11 +17,16 @@ export function subscribe_pool_account_update(dex_id: DEX_ID, pool_list: Standar
17
17
  })
18
18
  })
19
19
  ws_client.onMessage(((eventData: SolanaPoolAccountUpdateEventData): void => {
20
+ // 订阅 ACK(stream-quote 确认订阅成功,无 data 字段)→ 打 info 确认链路通,不当异常告警
21
+ if ((eventData as any).type === 'subscribed') {
22
+ log_info(`subscribe_pool_account_update: ACK ${(eventData as any).ws_id || (eventData as any).pool_address || ''}`);
23
+ return;
24
+ }
20
25
  if (!eventData.data) {
21
26
  log_warn(`subscribe_pool_account_update: no data`, eventData);
22
- } else {
23
- callback(eventData);
27
+ return;
24
28
  }
29
+ callback(eventData);
25
30
  }));
26
31
  ws_client.connect();
27
32
  }
@@ -191,7 +191,10 @@ export abstract class AbstractDexQuote<C extends SolanaChainOps = SolanaChainOps
191
191
  }
192
192
 
193
193
  private async handleBlockUpdateEvent(eventData: string): Promise<void> {
194
- const { slot, blockTime } = JSON.parse(eventData) as SolanaBlockMetaUpdateEvent
194
+ const parsed = JSON.parse(eventData) as SolanaBlockMetaUpdateEvent
195
+ // slot/blockTime 可能是 protobuf u64 字符串 → 在"blockNumber"归一化边界统一转 number
196
+ const slot = Number(parsed.slot)
197
+ const blockTime = Number(parsed.blockTime)
195
198
  this.assertValidBlockNumber(slot, `${this.dexId} block-event`)
196
199
  this.latestBlockSlot = slot // v1 兜底询价取当前 slot 用(动态费 currentPoint)
197
200
  for (const poolInfo of this.poolInfoMap.values()) {
@@ -66,9 +66,10 @@ export function toSolPoolEvent(data: SolanaPoolAccountUpdateEventData): SolPoolE
66
66
  pool_address: data.pool_address,
67
67
  dex_id: data.dex_id,
68
68
  pool_name: data.pool_name,
69
- blockNumber: d.slot,
69
+ // slot/write_version 可能是 protobuf u64 字符串 → 在归一化边界统一转 number,否则 assert 判非法/水位线变字符串比较
70
+ blockNumber: Number(d.slot),
70
71
  // Geyser write_version(全局单调);stream-quote 已补进 wire(step 2)→ (slot, writeVersion) 水位线去重
71
- writeVersion: d.write_version,
72
+ writeVersion: d.write_version != null ? Number(d.write_version) : undefined,
72
73
  txHash: d.tx_hash || 'account',
73
74
  blockTime: data.event_time || 0,
74
75
  poolAccountData: d.pool_account_data,
@@ -40,7 +40,8 @@ export interface SolanaAccountUpdateEvent {
40
40
  export interface SolanaBlockMetaUpdateEvent {
41
41
  slot: number;
42
42
  blockHash: string;
43
- blockTime: number;
43
+ blockTime: number; // 链上出块时间(Unix 秒,Solana 无亚秒精度)
44
+ recvBlockTime: number; // stream-block 从 Laserstream 收到该块的本地时间(Unix 毫秒);analyze 用它做 ms 精度时间戳/新鲜度
44
45
  blockHeight: number;
45
46
  parentSlot: number;
46
47
  parentBlockhash: string;