@defillama/sdk 2.3.23 → 2.3.24
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.
- package/build/computeTVL/index.js +38 -16
- package/package.json +1 -1
|
@@ -144,22 +144,44 @@ function getHistoricalChainPrices(ids, timestamp, knownTokenPrices, getCoingecko
|
|
|
144
144
|
});
|
|
145
145
|
});
|
|
146
146
|
}
|
|
147
|
-
function getChainSymbolsAndDecimals(ids) {
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
147
|
+
function getChainSymbolsAndDecimals(ids, maxRetries) {
|
|
148
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
149
|
+
var allCoins, i, response;
|
|
150
|
+
return __generator(this, function (_a) {
|
|
151
|
+
switch (_a.label) {
|
|
152
|
+
case 0:
|
|
153
|
+
allCoins = Object.entries(ids).map(function (chain) {
|
|
154
|
+
return chain[1].map(function (coin) { return chain[0] === "coingecko" ? coin.toLowerCase() : chain[0] + ":" + coin.toLowerCase(); });
|
|
155
|
+
})
|
|
156
|
+
.reduce(function (acc, coins) {
|
|
157
|
+
coins.forEach(function (coin) {
|
|
158
|
+
acc.add(coin);
|
|
159
|
+
});
|
|
160
|
+
return acc;
|
|
161
|
+
}, new Set([]));
|
|
162
|
+
i = 0;
|
|
163
|
+
_a.label = 1;
|
|
164
|
+
case 1:
|
|
165
|
+
if (!(i < maxRetries)) return [3 /*break*/, 4];
|
|
166
|
+
return [4 /*yield*/, node_fetch_1.default('https://api.llama.fi/coins', {
|
|
167
|
+
method: 'POST',
|
|
168
|
+
body: JSON.stringify({
|
|
169
|
+
coins: Array.from(allCoins)
|
|
170
|
+
})
|
|
171
|
+
}).then(function (response) { return response.json(); })];
|
|
172
|
+
case 2:
|
|
173
|
+
response = _a.sent();
|
|
174
|
+
if (Array.isArray(response)) {
|
|
175
|
+
return [2 /*return*/, response];
|
|
176
|
+
}
|
|
177
|
+
_a.label = 3;
|
|
178
|
+
case 3:
|
|
179
|
+
i++;
|
|
180
|
+
return [3 /*break*/, 1];
|
|
181
|
+
case 4: throw new Error("api.llama.fi/coins failed");
|
|
182
|
+
}
|
|
154
183
|
});
|
|
155
|
-
|
|
156
|
-
}, new Set([]));
|
|
157
|
-
return node_fetch_1.default('https://api.llama.fi/coins', {
|
|
158
|
-
method: 'POST',
|
|
159
|
-
body: JSON.stringify({
|
|
160
|
-
coins: Array.from(allCoins)
|
|
161
|
-
})
|
|
162
|
-
}).then(function (response) { return response.json(); });
|
|
184
|
+
});
|
|
163
185
|
}
|
|
164
186
|
function default_1(rawBalances, timestamp, verbose, knownTokenPrices, getCoingeckoLock, coingeckoMaxRetries) {
|
|
165
187
|
if (verbose === void 0) { verbose = false; }
|
|
@@ -235,7 +257,7 @@ function default_1(rawBalances, timestamp, verbose, knownTokenPrices, getCoingec
|
|
|
235
257
|
chainIds.coingecko.push(normalizedAddressOrName);
|
|
236
258
|
}
|
|
237
259
|
}
|
|
238
|
-
return [4 /*yield*/, getChainSymbolsAndDecimals(chainIds)];
|
|
260
|
+
return [4 /*yield*/, getChainSymbolsAndDecimals(chainIds, coingeckoMaxRetries)];
|
|
239
261
|
case 4:
|
|
240
262
|
symbolsAndDecimals = _c.sent();
|
|
241
263
|
if (!(timestamp === "now")) return [3 /*break*/, 5];
|