@curvefi/api 2.4.2 → 2.4.3

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.
@@ -23,7 +23,7 @@ exports.ALIASES_POLYGON = (0, utils_1.lowerCaseValues)({
23
23
  "router": "0xfA9a30350048B2BF66865ee20363067c66f67e58",
24
24
  "deposit_and_stake": "0x43FF7b96808988C9d19C1d05Ef19658B03e8a143",
25
25
  "factory": '0x722272d36ef0da72ff51c5a65db7b870e2e8d4ee',
26
- "crypto_factory": '0xF18056Bbd320E96A48e3Fbf8bC061322531aac99',
26
+ "crypto_factory": "0xE5De15A9C9bBedb4F5EC13B131E61245f2983A69",
27
27
  "registry_exchange": "",
28
28
  });
29
29
  exports.ALIASES_AVALANCHE = (0, utils_1.lowerCaseValues)({
package/lib/curve.js CHANGED
@@ -451,7 +451,7 @@ var Curve = /** @class */ (function () {
451
451
  return __generator(this, function (_e) {
452
452
  switch (_e.label) {
453
453
  case 0:
454
- if (this.chainId !== 1 && this.chainId !== 1337)
454
+ if (this.chainId !== 1 && this.chainId !== 137)
455
455
  return [2 /*return*/];
456
456
  if (!useApi) return [3 /*break*/, 2];
457
457
  _a = this.constants;
@@ -8,8 +8,14 @@ export declare const implementationBasePoolIdDictAvalanche: IDict<string>;
8
8
  export declare const basePoolIdZapDictEthereum: IDict<string>;
9
9
  export declare const basePoolIdZapDictPolygon: IDict<string>;
10
10
  export declare const basePoolIdZapDictAvalanche: IDict<string>;
11
- export declare const WETH_ADDRESS = "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2";
12
- export declare const ETH_ADDRESS = "0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee";
11
+ export declare const NATIVE_TOKEN_ADDRESS = "0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee";
12
+ export declare const NATIVE_TOKENS: {
13
+ [index: number]: {
14
+ symbol: string;
15
+ wrappedSymbol: string;
16
+ wrappedAddress: string;
17
+ };
18
+ };
13
19
  export declare const FACTORY_CONSTANTS: {
14
20
  [index: number]: {
15
21
  implementationABIDict: IDict<any>;
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.FACTORY_CONSTANTS = exports.ETH_ADDRESS = exports.WETH_ADDRESS = exports.basePoolIdZapDictAvalanche = exports.basePoolIdZapDictPolygon = exports.basePoolIdZapDictEthereum = exports.implementationBasePoolIdDictAvalanche = exports.implementationBasePoolIdDictPolygon = exports.implementationBasePoolIdDictEthereum = exports.implementationABIDictAvalanche = exports.implementationABIDictPolygon = exports.implementationABIDictEthereum = void 0;
6
+ exports.FACTORY_CONSTANTS = exports.NATIVE_TOKENS = exports.NATIVE_TOKEN_ADDRESS = exports.basePoolIdZapDictAvalanche = exports.basePoolIdZapDictPolygon = exports.basePoolIdZapDictEthereum = exports.implementationBasePoolIdDictAvalanche = exports.implementationBasePoolIdDictPolygon = exports.implementationBasePoolIdDictEthereum = exports.implementationABIDictAvalanche = exports.implementationABIDictPolygon = exports.implementationABIDictEthereum = void 0;
7
7
  var swap_json_1 = __importDefault(require("../constants/abis/factoryPools/swap.json"));
8
8
  var MetaUSD_json_1 = __importDefault(require("../constants/abis/factory-v2/MetaUSD.json"));
9
9
  var MetaUSDBalances_json_1 = __importDefault(require("../constants/abis/factory-v2/MetaUSDBalances.json"));
@@ -121,8 +121,19 @@ exports.basePoolIdZapDictAvalanche = {
121
121
  aave: "0x001E3BA199B4FF4B5B6e97aCD96daFC0E2e4156e".toLowerCase(),
122
122
  ren: "0xEeB3DDBcc4174e0b3fd1C13aD462b95D11Ef42C3".toLowerCase(),
123
123
  };
124
- exports.WETH_ADDRESS = "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2";
125
- exports.ETH_ADDRESS = "0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee";
124
+ exports.NATIVE_TOKEN_ADDRESS = "0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee";
125
+ exports.NATIVE_TOKENS = {
126
+ 1: {
127
+ symbol: 'ETH',
128
+ wrappedSymbol: 'WETH',
129
+ wrappedAddress: '0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
130
+ },
131
+ 137: {
132
+ symbol: 'MATIC',
133
+ wrappedSymbol: 'WMATIC',
134
+ wrappedAddress: '0x0d500b1d8e8ef31e21c99d1db9a6444d3adf1270',
135
+ },
136
+ };
126
137
  exports.FACTORY_CONSTANTS = {
127
138
  1: {
128
139
  implementationABIDict: exports.implementationABIDictEthereum,
@@ -162,10 +162,11 @@ function getFactoryPoolsDataFromApi(isCrypto) {
162
162
  var coinAddresses = pool.coins.map(function (c) { return c.address.toLowerCase(); });
163
163
  var coinNames = pool.coins.map(function (c) { return c.symbol; });
164
164
  var coinDecimals = pool.coins.map(function (c) { return Number(c.decimals); });
165
+ var nativeToken = constants_1.NATIVE_TOKENS[_this.chainId];
165
166
  if (isCrypto) {
166
- var cryptoCoinNames = pool.coins.map(function (c) { return c.symbol === "ETH" ? "WETH" : c.symbol; });
167
- var underlyingCoinNames = pool.coins.map(function (c) { return c.symbol === "WETH" ? "ETH" : c.symbol; });
168
- var underlyingCoinAddresses = pool.coins.map(function (c) { return c.address.toLowerCase() === constants_1.WETH_ADDRESS ? constants_1.ETH_ADDRESS : c.address.toLowerCase(); });
167
+ var cryptoCoinNames = pool.coins.map(function (c) { return c.symbol === nativeToken.symbol ? nativeToken.wrappedSymbol : c.symbol; });
168
+ var underlyingCoinNames = pool.coins.map(function (c) { return c.symbol === nativeToken.wrappedSymbol ? nativeToken.symbol : c.symbol; });
169
+ var underlyingCoinAddresses = coinAddresses.map(function (addr) { return addr === nativeToken.wrappedAddress ? constants_1.NATIVE_TOKEN_ADDRESS : addr; });
169
170
  FACTORY_POOLS_DATA[pool.id] = {
170
171
  name: pool.name.split(": ")[1].trim(),
171
172
  full_name: pool.name,
@@ -197,8 +197,9 @@ function setCryptoFactoryCoinsContracts(coinAddresses) {
197
197
  }
198
198
  function getCryptoFactoryUnderlyingCoinAddresses(coinAddresses) {
199
199
  return __awaiter(this, void 0, void 0, function () {
200
+ var _this = this;
200
201
  return __generator(this, function (_a) {
201
- return [2 /*return*/, coinAddresses.map(function (coins) { return coins.map(function (c) { return c === constants_1.WETH_ADDRESS ? "0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee" : c; }); })];
202
+ return [2 /*return*/, coinAddresses.map(function (coins) { return coins.map(function (c) { return c === constants_1.NATIVE_TOKENS[_this.chainId].wrappedAddress ? constants_1.NATIVE_TOKEN_ADDRESS : c; }); })];
202
203
  });
203
204
  });
204
205
  }
@@ -221,11 +222,11 @@ function getExistingCoinAddressNameDict() {
221
222
  _loop_1(poolData);
222
223
  }
223
224
  if (this.chainId === 1)
224
- dict["0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee"] = "ETH";
225
+ dict[constants_1.NATIVE_TOKEN_ADDRESS] = "ETH";
225
226
  if (this.chainId === 137)
226
- dict["0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee"] = "MATIC";
227
+ dict[constants_1.NATIVE_TOKEN_ADDRESS] = "MATIC";
227
228
  if (this.chainId === 43114)
228
- dict["0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee"] = "AVAX";
229
+ dict[constants_1.NATIVE_TOKEN_ADDRESS] = "AVAX";
229
230
  return dict;
230
231
  }
231
232
  function getCoinAddressNameDict(coinAddresses, existingCoinAddrNameDict) {
@@ -259,6 +260,7 @@ function getCoinAddressNameDict(coinAddresses, existingCoinAddrNameDict) {
259
260
  newCoinAddresses.forEach(function (addr, i) {
260
261
  coinAddrNamesDict[addr] = names[i];
261
262
  });
263
+ coinAddrNamesDict[constants_1.NATIVE_TOKEN_ADDRESS] = constants_1.NATIVE_TOKENS[this.chainId].symbol;
262
264
  return [2 /*return*/, coinAddrNamesDict];
263
265
  }
264
266
  });
@@ -266,18 +268,18 @@ function getCoinAddressNameDict(coinAddresses, existingCoinAddrNameDict) {
266
268
  }
267
269
  function getCoinAddressDecimalsDict(coinAddresses, existingCoinAddressDecimalsDict) {
268
270
  return __awaiter(this, void 0, void 0, function () {
269
- var flattenedCoinAddresses, newCoinAddresses, coinAddrNamesDict, _i, flattenedCoinAddresses_3, addr, calls, decimals;
271
+ var flattenedCoinAddresses, newCoinAddresses, coinAddressDecimalsDict, _i, flattenedCoinAddresses_3, addr, calls, decimals;
270
272
  var _this = this;
271
273
  return __generator(this, function (_a) {
272
274
  switch (_a.label) {
273
275
  case 0:
274
276
  flattenedCoinAddresses = Array.from(new Set(deepFlatten(coinAddresses)));
275
277
  newCoinAddresses = [];
276
- coinAddrNamesDict = {};
278
+ coinAddressDecimalsDict = {};
277
279
  for (_i = 0, flattenedCoinAddresses_3 = flattenedCoinAddresses; _i < flattenedCoinAddresses_3.length; _i++) {
278
280
  addr = flattenedCoinAddresses_3[_i];
279
281
  if (addr in existingCoinAddressDecimalsDict) {
280
- coinAddrNamesDict[addr] = existingCoinAddressDecimalsDict[addr];
282
+ coinAddressDecimalsDict[addr] = existingCoinAddressDecimalsDict[addr];
281
283
  }
282
284
  else {
283
285
  newCoinAddresses.push(addr);
@@ -290,10 +292,10 @@ function getCoinAddressDecimalsDict(coinAddresses, existingCoinAddressDecimalsDi
290
292
  case 1:
291
293
  decimals = (_a.sent()).map(function (_d) { return Number(ethers_1.ethers.utils.formatUnits(_d, 0)); });
292
294
  newCoinAddresses.forEach(function (addr, i) {
293
- coinAddrNamesDict[addr] = decimals[i];
295
+ coinAddressDecimalsDict[addr] = decimals[i];
294
296
  });
295
- coinAddrNamesDict['0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee'] = 18;
296
- return [2 /*return*/, coinAddrNamesDict];
297
+ coinAddressDecimalsDict[constants_1.NATIVE_TOKEN_ADDRESS] = 18;
298
+ return [2 /*return*/, coinAddressDecimalsDict];
297
299
  }
298
300
  });
299
301
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@curvefi/api",
3
- "version": "2.4.2",
3
+ "version": "2.4.3",
4
4
  "description": "JavaScript library for curve.fi",
5
5
  "main": "lib/index.js",
6
6
  "author": "Macket",