@curvefi/api 1.13.0 → 1.16.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 (53) hide show
  1. package/README.md +98 -1
  2. package/lib/constants/abis/abis-ethereum.js +216 -16
  3. package/lib/constants/abis/abis-polygon.js +17 -1
  4. package/lib/constants/abis/json/aave/rewards.json +107 -0
  5. package/lib/constants/abis/json/atricrypto3/swap.json +63 -63
  6. package/lib/constants/abis/json/atricrypto3/zap.json +8 -8
  7. package/lib/constants/abis/json/busd/deposit.json +5 -10
  8. package/lib/constants/abis/json/busd/swap.json +18 -36
  9. package/lib/constants/abis/json/compound/deposit.json +5 -10
  10. package/lib/constants/abis/json/compound/migration.json +1 -2
  11. package/lib/constants/abis/json/compound/oldSwap.json +16 -32
  12. package/lib/constants/abis/json/compound/swap.json +18 -36
  13. package/lib/constants/abis/json/crveth/swap.json +61 -61
  14. package/lib/constants/abis/json/eurt/swap.json +29 -29
  15. package/lib/constants/abis/json/eurtusd/deposit.json +13 -13
  16. package/lib/constants/abis/json/eurtusd/swap.json +59 -59
  17. package/lib/constants/abis/json/gauge.json +1 -1
  18. package/lib/constants/abis/json/gauge_factory.json +879 -0
  19. package/lib/constants/abis/json/gauge_rewards_only.json +649 -0
  20. package/lib/constants/abis/json/gauge_synthetix.json +590 -0
  21. package/lib/constants/abis/json/gauge_v2.json +942 -0
  22. package/lib/constants/abis/json/gauge_v3.json +954 -0
  23. package/lib/constants/abis/json/gauge_v4.json +913 -0
  24. package/lib/constants/abis/json/iearn/deposit.json +5 -10
  25. package/lib/constants/abis/json/iearn/swap.json +18 -36
  26. package/lib/constants/abis/json/minter.json +165 -0
  27. package/lib/constants/abis/json/pax/deposit.json +5 -10
  28. package/lib/constants/abis/json/pax/swap.json +19 -38
  29. package/lib/constants/abis/json/ren/swap.json +19 -38
  30. package/lib/constants/abis/json/ren-polygon/swap.json +46 -46
  31. package/lib/constants/abis/json/reth/swap.json +38 -38
  32. package/lib/constants/abis/json/sbtc/swap.json +19 -38
  33. package/lib/constants/abis/json/streamer.json +257 -0
  34. package/lib/constants/abis/json/susdv2/deposit.json +5 -10
  35. package/lib/constants/abis/json/susdv2/swap.json +16 -32
  36. package/lib/constants/abis/json/tricrypto2/deposit.json +3 -3
  37. package/lib/constants/abis/json/tricrypto2/swap.json +60 -60
  38. package/lib/constants/abis/json/usdt/deposit.json +5 -10
  39. package/lib/constants/abis/json/usdt/swap.json +19 -37
  40. package/lib/constants/aliases.d.ts +2 -0
  41. package/lib/constants/aliases.js +3 -1
  42. package/lib/constants/coins-ethereum.js +7 -3
  43. package/lib/constants/coins-polygon.js +3 -2
  44. package/lib/curve.d.ts +1 -0
  45. package/lib/curve.js +47 -16
  46. package/lib/index.d.ts +1 -0
  47. package/lib/index.js +1 -0
  48. package/lib/interfaces.d.ts +8 -0
  49. package/lib/pools.d.ts +41 -5
  50. package/lib/pools.js +357 -69
  51. package/lib/utils.d.ts +2 -1
  52. package/lib/utils.js +42 -29
  53. package/package.json +1 -1
package/lib/pools.js CHANGED
@@ -81,7 +81,7 @@ var Pool = /** @class */ (function () {
81
81
  _amounts = amounts.map(function (amount, i) {
82
82
  return ethers_1.ethers.utils.parseUnits(amount, _this.underlyingDecimals[i]);
83
83
  });
84
- if (!(['compound', 'usdt', 'y', 'busd', 'pax', 'aave', 'saave', 'ib', 'crveth', "cvxeth"].includes(this.name) || (curve_1.curve.chainId === 137 && this.name === 'ren'))) return [3 /*break*/, 2];
84
+ if (!(['compound', 'usdt', 'y', 'busd', 'pax', 'aave', 'saave', 'ib', 'crveth', "cvxeth", "spelleth", "teth"].includes(this.name) || (curve_1.curve.chainId === 137 && this.name === 'ren'))) return [3 /*break*/, 2];
85
85
  return [4 /*yield*/, this._calcLpTokenAmountWithUnderlying(_amounts, isDeposit)];
86
86
  case 1:
87
87
  _expected = _a.sent(); // Lending pools
@@ -126,14 +126,45 @@ var Pool = /** @class */ (function () {
126
126
  });
127
127
  });
128
128
  };
129
- this.getVirtualPrice = function () { return __awaiter(_this, void 0, void 0, function () {
130
- var _virtualPrice;
131
- return __generator(this, function (_a) {
132
- switch (_a.label) {
133
- case 0: return [4 /*yield*/, curve_1.curve.contracts[this.swap].contract.get_virtual_price(curve_1.curve.constantOptions)];
129
+ this.getParameters = function () { return __awaiter(_this, void 0, void 0, function () {
130
+ var multicallContract, calls, additionalCalls, _a, _virtualPrice, _fee, _adminFee, _A, _gamma, _c, virtualPrice, fee, adminFee, A, gamma, A_PRECISION, _d, _future_A, _initial_A, _future_A_time, _initial_A_time, _e, future_A, initial_A, future_A_time, initial_A_time;
131
+ return __generator(this, function (_f) {
132
+ switch (_f.label) {
133
+ case 0:
134
+ multicallContract = curve_1.curve.contracts[this.swap].multicallContract;
135
+ calls = [
136
+ multicallContract.get_virtual_price(),
137
+ multicallContract.fee(),
138
+ multicallContract.admin_fee(),
139
+ multicallContract.A(),
140
+ ];
141
+ if (this.isCrypto)
142
+ calls.push(multicallContract.gamma());
143
+ additionalCalls = this.isCrypto ? [] : [multicallContract.future_A()];
144
+ if ('initial_A' in multicallContract) {
145
+ additionalCalls.push(multicallContract.initial_A(), multicallContract.future_A_time(), multicallContract.initial_A_time());
146
+ }
147
+ return [4 /*yield*/, curve_1.curve.multicallProvider.all(calls)];
134
148
  case 1:
135
- _virtualPrice = _a.sent();
136
- return [2 /*return*/, ethers_1.ethers.utils.formatUnits(_virtualPrice)];
149
+ _a = _f.sent(), _virtualPrice = _a[0], _fee = _a[1], _adminFee = _a[2], _A = _a[3], _gamma = _a[4];
150
+ _c = [
151
+ ethers_1.ethers.utils.formatUnits(_virtualPrice),
152
+ ethers_1.ethers.utils.formatUnits(_fee, 8),
153
+ ethers_1.ethers.utils.formatUnits(_adminFee.mul(_fee)),
154
+ ethers_1.ethers.utils.formatUnits(_A, 0),
155
+ _gamma ? ethers_1.ethers.utils.formatUnits(_gamma) : _gamma,
156
+ ], virtualPrice = _c[0], fee = _c[1], adminFee = _c[2], A = _c[3], gamma = _c[4];
157
+ A_PRECISION = curve_1.curve.chainId === 1 && ['compound', 'usdt', 'y', 'busd', 'susd', 'pax', 'ren', 'sbtc', 'hbtc', '3pool'].includes(this.name) ? 1 : 100;
158
+ return [4 /*yield*/, curve_1.curve.multicallProvider.all(additionalCalls)];
159
+ case 2:
160
+ _d = _f.sent(), _future_A = _d[0], _initial_A = _d[1], _future_A_time = _d[2], _initial_A_time = _d[3];
161
+ _e = [
162
+ _future_A ? String(Number(ethers_1.ethers.utils.formatUnits(_future_A, 0)) / A_PRECISION) : undefined,
163
+ _initial_A ? String(Number(ethers_1.ethers.utils.formatUnits(_initial_A, 0)) / A_PRECISION) : undefined,
164
+ _future_A_time ? Number(ethers_1.ethers.utils.formatUnits(_future_A_time, 0)) * 1000 : undefined,
165
+ _initial_A_time ? Number(ethers_1.ethers.utils.formatUnits(_initial_A_time, 0)) * 1000 : undefined,
166
+ ], future_A = _e[0], initial_A = _e[1], future_A_time = _e[2], initial_A_time = _e[3];
167
+ return [2 /*return*/, { virtualPrice: virtualPrice, fee: fee, adminFee: adminFee, A: A, future_A: future_A, initial_A: initial_A, future_A_time: future_A_time, initial_A_time: initial_A_time, gamma: gamma }];
137
168
  }
138
169
  });
139
170
  }); };
@@ -161,7 +192,7 @@ var Pool = /** @class */ (function () {
161
192
  _poolUnderlyingBalances = this.name !== 'atricrypto3' ? __spreadArray(__spreadArray([], _poolUnderlyingBalance, true), _basePoolExpectedAmounts, true) : __spreadArray(__spreadArray([], _basePoolExpectedAmounts, true), _poolUnderlyingBalance, true);
162
193
  return [3 /*break*/, 6];
163
194
  case 3:
164
- if (!(['compound', 'usdt', 'y', 'busd', 'pax', 'aave', 'saave', 'ib', 'crveth', "cvxeth"].includes(this.name) || (curve_1.curve.chainId === 137 && this.name === 'ren'))) return [3 /*break*/, 5];
195
+ if (!(['compound', 'usdt', 'y', 'busd', 'pax', 'aave', 'saave', 'ib', 'crveth', "cvxeth", "spelleth", "teth"].includes(this.name) || (curve_1.curve.chainId === 137 && this.name === 'ren'))) return [3 /*break*/, 5];
165
196
  return [4 /*yield*/, this._getRates()];
166
197
  case 4:
167
198
  _rates_1 = _a.sent();
@@ -180,9 +211,6 @@ var Pool = /** @class */ (function () {
180
211
  return __generator(this, function (_a) {
181
212
  switch (_a.label) {
182
213
  case 0:
183
- if (this.isFake) {
184
- throw Error("".concat(this.name, " pool doesn't have this method"));
185
- }
186
214
  swapContract = curve_1.curve.contracts[this.swap].multicallContract;
187
215
  contractCalls = this.coins.map(function (_, i) { return swapContract.balances(i); });
188
216
  return [4 /*yield*/, curve_1.curve.multicallProvider.all(contractCalls)];
@@ -192,6 +220,156 @@ var Pool = /** @class */ (function () {
192
220
  }
193
221
  });
194
222
  }); };
223
+ this.getTotalLiquidity = function () { return __awaiter(_this, void 0, void 0, function () {
224
+ var balances, promises, _i, _a, addr, prices, totalLiquidity;
225
+ return __generator(this, function (_c) {
226
+ switch (_c.label) {
227
+ case 0: return [4 /*yield*/, this.getPoolBalances()];
228
+ case 1:
229
+ balances = _c.sent();
230
+ promises = [];
231
+ for (_i = 0, _a = this.underlyingCoinAddresses; _i < _a.length; _i++) {
232
+ addr = _a[_i];
233
+ promises.push((0, utils_1._getUsdRate)(addr));
234
+ }
235
+ return [4 /*yield*/, Promise.all(promises)];
236
+ case 2:
237
+ prices = _c.sent();
238
+ totalLiquidity = balances.reduce(function (liquidity, b, i) { return liquidity + (Number(b) * prices[i]); }, 0);
239
+ return [2 /*return*/, String(totalLiquidity)];
240
+ }
241
+ });
242
+ }); };
243
+ this.getVolume = function () { return __awaiter(_this, void 0, void 0, function () {
244
+ var name, statsUrl, volume, usdRate, _a;
245
+ return __generator(this, function (_c) {
246
+ switch (_c.label) {
247
+ case 0:
248
+ name = (this.name === 'ren' && curve_1.curve.chainId === 1) ? 'ren2' : this.name === 'sbtc' ? 'rens' : this.name;
249
+ statsUrl = (0, utils_1._getStatsUrl)(this.isCrypto);
250
+ return [4 /*yield*/, axios_1.default.get(statsUrl)];
251
+ case 1:
252
+ volume = (_c.sent()).data.volume[name] || 0;
253
+ if (!this.isCrypto) return [3 /*break*/, 2];
254
+ _a = 1;
255
+ return [3 /*break*/, 4];
256
+ case 2: return [4 /*yield*/, (0, utils_1._getUsdRate)(this.referenceAsset)];
257
+ case 3:
258
+ _a = _c.sent();
259
+ _c.label = 4;
260
+ case 4:
261
+ usdRate = _a;
262
+ return [2 /*return*/, String(volume * usdRate)];
263
+ }
264
+ });
265
+ }); };
266
+ this.getBaseApy = function () { return __awaiter(_this, void 0, void 0, function () {
267
+ var name, statsUrl, apy, formattedApy;
268
+ return __generator(this, function (_a) {
269
+ switch (_a.label) {
270
+ case 0:
271
+ name = (this.name === 'ren' && curve_1.curve.chainId === 1) ? 'ren2' : this.name === 'sbtc' ? 'rens' : this.name;
272
+ statsUrl = (0, utils_1._getStatsUrl)(this.isCrypto);
273
+ return [4 /*yield*/, axios_1.default.get(statsUrl)];
274
+ case 1:
275
+ apy = (_a.sent()).data.apy;
276
+ formattedApy = [apy.day[name], apy.week[name], apy.month[name], apy.total[name]].map(function (x) { return (x * 100).toFixed(4); });
277
+ return [2 /*return*/, {
278
+ day: formattedApy[0],
279
+ week: formattedApy[1],
280
+ month: formattedApy[2],
281
+ total: formattedApy[3],
282
+ }];
283
+ }
284
+ });
285
+ }); };
286
+ this.getTokenApy = function () { return __awaiter(_this, void 0, void 0, function () {
287
+ var gaugeContract, lpTokenContract, gaugeControllerContract, totalLiquidityUSD, _a, inflation, weight, workingSupply, totalSupply, rate, crvRate, baseApy, boostedApy;
288
+ return __generator(this, function (_c) {
289
+ switch (_c.label) {
290
+ case 0:
291
+ if (curve_1.curve.chainId === 137)
292
+ throw Error("No such method on network with id ".concat(curve_1.curve.chainId, ". Use getRewardsApy instead"));
293
+ gaugeContract = curve_1.curve.contracts[this.gauge].multicallContract;
294
+ lpTokenContract = curve_1.curve.contracts[this.lpToken].multicallContract;
295
+ gaugeControllerContract = curve_1.curve.contracts[curve_1.ALIASES.gauge_controller].multicallContract;
296
+ return [4 /*yield*/, this.getTotalLiquidity()];
297
+ case 1:
298
+ totalLiquidityUSD = _c.sent();
299
+ return [4 /*yield*/, curve_1.curve.multicallProvider.all([
300
+ gaugeContract.inflation_rate(),
301
+ gaugeControllerContract.gauge_relative_weight(this.gauge),
302
+ gaugeContract.working_supply(),
303
+ lpTokenContract.totalSupply(),
304
+ ])];
305
+ case 2:
306
+ _a = (_c.sent()).map(function (value) { return (0, utils_1.toBN)(value); }), inflation = _a[0], weight = _a[1], workingSupply = _a[2], totalSupply = _a[3];
307
+ rate = inflation.times(weight).times(31536000).times(0.4).div(workingSupply).times(totalSupply).div(Number(totalLiquidityUSD));
308
+ return [4 /*yield*/, (0, utils_1._getUsdRate)(curve_1.ALIASES.crv)];
309
+ case 3:
310
+ crvRate = _c.sent();
311
+ baseApy = rate.times(crvRate);
312
+ boostedApy = baseApy.times(2.5);
313
+ return [2 /*return*/, [baseApy.times(100).toFixed(4), boostedApy.times(100).toFixed(4)]];
314
+ }
315
+ });
316
+ }); };
317
+ this.getRewardsApy = function () { return __awaiter(_this, void 0, void 0, function () {
318
+ var apy_1, _i, _a, rewardToken, rewardContract, totalLiquidityUSD, crvRate, inflation, _c, baseApy, rewardTokenContract, symbol, mainPoolsGaugeRewards, mainPoolsGaugeRewardsLowerCase, apyData, apy, _d, apyData_1, data;
319
+ return __generator(this, function (_e) {
320
+ switch (_e.label) {
321
+ case 0:
322
+ if (!(curve_1.curve.chainId === 137)) return [3 /*break*/, 8];
323
+ apy_1 = [];
324
+ _i = 0, _a = this.rewardTokens;
325
+ _e.label = 1;
326
+ case 1:
327
+ if (!(_i < _a.length)) return [3 /*break*/, 7];
328
+ rewardToken = _a[_i];
329
+ rewardContract = curve_1.curve.contracts[this.rewardContract].contract;
330
+ return [4 /*yield*/, this.getTotalLiquidity()];
331
+ case 2:
332
+ totalLiquidityUSD = _e.sent();
333
+ return [4 /*yield*/, (0, utils_1._getUsdRate)(rewardToken)];
334
+ case 3:
335
+ crvRate = _e.sent();
336
+ _c = utils_1.toBN;
337
+ return [4 /*yield*/, rewardContract.reward_data(curve_1.ALIASES.crv, curve_1.curve.constantOptions)];
338
+ case 4:
339
+ inflation = _c.apply(void 0, [(_e.sent()).rate]);
340
+ baseApy = inflation.times(31536000).times(crvRate).div(Number(totalLiquidityUSD));
341
+ rewardTokenContract = curve_1.curve.contracts[rewardToken].contract;
342
+ return [4 /*yield*/, rewardTokenContract.symbol()];
343
+ case 5:
344
+ symbol = _e.sent();
345
+ apy_1.push({
346
+ token: rewardToken,
347
+ symbol: symbol,
348
+ apy: baseApy.times(100).toFixed(4),
349
+ });
350
+ _e.label = 6;
351
+ case 6:
352
+ _i++;
353
+ return [3 /*break*/, 1];
354
+ case 7: return [2 /*return*/, apy_1];
355
+ case 8: return [4 /*yield*/, axios_1.default.get("https://api.curve.fi/api/getMainPoolsGaugeRewards")];
356
+ case 9:
357
+ mainPoolsGaugeRewards = (_e.sent()).data.data.mainPoolsGaugeRewards;
358
+ mainPoolsGaugeRewardsLowerCase = Object.fromEntries(Object.entries(mainPoolsGaugeRewards).map(function (entry) { return [entry[0].toLowerCase(), entry[1]]; }));
359
+ apyData = mainPoolsGaugeRewardsLowerCase[this.gauge.toLowerCase()] || [];
360
+ apy = [];
361
+ for (_d = 0, apyData_1 = apyData; _d < apyData_1.length; _d++) {
362
+ data = apyData_1[_d];
363
+ apy.push({
364
+ token: data.tokenAddress,
365
+ symbol: data.symbol,
366
+ apy: String(data.apy),
367
+ });
368
+ }
369
+ return [2 /*return*/, apy];
370
+ }
371
+ });
372
+ }); };
195
373
  this.addLiquidityExpected = function (amounts) { return __awaiter(_this, void 0, void 0, function () {
196
374
  var _this = this;
197
375
  return __generator(this, function (_a) {
@@ -281,7 +459,7 @@ var Pool = /** @class */ (function () {
281
459
  return [4 /*yield*/, this._addLiquidityZap(_amounts, true)];
282
460
  case 3: return [2 /*return*/, _d.sent()];
283
461
  case 4:
284
- if (!(['aave', 'saave', 'ib', 'crveth', "cvxeth"].includes(this.name) || (curve_1.curve.chainId === 137 && this.name === 'ren'))) return [3 /*break*/, 6];
462
+ if (!(['aave', 'saave', 'ib', 'crveth', "cvxeth", "spelleth", "teth"].includes(this.name) || (curve_1.curve.chainId === 137 && this.name === 'ren'))) return [3 /*break*/, 6];
285
463
  return [4 /*yield*/, this._addLiquidity(_amounts, true, true)];
286
464
  case 5: return [2 /*return*/, _d.sent()];
287
465
  case 6:
@@ -329,7 +507,7 @@ var Pool = /** @class */ (function () {
329
507
  return [4 /*yield*/, this._addLiquidityZap(_amounts)];
330
508
  case 2: return [2 /*return*/, _a.sent()];
331
509
  case 3:
332
- if (!(['aave', 'saave', 'ib', 'crveth', "cvxeth"].includes(this.name) || (curve_1.curve.chainId === 137 && this.name === 'ren'))) return [3 /*break*/, 5];
510
+ if (!(['aave', 'saave', 'ib', 'crveth', "cvxeth", "spelleth", "teth"].includes(this.name) || (curve_1.curve.chainId === 137 && this.name === 'ren'))) return [3 /*break*/, 5];
333
511
  return [4 /*yield*/, this._addLiquidity(_amounts, true)];
334
512
  case 4: return [2 /*return*/, _a.sent()];
335
513
  case 5:
@@ -459,7 +637,7 @@ var Pool = /** @class */ (function () {
459
637
  _amounts = amounts.map(function (amount, i) {
460
638
  return ethers_1.ethers.utils.parseUnits(amount, _this.decimals[i]);
461
639
  });
462
- if (!(['aave', 'saave', 'ib', 'crveth', "cvxeth"].includes(this.name) || (curve_1.curve.chainId === 137 && this.name === 'ren'))) return [3 /*break*/, 4];
640
+ if (!(['aave', 'saave', 'ib', 'crveth', "cvxeth", "spelleth", "teth"].includes(this.name) || (curve_1.curve.chainId === 137 && this.name === 'ren'))) return [3 /*break*/, 4];
463
641
  return [4 /*yield*/, this._addLiquidity(_amounts, false, true)];
464
642
  case 3: return [2 /*return*/, _d.sent()];
465
643
  case 4: return [4 /*yield*/, this._addLiquiditySwap(_amounts, true)];
@@ -487,7 +665,7 @@ var Pool = /** @class */ (function () {
487
665
  return [4 /*yield*/, curve_1.curve.updateFeeData()];
488
666
  case 1:
489
667
  _a.sent();
490
- if (!(['aave', 'saave', 'ib', 'crveth', "cvxeth"].includes(this.name) || (curve_1.curve.chainId === 137 && this.name === 'ren'))) return [3 /*break*/, 3];
668
+ if (!(['aave', 'saave', 'ib', 'crveth', "cvxeth", "spelleth", "teth"].includes(this.name) || (curve_1.curve.chainId === 137 && this.name === 'ren'))) return [3 /*break*/, 3];
491
669
  return [4 /*yield*/, this._addLiquidity(_amounts, false)];
492
670
  case 2: return [2 /*return*/, _a.sent()];
493
671
  case 3: return [4 /*yield*/, this._addLiquiditySwap(_amounts)];
@@ -504,7 +682,7 @@ var Pool = /** @class */ (function () {
504
682
  switch (_a.label) {
505
683
  case 0:
506
684
  _lpTokenAmount = ethers_1.ethers.utils.parseUnits(lpTokenAmount);
507
- if (!(['compound', 'usdt', 'y', 'busd', 'pax', 'aave', 'saave', 'ib', 'crveth', "cvxeth"].includes(this.name) || (curve_1.curve.chainId === 137 && this.name === 'ren'))) return [3 /*break*/, 2];
685
+ if (!(['compound', 'usdt', 'y', 'busd', 'pax', 'aave', 'saave', 'ib', 'crveth', "cvxeth", "spelleth", "teth"].includes(this.name) || (curve_1.curve.chainId === 137 && this.name === 'ren'))) return [3 /*break*/, 2];
508
686
  return [4 /*yield*/, this._calcExpectedUnderlyingAmounts(_lpTokenAmount)];
509
687
  case 1:
510
688
  _expected = _a.sent(); // Lending pools
@@ -581,7 +759,7 @@ var Pool = /** @class */ (function () {
581
759
  return [4 /*yield*/, this._removeLiquidityZap(_lpTokenAmount, true)];
582
760
  case 4: return [2 /*return*/, _c.sent()];
583
761
  case 5:
584
- if (!(['aave', 'saave', 'ib', 'crveth', "cvxeth"].includes(this.name) || (curve_1.curve.chainId === 137 && this.name === 'ren'))) return [3 /*break*/, 7];
762
+ if (!(['aave', 'saave', 'ib', 'crveth', "cvxeth", "spelleth", "teth"].includes(this.name) || (curve_1.curve.chainId === 137 && this.name === 'ren'))) return [3 /*break*/, 7];
585
763
  return [4 /*yield*/, this._removeLiquidity(_lpTokenAmount, true, true)];
586
764
  case 6: return [2 /*return*/, _c.sent()];
587
765
  case 7:
@@ -606,7 +784,7 @@ var Pool = /** @class */ (function () {
606
784
  return [4 /*yield*/, this._removeLiquidityZap(_lpTokenAmount)];
607
785
  case 2: return [2 /*return*/, _a.sent()];
608
786
  case 3:
609
- if (!(['aave', 'saave', 'ib', 'crveth', "cvxeth"].includes(this.name) || (curve_1.curve.chainId === 137 && this.name === 'ren'))) return [3 /*break*/, 5];
787
+ if (!(['aave', 'saave', 'ib', 'crveth', "cvxeth", "spelleth", "teth"].includes(this.name) || (curve_1.curve.chainId === 137 && this.name === 'ren'))) return [3 /*break*/, 5];
610
788
  return [4 /*yield*/, this._removeLiquidity(_lpTokenAmount, true)];
611
789
  case 4: return [2 /*return*/, _a.sent()];
612
790
  case 5:
@@ -650,7 +828,7 @@ var Pool = /** @class */ (function () {
650
828
  if (Number(lpTokenBalance) < Number(lpTokenAmount)) {
651
829
  throw Error("Not enough LP tokens. Actual: ".concat(lpTokenBalance, ", required: ").concat(lpTokenAmount));
652
830
  }
653
- if (!(['aave', 'saave', 'ib', 'crveth', "cvxeth"].includes(this.name) || (curve_1.curve.chainId === 137 && this.name === 'ren'))) return [3 /*break*/, 3];
831
+ if (!(['aave', 'saave', 'ib', 'crveth', "cvxeth", "spelleth", "teth"].includes(this.name) || (curve_1.curve.chainId === 137 && this.name === 'ren'))) return [3 /*break*/, 3];
654
832
  return [4 /*yield*/, this._removeLiquidity(_lpTokenAmount, false, true)];
655
833
  case 2: return [2 /*return*/, _a.sent()];
656
834
  case 3: return [4 /*yield*/, this._removeLiquiditySwap(_lpTokenAmount, true)];
@@ -670,7 +848,7 @@ var Pool = /** @class */ (function () {
670
848
  return [4 /*yield*/, curve_1.curve.updateFeeData()];
671
849
  case 1:
672
850
  _a.sent();
673
- if (!(['aave', 'saave', 'ib', 'crveth', "cvxeth"].includes(this.name) || (curve_1.curve.chainId === 137 && this.name === 'ren'))) return [3 /*break*/, 3];
851
+ if (!(['aave', 'saave', 'ib', 'crveth', "cvxeth", "spelleth", "teth"].includes(this.name) || (curve_1.curve.chainId === 137 && this.name === 'ren'))) return [3 /*break*/, 3];
674
852
  return [4 /*yield*/, this._removeLiquidity(_lpTokenAmount, false)];
675
853
  case 2: return [2 /*return*/, _a.sent()];
676
854
  case 3: return [4 /*yield*/, this._removeLiquiditySwap(_lpTokenAmount)];
@@ -1047,7 +1225,7 @@ var Pool = /** @class */ (function () {
1047
1225
  return [4 /*yield*/, this._removeLiquidityOneCoinZap(_lpTokenAmount, i, true)];
1048
1226
  case 4: return [2 /*return*/, _c.sent()];
1049
1227
  case 5:
1050
- if (!(['aave', 'saave', 'ib', 'crveth', "cvxeth"].includes(this.name) || (curve_1.curve.chainId === 137 && this.name === 'ren'))) return [3 /*break*/, 7];
1228
+ if (!(['aave', 'saave', 'ib', 'crveth', "cvxeth", "spelleth", "teth"].includes(this.name) || (curve_1.curve.chainId === 137 && this.name === 'ren'))) return [3 /*break*/, 7];
1051
1229
  return [4 /*yield*/, this._removeLiquidityOneCoin(_lpTokenAmount, i, true, true)];
1052
1230
  case 6: return [2 /*return*/, _c.sent()];
1053
1231
  case 7: return [4 /*yield*/, this._removeLiquidityOneCoinSwap(_lpTokenAmount, i, true)];
@@ -1071,7 +1249,7 @@ var Pool = /** @class */ (function () {
1071
1249
  return [4 /*yield*/, this._removeLiquidityOneCoinZap(_lpTokenAmount, i)];
1072
1250
  case 2: return [2 /*return*/, _a.sent()];
1073
1251
  case 3:
1074
- if (!(['aave', 'saave', 'ib', 'crveth', "cvxeth"].includes(this.name) || (curve_1.curve.chainId === 137 && this.name === 'ren'))) return [3 /*break*/, 5];
1252
+ if (!(['aave', 'saave', 'ib', 'crveth', "cvxeth", "spelleth", "teth"].includes(this.name) || (curve_1.curve.chainId === 137 && this.name === 'ren'))) return [3 /*break*/, 5];
1075
1253
  return [4 /*yield*/, this._removeLiquidityOneCoin(_lpTokenAmount, i, true)];
1076
1254
  case 4: return [2 /*return*/, _a.sent()];
1077
1255
  case 5: return [4 /*yield*/, this._removeLiquidityOneCoinSwap(_lpTokenAmount, i)];
@@ -1143,7 +1321,7 @@ var Pool = /** @class */ (function () {
1143
1321
  throw Error("".concat(this.name, " pool doesn't have remove_liquidity_one_coin method for wrapped tokens"));
1144
1322
  }
1145
1323
  _lpTokenAmount = ethers_1.ethers.utils.parseUnits(lpTokenAmount);
1146
- if (!(['aave', 'saave', 'ib', 'crveth', "cvxeth"].includes(this.name) || (curve_1.curve.chainId === 137 && this.name === 'ren'))) return [3 /*break*/, 3];
1324
+ if (!(['aave', 'saave', 'ib', 'crveth', "cvxeth", "spelleth", "teth"].includes(this.name) || (curve_1.curve.chainId === 137 && this.name === 'ren'))) return [3 /*break*/, 3];
1147
1325
  return [4 /*yield*/, this._removeLiquidityOneCoin(_lpTokenAmount, i, false, true)];
1148
1326
  case 2: return [2 /*return*/, _a.sent()];
1149
1327
  case 3: return [4 /*yield*/, this._removeLiquidityOneCoinSwap(_lpTokenAmount, i, true)];
@@ -1167,7 +1345,7 @@ var Pool = /** @class */ (function () {
1167
1345
  case 1:
1168
1346
  _a.sent();
1169
1347
  _lpTokenAmount = ethers_1.ethers.utils.parseUnits(lpTokenAmount);
1170
- if (!(['aave', 'saave', 'ib', 'crveth', "cvxeth"].includes(this.name) || (curve_1.curve.chainId === 137 && this.name === 'ren'))) return [3 /*break*/, 3];
1348
+ if (!(['aave', 'saave', 'ib', 'crveth', "cvxeth", "spelleth", "teth"].includes(this.name) || (curve_1.curve.chainId === 137 && this.name === 'ren'))) return [3 /*break*/, 3];
1171
1349
  return [4 /*yield*/, this._removeLiquidityOneCoin(_lpTokenAmount, i, false)];
1172
1350
  case 2: return [2 /*return*/, _a.sent()];
1173
1351
  case 3: return [4 /*yield*/, this._removeLiquidityOneCoinSwap(_lpTokenAmount, i)];
@@ -1205,13 +1383,13 @@ var Pool = /** @class */ (function () {
1205
1383
  switch (_a.label) {
1206
1384
  case 0:
1207
1385
  _lpTokenAmount = ethers_1.ethers.utils.parseUnits(lpTokenAmount);
1208
- return [4 /*yield*/, curve_1.curve.contracts[this.gauge].contract.estimateGas.deposit(_lpTokenAmount, curve_1.curve.options)];
1386
+ return [4 /*yield*/, curve_1.curve.contracts[this.gauge].contract.estimateGas.deposit(_lpTokenAmount, curve_1.curve.constantOptions)];
1209
1387
  case 1: return [2 /*return*/, (_a.sent()).toNumber()];
1210
1388
  }
1211
1389
  });
1212
1390
  }); };
1213
1391
  this.gaugeDeposit = function (lpTokenAmount) { return __awaiter(_this, void 0, void 0, function () {
1214
- var _lpTokenAmount;
1392
+ var _lpTokenAmount, gasLimit;
1215
1393
  return __generator(this, function (_a) {
1216
1394
  switch (_a.label) {
1217
1395
  case 0:
@@ -1219,8 +1397,11 @@ var Pool = /** @class */ (function () {
1219
1397
  return [4 /*yield*/, (0, utils_1._ensureAllowance)([this.lpToken], [_lpTokenAmount], this.gauge)];
1220
1398
  case 1:
1221
1399
  _a.sent();
1222
- return [4 /*yield*/, curve_1.curve.contracts[this.gauge].contract.deposit(_lpTokenAmount, curve_1.curve.options)];
1223
- case 2: return [2 /*return*/, (_a.sent()).hash];
1400
+ return [4 /*yield*/, curve_1.curve.contracts[this.gauge].contract.estimateGas.deposit(_lpTokenAmount, curve_1.curve.constantOptions)];
1401
+ case 2:
1402
+ gasLimit = (_a.sent()).mul(150).div(100);
1403
+ return [4 /*yield*/, curve_1.curve.contracts[this.gauge].contract.deposit(_lpTokenAmount, __assign(__assign({}, curve_1.curve.options), { gasLimit: gasLimit }))];
1404
+ case 3: return [2 /*return*/, (_a.sent()).hash];
1224
1405
  }
1225
1406
  });
1226
1407
  }); };
@@ -1230,19 +1411,139 @@ var Pool = /** @class */ (function () {
1230
1411
  switch (_a.label) {
1231
1412
  case 0:
1232
1413
  _lpTokenAmount = ethers_1.ethers.utils.parseUnits(lpTokenAmount);
1233
- return [4 /*yield*/, curve_1.curve.contracts[this.gauge].contract.estimateGas.withdraw(_lpTokenAmount, curve_1.curve.options)];
1414
+ return [4 /*yield*/, curve_1.curve.contracts[this.gauge].contract.estimateGas.withdraw(_lpTokenAmount, curve_1.curve.constantOptions)];
1234
1415
  case 1: return [2 /*return*/, (_a.sent()).toNumber()];
1235
1416
  }
1236
1417
  });
1237
1418
  }); };
1238
1419
  this.gaugeWithdraw = function (lpTokenAmount) { return __awaiter(_this, void 0, void 0, function () {
1239
- var _lpTokenAmount;
1420
+ var _lpTokenAmount, gasLimit;
1240
1421
  return __generator(this, function (_a) {
1241
1422
  switch (_a.label) {
1242
1423
  case 0:
1243
1424
  _lpTokenAmount = ethers_1.ethers.utils.parseUnits(lpTokenAmount);
1244
- return [4 /*yield*/, curve_1.curve.contracts[this.gauge].contract.withdraw(_lpTokenAmount, curve_1.curve.options)];
1245
- case 1: return [2 /*return*/, (_a.sent()).hash];
1425
+ return [4 /*yield*/, curve_1.curve.contracts[this.gauge].contract.estimateGas.withdraw(_lpTokenAmount, curve_1.curve.constantOptions)];
1426
+ case 1:
1427
+ gasLimit = (_a.sent()).mul(180).div(100);
1428
+ return [4 /*yield*/, curve_1.curve.contracts[this.gauge].contract.withdraw(_lpTokenAmount, __assign(__assign({}, curve_1.curve.options), { gasLimit: gasLimit }))];
1429
+ case 2: return [2 /*return*/, (_a.sent()).hash];
1430
+ }
1431
+ });
1432
+ }); };
1433
+ this.gaugeClaimableTokens = function (address) {
1434
+ if (address === void 0) { address = ""; }
1435
+ return __awaiter(_this, void 0, void 0, function () {
1436
+ var _a, _c;
1437
+ return __generator(this, function (_d) {
1438
+ switch (_d.label) {
1439
+ case 0:
1440
+ if (curve_1.curve.chainId !== 1)
1441
+ throw Error("No such method on network with id ".concat(curve_1.curve.chainId, ". Use gaugeClaimableRewards instead"));
1442
+ address = address || curve_1.curve.signerAddress;
1443
+ if (!address)
1444
+ throw Error("Need to connect wallet or pass address into args");
1445
+ _c = (_a = ethers_1.ethers.utils).formatUnits;
1446
+ return [4 /*yield*/, curve_1.curve.contracts[this.gauge].contract.claimable_tokens(address, curve_1.curve.constantOptions)];
1447
+ case 1: return [2 /*return*/, _c.apply(_a, [_d.sent()])];
1448
+ }
1449
+ });
1450
+ });
1451
+ };
1452
+ this.gaugeClaimTokens = function () { return __awaiter(_this, void 0, void 0, function () {
1453
+ var gasLimit;
1454
+ return __generator(this, function (_a) {
1455
+ switch (_a.label) {
1456
+ case 0:
1457
+ if (curve_1.curve.chainId !== 1)
1458
+ throw Error("No such method on network with id ".concat(curve_1.curve.chainId, ". Use gaugeClaimRewards instead"));
1459
+ return [4 /*yield*/, curve_1.curve.contracts[curve_1.ALIASES.minter].contract.estimateGas.mint(this.gauge, curve_1.curve.constantOptions)];
1460
+ case 1:
1461
+ gasLimit = (_a.sent()).mul(130).div(100);
1462
+ return [4 /*yield*/, curve_1.curve.contracts[curve_1.ALIASES.minter].contract.mint(this.gauge, __assign(__assign({}, curve_1.curve.options), { gasLimit: gasLimit }))];
1463
+ case 2: return [2 /*return*/, (_a.sent()).hash];
1464
+ }
1465
+ });
1466
+ }); };
1467
+ // TODO 1. Fix aave and saave error
1468
+ // TODO 2. Figure out Synthetix cumulative results
1469
+ this.gaugeClaimableRewards = function (address) {
1470
+ if (address === void 0) { address = ""; }
1471
+ return __awaiter(_this, void 0, void 0, function () {
1472
+ var gaugeContract, rewards, _i, _a, rewardToken, rewardTokenContract, symbol, decimals, method, amount, _c, _d, rewardToken, rewardTokenContract, symbol, decimals, amount, _e, _f;
1473
+ return __generator(this, function (_h) {
1474
+ switch (_h.label) {
1475
+ case 0:
1476
+ address = address || curve_1.curve.signerAddress;
1477
+ if (!address)
1478
+ throw Error("Need to connect wallet or pass address into args");
1479
+ gaugeContract = curve_1.curve.contracts[this.gauge].contract;
1480
+ rewards = [];
1481
+ if (!('claimable_reward(address,address)' in gaugeContract)) return [3 /*break*/, 7];
1482
+ _i = 0, _a = this.rewardTokens;
1483
+ _h.label = 1;
1484
+ case 1:
1485
+ if (!(_i < _a.length)) return [3 /*break*/, 6];
1486
+ rewardToken = _a[_i];
1487
+ rewardTokenContract = curve_1.curve.contracts[rewardToken].contract;
1488
+ return [4 /*yield*/, rewardTokenContract.symbol()];
1489
+ case 2:
1490
+ symbol = _h.sent();
1491
+ return [4 /*yield*/, rewardTokenContract.decimals()];
1492
+ case 3:
1493
+ decimals = _h.sent();
1494
+ method = curve_1.curve.chainId === 1 ? "claimable_reward" : "claimable_reward_write";
1495
+ _d = (_c = ethers_1.ethers.utils).formatUnits;
1496
+ return [4 /*yield*/, gaugeContract[method](address, rewardToken, curve_1.curve.constantOptions)];
1497
+ case 4:
1498
+ amount = _d.apply(_c, [_h.sent(), decimals]);
1499
+ rewards.push({
1500
+ token: rewardToken,
1501
+ symbol: symbol,
1502
+ amount: amount,
1503
+ });
1504
+ _h.label = 5;
1505
+ case 5:
1506
+ _i++;
1507
+ return [3 /*break*/, 1];
1508
+ case 6: return [3 /*break*/, 11];
1509
+ case 7:
1510
+ if (!('claimable_reward(address)' in gaugeContract && this.rewardTokens.length > 0)) return [3 /*break*/, 11];
1511
+ rewardToken = this.rewardTokens[0];
1512
+ rewardTokenContract = curve_1.curve.contracts[rewardToken].contract;
1513
+ return [4 /*yield*/, rewardTokenContract.symbol()];
1514
+ case 8:
1515
+ symbol = _h.sent();
1516
+ return [4 /*yield*/, rewardTokenContract.decimals()];
1517
+ case 9:
1518
+ decimals = _h.sent();
1519
+ _f = (_e = ethers_1.ethers.utils).formatUnits;
1520
+ return [4 /*yield*/, gaugeContract.claimable_reward(address, curve_1.curve.constantOptions)];
1521
+ case 10:
1522
+ amount = _f.apply(_e, [_h.sent(), decimals]);
1523
+ rewards.push({
1524
+ token: rewardToken,
1525
+ symbol: symbol,
1526
+ amount: amount,
1527
+ });
1528
+ _h.label = 11;
1529
+ case 11: return [2 /*return*/, rewards];
1530
+ }
1531
+ });
1532
+ });
1533
+ };
1534
+ this.gaugeClaimRewards = function () { return __awaiter(_this, void 0, void 0, function () {
1535
+ var gaugeContract, gasLimit;
1536
+ return __generator(this, function (_a) {
1537
+ switch (_a.label) {
1538
+ case 0:
1539
+ gaugeContract = curve_1.curve.contracts[this.gauge].contract;
1540
+ if (!("claim_rewards()" in gaugeContract))
1541
+ throw Error("".concat(this.name, " pool doesn't have such method"));
1542
+ return [4 /*yield*/, gaugeContract.estimateGas.claim_rewards(curve_1.curve.constantOptions)];
1543
+ case 1:
1544
+ gasLimit = (_a.sent()).mul(130).div(100);
1545
+ return [4 /*yield*/, gaugeContract.claim_rewards(__assign(__assign({}, curve_1.curve.options), { gasLimit: gasLimit }))];
1546
+ case 2: return [2 /*return*/, (_a.sent()).hash];
1246
1547
  }
1247
1548
  });
1248
1549
  }); };
@@ -1336,7 +1637,7 @@ var Pool = /** @class */ (function () {
1336
1637
  return __generator(this, function (_a) {
1337
1638
  switch (_a.label) {
1338
1639
  case 0:
1339
- contractAddress = ["eurtusd", "atricrypto3"].includes(this.name) ? this.zap : this.swap;
1640
+ contractAddress = ["eurtusd", "xautusd", "atricrypto3"].includes(this.name) ? this.zap : this.swap;
1340
1641
  i = this._getCoinIdx(inputCoin);
1341
1642
  return [4 /*yield*/, (0, utils_1.hasAllowance)([this.underlyingCoinAddresses[i]], [amount], curve_1.curve.signerAddress, contractAddress)];
1342
1643
  case 1: return [2 /*return*/, _a.sent()];
@@ -1348,7 +1649,7 @@ var Pool = /** @class */ (function () {
1348
1649
  return __generator(this, function (_a) {
1349
1650
  switch (_a.label) {
1350
1651
  case 0:
1351
- contractAddress = ["eurtusd", "atricrypto3"].includes(this.name) ? this.zap : this.swap;
1652
+ contractAddress = ["eurtusd", "xautusd", "atricrypto3"].includes(this.name) ? this.zap : this.swap;
1352
1653
  i = this._getCoinIdx(inputCoin);
1353
1654
  return [4 /*yield*/, (0, utils_1.ensureAllowanceEstimateGas)([this.underlyingCoinAddresses[i]], [amount], contractAddress)];
1354
1655
  case 1: return [2 /*return*/, _a.sent()];
@@ -1360,7 +1661,7 @@ var Pool = /** @class */ (function () {
1360
1661
  return __generator(this, function (_a) {
1361
1662
  switch (_a.label) {
1362
1663
  case 0:
1363
- contractAddress = ["eurtusd", "atricrypto3"].includes(this.name) ? this.zap : this.swap;
1664
+ contractAddress = ["eurtusd", "xautusd", "atricrypto3"].includes(this.name) ? this.zap : this.swap;
1364
1665
  i = this._getCoinIdx(inputCoin);
1365
1666
  return [4 /*yield*/, (0, utils_1.ensureAllowance)([this.underlyingCoinAddresses[i]], [amount], contractAddress)];
1366
1667
  case 1: return [2 /*return*/, _a.sent()];
@@ -1374,7 +1675,7 @@ var Pool = /** @class */ (function () {
1374
1675
  return __generator(this, function (_d) {
1375
1676
  switch (_d.label) {
1376
1677
  case 0:
1377
- contractAddress = ["eurtusd", "atricrypto3"].includes(this.name) ? this.zap : this.swap;
1678
+ contractAddress = ["eurtusd", "xautusd", "atricrypto3"].includes(this.name) ? this.zap : this.swap;
1378
1679
  i = this._getCoinIdx(inputCoin);
1379
1680
  j = this._getCoinIdx(outputCoin);
1380
1681
  _c = (_a = Object).values;
@@ -1415,7 +1716,7 @@ var Pool = /** @class */ (function () {
1415
1716
  return __generator(this, function (_a) {
1416
1717
  switch (_a.label) {
1417
1718
  case 0:
1418
- contractAddress = ["eurtusd", "atricrypto3"].includes(this.name) ? this.zap : this.swap;
1719
+ contractAddress = ["eurtusd", "xautusd", "atricrypto3"].includes(this.name) ? this.zap : this.swap;
1419
1720
  i = this._getCoinIdx(inputCoin);
1420
1721
  j = this._getCoinIdx(outputCoin);
1421
1722
  _amount = ethers_1.ethers.utils.parseUnits(amount, this.underlyingDecimals[i]);
@@ -1718,32 +2019,6 @@ var Pool = /** @class */ (function () {
1718
2019
  }
1719
2020
  });
1720
2021
  }); };
1721
- this.getApy = function () { return __awaiter(_this, void 0, void 0, function () {
1722
- var swapContract, gaugeContract, gaugeControllerContract, _a, inflation, weight, workingSupply, virtualPrice, rate, crvRate, baseApy, boostedApy;
1723
- return __generator(this, function (_c) {
1724
- switch (_c.label) {
1725
- case 0:
1726
- swapContract = curve_1.curve.contracts[this.swap].multicallContract;
1727
- gaugeContract = curve_1.curve.contracts[this.gauge].multicallContract;
1728
- gaugeControllerContract = curve_1.curve.contracts[curve_1.ALIASES.gauge_controller].multicallContract;
1729
- return [4 /*yield*/, curve_1.curve.multicallProvider.all([
1730
- gaugeContract.inflation_rate(),
1731
- gaugeControllerContract.gauge_relative_weight(this.gauge),
1732
- gaugeContract.working_supply(),
1733
- swapContract.get_virtual_price(),
1734
- ])];
1735
- case 1:
1736
- _a = (_c.sent()).map(function (value) { return (0, utils_1.toBN)(value); }), inflation = _a[0], weight = _a[1], workingSupply = _a[2], virtualPrice = _a[3];
1737
- rate = inflation.times(weight).times(31536000).div(workingSupply).times(0.4).div(virtualPrice);
1738
- return [4 /*yield*/, (0, utils_1.getCrvRate)()];
1739
- case 2:
1740
- crvRate = _c.sent();
1741
- baseApy = rate.times(crvRate);
1742
- boostedApy = baseApy.times(2.5);
1743
- return [2 /*return*/, [baseApy.toFixed(4), boostedApy.toFixed(4)]];
1744
- }
1745
- });
1746
- }); };
1747
2022
  this._getCoinIdx = function (coin, useUnderlying) {
1748
2023
  if (useUnderlying === void 0) { useUnderlying = true; }
1749
2024
  if (typeof coin === 'number') {
@@ -1946,7 +2221,7 @@ var Pool = /** @class */ (function () {
1946
2221
  switch (_a.label) {
1947
2222
  case 0:
1948
2223
  contract = curve_1.curve.contracts[this.swap].contract;
1949
- if (!["eurtusd", "crveth", "cvxeth"].includes(this.name)) return [3 /*break*/, 2];
2224
+ if (!["eurtusd", "xautusd", "crveth", "cvxeth", "spelleth", "teth"].includes(this.name)) return [3 /*break*/, 2];
1950
2225
  return [4 /*yield*/, contract.calc_token_amount(_amounts, curve_1.curve.constantOptions)];
1951
2226
  case 1: return [2 /*return*/, _a.sent()];
1952
2227
  case 2: return [4 /*yield*/, contract.calc_token_amount(_amounts, isDeposit, curve_1.curve.constantOptions)];
@@ -1967,7 +2242,7 @@ var Pool = /** @class */ (function () {
1967
2242
  return [4 /*yield*/, contract.calc_token_amount(this.swap, _amounts, isDeposit, curve_1.curve.constantOptions)];
1968
2243
  case 1: return [2 /*return*/, _a.sent()];
1969
2244
  case 2:
1970
- if (!(this.name === "eurtusd")) return [3 /*break*/, 4];
2245
+ if (!["eurtusd", "xautusd"].includes(this.name)) return [3 /*break*/, 4];
1971
2246
  return [4 /*yield*/, contract.calc_token_amount(_amounts, curve_1.curve.constantOptions)];
1972
2247
  case 3: return [2 /*return*/, _a.sent()];
1973
2248
  case 4: return [4 /*yield*/, contract.calc_token_amount(_amounts, isDeposit, curve_1.curve.constantOptions)];
@@ -2627,7 +2902,7 @@ var Pool = /** @class */ (function () {
2627
2902
  return __generator(this, function (_a) {
2628
2903
  switch (_a.label) {
2629
2904
  case 0:
2630
- contractAddress = ["eurtusd", "atricrypto3"].includes(this.name) ? this.zap : this.swap;
2905
+ contractAddress = ["eurtusd", "xautusd", "atricrypto3"].includes(this.name) ? this.zap : this.swap;
2631
2906
  contract = curve_1.curve.contracts[contractAddress].contract;
2632
2907
  if (!Object.prototype.hasOwnProperty.call(contract, 'get_dy_underlying')) return [3 /*break*/, 2];
2633
2908
  return [4 /*yield*/, contract.get_dy_underlying(i, j, _amount, curve_1.curve.constantOptions)];
@@ -2647,10 +2922,12 @@ var Pool = /** @class */ (function () {
2647
2922
  }); };
2648
2923
  var poolData = curve_1.POOLS_DATA[name];
2649
2924
  this.name = name;
2925
+ this.referenceAsset = poolData.reference_asset;
2650
2926
  this.swap = poolData.swap_address;
2651
2927
  this.zap = poolData.deposit_address || null;
2652
2928
  this.lpToken = poolData.token_address;
2653
2929
  this.gauge = poolData.gauge_address;
2930
+ this.rewardContract = poolData.reward_contract || null;
2654
2931
  this.underlyingCoins = poolData.underlying_coins;
2655
2932
  this.coins = poolData.coins;
2656
2933
  this.underlyingCoinAddresses = poolData.underlying_coin_addresses;
@@ -2663,6 +2940,7 @@ var Pool = /** @class */ (function () {
2663
2940
  this.isCrypto = poolData.is_crypto || false;
2664
2941
  this.isFactory = poolData.is_factory || false;
2665
2942
  this.basePool = poolData.base_pool || '';
2943
+ this.rewardTokens = poolData.reward_tokens || [];
2666
2944
  this.estimateGas = {
2667
2945
  addLiquidityApprove: this.addLiquidityApproveEstimateGas,
2668
2946
  addLiquidity: this.addLiquidityEstimateGas,
@@ -2685,6 +2963,16 @@ var Pool = /** @class */ (function () {
2685
2963
  exchangeWrappedApprove: this.exchangeWrappedApproveEstimateGas,
2686
2964
  exchangeWrapped: this.exchangeWrappedEstimateGas,
2687
2965
  };
2966
+ this.stats = {
2967
+ getParameters: this.getParameters,
2968
+ getPoolBalances: this.getPoolBalances,
2969
+ getPoolWrappedBalances: this.getPoolWrappedBalances,
2970
+ getTotalLiquidity: this.getTotalLiquidity,
2971
+ getVolume: this.getVolume,
2972
+ getBaseApy: this.getBaseApy,
2973
+ getTokenApy: this.getTokenApy,
2974
+ getRewardsApy: this.getRewardsApy,
2975
+ };
2688
2976
  if (this.isMeta && !this.isFake) {
2689
2977
  var metaCoins = poolData.meta_coin_addresses;
2690
2978
  var metaCoinDecimals = poolData.meta_coin_decimals;
@@ -2765,10 +3053,10 @@ var _getBestPoolAndOutput = function (inputCoinAddress, outputCoinAddress, amoun
2765
3053
  else if (inputCoinIndexes[1] >= 0 && outputCoinIndexes[1] >= 0) {
2766
3054
  return { poolAddress: pool[1].swap_address, _output: ethers_1.ethers.BigNumber.from(0), outputUsd: 0, txCostUsd: 0 };
2767
3055
  }
2768
- else if (inputCoinIndexes[0] === 0 && outputCoinIndexes[2] >= 0 && pool[0] !== 'eurtusd') {
3056
+ else if (inputCoinIndexes[0] === 0 && outputCoinIndexes[2] >= 0 && !['eurtusd', "xautusd"].includes(pool[0])) {
2769
3057
  return { poolAddress: pool[1].swap_address, _output: ethers_1.ethers.BigNumber.from(0), outputUsd: 0, txCostUsd: 0 };
2770
3058
  }
2771
- else if (inputCoinIndexes[2] >= 0 && outputCoinIndexes[0] === 0 && pool[0] !== 'eurtusd') {
3059
+ else if (inputCoinIndexes[2] >= 0 && outputCoinIndexes[0] === 0 && !['eurtusd', "xautusd"].includes(pool[0])) {
2772
3060
  return { poolAddress: pool[1].swap_address, _output: ethers_1.ethers.BigNumber.from(0), outputUsd: 0, txCostUsd: 0 };
2773
3061
  }
2774
3062
  else {