@curvefi/api 2.29.0 → 2.30.1

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.
@@ -63,12 +63,14 @@ exports.getFactoryPoolData = void 0;
63
63
  var ethers_1 = require("ethers");
64
64
  var ethcall_1 = require("ethcall");
65
65
  var ERC20_json_1 = __importDefault(require("../constants/abis/ERC20.json"));
66
- var deposit_json_1 = __importDefault(require("../constants/abis/factoryPools/deposit.json"));
67
66
  var gauge_factory_json_1 = __importDefault(require("../constants/abis/gauge_factory.json"));
68
67
  var gauge_child_json_1 = __importDefault(require("../constants/abis/gauge_child.json"));
69
68
  var common_1 = require("./common");
70
69
  var constants_1 = require("./constants");
71
70
  var BLACK_LIST = {
71
+ 1: [
72
+ "0x066b6e1e93fa7dcd3f0eb7f8bac7d5a747ce0bf9",
73
+ ],
72
74
  137: [
73
75
  "0x666dc3b4babfd063faf965bd020024af0dc51b64",
74
76
  "0xe4199bc5c5c1f63dba47b56b6db7144c51cf0bf8",
@@ -106,8 +108,9 @@ function getRecentlyCreatedPoolId(swapAddress) {
106
108
  });
107
109
  });
108
110
  }
109
- function getFactoryIdsAndSwapAddresses() {
111
+ function getFactoryIdsAndSwapAddresses(fromIdx) {
110
112
  var _a;
113
+ if (fromIdx === void 0) { fromIdx = 0; }
111
114
  return __awaiter(this, void 0, void 0, function () {
112
115
  var factoryContract, factoryMulticallContract, poolCount, _b, _c, _e, calls, i, factories, swapAddresses, blacklist;
113
116
  return __generator(this, function (_f) {
@@ -121,12 +124,14 @@ function getFactoryIdsAndSwapAddresses() {
121
124
  case 1:
122
125
  poolCount = _b.apply(void 0, [_e.apply(_c, [_f.sent(), 0])]);
123
126
  calls = [];
124
- for (i = 0; i < poolCount; i++) {
127
+ for (i = fromIdx; i < poolCount; i++) {
125
128
  calls.push(factoryMulticallContract.pool_list(i));
126
129
  }
130
+ if (calls.length === 0)
131
+ return [2 /*return*/, [[], []]];
127
132
  return [4 /*yield*/, this.multicallProvider.all(calls)];
128
133
  case 2:
129
- factories = (_f.sent()).map(function (addr, i) { return ({ id: "factory-v2-".concat(i), address: addr.toLowerCase() }); });
134
+ factories = (_f.sent()).map(function (addr, i) { return ({ id: "factory-v2-".concat(fromIdx + i), address: addr.toLowerCase() }); });
130
135
  swapAddresses = Object.values(this.constants.POOLS_DATA).map(function (pool) { return pool.swap_address.toLowerCase(); });
131
136
  blacklist = (_a = BLACK_LIST[this.chainId]) !== null && _a !== void 0 ? _a : [];
132
137
  factories = factories.filter(function (f) { return !swapAddresses.includes(f.address) && !blacklist.includes(f.address); });
@@ -135,21 +140,51 @@ function getFactoryIdsAndSwapAddresses() {
135
140
  });
136
141
  });
137
142
  }
138
- function getFactoryImplementations(factorySwapAddresses) {
143
+ function _handleReferenceAssets(referenceAssets) {
144
+ return referenceAssets.map(function (t) {
145
+ return {
146
+ 0: "USD",
147
+ 1: "ETH",
148
+ 2: "BTC",
149
+ }[ethers_1.ethers.utils.formatUnits(t, 0)] || "OTHER";
150
+ });
151
+ }
152
+ function _handleCoinAddresses(coinAddresses) {
153
+ var _this = this;
154
+ return coinAddresses.map(function (addresses) { return addresses
155
+ .filter(function (addr) { return addr !== ethers_1.ethers.constants.AddressZero; })
156
+ .map(function (addr) { return _this.chainId === 137 && addr === "0x0000000000000000000000000000000000001010" ? _this.constants.NATIVE_TOKEN.address : addr.toLowerCase(); }); });
157
+ }
158
+ function getPoolsData(factorySwapAddresses) {
139
159
  return __awaiter(this, void 0, void 0, function () {
140
- var factoryMulticallContract, calls, _i, factorySwapAddresses_1, addr;
160
+ var factoryMulticallContract, calls, _i, factorySwapAddresses_1, addr, tempSwapContract, res, implememntationAddresses, gaugeAddresses, referenceAssets, symbols, names, isMeta, coinAddresses;
141
161
  return __generator(this, function (_a) {
142
162
  switch (_a.label) {
143
- case 0: return [4 /*yield*/, this.contracts[this.constants.ALIASES.factory].multicallContract];
144
- case 1:
145
- factoryMulticallContract = _a.sent();
163
+ case 0:
164
+ factoryMulticallContract = this.contracts[this.constants.ALIASES.factory].multicallContract;
146
165
  calls = [];
147
166
  for (_i = 0, factorySwapAddresses_1 = factorySwapAddresses; _i < factorySwapAddresses_1.length; _i++) {
148
167
  addr = factorySwapAddresses_1[_i];
168
+ tempSwapContract = new ethcall_1.Contract(addr, ERC20_json_1.default);
149
169
  calls.push(factoryMulticallContract.get_implementation_address(addr));
170
+ calls.push(factoryMulticallContract.get_gauge(addr));
171
+ calls.push(factoryMulticallContract.get_pool_asset_type(addr));
172
+ calls.push(tempSwapContract.symbol());
173
+ calls.push(tempSwapContract.name());
174
+ calls.push(factoryMulticallContract.is_meta(addr));
175
+ calls.push(factoryMulticallContract.get_coins(addr));
150
176
  }
151
177
  return [4 /*yield*/, this.multicallProvider.all(calls)];
152
- case 2: return [2 /*return*/, (_a.sent()).map(function (a) { return a.toLowerCase(); })];
178
+ case 1:
179
+ res = _a.sent();
180
+ implememntationAddresses = res.filter(function (a, i) { return i % 7 == 0; }).map(function (a) { return a.toLowerCase(); });
181
+ gaugeAddresses = res.filter(function (a, i) { return i % 7 == 1; }).map(function (a) { return a.toLowerCase(); });
182
+ referenceAssets = _handleReferenceAssets(res.filter(function (a, i) { return i % 7 == 2; }));
183
+ symbols = res.filter(function (a, i) { return i % 7 == 3; });
184
+ names = res.filter(function (a, i) { return i % 7 == 4; });
185
+ isMeta = res.filter(function (a, i) { return i % 7 == 5; });
186
+ coinAddresses = _handleCoinAddresses.call(this, res.filter(function (a, i) { return i % 7 == 6; }));
187
+ return [2 /*return*/, [implememntationAddresses, gaugeAddresses, referenceAssets, symbols, names, isMeta, coinAddresses]];
153
188
  }
154
189
  });
155
190
  });
@@ -157,110 +192,13 @@ function getFactoryImplementations(factorySwapAddresses) {
157
192
  function setFactorySwapContracts(factorySwapAddresses, factorySwapABIs) {
158
193
  var _this = this;
159
194
  factorySwapAddresses.forEach(function (addr, i) {
160
- _this.contracts[addr] = {
161
- contract: new ethers_1.Contract(addr, factorySwapABIs[i], _this.signer || _this.provider),
162
- multicallContract: new ethcall_1.Contract(addr, factorySwapABIs[i]),
163
- };
164
- });
165
- }
166
- function getFactoryGaugeAddresses(factorySwapAddresses) {
167
- return __awaiter(this, void 0, void 0, function () {
168
- var factoryMulticallContract, calls, _i, factorySwapAddresses_2, addr;
169
- return __generator(this, function (_a) {
170
- switch (_a.label) {
171
- case 0: return [4 /*yield*/, this.contracts[this.constants.ALIASES.factory].multicallContract];
172
- case 1:
173
- factoryMulticallContract = _a.sent();
174
- calls = [];
175
- for (_i = 0, factorySwapAddresses_2 = factorySwapAddresses; _i < factorySwapAddresses_2.length; _i++) {
176
- addr = factorySwapAddresses_2[_i];
177
- calls.push(factoryMulticallContract.get_gauge(addr));
178
- }
179
- return [4 /*yield*/, this.multicallProvider.all(calls)];
180
- case 2: return [2 /*return*/, (_a.sent()).map(function (addr) { return addr.toLowerCase(); })];
181
- }
182
- });
195
+ _this.setContract(addr, factorySwapABIs[i]);
183
196
  });
184
197
  }
185
198
  function setFactoryGaugeContracts(factoryGaugeAddresses) {
186
199
  var _this = this;
187
200
  factoryGaugeAddresses.filter(function (addr) { return addr !== ethers_1.ethers.constants.AddressZero; }).forEach(function (addr, i) {
188
- _this.contracts[addr] = {
189
- contract: new ethers_1.Contract(addr, _this.chainId === 1 ? gauge_factory_json_1.default : gauge_child_json_1.default, _this.signer || _this.provider),
190
- multicallContract: new ethcall_1.Contract(addr, _this.chainId === 1 ? gauge_factory_json_1.default : gauge_child_json_1.default),
191
- };
192
- });
193
- }
194
- function getFactorySymbolsAndNames(factorySwapAddresses) {
195
- return __awaiter(this, void 0, void 0, function () {
196
- var calls, _i, factorySwapAddresses_3, addr, res, symbols, names, i;
197
- return __generator(this, function (_a) {
198
- switch (_a.label) {
199
- case 0:
200
- calls = [];
201
- for (_i = 0, factorySwapAddresses_3 = factorySwapAddresses; _i < factorySwapAddresses_3.length; _i++) {
202
- addr = factorySwapAddresses_3[_i];
203
- calls.push(this.contracts[addr].multicallContract.symbol(), this.contracts[addr].multicallContract.name());
204
- }
205
- return [4 /*yield*/, this.multicallProvider.all(calls)];
206
- case 1:
207
- res = _a.sent();
208
- symbols = [];
209
- names = [];
210
- for (i = 0; i < factorySwapAddresses.length; i++) {
211
- symbols.push(res[2 * i]);
212
- names.push(res[(2 * i) + 1]);
213
- }
214
- return [2 /*return*/, [symbols, names]];
215
- }
216
- });
217
- });
218
- }
219
- function getFactoryReferenceAssets(factorySwapAddresses) {
220
- return __awaiter(this, void 0, void 0, function () {
221
- var factoryMulticallContract, calls, _i, factorySwapAddresses_4, addr;
222
- return __generator(this, function (_a) {
223
- switch (_a.label) {
224
- case 0: return [4 /*yield*/, this.contracts[this.constants.ALIASES.factory].multicallContract];
225
- case 1:
226
- factoryMulticallContract = _a.sent();
227
- calls = [];
228
- for (_i = 0, factorySwapAddresses_4 = factorySwapAddresses; _i < factorySwapAddresses_4.length; _i++) {
229
- addr = factorySwapAddresses_4[_i];
230
- calls.push(factoryMulticallContract.get_pool_asset_type(addr));
231
- }
232
- return [4 /*yield*/, this.multicallProvider.all(calls)];
233
- case 2: return [2 /*return*/, (_a.sent()).map(function (t) {
234
- return {
235
- 0: "USD",
236
- 1: "ETH",
237
- 2: "BTC",
238
- }[ethers_1.ethers.utils.formatUnits(t, 0)] || "OTHER";
239
- })];
240
- }
241
- });
242
- });
243
- }
244
- function getFactoryCoinAddresses(factorySwapAddresses) {
245
- return __awaiter(this, void 0, void 0, function () {
246
- var factoryMulticallContract, calls, _i, factorySwapAddresses_5, addr;
247
- var _this = this;
248
- return __generator(this, function (_a) {
249
- switch (_a.label) {
250
- case 0: return [4 /*yield*/, this.contracts[this.constants.ALIASES.factory].multicallContract];
251
- case 1:
252
- factoryMulticallContract = _a.sent();
253
- calls = [];
254
- for (_i = 0, factorySwapAddresses_5 = factorySwapAddresses; _i < factorySwapAddresses_5.length; _i++) {
255
- addr = factorySwapAddresses_5[_i];
256
- calls.push(factoryMulticallContract.get_coins(addr));
257
- }
258
- return [4 /*yield*/, this.multicallProvider.all(calls)];
259
- case 2: return [2 /*return*/, (_a.sent()).map(function (addresses) { return addresses
260
- .filter(function (addr) { return addr !== ethers_1.ethers.constants.AddressZero; })
261
- .map(function (addr) { return _this.chainId === 137 && addr === "0x0000000000000000000000000000000000001010" ? _this.constants.NATIVE_TOKEN.address : addr.toLowerCase(); }); })];
262
- }
263
- });
201
+ _this.setContract(addr, _this.chainId === 1 ? gauge_factory_json_1.default : gauge_child_json_1.default);
264
202
  });
265
203
  }
266
204
  function setFactoryCoinsContracts(coinAddresses) {
@@ -269,10 +207,7 @@ function setFactoryCoinsContracts(coinAddresses) {
269
207
  var addr = flattenedCoinAddresses_1[_i];
270
208
  if (addr in this.contracts)
271
209
  continue;
272
- this.contracts[addr] = {
273
- contract: new ethers_1.Contract(addr, ERC20_json_1.default, this.signer || this.provider),
274
- multicallContract: new ethcall_1.Contract(addr, ERC20_json_1.default),
275
- };
210
+ this.setContract(addr, ERC20_json_1.default);
276
211
  }
277
212
  }
278
213
  function getExistingCoinAddressNameDict() {
@@ -296,152 +231,102 @@ function getExistingCoinAddressNameDict() {
296
231
  dict[this.constants.NATIVE_TOKEN.address] = this.constants.NATIVE_TOKEN.symbol;
297
232
  return dict;
298
233
  }
299
- function getCoinAddressNameDict(coinAddresses, existingCoinAddrNameDict) {
234
+ function getCoinsData(coinAddresses, existingCoinAddrNameDict, existingCoinAddrDecimalsDict) {
300
235
  return __awaiter(this, void 0, void 0, function () {
301
- var flattenedCoinAddresses, newCoinAddresses, coinAddrNamesDict, _i, flattenedCoinAddresses_2, addr, calls, names;
302
- var _this = this;
303
- return __generator(this, function (_a) {
304
- switch (_a.label) {
236
+ var flattenedCoinAddresses, newCoinAddresses, coinAddrNamesDict, coinAddrDecimalsDict, _i, flattenedCoinAddresses_2, addr, calls, _a, newCoinAddresses_1, addr, res, symbols, decimals;
237
+ return __generator(this, function (_b) {
238
+ switch (_b.label) {
305
239
  case 0:
306
240
  flattenedCoinAddresses = Array.from(new Set(deepFlatten(coinAddresses)));
307
241
  newCoinAddresses = [];
308
242
  coinAddrNamesDict = {};
243
+ coinAddrDecimalsDict = {};
309
244
  for (_i = 0, flattenedCoinAddresses_2 = flattenedCoinAddresses; _i < flattenedCoinAddresses_2.length; _i++) {
310
245
  addr = flattenedCoinAddresses_2[_i];
311
246
  if (addr in existingCoinAddrNameDict) {
312
247
  coinAddrNamesDict[addr] = existingCoinAddrNameDict[addr];
248
+ coinAddrDecimalsDict[addr] = existingCoinAddrDecimalsDict[addr];
313
249
  }
314
250
  else {
315
251
  newCoinAddresses.push(addr);
316
252
  }
317
253
  }
318
- calls = newCoinAddresses.map(function (addr) {
319
- return _this.contracts[addr].multicallContract.symbol();
320
- });
321
- return [4 /*yield*/, this.multicallProvider.all(calls)];
322
- case 1:
323
- names = _a.sent();
324
- newCoinAddresses.forEach(function (addr, i) {
325
- coinAddrNamesDict[addr] = names[i];
326
- });
327
- return [2 /*return*/, coinAddrNamesDict];
328
- }
329
- });
330
- });
331
- }
332
- function getCoinAddressDecimalsDict(coinAddresses, existingCoinAddressDecimalsDict) {
333
- return __awaiter(this, void 0, void 0, function () {
334
- var flattenedCoinAddresses, newCoinAddresses, coinAddrNamesDict, _i, flattenedCoinAddresses_3, addr, calls, decimals;
335
- var _this = this;
336
- return __generator(this, function (_a) {
337
- switch (_a.label) {
338
- case 0:
339
- flattenedCoinAddresses = Array.from(new Set(deepFlatten(coinAddresses))).filter(function (addr) { return addr !== _this.constants.NATIVE_TOKEN.address; });
340
- newCoinAddresses = [];
341
- coinAddrNamesDict = {};
342
- for (_i = 0, flattenedCoinAddresses_3 = flattenedCoinAddresses; _i < flattenedCoinAddresses_3.length; _i++) {
343
- addr = flattenedCoinAddresses_3[_i];
344
- if (addr in existingCoinAddressDecimalsDict) {
345
- coinAddrNamesDict[addr] = existingCoinAddressDecimalsDict[addr];
346
- }
347
- else {
348
- newCoinAddresses.push(addr);
349
- }
254
+ calls = [];
255
+ for (_a = 0, newCoinAddresses_1 = newCoinAddresses; _a < newCoinAddresses_1.length; _a++) {
256
+ addr = newCoinAddresses_1[_a];
257
+ calls.push(this.contracts[addr].multicallContract.symbol());
258
+ calls.push(this.contracts[addr].multicallContract.decimals());
350
259
  }
351
- calls = newCoinAddresses.map(function (addr) {
352
- return _this.contracts[addr].multicallContract.decimals();
353
- });
354
260
  return [4 /*yield*/, this.multicallProvider.all(calls)];
355
261
  case 1:
356
- decimals = (_a.sent()).map(function (_d) { return Number(ethers_1.ethers.utils.formatUnits(_d, 0)); });
262
+ res = _b.sent();
263
+ symbols = res.filter(function (a, i) { return i % 2 == 0; });
264
+ decimals = res.filter(function (a, i) { return i % 2 == 1; }).map(function (_d) { return Number(ethers_1.ethers.utils.formatUnits(_d, 0)); });
357
265
  newCoinAddresses.forEach(function (addr, i) {
358
- coinAddrNamesDict[addr] = decimals[i];
266
+ coinAddrNamesDict[addr] = symbols[i];
267
+ coinAddrDecimalsDict[addr] = decimals[i];
359
268
  });
360
- coinAddrNamesDict[this.constants.NATIVE_TOKEN.address] = 18;
361
- return [2 /*return*/, coinAddrNamesDict];
269
+ return [2 /*return*/, [coinAddrNamesDict, coinAddrDecimalsDict]];
362
270
  }
363
271
  });
364
272
  });
365
273
  }
366
- function getFactoryIsMeta(factorySwapAddresses) {
274
+ function getFactoryPoolData(fromIdx, swapAddress) {
275
+ if (fromIdx === void 0) { fromIdx = 0; }
367
276
  return __awaiter(this, void 0, void 0, function () {
368
- var factoryMulticallContract, calls, _i, factorySwapAddresses_6, addr;
369
- return __generator(this, function (_a) {
370
- switch (_a.label) {
371
- case 0: return [4 /*yield*/, this.contracts[this.constants.ALIASES.factory].multicallContract];
372
- case 1:
373
- factoryMulticallContract = _a.sent();
374
- calls = [];
375
- for (_i = 0, factorySwapAddresses_6 = factorySwapAddresses; _i < factorySwapAddresses_6.length; _i++) {
376
- addr = factorySwapAddresses_6[_i];
377
- calls.push(factoryMulticallContract.is_meta(addr));
378
- }
379
- return [4 /*yield*/, this.multicallProvider.all(calls)];
380
- case 2: return [2 /*return*/, _a.sent()];
381
- }
382
- });
383
- });
384
- }
385
- function getFactoryPoolData(swapAddress) {
386
- return __awaiter(this, void 0, void 0, function () {
387
- var _a, rawPoolIds, rawSwapAddresses, _b, rawImplementations, poolIds, swapAddresses, implementations, implementationABIDict, i, swapABIs, gaugeAddresses, _c, poolSymbols, poolNames, referenceAssets, coinAddresses, existingCoinAddressNameDict, coinAddressNameDict, coinAddressDecimalsDict, isMeta, implementationBasePoolIdDict, basePoolIds, FACTORY_POOLS_DATA, _loop_2, this_1, i;
388
- return __generator(this, function (_e) {
389
- switch (_e.label) {
277
+ var _a, rawPoolIds, rawSwapAddresses, _b, _c, rawImplementations, rawGauges, rawReferenceAssets, rawPoolSymbols, rawPoolNames, rawIsMeta, rawCoinAddresses, poolIds, swapAddresses, implementations, gaugeAddresses, referenceAssets, poolSymbols, poolNames, isMeta, coinAddresses, implementationABIDict, i, swapABIs, _e, coinAddressNameDict, coinAddressDecimalsDict, implementationBasePoolIdDict, basePoolIds, FACTORY_POOLS_DATA, _loop_2, this_1, i;
278
+ return __generator(this, function (_f) {
279
+ switch (_f.label) {
390
280
  case 0:
391
281
  if (!swapAddress) return [3 /*break*/, 2];
392
282
  return [4 /*yield*/, getRecentlyCreatedPoolId.call(this, swapAddress)];
393
283
  case 1:
394
- _b = [[_e.sent()], [swapAddress.toLowerCase()]];
284
+ _b = [[_f.sent()], [swapAddress.toLowerCase()]];
395
285
  return [3 /*break*/, 4];
396
- case 2: return [4 /*yield*/, getFactoryIdsAndSwapAddresses.call(this)];
286
+ case 2: return [4 /*yield*/, getFactoryIdsAndSwapAddresses.call(this, fromIdx)];
397
287
  case 3:
398
- _b = _e.sent();
399
- _e.label = 4;
288
+ _b = _f.sent();
289
+ _f.label = 4;
400
290
  case 4:
401
291
  _a = _b, rawPoolIds = _a[0], rawSwapAddresses = _a[1];
402
- return [4 /*yield*/, getFactoryImplementations.call(this, rawSwapAddresses)];
292
+ if (rawPoolIds.length === 0)
293
+ return [2 /*return*/, {}];
294
+ return [4 /*yield*/, getPoolsData.call(this, rawSwapAddresses)];
403
295
  case 5:
404
- rawImplementations = _e.sent();
296
+ _c = _f.sent(), rawImplementations = _c[0], rawGauges = _c[1], rawReferenceAssets = _c[2], rawPoolSymbols = _c[3], rawPoolNames = _c[4], rawIsMeta = _c[5], rawCoinAddresses = _c[6];
405
297
  poolIds = [];
406
298
  swapAddresses = [];
407
299
  implementations = [];
300
+ gaugeAddresses = [];
301
+ referenceAssets = [];
302
+ poolSymbols = [];
303
+ poolNames = [];
304
+ isMeta = [];
305
+ coinAddresses = [];
408
306
  implementationABIDict = constants_1.FACTORY_CONSTANTS[this.chainId].implementationABIDict;
409
307
  for (i = 0; i < rawPoolIds.length; i++) {
410
308
  if (rawImplementations[i] in implementationABIDict) {
411
309
  poolIds.push(rawPoolIds[i]);
412
310
  swapAddresses.push(rawSwapAddresses[i]);
413
311
  implementations.push(rawImplementations[i]);
312
+ gaugeAddresses.push(rawGauges[i]);
313
+ referenceAssets.push(rawReferenceAssets[i]);
314
+ poolSymbols.push(rawPoolSymbols[i]);
315
+ poolNames.push(rawPoolNames[i]);
316
+ isMeta.push(rawIsMeta[i]);
317
+ coinAddresses.push(rawCoinAddresses[i]);
414
318
  }
415
319
  }
416
320
  swapABIs = implementations.map(function (addr) { return implementationABIDict[addr]; });
417
321
  setFactorySwapContracts.call(this, swapAddresses, swapABIs);
418
- return [4 /*yield*/, getFactoryGaugeAddresses.call(this, swapAddresses)];
419
- case 6:
420
- gaugeAddresses = _e.sent();
421
322
  setFactoryGaugeContracts.call(this, gaugeAddresses);
422
- return [4 /*yield*/, getFactorySymbolsAndNames.call(this, swapAddresses)];
423
- case 7:
424
- _c = _e.sent(), poolSymbols = _c[0], poolNames = _c[1];
425
- return [4 /*yield*/, getFactoryReferenceAssets.call(this, swapAddresses)];
426
- case 8:
427
- referenceAssets = _e.sent();
428
- return [4 /*yield*/, getFactoryCoinAddresses.call(this, swapAddresses)];
429
- case 9:
430
- coinAddresses = _e.sent();
431
323
  setFactoryCoinsContracts.call(this, coinAddresses);
432
- existingCoinAddressNameDict = getExistingCoinAddressNameDict.call(this);
433
- return [4 /*yield*/, getCoinAddressNameDict.call(this, coinAddresses, existingCoinAddressNameDict)];
434
- case 10:
435
- coinAddressNameDict = _e.sent();
436
- return [4 /*yield*/, getCoinAddressDecimalsDict.call(this, coinAddresses, this.constants.DECIMALS)];
437
- case 11:
438
- coinAddressDecimalsDict = _e.sent();
439
- return [4 /*yield*/, getFactoryIsMeta.call(this, swapAddresses)];
440
- case 12:
441
- isMeta = _e.sent();
324
+ common_1.setFactoryZapContracts.call(this, false);
325
+ return [4 /*yield*/, getCoinsData.call(this, coinAddresses, getExistingCoinAddressNameDict.call(this), this.constants.DECIMALS)];
326
+ case 6:
327
+ _e = _f.sent(), coinAddressNameDict = _e[0], coinAddressDecimalsDict = _e[1];
442
328
  implementationBasePoolIdDict = constants_1.FACTORY_CONSTANTS[this.chainId].implementationBasePoolIdDict;
443
329
  basePoolIds = implementations.map(function (addr) { return implementationBasePoolIdDict[addr]; });
444
- common_1.setFactoryZapContracts.call(this, false);
445
330
  FACTORY_POOLS_DATA = {};
446
331
  _loop_2 = function (i) {
447
332
  if (!isMeta[i]) {
@@ -453,6 +338,7 @@ function getFactoryPoolData(swapAddress) {
453
338
  swap_address: swapAddresses[i],
454
339
  token_address: swapAddresses[i],
455
340
  gauge_address: gaugeAddresses[i],
341
+ implementation_address: implementations[i],
456
342
  is_plain: true,
457
343
  is_factory: true,
458
344
  underlying_coins: coinAddresses[i].map(function (addr) { return coinAddressNameDict[addr]; }),
@@ -474,6 +360,7 @@ function getFactoryPoolData(swapAddress) {
474
360
  // @ts-ignore
475
361
  var basePoolIdDecimalsDict = Object.fromEntries(basePoolIds.map(function (poolId) { var _a; return [poolId, (_a = allPoolsData_1[poolId]) === null || _a === void 0 ? void 0 : _a.underlying_decimals]; }));
476
362
  var basePoolIdZapDict = constants_1.FACTORY_CONSTANTS[this_1.chainId].basePoolIdZapDict;
363
+ var basePoolZap = basePoolIdZapDict[basePoolIds[i]];
477
364
  FACTORY_POOLS_DATA[poolIds[i]] = {
478
365
  name: poolNames[i].split(": ")[1].trim(),
479
366
  full_name: poolNames[i],
@@ -483,6 +370,7 @@ function getFactoryPoolData(swapAddress) {
483
370
  token_address: swapAddresses[i],
484
371
  gauge_address: gaugeAddresses[i],
485
372
  deposit_address: basePoolIdZapDict[basePoolIds[i]].address,
373
+ implementation_address: implementations[i],
486
374
  is_meta: true,
487
375
  is_factory: true,
488
376
  base_pool: basePoolIds[i],
@@ -494,7 +382,7 @@ function getFactoryPoolData(swapAddress) {
494
382
  wrapped_decimals: coinAddresses[i].map(function (addr) { return coinAddressDecimalsDict[addr]; }),
495
383
  swap_abi: swapABIs[i],
496
384
  gauge_abi: this_1.chainId === 1 ? gauge_factory_json_1.default : gauge_child_json_1.default,
497
- deposit_abi: deposit_json_1.default,
385
+ deposit_abi: basePoolZap.ABI,
498
386
  };
499
387
  }
500
388
  };
package/lib/index.d.ts CHANGED
@@ -15,10 +15,6 @@ declare function init(providerType: 'JsonRpc' | 'Web3' | 'Infura' | 'Alchemy', p
15
15
  maxPriorityFeePerGas?: number;
16
16
  chainId?: number;
17
17
  }): Promise<void>;
18
- declare function fetchFactoryPools(useApi?: boolean): Promise<void>;
19
- declare function fetchCryptoFactoryPools(useApi?: boolean): Promise<void>;
20
- declare function fetchRecentlyDeployedFactoryPool(poolAddress: string): Promise<string>;
21
- declare function fetchRecentlyDeployedCryptoFactoryPool(poolAddress: string): Promise<string>;
22
18
  declare function setCustomFeeData(customFeeData: {
23
19
  gasPrice?: number;
24
20
  maxFeePerGas?: number;
@@ -29,11 +25,7 @@ declare const curve: {
29
25
  chainId: number;
30
26
  signerAddress: string;
31
27
  setCustomFeeData: typeof setCustomFeeData;
32
- fetchFactoryPools: typeof fetchFactoryPools;
33
- fetchCryptoFactoryPools: typeof fetchCryptoFactoryPools;
34
28
  getPoolList: () => string[];
35
- getFactoryPoolList: () => string[];
36
- getCryptoFactoryPoolList: () => string[];
37
29
  getUserPoolListByLiquidity: (address?: string) => Promise<string[]>;
38
30
  getUserPoolListByClaimable: (address?: string) => Promise<string[]>;
39
31
  getUserPoolList: (address?: string, useApi?: boolean) => Promise<string[]>;
@@ -63,28 +55,34 @@ declare const curve: {
63
55
  cryptoShare: number;
64
56
  }>;
65
57
  factory: {
66
- deployPlainPool: (name: string, symbol: string, coins: string[], A: number, fee: number, assetType: 0 | 1 | 2 | 3, implementationIdx: 0 | 1 | 2 | 3) => Promise<ethers.ContractTransaction>;
67
- deployMetaPool: (basePool: string, name: string, symbol: string, coin: string, A: number, fee: number, implementationIdx: 0 | 1) => Promise<ethers.ContractTransaction>;
58
+ fetchPools: (useApi?: boolean) => Promise<void>;
59
+ fetchNewPools: () => Promise<string[]>;
60
+ getPoolList: () => string[];
61
+ deployPlainPool: (name: string, symbol: string, coins: string[], A: string | number, fee: string | number, assetType: 0 | 1 | 2 | 3, implementationIdx: 0 | 1 | 2 | 3) => Promise<ethers.ContractTransaction>;
62
+ deployMetaPool: (basePool: string, name: string, symbol: string, coin: string, A: string | number, fee: string | number, implementationIdx: 0 | 1) => Promise<ethers.ContractTransaction>;
68
63
  deployGauge: (poolAddress: string) => Promise<ethers.ContractTransaction>;
69
64
  getDeployedPlainPoolAddress: (tx: ethers.ContractTransaction) => Promise<string>;
70
65
  getDeployedMetaPoolAddress: (tx: ethers.ContractTransaction) => Promise<string>;
71
66
  getDeployedGaugeAddress: (tx: ethers.ContractTransaction) => Promise<string>;
72
- fetchRecentlyDeployedPool: typeof fetchRecentlyDeployedFactoryPool;
67
+ fetchRecentlyDeployedPool: (poolAddress: string) => Promise<string>;
73
68
  estimateGas: {
74
- deployPlainPool: (name: string, symbol: string, coins: string[], A: number, fee: number, assetType: 0 | 1 | 2 | 3, implementationIdx: 0 | 1 | 2 | 3) => Promise<number>;
75
- deployMetaPool: (basePool: string, name: string, symbol: string, coin: string, A: number, fee: number, implementationIdx: 0 | 1) => Promise<number>;
69
+ deployPlainPool: (name: string, symbol: string, coins: string[], A: string | number, fee: string | number, assetType: 0 | 1 | 2 | 3, implementationIdx: 0 | 1 | 2 | 3) => Promise<number>;
70
+ deployMetaPool: (basePool: string, name: string, symbol: string, coin: string, A: string | number, fee: string | number, implementationIdx: 0 | 1) => Promise<number>;
76
71
  deployGauge: (poolAddress: string) => Promise<number>;
77
72
  };
78
73
  };
79
74
  cryptoFactory: {
80
- deployPool: (name: string, symbol: string, coins: string[], A: number, gamma: number, midFee: number, outFee: number, allowedExtraProfit: number, feeGamma: number, adjustmentStep: number, maHalfTime: number, initialPrice: number) => Promise<ethers.ContractTransaction>;
75
+ fetchPools: (useApi?: boolean) => Promise<void>;
76
+ fetchNewPools: () => Promise<string[]>;
77
+ getPoolList: () => string[];
78
+ deployPool: (name: string, symbol: string, coins: string[], A: string | number, gamma: string | number, midFee: string | number, outFee: string | number, allowedExtraProfit: string | number, feeGamma: string | number, adjustmentStep: string | number, maHalfTime: string | number, initialPrice: string | number) => Promise<ethers.ContractTransaction>;
81
79
  deployGauge: (poolAddress: string) => Promise<ethers.ContractTransaction>;
82
80
  getDeployed: (tx: ethers.ContractTransaction) => Promise<string>;
83
81
  getDeployedPoolAddress: (tx: ethers.ContractTransaction) => Promise<string>;
84
82
  getDeployedGaugeAddress: (tx: ethers.ContractTransaction) => Promise<string>;
85
- fetchRecentlyDeployedPool: typeof fetchRecentlyDeployedCryptoFactoryPool;
83
+ fetchRecentlyDeployedPool: (poolAddress: string) => Promise<string>;
86
84
  estimateGas: {
87
- deployPool: (name: string, symbol: string, coins: string[], A: number, gamma: number, midFee: number, outFee: number, allowedExtraProfit: number, feeGamma: number, adjustmentStep: number, maHalfTime: number, initialPrice: number) => Promise<number>;
85
+ deployPool: (name: string, symbol: string, coins: string[], A: string | number, gamma: string | number, midFee: string | number, outFee: string | number, allowedExtraProfit: string | number, feeGamma: string | number, adjustmentStep: string | number, maHalfTime: string | number, initialPrice: string | number) => Promise<number>;
88
86
  deployGauge: (poolAddress: string) => Promise<number>;
89
87
  };
90
88
  };
package/lib/index.js CHANGED
@@ -60,52 +60,6 @@ function init(providerType, providerSettings, options) {
60
60
  });
61
61
  });
62
62
  }
63
- function fetchFactoryPools(useApi) {
64
- if (useApi === void 0) { useApi = true; }
65
- return __awaiter(this, void 0, void 0, function () {
66
- return __generator(this, function (_a) {
67
- switch (_a.label) {
68
- case 0: return [4 /*yield*/, curve_1.curve.fetchFactoryPools(useApi)];
69
- case 1:
70
- _a.sent();
71
- return [2 /*return*/];
72
- }
73
- });
74
- });
75
- }
76
- function fetchCryptoFactoryPools(useApi) {
77
- if (useApi === void 0) { useApi = true; }
78
- return __awaiter(this, void 0, void 0, function () {
79
- return __generator(this, function (_a) {
80
- switch (_a.label) {
81
- case 0: return [4 /*yield*/, curve_1.curve.fetchCryptoFactoryPools(useApi)];
82
- case 1:
83
- _a.sent();
84
- return [2 /*return*/];
85
- }
86
- });
87
- });
88
- }
89
- function fetchRecentlyDeployedFactoryPool(poolAddress) {
90
- return __awaiter(this, void 0, void 0, function () {
91
- return __generator(this, function (_a) {
92
- switch (_a.label) {
93
- case 0: return [4 /*yield*/, curve_1.curve.fetchRecentlyDeployedFactoryPool(poolAddress)];
94
- case 1: return [2 /*return*/, _a.sent()];
95
- }
96
- });
97
- });
98
- }
99
- function fetchRecentlyDeployedCryptoFactoryPool(poolAddress) {
100
- return __awaiter(this, void 0, void 0, function () {
101
- return __generator(this, function (_a) {
102
- switch (_a.label) {
103
- case 0: return [4 /*yield*/, curve_1.curve.fetchRecentlyDeployedCryptoFactoryPool(poolAddress)];
104
- case 1: return [2 /*return*/, _a.sent()];
105
- }
106
- });
107
- });
108
- }
109
63
  function setCustomFeeData(customFeeData) {
110
64
  curve_1.curve.setCustomFeeData(customFeeData);
111
65
  }
@@ -114,11 +68,7 @@ var curve = {
114
68
  chainId: 0,
115
69
  signerAddress: '',
116
70
  setCustomFeeData: setCustomFeeData,
117
- fetchFactoryPools: fetchFactoryPools,
118
- fetchCryptoFactoryPools: fetchCryptoFactoryPools,
119
- getPoolList: utils_1.getPoolList,
120
- getFactoryPoolList: utils_1.getFactoryPoolList,
121
- getCryptoFactoryPoolList: utils_1.getCryptoFactoryPoolList,
71
+ getPoolList: curve_1.curve.getPoolList,
122
72
  getUserPoolListByLiquidity: utils_1.getUserPoolListByLiquidity,
123
73
  getUserPoolListByClaimable: utils_1.getUserPoolListByClaimable,
124
74
  getUserPoolList: utils_1.getUserPoolList,
@@ -135,6 +85,9 @@ var curve = {
135
85
  getCoinsData: utils_2.getCoinsData,
136
86
  getVolume: utils_2.getVolume,
137
87
  factory: {
88
+ fetchPools: curve_1.curve.fetchFactoryPools,
89
+ fetchNewPools: curve_1.curve.fetchNewFactoryPools,
90
+ getPoolList: curve_1.curve.getFactoryPoolList,
138
91
  deployPlainPool: deploy_1.deployStablePlainPool,
139
92
  deployMetaPool: deploy_1.deployStableMetaPool,
140
93
  deployGauge: function (poolAddress) { return __awaiter(void 0, void 0, void 0, function () { return __generator(this, function (_a) {
@@ -143,7 +96,7 @@ var curve = {
143
96
  getDeployedPlainPoolAddress: deploy_1.getDeployedStablePlainPoolAddress,
144
97
  getDeployedMetaPoolAddress: deploy_1.getDeployedStableMetaPoolAddress,
145
98
  getDeployedGaugeAddress: deploy_1.getDeployedGaugeAddress,
146
- fetchRecentlyDeployedPool: fetchRecentlyDeployedFactoryPool,
99
+ fetchRecentlyDeployedPool: curve_1.curve.fetchRecentlyDeployedFactoryPool,
147
100
  estimateGas: {
148
101
  deployPlainPool: deploy_1.deployStablePlainPoolEstimateGas,
149
102
  deployMetaPool: deploy_1.deployStableMetaPoolEstimateGas,
@@ -153,6 +106,9 @@ var curve = {
153
106
  },
154
107
  },
155
108
  cryptoFactory: {
109
+ fetchPools: curve_1.curve.fetchCryptoFactoryPools,
110
+ fetchNewPools: curve_1.curve.fetchNewCryptoFactoryPools,
111
+ getPoolList: curve_1.curve.getCryptoFactoryPoolList,
156
112
  deployPool: deploy_1.deployCryptoPool,
157
113
  deployGauge: function (poolAddress) { return __awaiter(void 0, void 0, void 0, function () { return __generator(this, function (_a) {
158
114
  return [2 /*return*/, (0, deploy_1.deployGauge)(poolAddress, true)];
@@ -160,7 +116,7 @@ var curve = {
160
116
  getDeployed: deploy_1.getDeployedStablePlainPoolAddress,
161
117
  getDeployedPoolAddress: deploy_1.getDeployedCryptoPoolAddress,
162
118
  getDeployedGaugeAddress: deploy_1.getDeployedGaugeAddress,
163
- fetchRecentlyDeployedPool: fetchRecentlyDeployedCryptoFactoryPool,
119
+ fetchRecentlyDeployedPool: curve_1.curve.fetchRecentlyDeployedCryptoFactoryPool,
164
120
  estimateGas: {
165
121
  deployPool: deploy_1.deployCryptoPoolEstimateGas,
166
122
  deployGauge: function (poolAddress) { return __awaiter(void 0, void 0, void 0, function () { return __generator(this, function (_a) {
@@ -17,6 +17,7 @@ export interface IPoolData {
17
17
  deposit_address?: string;
18
18
  sCurveRewards_address?: string;
19
19
  reward_contract?: string;
20
+ implementation_address?: string;
20
21
  is_plain?: boolean;
21
22
  is_lending?: boolean;
22
23
  is_meta?: boolean;
@@ -35,6 +36,7 @@ export interface IPoolData {
35
36
  gauge_abi: any;
36
37
  deposit_abi?: any;
37
38
  sCurveRewards_abi?: any;
39
+ in_api?: boolean;
38
40
  }
39
41
  export interface ICurve {
40
42
  provider: ethers.providers.Web3Provider | ethers.providers.JsonRpcProvider;
@@ -27,6 +27,7 @@ export declare class PoolTemplate {
27
27
  underlyingDecimals: number[];
28
28
  wrappedDecimals: number[];
29
29
  useLending: boolean[];
30
+ inApi: boolean;
30
31
  estimateGas: {
31
32
  depositApprove: (amounts: (number | string)[]) => Promise<number>;
32
33
  deposit: (amounts: (number | string)[]) => Promise<number>;