@clonegod/ttd-core 2.0.99 → 2.1.0

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.
@@ -18,6 +18,7 @@ const axios_1 = __importDefault(require("axios"));
18
18
  const index_1 = require("../../index");
19
19
  const gecko_terminal_1 = require("./gecko_terminal");
20
20
  const price_cache_1 = require("./price_cache");
21
+ const defi_llama_1 = require("./defi_llama");
21
22
  function get_solana_token_price_info(addresses) {
22
23
  return __awaiter(this, void 0, void 0, function* () {
23
24
  const result = new Map();
@@ -34,6 +35,12 @@ function get_solana_token_price_info(addresses) {
34
35
  batchSize: 10,
35
36
  batchDelay: 1000,
36
37
  },
38
+ {
39
+ name: 'DefiLlama',
40
+ fetchFn: (address_list) => (0, defi_llama_1.fetchPriceFromDefiLlama)(index_1.CHAIN_ID.SOLANA, address_list),
41
+ batchSize: 10,
42
+ batchDelay: 1000,
43
+ },
37
44
  {
38
45
  name: 'GeckoTerminal',
39
46
  fetchFn: (address_list) => (0, gecko_terminal_1.fetchPriceFromGeckoTerminal)(index_1.CHAIN_ID.SOLANA, address_list),
@@ -99,19 +106,19 @@ function fetchPriceFromJupiter(addresses) {
99
106
  const timeout = 10000;
100
107
  const maxRetries = 2;
101
108
  const retrysleepMs = 500;
102
- const url = `https://api.jup.ag/price/v2?ids=${addresses.join(',')}&showExtraInfo=false`;
109
+ const url = `https://lite-api.jup.ag/price/v3?ids=${addresses.join(',')}`;
103
110
  (0, index_1.log_debug)(`[fetchPriceFromJupiter] Requesting Jupiter API for ${addresses.length} tokens`);
104
111
  let retryCount = 0;
105
112
  while (retryCount <= maxRetries) {
106
113
  try {
107
114
  const response = yield axios_1.default.get(url, { timeout });
108
- if (response.data.data) {
115
+ if (response.data) {
109
116
  for (const address of addresses) {
110
117
  const key = address;
111
- if (response.data.data[key] !== undefined) {
118
+ if (response.data[key] !== undefined) {
112
119
  result.set(address, {
113
120
  address: address,
114
- price: response.data.data[key]['price'].toString(),
121
+ price: response.data[key]['usdPrice'].toString(),
115
122
  symbol: '',
116
123
  name: '',
117
124
  update_time: currentTime
@@ -145,6 +152,5 @@ if (require.main === module) {
145
152
  "JUPyiwrYJFskUPiHa7hkeR8VUtAeFoSYbKedZNsDvCN",
146
153
  "MEW1gQWJ3nEXg2qgERiKu7FAFj79PHvQVREQUzScPP5",
147
154
  ];
148
- console.log(yield get_solana_token_price_info(addresses));
149
155
  }))();
150
156
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@clonegod/ttd-core",
3
- "version": "2.0.99",
3
+ "version": "2.1.0",
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",