@clonegod/ttd-core 3.1.78 → 3.1.80

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.
@@ -7,6 +7,7 @@ export declare enum SERVICE_PORT {
7
7
  TRADE_ANALYZE_HTTP = 8004,
8
8
  MARKET_DATA_HTTP = 8005,
9
9
  WALLET_ASSETS_HTTP = 8006,
10
+ WALLET_TRANSFER_HTTP = 8007,
10
11
  STREAM_QUOTE_WS = 8011,
11
12
  SEND_TX_WS = 8012,
12
13
  STREAM_TRADE_WS = 8013
@@ -11,6 +11,7 @@ var SERVICE_PORT;
11
11
  SERVICE_PORT[SERVICE_PORT["TRADE_ANALYZE_HTTP"] = 8004] = "TRADE_ANALYZE_HTTP";
12
12
  SERVICE_PORT[SERVICE_PORT["MARKET_DATA_HTTP"] = 8005] = "MARKET_DATA_HTTP";
13
13
  SERVICE_PORT[SERVICE_PORT["WALLET_ASSETS_HTTP"] = 8006] = "WALLET_ASSETS_HTTP";
14
+ SERVICE_PORT[SERVICE_PORT["WALLET_TRANSFER_HTTP"] = 8007] = "WALLET_TRANSFER_HTTP";
14
15
  SERVICE_PORT[SERVICE_PORT["STREAM_QUOTE_WS"] = 8011] = "STREAM_QUOTE_WS";
15
16
  SERVICE_PORT[SERVICE_PORT["SEND_TX_WS"] = 8012] = "SEND_TX_WS";
16
17
  SERVICE_PORT[SERVICE_PORT["STREAM_TRADE_WS"] = 8013] = "STREAM_TRADE_WS";
@@ -57,7 +57,7 @@ function valid_fetch_pool_data(formatted_pool, min_tvl, min_vol, native_token) {
57
57
  throw new Error(`pool is too small: ${pool_name}, ${pool_address}, ${reasons.join(', ')}`);
58
58
  }
59
59
  if (!symbols.includes(native_token) && !symbols.includes('USDC') && !symbols.includes('USDT') && !symbols.includes('USD1')) {
60
- throw new Error(`pool don't contains: SOL, USDC, USDT, USD1, ${pool_name}, ${pool_address}`);
60
+ throw new Error(`pool don't contains: ${native_token}, USDC, USDT, USD1, ${pool_name}, ${pool_address}`);
61
61
  }
62
62
  if (!(0, token_util_1.is_valid_symbol)(tokenA.symbol)) {
63
63
  throw new Error(`pool contains bad symbol: tokenA.symbol=${tokenA.symbol}, ${pool_name}, ${pool_address}`);
@@ -39,9 +39,3 @@ export interface OrderbookEntry {
39
39
  export declare function toOrderbookEntry(q: QuoteEntry): OrderbookEntry;
40
40
  export declare const DEFAULT_TIER_PCT = 0.2;
41
41
  export declare function getDepthPricePctLevels(): number[];
42
- export declare function assertTierPriceInvariant(poolName: string, side: 'ASK' | 'BID', tiers: Array<{
43
- pct: number;
44
- price: number;
45
- amount: number;
46
- amount_in: number;
47
- }>, log_warn?: (msg: string) => void): void;
@@ -3,7 +3,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.DEFAULT_TIER_PCT = void 0;
4
4
  exports.toOrderbookEntry = toOrderbookEntry;
5
5
  exports.getDepthPricePctLevels = getDepthPricePctLevels;
6
- exports.assertTierPriceInvariant = assertTierPriceInvariant;
7
6
  function toOrderbookEntry(q) {
8
7
  return {
9
8
  price: q.price,
@@ -35,34 +34,3 @@ function getDepthPricePctLevels() {
35
34
  _pctLevelsCache = levels;
36
35
  return levels;
37
36
  }
38
- const _tierInvariantLastWarn = new Map();
39
- function assertTierPriceInvariant(poolName, side, tiers, log_warn) {
40
- if (!tiers || tiers.length === 0)
41
- return;
42
- const TOL_REL = 0.0001;
43
- for (const t of tiers) {
44
- if (!(t.price > 0) || !(t.amount > 0) || !(t.amount_in > 0))
45
- continue;
46
- const expected = side === 'ASK'
47
- ? t.amount_in / t.amount
48
- : t.amount / t.amount_in;
49
- if (expected <= 0)
50
- continue;
51
- const relDiff = Math.abs(t.price - expected) / expected;
52
- if (relDiff > TOL_REL) {
53
- const key = `${poolName}_${side}_${t.pct}`;
54
- const now = Date.now();
55
- if ((now - (_tierInvariantLastWarn.get(key) || 0)) < 60000)
56
- return;
57
- _tierInvariantLastWarn.set(key, now);
58
- const msg = `[tier-invariant] ${poolName} ${side} pct=${t.pct} price=${t.price.toFixed(10)} ` +
59
- `≠ expected ${expected.toFixed(10)} (relDiff=${(relDiff * 10000).toFixed(2)}bps, amount_in=${t.amount_in}, amount=${t.amount}) ` +
60
- `— check tier.price formula! Must be effective avg price including fee`;
61
- if (log_warn)
62
- log_warn(msg);
63
- else
64
- console.warn(msg);
65
- return;
66
- }
67
- }
68
- }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@clonegod/ttd-core",
3
- "version": "3.1.78",
3
+ "version": "3.1.80",
4
4
  "description": "Common types and utilities for trading systems - use `npm run push` to publish",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",