@clonegod/ttd-bsc-common 3.0.49 → 3.0.51

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.
@@ -34,10 +34,8 @@ export interface CheckSyncParams {
34
34
  export declare class QuoteAccuracyChecker {
35
35
  private quoteCache;
36
36
  private reserveCache;
37
- private pendingLogs;
38
37
  private get enabled();
39
- getAndClearLog(poolAddress: string): string | null;
40
- cacheQuote(poolAddress: string, priceId: string, askPrice: number, bidPrice: number, blockNumber: number, quoteAmountUsd: number, token0PriceUsd?: number, token1PriceUsd?: number): void;
38
+ cacheQuote(poolAddress: string, priceId: string, source: string, askPrice: number, bidPrice: number, blockNumber: number, quoteAmountUsd: number, token0PriceUsd?: number, token1PriceUsd?: number): void;
41
39
  checkSwap(params: CheckSwapParams): void;
42
40
  checkSync(params: CheckSyncParams): void;
43
41
  private compareAndLog;
@@ -6,22 +6,15 @@ class QuoteAccuracyChecker {
6
6
  constructor() {
7
7
  this.quoteCache = new Map();
8
8
  this.reserveCache = new Map();
9
- this.pendingLogs = new Map();
10
9
  }
11
10
  get enabled() {
12
11
  return process.env.QUOTE_ACCURACY_LOG === 'true';
13
12
  }
14
- getAndClearLog(poolAddress) {
15
- const log = this.pendingLogs.get(poolAddress);
16
- if (log)
17
- this.pendingLogs.delete(poolAddress);
18
- return log || null;
19
- }
20
- cacheQuote(poolAddress, priceId, askPrice, bidPrice, blockNumber, quoteAmountUsd, token0PriceUsd = 0, token1PriceUsd = 0) {
13
+ cacheQuote(poolAddress, priceId, source, askPrice, bidPrice, blockNumber, quoteAmountUsd, token0PriceUsd = 0, token1PriceUsd = 0) {
21
14
  if (!this.enabled)
22
15
  return;
23
16
  this.quoteCache.set(poolAddress, {
24
- priceId, askPrice, bidPrice, blockNumber, quoteAmountUsd,
17
+ priceId, source, askPrice, bidPrice, blockNumber, quoteAmountUsd,
25
18
  verifiedBlock: 0,
26
19
  token0PriceUsd, token1PriceUsd,
27
20
  });
@@ -139,8 +132,9 @@ class QuoteAccuracyChecker {
139
132
  ? `${inputAmountUi.toFixed(4)} ${quoteToken.symbol} -> ${outputAmountUi.toFixed(4)} ${baseToken.symbol}`
140
133
  : `${inputAmountUi.toFixed(4)} ${baseToken.symbol} -> ${outputAmountUi.toFixed(4)} ${quoteToken.symbol}`;
141
134
  const txTag = txHash ? ` tx:${txHash.slice(0, 10)}` : '';
142
- const msg = ` ↳ [QuoteAccuracy] vs blk:${cached.blockNumber} ${side} ${usdStr} (${tradeFlow}), ${isBuy ? 'ask' : 'bid'}=${refPrice.toFixed(12)} vs exec=${execPriceNum.toFixed(12)}, diff=${diffBps > 0 ? '+' : ''}${diffBps.toFixed(1)}bps ${status}${rangeTag}${txTag}`;
143
- this.pendingLogs.set(poolAddress, msg);
135
+ const srcTag = cached.source ? ` [${cached.source}]` : '';
136
+ const msg = ` ↳ [QuoteAccuracy] vs blk:${cached.blockNumber}${srcTag} ${side} ${usdStr} (${tradeFlow}), ${isBuy ? 'ask' : 'bid'}=${refPrice.toFixed(12)} vs exec=${execPriceNum.toFixed(12)}, diff=${diffBps > 0 ? '+' : ''}${diffBps.toFixed(1)}bps ${status}${rangeTag}${txTag}`;
137
+ console.log(msg + '\n');
144
138
  }
145
139
  }
146
140
  exports.QuoteAccuracyChecker = QuoteAccuracyChecker;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@clonegod/ttd-bsc-common",
3
- "version": "3.0.49",
3
+ "version": "3.0.51",
4
4
  "description": "BSC common library",
5
5
  "license": "UNLICENSED",
6
6
  "main": "dist/index.js",