@defillama/sdk 2.3.48 → 2.3.49

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.
Files changed (64) hide show
  1. package/LICENSE +661 -661
  2. package/README.md +16 -16
  3. package/build/abi/cachedABIs.d.ts +4 -4
  4. package/build/abi/cachedABIs.js +70 -70
  5. package/build/abi/convertResults.d.ts +2 -2
  6. package/build/abi/convertResults.js +56 -56
  7. package/build/abi/index.d.ts +26 -26
  8. package/build/abi/index.js +185 -185
  9. package/build/abi/index.test.d.ts +1 -1
  10. package/build/abi/index.test.js +651 -651
  11. package/build/abi/multicall.d.ts +13 -13
  12. package/build/abi/multicall.js +210 -210
  13. package/build/api.d.ts +10 -10
  14. package/build/api.js +32 -32
  15. package/build/cdp/compoundTokens.d.ts +68 -68
  16. package/build/cdp/compoundTokens.js +69 -69
  17. package/build/cdp/index.d.ts +29 -29
  18. package/build/cdp/index.js +124 -124
  19. package/build/cdp/index.test.d.ts +1 -1
  20. package/build/cdp/index.test.js +82 -82
  21. package/build/cdp/makerTokens.d.ts +10 -10
  22. package/build/cdp/makerTokens.js +244 -244
  23. package/build/cli.d.ts +2 -2
  24. package/build/cli.js +95 -95
  25. package/build/computeTVL/blocks.d.ts +18 -18
  26. package/build/computeTVL/blocks.js +138 -138
  27. package/build/computeTVL/blocks.test.d.ts +1 -1
  28. package/build/computeTVL/blocks.test.js +56 -56
  29. package/build/computeTVL/humanizeNumber.d.ts +1 -1
  30. package/build/computeTVL/humanizeNumber.js +18 -18
  31. package/build/computeTVL/index.d.ts +55 -55
  32. package/build/computeTVL/index.js +366 -366
  33. package/build/computeTVL/index.test.d.ts +1 -1
  34. package/build/computeTVL/index.test.js +107 -107
  35. package/build/computeTVL/prices.d.ts +9 -9
  36. package/build/computeTVL/prices.js +163 -163
  37. package/build/erc20/index.d.ts +31 -31
  38. package/build/erc20/index.js +144 -144
  39. package/build/erc20/index.test.d.ts +1 -1
  40. package/build/erc20/index.test.js +124 -124
  41. package/build/eth/index.d.ts +21 -21
  42. package/build/eth/index.js +90 -90
  43. package/build/eth/index.test.d.ts +1 -1
  44. package/build/eth/index.test.js +122 -122
  45. package/build/general.d.ts +10 -10
  46. package/build/general.js +105 -105
  47. package/build/general.test.d.ts +1 -1
  48. package/build/general.test.js +73 -73
  49. package/build/generalUtil.d.ts +19 -19
  50. package/build/generalUtil.js +117 -117
  51. package/build/generalUtil.test.d.ts +1 -1
  52. package/build/generalUtil.test.js +59 -59
  53. package/build/index.d.ts +2 -2
  54. package/build/index.js +24 -24
  55. package/build/index.test.js +69 -69
  56. package/build/types.d.ts +5 -5
  57. package/build/types.js +2 -2
  58. package/build/util/index.d.ts +57 -57
  59. package/build/util/index.js +354 -354
  60. package/build/util/index.test.d.ts +1 -1
  61. package/build/util/index.test.js +314 -314
  62. package/build/util/tokenList.d.ts +14 -14
  63. package/build/util/tokenList.js +3631 -3631
  64. package/package.json +41 -41
@@ -1 +1 @@
1
- export {};
1
+ export {};
@@ -1,314 +1,314 @@
1
- "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
- var __generator = (this && this.__generator) || function (thisArg, body) {
12
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
13
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
14
- function verb(n) { return function (v) { return step([n, v]); }; }
15
- function step(op) {
16
- if (f) throw new TypeError("Generator is already executing.");
17
- while (_) try {
18
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
19
- if (y = 0, t) op = [op[0] & 2, t.value];
20
- switch (op[0]) {
21
- case 0: case 1: t = op; break;
22
- case 4: _.label++; return { value: op[1], done: false };
23
- case 5: _.label++; y = op[1]; op = [0]; continue;
24
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
25
- default:
26
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
27
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
28
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
29
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
30
- if (t[2]) _.ops.pop();
31
- _.trys.pop(); continue;
32
- }
33
- op = body.call(thisArg, _);
34
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
35
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
36
- }
37
- };
38
- Object.defineProperty(exports, "__esModule", { value: true });
39
- var index_1 = require("./index");
40
- jest.setTimeout(20000);
41
- test("lookupBlock", function () { return __awaiter(void 0, void 0, void 0, function () {
42
- var block;
43
- return __generator(this, function (_a) {
44
- switch (_a.label) {
45
- case 0: return [4 /*yield*/, index_1.lookupBlock(1594115200)];
46
- case 1:
47
- block = _a.sent();
48
- // Approximation, DP's sdk returns { timestamp: 1594112400, block: 10411348 }
49
- expect(block.block).toBeCloseTo(10411539, -1.5);
50
- expect(block.timestamp).toBeCloseTo(1594115202, -2.5);
51
- return [2 /*return*/];
52
- }
53
- });
54
- }); });
55
- test("lookupBlock on xdai and terra", function () { return __awaiter(void 0, void 0, void 0, function () {
56
- var calls, i;
57
- return __generator(this, function (_a) {
58
- switch (_a.label) {
59
- case 0:
60
- calls = [];
61
- for (i = 0; i < 10; i++) {
62
- calls.push(index_1.lookupBlock(1594115200, {
63
- chain: "xdai",
64
- }), index_1.lookupBlock(1594115200, {
65
- chain: "terra",
66
- }));
67
- }
68
- return [4 /*yield*/, Promise.all(calls)];
69
- case 1:
70
- _a.sent();
71
- return [2 /*return*/];
72
- }
73
- });
74
- }); });
75
- test("tokenList", function () { return __awaiter(void 0, void 0, void 0, function () {
76
- var _a;
77
- return __generator(this, function (_b) {
78
- switch (_b.label) {
79
- case 0:
80
- _a = expect;
81
- return [4 /*yield*/, index_1.tokenList()];
82
- case 1:
83
- _a.apply(void 0, [(_b.sent()).length]).toMatchInlineSnapshot("811");
84
- return [2 /*return*/];
85
- }
86
- });
87
- }); });
88
- test("kyberTokens", function () { return __awaiter(void 0, void 0, void 0, function () {
89
- var tokens, keys, i, key;
90
- return __generator(this, function (_a) {
91
- switch (_a.label) {
92
- case 0: return [4 /*yield*/, index_1.kyberTokens()];
93
- case 1:
94
- tokens = _a.sent();
95
- keys = Object.keys(tokens.output);
96
- for (i = 0; i < keys.length; i++) {
97
- key = keys[i];
98
- if (i < 3) {
99
- tokens.output[key].ethPrice = 0.002; // To avoid constant changes that break the snapshot
100
- }
101
- else {
102
- delete tokens.output[key];
103
- }
104
- }
105
- expect(tokens).toEqual({
106
- output: {
107
- "0x111111111117dc0aa78b770fa6a738034120c302": {
108
- symbol: "1INCH",
109
- decimals: 18,
110
- ethPrice: 0.002,
111
- },
112
- "0xe48972fcd82a274411c01834e2f031d4377fa2c0": {
113
- symbol: "2KEY",
114
- decimals: 18,
115
- ethPrice: 0.002,
116
- },
117
- "0x7fc66500c84a76ad7e9c93437bfc5ac33e2ddae9": {
118
- symbol: "AAVE",
119
- decimals: 18,
120
- ethPrice: 0.002,
121
- },
122
- },
123
- });
124
- return [2 /*return*/];
125
- }
126
- });
127
- }); });
128
- var sortSymbols = function (a, b) { return (a.address > b.address ? 1 : -1); };
129
- test("toSymbols", function () { return __awaiter(void 0, void 0, void 0, function () {
130
- var _a;
131
- return __generator(this, function (_b) {
132
- switch (_b.label) {
133
- case 0:
134
- _a = expect;
135
- return [4 /*yield*/, index_1.toSymbols({
136
- "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE": "2.363644408933851e+23",
137
- "0x6B175474E89094C44Da98b954EedeAC495271d0F": "2.3462351944349785e+26",
138
- "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48": "370186290673080",
139
- "0xdAC17F958D2ee523a2206206994597C13D831ec7": "411511818650054",
140
- "0xC2cB1040220768554cf699b0d863A3cd4324ce32": "1.232581672477717e+25",
141
- })];
142
- case 1:
143
- _a.apply(void 0, [(_b.sent()).output.sort(sortSymbols)]).toEqual(JSON.parse('[{"symbol":"ETH","address":"0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee","balance":"236364.440893"},{"symbol":"DAI","address":"0x6b175474e89094c44da98b954eedeac495271d0f","balance":"234623519.443498"},{"symbol":"USDC","address":"0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48","balance":"370186290.673080"},{"symbol":"USDT","address":"0xdac17f958d2ee523a2206206994597c13d831ec7","balance":"411511818.650054"},{"symbol":"yDAI","address":"0xc2cb1040220768554cf699b0d863a3cd4324ce32","balance":"12325816.724777"}]').sort(sortSymbols));
144
- return [2 /*return*/];
145
- }
146
- });
147
- }); });
148
- test("toSymbols works well with 0x0 as an ETH address", function () { return __awaiter(void 0, void 0, void 0, function () {
149
- var _a;
150
- return __generator(this, function (_b) {
151
- switch (_b.label) {
152
- case 0:
153
- _a = expect;
154
- return [4 /*yield*/, index_1.toSymbols({
155
- "0x0000000000000000000000000000000000000000": "2100000000000000000", // ETH
156
- })];
157
- case 1:
158
- _a.apply(void 0, [_b.sent()]).toEqual({
159
- output: [
160
- {
161
- symbol: "ETH",
162
- address: "0x0000000000000000000000000000000000000000",
163
- balance: "2.100000",
164
- },
165
- ],
166
- });
167
- return [2 /*return*/];
168
- }
169
- });
170
- }); });
171
- test("getLogs", function () { return __awaiter(void 0, void 0, void 0, function () {
172
- var poolLogs;
173
- return __generator(this, function (_a) {
174
- switch (_a.label) {
175
- case 0: return [4 /*yield*/, index_1.getLogs({
176
- target: "0x9424B1412450D0f8Fc2255FAf6046b98213B76Bd",
177
- topic: "LOG_NEW_POOL(address,address)",
178
- keys: ["topics"],
179
- fromBlock: 9562480,
180
- toBlock: 9575480,
181
- })];
182
- case 1:
183
- poolLogs = _a.sent();
184
- expect(poolLogs).toEqual({
185
- output: [
186
- [
187
- "0x8ccec77b0cb63ac2cafd0f5de8cdfadab91ce656d262240ba8a6343bccc5f945",
188
- "0x00000000000000000000000018fa2ac3c88112e36eff15370346f9aff3161fd1",
189
- "0x000000000000000000000000165a50bc092f6870dc111c349bae5fc35147ac86",
190
- ],
191
- [
192
- "0x8ccec77b0cb63ac2cafd0f5de8cdfadab91ce656d262240ba8a6343bccc5f945",
193
- "0x00000000000000000000000018fa2ac3c88112e36eff15370346f9aff3161fd1",
194
- "0x00000000000000000000000057755f7dec33320bca83159c26e93751bfd30fbe",
195
- ],
196
- [
197
- "0x8ccec77b0cb63ac2cafd0f5de8cdfadab91ce656d262240ba8a6343bccc5f945",
198
- "0x00000000000000000000000018fa2ac3c88112e36eff15370346f9aff3161fd1",
199
- "0x000000000000000000000000e5d1fab0c5596ef846dcc0958d6d0b20e1ec4498",
200
- ],
201
- ],
202
- });
203
- return [2 /*return*/];
204
- }
205
- });
206
- }); });
207
- test("getLogs supports it's old API", function () { return __awaiter(void 0, void 0, void 0, function () {
208
- var _a;
209
- return __generator(this, function (_b) {
210
- switch (_b.label) {
211
- case 0:
212
- _a = expect;
213
- return [4 /*yield*/, index_1.getLogs({
214
- keys: [],
215
- toBlock: 12047406,
216
- target: "0x35d1b3f3d7966a1dfe207aa4514c12a259a0492b",
217
- fromBlock: 8928152,
218
- topics: [
219
- "0x65fae35e00000000000000000000000000000000000000000000000000000000",
220
- ],
221
- })];
222
- case 1:
223
- _a.apply(void 0, [(_b.sent()).output.slice(0, 2)]).toEqual([
224
- {
225
- address: "0x35D1b3F3D7966A1DFe207aa4514C12a259A0492B",
226
- blockHash: "0x4e0c6d0ceaade9476d0798a44452117c42300389f43ad8397e91092827019fed",
227
- blockNumber: 8928152,
228
- data: "0x000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000e065fae35e000000000000000000000000baa65281c2fa2baacb2cb550ba051525a480d3f40000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
229
- logIndex: 64,
230
- removed: false,
231
- topics: [
232
- "0x65fae35e00000000000000000000000000000000000000000000000000000000",
233
- "0x000000000000000000000000baa65281c2fa2baacb2cb550ba051525a480d3f4",
234
- "0x0000000000000000000000000000000000000000000000000000000000000000",
235
- "0x0000000000000000000000000000000000000000000000000000000000000000",
236
- ],
237
- transactionHash: "0xa39edcdeb7310150d7be44b8da94e5043d1cf8600d59f855a65c7a9c035b06a7",
238
- transactionIndex: 66,
239
- //id: 'log_4301d412' // SHOULD BE SUPPORTED BUT HEH
240
- },
241
- {
242
- address: "0x35D1b3F3D7966A1DFe207aa4514C12a259A0492B",
243
- blockHash: "0x4e0c6d0ceaade9476d0798a44452117c42300389f43ad8397e91092827019fed",
244
- blockNumber: 8928152,
245
- data: "0x000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000e065fae35e00000000000000000000000065c79fcb50ca1594b025960e539ed7a9a6d434a30000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
246
- logIndex: 68,
247
- removed: false,
248
- topics: [
249
- "0x65fae35e00000000000000000000000000000000000000000000000000000000",
250
- "0x00000000000000000000000065c79fcb50ca1594b025960e539ed7a9a6d434a3",
251
- "0x0000000000000000000000000000000000000000000000000000000000000000",
252
- "0x0000000000000000000000000000000000000000000000000000000000000000",
253
- ],
254
- transactionHash: "0xa39edcdeb7310150d7be44b8da94e5043d1cf8600d59f855a65c7a9c035b06a7",
255
- transactionIndex: 66,
256
- //id: 'log_eaa6bc34' // SHOULD BE SUPPORTED BUT HEH
257
- },
258
- ]);
259
- return [2 /*return*/];
260
- }
261
- });
262
- }); });
263
- test("sushiswap getLogs follow the old API", function () { return __awaiter(void 0, void 0, void 0, function () {
264
- var _a;
265
- return __generator(this, function (_b) {
266
- switch (_b.label) {
267
- case 0:
268
- _a = expect;
269
- return [4 /*yield*/, index_1.getLogs({
270
- keys: [],
271
- toBlock: 12052813,
272
- target: "0xc0aee478e3658e2610c5f7a4a2e1777ce9e4f2ac",
273
- fromBlock: 10794229,
274
- topic: "PairCreated(address,address,address,uint256)",
275
- })];
276
- case 1:
277
- _a.apply(void 0, [(_b.sent()).output.slice(0, 2)]).toEqual([
278
- {
279
- address: "0xC0AEe478e3658e2610c5F7A4A2E1777cE9e4f2Ac",
280
- blockHash: "0xf59ff7fcf1443e7e61582224359a030bb7178871182cc543acb16627e81ec1a8",
281
- blockNumber: 10794352,
282
- data: "0x000000000000000000000000680a025da7b1be2c204d7745e809919bce0740260000000000000000000000000000000000000000000000000000000000000001",
283
- logIndex: 81,
284
- removed: false,
285
- topics: [
286
- "0x0d3648bd0f6ba80134a33ba9275ac585d9d315f0ad8355cddefde31afa28d0e9",
287
- "0x0000000000000000000000006b3595068778dd592e39a122f4f5a5cf09c90fe2",
288
- "0x000000000000000000000000dac17f958d2ee523a2206206994597c13d831ec7",
289
- ],
290
- transactionHash: "0x64318dfffc6544cb4782715ad914e335039cda02f5e8d3e47f0dac47f53565d2",
291
- transactionIndex: 56,
292
- //id: 'log_20f0cd7e'
293
- },
294
- {
295
- address: "0xC0AEe478e3658e2610c5F7A4A2E1777cE9e4f2Ac",
296
- blockHash: "0x25c6da25c999e1c668d60a5068128eb521ef121e4b46fb24575ed6fb037ede67",
297
- blockNumber: 10822038,
298
- data: "0x00000000000000000000000006da0fd433c1a5d7a4faa01111c044910a1845530000000000000000000000000000000000000000000000000000000000000002",
299
- logIndex: 202,
300
- removed: false,
301
- topics: [
302
- "0x0d3648bd0f6ba80134a33ba9275ac585d9d315f0ad8355cddefde31afa28d0e9",
303
- "0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2",
304
- "0x000000000000000000000000dac17f958d2ee523a2206206994597c13d831ec7",
305
- ],
306
- transactionHash: "0xaf215158cef8da66b2f6addc48d8683199468560599ac568b8981d9d67dc04b6",
307
- transactionIndex: 89,
308
- //id: 'log_2758f079'
309
- },
310
- ]);
311
- return [2 /*return*/];
312
- }
313
- });
314
- }); });
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ var __generator = (this && this.__generator) || function (thisArg, body) {
12
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
13
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
14
+ function verb(n) { return function (v) { return step([n, v]); }; }
15
+ function step(op) {
16
+ if (f) throw new TypeError("Generator is already executing.");
17
+ while (_) try {
18
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
19
+ if (y = 0, t) op = [op[0] & 2, t.value];
20
+ switch (op[0]) {
21
+ case 0: case 1: t = op; break;
22
+ case 4: _.label++; return { value: op[1], done: false };
23
+ case 5: _.label++; y = op[1]; op = [0]; continue;
24
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
25
+ default:
26
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
27
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
28
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
29
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
30
+ if (t[2]) _.ops.pop();
31
+ _.trys.pop(); continue;
32
+ }
33
+ op = body.call(thisArg, _);
34
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
35
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
36
+ }
37
+ };
38
+ Object.defineProperty(exports, "__esModule", { value: true });
39
+ var index_1 = require("./index");
40
+ jest.setTimeout(20000);
41
+ test("lookupBlock", function () { return __awaiter(void 0, void 0, void 0, function () {
42
+ var block;
43
+ return __generator(this, function (_a) {
44
+ switch (_a.label) {
45
+ case 0: return [4 /*yield*/, index_1.lookupBlock(1594115200)];
46
+ case 1:
47
+ block = _a.sent();
48
+ // Approximation, DP's sdk returns { timestamp: 1594112400, block: 10411348 }
49
+ expect(block.block).toBeCloseTo(10411539, -1.5);
50
+ expect(block.timestamp).toBeCloseTo(1594115202, -2.5);
51
+ return [2 /*return*/];
52
+ }
53
+ });
54
+ }); });
55
+ test("lookupBlock on xdai and terra", function () { return __awaiter(void 0, void 0, void 0, function () {
56
+ var calls, i;
57
+ return __generator(this, function (_a) {
58
+ switch (_a.label) {
59
+ case 0:
60
+ calls = [];
61
+ for (i = 0; i < 10; i++) {
62
+ calls.push(index_1.lookupBlock(1594115200, {
63
+ chain: "xdai",
64
+ }), index_1.lookupBlock(1594115200, {
65
+ chain: "terra",
66
+ }));
67
+ }
68
+ return [4 /*yield*/, Promise.all(calls)];
69
+ case 1:
70
+ _a.sent();
71
+ return [2 /*return*/];
72
+ }
73
+ });
74
+ }); });
75
+ test("tokenList", function () { return __awaiter(void 0, void 0, void 0, function () {
76
+ var _a;
77
+ return __generator(this, function (_b) {
78
+ switch (_b.label) {
79
+ case 0:
80
+ _a = expect;
81
+ return [4 /*yield*/, index_1.tokenList()];
82
+ case 1:
83
+ _a.apply(void 0, [(_b.sent()).length]).toMatchInlineSnapshot("811");
84
+ return [2 /*return*/];
85
+ }
86
+ });
87
+ }); });
88
+ test("kyberTokens", function () { return __awaiter(void 0, void 0, void 0, function () {
89
+ var tokens, keys, i, key;
90
+ return __generator(this, function (_a) {
91
+ switch (_a.label) {
92
+ case 0: return [4 /*yield*/, index_1.kyberTokens()];
93
+ case 1:
94
+ tokens = _a.sent();
95
+ keys = Object.keys(tokens.output);
96
+ for (i = 0; i < keys.length; i++) {
97
+ key = keys[i];
98
+ if (i < 3) {
99
+ tokens.output[key].ethPrice = 0.002; // To avoid constant changes that break the snapshot
100
+ }
101
+ else {
102
+ delete tokens.output[key];
103
+ }
104
+ }
105
+ expect(tokens).toEqual({
106
+ output: {
107
+ "0x111111111117dc0aa78b770fa6a738034120c302": {
108
+ symbol: "1INCH",
109
+ decimals: 18,
110
+ ethPrice: 0.002,
111
+ },
112
+ "0xe48972fcd82a274411c01834e2f031d4377fa2c0": {
113
+ symbol: "2KEY",
114
+ decimals: 18,
115
+ ethPrice: 0.002,
116
+ },
117
+ "0x7fc66500c84a76ad7e9c93437bfc5ac33e2ddae9": {
118
+ symbol: "AAVE",
119
+ decimals: 18,
120
+ ethPrice: 0.002,
121
+ },
122
+ },
123
+ });
124
+ return [2 /*return*/];
125
+ }
126
+ });
127
+ }); });
128
+ var sortSymbols = function (a, b) { return (a.address > b.address ? 1 : -1); };
129
+ test("toSymbols", function () { return __awaiter(void 0, void 0, void 0, function () {
130
+ var _a;
131
+ return __generator(this, function (_b) {
132
+ switch (_b.label) {
133
+ case 0:
134
+ _a = expect;
135
+ return [4 /*yield*/, index_1.toSymbols({
136
+ "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE": "2.363644408933851e+23",
137
+ "0x6B175474E89094C44Da98b954EedeAC495271d0F": "2.3462351944349785e+26",
138
+ "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48": "370186290673080",
139
+ "0xdAC17F958D2ee523a2206206994597C13D831ec7": "411511818650054",
140
+ "0xC2cB1040220768554cf699b0d863A3cd4324ce32": "1.232581672477717e+25",
141
+ })];
142
+ case 1:
143
+ _a.apply(void 0, [(_b.sent()).output.sort(sortSymbols)]).toEqual(JSON.parse('[{"symbol":"ETH","address":"0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee","balance":"236364.440893"},{"symbol":"DAI","address":"0x6b175474e89094c44da98b954eedeac495271d0f","balance":"234623519.443498"},{"symbol":"USDC","address":"0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48","balance":"370186290.673080"},{"symbol":"USDT","address":"0xdac17f958d2ee523a2206206994597c13d831ec7","balance":"411511818.650054"},{"symbol":"yDAI","address":"0xc2cb1040220768554cf699b0d863a3cd4324ce32","balance":"12325816.724777"}]').sort(sortSymbols));
144
+ return [2 /*return*/];
145
+ }
146
+ });
147
+ }); });
148
+ test("toSymbols works well with 0x0 as an ETH address", function () { return __awaiter(void 0, void 0, void 0, function () {
149
+ var _a;
150
+ return __generator(this, function (_b) {
151
+ switch (_b.label) {
152
+ case 0:
153
+ _a = expect;
154
+ return [4 /*yield*/, index_1.toSymbols({
155
+ "0x0000000000000000000000000000000000000000": "2100000000000000000", // ETH
156
+ })];
157
+ case 1:
158
+ _a.apply(void 0, [_b.sent()]).toEqual({
159
+ output: [
160
+ {
161
+ symbol: "ETH",
162
+ address: "0x0000000000000000000000000000000000000000",
163
+ balance: "2.100000",
164
+ },
165
+ ],
166
+ });
167
+ return [2 /*return*/];
168
+ }
169
+ });
170
+ }); });
171
+ test("getLogs", function () { return __awaiter(void 0, void 0, void 0, function () {
172
+ var poolLogs;
173
+ return __generator(this, function (_a) {
174
+ switch (_a.label) {
175
+ case 0: return [4 /*yield*/, index_1.getLogs({
176
+ target: "0x9424B1412450D0f8Fc2255FAf6046b98213B76Bd",
177
+ topic: "LOG_NEW_POOL(address,address)",
178
+ keys: ["topics"],
179
+ fromBlock: 9562480,
180
+ toBlock: 9575480,
181
+ })];
182
+ case 1:
183
+ poolLogs = _a.sent();
184
+ expect(poolLogs).toEqual({
185
+ output: [
186
+ [
187
+ "0x8ccec77b0cb63ac2cafd0f5de8cdfadab91ce656d262240ba8a6343bccc5f945",
188
+ "0x00000000000000000000000018fa2ac3c88112e36eff15370346f9aff3161fd1",
189
+ "0x000000000000000000000000165a50bc092f6870dc111c349bae5fc35147ac86",
190
+ ],
191
+ [
192
+ "0x8ccec77b0cb63ac2cafd0f5de8cdfadab91ce656d262240ba8a6343bccc5f945",
193
+ "0x00000000000000000000000018fa2ac3c88112e36eff15370346f9aff3161fd1",
194
+ "0x00000000000000000000000057755f7dec33320bca83159c26e93751bfd30fbe",
195
+ ],
196
+ [
197
+ "0x8ccec77b0cb63ac2cafd0f5de8cdfadab91ce656d262240ba8a6343bccc5f945",
198
+ "0x00000000000000000000000018fa2ac3c88112e36eff15370346f9aff3161fd1",
199
+ "0x000000000000000000000000e5d1fab0c5596ef846dcc0958d6d0b20e1ec4498",
200
+ ],
201
+ ],
202
+ });
203
+ return [2 /*return*/];
204
+ }
205
+ });
206
+ }); });
207
+ test("getLogs supports it's old API", function () { return __awaiter(void 0, void 0, void 0, function () {
208
+ var _a;
209
+ return __generator(this, function (_b) {
210
+ switch (_b.label) {
211
+ case 0:
212
+ _a = expect;
213
+ return [4 /*yield*/, index_1.getLogs({
214
+ keys: [],
215
+ toBlock: 12047406,
216
+ target: "0x35d1b3f3d7966a1dfe207aa4514c12a259a0492b",
217
+ fromBlock: 8928152,
218
+ topics: [
219
+ "0x65fae35e00000000000000000000000000000000000000000000000000000000",
220
+ ],
221
+ })];
222
+ case 1:
223
+ _a.apply(void 0, [(_b.sent()).output.slice(0, 2)]).toEqual([
224
+ {
225
+ address: "0x35D1b3F3D7966A1DFe207aa4514C12a259A0492B",
226
+ blockHash: "0x4e0c6d0ceaade9476d0798a44452117c42300389f43ad8397e91092827019fed",
227
+ blockNumber: 8928152,
228
+ data: "0x000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000e065fae35e000000000000000000000000baa65281c2fa2baacb2cb550ba051525a480d3f40000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
229
+ logIndex: 64,
230
+ removed: false,
231
+ topics: [
232
+ "0x65fae35e00000000000000000000000000000000000000000000000000000000",
233
+ "0x000000000000000000000000baa65281c2fa2baacb2cb550ba051525a480d3f4",
234
+ "0x0000000000000000000000000000000000000000000000000000000000000000",
235
+ "0x0000000000000000000000000000000000000000000000000000000000000000",
236
+ ],
237
+ transactionHash: "0xa39edcdeb7310150d7be44b8da94e5043d1cf8600d59f855a65c7a9c035b06a7",
238
+ transactionIndex: 66,
239
+ //id: 'log_4301d412' // SHOULD BE SUPPORTED BUT HEH
240
+ },
241
+ {
242
+ address: "0x35D1b3F3D7966A1DFe207aa4514C12a259A0492B",
243
+ blockHash: "0x4e0c6d0ceaade9476d0798a44452117c42300389f43ad8397e91092827019fed",
244
+ blockNumber: 8928152,
245
+ data: "0x000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000e065fae35e00000000000000000000000065c79fcb50ca1594b025960e539ed7a9a6d434a30000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
246
+ logIndex: 68,
247
+ removed: false,
248
+ topics: [
249
+ "0x65fae35e00000000000000000000000000000000000000000000000000000000",
250
+ "0x00000000000000000000000065c79fcb50ca1594b025960e539ed7a9a6d434a3",
251
+ "0x0000000000000000000000000000000000000000000000000000000000000000",
252
+ "0x0000000000000000000000000000000000000000000000000000000000000000",
253
+ ],
254
+ transactionHash: "0xa39edcdeb7310150d7be44b8da94e5043d1cf8600d59f855a65c7a9c035b06a7",
255
+ transactionIndex: 66,
256
+ //id: 'log_eaa6bc34' // SHOULD BE SUPPORTED BUT HEH
257
+ },
258
+ ]);
259
+ return [2 /*return*/];
260
+ }
261
+ });
262
+ }); });
263
+ test("sushiswap getLogs follow the old API", function () { return __awaiter(void 0, void 0, void 0, function () {
264
+ var _a;
265
+ return __generator(this, function (_b) {
266
+ switch (_b.label) {
267
+ case 0:
268
+ _a = expect;
269
+ return [4 /*yield*/, index_1.getLogs({
270
+ keys: [],
271
+ toBlock: 12052813,
272
+ target: "0xc0aee478e3658e2610c5f7a4a2e1777ce9e4f2ac",
273
+ fromBlock: 10794229,
274
+ topic: "PairCreated(address,address,address,uint256)",
275
+ })];
276
+ case 1:
277
+ _a.apply(void 0, [(_b.sent()).output.slice(0, 2)]).toEqual([
278
+ {
279
+ address: "0xC0AEe478e3658e2610c5F7A4A2E1777cE9e4f2Ac",
280
+ blockHash: "0xf59ff7fcf1443e7e61582224359a030bb7178871182cc543acb16627e81ec1a8",
281
+ blockNumber: 10794352,
282
+ data: "0x000000000000000000000000680a025da7b1be2c204d7745e809919bce0740260000000000000000000000000000000000000000000000000000000000000001",
283
+ logIndex: 81,
284
+ removed: false,
285
+ topics: [
286
+ "0x0d3648bd0f6ba80134a33ba9275ac585d9d315f0ad8355cddefde31afa28d0e9",
287
+ "0x0000000000000000000000006b3595068778dd592e39a122f4f5a5cf09c90fe2",
288
+ "0x000000000000000000000000dac17f958d2ee523a2206206994597c13d831ec7",
289
+ ],
290
+ transactionHash: "0x64318dfffc6544cb4782715ad914e335039cda02f5e8d3e47f0dac47f53565d2",
291
+ transactionIndex: 56,
292
+ //id: 'log_20f0cd7e'
293
+ },
294
+ {
295
+ address: "0xC0AEe478e3658e2610c5F7A4A2E1777cE9e4f2Ac",
296
+ blockHash: "0x25c6da25c999e1c668d60a5068128eb521ef121e4b46fb24575ed6fb037ede67",
297
+ blockNumber: 10822038,
298
+ data: "0x00000000000000000000000006da0fd433c1a5d7a4faa01111c044910a1845530000000000000000000000000000000000000000000000000000000000000002",
299
+ logIndex: 202,
300
+ removed: false,
301
+ topics: [
302
+ "0x0d3648bd0f6ba80134a33ba9275ac585d9d315f0ad8355cddefde31afa28d0e9",
303
+ "0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2",
304
+ "0x000000000000000000000000dac17f958d2ee523a2206206994597c13d831ec7",
305
+ ],
306
+ transactionHash: "0xaf215158cef8da66b2f6addc48d8683199468560599ac568b8981d9d67dc04b6",
307
+ transactionIndex: 89,
308
+ //id: 'log_2758f079'
309
+ },
310
+ ]);
311
+ return [2 /*return*/];
312
+ }
313
+ });
314
+ }); });