@curvefi/api 1.3.0 → 1.5.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.
package/lib/boosting.js CHANGED
@@ -62,8 +62,8 @@ var getCrv = function () {
62
62
  return __generator(this, function (_b) {
63
63
  switch (_b.label) {
64
64
  case 0:
65
- addresses = utils_1._prepareAddresses(addresses);
66
- return [4 /*yield*/, utils_1._getBalances([curve_1.ALIASES.crv], addresses)];
65
+ addresses = (0, utils_1._prepareAddresses)(addresses);
66
+ return [4 /*yield*/, (0, utils_1._getBalances)([curve_1.ALIASES.crv], addresses)];
67
67
  case 1:
68
68
  rawBalances = (_b.sent());
69
69
  balances = {};
@@ -87,7 +87,7 @@ var getLockedAmountAndUnlockTime = function () {
87
87
  return __generator(this, function (_a) {
88
88
  switch (_a.label) {
89
89
  case 0:
90
- addresses = utils_1._prepareAddresses(addresses);
90
+ addresses = (0, utils_1._prepareAddresses)(addresses);
91
91
  veContract = curve_1.curve.contracts[curve_1.ALIASES.voting_escrow].multicallContract;
92
92
  contractCalls = addresses.map(function (address) { return veContract.locked(address); });
93
93
  return [4 /*yield*/, curve_1.curve.multicallProvider.all(contractCalls)];
@@ -113,7 +113,7 @@ var getVeCrv = function () {
113
113
  return __generator(this, function (_a) {
114
114
  switch (_a.label) {
115
115
  case 0:
116
- addresses = utils_1._prepareAddresses(addresses);
116
+ addresses = (0, utils_1._prepareAddresses)(addresses);
117
117
  veContract = curve_1.curve.contracts[curve_1.ALIASES.voting_escrow].multicallContract;
118
118
  contractCalls = addresses.map(function (address) { return veContract.balanceOf(address); });
119
119
  return [4 /*yield*/, curve_1.curve.multicallProvider.all(contractCalls)];
@@ -139,7 +139,7 @@ var getVeCrvPct = function () {
139
139
  return __generator(this, function (_c) {
140
140
  switch (_c.label) {
141
141
  case 0:
142
- addresses = utils_1._prepareAddresses(addresses);
142
+ addresses = (0, utils_1._prepareAddresses)(addresses);
143
143
  veContract = curve_1.curve.contracts[curve_1.ALIASES.voting_escrow].multicallContract;
144
144
  contractCalls = [veContract.totalSupply()];
145
145
  addresses.forEach(function (address) {
@@ -147,7 +147,7 @@ var getVeCrvPct = function () {
147
147
  });
148
148
  return [4 /*yield*/, curve_1.curve.multicallProvider.all(contractCalls)];
149
149
  case 1:
150
- response = (_c.sent()).map(function (value) { return utils_2.toBN(value); });
150
+ response = (_c.sent()).map(function (value) { return (0, utils_2.toBN)(value); });
151
151
  veTotalSupply = response.splice(0, 1)[0];
152
152
  resultBN = {};
153
153
  addresses.forEach(function (acct, i) {
@@ -156,7 +156,7 @@ var getVeCrvPct = function () {
156
156
  result = {};
157
157
  for (_a = 0, _b = Object.entries(resultBN); _a < _b.length; _a++) {
158
158
  entry = _b[_a];
159
- result[entry[0]] = utils_2.toStringFromBN(entry[1]);
159
+ result[entry[0]] = (0, utils_2.toStringFromBN)(entry[1]);
160
160
  }
161
161
  return [2 /*return*/, addresses.length === 1 ? result[addresses[0]] : result];
162
162
  }
@@ -168,20 +168,20 @@ var createLockEstimateGas = function (amount, days) { return __awaiter(void 0, v
168
168
  var crvBalance, _amount, unlockTime;
169
169
  return __generator(this, function (_a) {
170
170
  switch (_a.label) {
171
- case 0: return [4 /*yield*/, exports.getCrv()];
171
+ case 0: return [4 /*yield*/, (0, exports.getCrv)()];
172
172
  case 1:
173
173
  crvBalance = _a.sent();
174
174
  if (Number(crvBalance) < Number(amount)) {
175
175
  throw Error("Not enough . Actual: " + crvBalance + ", required: " + amount);
176
176
  }
177
- return [4 /*yield*/, utils_1.hasAllowance([curve_1.ALIASES.crv], [amount], curve_1.curve.signerAddress, curve_1.ALIASES.voting_escrow)];
177
+ return [4 /*yield*/, (0, utils_1.hasAllowance)([curve_1.ALIASES.crv], [amount], curve_1.curve.signerAddress, curve_1.ALIASES.voting_escrow)];
178
178
  case 2:
179
179
  if (!(_a.sent())) {
180
180
  throw Error("Token allowance is needed to estimate gas");
181
181
  }
182
182
  _amount = ethers_1.ethers.utils.parseUnits(amount);
183
183
  unlockTime = Math.floor(Date.now() / 1000) + (days * 86400);
184
- return [4 /*yield*/, curve_1.curve.contracts[curve_1.ALIASES.voting_escrow].contract.estimateGas.create_lock(_amount, unlockTime)];
184
+ return [4 /*yield*/, curve_1.curve.contracts[curve_1.ALIASES.voting_escrow].contract.estimateGas.create_lock(_amount, unlockTime, curve_1.curve.constantOptions)];
185
185
  case 3: return [2 /*return*/, (_a.sent()).toNumber()];
186
186
  }
187
187
  });
@@ -194,15 +194,18 @@ var createLock = function (amount, days) { return __awaiter(void 0, void 0, void
194
194
  case 0:
195
195
  _amount = ethers_1.ethers.utils.parseUnits(amount);
196
196
  unlockTime = Math.floor(Date.now() / 1000) + (days * 86400);
197
- return [4 /*yield*/, utils_2._ensureAllowance([curve_1.ALIASES.crv], [_amount], curve_1.ALIASES.voting_escrow)];
197
+ return [4 /*yield*/, (0, utils_2._ensureAllowance)([curve_1.ALIASES.crv], [_amount], curve_1.ALIASES.voting_escrow)];
198
198
  case 1:
199
199
  _a.sent();
200
200
  contract = curve_1.curve.contracts[curve_1.ALIASES.voting_escrow].contract;
201
- return [4 /*yield*/, contract.estimateGas.create_lock(_amount, unlockTime)];
201
+ return [4 /*yield*/, curve_1.curve.updateFeeData()];
202
202
  case 2:
203
+ _a.sent();
204
+ return [4 /*yield*/, contract.estimateGas.create_lock(_amount, unlockTime, curve_1.curve.constantOptions)];
205
+ case 3:
203
206
  gasLimit = (_a.sent()).mul(130).div(100);
204
207
  return [4 /*yield*/, contract.create_lock(_amount, unlockTime, __assign(__assign({}, curve_1.curve.options), { gasLimit: gasLimit }))];
205
- case 3: return [2 /*return*/, (_a.sent()).hash];
208
+ case 4: return [2 /*return*/, (_a.sent()).hash];
206
209
  }
207
210
  });
208
211
  }); };
@@ -211,20 +214,20 @@ var increaseAmountEstimateGas = function (amount) { return __awaiter(void 0, voi
211
214
  var crvBalance, _amount, contract;
212
215
  return __generator(this, function (_a) {
213
216
  switch (_a.label) {
214
- case 0: return [4 /*yield*/, exports.getCrv()];
217
+ case 0: return [4 /*yield*/, (0, exports.getCrv)()];
215
218
  case 1:
216
219
  crvBalance = _a.sent();
217
220
  if (Number(crvBalance) < Number(amount)) {
218
221
  throw Error("Not enough. Actual: " + crvBalance + ", required: " + amount);
219
222
  }
220
- return [4 /*yield*/, utils_1.hasAllowance([curve_1.ALIASES.crv], [amount], curve_1.curve.signerAddress, curve_1.ALIASES.voting_escrow)];
223
+ return [4 /*yield*/, (0, utils_1.hasAllowance)([curve_1.ALIASES.crv], [amount], curve_1.curve.signerAddress, curve_1.ALIASES.voting_escrow)];
221
224
  case 2:
222
225
  if (!(_a.sent())) {
223
226
  throw Error("Token allowance is needed to estimate gas");
224
227
  }
225
228
  _amount = ethers_1.ethers.utils.parseUnits(amount);
226
229
  contract = curve_1.curve.contracts[curve_1.ALIASES.voting_escrow].contract;
227
- return [4 /*yield*/, contract.estimateGas.increase_amount(_amount)];
230
+ return [4 /*yield*/, contract.estimateGas.increase_amount(_amount, curve_1.curve.constantOptions)];
228
231
  case 3: return [2 /*return*/, (_a.sent()).toNumber()];
229
232
  }
230
233
  });
@@ -236,15 +239,18 @@ var increaseAmount = function (amount) { return __awaiter(void 0, void 0, void 0
236
239
  switch (_a.label) {
237
240
  case 0:
238
241
  _amount = ethers_1.ethers.utils.parseUnits(amount);
239
- return [4 /*yield*/, utils_2._ensureAllowance([curve_1.ALIASES.crv], [_amount], curve_1.ALIASES.voting_escrow)];
242
+ return [4 /*yield*/, (0, utils_2._ensureAllowance)([curve_1.ALIASES.crv], [_amount], curve_1.ALIASES.voting_escrow)];
240
243
  case 1:
241
244
  _a.sent();
242
245
  contract = curve_1.curve.contracts[curve_1.ALIASES.voting_escrow].contract;
243
- return [4 /*yield*/, contract.estimateGas.increase_amount(_amount)];
246
+ return [4 /*yield*/, curve_1.curve.updateFeeData()];
244
247
  case 2:
248
+ _a.sent();
249
+ return [4 /*yield*/, contract.estimateGas.increase_amount(_amount, curve_1.curve.constantOptions)];
250
+ case 3:
245
251
  gasLimit = (_a.sent()).mul(130).div(100);
246
252
  return [4 /*yield*/, contract.increase_amount(_amount, __assign(__assign({}, curve_1.curve.options), { gasLimit: gasLimit }))];
247
- case 3: return [2 /*return*/, (_a.sent()).hash];
253
+ case 4: return [2 /*return*/, (_a.sent()).hash];
248
254
  }
249
255
  });
250
256
  }); };
@@ -253,12 +259,12 @@ var increaseUnlockTimeEstimateGas = function (days) { return __awaiter(void 0, v
253
259
  var unlockTime, newUnlockTime, contract;
254
260
  return __generator(this, function (_a) {
255
261
  switch (_a.label) {
256
- case 0: return [4 /*yield*/, exports.getLockedAmountAndUnlockTime()];
262
+ case 0: return [4 /*yield*/, (0, exports.getLockedAmountAndUnlockTime)()];
257
263
  case 1:
258
264
  unlockTime = (_a.sent()).unlockTime;
259
265
  newUnlockTime = Math.floor(unlockTime / 1000) + (days * 86400);
260
266
  contract = curve_1.curve.contracts[curve_1.ALIASES.voting_escrow].contract;
261
- return [4 /*yield*/, contract.estimateGas.increase_unlock_time(newUnlockTime)];
267
+ return [4 /*yield*/, contract.estimateGas.increase_unlock_time(newUnlockTime, curve_1.curve.constantOptions)];
262
268
  case 2: return [2 /*return*/, (_a.sent()).toNumber()];
263
269
  }
264
270
  });
@@ -268,16 +274,19 @@ var increaseUnlockTime = function (days) { return __awaiter(void 0, void 0, void
268
274
  var unlockTime, newUnlockTime, contract, gasLimit;
269
275
  return __generator(this, function (_a) {
270
276
  switch (_a.label) {
271
- case 0: return [4 /*yield*/, exports.getLockedAmountAndUnlockTime()];
277
+ case 0: return [4 /*yield*/, (0, exports.getLockedAmountAndUnlockTime)()];
272
278
  case 1:
273
279
  unlockTime = (_a.sent()).unlockTime;
274
280
  newUnlockTime = Math.floor(unlockTime / 1000) + (days * 86400);
275
281
  contract = curve_1.curve.contracts[curve_1.ALIASES.voting_escrow].contract;
276
- return [4 /*yield*/, contract.estimateGas.increase_unlock_time(newUnlockTime)];
282
+ return [4 /*yield*/, curve_1.curve.updateFeeData()];
277
283
  case 2:
284
+ _a.sent();
285
+ return [4 /*yield*/, contract.estimateGas.increase_unlock_time(newUnlockTime, curve_1.curve.constantOptions)];
286
+ case 3:
278
287
  gasLimit = (_a.sent()).mul(130).div(100);
279
288
  return [4 /*yield*/, contract.increase_unlock_time(newUnlockTime, __assign(__assign({}, curve_1.curve.options), { gasLimit: gasLimit }))];
280
- case 3: return [2 /*return*/, (_a.sent()).hash];
289
+ case 4: return [2 /*return*/, (_a.sent()).hash];
281
290
  }
282
291
  });
283
292
  }); };
@@ -288,7 +297,7 @@ var withdrawLockedCrvEstimateGas = function () { return __awaiter(void 0, void 0
288
297
  switch (_a.label) {
289
298
  case 0:
290
299
  contract = curve_1.curve.contracts[curve_1.ALIASES.voting_escrow].contract;
291
- return [4 /*yield*/, contract.estimateGas.withdraw()];
300
+ return [4 /*yield*/, contract.estimateGas.withdraw(curve_1.curve.constantOptions)];
292
301
  case 1: return [2 /*return*/, (_a.sent()).toNumber()];
293
302
  }
294
303
  });
@@ -300,11 +309,14 @@ var withdrawLockedCrv = function () { return __awaiter(void 0, void 0, void 0, f
300
309
  switch (_a.label) {
301
310
  case 0:
302
311
  contract = curve_1.curve.contracts[curve_1.ALIASES.voting_escrow].contract;
303
- return [4 /*yield*/, contract.estimateGas.withdraw()];
312
+ return [4 /*yield*/, curve_1.curve.updateFeeData()];
304
313
  case 1:
314
+ _a.sent();
315
+ return [4 /*yield*/, contract.estimateGas.withdraw(curve_1.curve.constantOptions)];
316
+ case 2:
305
317
  gasLimit = (_a.sent()).mul(130).div(100);
306
318
  return [4 /*yield*/, contract.withdraw(__assign(__assign({}, curve_1.curve.options), { gasLimit: gasLimit }))];
307
- case 2: return [2 /*return*/, (_a.sent()).hash];
319
+ case 3: return [2 /*return*/, (_a.sent()).hash];
308
320
  }
309
321
  });
310
322
  }); };
@@ -664,8 +664,7 @@
664
664
  "name": "arg0"
665
665
  }
666
666
  ],
667
- "constant": true,
668
- "payable": false,
667
+ "stateMutability": "view",
669
668
  "type": "function",
670
669
  "gas": "2220"
671
670
  },
@@ -664,8 +664,7 @@
664
664
  "name": "arg0"
665
665
  }
666
666
  ],
667
- "constant": true,
668
- "payable": false,
667
+ "stateMutability": "view",
669
668
  "type": "function",
670
669
  "gas": "2250"
671
670
  },
@@ -664,8 +664,7 @@
664
664
  "name": "arg0"
665
665
  }
666
666
  ],
667
- "constant": true,
668
- "payable": false,
667
+ "stateMutability": "view",
669
668
  "type": "function",
670
669
  "gas": "2220"
671
670
  },
@@ -685,8 +685,7 @@
685
685
  "name": "arg0"
686
686
  }
687
687
  ],
688
- "constant": true,
689
- "payable": false,
688
+ "stateMutability": "view",
690
689
  "type": "function",
691
690
  "gas": "2280"
692
691
  },
@@ -671,8 +671,7 @@
671
671
  "name": "arg0"
672
672
  }
673
673
  ],
674
- "constant": true,
675
- "payable": false,
674
+ "stateMutability": "view",
676
675
  "type": "function",
677
676
  "gas": "2340"
678
677
  },
@@ -671,8 +671,7 @@
671
671
  "name": "arg0"
672
672
  }
673
673
  ],
674
- "constant": true,
675
- "payable": false,
674
+ "stateMutability": "view",
676
675
  "type": "function",
677
676
  "gas": "2340"
678
677
  },
@@ -610,8 +610,7 @@
610
610
  "name": "arg0"
611
611
  }
612
612
  ],
613
- "constant": true,
614
- "payable": false,
613
+ "stateMutability": "view",
615
614
  "type": "function",
616
615
  "gas": "2190"
617
616
  },
@@ -664,8 +664,7 @@
664
664
  "name": "arg0"
665
665
  }
666
666
  ],
667
- "constant": true,
668
- "payable": false,
667
+ "stateMutability": "view",
669
668
  "type": "function",
670
669
  "gas": "2250"
671
670
  },
package/lib/curve.d.ts CHANGED
@@ -23,9 +23,18 @@ declare class Curve {
23
23
  multicallContract: MulticallContract;
24
24
  };
25
25
  };
26
- options: {
26
+ feeData: {
27
+ gasPrice?: number;
28
+ maxFeePerGas?: number;
29
+ maxPriorityFeePerGas?: number;
30
+ };
31
+ constantOptions: {
27
32
  gasLimit: number;
33
+ };
34
+ options: {
28
35
  gasPrice?: number | ethers.BigNumber;
36
+ maxFeePerGas?: number | ethers.BigNumber;
37
+ maxPriorityFeePerGas?: number | ethers.BigNumber;
29
38
  };
30
39
  constructor();
31
40
  init(providerType: 'JsonRpc' | 'Web3' | 'Infura', providerSettings: {
@@ -38,9 +47,16 @@ declare class Curve {
38
47
  apiKey?: string;
39
48
  }, options?: {
40
49
  gasPrice?: number;
50
+ maxFeePerGas?: number;
51
+ maxPriorityFeePerGas?: number;
41
52
  chainId?: number;
42
53
  }): Promise<void>;
43
- setGasPrice(gasPrice: number): void;
54
+ setCustomFeeData(customFeeData: {
55
+ gasPrice?: number;
56
+ maxFeePerGas?: number;
57
+ maxPriorityFeePerGas?: number;
58
+ }): void;
59
+ updateFeeData(): Promise<void>;
44
60
  }
45
61
  export declare const curve: Curve;
46
62
  export {};
package/lib/curve.js CHANGED
@@ -1,4 +1,15 @@
1
1
  "use strict";
2
+ var __assign = (this && this.__assign) || function () {
3
+ __assign = Object.assign || function(t) {
4
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
5
+ s = arguments[i];
6
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
7
+ t[p] = s[p];
8
+ }
9
+ return t;
10
+ };
11
+ return __assign.apply(this, arguments);
12
+ };
2
13
  var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
14
  function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
15
  return new (P || (P = Promise))(function (resolve, reject) {
@@ -60,7 +71,7 @@ exports.ALIASES = {
60
71
  "minter": "0xd061D61a4d941c39E5453435B6345Dc261C2fcE0",
61
72
  "fee_distributor": "0xA464e6DCda8AC41e03616F95f4BC98a13b8922Dc",
62
73
  "address_provider": "0x0000000022d53366457f9d5e68ec105046fc4383",
63
- "router": "0x13e987c9169f532e1EAcAFcd69CFc84344Dbd781",
74
+ "router": "0xfA9a30350048B2BF66865ee20363067c66f67e58",
64
75
  };
65
76
  var cTokens = [
66
77
  '0x5d3a536E4D6DbD6114cc1Ead35777bAB948E3643',
@@ -100,15 +111,17 @@ var Curve = /** @class */ (function () {
100
111
  // @ts-ignore
101
112
  this.multicallProvider = null;
102
113
  this.contracts = {};
103
- this.options = { gasLimit: 12000000 };
114
+ this.feeData = {};
115
+ this.constantOptions = { gasLimit: 12000000 };
116
+ this.options = {};
104
117
  }
105
118
  Curve.prototype.init = function (providerType, providerSettings, options // gasPrice in Gwei
106
119
  ) {
107
120
  if (options === void 0) { options = {}; }
108
121
  return __awaiter(this, void 0, void 0, function () {
109
- var _a, _b, _c, _i, _d, pool, _e, _f, coinAddr, _g, _h, coinAddr;
110
- return __generator(this, function (_j) {
111
- switch (_j.label) {
122
+ var _a, _i, _b, pool, _c, _d, coinAddr, _e, _f, coinAddr;
123
+ return __generator(this, function (_g) {
124
+ switch (_g.label) {
112
125
  case 0:
113
126
  // JsonRpc provider
114
127
  if (providerType.toLowerCase() === 'JsonRpc'.toLowerCase()) {
@@ -147,29 +160,23 @@ var Curve = /** @class */ (function () {
147
160
  this.multicallProvider = new ethers_multicall_1.Provider(this.provider);
148
161
  return [4 /*yield*/, this.multicallProvider.init()];
149
162
  case 2:
150
- _j.sent();
151
- _j.label = 3;
163
+ _g.sent();
164
+ _g.label = 3;
152
165
  case 3:
153
166
  if (!this.signer) return [3 /*break*/, 5];
154
167
  _a = this;
155
168
  return [4 /*yield*/, this.signer.getAddress()];
156
169
  case 4:
157
- _a.signerAddress = _j.sent();
158
- _j.label = 5;
170
+ _a.signerAddress = _g.sent();
171
+ _g.label = 5;
159
172
  case 5:
160
- _b = this.options;
161
- if (!(options.gasPrice !== undefined)) return [3 /*break*/, 6];
162
- _c = (options.gasPrice * 1e9);
163
- return [3 /*break*/, 8];
164
- case 6: return [4 /*yield*/, this.provider.getGasPrice()];
165
- case 7:
166
- _c = _j.sent();
167
- _j.label = 8;
168
- case 8:
169
- _b.gasPrice = _c;
173
+ this.feeData = { gasPrice: options.gasPrice, maxFeePerGas: options.maxFeePerGas, maxPriorityFeePerGas: options.maxPriorityFeePerGas };
174
+ return [4 /*yield*/, this.updateFeeData()];
175
+ case 6:
176
+ _g.sent();
170
177
  // TODO delete toLowerCase()
171
- for (_i = 0, _d = Object.values(abis_ethereum_1.poolsData); _i < _d.length; _i++) {
172
- pool = _d[_i];
178
+ for (_i = 0, _b = Object.values(abis_ethereum_1.poolsData); _i < _b.length; _i++) {
179
+ pool = _b[_i];
173
180
  this.contracts[pool.swap_address] = {
174
181
  contract: new ethers_1.Contract(pool.swap_address, pool.swap_abi, this.signer || this.provider),
175
182
  multicallContract: new ethers_multicall_1.Contract(pool.swap_address, pool.swap_abi),
@@ -206,8 +213,8 @@ var Curve = /** @class */ (function () {
206
213
  multicallContract: new ethers_multicall_1.Contract(pool.deposit_address, pool.deposit_abi),
207
214
  };
208
215
  }
209
- for (_e = 0, _f = pool.underlying_coin_addresses; _e < _f.length; _e++) {
210
- coinAddr = _f[_e];
216
+ for (_c = 0, _d = pool.underlying_coin_addresses; _c < _d.length; _c++) {
217
+ coinAddr = _d[_c];
211
218
  this.contracts[coinAddr] = {
212
219
  contract: new ethers_1.Contract(coinAddr, ERC20_json_1.default, this.signer || this.provider),
213
220
  multicallContract: new ethers_multicall_1.Contract(coinAddr, ERC20_json_1.default),
@@ -218,8 +225,8 @@ var Curve = /** @class */ (function () {
218
225
  };
219
226
  }
220
227
  // TODO add all coins
221
- for (_g = 0, _h = pool.coin_addresses; _g < _h.length; _g++) {
222
- coinAddr = _h[_g];
228
+ for (_e = 0, _f = pool.coin_addresses; _e < _f.length; _e++) {
229
+ coinAddr = _f[_e];
223
230
  if (cTokens.includes(coinAddr)) {
224
231
  this.contracts[coinAddr] = {
225
232
  contract: new ethers_1.Contract(coinAddr, cERC20_json_1.default, this.signer || this.provider),
@@ -297,8 +304,50 @@ var Curve = /** @class */ (function () {
297
304
  });
298
305
  });
299
306
  };
300
- Curve.prototype.setGasPrice = function (gasPrice) {
301
- this.options.gasPrice = gasPrice * 1e9;
307
+ Curve.prototype.setCustomFeeData = function (customFeeData) {
308
+ this.feeData = __assign(__assign({}, this.feeData), customFeeData);
309
+ };
310
+ Curve.prototype.updateFeeData = function () {
311
+ return __awaiter(this, void 0, void 0, function () {
312
+ var feeData, _a, _b, _c;
313
+ return __generator(this, function (_d) {
314
+ switch (_d.label) {
315
+ case 0: return [4 /*yield*/, this.provider.getFeeData()];
316
+ case 1:
317
+ feeData = _d.sent();
318
+ if (!(feeData.maxFeePerGas === null || feeData.maxPriorityFeePerGas === null)) return [3 /*break*/, 6];
319
+ delete this.options.maxFeePerGas;
320
+ delete this.options.maxPriorityFeePerGas;
321
+ _a = this.options;
322
+ if (!(this.feeData.gasPrice !== undefined)) return [3 /*break*/, 2];
323
+ _b = ethers_1.ethers.utils.parseUnits(this.feeData.gasPrice.toString(), "gwei");
324
+ return [3 /*break*/, 5];
325
+ case 2:
326
+ _c = feeData.gasPrice;
327
+ if (_c) return [3 /*break*/, 4];
328
+ return [4 /*yield*/, this.provider.getGasPrice()];
329
+ case 3:
330
+ _c = (_d.sent());
331
+ _d.label = 4;
332
+ case 4:
333
+ _b = (_c);
334
+ _d.label = 5;
335
+ case 5:
336
+ _a.gasPrice = _b;
337
+ return [3 /*break*/, 7];
338
+ case 6:
339
+ delete this.options.gasPrice;
340
+ this.options.maxFeePerGas = this.feeData.maxFeePerGas !== undefined ?
341
+ ethers_1.ethers.utils.parseUnits(this.feeData.maxFeePerGas.toString(), "gwei") :
342
+ feeData.maxFeePerGas;
343
+ this.options.maxPriorityFeePerGas = this.feeData.maxPriorityFeePerGas !== undefined ?
344
+ ethers_1.ethers.utils.parseUnits(this.feeData.maxPriorityFeePerGas.toString(), "gwei") :
345
+ feeData.maxFeePerGas;
346
+ _d.label = 7;
347
+ case 7: return [2 /*return*/];
348
+ }
349
+ });
350
+ });
302
351
  };
303
352
  return Curve;
304
353
  }());
package/lib/index.d.ts CHANGED
@@ -11,12 +11,18 @@ declare function init(providerType: 'JsonRpc' | 'Web3' | 'Infura', providerSetti
11
11
  apiKey?: string;
12
12
  }, options?: {
13
13
  gasPrice?: number;
14
+ maxFeePerGas?: number;
15
+ maxPriorityFeePerGas?: number;
14
16
  chainId?: number;
15
17
  }): Promise<void>;
16
- declare function setGasPrice(gasPrice: number): void;
18
+ declare function setCustomFeeData(customFeeData: {
19
+ gasPrice?: number;
20
+ maxFeePerGas?: number;
21
+ maxPriorityFeePerGas?: number;
22
+ }): void;
17
23
  declare const curve: {
18
24
  init: typeof init;
19
- setGasPrice: typeof setGasPrice;
25
+ setCustomFeeData: typeof setCustomFeeData;
20
26
  signerAddress: string;
21
27
  Pool: typeof Pool;
22
28
  getBalances: (coins: string[], ...addresses: string[] | string[][]) => Promise<string[] | import("./interfaces").DictInterface<string[]>>;
package/lib/index.js CHANGED
@@ -55,12 +55,12 @@ function init(providerType, providerSettings, options) {
55
55
  });
56
56
  });
57
57
  }
58
- function setGasPrice(gasPrice) {
59
- curve_1.curve.setGasPrice(gasPrice);
58
+ function setCustomFeeData(customFeeData) {
59
+ curve_1.curve.setCustomFeeData(customFeeData);
60
60
  }
61
61
  var curve = {
62
62
  init: init,
63
- setGasPrice: setGasPrice,
63
+ setCustomFeeData: setCustomFeeData,
64
64
  signerAddress: '',
65
65
  Pool: pools_1.Pool,
66
66
  getBalances: utils_1.getBalances,
package/lib/pools.d.ts CHANGED
@@ -18,46 +18,80 @@ export declare class Pool {
18
18
  basePool: string;
19
19
  isFactory: boolean;
20
20
  estimateGas: {
21
+ addLiquidityApprove: (amounts: string[]) => Promise<number>;
21
22
  addLiquidity: (amounts: string[]) => Promise<number>;
23
+ addLiquidityWrappedApprove: (amounts: string[]) => Promise<number>;
22
24
  addLiquidityWrapped: (amounts: string[]) => Promise<number>;
25
+ gaugeDepositApprove: (lpTokenAmount: string) => Promise<number>;
26
+ gaugeDeposit: (lpTokenAmount: string) => Promise<number>;
27
+ gaugeWithdraw: (lpTokenAmount: string) => Promise<number>;
28
+ removeLiquidityApprove: (lpTokenAmount: string) => Promise<number>;
23
29
  removeLiquidity: (lpTokenAmount: string) => Promise<number>;
24
30
  removeLiquidityWrapped: (lpTokenAmount: string) => Promise<number>;
31
+ removeLiquidityImbalanceApprove: (amounts: string[]) => Promise<number>;
25
32
  removeLiquidityImbalance: (amounts: string[]) => Promise<number>;
26
33
  removeLiquidityImbalanceWrapped: (amounts: string[]) => Promise<number>;
34
+ removeLiquidityOneCoinApprove: (lpTokenAmount: string, coin: string | number) => Promise<number>;
27
35
  removeLiquidityOneCoin: (lpTokenAmount: string, coin: string | number) => Promise<number>;
28
36
  removeLiquidityOneCoinWrapped: (lpTokenAmount: string, coin: string | number) => Promise<number>;
37
+ exchangeApprove: (inputCoin: string | number, amount: string) => Promise<number>;
29
38
  exchange: (inputCoin: string | number, outputCoin: string | number, amount: string, maxSlippage: number) => Promise<number>;
30
- exchangeTricrypto: (inputCoin: string | number, outputCoin: string | number, amount: string, maxSlippage: number, useEth: boolean) => Promise<number>;
39
+ exchangeTricryptoApprove: (inputCoin: string | number, amount: string, useEth?: boolean) => Promise<number>;
40
+ exchangeTricrypto: (inputCoin: string | number, outputCoin: string | number, amount: string, maxSlippage: number, useEth?: boolean) => Promise<number>;
41
+ exchangeWrappedApprove: (inputCoin: string | number, amount: string) => Promise<number>;
31
42
  exchangeWrapped: (inputCoin: string | number, outputCoin: string | number, amount: string, maxSlippage: number) => Promise<number>;
32
43
  };
33
44
  constructor(name: string);
34
45
  calcLpTokenAmount: (amounts: string[], isDeposit?: boolean) => Promise<string>;
35
46
  calcLpTokenAmountWrapped: (amounts: string[], isDeposit?: boolean) => Promise<string>;
47
+ getVirtualPrice: () => Promise<string>;
36
48
  addLiquidityExpected: (amounts: string[]) => Promise<string>;
49
+ addLiquidityIsApproved: (amounts: string[]) => Promise<boolean>;
50
+ private addLiquidityApproveEstimateGas;
51
+ addLiquidityApprove: (amounts: string[]) => Promise<string[]>;
37
52
  private addLiquidityEstimateGas;
53
+ balancedAmounts: () => Promise<string[]>;
38
54
  addLiquidity: (amounts: string[]) => Promise<string>;
55
+ balancedWrappedAmounts: (address?: string | undefined) => Promise<string[]>;
39
56
  addLiquidityWrappedExpected: (amounts: string[]) => Promise<string>;
57
+ addLiquidityWrappedIsApproved: (amounts: string[]) => Promise<boolean>;
58
+ private addLiquidityWrappedApproveEstimateGas;
59
+ addLiquidityWrappedApprove: (amounts: string[]) => Promise<string[]>;
40
60
  private addLiquidityWrappedEstimateGas;
41
61
  addLiquidityWrapped: (amounts: string[]) => Promise<string>;
42
62
  removeLiquidityExpected: (lpTokenAmount: string) => Promise<string[]>;
63
+ removeLiquidityIsApproved: (lpTokenAmount: string) => Promise<boolean>;
64
+ private removeLiquidityApproveEstimateGas;
65
+ removeLiquidityApprove: (lpTokenAmount: string) => Promise<string[]>;
43
66
  private removeLiquidityEstimateGas;
44
67
  removeLiquidity: (lpTokenAmount: string) => Promise<string>;
45
68
  removeLiquidityWrappedExpected: (lpTokenAmount: string) => Promise<string[]>;
46
69
  private removeLiquidityWrappedEstimateGas;
47
70
  removeLiquidityWrapped: (lpTokenAmount: string) => Promise<string>;
48
71
  removeLiquidityImbalanceExpected: (amounts: string[]) => Promise<string>;
72
+ removeLiquidityImbalanceIsApproved: (amounts: string[]) => Promise<boolean>;
73
+ private removeLiquidityImbalanceApproveEstimateGas;
74
+ removeLiquidityImbalanceApprove: (amounts: string[]) => Promise<string[]>;
49
75
  private removeLiquidityImbalanceEstimateGas;
50
76
  removeLiquidityImbalance: (amounts: string[]) => Promise<string>;
51
77
  removeLiquidityImbalanceWrappedExpected: (amounts: string[]) => Promise<string>;
52
78
  private removeLiquidityImbalanceWrappedEstimateGas;
53
79
  removeLiquidityImbalanceWrapped: (amounts: string[], estimateGas?: boolean) => Promise<string | number>;
54
80
  removeLiquidityOneCoinExpected: (lpTokenAmount: string, coin: string | number) => Promise<string>;
81
+ removeLiquidityOneCoinIsApproved: (lpTokenAmount: string) => Promise<boolean>;
82
+ private removeLiquidityOneCoinApproveEstimateGas;
83
+ removeLiquidityOneCoinApprove: (lpTokenAmount: string) => Promise<string[]>;
55
84
  private removeLiquidityOneCoinEstimateGas;
56
85
  removeLiquidityOneCoin: (lpTokenAmount: string, coin: string | number) => Promise<string>;
57
86
  removeLiquidityOneCoinWrappedExpected: (lpTokenAmount: string, coin: string | number) => Promise<string>;
58
87
  private removeLiquidityOneCoinWrappedEstimateGas;
59
88
  removeLiquidityOneCoinWrapped: (lpTokenAmount: string, coin: string | number) => Promise<string>;
89
+ gaugeDepositIsApproved: (lpTokenAmount: string) => Promise<boolean>;
90
+ private gaugeDepositApproveEstimateGas;
91
+ gaugeDepositApprove: (lpTokenAmount: string) => Promise<string[]>;
92
+ private gaugeDepositEstimateGas;
60
93
  gaugeDeposit: (lpTokenAmount: string) => Promise<string>;
94
+ private gaugeWithdrawEstimateGas;
61
95
  gaugeWithdraw: (lpTokenAmount: string) => Promise<string>;
62
96
  balances: (...addresses: string[] | string[][]) => Promise<DictInterface<DictInterface<string>> | DictInterface<string>>;
63
97
  lpTokenBalances: (...addresses: string[] | string[][]) => Promise<DictInterface<DictInterface<string>> | DictInterface<string>>;
@@ -65,11 +99,20 @@ export declare class Pool {
65
99
  coinBalances: (...addresses: string[] | string[][]) => Promise<DictInterface<DictInterface<string>> | DictInterface<string>>;
66
100
  allCoinBalances: (...addresses: string[] | string[][]) => Promise<DictInterface<DictInterface<string>> | DictInterface<string>>;
67
101
  exchangeExpected: (inputCoin: string | number, outputCoin: string | number, amount: string) => Promise<string>;
102
+ exchangeIsApproved: (inputCoin: string | number, amount: string) => Promise<boolean>;
103
+ private exchangeApproveEstimateGas;
104
+ exchangeApprove: (inputCoin: string | number, amount: string) => Promise<string[]>;
68
105
  private exchangeEstimateGas;
69
106
  exchange: (inputCoin: string | number, outputCoin: string | number, amount: string, maxSlippage?: number) => Promise<string>;
107
+ exchangeTricryptoIsApproved: (inputCoin: string | number, amount: string, useEth?: boolean) => Promise<boolean>;
108
+ private exchangeTricryptoApproveEstimateGas;
109
+ exchangeTricryptoApprove: (inputCoin: string | number, amount: string, useEth?: boolean) => Promise<string[]>;
70
110
  private exchangeTricryptoEstimateGas;
71
111
  exchangeTricrypto: (inputCoin: string | number, outputCoin: string | number, amount: string, maxSlippage?: number, useEth?: boolean) => Promise<string>;
72
112
  exchangeWrappedExpected: (inputCoin: string | number, outputCoin: string | number, amount: string) => Promise<string>;
113
+ exchangeWrappedIsApproved: (inputCoin: string | number, amount: string) => Promise<boolean>;
114
+ private exchangeWrappedApproveEstimateGas;
115
+ exchangeWrappedApprove: (inputCoin: string | number, amount: string) => Promise<string[]>;
73
116
  private exchangeWrappedEstimateGas;
74
117
  exchangeWrapped: (inputCoin: string | number, outputCoin: string | number, amount: string, maxSlippage?: number) => Promise<string>;
75
118
  gaugeMaxBoostedDeposit: (...addresses: string[]) => Promise<DictInterface<string>>;
@@ -79,6 +122,7 @@ export declare class Pool {
79
122
  private _getCoinIdx;
80
123
  private _getRates;
81
124
  private _balances;
125
+ private _balancedAmounts;
82
126
  private _calcLpTokenAmount;
83
127
  private _calcLpTokenAmountZap;
84
128
  private _calcLpTokenAmountWithUnderlying;