@curvefi/api 2.8.6 → 2.9.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.
@@ -6,6 +6,7 @@ export declare const implementationABIDictAvalanche: IDict<any>;
6
6
  export declare const implementationABIDictArbitrum: IDict<any>;
7
7
  export declare const implementationABIDictOptimism: IDict<any>;
8
8
  export declare const implementationABIDictXDai: IDict<any>;
9
+ export declare const implementationABIDictMoonbeam: IDict<any>;
9
10
  export declare const implementationBasePoolIdDictEthereum: IDict<string>;
10
11
  export declare const implementationBasePoolIdDictPolygon: IDict<string>;
11
12
  export declare const implementationBasePoolIdDictFantom: IDict<string>;
@@ -13,13 +14,39 @@ export declare const implementationBasePoolIdDictAvalanche: IDict<string>;
13
14
  export declare const implementationBasePoolIdDictArbitrum: IDict<string>;
14
15
  export declare const implementationBasePoolIdDictOptimism: IDict<string>;
15
16
  export declare const implementationBasePoolIdDictXDai: IDict<string>;
16
- export declare const basePoolIdZapDictEthereum: IDict<string>;
17
- export declare const basePoolIdZapDictPolygon: IDict<string>;
18
- export declare const basePoolIdZapDictFantom: IDict<string>;
19
- export declare const basePoolIdZapDictAvalanche: IDict<string>;
20
- export declare const basePoolIdZapDictArbitrum: IDict<string>;
21
- export declare const basePoolIdZapDictOptimism: IDict<string>;
22
- export declare const basePoolIdZapDictXDai: IDict<string>;
17
+ export declare const implementationBasePoolIdDictMoonbeam: IDict<string>;
18
+ export declare const basePoolIdZapDictEthereum: IDict<{
19
+ address: string;
20
+ ABI: any;
21
+ }>;
22
+ export declare const basePoolIdZapDictPolygon: IDict<{
23
+ address: string;
24
+ ABI: any;
25
+ }>;
26
+ export declare const basePoolIdZapDictFantom: IDict<{
27
+ address: string;
28
+ ABI: any;
29
+ }>;
30
+ export declare const basePoolIdZapDictAvalanche: IDict<{
31
+ address: string;
32
+ ABI: any;
33
+ }>;
34
+ export declare const basePoolIdZapDictArbitrum: IDict<{
35
+ address: string;
36
+ ABI: any;
37
+ }>;
38
+ export declare const basePoolIdZapDictOptimism: IDict<{
39
+ address: string;
40
+ ABI: any;
41
+ }>;
42
+ export declare const basePoolIdZapDictXDai: IDict<{
43
+ address: string;
44
+ ABI: any;
45
+ }>;
46
+ export declare const basePoolIdZapDictMoonbeam: IDict<{
47
+ address: string;
48
+ ABI: any;
49
+ }>;
23
50
  export declare const NATIVE_TOKEN_ADDRESS = "0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee";
24
51
  export declare const NATIVE_TOKENS: {
25
52
  [index: number]: {
@@ -32,6 +59,9 @@ export declare const FACTORY_CONSTANTS: {
32
59
  [index: number]: {
33
60
  implementationABIDict: IDict<any>;
34
61
  implementationBasePoolIdDict: IDict<string>;
35
- basePoolIdZapDict: IDict<string>;
62
+ basePoolIdZapDict: IDict<{
63
+ address: string;
64
+ ABI: any;
65
+ }>;
36
66
  };
37
67
  };
@@ -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.NATIVE_TOKENS = exports.NATIVE_TOKEN_ADDRESS = exports.basePoolIdZapDictXDai = exports.basePoolIdZapDictOptimism = exports.basePoolIdZapDictArbitrum = exports.basePoolIdZapDictAvalanche = exports.basePoolIdZapDictFantom = exports.basePoolIdZapDictPolygon = exports.basePoolIdZapDictEthereum = exports.implementationBasePoolIdDictXDai = exports.implementationBasePoolIdDictOptimism = exports.implementationBasePoolIdDictArbitrum = exports.implementationBasePoolIdDictAvalanche = exports.implementationBasePoolIdDictFantom = exports.implementationBasePoolIdDictPolygon = exports.implementationBasePoolIdDictEthereum = exports.implementationABIDictXDai = exports.implementationABIDictOptimism = exports.implementationABIDictArbitrum = exports.implementationABIDictAvalanche = exports.implementationABIDictFantom = exports.implementationABIDictPolygon = exports.implementationABIDictEthereum = void 0;
6
+ exports.FACTORY_CONSTANTS = exports.NATIVE_TOKENS = exports.NATIVE_TOKEN_ADDRESS = exports.basePoolIdZapDictMoonbeam = exports.basePoolIdZapDictXDai = exports.basePoolIdZapDictOptimism = exports.basePoolIdZapDictArbitrum = exports.basePoolIdZapDictAvalanche = exports.basePoolIdZapDictFantom = exports.basePoolIdZapDictPolygon = exports.basePoolIdZapDictEthereum = exports.implementationBasePoolIdDictMoonbeam = exports.implementationBasePoolIdDictXDai = exports.implementationBasePoolIdDictOptimism = exports.implementationBasePoolIdDictArbitrum = exports.implementationBasePoolIdDictAvalanche = exports.implementationBasePoolIdDictFantom = exports.implementationBasePoolIdDictPolygon = exports.implementationBasePoolIdDictEthereum = exports.implementationABIDictMoonbeam = exports.implementationABIDictXDai = exports.implementationABIDictOptimism = exports.implementationABIDictArbitrum = exports.implementationABIDictAvalanche = exports.implementationABIDictFantom = 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"));
@@ -26,6 +26,13 @@ var Plain4Basic_json_1 = __importDefault(require("../constants/abis/factory-v2/P
26
26
  var Plain4Balances_json_1 = __importDefault(require("../constants/abis/factory-v2/Plain4Balances.json"));
27
27
  var Plain4ETH_json_1 = __importDefault(require("../constants/abis/factory-v2/Plain4ETH.json"));
28
28
  var Plain4Optimized_json_1 = __importDefault(require("../constants/abis/factory-v2/Plain4Optimized.json"));
29
+ // --- ZAPS --
30
+ var deposit_json_1 = __importDefault(require("../constants/abis/factoryPools/deposit.json"));
31
+ var metaZap_json_1 = __importDefault(require("../constants/abis/fraxusdc/metaZap.json"));
32
+ var DepositZapMetaUsdPolygon_json_1 = __importDefault(require("../constants/abis/factory-v2/DepositZapMetaUsdPolygon.json"));
33
+ var DepositZapMetaBtcPolygon_json_1 = __importDefault(require("../constants/abis/factory-v2/DepositZapMetaBtcPolygon.json"));
34
+ var DepositZapFantom_json_1 = __importDefault(require("../constants/abis/factory-v2/DepositZapFantom.json"));
35
+ var DepositZapMetaUsd2Fantom_json_1 = __importDefault(require("../constants/abis/factory-v2/DepositZapMetaUsd2Fantom.json"));
29
36
  exports.implementationABIDictEthereum = {
30
37
  "0x5F890841f657d90E081bAbdB532A05996Af79Fe6": swap_json_1.default,
31
38
  "0x213be373FDff327658139C7df330817DAD2d5bBE": MetaUSD_json_1.default,
@@ -110,6 +117,8 @@ exports.implementationABIDictArbitrum = {
110
117
  "0xBE175115BF33E12348ff77CcfEE4726866A0Fbd5": MetaUSDBalances_json_1.default,
111
118
  "0x094d12e5b541784701FD8d65F11fc0598FBC6332": MetaBTCRen_json_1.default,
112
119
  "0xF1f85a74AD6c64315F85af52d3d46bF715236ADc": MetaBTCBalancesRen_json_1.default,
120
+ "0x8DEb66a4A40E370355bEe35f12E55Fe9c755d686": MetaFraxUSD_json_1.default,
121
+ "0x3edE9b145F82e9e46C03f8A8F67B77aEE847b632": MetaFraxUSDBalances_json_1.default,
113
122
  "0x54e8A25d0Ac0E4945b697C80b8372445FEA17A62": Plain2Basic_json_1.default,
114
123
  "0xD68970e266cE1A015953897C7055a5E0bC657Af8": Plain2Balances_json_1.default,
115
124
  "0x7DA64233Fefb352f8F501B357c018158ED8aA455": Plain2ETH_json_1.default,
@@ -157,6 +166,20 @@ exports.implementationABIDictXDai = {
157
166
  "0xc1C49622b63B961ce1D352ecb7D8261Ab5556695": Plain4ETH_json_1.default,
158
167
  "0x0E2615ce69Cd3Dc3Ff6f66a975bEa0655F3bA7b9": Plain4Optimized_json_1.default,
159
168
  };
169
+ exports.implementationABIDictMoonbeam = {
170
+ "0x6842E0412AC1c00464dc48961330156a07268d14": Plain2Basic_json_1.default,
171
+ "0x9fAe78C4bBB649deB7b2295dDB8A03adA7eB660F": Plain2Balances_json_1.default,
172
+ "0xfCE359115dFe1533a2458650123F86C454BC0213": Plain2ETH_json_1.default,
173
+ "0x09C62ad0694e3f1ad8cF8876aaBe56138C586f5F": Plain2Optimized_json_1.default,
174
+ "0xD19Baeadc667Cf2015e395f2B08668Ef120f41F5": Plain3Basic_json_1.default,
175
+ "0x04e39EF8332e979Cf8e4f8891E64934FF65F231b": Plain3Balances_json_1.default,
176
+ "0xC9438d8928486bD9621D326002F4672bF684187A": Plain3ETH_json_1.default,
177
+ "0x2b70A5B878665FfDB4A06Ba40a264d6c70f68F4B": Plain3Optimized_json_1.default,
178
+ "0x2D036f0Ff6F440dB623e0D9D3B5Daa509e5500C3": Plain4Basic_json_1.default,
179
+ "0x7Bb707085905c9D80854652809A1ba8480C11789": Plain4Balances_json_1.default,
180
+ "0xec9cEBE650E181079576C1b6d0d2e092B1EdfF13": Plain4ETH_json_1.default,
181
+ "0xe8269B33E47761f552E1a3070119560d5fa8bBD6": Plain4Optimized_json_1.default,
182
+ };
160
183
  exports.implementationBasePoolIdDictEthereum = {
161
184
  "0x5F890841f657d90E081bAbdB532A05996Af79Fe6": "3pool",
162
185
  "0x213be373FDff327658139C7df330817DAD2d5bBE": "3pool",
@@ -193,6 +216,8 @@ exports.implementationBasePoolIdDictArbitrum = {
193
216
  "0xBE175115BF33E12348ff77CcfEE4726866A0Fbd5": "2pool",
194
217
  "0x094d12e5b541784701FD8d65F11fc0598FBC6332": "ren",
195
218
  "0xF1f85a74AD6c64315F85af52d3d46bF715236ADc": "ren",
219
+ "0x8DEb66a4A40E370355bEe35f12E55Fe9c755d686": "factory-v2-41",
220
+ "0x3edE9b145F82e9e46C03f8A8F67B77aEE847b632": "factory-v2-41", // fraxbp
196
221
  };
197
222
  exports.implementationBasePoolIdDictOptimism = {
198
223
  "0x78CF256256C8089d68Cde634Cf7cDEFb39286470": "3pool",
@@ -204,36 +229,90 @@ exports.implementationBasePoolIdDictXDai = {
204
229
  "0x4A5bF7Ab9A8202692051c19B102d3eDD62aaBAE6": "3pool",
205
230
  "0x0B4dc7A945695D11FD83e40B2DfC2B896A02395F": "3pool",
206
231
  };
232
+ exports.implementationBasePoolIdDictMoonbeam = {};
207
233
  exports.basePoolIdZapDictEthereum = {
208
- '3pool': "0xA79828DF1850E8a3A3064576f380D90aECDD3359".toLowerCase(),
209
- fraxusdc: "0x08780fb7E580e492c1935bEe4fA5920b94AA95Da".toLowerCase(),
210
- sbtc: "0x7abdbaf29929e7f8621b757d2a7c04d78d633834".toLowerCase(),
211
- ren: "0x7abdbaf29929e7f8621b757d2a7c04d78d633834".toLowerCase(), // TODO CHECK!!!
234
+ '3pool': {
235
+ address: "0xA79828DF1850E8a3A3064576f380D90aECDD3359".toLowerCase(),
236
+ ABI: deposit_json_1.default,
237
+ },
238
+ fraxusdc: {
239
+ address: "0x08780fb7E580e492c1935bEe4fA5920b94AA95Da".toLowerCase(),
240
+ ABI: metaZap_json_1.default,
241
+ },
242
+ sbtc: {
243
+ address: "0x7abdbaf29929e7f8621b757d2a7c04d78d633834".toLowerCase(),
244
+ ABI: deposit_json_1.default,
245
+ },
246
+ ren: {
247
+ address: "0x7abdbaf29929e7f8621b757d2a7c04d78d633834".toLowerCase(),
248
+ ABI: deposit_json_1.default,
249
+ }, // TODO MUST BE CHANGED!!!
212
250
  };
213
251
  exports.basePoolIdZapDictPolygon = {
214
- aave: "0x5ab5C56B9db92Ba45a0B46a207286cD83C15C939".toLowerCase(),
215
- ren: "0xE2e6DC1708337A6e59f227921db08F21e3394723".toLowerCase(),
252
+ aave: {
253
+ address: "0x5ab5C56B9db92Ba45a0B46a207286cD83C15C939".toLowerCase(),
254
+ ABI: DepositZapMetaUsdPolygon_json_1.default,
255
+ },
256
+ ren: {
257
+ address: "0xE2e6DC1708337A6e59f227921db08F21e3394723".toLowerCase(),
258
+ ABI: DepositZapMetaBtcPolygon_json_1.default,
259
+ },
216
260
  };
217
261
  exports.basePoolIdZapDictFantom = {
218
- '2pool': "0x78D51EB71a62c081550EfcC0a9F9Ea94B2Ef081c".toLowerCase(),
219
- ren: "0x001E3BA199B4FF4B5B6e97aCD96daFC0E2e4156e".toLowerCase(),
220
- geist: "0x247aEB220E87f24c40C9F86b65d6bd5d3c987B55".toLowerCase(),
262
+ '2pool': {
263
+ address: "0x78D51EB71a62c081550EfcC0a9F9Ea94B2Ef081c".toLowerCase(),
264
+ ABI: DepositZapFantom_json_1.default,
265
+ },
266
+ ren: {
267
+ address: "0x001E3BA199B4FF4B5B6e97aCD96daFC0E2e4156e".toLowerCase(),
268
+ ABI: DepositZapFantom_json_1.default,
269
+ },
270
+ geist: {
271
+ address: "0x247aEB220E87f24c40C9F86b65d6bd5d3c987B55".toLowerCase(),
272
+ ABI: DepositZapMetaUsd2Fantom_json_1.default,
273
+ },
221
274
  };
222
275
  exports.basePoolIdZapDictAvalanche = {
223
- aave: "0x001E3BA199B4FF4B5B6e97aCD96daFC0E2e4156e".toLowerCase(),
224
- ren: "0xEeB3DDBcc4174e0b3fd1C13aD462b95D11Ef42C3".toLowerCase(),
276
+ aave: {
277
+ address: "0x001E3BA199B4FF4B5B6e97aCD96daFC0E2e4156e".toLowerCase(),
278
+ ABI: DepositZapMetaUsdPolygon_json_1.default,
279
+ },
280
+ ren: {
281
+ address: "0xEeB3DDBcc4174e0b3fd1C13aD462b95D11Ef42C3".toLowerCase(),
282
+ ABI: DepositZapMetaBtcPolygon_json_1.default,
283
+ },
225
284
  };
226
285
  exports.basePoolIdZapDictArbitrum = {
227
- "2pool": "0x7544Fe3d184b6B55D6B36c3FCA1157eE0Ba30287".toLowerCase(),
228
- ren: "0x803A2B40c5a9BB2B86DD630B274Fa2A9202874C2".toLowerCase(),
286
+ "2pool": {
287
+ address: "0x7544Fe3d184b6B55D6B36c3FCA1157eE0Ba30287".toLowerCase(),
288
+ ABI: DepositZapFantom_json_1.default,
289
+ },
290
+ ren: {
291
+ address: "0x803A2B40c5a9BB2B86DD630B274Fa2A9202874C2".toLowerCase(),
292
+ ABI: DepositZapFantom_json_1.default,
293
+ },
294
+ "factory-v2-41": {
295
+ address: "0x58AC91f5BE7dC0c35b24B96B19BAc55FBB8E705e".toLowerCase(),
296
+ ABI: DepositZapFantom_json_1.default,
297
+ },
229
298
  };
230
299
  exports.basePoolIdZapDictOptimism = {
231
- "3pool": "0x167e42a1c7ab4be03764a2222aac57f5f6754411".toLowerCase(),
232
- "factory-v2-16": "'0x4244eB811D6e0Ef302326675207A95113dB4E1F8'".toLowerCase(),
300
+ "3pool": {
301
+ address: "0x167e42a1c7ab4be03764a2222aac57f5f6754411".toLowerCase(),
302
+ ABI: deposit_json_1.default,
303
+ },
304
+ "factory-v2-16": {
305
+ address: "0x4244eB811D6e0Ef302326675207A95113dB4E1F8".toLowerCase(),
306
+ ABI: DepositZapFantom_json_1.default,
307
+ },
233
308
  };
234
309
  exports.basePoolIdZapDictXDai = {
235
- "3pool": "0x87C067fAc25f123554a0E76596BF28cFa37fD5E9".toLowerCase(),
310
+ "3pool": {
311
+ address: "0x87C067fAc25f123554a0E76596BF28cFa37fD5E9".toLowerCase(),
312
+ ABI: deposit_json_1.default,
313
+ },
236
314
  };
315
+ exports.basePoolIdZapDictMoonbeam = {};
237
316
  exports.NATIVE_TOKEN_ADDRESS = "0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee";
238
317
  exports.NATIVE_TOKENS = {
239
318
  1: {
@@ -261,6 +340,11 @@ exports.NATIVE_TOKENS = {
261
340
  wrappedSymbol: 'WFTM',
262
341
  wrappedAddress: '0x21be370D5312f44cB42ce377BC9b8a0cEF1A4C83'.toLowerCase(),
263
342
  },
343
+ 1284: {
344
+ symbol: 'GLMR',
345
+ wrappedSymbol: 'WGLMR',
346
+ wrappedAddress: '0xAcc15dC74880C9944775448304B263D191c6077F'.toLowerCase(),
347
+ },
264
348
  42161: {
265
349
  symbol: 'ETH',
266
350
  wrappedSymbol: 'WETH',
@@ -293,6 +377,11 @@ exports.FACTORY_CONSTANTS = {
293
377
  implementationBasePoolIdDict: exports.implementationBasePoolIdDictFantom,
294
378
  basePoolIdZapDict: exports.basePoolIdZapDictFantom,
295
379
  },
380
+ 1284: {
381
+ implementationABIDict: exports.implementationABIDictMoonbeam,
382
+ implementationBasePoolIdDict: exports.implementationBasePoolIdDictMoonbeam,
383
+ basePoolIdZapDict: exports.basePoolIdZapDictMoonbeam,
384
+ },
296
385
  43114: {
297
386
  implementationABIDict: exports.implementationABIDictAvalanche,
298
387
  implementationBasePoolIdDict: exports.implementationBasePoolIdDictAvalanche,
@@ -273,7 +273,7 @@ function getFactoryPoolsDataFromApi(isCrypto) {
273
273
  var basePoolCoinNames = basePoolIdCoinsDict[basePoolId];
274
274
  var basePoolCoinAddresses = basePoolIdCoinAddressesDict[basePoolId];
275
275
  var basePoolDecimals = basePoolIdDecimalsDict[basePoolId];
276
- var basePoolZap = basePoolIdZapDict[basePoolId];
276
+ var basePoolZap = basePoolIdZapDict[basePoolId].address;
277
277
  FACTORY_POOLS_DATA[pool.id] = {
278
278
  name: pool.name.split(": ")[1].trim(),
279
279
  full_name: pool.name,
@@ -243,6 +243,8 @@ function getExistingCoinAddressNameDict() {
243
243
  dict[constants_1.NATIVE_TOKEN_ADDRESS] = "MATIC";
244
244
  if (this.chainId === 250)
245
245
  dict[constants_1.NATIVE_TOKEN_ADDRESS] = "FTM";
246
+ if (this.chainId === 1284)
247
+ dict[constants_1.NATIVE_TOKEN_ADDRESS] = "GLMR";
246
248
  if (this.chainId === 43114)
247
249
  dict[constants_1.NATIVE_TOKEN_ADDRESS] = "AVAX";
248
250
  if (this.chainId === 42161)
@@ -78,6 +78,7 @@ var BLACK_LIST = {
78
78
  "0x88c4d6534165510b2e2caf0a130d4f70aa4b6d71",
79
79
  ],
80
80
  250: [],
81
+ 1284: [],
81
82
  43114: [],
82
83
  42161: [],
83
84
  };
@@ -277,6 +278,8 @@ function getExistingCoinAddressNameDict() {
277
278
  dict[constants_1.NATIVE_TOKEN_ADDRESS] = "MATIC";
278
279
  if (this.chainId === 250)
279
280
  dict[constants_1.NATIVE_TOKEN_ADDRESS] = "FTM";
281
+ if (this.chainId === 1284)
282
+ dict[constants_1.NATIVE_TOKEN_ADDRESS] = "GLMR";
280
283
  if (this.chainId === 43114)
281
284
  dict[constants_1.NATIVE_TOKEN_ADDRESS] = "AVAX";
282
285
  if (this.chainId === 42161)
@@ -450,7 +453,7 @@ function getFactoryPoolData() {
450
453
  swap_address: swapAddresses[i],
451
454
  token_address: swapAddresses[i],
452
455
  gauge_address: gaugeAddresses[i],
453
- deposit_address: basePoolIdZapDict[basePoolIds[i]],
456
+ deposit_address: basePoolIdZapDict[basePoolIds[i]].address,
454
457
  is_meta: true,
455
458
  is_factory: true,
456
459
  base_pool: basePoolIds[i],
@@ -70,6 +70,7 @@ export interface ICurve {
70
70
  DECIMALS: IDict<number>;
71
71
  GAUGES: string[];
72
72
  };
73
+ setContract: (address: string, abi: any) => void;
73
74
  }
74
75
  export interface ICoinFromPoolDataApi {
75
76
  address: string;
@@ -99,6 +100,7 @@ export interface IPoolDataFromApi {
99
100
  coins: ICoinFromPoolDataApi[];
100
101
  gaugeRewards?: IReward[];
101
102
  usdTotal: number;
103
+ totalSupply: number;
102
104
  }
103
105
  export interface ISubgraphPoolData {
104
106
  address: string;
@@ -162,32 +162,71 @@ var PoolTemplate = /** @class */ (function () {
162
162
  });
163
163
  };
164
164
  this.statsVolume = function () { return __awaiter(_this, void 0, void 0, function () {
165
- var network, poolsData, poolData;
165
+ var _c, mainPoolsData, factoryPoolsData, poolData_1, lpPrice, network, poolsData, poolData;
166
166
  var _this = this;
167
- return __generator(this, function (_c) {
168
- switch (_c.label) {
167
+ return __generator(this, function (_d) {
168
+ switch (_d.label) {
169
169
  case 0:
170
+ if (!(curve_1.curve.chainId === 1284)) return [3 /*break*/, 3];
171
+ return [4 /*yield*/, Promise.all([
172
+ (0, external_api_1._getMoonbeamLegacyAPYsAndVolumes)(),
173
+ (0, external_api_1._getMoonbeamFactoryAPYsAndVolumes)(),
174
+ ])];
175
+ case 1:
176
+ _c = _d.sent(), mainPoolsData = _c[0], factoryPoolsData = _c[1];
177
+ if (this.id in mainPoolsData) {
178
+ return [2 /*return*/, mainPoolsData[this.id].volume.toString()];
179
+ }
180
+ poolData_1 = factoryPoolsData.find(function (d) { return d.poolAddress.toLowerCase() === _this.address; });
181
+ if (!poolData_1)
182
+ throw Error("Can't get Volume for ".concat(this.name, " (id: ").concat(this.id, ")"));
183
+ return [4 /*yield*/, (0, utils_1._getUsdRate)(this.lpToken)];
184
+ case 2:
185
+ lpPrice = _d.sent();
186
+ return [2 /*return*/, (poolData_1.volume * lpPrice).toString()];
187
+ case 3:
170
188
  network = curve_1.curve.constants.NETWORK_NAME;
171
189
  return [4 /*yield*/, (0, external_api_1._getSubgraphData)(network)];
172
- case 1:
173
- poolsData = (_c.sent());
190
+ case 4:
191
+ poolsData = (_d.sent());
174
192
  poolData = poolsData.find(function (d) { return d.address.toLowerCase() === _this.address; });
175
193
  if (!poolData)
176
- throw Error("Can't get base APY for ".concat(this.name, " (id: ").concat(this.id, ")"));
194
+ throw Error("Can't get Volume for ".concat(this.name, " (id: ").concat(this.id, ")"));
177
195
  return [2 /*return*/, poolData.volumeUSD.toString()];
178
196
  }
179
197
  });
180
198
  }); };
181
199
  this.statsBaseApy = function () { return __awaiter(_this, void 0, void 0, function () {
182
- var network, poolsData, poolData;
200
+ var _c, mainPoolsData, factoryPoolsData, poolData_2, network, poolsData, poolData;
183
201
  var _this = this;
184
- return __generator(this, function (_c) {
185
- switch (_c.label) {
202
+ return __generator(this, function (_d) {
203
+ switch (_d.label) {
186
204
  case 0:
205
+ if (!(curve_1.curve.chainId === 1284)) return [3 /*break*/, 2];
206
+ return [4 /*yield*/, Promise.all([
207
+ (0, external_api_1._getMoonbeamLegacyAPYsAndVolumes)(),
208
+ (0, external_api_1._getMoonbeamFactoryAPYsAndVolumes)(),
209
+ ])];
210
+ case 1:
211
+ _c = _d.sent(), mainPoolsData = _c[0], factoryPoolsData = _c[1];
212
+ if (this.id in mainPoolsData) {
213
+ return [2 /*return*/, {
214
+ day: mainPoolsData[this.id].apy.day.toString(),
215
+ week: mainPoolsData[this.id].apy.week.toString(),
216
+ }];
217
+ }
218
+ poolData_2 = factoryPoolsData.find(function (d) { return d.poolAddress.toLowerCase() === _this.address; });
219
+ if (!poolData_2)
220
+ throw Error("Can't get base APY for ".concat(this.name, " (id: ").concat(this.id, ")"));
221
+ return [2 /*return*/, {
222
+ day: poolData_2.apy.toString(),
223
+ week: poolData_2.apy.toString(),
224
+ }];
225
+ case 2:
187
226
  network = curve_1.curve.constants.NETWORK_NAME;
188
227
  return [4 /*yield*/, (0, external_api_1._getSubgraphData)(network)];
189
- case 1:
190
- poolsData = (_c.sent());
228
+ case 3:
229
+ poolsData = (_d.sent());
191
230
  poolData = poolsData.find(function (d) { return d.address.toLowerCase() === _this.address; });
192
231
  if (!poolData)
193
232
  throw Error("Can't get base APY for ".concat(this.name, " (id: ").concat(this.id, ")"));
@@ -228,7 +267,7 @@ var PoolTemplate = /** @class */ (function () {
228
267
  case 4: return [4 /*yield*/, (0, utils_1._getUsdRate)(curve_1.curve.constants.ALIASES.crv)];
229
268
  case 5:
230
269
  crvRate_1 = _f.sent();
231
- apy = inflationRateBN.times(31536000).times(crvRate_1).div(Number(totalLiquidityUSD));
270
+ apy = inflationRateBN.times(31536000).times(0.4).times(crvRate_1).div(Number(totalLiquidityUSD));
232
271
  return [2 /*return*/, [apy.times(100).toFixed(4), apy.times(100).toFixed(4)]];
233
272
  case 6:
234
273
  gaugeContract = curve_1.curve.contracts[this.gauge].multicallContract;
@@ -262,7 +301,7 @@ var PoolTemplate = /** @class */ (function () {
262
301
  case 0:
263
302
  if (this.gauge === ethers_1.ethers.constants.AddressZero)
264
303
  return [2 /*return*/, []];
265
- if (![10, 100, 137, 250, 43114, 42161].includes(curve_1.curve.chainId)) return [3 /*break*/, 8];
304
+ if (![10, 100, 137, 250, 1284, 43114, 42161].includes(curve_1.curve.chainId)) return [3 /*break*/, 8];
266
305
  apy = [];
267
306
  return [4 /*yield*/, this.rewardTokens()];
268
307
  case 1:
@@ -371,11 +410,13 @@ var PoolTemplate = /** @class */ (function () {
371
410
  _d = [(0, utils_1.toBN)(_totalSupply), (0, utils_1.toBN)(_fee, 10).times(N_coins).div(4 * (N_coins - 1)), (0, utils_1.toBN)(_lpTokenAmount)], totalSupplyBN = _d[0], feeBN = _d[1], lpTokenAmountBN = _d[2];
372
411
  balancesBN = balances.map(function (b) { return (0, utils_1.BN)(b); });
373
412
  amountsBN = _amounts.map(function (_a, i) { return (0, utils_1.toBN)(_a, decimals[i]); });
374
- feesBN = [];
375
- for (i = 0; i < N_coins; i++) {
376
- feesBN[i] = balancesBN[i].times(lpTokenAmountBN).div(totalSupplyBN).minus(amountsBN[i]).times(feeBN);
377
- if (feesBN[i].lt(0))
378
- feesBN[i] = feesBN[i].times(-1);
413
+ feesBN = Array(N_coins).fill((0, utils_1.BN)(0));
414
+ if (totalSupplyBN.gt(0)) {
415
+ for (i = 0; i < N_coins; i++) {
416
+ feesBN[i] = balancesBN[i].times(lpTokenAmountBN).div(totalSupplyBN).minus(amountsBN[i]).times(feeBN);
417
+ if (feesBN[i].lt(0))
418
+ feesBN[i] = feesBN[i].times(-1);
419
+ }
379
420
  }
380
421
  _fees = feesBN.map(function (fBN, i) { return (0, utils_1.fromBN)(fBN, decimals[i]); });
381
422
  return [4 /*yield*/, this._pureCalcLpTokenAmount(_fees, !isDeposit, useUnderlying)];
@@ -45,7 +45,7 @@ var getPool = function (poolId) {
45
45
  return Pool;
46
46
  }(PoolTemplate_1.PoolTemplate));
47
47
  // statsBalances
48
- if (poolDummy.isFake) {
48
+ if (poolDummy.isFake || (curve_1.curve.chainId === 100 && poolDummy.id === "tricrypto")) { // 100 is xDAI
49
49
  Object.assign(Pool.prototype, poolBalancesMixin_1.poolBalancesAtricrypto3Mixin);
50
50
  }
51
51
  else if (poolDummy.isMeta) {
@@ -104,7 +104,7 @@ var getPool = function (poolId) {
104
104
  }
105
105
  }
106
106
  // withdrawExpected
107
- if (poolDummy.isFake) {
107
+ if (poolDummy.isFake || (curve_1.curve.chainId === 100 && poolDummy.id === "tricrypto")) { // 100 is xDAI
108
108
  Object.assign(Pool.prototype, withdrawExpectedMixins_1.withdrawExpectedAtricrypto3Mixin);
109
109
  }
110
110
  else if (poolDummy.isMeta) {
@@ -227,7 +227,8 @@ var getPool = function (poolId) {
227
227
  }
228
228
  }
229
229
  // swap and swapEstimateGas
230
- if ('exchange(uint256,uint256,uint256,uint256,bool)' in curve_1.curve.contracts[poolDummy.address].contract) { // tricrypto2 (eth), tricrypto (arbitrum)
230
+ if ('exchange(uint256,uint256,uint256,uint256,bool)' in curve_1.curve.contracts[poolDummy.address].contract &&
231
+ !(curve_1.curve.chainId === 100 && poolDummy.id === "tricrypto")) { // tricrypto2 (eth), tricrypto (arbitrum); 100 is xDAI
231
232
  Object.assign(Pool.prototype, swapMixins_1.swapTricrypto2Mixin);
232
233
  }
233
234
  else if (poolDummy.isMetaFactory && ((0, exports.getPool)(poolDummy.basePool).isLending || (0, exports.getPool)(poolDummy.basePool).isFake)) {
package/lib/utils.js CHANGED
@@ -408,10 +408,10 @@ var getPoolNameBySwapAddress = function (swapAddress) {
408
408
  };
409
409
  exports.getPoolNameBySwapAddress = getPoolNameBySwapAddress;
410
410
  var _getUsdPricesFromApi = function () { return __awaiter(void 0, void 0, void 0, function () {
411
- var network, promises, allTypesExtendedPoolData, priceDict, _i, allTypesExtendedPoolData_1, extendedPoolData, _a, _b, pool, _c, _d, coin, _e, _f, coin;
412
- var _g;
413
- return __generator(this, function (_h) {
414
- switch (_h.label) {
411
+ var network, promises, allTypesExtendedPoolData, priceDict, _i, allTypesExtendedPoolData_1, extendedPoolData, _a, _b, pool, lpTokenAddress, totalSupply, _c, _d, coin, _e, _f, coin;
412
+ var _g, _h;
413
+ return __generator(this, function (_j) {
414
+ switch (_j.label) {
415
415
  case 0:
416
416
  network = curve_1.curve.constants.NETWORK_NAME;
417
417
  promises = [
@@ -422,18 +422,21 @@ var _getUsdPricesFromApi = function () { return __awaiter(void 0, void 0, void 0
422
422
  ];
423
423
  return [4 /*yield*/, Promise.all(promises)];
424
424
  case 1:
425
- allTypesExtendedPoolData = _h.sent();
425
+ allTypesExtendedPoolData = _j.sent();
426
426
  priceDict = {};
427
427
  for (_i = 0, allTypesExtendedPoolData_1 = allTypesExtendedPoolData; _i < allTypesExtendedPoolData_1.length; _i++) {
428
428
  extendedPoolData = allTypesExtendedPoolData_1[_i];
429
429
  for (_a = 0, _b = extendedPoolData.poolData; _a < _b.length; _a++) {
430
430
  pool = _b[_a];
431
+ lpTokenAddress = (_g = pool.lpTokenAddress) !== null && _g !== void 0 ? _g : pool.address;
432
+ totalSupply = pool.totalSupply / (Math.pow(10, 18));
433
+ priceDict[lpTokenAddress.toLowerCase()] = pool.usdTotal && totalSupply ? pool.usdTotal / totalSupply : 0;
431
434
  for (_c = 0, _d = pool.coins; _c < _d.length; _c++) {
432
435
  coin = _d[_c];
433
436
  if (typeof coin.usdPrice === "number")
434
437
  priceDict[coin.address.toLowerCase()] = coin.usdPrice;
435
438
  }
436
- for (_e = 0, _f = (_g = pool.gaugeRewards) !== null && _g !== void 0 ? _g : []; _e < _f.length; _e++) {
439
+ for (_e = 0, _f = (_h = pool.gaugeRewards) !== null && _h !== void 0 ? _h : []; _e < _f.length; _e++) {
437
440
  coin = _f[_e];
438
441
  if (typeof coin.tokenPrice === "number")
439
442
  priceDict[coin.tokenAddress.toLowerCase()] = coin.tokenPrice;
@@ -464,6 +467,7 @@ var _getUsdRate = function (assetId) { return __awaiter(void 0, void 0, void 0,
464
467
  100: 'xdai',
465
468
  137: 'polygon-pos',
466
469
  250: 'fantom',
470
+ 1284: 'moonbeam',
467
471
  43114: 'avalanche',
468
472
  42161: 'arbitrum-one',
469
473
  }[curve_1.curve.chainId];
@@ -473,6 +477,7 @@ var _getUsdRate = function (assetId) { return __awaiter(void 0, void 0, void 0,
473
477
  100: 'xdai',
474
478
  137: 'matic-network',
475
479
  250: 'fantom',
480
+ 1284: 'moonbeam',
476
481
  43114: 'avalanche-2',
477
482
  42161: 'ethereum',
478
483
  }[curve_1.curve.chainId];
@@ -541,6 +546,7 @@ var getTVL = function (chainId) {
541
546
  100: 'xdai',
542
547
  137: "polygon",
543
548
  250: "fantom",
549
+ 1284: "moonbeam",
544
550
  43114: "avalanche",
545
551
  42161: "arbitrum",
546
552
  }[chainId]) !== null && _a !== void 0 ? _a : "ethereum";
@@ -553,7 +559,7 @@ var getTVL = function (chainId) {
553
559
  return [4 /*yield*/, Promise.all(promises)];
554
560
  case 1:
555
561
  allTypesExtendedPoolData = _b.sent();
556
- return [2 /*return*/, allTypesExtendedPoolData.reduce(function (sum, data) { var _a; return sum + ((_a = data.tvl) !== null && _a !== void 0 ? _a : data.tvlAll); }, 0)];
562
+ return [2 /*return*/, allTypesExtendedPoolData.reduce(function (sum, data) { var _a, _b; return sum + ((_b = (_a = data.tvl) !== null && _a !== void 0 ? _a : data.tvlAll) !== null && _b !== void 0 ? _b : 0); }, 0)];
557
563
  }
558
564
  });
559
565
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@curvefi/api",
3
- "version": "2.8.6",
3
+ "version": "2.9.0",
4
4
  "description": "JavaScript library for curve.fi",
5
5
  "main": "lib/index.js",
6
6
  "author": "Macket",
@@ -34,7 +34,7 @@
34
34
  "@ethersproject/networks": "^5.5.0",
35
35
  "axios": "^0.21.1",
36
36
  "bignumber.js": "^9.0.1",
37
- "ethcall": "^4.2.5",
37
+ "ethcall": "^4.8.2",
38
38
  "ethers": "^5.4.6",
39
39
  "memoizee": "^0.4.15"
40
40
  }