@clonegod/ttd-bsc-common 3.1.60 → 3.1.62

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.
@@ -14,6 +14,7 @@ export interface CheckSwapParams {
14
14
  tokenB: any;
15
15
  quote_token: string;
16
16
  };
17
+ swapperDeltaConvention?: boolean;
17
18
  }
18
19
  export interface CheckSyncParams {
19
20
  poolAddress: string;
@@ -46,8 +46,9 @@ class QuotePriceVerify {
46
46
  if (cached.verifiedReferenceBlock === cached.referenceBlock)
47
47
  return;
48
48
  cached.verifiedReferenceBlock = cached.referenceBlock;
49
- const amt0 = BigInt(amount0);
50
- const amt1 = BigInt(amount1);
49
+ const sign = params.swapperDeltaConvention ? -1n : 1n;
50
+ const amt0 = BigInt(amount0) * sign;
51
+ const amt1 = BigInt(amount1) * sign;
51
52
  if (amt0 === 0n && amt1 === 0n)
52
53
  return;
53
54
  let inputTokenAddress;
@@ -134,9 +135,9 @@ class QuotePriceVerify {
134
135
  const side = isBuy ? 'BUY' : 'SELL';
135
136
  if (refPrice <= 0 || execPriceNum <= 0)
136
137
  return;
137
- const diffBps = (execPriceNum - refPrice) / refPrice * 10000;
138
+ const diffBps = (refPrice - execPriceNum) / refPrice * 10000;
138
139
  const absDiffBps = Math.abs(diffBps);
139
- const status = absDiffBps < 10 ? '✅' : absDiffBps < 30 ? '⚠️' : '❌';
140
+ const status = absDiffBps < 5 ? '✅' : absDiffBps < 10 ? '⚠️' : '❌';
140
141
  const usdStr = swapUsd > 0 ? `$${swapUsd.toFixed(0)}` : '$?';
141
142
  const maxUsd = cached.quoteAmountUsd * 2;
142
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.60",
3
+ "version": "3.1.62",
4
4
  "description": "BSC common library",
5
5
  "license": "UNLICENSED",
6
6
  "main": "dist/index.js",