@curvefi/api 2.46.6 → 2.47.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.
package/lib/utils.d.ts CHANGED
@@ -45,3 +45,5 @@ export declare const getCoinsData: (...coins: string[] | string[][]) => Promise<
45
45
  symbol: string;
46
46
  decimals: number;
47
47
  }[]>;
48
+ export declare const hasDepositAndStake: () => boolean;
49
+ export declare const hasRouter: () => boolean;
package/lib/utils.js CHANGED
@@ -408,7 +408,7 @@ var _getTokenAddressBySwapAddress = function (swapAddress) {
408
408
  return res[0][1].token_address;
409
409
  };
410
410
  export var _getUsdPricesFromApi = function () { return __awaiter(void 0, void 0, void 0, function () {
411
- var network, allTypesExtendedPoolData, priceDict, _i, allTypesExtendedPoolData_1, extendedPoolData, _a, _b, pool, lpTokenAddress, totalSupply, _c, _d, coin, _e, _f, coin;
411
+ var network, allTypesExtendedPoolData, priceDict, priceDictByMaxTvl, _i, allTypesExtendedPoolData_1, extendedPoolData, _a, _b, pool, lpTokenAddress, totalSupply, _c, _d, coin, _e, _f, coin, address, maxTvlItem;
412
412
  var _g, _h;
413
413
  return __generator(this, function (_j) {
414
414
  switch (_j.label) {
@@ -418,26 +418,81 @@ export var _getUsdPricesFromApi = function () { return __awaiter(void 0, void 0,
418
418
  case 1:
419
419
  allTypesExtendedPoolData = _j.sent();
420
420
  priceDict = {};
421
+ priceDictByMaxTvl = {};
421
422
  for (_i = 0, allTypesExtendedPoolData_1 = allTypesExtendedPoolData; _i < allTypesExtendedPoolData_1.length; _i++) {
422
423
  extendedPoolData = allTypesExtendedPoolData_1[_i];
423
424
  for (_a = 0, _b = extendedPoolData.poolData; _a < _b.length; _a++) {
424
425
  pool = _b[_a];
425
426
  lpTokenAddress = (_g = pool.lpTokenAddress) !== null && _g !== void 0 ? _g : pool.address;
426
427
  totalSupply = pool.totalSupply / (Math.pow(10, 18));
427
- priceDict[lpTokenAddress.toLowerCase()] = pool.usdTotal && totalSupply ? pool.usdTotal / totalSupply : 0;
428
+ if (lpTokenAddress.toLowerCase() in priceDict) {
429
+ priceDict[lpTokenAddress.toLowerCase()].push({
430
+ price: pool.usdTotal && totalSupply ? pool.usdTotal / totalSupply : 0,
431
+ tvl: pool.usdTotal
432
+ });
433
+ }
434
+ else {
435
+ priceDict[lpTokenAddress.toLowerCase()] = [];
436
+ priceDict[lpTokenAddress.toLowerCase()].push({
437
+ price: pool.usdTotal && totalSupply ? pool.usdTotal / totalSupply : 0,
438
+ tvl: pool.usdTotal
439
+ });
440
+ }
428
441
  for (_c = 0, _d = pool.coins; _c < _d.length; _c++) {
429
442
  coin = _d[_c];
430
- if (typeof coin.usdPrice === "number")
431
- priceDict[coin.address.toLowerCase()] = coin.usdPrice;
443
+ if (typeof coin.usdPrice === "number") {
444
+ if (coin.address.toLowerCase() in priceDict) {
445
+ priceDict[coin.address.toLowerCase()].push({
446
+ price: coin.usdPrice,
447
+ tvl: pool.usdTotal
448
+ });
449
+ }
450
+ else {
451
+ priceDict[coin.address.toLowerCase()] = [];
452
+ priceDict[coin.address.toLowerCase()].push({
453
+ price: coin.usdPrice,
454
+ tvl: pool.usdTotal
455
+ });
456
+ }
457
+ }
432
458
  }
433
459
  for (_e = 0, _f = (_h = pool.gaugeRewards) !== null && _h !== void 0 ? _h : []; _e < _f.length; _e++) {
434
460
  coin = _f[_e];
435
- if (typeof coin.tokenPrice === "number")
436
- priceDict[coin.tokenAddress.toLowerCase()] = coin.tokenPrice;
461
+ if (typeof coin.tokenPrice === "number") {
462
+ if (coin.tokenAddress.toLowerCase() in priceDict) {
463
+ priceDict[coin.tokenAddress.toLowerCase()].push({
464
+ price: coin.tokenPrice,
465
+ tvl: pool.usdTotal
466
+ });
467
+ }
468
+ else {
469
+ priceDict[coin.tokenAddress.toLowerCase()] = [];
470
+ priceDict[coin.tokenAddress.toLowerCase()].push({
471
+ price: coin.tokenPrice,
472
+ tvl: pool.usdTotal
473
+ });
474
+ }
475
+ }
437
476
  }
438
477
  }
439
478
  }
440
- return [2 /*return*/, priceDict];
479
+ for (address in priceDict) {
480
+ if (priceDict[address].length > 0) {
481
+ maxTvlItem = priceDict[address].reduce(function (prev, current) {
482
+ if (+current.tvl > +prev.tvl) {
483
+ return current;
484
+ }
485
+ else {
486
+ return prev;
487
+ }
488
+ });
489
+ priceDictByMaxTvl[address] = maxTvlItem.price;
490
+ }
491
+ else {
492
+ priceDictByMaxTvl[address] = 0;
493
+ }
494
+ }
495
+ return [2 /*return*/, priceDictByMaxTvl];
441
496
  }
442
497
  });
443
498
  }); };
@@ -756,3 +811,5 @@ export var getCoinsData = function () {
756
811
  });
757
812
  });
758
813
  };
814
+ export var hasDepositAndStake = function () { return curve.constants.ALIASES.deposit_and_stake !== curve.constants.ZERO_ADDRESS; };
815
+ export var hasRouter = function () { return curve.constants.ALIASES.router !== curve.constants.ZERO_ADDRESS; };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@curvefi/api",
3
- "version": "2.46.6",
3
+ "version": "2.47.0",
4
4
  "description": "JavaScript library for curve.fi",
5
5
  "main": "lib/index.js",
6
6
  "author": "Macket",
@@ -1,309 +0,0 @@
1
- [
2
- {
3
- "name": "NewAddressIdentifier",
4
- "inputs": [
5
- {
6
- "type": "uint256",
7
- "name": "id",
8
- "indexed": true
9
- },
10
- {
11
- "type": "address",
12
- "name": "addr",
13
- "indexed": false
14
- },
15
- {
16
- "type": "string",
17
- "name": "description",
18
- "indexed": false
19
- }
20
- ],
21
- "anonymous": false,
22
- "type": "event"
23
- },
24
- {
25
- "name": "AddressModified",
26
- "inputs": [
27
- {
28
- "type": "uint256",
29
- "name": "id",
30
- "indexed": true
31
- },
32
- {
33
- "type": "address",
34
- "name": "new_address",
35
- "indexed": false
36
- },
37
- {
38
- "type": "uint256",
39
- "name": "version",
40
- "indexed": false
41
- }
42
- ],
43
- "anonymous": false,
44
- "type": "event"
45
- },
46
- {
47
- "name": "CommitNewAdmin",
48
- "inputs": [
49
- {
50
- "type": "uint256",
51
- "name": "deadline",
52
- "indexed": true
53
- },
54
- {
55
- "type": "address",
56
- "name": "admin",
57
- "indexed": true
58
- }
59
- ],
60
- "anonymous": false,
61
- "type": "event"
62
- },
63
- {
64
- "name": "NewAdmin",
65
- "inputs": [
66
- {
67
- "type": "address",
68
- "name": "admin",
69
- "indexed": true
70
- }
71
- ],
72
- "anonymous": false,
73
- "type": "event"
74
- },
75
- {
76
- "outputs": [],
77
- "inputs": [
78
- {
79
- "type": "address",
80
- "name": "_admin"
81
- }
82
- ],
83
- "stateMutability": "nonpayable",
84
- "type": "constructor"
85
- },
86
- {
87
- "name": "get_registry",
88
- "outputs": [
89
- {
90
- "type": "address",
91
- "name": ""
92
- }
93
- ],
94
- "inputs": [],
95
- "stateMutability": "view",
96
- "type": "function",
97
- "gas": "1061"
98
- },
99
- {
100
- "name": "max_id",
101
- "outputs": [
102
- {
103
- "type": "uint256",
104
- "name": ""
105
- }
106
- ],
107
- "inputs": [],
108
- "stateMutability": "view",
109
- "type": "function",
110
- "gas": "1258"
111
- },
112
- {
113
- "name": "get_address",
114
- "outputs": [
115
- {
116
- "type": "address",
117
- "name": ""
118
- }
119
- ],
120
- "inputs": [
121
- {
122
- "type": "uint256",
123
- "name": "_id"
124
- }
125
- ],
126
- "stateMutability": "view",
127
- "type": "function",
128
- "gas": "1308"
129
- },
130
- {
131
- "name": "add_new_id",
132
- "outputs": [
133
- {
134
- "type": "uint256",
135
- "name": ""
136
- }
137
- ],
138
- "inputs": [
139
- {
140
- "type": "address",
141
- "name": "_address"
142
- },
143
- {
144
- "type": "string",
145
- "name": "_description"
146
- }
147
- ],
148
- "stateMutability": "nonpayable",
149
- "type": "function",
150
- "gas": "291275"
151
- },
152
- {
153
- "name": "set_address",
154
- "outputs": [
155
- {
156
- "type": "bool",
157
- "name": ""
158
- }
159
- ],
160
- "inputs": [
161
- {
162
- "type": "uint256",
163
- "name": "_id"
164
- },
165
- {
166
- "type": "address",
167
- "name": "_address"
168
- }
169
- ],
170
- "stateMutability": "nonpayable",
171
- "type": "function",
172
- "gas": "182430"
173
- },
174
- {
175
- "name": "unset_address",
176
- "outputs": [
177
- {
178
- "type": "bool",
179
- "name": ""
180
- }
181
- ],
182
- "inputs": [
183
- {
184
- "type": "uint256",
185
- "name": "_id"
186
- }
187
- ],
188
- "stateMutability": "nonpayable",
189
- "type": "function",
190
- "gas": "101348"
191
- },
192
- {
193
- "name": "commit_transfer_ownership",
194
- "outputs": [
195
- {
196
- "type": "bool",
197
- "name": ""
198
- }
199
- ],
200
- "inputs": [
201
- {
202
- "type": "address",
203
- "name": "_new_admin"
204
- }
205
- ],
206
- "stateMutability": "nonpayable",
207
- "type": "function",
208
- "gas": "74048"
209
- },
210
- {
211
- "name": "apply_transfer_ownership",
212
- "outputs": [
213
- {
214
- "type": "bool",
215
- "name": ""
216
- }
217
- ],
218
- "inputs": [],
219
- "stateMutability": "nonpayable",
220
- "type": "function",
221
- "gas": "60125"
222
- },
223
- {
224
- "name": "revert_transfer_ownership",
225
- "outputs": [
226
- {
227
- "type": "bool",
228
- "name": ""
229
- }
230
- ],
231
- "inputs": [],
232
- "stateMutability": "nonpayable",
233
- "type": "function",
234
- "gas": "21400"
235
- },
236
- {
237
- "name": "admin",
238
- "outputs": [
239
- {
240
- "type": "address",
241
- "name": ""
242
- }
243
- ],
244
- "inputs": [],
245
- "stateMutability": "view",
246
- "type": "function",
247
- "gas": "1331"
248
- },
249
- {
250
- "name": "transfer_ownership_deadline",
251
- "outputs": [
252
- {
253
- "type": "uint256",
254
- "name": ""
255
- }
256
- ],
257
- "inputs": [],
258
- "stateMutability": "view",
259
- "type": "function",
260
- "gas": "1361"
261
- },
262
- {
263
- "name": "future_admin",
264
- "outputs": [
265
- {
266
- "type": "address",
267
- "name": ""
268
- }
269
- ],
270
- "inputs": [],
271
- "stateMutability": "view",
272
- "type": "function",
273
- "gas": "1391"
274
- },
275
- {
276
- "name": "get_id_info",
277
- "outputs": [
278
- {
279
- "type": "address",
280
- "name": "addr"
281
- },
282
- {
283
- "type": "bool",
284
- "name": "is_active"
285
- },
286
- {
287
- "type": "uint256",
288
- "name": "version"
289
- },
290
- {
291
- "type": "uint256",
292
- "name": "last_modified"
293
- },
294
- {
295
- "type": "string",
296
- "name": "description"
297
- }
298
- ],
299
- "inputs": [
300
- {
301
- "type": "uint256",
302
- "name": "arg0"
303
- }
304
- ],
305
- "stateMutability": "view",
306
- "type": "function",
307
- "gas": "12168"
308
- }
309
- ]