@clonegod/ttd-sol-common 2.0.81 → 2.0.83

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.
@@ -3,7 +3,7 @@ import { TransactionInstruction } from '@solana/web3.js';
3
3
  import { SolTransactionBuilder } from './tx_builder';
4
4
  export declare abstract class AbstractSolDexTrade<Q extends QuoteResultType = QuoteResultType> extends AbastrcatTrade {
5
5
  abstract txBuilder: SolTransactionBuilder;
6
- protected abstract getQuoteResult(context: TradeContext): Promise<Q> | Q;
6
+ protected abstract prepareSwapParams(context: TradeContext): Promise<Q> | Q;
7
7
  protected abstract createSwapInstructions(context: TradeContext, quote_result: Q): Promise<TransactionInstruction[]>;
8
8
  execute(context: TradeContext): Promise<string>;
9
9
  }
@@ -17,10 +17,10 @@ class AbstractSolDexTrade extends dist_1.AbastrcatTrade {
17
17
  trace.set('order_id', order_msg.unique_order_msg_id);
18
18
  trace.set('amount', order_msg.amount);
19
19
  trace.set('slippage', `${slippage_bps / 100}%`);
20
- let stage = 'quote';
20
+ let stage = 'prepare';
21
21
  try {
22
- const quote_result = await this.getQuoteResult(context);
23
- trace.mark('quote');
22
+ const quote_result = await this.prepareSwapParams(context);
23
+ trace.mark('prepare');
24
24
  trace.set('exec_price', quote_result.price);
25
25
  stage = 'encode';
26
26
  const swapIxs = await this.createSwapInstructions(context, quote_result);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@clonegod/ttd-sol-common",
3
- "version": "2.0.81",
3
+ "version": "2.0.83",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -9,21 +9,22 @@ import { TransactionSender } from './send'
9
9
  * AbstractSolDexTrade —— Solana 交易执行基类(对齐 BSC/BASE 的 abstract_dex_trade)。
10
10
  *
11
11
  * 共享一套交易热路径 + TradeTrace 打点(一处维护,8 个 DEX 共用),DEX 只实现两个差异点:
12
- * - getQuoteResult:重新询价,拿 exec 用的 quote_result(可同步可异步)。
13
- * - createSwapInstructions:组装这笔 swap 的指令(内部自取 poolData / account / 0-RPC 组装)。
12
+ * - prepareSwapParams:按订单算 swap 参数(amountIn/amountOutMin 滑点下限/amountInMax)。**不是询价** ——
13
+ * 价格随订单 order_msg.price 而来(询价进程早算好),trade 信任它,纯算术、无 RPC
14
+ * - createSwapInstructions:组装这笔 swap 的指令(内部自取 poolData / account / 0-RPC;CLMM 的真 tick 模拟在这)。
14
15
  *
15
- * 流程(SOL 模型,非 EVM):recv → quote → encode → build(签名) → sent(Helius Sender 发出,fire-and-forget;
16
+ * 流程(SOL 模型,非 EVM):recv → prepare → encode → build(签名) → sent(Helius Sender 发出,fire-and-forget;
16
17
  * 结果走 tx_result_check 异步回来)。无 nonce / caller。
17
18
  *
18
- * 输出对齐 BSC:成功 `[TRADE OK] <id> | pair dir { timeline: recv -> quote(Xms) -> encode -> build -> sent = N ms, ... }`,
19
+ * 输出对齐 BSC:成功 `[TRADE OK] <id> | pair dir { timeline: recv -> prepare(Xms) -> encode -> build -> sent = N ms, ... }`,
19
20
  * 失败 `[TRADE FAILED] ... stage=<阶段> | <错误>`。
20
21
  */
21
22
  export abstract class AbstractSolDexTrade<Q extends QuoteResultType = QuoteResultType> extends AbastrcatTrade {
22
23
  /** DEX 子类持有(构造时 new SolTransactionBuilder(appConfig));基类只调用 buildTransactionForSwap。 */
23
24
  abstract txBuilder: SolTransactionBuilder
24
25
 
25
- /** DEX 实现:重新询价(exec 用)。Q 允许 DEX 用自己的 quote_result 子类型(如 PumfunQuoteResultType)。 */
26
- protected abstract getQuoteResult(context: TradeContext): Promise<Q> | Q
26
+ /** DEX 实现:按订单算 swap 参数(amountIn/minOut/滑点边界)。**非询价**,纯算术。Q 允许 DEX 用自己的子类型(如 PumfunQuoteResultType)。 */
27
+ protected abstract prepareSwapParams(context: TradeContext): Promise<Q> | Q
27
28
  /** DEX 实现:组装 swap 指令(内部自取 poolData / 0-RPC)。返回指令数组。 */
28
29
  protected abstract createSwapInstructions(context: TradeContext, quote_result: Q): Promise<TransactionInstruction[]>
29
30
 
@@ -37,10 +38,10 @@ export abstract class AbstractSolDexTrade<Q extends QuoteResultType = QuoteResul
37
38
  trace.set('amount', order_msg.amount)
38
39
  trace.set('slippage', `${slippage_bps / 100}%`)
39
40
 
40
- let stage = 'quote'
41
+ let stage = 'prepare'
41
42
  try {
42
- const quote_result = await this.getQuoteResult(context)
43
- trace.mark('quote')
43
+ const quote_result = await this.prepareSwapParams(context)
44
+ trace.mark('prepare')
44
45
  trace.set('exec_price', quote_result.price)
45
46
 
46
47
  stage = 'encode'