@curvefi/api 2.31.1 → 2.33.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.
Files changed (62) hide show
  1. package/lib/boosting.js +385 -135
  2. package/lib/constants/abis/stable_calc.json +151 -0
  3. package/lib/constants/abis/wbeth/swap.json +1086 -0
  4. package/lib/constants/aliases.js +33 -11
  5. package/lib/constants/coins/arbitrum.js +5 -5
  6. package/lib/constants/coins/aurora.js +5 -5
  7. package/lib/constants/coins/avalanche.js +6 -6
  8. package/lib/constants/coins/celo.js +5 -5
  9. package/lib/constants/coins/ethereum.js +10 -9
  10. package/lib/constants/coins/fantom.js +7 -7
  11. package/lib/constants/coins/kava.js +5 -5
  12. package/lib/constants/coins/moonbeam.js +5 -5
  13. package/lib/constants/coins/optimism.js +5 -5
  14. package/lib/constants/coins/polygon.js +6 -6
  15. package/lib/constants/coins/xdai.js +5 -5
  16. package/lib/constants/pools/arbitrum.js +1 -1
  17. package/lib/constants/pools/aurora.js +1 -1
  18. package/lib/constants/pools/avalanche.js +1 -1
  19. package/lib/constants/pools/celo.js +1 -1
  20. package/lib/constants/pools/ethereum.js +26 -1
  21. package/lib/constants/pools/fantom.js +1 -1
  22. package/lib/constants/pools/kava.js +1 -1
  23. package/lib/constants/pools/moonbeam.js +1 -1
  24. package/lib/constants/pools/optimism.js +1 -1
  25. package/lib/constants/pools/polygon.js +1 -1
  26. package/lib/constants/pools/xdai.js +1 -1
  27. package/lib/constants/utils.d.ts +1 -1
  28. package/lib/constants/utils.js +19 -18
  29. package/lib/curve.js +507 -281
  30. package/lib/external-api.js +132 -45
  31. package/lib/factory/common.js +3 -3
  32. package/lib/factory/constants-crypto.js +21 -21
  33. package/lib/factory/constants.js +32 -31
  34. package/lib/factory/deploy.js +336 -176
  35. package/lib/factory/factory-api.js +256 -180
  36. package/lib/factory/factory-crypto.js +309 -163
  37. package/lib/factory/factory.d.ts +1 -1
  38. package/lib/factory/factory.js +336 -186
  39. package/lib/index.js +98 -44
  40. package/lib/interfaces.d.ts +1 -1
  41. package/lib/pools/PoolTemplate.js +2882 -1511
  42. package/lib/pools/mixins/common.js +106 -22
  43. package/lib/pools/mixins/depositBalancedAmountsMixins.js +131 -48
  44. package/lib/pools/mixins/depositMixins.js +413 -144
  45. package/lib/pools/mixins/depositWrappedMixins.js +223 -72
  46. package/lib/pools/mixins/poolBalancesMixin.js +98 -22
  47. package/lib/pools/mixins/swapMixins.js +347 -125
  48. package/lib/pools/mixins/swapWrappedMixins.js +270 -88
  49. package/lib/pools/mixins/withdrawExpectedMixins.js +104 -23
  50. package/lib/pools/mixins/withdrawImbalanceMixins.js +316 -97
  51. package/lib/pools/mixins/withdrawImbalanceWrappedMixins.js +187 -51
  52. package/lib/pools/mixins/withdrawMixins.js +385 -122
  53. package/lib/pools/mixins/withdrawOneCoinExpectedMixins.js +88 -16
  54. package/lib/pools/mixins/withdrawOneCoinMixins.js +386 -123
  55. package/lib/pools/mixins/withdrawOneCoinWrappedExpectedMixins.js +62 -8
  56. package/lib/pools/mixins/withdrawOneCoinWrappedMixins.js +185 -53
  57. package/lib/pools/mixins/withdrawWrappedMixins.js +185 -50
  58. package/lib/pools/poolConstructor.js +25 -5
  59. package/lib/pools/utils.js +488 -298
  60. package/lib/router.js +636 -378
  61. package/lib/utils.js +675 -354
  62. package/package.json +1 -1
@@ -1,3 +1,59 @@
1
+ var __assign = (this && this.__assign) || function () {
2
+ __assign = Object.assign || function(t) {
3
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
4
+ s = arguments[i];
5
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
6
+ t[p] = s[p];
7
+ }
8
+ return t;
9
+ };
10
+ return __assign.apply(this, arguments);
11
+ };
12
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
13
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
14
+ return new (P || (P = Promise))(function (resolve, reject) {
15
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
16
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
17
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
18
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
19
+ });
20
+ };
21
+ var __generator = (this && this.__generator) || function (thisArg, body) {
22
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
23
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
24
+ function verb(n) { return function (v) { return step([n, v]); }; }
25
+ function step(op) {
26
+ if (f) throw new TypeError("Generator is already executing.");
27
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
28
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
29
+ if (y = 0, t) op = [op[0] & 2, t.value];
30
+ switch (op[0]) {
31
+ case 0: case 1: t = op; break;
32
+ case 4: _.label++; return { value: op[1], done: false };
33
+ case 5: _.label++; y = op[1]; op = [0]; continue;
34
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
35
+ default:
36
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
37
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
38
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
39
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
40
+ if (t[2]) _.ops.pop();
41
+ _.trys.pop(); continue;
42
+ }
43
+ op = body.call(thisArg, _);
44
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
45
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
46
+ }
47
+ };
48
+ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
49
+ if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
50
+ if (ar || !(i in from)) {
51
+ if (!ar) ar = Array.prototype.slice.call(from, 0, i);
52
+ ar[i] = from[i];
53
+ }
54
+ }
55
+ return to.concat(ar || Array.prototype.slice.call(from));
56
+ };
1
57
  import { Contract } from "ethers";
2
58
  import { Contract as MulticallContract } from "ethcall";
3
59
  import { curve } from "../curve.js";
@@ -9,18 +65,22 @@ import { FACTORY_CONSTANTS } from "./constants.js";
9
65
  import { CRYPTO_FACTORY_CONSTANTS } from "./constants-crypto.js";
10
66
  import { setFactoryZapContracts } from "./common.js";
11
67
  import { _getPoolsFromApi } from "../external-api.js";
12
- export const lowerCasePoolDataAddresses = (poolsData) => {
13
- for (const poolData of poolsData) {
68
+ export var lowerCasePoolDataAddresses = function (poolsData) {
69
+ var _a;
70
+ for (var _i = 0, poolsData_1 = poolsData; _i < poolsData_1.length; _i++) {
71
+ var poolData = poolsData_1[_i];
14
72
  poolData.address = poolData.address.toLowerCase();
15
73
  if (poolData.lpTokenAddress)
16
74
  poolData.lpTokenAddress = poolData.lpTokenAddress.toLowerCase();
17
75
  if (poolData.gaugeAddress)
18
76
  poolData.gaugeAddress = poolData.gaugeAddress.toLowerCase();
19
77
  poolData.implementationAddress = poolData.implementationAddress.toLowerCase();
20
- for (const coin of poolData.coins) {
78
+ for (var _b = 0, _c = poolData.coins; _b < _c.length; _b++) {
79
+ var coin = _c[_b];
21
80
  coin.address = coin.address.toLowerCase();
22
81
  }
23
- for (const reward of poolData.gaugeRewards ?? []) {
82
+ for (var _d = 0, _e = (_a = poolData.gaugeRewards) !== null && _a !== void 0 ? _a : []; _d < _e.length; _d++) {
83
+ var reward = _e[_d];
24
84
  reward.gaugeAddress = reward.gaugeAddress.toLowerCase();
25
85
  reward.tokenAddress = reward.tokenAddress.toLowerCase();
26
86
  }
@@ -28,50 +88,55 @@ export const lowerCasePoolDataAddresses = (poolsData) => {
28
88
  return poolsData;
29
89
  };
30
90
  function setFactorySwapContracts(rawPoolList, isCrypto) {
91
+ var _this = this;
31
92
  if (isCrypto) {
32
- rawPoolList.forEach((pool) => {
33
- const addr = pool.address;
34
- this.contracts[addr] = {
35
- contract: new Contract(addr, cryptoFactorySwapABI, this.signer || this.provider),
93
+ rawPoolList.forEach(function (pool) {
94
+ var addr = pool.address;
95
+ _this.contracts[addr] = {
96
+ contract: new Contract(addr, cryptoFactorySwapABI, _this.signer || _this.provider),
36
97
  multicallContract: new MulticallContract(addr, cryptoFactorySwapABI),
37
98
  };
38
99
  });
39
100
  }
40
101
  else {
41
- const implementationABIDict = FACTORY_CONSTANTS[this.chainId].implementationABIDict;
42
- rawPoolList.forEach((pool) => {
43
- const addr = pool.address;
44
- this.contracts[addr] = {
45
- contract: new Contract(addr, implementationABIDict[pool.implementationAddress], this.signer || this.provider),
46
- multicallContract: new MulticallContract(addr, implementationABIDict[pool.implementationAddress]),
102
+ var implementationABIDict_1 = FACTORY_CONSTANTS[this.chainId].implementationABIDict;
103
+ rawPoolList.forEach(function (pool) {
104
+ var addr = pool.address;
105
+ _this.contracts[addr] = {
106
+ contract: new Contract(addr, implementationABIDict_1[pool.implementationAddress], _this.signer || _this.provider),
107
+ multicallContract: new MulticallContract(addr, implementationABIDict_1[pool.implementationAddress]),
47
108
  };
48
109
  });
49
110
  }
50
111
  }
51
112
  function setCryptoFactoryTokenContracts(rawPoolList) {
52
- rawPoolList.forEach((pool) => {
53
- const addr = pool.lpTokenAddress;
54
- this.contracts[addr] = {
55
- contract: new Contract(addr, ERC20ABI, this.signer || this.provider),
113
+ var _this = this;
114
+ rawPoolList.forEach(function (pool) {
115
+ var addr = pool.lpTokenAddress;
116
+ _this.contracts[addr] = {
117
+ contract: new Contract(addr, ERC20ABI, _this.signer || _this.provider),
56
118
  multicallContract: new MulticallContract(addr, ERC20ABI),
57
119
  };
58
120
  });
59
121
  }
60
122
  function setFactoryGaugeContracts(rawPoolList) {
61
- rawPoolList.forEach((pool) => {
123
+ var _this = this;
124
+ rawPoolList.forEach(function (pool) {
62
125
  if (pool.gaugeAddress) {
63
- const addr = pool.gaugeAddress;
64
- this.contracts[addr] = {
65
- contract: new Contract(addr, this.chainId === 1 ? factoryGaugeABI : gaugeChildABI, this.signer || this.provider),
66
- multicallContract: new MulticallContract(addr, this.chainId === 1 ? factoryGaugeABI : gaugeChildABI),
126
+ var addr = pool.gaugeAddress;
127
+ _this.contracts[addr] = {
128
+ contract: new Contract(addr, _this.chainId === 1 ? factoryGaugeABI : gaugeChildABI, _this.signer || _this.provider),
129
+ multicallContract: new MulticallContract(addr, _this.chainId === 1 ? factoryGaugeABI : gaugeChildABI),
67
130
  };
68
131
  }
69
132
  });
70
133
  }
71
134
  function setFactoryCoinsContracts(rawPoolList) {
72
- for (const pool of rawPoolList) {
73
- for (const coin of pool.coins) {
74
- const addr = coin.address;
135
+ for (var _i = 0, rawPoolList_1 = rawPoolList; _i < rawPoolList_1.length; _i++) {
136
+ var pool = rawPoolList_1[_i];
137
+ for (var _a = 0, _b = pool.coins; _a < _b.length; _a++) {
138
+ var coin = _b[_a];
139
+ var addr = coin.address;
75
140
  if (addr in this.contracts)
76
141
  continue;
77
142
  this.contracts[addr] = {
@@ -81,160 +146,171 @@ function setFactoryCoinsContracts(rawPoolList) {
81
146
  }
82
147
  }
83
148
  }
84
- export async function getFactoryPoolsDataFromApi(isCrypto) {
85
- const network = this.constants.NETWORK_NAME;
86
- const factoryType = isCrypto ? "factory-crypto" : "factory";
87
- let rawPoolList = lowerCasePoolDataAddresses((await _getPoolsFromApi(network, factoryType)).poolData);
88
- if (!isCrypto) {
89
- rawPoolList = rawPoolList.filter((p) => p.implementationAddress in FACTORY_CONSTANTS[this.chainId].implementationABIDict);
90
- }
91
- // Filter duplications
92
- const mainAddresses = Object.values(this.constants.POOLS_DATA).map((pool) => pool.swap_address);
93
- rawPoolList = rawPoolList.filter((p) => !mainAddresses.includes(p.address));
94
- setFactorySwapContracts.call(this, rawPoolList, isCrypto);
95
- if (isCrypto)
96
- setCryptoFactoryTokenContracts.call(this, rawPoolList);
97
- setFactoryGaugeContracts.call(this, rawPoolList);
98
- setFactoryCoinsContracts.call(this, rawPoolList);
99
- setFactoryZapContracts.call(this, isCrypto);
100
- const FACTORY_POOLS_DATA = {};
101
- rawPoolList.forEach((pool) => {
102
- const nativeToken = this.constants.NATIVE_TOKEN;
103
- let coinAddresses = pool.coins.map((c) => c.address);
104
- if (this.chainId === 137) {
105
- coinAddresses = coinAddresses.map((a) => a === "0x0000000000000000000000000000000000001010" ? nativeToken.wrappedAddress : a);
106
- }
107
- const coinNames = pool.coins.map((c) => c.symbol);
108
- const coinDecimals = pool.coins.map((c) => Number(c.decimals));
109
- if (isCrypto) {
110
- const wrappedCoinNames = pool.coins.map((c) => c.symbol === nativeToken.symbol ? nativeToken.wrappedSymbol : c.symbol);
111
- const underlyingCoinNames = pool.coins.map((c) => c.symbol === nativeToken.wrappedSymbol ? nativeToken.symbol : c.symbol);
112
- const underlyingCoinAddresses = coinAddresses.map((addr) => addr === nativeToken.wrappedAddress ? nativeToken.address : addr);
113
- const isPlain = !coinAddresses.includes(nativeToken.wrappedAddress);
114
- const lpTokenBasePoolIdDict = CRYPTO_FACTORY_CONSTANTS[this.chainId].lpTokenBasePoolIdDict;
115
- const basePoolIdZapDict = CRYPTO_FACTORY_CONSTANTS[this.chainId].basePoolIdZapDict;
116
- const basePoolId = lpTokenBasePoolIdDict[coinAddresses[1]];
117
- if (basePoolId) { // isMeta
118
- const allPoolsData = { ...this.constants.POOLS_DATA, ...FACTORY_POOLS_DATA };
119
- const basePoolCoinNames = [...allPoolsData[basePoolId].underlying_coins];
120
- const basePoolCoinAddresses = [...allPoolsData[basePoolId].underlying_coin_addresses];
121
- const basePoolDecimals = [...allPoolsData[basePoolId].underlying_decimals];
122
- const basePoolZap = basePoolIdZapDict[basePoolId];
123
- FACTORY_POOLS_DATA[pool.id] = {
124
- name: pool.name.split(": ")[1].trim(),
125
- full_name: pool.name,
126
- symbol: pool.symbol,
127
- reference_asset: "CRYPTO",
128
- swap_address: pool.address,
129
- token_address: pool.lpTokenAddress,
130
- gauge_address: pool.gaugeAddress ? pool.gaugeAddress : curve.constants.ZERO_ADDRESS,
131
- deposit_address: basePoolZap.address,
132
- is_meta: true,
133
- is_crypto: true,
134
- is_factory: true,
135
- base_pool: basePoolId,
136
- underlying_coins: [underlyingCoinNames[0], ...basePoolCoinNames],
137
- wrapped_coins: wrappedCoinNames,
138
- underlying_coin_addresses: [underlyingCoinAddresses[0], ...basePoolCoinAddresses],
139
- wrapped_coin_addresses: coinAddresses,
140
- underlying_decimals: [coinDecimals[0], ...basePoolDecimals],
141
- wrapped_decimals: coinDecimals,
142
- swap_abi: cryptoFactorySwapABI,
143
- gauge_abi: this.chainId === 1 ? factoryGaugeABI : gaugeChildABI,
144
- deposit_abi: basePoolZap.ABI,
145
- in_api: true,
146
- };
147
- }
148
- else {
149
- FACTORY_POOLS_DATA[pool.id] = {
150
- name: pool.name.split(": ")[1].trim(),
151
- full_name: pool.name,
152
- symbol: pool.symbol,
153
- reference_asset: "CRYPTO",
154
- swap_address: pool.address,
155
- token_address: pool.lpTokenAddress,
156
- gauge_address: pool.gaugeAddress ? pool.gaugeAddress : curve.constants.ZERO_ADDRESS,
157
- is_crypto: true,
158
- is_plain: isPlain,
159
- is_factory: true,
160
- underlying_coins: underlyingCoinNames,
161
- wrapped_coins: wrappedCoinNames,
162
- underlying_coin_addresses: underlyingCoinAddresses,
163
- wrapped_coin_addresses: coinAddresses,
164
- underlying_decimals: coinDecimals,
165
- wrapped_decimals: coinDecimals,
166
- swap_abi: cryptoFactorySwapABI,
167
- gauge_abi: this.chainId === 1 ? factoryGaugeABI : gaugeChildABI,
168
- in_api: true,
169
- };
149
+ export function getFactoryPoolsDataFromApi(isCrypto) {
150
+ return __awaiter(this, void 0, void 0, function () {
151
+ var network, factoryType, rawPoolList, _a, mainAddresses, FACTORY_POOLS_DATA;
152
+ var _this = this;
153
+ return __generator(this, function (_b) {
154
+ switch (_b.label) {
155
+ case 0:
156
+ network = this.constants.NETWORK_NAME;
157
+ factoryType = isCrypto ? "factory-crypto" : "factory";
158
+ _a = lowerCasePoolDataAddresses;
159
+ return [4 /*yield*/, _getPoolsFromApi(network, factoryType)];
160
+ case 1:
161
+ rawPoolList = _a.apply(void 0, [(_b.sent()).poolData]);
162
+ if (!isCrypto) {
163
+ rawPoolList = rawPoolList.filter(function (p) { return p.implementationAddress in FACTORY_CONSTANTS[_this.chainId].implementationABIDict; });
164
+ }
165
+ mainAddresses = Object.values(this.constants.POOLS_DATA).map(function (pool) { return pool.swap_address; });
166
+ rawPoolList = rawPoolList.filter(function (p) { return !mainAddresses.includes(p.address); });
167
+ setFactorySwapContracts.call(this, rawPoolList, isCrypto);
168
+ if (isCrypto)
169
+ setCryptoFactoryTokenContracts.call(this, rawPoolList);
170
+ setFactoryGaugeContracts.call(this, rawPoolList);
171
+ setFactoryCoinsContracts.call(this, rawPoolList);
172
+ setFactoryZapContracts.call(this, isCrypto);
173
+ FACTORY_POOLS_DATA = {};
174
+ rawPoolList.forEach(function (pool) {
175
+ var nativeToken = _this.constants.NATIVE_TOKEN;
176
+ var coinAddresses = pool.coins.map(function (c) { return c.address; });
177
+ if (_this.chainId === 137) {
178
+ coinAddresses = coinAddresses.map(function (a) { return a === "0x0000000000000000000000000000000000001010" ? nativeToken.wrappedAddress : a; });
179
+ }
180
+ var coinNames = pool.coins.map(function (c) { return c.symbol; });
181
+ var coinDecimals = pool.coins.map(function (c) { return Number(c.decimals); });
182
+ if (isCrypto) {
183
+ var wrappedCoinNames = pool.coins.map(function (c) { return c.symbol === nativeToken.symbol ? nativeToken.wrappedSymbol : c.symbol; });
184
+ var underlyingCoinNames = pool.coins.map(function (c) { return c.symbol === nativeToken.wrappedSymbol ? nativeToken.symbol : c.symbol; });
185
+ var underlyingCoinAddresses = coinAddresses.map(function (addr) { return addr === nativeToken.wrappedAddress ? nativeToken.address : addr; });
186
+ var isPlain = !coinAddresses.includes(nativeToken.wrappedAddress);
187
+ var lpTokenBasePoolIdDict = CRYPTO_FACTORY_CONSTANTS[_this.chainId].lpTokenBasePoolIdDict;
188
+ var basePoolIdZapDict = CRYPTO_FACTORY_CONSTANTS[_this.chainId].basePoolIdZapDict;
189
+ var basePoolId = lpTokenBasePoolIdDict[coinAddresses[1]];
190
+ if (basePoolId) { // isMeta
191
+ var allPoolsData = __assign(__assign({}, _this.constants.POOLS_DATA), FACTORY_POOLS_DATA);
192
+ var basePoolCoinNames = __spreadArray([], allPoolsData[basePoolId].underlying_coins, true);
193
+ var basePoolCoinAddresses = __spreadArray([], allPoolsData[basePoolId].underlying_coin_addresses, true);
194
+ var basePoolDecimals = __spreadArray([], allPoolsData[basePoolId].underlying_decimals, true);
195
+ var basePoolZap = basePoolIdZapDict[basePoolId];
196
+ FACTORY_POOLS_DATA[pool.id] = {
197
+ name: pool.name.split(": ")[1].trim(),
198
+ full_name: pool.name,
199
+ symbol: pool.symbol,
200
+ reference_asset: "CRYPTO",
201
+ swap_address: pool.address,
202
+ token_address: pool.lpTokenAddress,
203
+ gauge_address: pool.gaugeAddress ? pool.gaugeAddress : curve.constants.ZERO_ADDRESS,
204
+ deposit_address: basePoolZap.address,
205
+ is_meta: true,
206
+ is_crypto: true,
207
+ is_factory: true,
208
+ base_pool: basePoolId,
209
+ underlying_coins: __spreadArray([underlyingCoinNames[0]], basePoolCoinNames, true),
210
+ wrapped_coins: wrappedCoinNames,
211
+ underlying_coin_addresses: __spreadArray([underlyingCoinAddresses[0]], basePoolCoinAddresses, true),
212
+ wrapped_coin_addresses: coinAddresses,
213
+ underlying_decimals: __spreadArray([coinDecimals[0]], basePoolDecimals, true),
214
+ wrapped_decimals: coinDecimals,
215
+ swap_abi: cryptoFactorySwapABI,
216
+ gauge_abi: _this.chainId === 1 ? factoryGaugeABI : gaugeChildABI,
217
+ deposit_abi: basePoolZap.ABI,
218
+ in_api: true,
219
+ };
220
+ }
221
+ else {
222
+ FACTORY_POOLS_DATA[pool.id] = {
223
+ name: pool.name.split(": ")[1].trim(),
224
+ full_name: pool.name,
225
+ symbol: pool.symbol,
226
+ reference_asset: "CRYPTO",
227
+ swap_address: pool.address,
228
+ token_address: pool.lpTokenAddress,
229
+ gauge_address: pool.gaugeAddress ? pool.gaugeAddress : curve.constants.ZERO_ADDRESS,
230
+ is_crypto: true,
231
+ is_plain: isPlain,
232
+ is_factory: true,
233
+ underlying_coins: underlyingCoinNames,
234
+ wrapped_coins: wrappedCoinNames,
235
+ underlying_coin_addresses: underlyingCoinAddresses,
236
+ wrapped_coin_addresses: coinAddresses,
237
+ underlying_decimals: coinDecimals,
238
+ wrapped_decimals: coinDecimals,
239
+ swap_abi: cryptoFactorySwapABI,
240
+ gauge_abi: _this.chainId === 1 ? factoryGaugeABI : gaugeChildABI,
241
+ in_api: true,
242
+ };
243
+ }
244
+ }
245
+ else if (pool.implementation.includes("meta")) {
246
+ var implementationABIDict = FACTORY_CONSTANTS[_this.chainId].implementationABIDict;
247
+ var implementationBasePoolIdDict = FACTORY_CONSTANTS[_this.chainId].implementationBasePoolIdDict;
248
+ var basePoolIds = Object.values(implementationBasePoolIdDict).filter(function (poolId, i, arr) { return arr.indexOf(poolId) === i; });
249
+ var allPoolsData_1 = __assign(__assign({}, _this.constants.POOLS_DATA), FACTORY_POOLS_DATA);
250
+ // @ts-ignore
251
+ var basePoolIdCoinsDict = Object.fromEntries(basePoolIds.map(function (poolId) { var _a; return [poolId, (_a = allPoolsData_1[poolId]) === null || _a === void 0 ? void 0 : _a.underlying_coins]; }));
252
+ // @ts-ignore
253
+ var basePoolIdCoinAddressesDict = Object.fromEntries(basePoolIds.map(function (poolId) { var _a; return [poolId, (_a = allPoolsData_1[poolId]) === null || _a === void 0 ? void 0 : _a.underlying_coin_addresses]; }));
254
+ // @ts-ignore
255
+ 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]; }));
256
+ var basePoolIdZapDict = FACTORY_CONSTANTS[_this.chainId].basePoolIdZapDict;
257
+ var basePoolId = implementationBasePoolIdDict[pool.implementationAddress];
258
+ var basePoolCoinNames = basePoolIdCoinsDict[basePoolId];
259
+ var basePoolCoinAddresses = basePoolIdCoinAddressesDict[basePoolId];
260
+ var basePoolDecimals = basePoolIdDecimalsDict[basePoolId];
261
+ var basePoolZap = basePoolIdZapDict[basePoolId];
262
+ FACTORY_POOLS_DATA[pool.id] = {
263
+ name: pool.name.split(": ")[1].trim(),
264
+ full_name: pool.name,
265
+ symbol: pool.symbol,
266
+ reference_asset: pool.assetTypeName.toUpperCase(),
267
+ swap_address: pool.address,
268
+ token_address: pool.address,
269
+ gauge_address: pool.gaugeAddress ? pool.gaugeAddress : curve.constants.ZERO_ADDRESS,
270
+ deposit_address: basePoolZap.address,
271
+ implementation_address: pool.implementationAddress,
272
+ is_meta: true,
273
+ is_factory: true,
274
+ base_pool: basePoolId,
275
+ underlying_coins: __spreadArray([coinNames[0]], basePoolCoinNames, true),
276
+ wrapped_coins: coinNames,
277
+ underlying_coin_addresses: __spreadArray([coinAddresses[0]], basePoolCoinAddresses, true),
278
+ wrapped_coin_addresses: coinAddresses,
279
+ underlying_decimals: __spreadArray([coinDecimals[0]], basePoolDecimals, true),
280
+ wrapped_decimals: coinDecimals,
281
+ swap_abi: implementationABIDict[pool.implementationAddress],
282
+ gauge_abi: _this.chainId === 1 ? factoryGaugeABI : gaugeChildABI,
283
+ deposit_abi: basePoolZap.ABI,
284
+ in_api: true,
285
+ };
286
+ }
287
+ else {
288
+ var implementationABIDict = FACTORY_CONSTANTS[_this.chainId].implementationABIDict;
289
+ FACTORY_POOLS_DATA[pool.id] = {
290
+ name: pool.name.split(": ")[1].trim(),
291
+ full_name: pool.name,
292
+ symbol: pool.symbol,
293
+ reference_asset: pool.assetTypeName.toUpperCase(),
294
+ swap_address: pool.address,
295
+ token_address: pool.address,
296
+ gauge_address: pool.gaugeAddress ? pool.gaugeAddress : curve.constants.ZERO_ADDRESS,
297
+ implementation_address: pool.implementationAddress,
298
+ is_plain: true,
299
+ is_factory: true,
300
+ underlying_coins: coinNames,
301
+ wrapped_coins: coinNames,
302
+ underlying_coin_addresses: coinAddresses,
303
+ wrapped_coin_addresses: coinAddresses,
304
+ underlying_decimals: coinDecimals,
305
+ wrapped_decimals: coinDecimals,
306
+ swap_abi: implementationABIDict[pool.implementationAddress],
307
+ gauge_abi: _this.chainId === 1 ? factoryGaugeABI : gaugeChildABI,
308
+ in_api: true,
309
+ };
310
+ }
311
+ });
312
+ return [2 /*return*/, FACTORY_POOLS_DATA];
170
313
  }
171
- }
172
- else if (pool.implementation.includes("meta")) {
173
- const implementationABIDict = FACTORY_CONSTANTS[this.chainId].implementationABIDict;
174
- const implementationBasePoolIdDict = FACTORY_CONSTANTS[this.chainId].implementationBasePoolIdDict;
175
- const basePoolIds = Object.values(implementationBasePoolIdDict).filter((poolId, i, arr) => arr.indexOf(poolId) === i);
176
- const allPoolsData = { ...this.constants.POOLS_DATA, ...FACTORY_POOLS_DATA };
177
- // @ts-ignore
178
- const basePoolIdCoinsDict = Object.fromEntries(basePoolIds.map((poolId) => [poolId, allPoolsData[poolId]?.underlying_coins]));
179
- // @ts-ignore
180
- const basePoolIdCoinAddressesDict = Object.fromEntries(basePoolIds.map((poolId) => [poolId, allPoolsData[poolId]?.underlying_coin_addresses]));
181
- // @ts-ignore
182
- const basePoolIdDecimalsDict = Object.fromEntries(basePoolIds.map((poolId) => [poolId, allPoolsData[poolId]?.underlying_decimals]));
183
- const basePoolIdZapDict = FACTORY_CONSTANTS[this.chainId].basePoolIdZapDict;
184
- const basePoolId = implementationBasePoolIdDict[pool.implementationAddress];
185
- const basePoolCoinNames = basePoolIdCoinsDict[basePoolId];
186
- const basePoolCoinAddresses = basePoolIdCoinAddressesDict[basePoolId];
187
- const basePoolDecimals = basePoolIdDecimalsDict[basePoolId];
188
- const basePoolZap = basePoolIdZapDict[basePoolId];
189
- FACTORY_POOLS_DATA[pool.id] = {
190
- name: pool.name.split(": ")[1].trim(),
191
- full_name: pool.name,
192
- symbol: pool.symbol,
193
- reference_asset: pool.assetTypeName.toUpperCase(),
194
- swap_address: pool.address,
195
- token_address: pool.address,
196
- gauge_address: pool.gaugeAddress ? pool.gaugeAddress : curve.constants.ZERO_ADDRESS,
197
- deposit_address: basePoolZap.address,
198
- implementation_address: pool.implementationAddress,
199
- is_meta: true,
200
- is_factory: true,
201
- base_pool: basePoolId,
202
- underlying_coins: [coinNames[0], ...basePoolCoinNames],
203
- wrapped_coins: coinNames,
204
- underlying_coin_addresses: [coinAddresses[0], ...basePoolCoinAddresses],
205
- wrapped_coin_addresses: coinAddresses,
206
- underlying_decimals: [coinDecimals[0], ...basePoolDecimals],
207
- wrapped_decimals: coinDecimals,
208
- swap_abi: implementationABIDict[pool.implementationAddress],
209
- gauge_abi: this.chainId === 1 ? factoryGaugeABI : gaugeChildABI,
210
- deposit_abi: basePoolZap.ABI,
211
- in_api: true,
212
- };
213
- }
214
- else {
215
- const implementationABIDict = FACTORY_CONSTANTS[this.chainId].implementationABIDict;
216
- FACTORY_POOLS_DATA[pool.id] = {
217
- name: pool.name.split(": ")[1].trim(),
218
- full_name: pool.name,
219
- symbol: pool.symbol,
220
- reference_asset: pool.assetTypeName.toUpperCase(),
221
- swap_address: pool.address,
222
- token_address: pool.address,
223
- gauge_address: pool.gaugeAddress ? pool.gaugeAddress : curve.constants.ZERO_ADDRESS,
224
- implementation_address: pool.implementationAddress,
225
- is_plain: true,
226
- is_factory: true,
227
- underlying_coins: coinNames,
228
- wrapped_coins: coinNames,
229
- underlying_coin_addresses: coinAddresses,
230
- wrapped_coin_addresses: coinAddresses,
231
- underlying_decimals: coinDecimals,
232
- wrapped_decimals: coinDecimals,
233
- swap_abi: implementationABIDict[pool.implementationAddress],
234
- gauge_abi: this.chainId === 1 ? factoryGaugeABI : gaugeChildABI,
235
- in_api: true,
236
- };
237
- }
314
+ });
238
315
  });
239
- return FACTORY_POOLS_DATA;
240
316
  }