@clonegod/ttd-bsc-common 3.0.50 → 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,9 +34,7 @@ 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
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;
|
|
@@ -6,17 +6,10 @@ 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
13
|
cacheQuote(poolAddress, priceId, source, askPrice, bidPrice, blockNumber, quoteAmountUsd, token0PriceUsd = 0, token1PriceUsd = 0) {
|
|
21
14
|
if (!this.enabled)
|
|
22
15
|
return;
|
|
@@ -141,7 +134,7 @@ class QuoteAccuracyChecker {
|
|
|
141
134
|
const txTag = txHash ? ` tx:${txHash.slice(0, 10)}` : '';
|
|
142
135
|
const srcTag = cached.source ? ` [${cached.source}]` : '';
|
|
143
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}`;
|
|
144
|
-
|
|
137
|
+
console.log(msg + '\n');
|
|
145
138
|
}
|
|
146
139
|
}
|
|
147
140
|
exports.QuoteAccuracyChecker = QuoteAccuracyChecker;
|