@clonegod/ttd-core 2.1.6 → 2.1.8

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.
@@ -103,15 +103,20 @@ function fetchPriceFromJupiter(addresses) {
103
103
  return __awaiter(this, void 0, void 0, function* () {
104
104
  const result = new Map();
105
105
  const currentTime = (0, index_1.getCurDateTime)();
106
- const timeout = 10000;
106
+ const timeout = 6000;
107
107
  const maxRetries = 2;
108
108
  const retrysleepMs = 500;
109
- const url = `https://lite-api.jup.ag/price/v3?ids=${addresses.join(',')}`;
109
+ const url = (process.env.JUPITER_PRICE_API || 'https://api.jup.ag/price/v3') + `?ids=${addresses.join(',')}`;
110
110
  (0, index_1.log_debug)(`[fetchPriceFromJupiter] Requesting Jupiter API for ${addresses.length} tokens`);
111
111
  let retryCount = 0;
112
112
  while (retryCount <= maxRetries) {
113
113
  try {
114
- const response = yield axios_1.default.get(url, { timeout });
114
+ const response = yield axios_1.default.get(url, {
115
+ headers: {
116
+ 'x-api-key': process.env.JUPITER_API_KEY
117
+ },
118
+ timeout,
119
+ });
115
120
  if (response.data) {
116
121
  for (const address of addresses) {
117
122
  const key = address;
@@ -14,6 +14,7 @@ export declare class TradeContext {
14
14
  fee_rate: string;
15
15
  pool_info: StandardPoolInfoType;
16
16
  aToB: boolean;
17
+ pool_aToB: boolean;
17
18
  slippage_bps: number;
18
19
  ui_tip_amount: number;
19
20
  constructor(price_msg: PriceMessageType, order_msg: OrderMessageType);
@@ -43,6 +43,7 @@ class TradeContext {
43
43
  }
44
44
  this.slippage_bps = Math.min(300, Math.max(0, this.trade_runtime.settings.slippage_bps));
45
45
  this.aToB = this.pool_info.is_reverse_token ? !this.order_msg.aToB : this.order_msg.aToB;
46
+ this.pool_aToB = this.pool_info.tokenA.address === inputToken.address;
46
47
  });
47
48
  }
48
49
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@clonegod/ttd-core",
3
- "version": "2.1.6",
3
+ "version": "2.1.8",
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": "types/index.d.ts",