@clonegod/ttd-bsc-common 3.1.61 → 3.1.63

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.
@@ -31,6 +31,7 @@ export interface CheckSyncParams {
31
31
  tokenB: any;
32
32
  quote_token: string;
33
33
  };
34
+ txHash?: string;
34
35
  }
35
36
  export declare class QuotePriceVerify {
36
37
  private quoteCache;
@@ -75,7 +75,7 @@ class QuotePriceVerify {
75
75
  checkSync(params) {
76
76
  if (!this.enabled)
77
77
  return;
78
- const { poolAddress, poolName, blockNumber, reserve0, reserve1, poolInfo } = params;
78
+ const { poolAddress, poolName, blockNumber, reserve0, reserve1, poolInfo, txHash } = params;
79
79
  const { token0Address, token1Address, token0Decimals, token1Decimals } = params;
80
80
  const cached = this.quoteCache.get(poolAddress);
81
81
  if (!cached)
@@ -112,7 +112,7 @@ class QuotePriceVerify {
112
112
  inputAmountUi = Number(delta1) / Math.pow(10, token1Decimals);
113
113
  outputAmountUi = Number(-delta0) / Math.pow(10, token0Decimals);
114
114
  }
115
- this.compareAndLog(poolAddress, poolName, poolInfo, cached, inputTokenAddress, outputTokenAddress, inputAmountUi, outputAmountUi, cached.token0PriceUsd, cached.token1PriceUsd, token0Address, blockNumber);
115
+ this.compareAndLog(poolAddress, poolName, poolInfo, cached, inputTokenAddress, outputTokenAddress, inputAmountUi, outputAmountUi, cached.token0PriceUsd, cached.token1PriceUsd, token0Address, blockNumber, txHash);
116
116
  }
117
117
  compareAndLog(poolAddress, poolName, poolInfo, cached, inputTokenAddress, outputTokenAddress, inputAmountUi, outputAmountUi, token0PriceUsd, token1PriceUsd, token0Address, swapBlockNumber, txHash) {
118
118
  if (inputAmountUi <= 0 || outputAmountUi <= 0)
@@ -135,9 +135,9 @@ class QuotePriceVerify {
135
135
  const side = isBuy ? 'BUY' : 'SELL';
136
136
  if (refPrice <= 0 || execPriceNum <= 0)
137
137
  return;
138
- const diffBps = (execPriceNum - refPrice) / refPrice * 10000;
138
+ const diffBps = (refPrice - execPriceNum) / refPrice * 10000;
139
139
  const absDiffBps = Math.abs(diffBps);
140
- const status = absDiffBps < 10 ? '✅' : absDiffBps < 30 ? '⚠️' : '❌';
140
+ const status = absDiffBps < 5 ? '✅' : absDiffBps < 10 ? '⚠️' : '❌';
141
141
  const usdStr = swapUsd > 0 ? `$${swapUsd.toFixed(0)}` : '$?';
142
142
  const maxUsd = cached.quoteAmountUsd * 2;
143
143
  const inRange = swapUsd <= 0 || swapUsd <= maxUsd;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@clonegod/ttd-bsc-common",
3
- "version": "3.1.61",
3
+ "version": "3.1.63",
4
4
  "description": "BSC common library",
5
5
  "license": "UNLICENSED",
6
6
  "main": "dist/index.js",