@curvefi/api 2.62.0 → 2.63.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.
Files changed (83) hide show
  1. package/lib/boosting.js +247 -645
  2. package/lib/constants/L2Networks.js +1 -1
  3. package/lib/constants/aliases.js +31 -31
  4. package/lib/constants/coins/arbitrum.js +5 -5
  5. package/lib/constants/coins/aurora.js +5 -5
  6. package/lib/constants/coins/avalanche.js +6 -6
  7. package/lib/constants/coins/base.js +5 -5
  8. package/lib/constants/coins/bsc.js +5 -5
  9. package/lib/constants/coins/celo.js +5 -5
  10. package/lib/constants/coins/ethereum.js +9 -9
  11. package/lib/constants/coins/fantom.js +7 -7
  12. package/lib/constants/coins/fraxtal.js +5 -5
  13. package/lib/constants/coins/kava.js +5 -5
  14. package/lib/constants/coins/mantle.js +5 -5
  15. package/lib/constants/coins/moonbeam.js +5 -5
  16. package/lib/constants/coins/optimism.js +5 -5
  17. package/lib/constants/coins/polygon.js +6 -6
  18. package/lib/constants/coins/xdai.js +5 -5
  19. package/lib/constants/coins/xlayer.js +5 -5
  20. package/lib/constants/coins/zksync.js +5 -5
  21. package/lib/constants/pools/arbitrum.js +1 -1
  22. package/lib/constants/pools/aurora.js +1 -1
  23. package/lib/constants/pools/avalanche.js +1 -1
  24. package/lib/constants/pools/base.js +1 -1
  25. package/lib/constants/pools/bsc.js +1 -1
  26. package/lib/constants/pools/celo.js +1 -1
  27. package/lib/constants/pools/ethereum.js +2 -2
  28. package/lib/constants/pools/fantom.js +1 -1
  29. package/lib/constants/pools/fraxtal.js +1 -1
  30. package/lib/constants/pools/kava.js +1 -1
  31. package/lib/constants/pools/mantle.js +1 -1
  32. package/lib/constants/pools/moonbeam.js +1 -1
  33. package/lib/constants/pools/optimism.js +1 -1
  34. package/lib/constants/pools/polygon.js +1 -1
  35. package/lib/constants/pools/xdai.js +1 -1
  36. package/lib/constants/pools/xlayer.js +1 -1
  37. package/lib/constants/pools/zksync.js +1 -1
  38. package/lib/constants/tricryptoDeployImplementations.js +3 -3
  39. package/lib/constants/utils.js +18 -19
  40. package/lib/constants/volumeNetworks.js +1 -1
  41. package/lib/curve.d.ts +3 -1
  42. package/lib/curve.js +534 -909
  43. package/lib/dao.js +351 -705
  44. package/lib/external-api.js +127 -256
  45. package/lib/factory/common.js +4 -4
  46. package/lib/factory/constants-crypto.js +33 -33
  47. package/lib/factory/constants.js +36 -46
  48. package/lib/factory/deploy.js +542 -907
  49. package/lib/factory/factory-api.js +205 -269
  50. package/lib/factory/factory-crypto.js +202 -342
  51. package/lib/factory/factory-tricrypto.js +164 -286
  52. package/lib/factory/factory-twocrypto.js +151 -269
  53. package/lib/factory/factory.js +245 -385
  54. package/lib/index.js +109 -198
  55. package/lib/interfaces.d.ts +1 -6
  56. package/lib/pools/PoolTemplate.js +1773 -3025
  57. package/lib/pools/gaugePool.js +112 -251
  58. package/lib/pools/mixins/common.js +22 -93
  59. package/lib/pools/mixins/depositBalancedAmountsMixins.js +52 -118
  60. package/lib/pools/mixins/depositMixins.js +160 -386
  61. package/lib/pools/mixins/depositWrappedMixins.js +79 -205
  62. package/lib/pools/mixins/poolBalancesMixin.js +24 -87
  63. package/lib/pools/mixins/swapMixins.js +139 -324
  64. package/lib/pools/mixins/swapWrappedMixins.js +111 -265
  65. package/lib/pools/mixins/withdrawExpectedMixins.js +27 -91
  66. package/lib/pools/mixins/withdrawImbalanceMixins.js +111 -293
  67. package/lib/pools/mixins/withdrawImbalanceWrappedMixins.js +58 -169
  68. package/lib/pools/mixins/withdrawMixins.js +139 -359
  69. package/lib/pools/mixins/withdrawOneCoinExpectedMixins.js +20 -75
  70. package/lib/pools/mixins/withdrawOneCoinMixins.js +140 -360
  71. package/lib/pools/mixins/withdrawOneCoinWrappedExpectedMixins.js +10 -51
  72. package/lib/pools/mixins/withdrawOneCoinWrappedMixins.js +60 -167
  73. package/lib/pools/mixins/withdrawWrappedMixins.js +57 -167
  74. package/lib/pools/poolConstructor.js +5 -25
  75. package/lib/pools/utils.js +301 -469
  76. package/lib/route-finder.worker.d.ts +9 -0
  77. package/lib/route-finder.worker.js +112 -0
  78. package/lib/route-graph.worker.d.ts +11 -0
  79. package/lib/route-graph.worker.js +334 -0
  80. package/lib/router.js +323 -912
  81. package/lib/utils.d.ts +5 -4
  82. package/lib/utils.js +539 -906
  83. package/package.json +1 -1
@@ -1,14 +1,3 @@
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
1
  var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
13
2
  function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
14
3
  return new (P || (P = Promise))(function (resolve, reject) {
@@ -18,42 +7,6 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
18
7
  step((generator = generator.apply(thisArg, _arguments || [])).next());
19
8
  });
20
9
  };
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
- };
57
10
  import { curve } from "../curve.js";
58
11
  import factoryGaugeABI from "../constants/abis/gauge_factory.json" assert { type: 'json' };
59
12
  import gaugeChildABI from "../constants/abis/gauge_child.json" assert { type: 'json' };
@@ -68,10 +21,9 @@ import { getPoolIdByAddress, setFactoryZapContracts } from "./common.js";
68
21
  import { _getPoolsFromApi } from "../external-api.js";
69
22
  import { assetTypeNameHandler, getPoolName, isStableNgPool } from "../utils.js";
70
23
  import { tricryptoDeployImplementations } from "../constants/tricryptoDeployImplementations.js";
71
- export var lowerCasePoolDataAddresses = function (poolsData) {
24
+ export const lowerCasePoolDataAddresses = (poolsData) => {
72
25
  var _a;
73
- for (var _i = 0, poolsData_1 = poolsData; _i < poolsData_1.length; _i++) {
74
- var poolData = poolsData_1[_i];
26
+ for (const poolData of poolsData) {
75
27
  poolData.address = poolData.address.toLowerCase();
76
28
  if (poolData.lpTokenAddress)
77
29
  poolData.lpTokenAddress = poolData.lpTokenAddress.toLowerCase();
@@ -79,12 +31,10 @@ export var lowerCasePoolDataAddresses = function (poolsData) {
79
31
  poolData.gaugeAddress = poolData.gaugeAddress.toLowerCase();
80
32
  if (poolData.implementationAddress)
81
33
  poolData.implementationAddress = poolData.implementationAddress.toLowerCase();
82
- for (var _b = 0, _c = poolData.coins; _b < _c.length; _b++) {
83
- var coin = _c[_b];
34
+ for (const coin of poolData.coins) {
84
35
  coin.address = coin.address.toLowerCase();
85
36
  }
86
- for (var _d = 0, _e = (_a = poolData.gaugeRewards) !== null && _a !== void 0 ? _a : []; _d < _e.length; _d++) {
87
- var reward = _e[_d];
37
+ for (const reward of (_a = poolData.gaugeRewards) !== null && _a !== void 0 ? _a : []) {
88
38
  reward.gaugeAddress = reward.gaugeAddress.toLowerCase();
89
39
  reward.tokenAddress = reward.tokenAddress.toLowerCase();
90
40
  }
@@ -92,62 +42,57 @@ export var lowerCasePoolDataAddresses = function (poolsData) {
92
42
  return poolsData;
93
43
  };
94
44
  function setFactorySwapContracts(rawPoolList, factoryType) {
95
- var _this = this;
96
45
  if (factoryType === "factory-crypto") {
97
- rawPoolList.forEach(function (pool) {
98
- _this.setContract(pool.address, cryptoFactorySwapABI);
46
+ rawPoolList.forEach((pool) => {
47
+ this.setContract(pool.address, cryptoFactorySwapABI);
99
48
  });
100
49
  }
101
50
  else if (factoryType === "factory-twocrypto") {
102
- rawPoolList.forEach(function (pool) {
103
- _this.setContract(pool.address, twocryptoFactorySwapABI);
51
+ rawPoolList.forEach((pool) => {
52
+ this.setContract(pool.address, twocryptoFactorySwapABI);
104
53
  });
105
54
  }
106
55
  else if (factoryType === "factory-tricrypto") {
107
- rawPoolList.forEach(function (pool) {
56
+ rawPoolList.forEach((pool) => {
108
57
  if (pool.implementationAddress === tricryptoDeployImplementations[curve.chainId].amm_native_transfers_disabled) {
109
- _this.setContract(pool.address, tricryptoFactoryEthDisabledSwapABI);
58
+ this.setContract(pool.address, tricryptoFactoryEthDisabledSwapABI);
110
59
  }
111
60
  else {
112
- _this.setContract(pool.address, tricryptoFactorySwapABI);
61
+ this.setContract(pool.address, tricryptoFactorySwapABI);
113
62
  }
114
63
  });
115
64
  }
116
65
  else {
117
- var implementationABIDict_1 = FACTORY_CONSTANTS[this.chainId].implementationABIDict;
118
- rawPoolList.forEach(function (pool) {
119
- _this.setContract(pool.address, implementationABIDict_1[pool.implementationAddress]);
66
+ const implementationABIDict = FACTORY_CONSTANTS[this.chainId].implementationABIDict;
67
+ rawPoolList.forEach((pool) => {
68
+ this.setContract(pool.address, implementationABIDict[pool.implementationAddress]);
120
69
  });
121
70
  }
122
71
  }
123
72
  function setCryptoFactoryTokenContracts(rawPoolList) {
124
- var _this = this;
125
- rawPoolList.forEach(function (pool) {
126
- _this.setContract(pool.lpTokenAddress, ERC20ABI);
73
+ rawPoolList.forEach((pool) => {
74
+ this.setContract(pool.lpTokenAddress, ERC20ABI);
127
75
  });
128
76
  }
129
77
  function setFactoryGaugeContracts(rawPoolList) {
130
- var _this = this;
131
- rawPoolList.forEach(function (pool) {
78
+ rawPoolList.forEach((pool) => {
132
79
  if (pool.gaugeAddress) {
133
- _this.setContract(pool.gaugeAddress, _this.chainId === 1 ? factoryGaugeABI : gaugeChildABI);
80
+ this.setContract(pool.gaugeAddress, this.chainId === 1 ? factoryGaugeABI : gaugeChildABI);
134
81
  }
135
82
  });
136
83
  }
137
84
  function setFactoryCoinsContracts(rawPoolList) {
138
- for (var _i = 0, rawPoolList_1 = rawPoolList; _i < rawPoolList_1.length; _i++) {
139
- var pool = rawPoolList_1[_i];
140
- for (var _a = 0, _b = pool.coins; _a < _b.length; _a++) {
141
- var coin = _b[_a];
85
+ for (const pool of rawPoolList) {
86
+ for (const coin of pool.coins) {
142
87
  if (coin.address in this.contracts)
143
88
  continue;
144
89
  this.setContract(coin.address, ERC20ABI);
145
90
  }
146
91
  }
147
92
  }
148
- var getSwapAbiByFactoryType = function (factoryType, pool) {
149
- var isETHDisabled = pool.implementationAddress === tricryptoDeployImplementations[curve.chainId].amm_native_transfers_disabled;
150
- var map = {
93
+ const getSwapAbiByFactoryType = (factoryType, pool) => {
94
+ const isETHDisabled = pool.implementationAddress === tricryptoDeployImplementations[curve.chainId].amm_native_transfers_disabled;
95
+ const map = {
151
96
  "factory-crypto": cryptoFactorySwapABI,
152
97
  "factory-twocrypto": twocryptoFactorySwapABI,
153
98
  "facroty-tricrypto": isETHDisabled ? tricryptoFactoryEthDisabledSwapABI : tricryptoFactorySwapABI,
@@ -155,204 +100,195 @@ var getSwapAbiByFactoryType = function (factoryType, pool) {
155
100
  return map[factoryType];
156
101
  };
157
102
  export function getFactoryPoolsDataFromApi(factoryType) {
158
- return __awaiter(this, void 0, void 0, function () {
159
- var network, isCrypto, rawPoolList, _a, mainAddresses, FACTORY_POOLS_DATA;
160
- var _this = this;
161
- return __generator(this, function (_b) {
162
- switch (_b.label) {
163
- case 0:
164
- network = this.constants.NETWORK_NAME;
165
- isCrypto = factoryType === "factory-crypto" || factoryType === "factory-twocrypto" || factoryType === "factory-tricrypto";
166
- _a = lowerCasePoolDataAddresses;
167
- return [4 /*yield*/, _getPoolsFromApi(network, factoryType)];
168
- case 1:
169
- rawPoolList = _a.apply(void 0, [(_b.sent()).poolData]);
170
- if (!isCrypto) {
171
- rawPoolList = rawPoolList.filter(function (p) { return p.implementationAddress in FACTORY_CONSTANTS[_this.chainId].implementationABIDict; });
103
+ return __awaiter(this, void 0, void 0, function* () {
104
+ const network = this.constants.NETWORK_NAME;
105
+ const isCrypto = factoryType === "factory-crypto" || factoryType === "factory-twocrypto" || factoryType === "factory-tricrypto";
106
+ let rawPoolList = lowerCasePoolDataAddresses((yield _getPoolsFromApi(network, factoryType)).poolData);
107
+ if (!isCrypto) {
108
+ rawPoolList = rawPoolList.filter((p) => p.implementationAddress in FACTORY_CONSTANTS[this.chainId].implementationABIDict);
109
+ }
110
+ // Filter duplications
111
+ const mainAddresses = Object.values(this.constants.POOLS_DATA).map((pool) => pool.swap_address);
112
+ rawPoolList = rawPoolList.filter((p) => !mainAddresses.includes(p.address));
113
+ setFactorySwapContracts.call(this, rawPoolList, factoryType);
114
+ if (factoryType === "factory-crypto")
115
+ setCryptoFactoryTokenContracts.call(this, rawPoolList);
116
+ setFactoryGaugeContracts.call(this, rawPoolList);
117
+ setFactoryCoinsContracts.call(this, rawPoolList);
118
+ setFactoryZapContracts.call(this, isCrypto);
119
+ const FACTORY_POOLS_DATA = {};
120
+ rawPoolList.forEach((pool) => {
121
+ var _a, _b, _c;
122
+ const nativeToken = this.constants.NATIVE_TOKEN;
123
+ let coinAddresses = pool.coins.map((c) => c.address);
124
+ if (this.chainId === 137) {
125
+ coinAddresses = coinAddresses.map((a) => a === "0x0000000000000000000000000000000000001010" ? nativeToken.wrappedAddress : a);
126
+ }
127
+ const coinNames = pool.coins.map((c) => c.symbol);
128
+ const coinDecimals = pool.coins.map((c) => Number(c.decimals));
129
+ if (isCrypto) {
130
+ const wrappedCoinNames = pool.coins.map((c) => c.symbol === nativeToken.symbol ? nativeToken.wrappedSymbol : c.symbol);
131
+ const underlyingCoinNames = pool.coins.map((c) => {
132
+ if (factoryType === 'factory-twocrypto') {
133
+ return c.symbol;
172
134
  }
173
- mainAddresses = Object.values(this.constants.POOLS_DATA).map(function (pool) { return pool.swap_address; });
174
- rawPoolList = rawPoolList.filter(function (p) { return !mainAddresses.includes(p.address); });
175
- setFactorySwapContracts.call(this, rawPoolList, factoryType);
176
- if (factoryType === "factory-crypto")
177
- setCryptoFactoryTokenContracts.call(this, rawPoolList);
178
- setFactoryGaugeContracts.call(this, rawPoolList);
179
- setFactoryCoinsContracts.call(this, rawPoolList);
180
- setFactoryZapContracts.call(this, isCrypto);
181
- FACTORY_POOLS_DATA = {};
182
- rawPoolList.forEach(function (pool) {
183
- var _a, _b, _c;
184
- var nativeToken = _this.constants.NATIVE_TOKEN;
185
- var coinAddresses = pool.coins.map(function (c) { return c.address; });
186
- if (_this.chainId === 137) {
187
- coinAddresses = coinAddresses.map(function (a) { return a === "0x0000000000000000000000000000000000001010" ? nativeToken.wrappedAddress : a; });
135
+ else if (factoryType === 'factory-tricrypto') {
136
+ const isETHEnabled = pool.implementationAddress === tricryptoDeployImplementations[curve.chainId].amm_native_transfers_enabled;
137
+ if (isETHEnabled) {
138
+ return c.symbol === nativeToken.wrappedSymbol ? nativeToken.symbol : c.symbol;
188
139
  }
189
- var coinNames = pool.coins.map(function (c) { return c.symbol; });
190
- var coinDecimals = pool.coins.map(function (c) { return Number(c.decimals); });
191
- if (isCrypto) {
192
- var wrappedCoinNames = pool.coins.map(function (c) { return c.symbol === nativeToken.symbol ? nativeToken.wrappedSymbol : c.symbol; });
193
- var underlyingCoinNames = pool.coins.map(function (c) {
194
- if (factoryType === 'factory-twocrypto') {
195
- return c.symbol;
196
- }
197
- else if (factoryType === 'factory-tricrypto') {
198
- var isETHEnabled = pool.implementationAddress === tricryptoDeployImplementations[curve.chainId].amm_native_transfers_enabled;
199
- if (isETHEnabled) {
200
- return c.symbol === nativeToken.wrappedSymbol ? nativeToken.symbol : c.symbol;
201
- }
202
- else {
203
- return c.symbol;
204
- }
205
- }
206
- else {
207
- return c.symbol === nativeToken.wrappedSymbol ? nativeToken.symbol : c.symbol;
208
- }
209
- });
210
- var underlyingCoinAddresses = coinAddresses.map(function (addr) {
211
- if (factoryType === 'factory-twocrypto') {
212
- return addr;
213
- }
214
- else if (factoryType === 'factory-tricrypto') {
215
- var isETHEnabled = pool.implementationAddress === tricryptoDeployImplementations[curve.chainId].amm_native_transfers_enabled;
216
- if (isETHEnabled) {
217
- return addr === nativeToken.wrappedAddress ? nativeToken.address : addr;
218
- }
219
- else {
220
- return addr;
221
- }
222
- }
223
- else {
224
- return addr === nativeToken.wrappedAddress ? nativeToken.address : addr;
225
- }
226
- });
227
- var isPlain = underlyingCoinNames.toString() === wrappedCoinNames.toString();
228
- var lpTokenBasePoolIdDict = CRYPTO_FACTORY_CONSTANTS[_this.chainId].lpTokenBasePoolIdDict;
229
- var basePoolIdZapDict = CRYPTO_FACTORY_CONSTANTS[_this.chainId].basePoolIdZapDict;
230
- var basePoolId = lpTokenBasePoolIdDict[coinAddresses[1]];
231
- if (factoryType !== "factory-tricrypto" && factoryType !== "factory-twocrypto" && basePoolId) { // isMeta
232
- var allPoolsData = __assign(__assign({}, _this.constants.POOLS_DATA), FACTORY_POOLS_DATA);
233
- var basePoolCoinNames = __spreadArray([], allPoolsData[basePoolId].underlying_coins, true);
234
- var basePoolCoinAddresses = __spreadArray([], allPoolsData[basePoolId].underlying_coin_addresses, true);
235
- var basePoolDecimals = __spreadArray([], allPoolsData[basePoolId].underlying_decimals, true);
236
- var basePoolZap = basePoolIdZapDict[basePoolId];
237
- _this.constants.BASE_POOLS[basePoolId] = _this.constants.BASE_POOLS[basePoolId] ? _this.constants.BASE_POOLS[basePoolId] + 1 : 1;
238
- FACTORY_POOLS_DATA[pool.id] = {
239
- name: getPoolName(pool.name),
240
- full_name: pool.name,
241
- symbol: pool.symbol,
242
- reference_asset: "CRYPTO",
243
- swap_address: pool.address,
244
- token_address: pool.lpTokenAddress,
245
- gauge_address: pool.gaugeAddress ? pool.gaugeAddress : curve.constants.ZERO_ADDRESS,
246
- deposit_address: basePoolZap.address,
247
- is_meta: true,
248
- is_crypto: true,
249
- is_factory: true,
250
- base_pool: basePoolId,
251
- underlying_coins: __spreadArray([underlyingCoinNames[0]], basePoolCoinNames, true),
252
- wrapped_coins: wrappedCoinNames,
253
- underlying_coin_addresses: __spreadArray([underlyingCoinAddresses[0]], basePoolCoinAddresses, true),
254
- wrapped_coin_addresses: coinAddresses,
255
- underlying_decimals: __spreadArray([coinDecimals[0]], basePoolDecimals, true),
256
- wrapped_decimals: coinDecimals,
257
- swap_abi: cryptoFactorySwapABI,
258
- gauge_abi: _this.chainId === 1 ? factoryGaugeABI : gaugeChildABI,
259
- deposit_abi: basePoolZap.ABI,
260
- in_api: true,
261
- is_ng: false,
262
- };
263
- }
264
- else {
265
- FACTORY_POOLS_DATA[pool.id] = {
266
- name: factoryType === "factory-tricrypto" ? pool.name : getPoolName(pool.name),
267
- full_name: pool.name,
268
- symbol: pool.symbol,
269
- reference_asset: "CRYPTO",
270
- swap_address: pool.address,
271
- token_address: pool.lpTokenAddress,
272
- gauge_address: pool.gaugeAddress ? pool.gaugeAddress : curve.constants.ZERO_ADDRESS,
273
- is_crypto: true,
274
- is_plain: isPlain,
275
- is_factory: true,
276
- underlying_coins: underlyingCoinNames,
277
- wrapped_coins: wrappedCoinNames,
278
- underlying_coin_addresses: underlyingCoinAddresses,
279
- wrapped_coin_addresses: coinAddresses,
280
- underlying_decimals: coinDecimals,
281
- wrapped_decimals: coinDecimals,
282
- swap_abi: getSwapAbiByFactoryType(factoryType, pool),
283
- gauge_abi: _this.chainId === 1 ? factoryGaugeABI : gaugeChildABI,
284
- in_api: true,
285
- is_ng: factoryType === "factory-tricrypto" || factoryType === "factory-twocrypto",
286
- };
287
- }
140
+ else {
141
+ return c.symbol;
288
142
  }
289
- else if (pool.isMetaPool) {
290
- var implementationABIDict = FACTORY_CONSTANTS[_this.chainId].implementationABIDict;
291
- var allPoolsData = __assign(__assign({}, _this.constants.POOLS_DATA), FACTORY_POOLS_DATA);
292
- var basePoolId = getPoolIdByAddress(rawPoolList, pool.basePoolAddress);
293
- _this.constants.BASE_POOLS[basePoolId] = _this.constants.BASE_POOLS[basePoolId] ? _this.constants.BASE_POOLS[basePoolId] + 1 : 1;
294
- var basePoolCoinNames = (_a = allPoolsData[basePoolId]) === null || _a === void 0 ? void 0 : _a.underlying_coins;
295
- var basePoolCoinAddresses = (_b = allPoolsData[basePoolId]) === null || _b === void 0 ? void 0 : _b.underlying_coin_addresses;
296
- var basePoolDecimals = (_c = allPoolsData[basePoolId]) === null || _c === void 0 ? void 0 : _c.underlying_decimals;
297
- var basePoolIdZapDict = FACTORY_CONSTANTS[_this.chainId].basePoolIdZapDict;
298
- var basePoolZap = isStableNgPool(basePoolId) ? FACTORY_CONSTANTS[_this.chainId].stableNgBasePoolZap : basePoolIdZapDict[basePoolId];
299
- if (isStableNgPool(basePoolId)) {
300
- _this.setContract(FACTORY_CONSTANTS[_this.chainId].stableNgBasePoolZap.address, FACTORY_CONSTANTS[_this.chainId].stableNgBasePoolZap.ABI);
301
- }
302
- FACTORY_POOLS_DATA[pool.id] = {
303
- name: getPoolName(pool.name),
304
- full_name: pool.name,
305
- symbol: pool.symbol,
306
- reference_asset: assetTypeNameHandler(pool.assetTypeName),
307
- swap_address: pool.address,
308
- token_address: pool.address,
309
- gauge_address: pool.gaugeAddress ? pool.gaugeAddress : curve.constants.ZERO_ADDRESS,
310
- deposit_address: basePoolZap.address,
311
- implementation_address: pool.implementationAddress,
312
- is_meta: true,
313
- is_factory: true,
314
- base_pool: basePoolId,
315
- underlying_coins: __spreadArray([coinNames[0]], basePoolCoinNames, true),
316
- wrapped_coins: coinNames,
317
- underlying_coin_addresses: __spreadArray([coinAddresses[0]], basePoolCoinAddresses, true),
318
- wrapped_coin_addresses: coinAddresses,
319
- underlying_decimals: __spreadArray([coinDecimals[0]], basePoolDecimals, true),
320
- wrapped_decimals: coinDecimals,
321
- swap_abi: implementationABIDict[pool.implementationAddress],
322
- gauge_abi: _this.chainId === 1 ? factoryGaugeABI : gaugeChildABI,
323
- deposit_abi: basePoolZap.ABI,
324
- in_api: true,
325
- is_ng: factoryType === 'factory-stable-ng',
326
- };
143
+ }
144
+ else {
145
+ return c.symbol === nativeToken.wrappedSymbol ? nativeToken.symbol : c.symbol;
146
+ }
147
+ });
148
+ const underlyingCoinAddresses = coinAddresses.map((addr) => {
149
+ if (factoryType === 'factory-twocrypto') {
150
+ return addr;
151
+ }
152
+ else if (factoryType === 'factory-tricrypto') {
153
+ const isETHEnabled = pool.implementationAddress === tricryptoDeployImplementations[curve.chainId].amm_native_transfers_enabled;
154
+ if (isETHEnabled) {
155
+ return addr === nativeToken.wrappedAddress ? nativeToken.address : addr;
327
156
  }
328
157
  else {
329
- var implementationABIDict = FACTORY_CONSTANTS[_this.chainId].implementationABIDict;
330
- FACTORY_POOLS_DATA[pool.id] = {
331
- name: getPoolName(pool.name),
332
- full_name: pool.name,
333
- symbol: pool.symbol,
334
- reference_asset: assetTypeNameHandler(pool.assetTypeName),
335
- swap_address: pool.address,
336
- token_address: pool.address,
337
- gauge_address: pool.gaugeAddress ? pool.gaugeAddress : curve.constants.ZERO_ADDRESS,
338
- implementation_address: pool.implementationAddress,
339
- is_plain: true,
340
- is_factory: true,
341
- underlying_coins: coinNames,
342
- wrapped_coins: coinNames,
343
- underlying_coin_addresses: coinAddresses,
344
- wrapped_coin_addresses: coinAddresses,
345
- underlying_decimals: coinDecimals,
346
- wrapped_decimals: coinDecimals,
347
- swap_abi: implementationABIDict[pool.implementationAddress],
348
- gauge_abi: _this.chainId === 1 ? factoryGaugeABI : gaugeChildABI,
349
- in_api: true,
350
- is_ng: factoryType === 'factory-stable-ng',
351
- };
158
+ return addr;
352
159
  }
353
- });
354
- return [2 /*return*/, FACTORY_POOLS_DATA];
160
+ }
161
+ else {
162
+ return addr === nativeToken.wrappedAddress ? nativeToken.address : addr;
163
+ }
164
+ });
165
+ const isPlain = underlyingCoinNames.toString() === wrappedCoinNames.toString();
166
+ const lpTokenBasePoolIdDict = CRYPTO_FACTORY_CONSTANTS[this.chainId].lpTokenBasePoolIdDict;
167
+ const basePoolIdZapDict = CRYPTO_FACTORY_CONSTANTS[this.chainId].basePoolIdZapDict;
168
+ const basePoolId = lpTokenBasePoolIdDict[coinAddresses[1]];
169
+ if (factoryType !== "factory-tricrypto" && factoryType !== "factory-twocrypto" && basePoolId) { // isMeta
170
+ const allPoolsData = Object.assign(Object.assign({}, this.constants.POOLS_DATA), FACTORY_POOLS_DATA);
171
+ const basePoolCoinNames = [...allPoolsData[basePoolId].underlying_coins];
172
+ const basePoolCoinAddresses = [...allPoolsData[basePoolId].underlying_coin_addresses];
173
+ const basePoolDecimals = [...allPoolsData[basePoolId].underlying_decimals];
174
+ const basePoolZap = basePoolIdZapDict[basePoolId];
175
+ this.constants.BASE_POOLS[basePoolId] = this.constants.BASE_POOLS[basePoolId] ? this.constants.BASE_POOLS[basePoolId] + 1 : 1;
176
+ FACTORY_POOLS_DATA[pool.id] = {
177
+ name: getPoolName(pool.name),
178
+ full_name: pool.name,
179
+ symbol: pool.symbol,
180
+ reference_asset: "CRYPTO",
181
+ swap_address: pool.address,
182
+ token_address: pool.lpTokenAddress,
183
+ gauge_address: pool.gaugeAddress ? pool.gaugeAddress : curve.constants.ZERO_ADDRESS,
184
+ deposit_address: basePoolZap.address,
185
+ is_meta: true,
186
+ is_crypto: true,
187
+ is_factory: true,
188
+ base_pool: basePoolId,
189
+ underlying_coins: [underlyingCoinNames[0], ...basePoolCoinNames],
190
+ wrapped_coins: wrappedCoinNames,
191
+ underlying_coin_addresses: [underlyingCoinAddresses[0], ...basePoolCoinAddresses],
192
+ wrapped_coin_addresses: coinAddresses,
193
+ underlying_decimals: [coinDecimals[0], ...basePoolDecimals],
194
+ wrapped_decimals: coinDecimals,
195
+ swap_abi: cryptoFactorySwapABI,
196
+ gauge_abi: this.chainId === 1 ? factoryGaugeABI : gaugeChildABI,
197
+ deposit_abi: basePoolZap.ABI,
198
+ in_api: true,
199
+ is_ng: false,
200
+ };
201
+ }
202
+ else {
203
+ FACTORY_POOLS_DATA[pool.id] = {
204
+ name: factoryType === "factory-tricrypto" ? pool.name : getPoolName(pool.name),
205
+ full_name: pool.name,
206
+ symbol: pool.symbol,
207
+ reference_asset: "CRYPTO",
208
+ swap_address: pool.address,
209
+ token_address: pool.lpTokenAddress,
210
+ gauge_address: pool.gaugeAddress ? pool.gaugeAddress : curve.constants.ZERO_ADDRESS,
211
+ is_crypto: true,
212
+ is_plain: isPlain,
213
+ is_factory: true,
214
+ underlying_coins: underlyingCoinNames,
215
+ wrapped_coins: wrappedCoinNames,
216
+ underlying_coin_addresses: underlyingCoinAddresses,
217
+ wrapped_coin_addresses: coinAddresses,
218
+ underlying_decimals: coinDecimals,
219
+ wrapped_decimals: coinDecimals,
220
+ swap_abi: getSwapAbiByFactoryType(factoryType, pool),
221
+ gauge_abi: this.chainId === 1 ? factoryGaugeABI : gaugeChildABI,
222
+ in_api: true,
223
+ is_ng: factoryType === "factory-tricrypto" || factoryType === "factory-twocrypto",
224
+ };
225
+ }
226
+ }
227
+ else if (pool.isMetaPool) {
228
+ const implementationABIDict = FACTORY_CONSTANTS[this.chainId].implementationABIDict;
229
+ const allPoolsData = Object.assign(Object.assign({}, this.constants.POOLS_DATA), FACTORY_POOLS_DATA);
230
+ const basePoolId = getPoolIdByAddress(rawPoolList, pool.basePoolAddress);
231
+ this.constants.BASE_POOLS[basePoolId] = this.constants.BASE_POOLS[basePoolId] ? this.constants.BASE_POOLS[basePoolId] + 1 : 1;
232
+ const basePoolCoinNames = (_a = allPoolsData[basePoolId]) === null || _a === void 0 ? void 0 : _a.underlying_coins;
233
+ const basePoolCoinAddresses = (_b = allPoolsData[basePoolId]) === null || _b === void 0 ? void 0 : _b.underlying_coin_addresses;
234
+ const basePoolDecimals = (_c = allPoolsData[basePoolId]) === null || _c === void 0 ? void 0 : _c.underlying_decimals;
235
+ const basePoolIdZapDict = FACTORY_CONSTANTS[this.chainId].basePoolIdZapDict;
236
+ const basePoolZap = isStableNgPool(basePoolId) ? FACTORY_CONSTANTS[this.chainId].stableNgBasePoolZap : basePoolIdZapDict[basePoolId];
237
+ if (isStableNgPool(basePoolId)) {
238
+ this.setContract(FACTORY_CONSTANTS[this.chainId].stableNgBasePoolZap.address, FACTORY_CONSTANTS[this.chainId].stableNgBasePoolZap.ABI);
239
+ }
240
+ FACTORY_POOLS_DATA[pool.id] = {
241
+ name: getPoolName(pool.name),
242
+ full_name: pool.name,
243
+ symbol: pool.symbol,
244
+ reference_asset: assetTypeNameHandler(pool.assetTypeName),
245
+ swap_address: pool.address,
246
+ token_address: pool.address,
247
+ gauge_address: pool.gaugeAddress ? pool.gaugeAddress : curve.constants.ZERO_ADDRESS,
248
+ deposit_address: basePoolZap.address,
249
+ implementation_address: pool.implementationAddress,
250
+ is_meta: true,
251
+ is_factory: true,
252
+ base_pool: basePoolId,
253
+ underlying_coins: [coinNames[0], ...basePoolCoinNames],
254
+ wrapped_coins: coinNames,
255
+ underlying_coin_addresses: [coinAddresses[0], ...basePoolCoinAddresses],
256
+ wrapped_coin_addresses: coinAddresses,
257
+ underlying_decimals: [coinDecimals[0], ...basePoolDecimals],
258
+ wrapped_decimals: coinDecimals,
259
+ swap_abi: implementationABIDict[pool.implementationAddress],
260
+ gauge_abi: this.chainId === 1 ? factoryGaugeABI : gaugeChildABI,
261
+ deposit_abi: basePoolZap.ABI,
262
+ in_api: true,
263
+ is_ng: factoryType === 'factory-stable-ng',
264
+ };
265
+ }
266
+ else {
267
+ const implementationABIDict = FACTORY_CONSTANTS[this.chainId].implementationABIDict;
268
+ FACTORY_POOLS_DATA[pool.id] = {
269
+ name: getPoolName(pool.name),
270
+ full_name: pool.name,
271
+ symbol: pool.symbol,
272
+ reference_asset: assetTypeNameHandler(pool.assetTypeName),
273
+ swap_address: pool.address,
274
+ token_address: pool.address,
275
+ gauge_address: pool.gaugeAddress ? pool.gaugeAddress : curve.constants.ZERO_ADDRESS,
276
+ implementation_address: pool.implementationAddress,
277
+ is_plain: true,
278
+ is_factory: true,
279
+ underlying_coins: coinNames,
280
+ wrapped_coins: coinNames,
281
+ underlying_coin_addresses: coinAddresses,
282
+ wrapped_coin_addresses: coinAddresses,
283
+ underlying_decimals: coinDecimals,
284
+ wrapped_decimals: coinDecimals,
285
+ swap_abi: implementationABIDict[pool.implementationAddress],
286
+ gauge_abi: this.chainId === 1 ? factoryGaugeABI : gaugeChildABI,
287
+ in_api: true,
288
+ is_ng: factoryType === 'factory-stable-ng',
289
+ };
355
290
  }
356
291
  });
292
+ return FACTORY_POOLS_DATA;
357
293
  });
358
294
  }