@curvefi/api 2.12.1 → 2.13.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.
@@ -0,0 +1,86 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.CRYPTO_FACTORY_CONSTANTS = exports.basePoolIdZapDictKava = exports.basePoolIdZapDictMoonbeam = exports.basePoolIdZapDictXDai = exports.basePoolIdZapDictOptimism = exports.basePoolIdZapDictArbitrum = exports.basePoolIdZapDictAvalanche = exports.basePoolIdZapDictFantom = exports.basePoolIdZapDictPolygon = exports.basePoolIdZapDictEthereum = exports.lpTokenBasePoolIdDictKava = exports.lpTokenBasePoolIdDictMoonbeam = exports.lpTokenBasePoolIdDictXDai = exports.lpTokenBasePoolIdDictOptimism = exports.lpTokenBasePoolIdDictArbitrum = exports.lpTokenBasePoolIdDictAvalanche = exports.lpTokenBasePoolIdDictFantom = exports.lpTokenBasePoolIdDictPolygon = exports.lpTokenBasePoolIdDictEthereum = void 0;
7
+ var utils_1 = require("../constants/utils");
8
+ // --- ZAPS --
9
+ var base_pool_zap_json_1 = __importDefault(require("../constants/abis/atricrypto3/base_pool_zap.json"));
10
+ var meta_zap_crypto_json_1 = __importDefault(require("../constants/abis/3pool/meta_zap_crypto.json"));
11
+ var meta_zap_crypto_json_2 = __importDefault(require("../constants/abis/fraxusdc/meta_zap_crypto.json"));
12
+ exports.lpTokenBasePoolIdDictEthereum = (0, utils_1.lowerCaseKeys)({
13
+ '0x6c3F90f043a72FA612cbac8115EE7e52BDe6E490': '3pool',
14
+ '0x3175Df0976dFA876431C2E9eE6Bc45b65d3473CC': 'fraxusdc',
15
+ });
16
+ exports.lpTokenBasePoolIdDictPolygon = (0, utils_1.lowerCaseKeys)({
17
+ '0xdAD97F7713Ae9437fa9249920eC8507e5FbB23d3': 'atricrypto3',
18
+ });
19
+ exports.lpTokenBasePoolIdDictFantom = (0, utils_1.lowerCaseKeys)({});
20
+ exports.lpTokenBasePoolIdDictAvalanche = (0, utils_1.lowerCaseKeys)({});
21
+ exports.lpTokenBasePoolIdDictArbitrum = (0, utils_1.lowerCaseKeys)({});
22
+ exports.lpTokenBasePoolIdDictOptimism = (0, utils_1.lowerCaseKeys)({});
23
+ exports.lpTokenBasePoolIdDictXDai = (0, utils_1.lowerCaseKeys)({});
24
+ exports.lpTokenBasePoolIdDictMoonbeam = (0, utils_1.lowerCaseKeys)({});
25
+ exports.lpTokenBasePoolIdDictKava = (0, utils_1.lowerCaseKeys)({});
26
+ exports.basePoolIdZapDictEthereum = {
27
+ '3pool': {
28
+ address: "0x97aDC08FA1D849D2C48C5dcC1DaB568B169b0267".toLowerCase(),
29
+ ABI: meta_zap_crypto_json_1.default,
30
+ },
31
+ fraxusdc: {
32
+ address: "0x5de4ef4879f4fe3bbadf2227d2ac5d0e2d76c895".toLowerCase(),
33
+ ABI: meta_zap_crypto_json_2.default,
34
+ },
35
+ };
36
+ exports.basePoolIdZapDictPolygon = {
37
+ atricrypto3: {
38
+ address: "0x3d8EADb739D1Ef95dd53D718e4810721837c69c1".toLowerCase(),
39
+ ABI: base_pool_zap_json_1.default,
40
+ },
41
+ };
42
+ exports.basePoolIdZapDictFantom = {};
43
+ exports.basePoolIdZapDictAvalanche = {};
44
+ exports.basePoolIdZapDictArbitrum = {};
45
+ exports.basePoolIdZapDictOptimism = {};
46
+ exports.basePoolIdZapDictXDai = {};
47
+ exports.basePoolIdZapDictMoonbeam = {};
48
+ exports.basePoolIdZapDictKava = {};
49
+ exports.CRYPTO_FACTORY_CONSTANTS = {
50
+ 1: {
51
+ lpTokenBasePoolIdDict: exports.lpTokenBasePoolIdDictEthereum,
52
+ basePoolIdZapDict: exports.basePoolIdZapDictEthereum,
53
+ },
54
+ 10: {
55
+ lpTokenBasePoolIdDict: exports.lpTokenBasePoolIdDictOptimism,
56
+ basePoolIdZapDict: exports.basePoolIdZapDictOptimism,
57
+ },
58
+ 100: {
59
+ lpTokenBasePoolIdDict: exports.lpTokenBasePoolIdDictXDai,
60
+ basePoolIdZapDict: exports.basePoolIdZapDictXDai,
61
+ },
62
+ 137: {
63
+ lpTokenBasePoolIdDict: exports.lpTokenBasePoolIdDictPolygon,
64
+ basePoolIdZapDict: exports.basePoolIdZapDictPolygon,
65
+ },
66
+ 250: {
67
+ lpTokenBasePoolIdDict: exports.lpTokenBasePoolIdDictFantom,
68
+ basePoolIdZapDict: exports.basePoolIdZapDictFantom,
69
+ },
70
+ 1284: {
71
+ lpTokenBasePoolIdDict: exports.lpTokenBasePoolIdDictMoonbeam,
72
+ basePoolIdZapDict: exports.basePoolIdZapDictMoonbeam,
73
+ },
74
+ 2222: {
75
+ lpTokenBasePoolIdDict: exports.lpTokenBasePoolIdDictKava,
76
+ basePoolIdZapDict: exports.basePoolIdZapDictKava,
77
+ },
78
+ 43114: {
79
+ lpTokenBasePoolIdDict: exports.lpTokenBasePoolIdDictAvalanche,
80
+ basePoolIdZapDict: exports.basePoolIdZapDictAvalanche,
81
+ },
82
+ 42161: {
83
+ lpTokenBasePoolIdDict: exports.lpTokenBasePoolIdDictArbitrum,
84
+ basePoolIdZapDict: exports.basePoolIdZapDictArbitrum,
85
+ },
86
+ };
@@ -28,7 +28,7 @@ var Plain4ETH_json_1 = __importDefault(require("../constants/abis/factory-v2/Pla
28
28
  var Plain4Optimized_json_1 = __importDefault(require("../constants/abis/factory-v2/Plain4Optimized.json"));
29
29
  // --- ZAPS --
30
30
  var deposit_json_1 = __importDefault(require("../constants/abis/factoryPools/deposit.json"));
31
- var metaZap_json_1 = __importDefault(require("../constants/abis/fraxusdc/metaZap.json"));
31
+ var meta_zap_json_1 = __importDefault(require("../constants/abis/fraxusdc/meta_zap.json"));
32
32
  var DepositZapMetaUsdPolygon_json_1 = __importDefault(require("../constants/abis/factory-v2/DepositZapMetaUsdPolygon.json"));
33
33
  var DepositZapMetaBtcPolygon_json_1 = __importDefault(require("../constants/abis/factory-v2/DepositZapMetaBtcPolygon.json"));
34
34
  var DepositZapFantom_json_1 = __importDefault(require("../constants/abis/factory-v2/DepositZapFantom.json"));
@@ -253,7 +253,7 @@ exports.basePoolIdZapDictEthereum = {
253
253
  },
254
254
  fraxusdc: {
255
255
  address: "0x08780fb7E580e492c1935bEe4fA5920b94AA95Da".toLowerCase(),
256
- ABI: metaZap_json_1.default,
256
+ ABI: meta_zap_json_1.default,
257
257
  },
258
258
  sbtc: {
259
259
  address: "0x7abdbaf29929e7f8621b757d2a7c04d78d633834".toLowerCase(),
@@ -66,11 +66,10 @@ var ethcall_1 = require("ethcall");
66
66
  var gauge_factory_json_1 = __importDefault(require("../constants/abis/gauge_factory.json"));
67
67
  var gauge_child_json_1 = __importDefault(require("../constants/abis/gauge_child.json"));
68
68
  var gauge_rewards_only_json_1 = __importDefault(require("../constants/abis/gauge_rewards_only.json"));
69
- var deposit_json_1 = __importDefault(require("../constants/abis/factoryPools/deposit.json"));
70
69
  var ERC20_json_1 = __importDefault(require("../constants/abis/ERC20.json"));
71
70
  var factory_crypto_pool_2_json_1 = __importDefault(require("../constants/abis/factory-crypto/factory-crypto-pool-2.json"));
72
- var base_pool_zap_json_1 = __importDefault(require("../constants/abis/atricrypto3/base_pool_zap.json"));
73
71
  var constants_1 = require("./constants");
72
+ var constants_crypto_1 = require("./constants-crypto");
74
73
  var common_1 = require("./common");
75
74
  function setFactorySwapContracts(rawPoolList, isCrypto) {
76
75
  var _this = this;
@@ -147,7 +146,6 @@ function setFactoryRewardCoinsContracts(rawPoolList) {
147
146
  }
148
147
  }
149
148
  }
150
- var atricrypto3Lp = "0xdAD97F7713Ae9437fa9249920eC8507e5FbB23d3".toLowerCase();
151
149
  function getFactoryPoolsDataFromApi(isCrypto) {
152
150
  return __awaiter(this, void 0, void 0, function () {
153
151
  var network, factoryType, url, response, rawPoolList, mainAddresses, url_1, response_1, poolGaugeDict, _i, _a, gaugeData, i, FACTORY_POOLS_DATA;
@@ -185,10 +183,7 @@ function getFactoryPoolsDataFromApi(isCrypto) {
185
183
  setFactoryGaugeContracts.call(this, rawPoolList);
186
184
  setFactoryCoinsContracts.call(this, rawPoolList);
187
185
  setFactoryRewardCoinsContracts.call(this, rawPoolList);
188
- if (!isCrypto)
189
- common_1.setFactoryZapContracts.call(this);
190
- if (isCrypto)
191
- common_1.setCryptoFactoryZapContracts.call(this);
186
+ common_1.setFactoryZapContracts.call(this, isCrypto);
192
187
  FACTORY_POOLS_DATA = {};
193
188
  rawPoolList.forEach(function (pool) {
194
189
  var coinAddresses = pool.coins.map(function (c) { return c.address.toLowerCase(); });
@@ -196,23 +191,19 @@ function getFactoryPoolsDataFromApi(isCrypto) {
196
191
  var coinDecimals = pool.coins.map(function (c) { return Number(c.decimals); });
197
192
  var nativeToken = _this.constants.NATIVE_TOKEN;
198
193
  if (isCrypto) {
199
- var cryptoCoinNames = pool.coins.map(function (c) { return c.symbol === nativeToken.symbol ? nativeToken.wrappedSymbol : c.symbol; });
194
+ var wrappedCoinNames = pool.coins.map(function (c) { return c.symbol === nativeToken.symbol ? nativeToken.wrappedSymbol : c.symbol; });
200
195
  var underlyingCoinNames = pool.coins.map(function (c) { return c.symbol === nativeToken.wrappedSymbol ? nativeToken.symbol : c.symbol; });
201
196
  var underlyingCoinAddresses = coinAddresses.map(function (addr) { return addr === nativeToken.wrappedAddress ? nativeToken.address : addr; });
202
197
  var isPlain = !coinAddresses.includes(nativeToken.wrappedAddress);
203
- var isMeta = _this.chainId === 137 && coinAddresses[1].toLowerCase() === atricrypto3Lp;
204
- if (isMeta) {
205
- var basePoolId = "atricrypto3";
206
- var basePoolCoinNames = ['DAI', 'USDC', 'USDT', 'WBTC', 'WETH'];
207
- var basePoolCoinAddresses = [
208
- '0x8f3cf7ad23cd3cadbd9735aff958023239c6a063',
209
- '0x2791bca1f2de4661ed88a30c99a7a9449aa84174',
210
- '0xc2132d05d31c914a87c6611c10748aeb04b58e8f',
211
- '0x1BFD67037B42Cf73acF2047067bd4F2C47D9BfD6',
212
- '0x7ceB23fD6bC0adD59E62ac25578270cFf1b9f619', // WETH
213
- ];
214
- var basePoolDecimals = [18, 6, 6, 8, 18];
215
- var basePoolZap = "0x3d8EADb739D1Ef95dd53D718e4810721837c69c1";
198
+ var lpTokenBasePoolIdDict = constants_crypto_1.CRYPTO_FACTORY_CONSTANTS[_this.chainId].lpTokenBasePoolIdDict;
199
+ var basePoolIdZapDict = constants_crypto_1.CRYPTO_FACTORY_CONSTANTS[_this.chainId].basePoolIdZapDict;
200
+ var basePoolId = lpTokenBasePoolIdDict[coinAddresses[1].toLowerCase()];
201
+ if (basePoolId) { // isMeta
202
+ var allPoolsData = __assign(__assign({}, _this.constants.POOLS_DATA), FACTORY_POOLS_DATA);
203
+ var basePoolCoinNames = __spreadArray([], allPoolsData[basePoolId].underlying_coins, true);
204
+ var basePoolCoinAddresses = __spreadArray([], allPoolsData[basePoolId].underlying_coin_addresses, true);
205
+ var basePoolDecimals = __spreadArray([], allPoolsData[basePoolId].underlying_decimals, true);
206
+ var basePoolZap = basePoolIdZapDict[basePoolId];
216
207
  FACTORY_POOLS_DATA[pool.id] = {
217
208
  name: pool.name.split(": ")[1].trim(),
218
209
  full_name: pool.name,
@@ -221,20 +212,20 @@ function getFactoryPoolsDataFromApi(isCrypto) {
221
212
  swap_address: pool.address.toLowerCase(),
222
213
  token_address: pool.lpTokenAddress.toLowerCase(),
223
214
  gauge_address: pool.gaugeAddress ? pool.gaugeAddress.toLowerCase() : ethers_1.ethers.constants.AddressZero,
224
- deposit_address: basePoolZap,
215
+ deposit_address: basePoolZap.address,
225
216
  is_meta: true,
226
217
  is_crypto: true,
227
218
  is_factory: true,
228
219
  base_pool: basePoolId,
229
- underlying_coins: __spreadArray([coinNames[0]], basePoolCoinNames, true),
230
- wrapped_coins: coinNames,
231
- underlying_coin_addresses: __spreadArray([coinAddresses[0]], basePoolCoinAddresses, true),
220
+ underlying_coins: __spreadArray([underlyingCoinNames[0]], basePoolCoinNames, true),
221
+ wrapped_coins: wrappedCoinNames,
222
+ underlying_coin_addresses: __spreadArray([underlyingCoinAddresses[0]], basePoolCoinAddresses, true),
232
223
  wrapped_coin_addresses: coinAddresses,
233
224
  underlying_decimals: __spreadArray([coinDecimals[0]], basePoolDecimals, true),
234
225
  wrapped_decimals: coinDecimals,
235
226
  swap_abi: factory_crypto_pool_2_json_1.default,
236
227
  gauge_abi: _this.chainId === 1 ? gauge_factory_json_1.default : gauge_child_json_1.default,
237
- deposit_abi: base_pool_zap_json_1.default,
228
+ deposit_abi: basePoolZap.ABI,
238
229
  };
239
230
  }
240
231
  else {
@@ -250,7 +241,7 @@ function getFactoryPoolsDataFromApi(isCrypto) {
250
241
  is_plain: isPlain,
251
242
  is_factory: true,
252
243
  underlying_coins: underlyingCoinNames,
253
- wrapped_coins: cryptoCoinNames,
244
+ wrapped_coins: wrappedCoinNames,
254
245
  underlying_coin_addresses: underlyingCoinAddresses,
255
246
  wrapped_coin_addresses: coinAddresses,
256
247
  underlying_decimals: coinDecimals,
@@ -276,7 +267,7 @@ function getFactoryPoolsDataFromApi(isCrypto) {
276
267
  var basePoolCoinNames = basePoolIdCoinsDict[basePoolId];
277
268
  var basePoolCoinAddresses = basePoolIdCoinAddressesDict[basePoolId];
278
269
  var basePoolDecimals = basePoolIdDecimalsDict[basePoolId];
279
- var basePoolZap = basePoolIdZapDict[basePoolId].address;
270
+ var basePoolZap = basePoolIdZapDict[basePoolId];
280
271
  FACTORY_POOLS_DATA[pool.id] = {
281
272
  name: pool.name.split(": ")[1].trim(),
282
273
  full_name: pool.name,
@@ -285,7 +276,7 @@ function getFactoryPoolsDataFromApi(isCrypto) {
285
276
  swap_address: pool.address.toLowerCase(),
286
277
  token_address: pool.address.toLowerCase(),
287
278
  gauge_address: pool.gaugeAddress ? pool.gaugeAddress.toLowerCase() : ethers_1.ethers.constants.AddressZero,
288
- deposit_address: basePoolZap,
279
+ deposit_address: basePoolZap.address,
289
280
  is_meta: true,
290
281
  is_factory: true,
291
282
  base_pool: basePoolId,
@@ -297,7 +288,7 @@ function getFactoryPoolsDataFromApi(isCrypto) {
297
288
  wrapped_decimals: coinDecimals,
298
289
  swap_abi: implementationABIDict[pool.implementationAddress],
299
290
  gauge_abi: _this.chainId === 1 ? gauge_factory_json_1.default : gauge_child_json_1.default,
300
- deposit_abi: deposit_json_1.default,
291
+ deposit_abi: basePoolZap.ABI,
301
292
  };
302
293
  }
303
294
  else {
@@ -1,4 +1,15 @@
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
+ };
2
13
  var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
14
  function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
15
  return new (P || (P = Promise))(function (resolve, reject) {
@@ -55,8 +66,8 @@ var ERC20_json_1 = __importDefault(require("../constants/abis/ERC20.json"));
55
66
  var factory_crypto_pool_2_json_1 = __importDefault(require("../constants/abis/factory-crypto/factory-crypto-pool-2.json"));
56
67
  var gauge_factory_json_1 = __importDefault(require("../constants/abis/gauge_factory.json"));
57
68
  var gauge_child_json_1 = __importDefault(require("../constants/abis/gauge_child.json"));
58
- var base_pool_zap_json_1 = __importDefault(require("../constants/abis/atricrypto3/base_pool_zap.json"));
59
69
  var common_1 = require("./common");
70
+ var constants_crypto_1 = require("./constants-crypto");
60
71
  var deepFlatten = function (arr) { return [].concat.apply([], arr.map(function (v) { return (Array.isArray(v) ? deepFlatten(v) : v); })); };
61
72
  function getCryptoFactoryIdsAndSwapAddresses() {
62
73
  return __awaiter(this, void 0, void 0, function () {
@@ -323,10 +334,9 @@ function getCoinAddressDecimalsDict(coinAddresses, existingCoinAddressDecimalsDi
323
334
  });
324
335
  });
325
336
  }
326
- var atricrypto3Lp = "0xdAD97F7713Ae9437fa9249920eC8507e5FbB23d3".toLowerCase();
327
337
  function getCryptoFactoryPoolData() {
328
338
  return __awaiter(this, void 0, void 0, function () {
329
- var _a, poolIds, swapAddresses, tokenAddresses, gaugeAddresses, _b, poolSymbols, poolNames, coinAddresses, underlyingCoinAddresses, existingCoinAddressNameDict, coinAddressNameDict, coinAddressDecimalsDict, CRYPTO_FACTORY_POOLS_DATA, i, isMeta, basePoolId, basePoolCoinNames, basePoolCoinAddresses, basePoolDecimals, basePoolZap;
339
+ var _a, poolIds, swapAddresses, tokenAddresses, gaugeAddresses, _b, poolSymbols, poolNames, coinAddresses, underlyingCoinAddresses, existingCoinAddressNameDict, coinAddressNameDict, coinAddressDecimalsDict, CRYPTO_FACTORY_POOLS_DATA, i, lpTokenBasePoolIdDict, basePoolIdZapDict, basePoolId, allPoolsData, basePoolCoinNames, basePoolCoinAddresses, basePoolDecimals, basePoolZap;
330
340
  return __generator(this, function (_c) {
331
341
  switch (_c.label) {
332
342
  case 0: return [4 /*yield*/, getCryptoFactoryIdsAndSwapAddresses.call(this)];
@@ -358,22 +368,18 @@ function getCryptoFactoryPoolData() {
358
368
  return [4 /*yield*/, getCoinAddressDecimalsDict.call(this, coinAddresses, this.constants.DECIMALS)];
359
369
  case 8:
360
370
  coinAddressDecimalsDict = _c.sent();
361
- common_1.setCryptoFactoryZapContracts.call(this);
371
+ common_1.setFactoryZapContracts.call(this, true);
362
372
  CRYPTO_FACTORY_POOLS_DATA = {};
363
373
  for (i = 0; i < poolIds.length; i++) {
364
- isMeta = this.chainId === 137 && coinAddresses[i][1].toLowerCase() === atricrypto3Lp;
365
- if (isMeta) {
366
- basePoolId = "atricrypto3";
367
- basePoolCoinNames = ['DAI', 'USDC', 'USDT', 'WBTC', 'WETH'];
368
- basePoolCoinAddresses = [
369
- '0x8f3cf7ad23cd3cadbd9735aff958023239c6a063',
370
- '0x2791bca1f2de4661ed88a30c99a7a9449aa84174',
371
- '0xc2132d05d31c914a87c6611c10748aeb04b58e8f',
372
- '0x1BFD67037B42Cf73acF2047067bd4F2C47D9BfD6',
373
- '0x7ceB23fD6bC0adD59E62ac25578270cFf1b9f619', // WETH
374
- ];
375
- basePoolDecimals = [18, 6, 6, 8, 18];
376
- basePoolZap = "0x3d8EADb739D1Ef95dd53D718e4810721837c69c1";
374
+ lpTokenBasePoolIdDict = constants_crypto_1.CRYPTO_FACTORY_CONSTANTS[this.chainId].lpTokenBasePoolIdDict;
375
+ basePoolIdZapDict = constants_crypto_1.CRYPTO_FACTORY_CONSTANTS[this.chainId].basePoolIdZapDict;
376
+ basePoolId = lpTokenBasePoolIdDict[coinAddresses[i][1].toLowerCase()];
377
+ if (basePoolId) { // isMeta
378
+ allPoolsData = __assign(__assign({}, this.constants.POOLS_DATA), CRYPTO_FACTORY_POOLS_DATA);
379
+ basePoolCoinNames = __spreadArray([], allPoolsData[basePoolId].underlying_coins, true);
380
+ basePoolCoinAddresses = __spreadArray([], allPoolsData[basePoolId].underlying_coin_addresses, true);
381
+ basePoolDecimals = __spreadArray([], allPoolsData[basePoolId].underlying_decimals, true);
382
+ basePoolZap = basePoolIdZapDict[basePoolId];
377
383
  CRYPTO_FACTORY_POOLS_DATA[poolIds[i]] = {
378
384
  name: poolNames[i].split(": ")[1].trim(),
379
385
  full_name: poolNames[i],
@@ -382,20 +388,20 @@ function getCryptoFactoryPoolData() {
382
388
  swap_address: swapAddresses[i],
383
389
  token_address: tokenAddresses[i],
384
390
  gauge_address: gaugeAddresses[i],
385
- deposit_address: basePoolZap,
391
+ deposit_address: basePoolZap.address,
386
392
  is_meta: true,
387
393
  is_crypto: true,
388
394
  is_factory: true,
389
395
  base_pool: basePoolId,
390
- underlying_coins: __spreadArray([coinAddressNameDict[coinAddresses[i][0]]], basePoolCoinNames, true),
396
+ underlying_coins: __spreadArray([coinAddressNameDict[underlyingCoinAddresses[i][0]]], basePoolCoinNames, true),
391
397
  wrapped_coins: coinAddresses[i].map(function (addr) { return coinAddressNameDict[addr]; }),
392
- underlying_coin_addresses: __spreadArray([coinAddresses[i][0]], basePoolCoinAddresses, true),
398
+ underlying_coin_addresses: __spreadArray([underlyingCoinAddresses[i][0]], basePoolCoinAddresses, true),
393
399
  wrapped_coin_addresses: coinAddresses[i],
394
- underlying_decimals: __spreadArray([coinAddressDecimalsDict[coinAddresses[i][0]]], basePoolDecimals, true),
400
+ underlying_decimals: __spreadArray([coinAddressDecimalsDict[underlyingCoinAddresses[i][0]]], basePoolDecimals, true),
395
401
  wrapped_decimals: coinAddresses[i].map(function (addr) { return coinAddressDecimalsDict[addr]; }),
396
402
  swap_abi: factory_crypto_pool_2_json_1.default,
397
403
  gauge_abi: this.chainId === 1 ? gauge_factory_json_1.default : gauge_child_json_1.default,
398
- deposit_abi: base_pool_zap_json_1.default,
404
+ deposit_abi: basePoolZap.ABI,
399
405
  };
400
406
  }
401
407
  else {
@@ -415,7 +415,7 @@ function getFactoryPoolData() {
415
415
  isMeta = _c.sent();
416
416
  implementationBasePoolIdDict = constants_1.FACTORY_CONSTANTS[this.chainId].implementationBasePoolIdDict;
417
417
  basePoolIds = implementations.map(function (addr) { return implementationBasePoolIdDict[addr]; });
418
- common_1.setFactoryZapContracts.call(this);
418
+ common_1.setFactoryZapContracts.call(this, false);
419
419
  FACTORY_POOLS_DATA = {};
420
420
  _loop_2 = function (i) {
421
421
  if (!isMeta[i]) {
package/lib/index.d.ts CHANGED
@@ -75,7 +75,7 @@ declare const curve: {
75
75
  output: string;
76
76
  }>;
77
77
  expected: (inputCoin: string, outputCoin: string, amount: string | number) => Promise<string>;
78
- priceImpact: (inputCoin: string, outputCoin: string, amount: string | number) => Promise<string>;
78
+ priceImpact: (inputCoin: string, outputCoin: string, amount: string | number) => Promise<number>;
79
79
  isApproved: (inputCoin: string, amount: string | number) => Promise<boolean>;
80
80
  approve: (inputCoin: string, amount: string | number) => Promise<string[]>;
81
81
  swap: (inputCoin: string, outputCoin: string, amount: string | number, slippage?: number) => Promise<string>;
@@ -126,7 +126,7 @@ export interface IRouteStep {
126
126
  outputCoinAddress: string;
127
127
  i: number;
128
128
  j: number;
129
- swapType: 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10;
129
+ swapType: 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11;
130
130
  swapAddress: string;
131
131
  }
132
132
  export interface IRoute_ {
@@ -219,7 +219,7 @@ export declare class PoolTemplate {
219
219
  }>;
220
220
  private _swapExpected;
221
221
  swapExpected(inputCoin: string | number, outputCoin: string | number, amount: number | string): Promise<string>;
222
- swapPriceImpact(inputCoin: string | number, outputCoin: string | number, amount: number | string): Promise<string>;
222
+ swapPriceImpact(inputCoin: string | number, outputCoin: string | number, amount: number | string): Promise<number>;
223
223
  private _swapContractAddress;
224
224
  swapIsApproved(inputCoin: string | number, amount: number | string): Promise<boolean>;
225
225
  private swapApproveEstimateGas;
@@ -228,7 +228,7 @@ export declare class PoolTemplate {
228
228
  swap(inputCoin: string | number, outputCoin: string | number, amount: number | string, slippage?: number): Promise<string>;
229
229
  private _swapWrappedExpected;
230
230
  swapWrappedExpected(inputCoin: string | number, outputCoin: string | number, amount: number | string): Promise<string>;
231
- swapWrappedPriceImpact(inputCoin: string | number, outputCoin: string | number, amount: number | string): Promise<string>;
231
+ swapWrappedPriceImpact(inputCoin: string | number, outputCoin: string | number, amount: number | string): Promise<number>;
232
232
  swapWrappedIsApproved(inputCoin: string | number, amount: number | string): Promise<boolean>;
233
233
  private swapWrappedApproveEstimateGas;
234
234
  swapWrappedApprove(inputCoin: string | number, amount: number | string): Promise<string[]>;
@@ -61,7 +61,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
61
61
  Object.defineProperty(exports, "__esModule", { value: true });
62
62
  exports.PoolTemplate = void 0;
63
63
  var ethers_1 = require("ethers");
64
- var bignumber_js_1 = __importDefault(require("bignumber.js"));
65
64
  var memoizee_1 = __importDefault(require("memoizee"));
66
65
  var external_api_1 = require("../external-api");
67
66
  var utils_1 = require("../utils");
@@ -2624,7 +2623,7 @@ var PoolTemplate = /** @class */ (function () {
2624
2623
  };
2625
2624
  PoolTemplate.prototype.swapPriceImpact = function (inputCoin, outputCoin, amount) {
2626
2625
  return __awaiter(this, void 0, void 0, function () {
2627
- var i, j, _c, inputCoinDecimals, outputCoinDecimals, _amount, _output, target, amountIntBN, outputIntBN, k, smallAmountIntBN, _smallAmount, _smallOutput, amountBN, outputBN, smallAmountBN, smallOutputBN, rateBN, smallRateBN, slippageBN;
2626
+ var i, j, _c, inputCoinDecimals, outputCoinDecimals, _amount, _output, smallAmountIntBN, amountIntBN, _smallAmount, _smallOutput, priceImpactBN;
2628
2627
  return __generator(this, function (_d) {
2629
2628
  switch (_d.label) {
2630
2629
  case 0:
@@ -2635,25 +2634,16 @@ var PoolTemplate = /** @class */ (function () {
2635
2634
  return [4 /*yield*/, this._swapExpected(i, j, _amount)];
2636
2635
  case 1:
2637
2636
  _output = _d.sent();
2638
- target = (0, utils_1.BN)(Math.pow(10, 15));
2639
- amountIntBN = (0, utils_1.BN)(amount).times(Math.pow(10, inputCoinDecimals));
2640
- outputIntBN = (0, utils_1.toBN)(_output, 0);
2641
- k = bignumber_js_1.default.min(bignumber_js_1.default.max(target.div(amountIntBN), target.div(outputIntBN)), 0.2);
2642
- smallAmountIntBN = bignumber_js_1.default.min(amountIntBN.times(k), (0, utils_1.BN)(Math.pow(10, inputCoinDecimals)));
2643
- if (smallAmountIntBN.toFixed(0) === '0')
2644
- return [2 /*return*/, '0'];
2637
+ smallAmountIntBN = (0, utils_1._get_small_x)(_amount, _output, inputCoinDecimals, outputCoinDecimals);
2638
+ amountIntBN = (0, utils_1.toBN)(_amount, 0);
2639
+ if (smallAmountIntBN.gte(amountIntBN))
2640
+ return [2 /*return*/, 0];
2645
2641
  _smallAmount = (0, utils_1.fromBN)(smallAmountIntBN.div(Math.pow(10, inputCoinDecimals)), inputCoinDecimals);
2646
2642
  return [4 /*yield*/, this._swapExpected(i, j, _smallAmount)];
2647
2643
  case 2:
2648
2644
  _smallOutput = _d.sent();
2649
- amountBN = (0, utils_1.BN)(amount);
2650
- outputBN = (0, utils_1.toBN)(_output, outputCoinDecimals);
2651
- smallAmountBN = (0, utils_1.toBN)(_smallAmount, inputCoinDecimals);
2652
- smallOutputBN = (0, utils_1.toBN)(_smallOutput, outputCoinDecimals);
2653
- rateBN = outputBN.div(amountBN);
2654
- smallRateBN = smallOutputBN.div(smallAmountBN);
2655
- slippageBN = (0, utils_1.BN)(1).minus(rateBN.div(smallRateBN)).times(100);
2656
- return [2 /*return*/, (0, utils_1._cutZeros)(slippageBN.toFixed(6)).replace('-', '')];
2645
+ priceImpactBN = (0, utils_1._get_price_impact)(_amount, _output, _smallAmount, _smallOutput, inputCoinDecimals, outputCoinDecimals);
2646
+ return [2 /*return*/, Number((0, utils_1._cutZeros)(priceImpactBN.toFixed(4)).replace('-', ''))];
2657
2647
  }
2658
2648
  });
2659
2649
  });
@@ -2741,7 +2731,7 @@ var PoolTemplate = /** @class */ (function () {
2741
2731
  };
2742
2732
  PoolTemplate.prototype.swapWrappedPriceImpact = function (inputCoin, outputCoin, amount) {
2743
2733
  return __awaiter(this, void 0, void 0, function () {
2744
- var i, j, _c, inputCoinDecimals, outputCoinDecimals, _amount, _output, target, amountIntBN, outputIntBN, k, smallAmountIntBN, _smallAmount, _smallOutput, amountBN, outputBN, smallAmountBN, smallOutputBN, rateBN, smallRateBN, slippageBN;
2734
+ var i, j, _c, inputCoinDecimals, outputCoinDecimals, _amount, _output, smallAmountIntBN, amountIntBN, _smallAmount, _smallOutput, priceImpactBN;
2745
2735
  return __generator(this, function (_d) {
2746
2736
  switch (_d.label) {
2747
2737
  case 0:
@@ -2755,25 +2745,16 @@ var PoolTemplate = /** @class */ (function () {
2755
2745
  return [4 /*yield*/, this._swapWrappedExpected(i, j, _amount)];
2756
2746
  case 1:
2757
2747
  _output = _d.sent();
2758
- target = (0, utils_1.BN)(Math.pow(10, 15));
2759
- amountIntBN = (0, utils_1.BN)(amount).times(Math.pow(10, inputCoinDecimals));
2760
- outputIntBN = (0, utils_1.toBN)(_output, 0);
2761
- k = bignumber_js_1.default.min(bignumber_js_1.default.max(target.div(amountIntBN), target.div(outputIntBN)), 0.2);
2762
- smallAmountIntBN = bignumber_js_1.default.min(amountIntBN.times(k), (0, utils_1.BN)(Math.pow(10, inputCoinDecimals)));
2763
- if (smallAmountIntBN.toFixed(0) === '0')
2764
- return [2 /*return*/, '0'];
2748
+ smallAmountIntBN = (0, utils_1._get_small_x)(_amount, _output, inputCoinDecimals, outputCoinDecimals);
2749
+ amountIntBN = (0, utils_1.toBN)(_amount, 0);
2750
+ if (smallAmountIntBN.gte(amountIntBN))
2751
+ return [2 /*return*/, 0];
2765
2752
  _smallAmount = (0, utils_1.fromBN)(smallAmountIntBN.div(Math.pow(10, inputCoinDecimals)), inputCoinDecimals);
2766
2753
  return [4 /*yield*/, this._swapWrappedExpected(i, j, _smallAmount)];
2767
2754
  case 2:
2768
2755
  _smallOutput = _d.sent();
2769
- amountBN = (0, utils_1.BN)(amount);
2770
- outputBN = (0, utils_1.toBN)(_output, outputCoinDecimals);
2771
- smallAmountBN = (0, utils_1.toBN)(_smallAmount, inputCoinDecimals);
2772
- smallOutputBN = (0, utils_1.toBN)(_smallOutput, outputCoinDecimals);
2773
- rateBN = outputBN.div(amountBN);
2774
- smallRateBN = smallOutputBN.div(smallAmountBN);
2775
- slippageBN = (0, utils_1.BN)(1).minus(rateBN.div(smallRateBN)).times(100);
2776
- return [2 /*return*/, (0, utils_1._cutZeros)(slippageBN.toFixed(6)).replace('-', '')];
2756
+ priceImpactBN = (0, utils_1._get_price_impact)(_amount, _output, _smallAmount, _smallOutput, inputCoinDecimals, outputCoinDecimals);
2757
+ return [2 /*return*/, Number((0, utils_1._cutZeros)(priceImpactBN.toFixed(4)).replace('-', ''))];
2777
2758
  }
2778
2759
  });
2779
2760
  });
@@ -231,7 +231,7 @@ var getPool = function (poolId) {
231
231
  !(curve_1.curve.chainId === 100 && poolDummy.id === "tricrypto")) { // tricrypto2 (eth), tricrypto (arbitrum); 100 is xDAI
232
232
  Object.assign(Pool.prototype, swapMixins_1.swapTricrypto2Mixin);
233
233
  }
234
- else if (poolDummy.isMetaFactory && ((0, exports.getPool)(poolDummy.basePool).isLending || (0, exports.getPool)(poolDummy.basePool).isFake)) {
234
+ else if (poolDummy.isMetaFactory && ((0, exports.getPool)(poolDummy.basePool).isLending || (0, exports.getPool)(poolDummy.basePool).isFake || poolDummy.isCrypto)) {
235
235
  Object.assign(Pool.prototype, swapMixins_1.swapMetaFactoryMixin);
236
236
  }
237
237
  else {
package/lib/router.d.ts CHANGED
@@ -7,7 +7,7 @@ export declare const getBestRouteAndOutput: (inputCoin: string, outputCoin: stri
7
7
  output: string;
8
8
  }>;
9
9
  export declare const swapExpected: (inputCoin: string, outputCoin: string, amount: number | string) => Promise<string>;
10
- export declare const swapPriceImpact: (inputCoin: string, outputCoin: string, amount: number | string) => Promise<string>;
10
+ export declare const swapPriceImpact: (inputCoin: string, outputCoin: string, amount: number | string) => Promise<number>;
11
11
  export declare const swapIsApproved: (inputCoin: string, amount: number | string) => Promise<boolean>;
12
12
  export declare const swapApproveEstimateGas: (inputCoin: string, amount: number | string) => Promise<number>;
13
13
  export declare const swapApprove: (inputCoin: string, amount: number | string) => Promise<string[]>;