@curvefi/api 1.20.1 → 1.22.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.
@@ -1,15 +1,4 @@
1
1
  "use strict";
2
- var __assign = (this && this.__assign) || function () {
3
- __assign = Object.assign || function(t) {
4
- for (var s, i = 1, n = arguments.length; i < n; i++) {
5
- s = arguments[i];
6
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
7
- t[p] = s[p];
8
- }
9
- return t;
10
- };
11
- return __assign.apply(this, arguments);
12
- };
13
2
  var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
14
3
  function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
15
4
  return new (P || (P = Promise))(function (resolve, reject) {
@@ -53,14 +42,14 @@ Object.defineProperty(exports, "__esModule", { value: true });
53
42
  exports.getCryptoFactoryPoolData = void 0;
54
43
  var ethers_1 = require("ethers");
55
44
  var ethcall_1 = require("ethcall");
56
- var ERC20_json_1 = __importDefault(require("./constants/abis/json/ERC20.json"));
57
- var factory_crypto_pool_2_json_1 = __importDefault(require("./constants/abis/json/factory-crypto/factory-crypto-pool-2.json"));
58
- var gauge_factory_json_1 = __importDefault(require("./constants/abis/json/gauge_factory.json"));
45
+ var ERC20_json_1 = __importDefault(require("../constants/abis/json/ERC20.json"));
46
+ var factory_crypto_pool_2_json_1 = __importDefault(require("../constants/abis/json/factory-crypto/factory-crypto-pool-2.json"));
47
+ var gauge_factory_json_1 = __importDefault(require("../constants/abis/json/gauge_factory.json"));
59
48
  var WETH_ADDRESS = "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2";
60
49
  var deepFlatten = function (arr) { return [].concat.apply([], arr.map(function (v) { return (Array.isArray(v) ? deepFlatten(v) : v); })); };
61
- function getCryptoFactorySwapAddresses() {
50
+ function getCryptoFactoryIdsAndSwapAddresses() {
62
51
  return __awaiter(this, void 0, void 0, function () {
63
- var factoryContract, factoryMulticallContract, poolCount, _a, _b, _c, calls, i, factorySwapAddresses, swapAddresses;
52
+ var factoryContract, factoryMulticallContract, poolCount, _a, _b, _c, calls, i, factories, swapAddresses;
64
53
  return __generator(this, function (_e) {
65
54
  switch (_e.label) {
66
55
  case 0:
@@ -77,10 +66,10 @@ function getCryptoFactorySwapAddresses() {
77
66
  }
78
67
  return [4 /*yield*/, this.multicallProvider.all(calls)];
79
68
  case 2:
80
- factorySwapAddresses = (_e.sent()).map(function (addr) { return addr.toLowerCase(); });
81
- swapAddresses = Object.values(__assign(__assign({}, this.constants.POOLS_DATA), this.constants.FACTORY_POOLS_DATA))
82
- .map(function (pool) { return pool.swap_address.toLowerCase(); });
83
- return [2 /*return*/, factorySwapAddresses.filter(function (addr) { return !swapAddresses.includes(addr); })];
69
+ factories = (_e.sent()).map(function (addr, i) { return ({ id: "factory-crypto-".concat(i), address: addr.toLowerCase() }); });
70
+ swapAddresses = Object.values(this.constants.POOLS_DATA).map(function (pool) { return pool.swap_address.toLowerCase(); });
71
+ factories = factories.filter(function (f) { return !swapAddresses.includes(f.address); });
72
+ return [2 /*return*/, [factories.map(function (f) { return f.id; }), factories.map(function (f) { return f.address; })]];
84
73
  }
85
74
  });
86
75
  });
@@ -150,32 +139,27 @@ function setCryptoFactoryGaugeContracts(factoryGaugeAddresses) {
150
139
  };
151
140
  });
152
141
  }
153
- function getCryptoFactoryPoolNames(factoryTokenAddresses) {
142
+ function getCryptoFactorySymbolsAndNames(factoryTokenAddresses) {
154
143
  return __awaiter(this, void 0, void 0, function () {
155
- var calls, _i, factoryTokenAddresses_1, addr, names, existingNames, i, n;
144
+ var calls, _i, factoryTokenAddresses_1, addr, res, symbols, names, i;
156
145
  return __generator(this, function (_a) {
157
146
  switch (_a.label) {
158
147
  case 0:
159
148
  calls = [];
160
149
  for (_i = 0, factoryTokenAddresses_1 = factoryTokenAddresses; _i < factoryTokenAddresses_1.length; _i++) {
161
150
  addr = factoryTokenAddresses_1[_i];
162
- calls.push(this.contracts[addr].multicallContract.symbol());
151
+ calls.push(this.contracts[addr].multicallContract.symbol(), this.contracts[addr].multicallContract.name());
163
152
  }
164
153
  return [4 /*yield*/, this.multicallProvider.all(calls)];
165
154
  case 1:
166
- names = (_a.sent()).map(function (name) { return name + "V2"; });
167
- existingNames = Object.keys(this.constants.POOLS_DATA);
168
- // rename duplications
169
- for (i = 0; i < names.length; i++) {
170
- if (names.indexOf(names[i]) !== i || existingNames.includes(names[i])) {
171
- n = 1;
172
- do {
173
- n++;
174
- } while (names.indexOf(names[i].slice(0, -4) + "-".concat(n) + "-fV2") !== -1 || existingNames.includes(names[i].slice(0, -4) + "-".concat(n) + "-fV2"));
175
- names[i] = names[i].slice(0, -4) + "-".concat(n) + "-fV2";
176
- }
155
+ res = _a.sent();
156
+ symbols = [];
157
+ names = [];
158
+ for (i = 0; i < factoryTokenAddresses.length; i++) {
159
+ symbols.push(res[2 * i]);
160
+ names.push(res[(2 * i) + 1]);
177
161
  }
178
- return [2 /*return*/, names];
162
+ return [2 /*return*/, [symbols, names]];
179
163
  }
180
164
  });
181
165
  });
@@ -255,6 +239,9 @@ function getCoinAddressNameDict(coinAddresses, existingCoinAddrNameDict) {
255
239
  if (addr in existingCoinAddrNameDict) {
256
240
  coinAddrNamesDict[addr] = existingCoinAddrNameDict[addr];
257
241
  }
242
+ else if (addr === "0x9f8f72aa9304c8b593d555f12ef6589cc3a579a2") {
243
+ coinAddrNamesDict[addr] = "MKR";
244
+ }
258
245
  else {
259
246
  newCoinAddresses.push(addr);
260
247
  }
@@ -309,46 +296,49 @@ function getCoinAddressDecimalsDict(coinAddresses, existingCoinAddressDecimalsDi
309
296
  }
310
297
  function getCryptoFactoryPoolData() {
311
298
  return __awaiter(this, void 0, void 0, function () {
312
- var swapAddresses, tokenAddresses, gaugeAddresses, poolNames, coinAddresses, underlyingCoinAddresses, existingCoinAddressNameDict, coinAddressNameDict, coinAddressDecimalsDict, CRYPTO_FACTORY_POOLS_DATA, i;
313
- var _a, _b;
314
- return __generator(this, function (_c) {
315
- switch (_c.label) {
316
- case 0: return [4 /*yield*/, getCryptoFactorySwapAddresses.call(this)];
299
+ var _a, poolIds, swapAddresses, tokenAddresses, gaugeAddresses, _b, poolSymbols, poolNames, coinAddresses, underlyingCoinAddresses, existingCoinAddressNameDict, coinAddressNameDict, coinAddressDecimalsDict, CRYPTO_FACTORY_POOLS_DATA, i;
300
+ var _c, _e;
301
+ return __generator(this, function (_f) {
302
+ switch (_f.label) {
303
+ case 0: return [4 /*yield*/, getCryptoFactoryIdsAndSwapAddresses.call(this)];
317
304
  case 1:
318
- swapAddresses = _c.sent();
305
+ _a = _f.sent(), poolIds = _a[0], swapAddresses = _a[1];
319
306
  setCryptoFactorySwapContracts.call(this, swapAddresses);
320
307
  return [4 /*yield*/, getCryptoFactoryTokenAddresses.call(this, swapAddresses)];
321
308
  case 2:
322
- tokenAddresses = _c.sent();
309
+ tokenAddresses = _f.sent();
323
310
  setCryptoFactoryTokenContracts.call(this, tokenAddresses);
324
- (_a = this.constants.LP_TOKENS).push.apply(_a, tokenAddresses); // TODO move to another place
311
+ (_c = this.constants.LP_TOKENS).push.apply(_c, tokenAddresses); // TODO move to another place
325
312
  return [4 /*yield*/, getCryptoFactoryGaugeAddresses.call(this, swapAddresses)];
326
313
  case 3:
327
- gaugeAddresses = _c.sent();
314
+ gaugeAddresses = _f.sent();
328
315
  setCryptoFactoryGaugeContracts.call(this, gaugeAddresses);
329
- (_b = this.constants.GAUGES).push.apply(_b, gaugeAddresses.filter(function (addr) { return addr !== ethers_1.ethers.constants.AddressZero; })); // TODO move to another place
330
- return [4 /*yield*/, getCryptoFactoryPoolNames.call(this, tokenAddresses)];
316
+ (_e = this.constants.GAUGES).push.apply(_e, gaugeAddresses.filter(function (addr) { return addr !== ethers_1.ethers.constants.AddressZero; })); // TODO move to another place
317
+ return [4 /*yield*/, getCryptoFactorySymbolsAndNames.call(this, tokenAddresses)];
331
318
  case 4:
332
- poolNames = _c.sent();
319
+ _b = _f.sent(), poolSymbols = _b[0], poolNames = _b[1];
333
320
  return [4 /*yield*/, getCryptoFactoryCoinAddresses.call(this, swapAddresses)];
334
321
  case 5:
335
- coinAddresses = _c.sent();
322
+ coinAddresses = _f.sent();
336
323
  setCryptoFactoryCoinsContracts.call(this, coinAddresses);
337
324
  return [4 /*yield*/, getCryptoFactoryUnderlyingCoinAddresses.call(this, coinAddresses)];
338
325
  case 6:
339
- underlyingCoinAddresses = _c.sent();
326
+ underlyingCoinAddresses = _f.sent();
340
327
  existingCoinAddressNameDict = getExistingCoinAddressNameDict.call(this);
341
328
  return [4 /*yield*/, getCoinAddressNameDict.call(this, coinAddresses, existingCoinAddressNameDict)];
342
329
  case 7:
343
- coinAddressNameDict = _c.sent();
330
+ coinAddressNameDict = _f.sent();
344
331
  coinAddressNameDict['0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee'] = 'ETH';
345
332
  return [4 /*yield*/, getCoinAddressDecimalsDict.call(this, coinAddresses, this.constants.DECIMALS_LOWER_CASE)];
346
333
  case 8:
347
- coinAddressDecimalsDict = _c.sent();
334
+ coinAddressDecimalsDict = _f.sent();
348
335
  coinAddressDecimalsDict['0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee'] = 18;
349
336
  CRYPTO_FACTORY_POOLS_DATA = {};
350
- for (i = 0; i < poolNames.length; i++) {
351
- CRYPTO_FACTORY_POOLS_DATA[poolNames[i]] = {
337
+ for (i = 0; i < poolIds.length; i++) {
338
+ CRYPTO_FACTORY_POOLS_DATA[poolIds[i]] = {
339
+ name: poolNames[i].split(": ")[1].trim(),
340
+ full_name: poolNames[i],
341
+ symbol: poolSymbols[i],
352
342
  reference_asset: "CRYPTO",
353
343
  N_COINS: coinAddresses[i].length,
354
344
  is_crypto: true,
@@ -363,7 +353,7 @@ function getCryptoFactoryPoolData() {
363
353
  gauge_address: gaugeAddresses[i],
364
354
  underlying_coin_addresses: underlyingCoinAddresses[i],
365
355
  coin_addresses: coinAddresses[i],
366
- swap_abi: factory_crypto_pool_2_json_1.default[i],
356
+ swap_abi: factory_crypto_pool_2_json_1.default,
367
357
  gauge_abi: gauge_factory_json_1.default,
368
358
  is_factory: true,
369
359
  is_crypto_factory: true,
@@ -0,0 +1,2 @@
1
+ import { DictInterface, PoolDataInterface, ICurve } from "../interfaces";
2
+ export declare function getFactoryPoolData(this: ICurve): Promise<DictInterface<PoolDataInterface>>;
@@ -51,30 +51,30 @@ Object.defineProperty(exports, "__esModule", { value: true });
51
51
  exports.getFactoryPoolData = void 0;
52
52
  var ethers_1 = require("ethers");
53
53
  var ethcall_1 = require("ethcall");
54
- var ERC20_json_1 = __importDefault(require("./constants/abis/json/ERC20.json"));
55
- var swap_json_1 = __importDefault(require("./constants/abis/json/factoryPools/swap.json"));
56
- var deposit_json_1 = __importDefault(require("./constants/abis/json/factoryPools/deposit.json"));
57
- var gauge_factory_json_1 = __importDefault(require("./constants/abis/json/gauge_factory.json"));
58
- var DepositZapMetaUsdPolygon_json_1 = __importDefault(require("./constants/abis/json/factory-v2/DepositZapMetaUsdPolygon.json"));
59
- var DepositZapMetaBtcPolygon_json_1 = __importDefault(require("./constants/abis/json/factory-v2/DepositZapMetaBtcPolygon.json"));
60
- var MetaUSD_json_1 = __importDefault(require("./constants/abis/json/factory-v2/MetaUSD.json"));
61
- var MetaUSDBalances_json_1 = __importDefault(require("./constants/abis/json/factory-v2/MetaUSDBalances.json"));
62
- var MetaBTC_json_1 = __importDefault(require("./constants/abis/json/factory-v2/MetaBTC.json"));
63
- var MetaBTCBalances_json_1 = __importDefault(require("./constants/abis/json/factory-v2/MetaBTCBalances.json"));
64
- var MetaBTCRen_json_1 = __importDefault(require("./constants/abis/json/factory-v2/MetaBTCRen.json"));
65
- var MetaBTCBalancesRen_json_1 = __importDefault(require("./constants/abis/json/factory-v2/MetaBTCBalancesRen.json"));
66
- var Plain2Basic_json_1 = __importDefault(require("./constants/abis/json/factory-v2/Plain2Basic.json"));
67
- var Plain2Balances_json_1 = __importDefault(require("./constants/abis/json/factory-v2/Plain2Balances.json"));
68
- var Plain2ETH_json_1 = __importDefault(require("./constants/abis/json/factory-v2/Plain2ETH.json"));
69
- var Plain2Optimized_json_1 = __importDefault(require("./constants/abis/json/factory-v2/Plain2Optimized.json"));
70
- var Plain3Basic_json_1 = __importDefault(require("./constants/abis/json/factory-v2/Plain3Basic.json"));
71
- var Plain3Balances_json_1 = __importDefault(require("./constants/abis/json/factory-v2/Plain3Balances.json"));
72
- var Plain3ETH_json_1 = __importDefault(require("./constants/abis/json/factory-v2/Plain3ETH.json"));
73
- var Plain3Optimized_json_1 = __importDefault(require("./constants/abis/json/factory-v2/Plain3Optimized.json"));
74
- var Plain4Basic_json_1 = __importDefault(require("./constants/abis/json/factory-v2/Plain4Basic.json"));
75
- var Plain4Balances_json_1 = __importDefault(require("./constants/abis/json/factory-v2/Plain4Balances.json"));
76
- var Plain4ETH_json_1 = __importDefault(require("./constants/abis/json/factory-v2/Plain4ETH.json"));
77
- var Plain4Optimized_json_1 = __importDefault(require("./constants/abis/json/factory-v2/Plain4Optimized.json"));
54
+ var ERC20_json_1 = __importDefault(require("../constants/abis/json/ERC20.json"));
55
+ var swap_json_1 = __importDefault(require("../constants/abis/json/factoryPools/swap.json"));
56
+ var deposit_json_1 = __importDefault(require("../constants/abis/json/factoryPools/deposit.json"));
57
+ var gauge_factory_json_1 = __importDefault(require("../constants/abis/json/gauge_factory.json"));
58
+ var DepositZapMetaUsdPolygon_json_1 = __importDefault(require("../constants/abis/json/factory-v2/DepositZapMetaUsdPolygon.json"));
59
+ var DepositZapMetaBtcPolygon_json_1 = __importDefault(require("../constants/abis/json/factory-v2/DepositZapMetaBtcPolygon.json"));
60
+ var MetaUSD_json_1 = __importDefault(require("../constants/abis/json/factory-v2/MetaUSD.json"));
61
+ var MetaUSDBalances_json_1 = __importDefault(require("../constants/abis/json/factory-v2/MetaUSDBalances.json"));
62
+ var MetaBTC_json_1 = __importDefault(require("../constants/abis/json/factory-v2/MetaBTC.json"));
63
+ var MetaBTCBalances_json_1 = __importDefault(require("../constants/abis/json/factory-v2/MetaBTCBalances.json"));
64
+ var MetaBTCRen_json_1 = __importDefault(require("../constants/abis/json/factory-v2/MetaBTCRen.json"));
65
+ var MetaBTCBalancesRen_json_1 = __importDefault(require("../constants/abis/json/factory-v2/MetaBTCBalancesRen.json"));
66
+ var Plain2Basic_json_1 = __importDefault(require("../constants/abis/json/factory-v2/Plain2Basic.json"));
67
+ var Plain2Balances_json_1 = __importDefault(require("../constants/abis/json/factory-v2/Plain2Balances.json"));
68
+ var Plain2ETH_json_1 = __importDefault(require("../constants/abis/json/factory-v2/Plain2ETH.json"));
69
+ var Plain2Optimized_json_1 = __importDefault(require("../constants/abis/json/factory-v2/Plain2Optimized.json"));
70
+ var Plain3Basic_json_1 = __importDefault(require("../constants/abis/json/factory-v2/Plain3Basic.json"));
71
+ var Plain3Balances_json_1 = __importDefault(require("../constants/abis/json/factory-v2/Plain3Balances.json"));
72
+ var Plain3ETH_json_1 = __importDefault(require("../constants/abis/json/factory-v2/Plain3ETH.json"));
73
+ var Plain3Optimized_json_1 = __importDefault(require("../constants/abis/json/factory-v2/Plain3Optimized.json"));
74
+ var Plain4Basic_json_1 = __importDefault(require("../constants/abis/json/factory-v2/Plain4Basic.json"));
75
+ var Plain4Balances_json_1 = __importDefault(require("../constants/abis/json/factory-v2/Plain4Balances.json"));
76
+ var Plain4ETH_json_1 = __importDefault(require("../constants/abis/json/factory-v2/Plain4ETH.json"));
77
+ var Plain4Optimized_json_1 = __importDefault(require("../constants/abis/json/factory-v2/Plain4Optimized.json"));
78
78
  var implementationABIDictEthereum = {
79
79
  "0x5F890841f657d90E081bAbdB532A05996Af79Fe6": swap_json_1.default,
80
80
  "0x213be373FDff327658139C7df330817DAD2d5bBE": MetaUSD_json_1.default,
@@ -184,9 +184,9 @@ var blackListPolygon = [
184
184
  ];
185
185
  var blackListEthereum = [];
186
186
  var deepFlatten = function (arr) { return [].concat.apply([], arr.map(function (v) { return (Array.isArray(v) ? deepFlatten(v) : v); })); };
187
- function getFactorySwapAddresses() {
187
+ function getFactoryIdsAndSwapAddresses() {
188
188
  return __awaiter(this, void 0, void 0, function () {
189
- var factoryContract, factoryMulticallContract, poolCount, _a, _b, _c, calls, i, factorySwapAddresses, swapAddresses, blacklist;
189
+ var factoryContract, factoryMulticallContract, poolCount, _a, _b, _c, calls, i, factories, swapAddresses, blacklist;
190
190
  return __generator(this, function (_e) {
191
191
  switch (_e.label) {
192
192
  case 0:
@@ -203,10 +203,11 @@ function getFactorySwapAddresses() {
203
203
  }
204
204
  return [4 /*yield*/, this.multicallProvider.all(calls)];
205
205
  case 2:
206
- factorySwapAddresses = (_e.sent()).map(function (addr) { return addr.toLowerCase(); });
206
+ factories = (_e.sent()).map(function (addr, i) { return ({ id: "factory-v2-".concat(i), address: addr.toLowerCase() }); });
207
207
  swapAddresses = Object.values(this.constants.POOLS_DATA).map(function (pool) { return pool.swap_address.toLowerCase(); });
208
208
  blacklist = this.chainId === 137 ? blackListPolygon : blackListEthereum;
209
- return [2 /*return*/, factorySwapAddresses.filter(function (addr) { return !swapAddresses.includes(addr) && !blacklist.includes(addr); })];
209
+ factories = factories.filter(function (f) { return !swapAddresses.includes(f.address) && !blacklist.includes(f.address); });
210
+ return [2 /*return*/, [factories.map(function (f) { return f.id; }), factories.map(function (f) { return f.address; })]];
210
211
  }
211
212
  });
212
213
  });
@@ -271,32 +272,27 @@ function setFactoryGaugeContracts(factoryGaugeAddresses) {
271
272
  };
272
273
  });
273
274
  }
274
- function getFactoryPoolNames(factorySwapAddresses) {
275
+ function getFactorySymbolsAndNames(factorySwapAddresses) {
275
276
  return __awaiter(this, void 0, void 0, function () {
276
- var calls, _i, factorySwapAddresses_3, addr, names, existingNames, i, n;
277
+ var calls, _i, factorySwapAddresses_3, addr, res, symbols, names, i;
277
278
  return __generator(this, function (_a) {
278
279
  switch (_a.label) {
279
280
  case 0:
280
281
  calls = [];
281
282
  for (_i = 0, factorySwapAddresses_3 = factorySwapAddresses; _i < factorySwapAddresses_3.length; _i++) {
282
283
  addr = factorySwapAddresses_3[_i];
283
- calls.push(this.contracts[addr].multicallContract.symbol());
284
+ calls.push(this.contracts[addr].multicallContract.symbol(), this.contracts[addr].multicallContract.name());
284
285
  }
285
286
  return [4 /*yield*/, this.multicallProvider.all(calls)];
286
287
  case 1:
287
- names = _a.sent();
288
- existingNames = Object.keys(this.constants.POOLS_DATA);
289
- // rename duplications
290
- for (i = 0; i < names.length; i++) {
291
- if (names.indexOf(names[i]) !== i || existingNames.includes(names[i])) {
292
- n = 1;
293
- do {
294
- n++;
295
- } while (names.indexOf(names[i].slice(0, -2) + "-".concat(n) + "-f") !== -1 || existingNames.includes(names[i].slice(0, -2) + "-".concat(n) + "-f"));
296
- names[i] = names[i].slice(0, -2) + "-".concat(n) + "-f";
297
- }
288
+ res = _a.sent();
289
+ symbols = [];
290
+ names = [];
291
+ for (i = 0; i < factorySwapAddresses.length; i++) {
292
+ symbols.push(res[2 * i]);
293
+ names.push(res[(2 * i) + 1]);
298
294
  }
299
- return [2 /*return*/, names];
295
+ return [2 /*return*/, [symbols, names]];
300
296
  }
301
297
  });
302
298
  });
@@ -509,46 +505,46 @@ function setFactoryZapContracts() {
509
505
  }
510
506
  function getFactoryPoolData() {
511
507
  return __awaiter(this, void 0, void 0, function () {
512
- var swapAddresses, swapABIs, gaugeAddresses, poolNames, referenceAssets, coinAddresses, existingCoinAddressNameDict, coinAddressNameDict, coinAddressDecimalsDict, isMeta, basePoolAddresses, basePoolAddressCoinsDict, basePoolAddressNameDict, basePoolAddressCoinAddressesDict, basePoolAddressDecimalsDict, basePoolAddressZapDict, FACTORY_POOLS_DATA, i;
513
- var _a, _b;
514
- return __generator(this, function (_c) {
515
- switch (_c.label) {
516
- case 0: return [4 /*yield*/, getFactorySwapAddresses.call(this)];
508
+ var _a, poolIds, swapAddresses, swapABIs, gaugeAddresses, _b, poolSymbols, poolNames, referenceAssets, coinAddresses, existingCoinAddressNameDict, coinAddressNameDict, coinAddressDecimalsDict, isMeta, basePoolAddresses, basePoolAddressCoinsDict, basePoolAddressNameDict, basePoolAddressCoinAddressesDict, basePoolAddressDecimalsDict, basePoolAddressZapDict, FACTORY_POOLS_DATA, i;
509
+ var _c, _e;
510
+ return __generator(this, function (_f) {
511
+ switch (_f.label) {
512
+ case 0: return [4 /*yield*/, getFactoryIdsAndSwapAddresses.call(this)];
517
513
  case 1:
518
- swapAddresses = _c.sent();
514
+ _a = _f.sent(), poolIds = _a[0], swapAddresses = _a[1];
519
515
  return [4 /*yield*/, getFactorySwapABIs.call(this, swapAddresses)];
520
516
  case 2:
521
- swapABIs = _c.sent();
517
+ swapABIs = _f.sent();
522
518
  setFactorySwapContracts.call(this, swapAddresses, swapABIs);
523
- (_a = this.constants.LP_TOKENS).push.apply(_a, swapAddresses); // TODO move to another place
519
+ (_c = this.constants.LP_TOKENS).push.apply(_c, swapAddresses); // TODO move to another place
524
520
  return [4 /*yield*/, getFactoryGaugeAddresses.call(this, swapAddresses)];
525
521
  case 3:
526
- gaugeAddresses = _c.sent();
522
+ gaugeAddresses = _f.sent();
527
523
  setFactoryGaugeContracts.call(this, gaugeAddresses);
528
- (_b = this.constants.GAUGES).push.apply(_b, gaugeAddresses.filter(function (addr) { return addr !== ethers_1.ethers.constants.AddressZero; })); // TODO move to another place
529
- return [4 /*yield*/, getFactoryPoolNames.call(this, swapAddresses)];
524
+ (_e = this.constants.GAUGES).push.apply(_e, gaugeAddresses.filter(function (addr) { return addr !== ethers_1.ethers.constants.AddressZero; })); // TODO move to another place
525
+ return [4 /*yield*/, getFactorySymbolsAndNames.call(this, swapAddresses)];
530
526
  case 4:
531
- poolNames = _c.sent();
527
+ _b = _f.sent(), poolSymbols = _b[0], poolNames = _b[1];
532
528
  return [4 /*yield*/, getFactoryReferenceAssets.call(this, swapAddresses)];
533
529
  case 5:
534
- referenceAssets = _c.sent();
530
+ referenceAssets = _f.sent();
535
531
  return [4 /*yield*/, getFactoryCoinAddresses.call(this, swapAddresses)];
536
532
  case 6:
537
- coinAddresses = _c.sent();
533
+ coinAddresses = _f.sent();
538
534
  setFactoryCoinsContracts.call(this, coinAddresses);
539
535
  existingCoinAddressNameDict = getExistingCoinAddressNameDict.call(this);
540
536
  return [4 /*yield*/, getCoinAddressNameDict.call(this, coinAddresses, existingCoinAddressNameDict)];
541
537
  case 7:
542
- coinAddressNameDict = _c.sent();
538
+ coinAddressNameDict = _f.sent();
543
539
  return [4 /*yield*/, getCoinAddressDecimalsDict.call(this, coinAddresses, this.constants.DECIMALS_LOWER_CASE)];
544
540
  case 8:
545
- coinAddressDecimalsDict = _c.sent();
541
+ coinAddressDecimalsDict = _f.sent();
546
542
  return [4 /*yield*/, getFactoryIsMeta.call(this, swapAddresses)];
547
543
  case 9:
548
- isMeta = _c.sent();
544
+ isMeta = _f.sent();
549
545
  return [4 /*yield*/, getFactoryBasePoolAddresses.call(this, swapAddresses)];
550
546
  case 10:
551
- basePoolAddresses = _c.sent();
547
+ basePoolAddresses = _f.sent();
552
548
  setFactoryZapContracts.call(this);
553
549
  basePoolAddressCoinsDict = this.chainId === 137 ? basePoolAddressCoinsDictPolygon : basePoolAddressCoinsDictEthereum;
554
550
  basePoolAddressNameDict = this.chainId === 137 ? basePoolAddressNameDictPolygon : basePoolAddressNameDictEthereum;
@@ -556,9 +552,12 @@ function getFactoryPoolData() {
556
552
  basePoolAddressDecimalsDict = this.chainId === 137 ? basePoolAddressDecimalsDictPolygon : basePoolAddressDecimalsDictEthereum;
557
553
  basePoolAddressZapDict = this.chainId === 137 ? basePoolAddressZapDictPolygon : basePoolAddressZapDictEthereum;
558
554
  FACTORY_POOLS_DATA = {};
559
- for (i = 0; i < poolNames.length; i++) {
555
+ for (i = 0; i < poolIds.length; i++) {
560
556
  if (!isMeta[i]) {
561
- FACTORY_POOLS_DATA[poolNames[i]] = {
557
+ FACTORY_POOLS_DATA[poolIds[i]] = {
558
+ name: poolNames[i].split(": ")[1].trim(),
559
+ full_name: poolNames[i],
560
+ symbol: poolSymbols[i],
562
561
  reference_asset: referenceAssets[i],
563
562
  N_COINS: coinAddresses[i].length,
564
563
  underlying_decimals: coinAddresses[i].map(function (addr) { return coinAddressDecimalsDict[addr]; }),
@@ -579,7 +578,10 @@ function getFactoryPoolData() {
579
578
  };
580
579
  }
581
580
  else {
582
- FACTORY_POOLS_DATA[poolNames[i]] = {
581
+ FACTORY_POOLS_DATA[poolIds[i]] = {
582
+ name: poolNames[i].split(": ")[1].trim(),
583
+ full_name: poolNames[i],
584
+ symbol: poolSymbols[i],
583
585
  reference_asset: referenceAssets[i],
584
586
  N_COINS: coinAddresses[i].length,
585
587
  underlying_decimals: coinAddresses[i].map(function (addr) { return coinAddressDecimalsDict[addr]; }),
package/lib/index.d.ts CHANGED
@@ -15,8 +15,8 @@ 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(): Promise<void>;
19
- declare function fetchCryptoFactoryPools(): Promise<void>;
18
+ declare function fetchFactoryPools(useApi?: boolean): Promise<void>;
19
+ declare function fetchCryptoFactoryPools(useApi?: boolean): Promise<void>;
20
20
  declare function setCustomFeeData(customFeeData: {
21
21
  gasPrice?: number;
22
22
  maxFeePerGas?: number;
@@ -30,6 +30,7 @@ declare const curve: {
30
30
  getFactoryPoolList: () => string[];
31
31
  getCryptoFactoryPoolList: () => string[];
32
32
  getUsdRate: (coin: string) => Promise<number>;
33
+ getTVL: (chainId?: number) => Promise<number>;
33
34
  setCustomFeeData: typeof setCustomFeeData;
34
35
  signerAddress: string;
35
36
  chainId: number;
@@ -56,6 +57,7 @@ declare const curve: {
56
57
  crossAssetExchangeIsApproved: (inputCoin: string, amount: string) => Promise<boolean>;
57
58
  crossAssetExchangeApprove: (inputCoin: string, amount: string) => Promise<string[]>;
58
59
  crossAssetExchange: (inputCoin: string, outputCoin: string, amount: string, maxSlippage?: number) => Promise<string>;
60
+ getUserPoolList: (address?: string | undefined) => Promise<string[]>;
59
61
  estimateGas: {
60
62
  ensureAllowance: (coins: string[], amounts: string[], spender: string) => Promise<number>;
61
63
  exchangeApprove: (inputCoin: string, outputCoin: string, amount: string) => Promise<number>;
package/lib/index.js CHANGED
@@ -57,11 +57,12 @@ function init(providerType, providerSettings, options) {
57
57
  });
58
58
  });
59
59
  }
60
- function fetchFactoryPools() {
60
+ function fetchFactoryPools(useApi) {
61
+ if (useApi === void 0) { useApi = true; }
61
62
  return __awaiter(this, void 0, void 0, function () {
62
63
  return __generator(this, function (_a) {
63
64
  switch (_a.label) {
64
- case 0: return [4 /*yield*/, curve_1.curve.fetchFactoryPools()];
65
+ case 0: return [4 /*yield*/, curve_1.curve.fetchFactoryPools(useApi)];
65
66
  case 1:
66
67
  _a.sent();
67
68
  return [2 /*return*/];
@@ -69,11 +70,12 @@ function fetchFactoryPools() {
69
70
  });
70
71
  });
71
72
  }
72
- function fetchCryptoFactoryPools() {
73
+ function fetchCryptoFactoryPools(useApi) {
74
+ if (useApi === void 0) { useApi = true; }
73
75
  return __awaiter(this, void 0, void 0, function () {
74
76
  return __generator(this, function (_a) {
75
77
  switch (_a.label) {
76
- case 0: return [4 /*yield*/, curve_1.curve.fetchCryptoFactoryPools()];
78
+ case 0: return [4 /*yield*/, curve_1.curve.fetchCryptoFactoryPools(useApi)];
77
79
  case 1:
78
80
  _a.sent();
79
81
  return [2 /*return*/];
@@ -92,6 +94,7 @@ var curve = {
92
94
  getFactoryPoolList: utils_1.getFactoryPoolList,
93
95
  getCryptoFactoryPoolList: utils_1.getCryptoFactoryPoolList,
94
96
  getUsdRate: utils_1.getUsdRate,
97
+ getTVL: utils_1.getTVL,
95
98
  setCustomFeeData: setCustomFeeData,
96
99
  signerAddress: '',
97
100
  chainId: 0,
@@ -111,6 +114,7 @@ var curve = {
111
114
  crossAssetExchangeIsApproved: pools_1.crossAssetExchangeIsApproved,
112
115
  crossAssetExchangeApprove: pools_1.crossAssetExchangeApprove,
113
116
  crossAssetExchange: pools_1.crossAssetExchange,
117
+ getUserPoolList: pools_1.getUserPoolList,
114
118
  estimateGas: {
115
119
  ensureAllowance: utils_1.ensureAllowanceEstimateGas,
116
120
  exchangeApprove: pools_1.exchangeApproveEstimateGas,
@@ -1,9 +1,41 @@
1
- import { ethers } from "ethers";
1
+ import { Contract, ethers } from "ethers";
2
+ import { Contract as MulticallContract, Provider as MulticallProvider } from "ethcall";
2
3
  export interface DictInterface<T> {
3
4
  [index: string]: T;
4
5
  }
6
+ export interface ICurve {
7
+ provider: ethers.providers.Web3Provider | ethers.providers.JsonRpcProvider;
8
+ multicallProvider: MulticallProvider;
9
+ signer: ethers.Signer | null;
10
+ signerAddress: string;
11
+ chainId: number;
12
+ contracts: {
13
+ [index: string]: {
14
+ contract: Contract;
15
+ multicallContract: MulticallContract;
16
+ };
17
+ };
18
+ feeData: {
19
+ gasPrice?: number;
20
+ maxFeePerGas?: number;
21
+ maxPriorityFeePerGas?: number;
22
+ };
23
+ constantOptions: {
24
+ gasLimit: number;
25
+ };
26
+ options: {
27
+ gasPrice?: number | ethers.BigNumber;
28
+ maxFeePerGas?: number | ethers.BigNumber;
29
+ maxPriorityFeePerGas?: number | ethers.BigNumber;
30
+ };
31
+ constants: DictInterface<any>;
32
+ }
33
+ export declare type REFERENCE_ASSET = 'USD' | 'EUR' | 'BTC' | 'ETH' | 'LINK' | 'CRYPTO' | 'OTHER';
5
34
  export interface PoolDataInterface {
6
- reference_asset: 'USD' | 'EUR' | 'BTC' | 'ETH' | 'LINK' | 'CRYPTO' | 'OTHER';
35
+ name: string;
36
+ full_name: string;
37
+ symbol: string;
38
+ reference_asset: REFERENCE_ASSET;
7
39
  N_COINS: number;
8
40
  underlying_decimals: number[];
9
41
  decimals: number[];
@@ -56,6 +88,30 @@ export interface PoolDataInterface {
56
88
  pool_type?: string;
57
89
  reward_contract?: string;
58
90
  }
91
+ export interface ICoinFromPoolDataApi {
92
+ address: string;
93
+ symbol: string;
94
+ decimals: string;
95
+ usdPrice: number | string;
96
+ }
97
+ export interface IPoolDataFromApi {
98
+ id: string;
99
+ name: string;
100
+ symbol: string;
101
+ assetTypeName: string;
102
+ address: string;
103
+ lpTokenAddress?: string;
104
+ gaugeAddress?: string;
105
+ implementation: string;
106
+ implementationAddress: string;
107
+ coins: ICoinFromPoolDataApi[];
108
+ usdTotal: number;
109
+ }
110
+ export interface IExtendedPoolDataFromApi {
111
+ poolData: IPoolDataFromApi[];
112
+ tvl?: number;
113
+ tvlAll: number;
114
+ }
59
115
  export interface RewardsApyInterface {
60
116
  token: string;
61
117
  symbol: string;
package/lib/pools.d.ts CHANGED
@@ -2,7 +2,10 @@ import { ethers } from "ethers";
2
2
  import BigNumber from 'bignumber.js';
3
3
  import { DictInterface, RewardsApyInterface } from './interfaces';
4
4
  export declare class Pool {
5
+ id: string;
5
6
  name: string;
7
+ fullName: string;
8
+ symbol: string;
6
9
  referenceAsset: string;
7
10
  swap: string;
8
11
  zap: string | null;
@@ -61,7 +64,7 @@ export declare class Pool {
61
64
  }>;
62
65
  getPoolBalances: () => Promise<string[]>;
63
66
  getPoolWrappedBalances: () => Promise<string[]>;
64
- getTotalLiquidity: () => Promise<string>;
67
+ getTotalLiquidity: (useApi?: boolean) => Promise<string>;
65
68
  getVolume: () => Promise<string>;
66
69
  getBaseApy: () => Promise<{
67
70
  day: string;
@@ -72,7 +75,7 @@ export declare class Pool {
72
75
  getTokenApy: () => Promise<[baseApy: string, boostedApy: string]>;
73
76
  getRewardsApy: () => Promise<RewardsApyInterface[]>;
74
77
  };
75
- constructor(name: string);
78
+ constructor(id: string);
76
79
  calcLpTokenAmount: (amounts: string[], isDeposit?: boolean) => Promise<string>;
77
80
  calcLpTokenAmountWrapped: (amounts: string[], isDeposit?: boolean) => Promise<string>;
78
81
  private getParameters;
@@ -250,3 +253,4 @@ export declare const crossAssetExchangeApproveEstimateGas: (inputCoin: string, a
250
253
  export declare const crossAssetExchangeApprove: (inputCoin: string, amount: string) => Promise<string[]>;
251
254
  export declare const crossAssetExchangeEstimateGas: (inputCoin: string, outputCoin: string, amount: string, maxSlippage?: number) => Promise<number>;
252
255
  export declare const crossAssetExchange: (inputCoin: string, outputCoin: string, amount: string, maxSlippage?: number) => Promise<string>;
256
+ export declare const getUserPoolList: (address?: string | undefined) => Promise<string[]>;