@clonegod/ttd-core 3.1.44 → 3.1.46

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.
@@ -99,6 +99,7 @@ const WS_TYPES = new Set([
99
99
  'PriceMessageType',
100
100
  'DepthLevels',
101
101
  'QuoteVerify',
102
+ 'QuoteCandidate',
102
103
  ]);
103
104
  const HTTP_PATH = {
104
105
  OrderMessageType: '/ingest/order',
@@ -30,4 +30,13 @@ export interface QuoteResponseOptions {
30
30
  depth?: PoolDepthData;
31
31
  }
32
32
  export declare function on_quote_response(opts: QuoteResponseOptions): void;
33
+ export declare function report_quote_candidate(opts: {
34
+ pool_address: string;
35
+ pair: string;
36
+ dex_id: string;
37
+ source: string;
38
+ block_number: number;
39
+ ask_price: number | string;
40
+ bid_price: number | string;
41
+ }): void;
33
42
  export declare function on_quote_respose(appConfig: AppConfig, pool_info: StandardPoolInfoType, quote_amount_usd: number, _execution_price: number, stream_time: number, quote_start_time: number, slot_info: string, result: [QuoteResultType, QuoteResultType, number], txid: string, push_price_message?: boolean, source?: string, depth?: PoolDepthData): void;
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.on_quote_response = on_quote_response;
4
+ exports.report_quote_candidate = report_quote_candidate;
4
5
  exports.on_quote_respose = on_quote_respose;
5
6
  const analyze_1 = require("../analyze");
6
7
  const log_quote_price_1 = require("./log_quote_price");
@@ -32,7 +33,7 @@ function on_quote_response(opts) {
32
33
  price_id: price_msg.price_id,
33
34
  unique_orderbook_id: price_msg.unique_orderbook_id,
34
35
  pair: price_msg.pair,
35
- depth
36
+ depth,
36
37
  });
37
38
  }
38
39
  })
@@ -40,6 +41,20 @@ function on_quote_response(opts) {
40
41
  console.error(`[on_quote_response] error: ${(err === null || err === void 0 ? void 0 : err.message) || err}`);
41
42
  });
42
43
  }
44
+ function report_quote_candidate(opts) {
45
+ if (!opts.pool_address || !opts.block_number || !opts.source)
46
+ return;
47
+ (0, analyze_1.report_data_to_analyze)('QuoteCandidate', {
48
+ pool_address: opts.pool_address.toLowerCase(),
49
+ pair: opts.pair || '',
50
+ dex_id: opts.dex_id || '',
51
+ source: opts.source,
52
+ block_number: opts.block_number,
53
+ ask_price: Number(opts.ask_price) || 0,
54
+ bid_price: Number(opts.bid_price) || 0,
55
+ computed_at: Date.now(),
56
+ });
57
+ }
43
58
  function on_quote_respose(appConfig, pool_info, quote_amount_usd, _execution_price, stream_time, quote_start_time, slot_info, result, txid, push_price_message = true, source = "", depth) {
44
59
  on_quote_response({
45
60
  appConfig,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@clonegod/ttd-core",
3
- "version": "3.1.44",
3
+ "version": "3.1.46",
4
4
  "description": "Common types and utilities for trading systems - use `npm run push` to publish",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
package/types/index.d.ts CHANGED
@@ -940,6 +940,9 @@ export interface PostTradeType {
940
940
 
941
941
  /** 同区块分析 (MEV) */
942
942
  same_block: AnalyzeSameBlockType
943
+
944
+ /** 完整 OnTrade 记录:时间线 / 成交结果 / 盘口快照 / 偏差 — 给 UI 渲染时间线和滑点归因用 */
945
+ ontrade?: OnTradeType
943
946
  }
944
947
 
945
948
  export interface AnalyzeQuoteSnapshotType {