@curvefi/api 2.63.0 → 2.63.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (83) hide show
  1. package/lib/boosting.js +247 -645
  2. package/lib/constants/L2Networks.js +1 -1
  3. package/lib/constants/aliases.js +19 -19
  4. package/lib/constants/coins/arbitrum.js +5 -5
  5. package/lib/constants/coins/aurora.js +5 -5
  6. package/lib/constants/coins/avalanche.js +6 -6
  7. package/lib/constants/coins/base.js +5 -5
  8. package/lib/constants/coins/bsc.js +5 -5
  9. package/lib/constants/coins/celo.js +5 -5
  10. package/lib/constants/coins/ethereum.js +9 -9
  11. package/lib/constants/coins/fantom.js +7 -7
  12. package/lib/constants/coins/fraxtal.js +5 -5
  13. package/lib/constants/coins/kava.js +5 -5
  14. package/lib/constants/coins/mantle.js +5 -5
  15. package/lib/constants/coins/moonbeam.js +5 -5
  16. package/lib/constants/coins/optimism.js +5 -5
  17. package/lib/constants/coins/polygon.js +6 -6
  18. package/lib/constants/coins/xdai.js +5 -5
  19. package/lib/constants/coins/xlayer.js +5 -5
  20. package/lib/constants/coins/zksync.js +5 -5
  21. package/lib/constants/pools/arbitrum.js +1 -1
  22. package/lib/constants/pools/aurora.js +1 -1
  23. package/lib/constants/pools/avalanche.js +1 -1
  24. package/lib/constants/pools/base.js +1 -1
  25. package/lib/constants/pools/bsc.js +1 -1
  26. package/lib/constants/pools/celo.js +1 -1
  27. package/lib/constants/pools/ethereum.js +2 -2
  28. package/lib/constants/pools/fantom.js +1 -1
  29. package/lib/constants/pools/fraxtal.js +1 -1
  30. package/lib/constants/pools/kava.js +1 -1
  31. package/lib/constants/pools/mantle.js +1 -1
  32. package/lib/constants/pools/moonbeam.js +1 -1
  33. package/lib/constants/pools/optimism.js +1 -1
  34. package/lib/constants/pools/polygon.js +1 -1
  35. package/lib/constants/pools/xdai.js +1 -1
  36. package/lib/constants/pools/xlayer.js +1 -1
  37. package/lib/constants/pools/zksync.js +1 -1
  38. package/lib/constants/tricryptoDeployImplementations.js +1 -1
  39. package/lib/constants/utils.js +18 -19
  40. package/lib/constants/volumeNetworks.js +1 -1
  41. package/lib/curve.d.ts +10 -6
  42. package/lib/curve.js +534 -909
  43. package/lib/dao.js +351 -705
  44. package/lib/external-api.js +127 -256
  45. package/lib/factory/common.js +4 -4
  46. package/lib/factory/constants-crypto.js +33 -33
  47. package/lib/factory/constants.js +34 -34
  48. package/lib/factory/deploy.js +542 -907
  49. package/lib/factory/factory-api.js +205 -269
  50. package/lib/factory/factory-crypto.js +202 -342
  51. package/lib/factory/factory-tricrypto.js +164 -286
  52. package/lib/factory/factory-twocrypto.js +151 -269
  53. package/lib/factory/factory.js +245 -385
  54. package/lib/index.js +109 -198
  55. package/lib/interfaces.d.ts +46 -6
  56. package/lib/pools/PoolTemplate.js +1774 -3027
  57. package/lib/pools/gaugePool.js +112 -251
  58. package/lib/pools/mixins/common.js +22 -93
  59. package/lib/pools/mixins/depositBalancedAmountsMixins.js +52 -118
  60. package/lib/pools/mixins/depositMixins.js +160 -386
  61. package/lib/pools/mixins/depositWrappedMixins.js +79 -205
  62. package/lib/pools/mixins/poolBalancesMixin.js +24 -87
  63. package/lib/pools/mixins/swapMixins.js +139 -324
  64. package/lib/pools/mixins/swapWrappedMixins.js +111 -265
  65. package/lib/pools/mixins/withdrawExpectedMixins.js +27 -91
  66. package/lib/pools/mixins/withdrawImbalanceMixins.js +111 -293
  67. package/lib/pools/mixins/withdrawImbalanceWrappedMixins.js +58 -169
  68. package/lib/pools/mixins/withdrawMixins.js +139 -359
  69. package/lib/pools/mixins/withdrawOneCoinExpectedMixins.js +20 -75
  70. package/lib/pools/mixins/withdrawOneCoinMixins.js +140 -360
  71. package/lib/pools/mixins/withdrawOneCoinWrappedExpectedMixins.js +10 -51
  72. package/lib/pools/mixins/withdrawOneCoinWrappedMixins.js +60 -167
  73. package/lib/pools/mixins/withdrawWrappedMixins.js +57 -167
  74. package/lib/pools/poolConstructor.js +11 -31
  75. package/lib/pools/utils.js +301 -469
  76. package/lib/route-finder.worker.d.ts +9 -0
  77. package/lib/route-finder.worker.js +112 -0
  78. package/lib/route-graph.worker.d.ts +11 -0
  79. package/lib/route-graph.worker.js +334 -0
  80. package/lib/router.js +323 -912
  81. package/lib/utils.d.ts +8 -7
  82. package/lib/utils.js +540 -927
  83. package/package.json +3 -2
@@ -1,14 +1,3 @@
1
- var __assign = (this && this.__assign) || function () {
2
- __assign = Object.assign || function(t) {
3
- for (var s, i = 1, n = arguments.length; i < n; i++) {
4
- s = arguments[i];
5
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
6
- t[p] = s[p];
7
- }
8
- return t;
9
- };
10
- return __assign.apply(this, arguments);
11
- };
12
1
  var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
13
2
  function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
14
3
  return new (P || (P = Promise))(function (resolve, reject) {
@@ -18,404 +7,195 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
18
7
  step((generator = generator.apply(thisArg, _arguments || [])).next());
19
8
  });
20
9
  };
21
- var __generator = (this && this.__generator) || function (thisArg, body) {
22
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
23
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
24
- function verb(n) { return function (v) { return step([n, v]); }; }
25
- function step(op) {
26
- if (f) throw new TypeError("Generator is already executing.");
27
- while (g && (g = 0, op[0] && (_ = 0)), _) try {
28
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
29
- if (y = 0, t) op = [op[0] & 2, t.value];
30
- switch (op[0]) {
31
- case 0: case 1: t = op; break;
32
- case 4: _.label++; return { value: op[1], done: false };
33
- case 5: _.label++; y = op[1]; op = [0]; continue;
34
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
35
- default:
36
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
37
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
38
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
39
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
40
- if (t[2]) _.ops.pop();
41
- _.trys.pop(); continue;
42
- }
43
- op = body.call(thisArg, _);
44
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
45
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
46
- }
47
- };
48
- var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
49
- if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
50
- if (ar || !(i in from)) {
51
- if (!ar) ar = Array.prototype.slice.call(from, 0, i);
52
- ar[i] = from[i];
53
- }
54
- }
55
- return to.concat(ar || Array.prototype.slice.call(from));
56
- };
57
10
  import { curve } from "../../curve.js";
58
11
  import { _ensureAllowance, fromBN, hasAllowance, toBN, parseUnits, mulBy1_3, smartNumber, DIGas } from '../../utils.js';
59
12
  // @ts-ignore
60
- function _withdrawOneCoinCheck(lpTokenAmount, coin, estimateGas) {
61
- if (estimateGas === void 0) { estimateGas = false; }
62
- return __awaiter(this, void 0, void 0, function () {
63
- var lpTokenBalance, _a, i, _lpTokenAmount;
64
- return __generator(this, function (_b) {
65
- switch (_b.label) {
66
- case 0: return [4 /*yield*/, this.wallet.lpTokenBalances()];
67
- case 1:
68
- lpTokenBalance = (_b.sent())['lpToken'];
69
- if (Number(lpTokenBalance) < Number(lpTokenAmount)) {
70
- throw Error("Not enough LP tokens. Actual: ".concat(lpTokenBalance, ", required: ").concat(lpTokenAmount));
71
- }
72
- _a = estimateGas && this.zap;
73
- if (!_a) return [3 /*break*/, 3];
74
- return [4 /*yield*/, hasAllowance([this.lpToken], [lpTokenAmount], curve.signerAddress, this.zap)];
75
- case 2:
76
- _a = !(_b.sent());
77
- _b.label = 3;
78
- case 3:
79
- if (_a) {
80
- throw Error("Token allowance is needed to estimate gas");
81
- }
82
- if (!!estimateGas) return [3 /*break*/, 5];
83
- return [4 /*yield*/, curve.updateFeeData()];
84
- case 4:
85
- _b.sent();
86
- _b.label = 5;
87
- case 5:
88
- i = this._getCoinIdx(coin);
89
- _lpTokenAmount = parseUnits(lpTokenAmount);
90
- return [2 /*return*/, [_lpTokenAmount, i]];
91
- }
92
- });
13
+ function _withdrawOneCoinCheck(lpTokenAmount, coin, estimateGas = false) {
14
+ return __awaiter(this, void 0, void 0, function* () {
15
+ const lpTokenBalance = (yield this.wallet.lpTokenBalances())['lpToken'];
16
+ if (Number(lpTokenBalance) < Number(lpTokenAmount)) {
17
+ throw Error(`Not enough LP tokens. Actual: ${lpTokenBalance}, required: ${lpTokenAmount}`);
18
+ }
19
+ if (estimateGas && this.zap && !(yield hasAllowance([this.lpToken], [lpTokenAmount], curve.signerAddress, this.zap))) {
20
+ throw Error("Token allowance is needed to estimate gas");
21
+ }
22
+ if (!estimateGas)
23
+ yield curve.updateFeeData();
24
+ // @ts-ignore
25
+ const i = this._getCoinIdx(coin);
26
+ const _lpTokenAmount = parseUnits(lpTokenAmount);
27
+ return [_lpTokenAmount, i];
93
28
  });
94
29
  }
95
- function _withdrawOneCoinMinAmount(_lpTokenAmount, i, slippage) {
96
- if (slippage === void 0) { slippage = 0.5; }
97
- return __awaiter(this, void 0, void 0, function () {
98
- var _expectedLpTokenAmount, minAmountBN;
99
- return __generator(this, function (_a) {
100
- switch (_a.label) {
101
- case 0: return [4 /*yield*/, this._withdrawOneCoinExpected(_lpTokenAmount, i)];
102
- case 1:
103
- _expectedLpTokenAmount = _a.sent();
104
- minAmountBN = toBN(_expectedLpTokenAmount).times(100 - slippage).div(100);
105
- return [2 /*return*/, fromBN(minAmountBN)];
106
- }
107
- });
30
+ function _withdrawOneCoinMinAmount(_lpTokenAmount, i, slippage = 0.5) {
31
+ return __awaiter(this, void 0, void 0, function* () {
32
+ // @ts-ignore
33
+ const _expectedLpTokenAmount = yield this._withdrawOneCoinExpected(_lpTokenAmount, i);
34
+ const minAmountBN = toBN(_expectedLpTokenAmount).times(100 - slippage).div(100);
35
+ return fromBN(minAmountBN);
108
36
  });
109
37
  }
110
38
  // @ts-ignore
111
- export var withdrawOneCoinMetaFactoryMixin = {
39
+ export const withdrawOneCoinMetaFactoryMixin = {
112
40
  // @ts-ignore
113
- _withdrawOneCoin: function (_lpTokenAmount, i, slippage, estimateGas) {
114
- if (estimateGas === void 0) { estimateGas = false; }
115
- return __awaiter(this, void 0, void 0, function () {
116
- var _minAmount, contract, gas, gasLimit;
117
- return __generator(this, function (_a) {
118
- switch (_a.label) {
119
- case 0:
120
- if (!!estimateGas) return [3 /*break*/, 2];
121
- return [4 /*yield*/, _ensureAllowance([this.lpToken], [_lpTokenAmount], this.zap)];
122
- case 1:
123
- _a.sent();
124
- _a.label = 2;
125
- case 2: return [4 /*yield*/, _withdrawOneCoinMinAmount.call(this, _lpTokenAmount, i, slippage)];
126
- case 3:
127
- _minAmount = _a.sent();
128
- contract = curve.contracts[this.zap].contract;
129
- return [4 /*yield*/, contract.remove_liquidity_one_coin.estimateGas(this.address, _lpTokenAmount, i, _minAmount, curve.constantOptions)];
130
- case 4:
131
- gas = _a.sent();
132
- if (estimateGas)
133
- return [2 /*return*/, smartNumber(gas)];
134
- gasLimit = mulBy1_3(DIGas(gas));
135
- return [4 /*yield*/, contract.remove_liquidity_one_coin(this.address, _lpTokenAmount, i, _minAmount, __assign(__assign({}, curve.options), { gasLimit: gasLimit }))];
136
- case 5: return [2 /*return*/, (_a.sent()).hash];
137
- }
138
- });
41
+ _withdrawOneCoin(_lpTokenAmount, i, slippage, estimateGas = false) {
42
+ return __awaiter(this, void 0, void 0, function* () {
43
+ if (!estimateGas)
44
+ yield _ensureAllowance([this.lpToken], [_lpTokenAmount], this.zap);
45
+ const _minAmount = yield _withdrawOneCoinMinAmount.call(this, _lpTokenAmount, i, slippage);
46
+ const contract = curve.contracts[this.zap].contract;
47
+ const gas = yield contract.remove_liquidity_one_coin.estimateGas(this.address, _lpTokenAmount, i, _minAmount, curve.constantOptions);
48
+ if (estimateGas)
49
+ return smartNumber(gas);
50
+ const gasLimit = mulBy1_3(DIGas(gas));
51
+ return (yield contract.remove_liquidity_one_coin(this.address, _lpTokenAmount, i, _minAmount, Object.assign(Object.assign({}, curve.options), { gasLimit }))).hash;
139
52
  });
140
53
  },
141
- withdrawOneCoinEstimateGas: function (lpTokenAmount, coin) {
142
- return __awaiter(this, void 0, void 0, function () {
143
- var _a, _lpTokenAmount, i;
144
- return __generator(this, function (_b) {
145
- switch (_b.label) {
146
- case 0: return [4 /*yield*/, _withdrawOneCoinCheck.call(this, lpTokenAmount, coin, true)];
147
- case 1:
148
- _a = _b.sent(), _lpTokenAmount = _a[0], i = _a[1];
149
- return [4 /*yield*/, this._withdrawOneCoin(_lpTokenAmount, i, 0.1, true)];
150
- case 2:
151
- // @ts-ignore
152
- return [2 /*return*/, _b.sent()];
153
- }
154
- });
54
+ withdrawOneCoinEstimateGas(lpTokenAmount, coin) {
55
+ return __awaiter(this, void 0, void 0, function* () {
56
+ // @ts-ignore
57
+ const [_lpTokenAmount, i] = yield _withdrawOneCoinCheck.call(this, lpTokenAmount, coin, true);
58
+ // @ts-ignore
59
+ return yield this._withdrawOneCoin(_lpTokenAmount, i, 0.1, true);
155
60
  });
156
61
  },
157
- withdrawOneCoin: function (lpTokenAmount, coin, slippage) {
158
- return __awaiter(this, void 0, void 0, function () {
159
- var _a, _lpTokenAmount, i;
160
- return __generator(this, function (_b) {
161
- switch (_b.label) {
162
- case 0: return [4 /*yield*/, _withdrawOneCoinCheck.call(this, lpTokenAmount, coin)];
163
- case 1:
164
- _a = _b.sent(), _lpTokenAmount = _a[0], i = _a[1];
165
- return [4 /*yield*/, this._withdrawOneCoin(_lpTokenAmount, i, slippage)];
166
- case 2:
167
- // @ts-ignore
168
- return [2 /*return*/, _b.sent()];
169
- }
170
- });
62
+ withdrawOneCoin(lpTokenAmount, coin, slippage) {
63
+ return __awaiter(this, void 0, void 0, function* () {
64
+ // @ts-ignore
65
+ const [_lpTokenAmount, i] = yield _withdrawOneCoinCheck.call(this, lpTokenAmount, coin);
66
+ // @ts-ignore
67
+ return yield this._withdrawOneCoin(_lpTokenAmount, i, slippage);
171
68
  });
172
69
  },
173
70
  };
174
71
  // @ts-ignore
175
- export var withdrawOneCoinCryptoMetaFactoryMixin = {
72
+ export const withdrawOneCoinCryptoMetaFactoryMixin = {
176
73
  // @ts-ignore
177
- _withdrawOneCoin: function (_lpTokenAmount, i, slippage, estimateGas) {
178
- if (estimateGas === void 0) { estimateGas = false; }
179
- return __awaiter(this, void 0, void 0, function () {
180
- var _minAmount, contract, gas, gasLimit;
181
- return __generator(this, function (_a) {
182
- switch (_a.label) {
183
- case 0:
184
- if (!!estimateGas) return [3 /*break*/, 2];
185
- return [4 /*yield*/, _ensureAllowance([this.lpToken], [_lpTokenAmount], this.zap)];
186
- case 1:
187
- _a.sent();
188
- _a.label = 2;
189
- case 2: return [4 /*yield*/, _withdrawOneCoinMinAmount.call(this, _lpTokenAmount, i, slippage)];
190
- case 3:
191
- _minAmount = _a.sent();
192
- contract = curve.contracts[this.zap].contract;
193
- return [4 /*yield*/, contract.remove_liquidity_one_coin.estimateGas(this.address, _lpTokenAmount, i, _minAmount, true, curve.constantOptions)];
194
- case 4:
195
- gas = _a.sent();
196
- if (estimateGas)
197
- return [2 /*return*/, smartNumber(gas)];
198
- gasLimit = mulBy1_3(DIGas(gas));
199
- return [4 /*yield*/, contract.remove_liquidity_one_coin(this.address, _lpTokenAmount, i, _minAmount, true, __assign(__assign({}, curve.options), { gasLimit: gasLimit }))];
200
- case 5: return [2 /*return*/, (_a.sent()).hash];
201
- }
202
- });
74
+ _withdrawOneCoin(_lpTokenAmount, i, slippage, estimateGas = false) {
75
+ return __awaiter(this, void 0, void 0, function* () {
76
+ if (!estimateGas)
77
+ yield _ensureAllowance([this.lpToken], [_lpTokenAmount], this.zap);
78
+ const _minAmount = yield _withdrawOneCoinMinAmount.call(this, _lpTokenAmount, i, slippage);
79
+ const contract = curve.contracts[this.zap].contract;
80
+ const gas = yield contract.remove_liquidity_one_coin.estimateGas(this.address, _lpTokenAmount, i, _minAmount, true, curve.constantOptions);
81
+ if (estimateGas)
82
+ return smartNumber(gas);
83
+ const gasLimit = mulBy1_3(DIGas(gas));
84
+ return (yield contract.remove_liquidity_one_coin(this.address, _lpTokenAmount, i, _minAmount, true, Object.assign(Object.assign({}, curve.options), { gasLimit }))).hash;
203
85
  });
204
86
  },
205
- withdrawOneCoinEstimateGas: function (lpTokenAmount, coin) {
206
- return __awaiter(this, void 0, void 0, function () {
207
- var _a, _lpTokenAmount, i;
208
- return __generator(this, function (_b) {
209
- switch (_b.label) {
210
- case 0: return [4 /*yield*/, _withdrawOneCoinCheck.call(this, lpTokenAmount, coin, true)];
211
- case 1:
212
- _a = _b.sent(), _lpTokenAmount = _a[0], i = _a[1];
213
- return [4 /*yield*/, this._withdrawOneCoin(_lpTokenAmount, i, 0.1, true)];
214
- case 2:
215
- // @ts-ignore
216
- return [2 /*return*/, _b.sent()];
217
- }
218
- });
87
+ withdrawOneCoinEstimateGas(lpTokenAmount, coin) {
88
+ return __awaiter(this, void 0, void 0, function* () {
89
+ // @ts-ignore
90
+ const [_lpTokenAmount, i] = yield _withdrawOneCoinCheck.call(this, lpTokenAmount, coin, true);
91
+ // @ts-ignore
92
+ return yield this._withdrawOneCoin(_lpTokenAmount, i, 0.1, true);
219
93
  });
220
94
  },
221
- withdrawOneCoin: function (lpTokenAmount, coin, slippage) {
222
- return __awaiter(this, void 0, void 0, function () {
223
- var _a, _lpTokenAmount, i;
224
- return __generator(this, function (_b) {
225
- switch (_b.label) {
226
- case 0: return [4 /*yield*/, _withdrawOneCoinCheck.call(this, lpTokenAmount, coin)];
227
- case 1:
228
- _a = _b.sent(), _lpTokenAmount = _a[0], i = _a[1];
229
- return [4 /*yield*/, this._withdrawOneCoin(_lpTokenAmount, i, slippage)];
230
- case 2:
231
- // @ts-ignore
232
- return [2 /*return*/, _b.sent()];
233
- }
234
- });
95
+ withdrawOneCoin(lpTokenAmount, coin, slippage) {
96
+ return __awaiter(this, void 0, void 0, function* () {
97
+ // @ts-ignore
98
+ const [_lpTokenAmount, i] = yield _withdrawOneCoinCheck.call(this, lpTokenAmount, coin);
99
+ // @ts-ignore
100
+ return yield this._withdrawOneCoin(_lpTokenAmount, i, slippage);
235
101
  });
236
102
  },
237
103
  };
238
104
  // @ts-ignore
239
- export var withdrawOneCoinZapMixin = {
105
+ export const withdrawOneCoinZapMixin = {
240
106
  // @ts-ignore
241
- _withdrawOneCoin: function (_lpTokenAmount, i, slippage, estimateGas) {
242
- if (estimateGas === void 0) { estimateGas = false; }
243
- return __awaiter(this, void 0, void 0, function () {
244
- var _minAmount, contract, args, gas, gasLimit;
245
- var _a;
246
- return __generator(this, function (_b) {
247
- switch (_b.label) {
248
- case 0:
249
- if (!!estimateGas) return [3 /*break*/, 2];
250
- return [4 /*yield*/, _ensureAllowance([this.lpToken], [_lpTokenAmount], this.zap)];
251
- case 1:
252
- _b.sent();
253
- _b.label = 2;
254
- case 2: return [4 /*yield*/, _withdrawOneCoinMinAmount.call(this, _lpTokenAmount, i, slippage)];
255
- case 3:
256
- _minAmount = _b.sent();
257
- contract = curve.contracts[this.zap].contract;
258
- args = [_lpTokenAmount, i, _minAmount];
259
- if ("remove_liquidity_one_coin(uint256,uint256,uint256,bool)" in contract)
260
- args.push(true);
261
- return [4 /*yield*/, (_a = contract.remove_liquidity_one_coin).estimateGas.apply(_a, __spreadArray(__spreadArray([], args, false), [curve.constantOptions], false))];
262
- case 4:
263
- gas = _b.sent();
264
- if (estimateGas)
265
- return [2 /*return*/, smartNumber(gas)];
266
- gasLimit = mulBy1_3(DIGas(gas));
267
- return [4 /*yield*/, contract.remove_liquidity_one_coin.apply(contract, __spreadArray(__spreadArray([], args, false), [__assign(__assign({}, curve.options), { gasLimit: gasLimit })], false))];
268
- case 5: return [2 /*return*/, (_b.sent()).hash];
269
- }
270
- });
107
+ _withdrawOneCoin(_lpTokenAmount, i, slippage, estimateGas = false) {
108
+ return __awaiter(this, void 0, void 0, function* () {
109
+ if (!estimateGas)
110
+ yield _ensureAllowance([this.lpToken], [_lpTokenAmount], this.zap);
111
+ const _minAmount = yield _withdrawOneCoinMinAmount.call(this, _lpTokenAmount, i, slippage);
112
+ const contract = curve.contracts[this.zap].contract;
113
+ const args = [_lpTokenAmount, i, _minAmount];
114
+ if (`remove_liquidity_one_coin(uint256,uint256,uint256,bool)` in contract)
115
+ args.push(true);
116
+ const gas = yield contract.remove_liquidity_one_coin.estimateGas(...args, curve.constantOptions);
117
+ if (estimateGas)
118
+ return smartNumber(gas);
119
+ const gasLimit = mulBy1_3(DIGas(gas));
120
+ return (yield contract.remove_liquidity_one_coin(...args, Object.assign(Object.assign({}, curve.options), { gasLimit }))).hash;
271
121
  });
272
122
  },
273
- withdrawOneCoinEstimateGas: function (lpTokenAmount, coin) {
274
- return __awaiter(this, void 0, void 0, function () {
275
- var _a, _lpTokenAmount, i;
276
- return __generator(this, function (_b) {
277
- switch (_b.label) {
278
- case 0: return [4 /*yield*/, _withdrawOneCoinCheck.call(this, lpTokenAmount, coin, true)];
279
- case 1:
280
- _a = _b.sent(), _lpTokenAmount = _a[0], i = _a[1];
281
- return [4 /*yield*/, this._withdrawOneCoin(_lpTokenAmount, i, 0.1, true)];
282
- case 2:
283
- // @ts-ignore
284
- return [2 /*return*/, _b.sent()];
285
- }
286
- });
123
+ withdrawOneCoinEstimateGas(lpTokenAmount, coin) {
124
+ return __awaiter(this, void 0, void 0, function* () {
125
+ // @ts-ignore
126
+ const [_lpTokenAmount, i] = yield _withdrawOneCoinCheck.call(this, lpTokenAmount, coin, true);
127
+ // @ts-ignore
128
+ return yield this._withdrawOneCoin(_lpTokenAmount, i, 0.1, true);
287
129
  });
288
130
  },
289
- withdrawOneCoin: function (lpTokenAmount, coin, slippage) {
290
- return __awaiter(this, void 0, void 0, function () {
291
- var _a, _lpTokenAmount, i;
292
- return __generator(this, function (_b) {
293
- switch (_b.label) {
294
- case 0: return [4 /*yield*/, _withdrawOneCoinCheck.call(this, lpTokenAmount, coin)];
295
- case 1:
296
- _a = _b.sent(), _lpTokenAmount = _a[0], i = _a[1];
297
- return [4 /*yield*/, this._withdrawOneCoin(_lpTokenAmount, i, slippage)];
298
- case 2:
299
- // @ts-ignore
300
- return [2 /*return*/, _b.sent()];
301
- }
302
- });
131
+ withdrawOneCoin(lpTokenAmount, coin, slippage) {
132
+ return __awaiter(this, void 0, void 0, function* () {
133
+ // @ts-ignore
134
+ const [_lpTokenAmount, i] = yield _withdrawOneCoinCheck.call(this, lpTokenAmount, coin);
135
+ // @ts-ignore
136
+ return yield this._withdrawOneCoin(_lpTokenAmount, i, slippage);
303
137
  });
304
138
  },
305
139
  };
306
140
  // @ts-ignore
307
- export var withdrawOneCoinLendingOrCryptoMixin = {
141
+ export const withdrawOneCoinLendingOrCryptoMixin = {
308
142
  // @ts-ignore
309
- _withdrawOneCoin: function (_lpTokenAmount, i, slippage, estimateGas) {
310
- if (estimateGas === void 0) { estimateGas = false; }
311
- return __awaiter(this, void 0, void 0, function () {
312
- var _minAmount, contract, gas, gasLimit;
313
- return __generator(this, function (_a) {
314
- switch (_a.label) {
315
- case 0: return [4 /*yield*/, _withdrawOneCoinMinAmount.call(this, _lpTokenAmount, i, slippage)];
316
- case 1:
317
- _minAmount = _a.sent();
318
- contract = curve.contracts[this.address].contract;
319
- return [4 /*yield*/, contract.remove_liquidity_one_coin.estimateGas(_lpTokenAmount, i, _minAmount, true, curve.constantOptions)];
320
- case 2:
321
- gas = _a.sent();
322
- if (estimateGas)
323
- return [2 /*return*/, smartNumber(gas)];
324
- gasLimit = curve.chainId === 137 && this.id === 'ren' ? DIGas(gas) * curve.parseUnits("160", 0) / curve.parseUnits("100", 0) : mulBy1_3(DIGas(gas));
325
- return [4 /*yield*/, contract.remove_liquidity_one_coin(_lpTokenAmount, i, _minAmount, true, __assign(__assign({}, curve.options), { gasLimit: gasLimit }))];
326
- case 3: return [2 /*return*/, (_a.sent()).hash];
327
- }
328
- });
143
+ _withdrawOneCoin(_lpTokenAmount, i, slippage, estimateGas = false) {
144
+ return __awaiter(this, void 0, void 0, function* () {
145
+ const _minAmount = yield _withdrawOneCoinMinAmount.call(this, _lpTokenAmount, i, slippage);
146
+ const contract = curve.contracts[this.address].contract;
147
+ const gas = yield contract.remove_liquidity_one_coin.estimateGas(_lpTokenAmount, i, _minAmount, true, curve.constantOptions);
148
+ if (estimateGas)
149
+ return smartNumber(gas);
150
+ const gasLimit = curve.chainId === 137 && this.id === 'ren' ? DIGas(gas) * curve.parseUnits("160", 0) / curve.parseUnits("100", 0) : mulBy1_3(DIGas(gas));
151
+ return (yield contract.remove_liquidity_one_coin(_lpTokenAmount, i, _minAmount, true, Object.assign(Object.assign({}, curve.options), { gasLimit }))).hash;
329
152
  });
330
153
  },
331
- withdrawOneCoinEstimateGas: function (lpTokenAmount, coin) {
332
- return __awaiter(this, void 0, void 0, function () {
333
- var _a, _lpTokenAmount, i;
334
- return __generator(this, function (_b) {
335
- switch (_b.label) {
336
- case 0: return [4 /*yield*/, _withdrawOneCoinCheck.call(this, lpTokenAmount, coin, true)];
337
- case 1:
338
- _a = _b.sent(), _lpTokenAmount = _a[0], i = _a[1];
339
- return [4 /*yield*/, this._withdrawOneCoin(_lpTokenAmount, i, 0.1, true)];
340
- case 2:
341
- // @ts-ignore
342
- return [2 /*return*/, _b.sent()];
343
- }
344
- });
154
+ withdrawOneCoinEstimateGas(lpTokenAmount, coin) {
155
+ return __awaiter(this, void 0, void 0, function* () {
156
+ // @ts-ignore
157
+ const [_lpTokenAmount, i] = yield _withdrawOneCoinCheck.call(this, lpTokenAmount, coin, true);
158
+ // @ts-ignore
159
+ return yield this._withdrawOneCoin(_lpTokenAmount, i, 0.1, true);
345
160
  });
346
161
  },
347
- withdrawOneCoin: function (lpTokenAmount, coin, slippage) {
348
- return __awaiter(this, void 0, void 0, function () {
349
- var _a, _lpTokenAmount, i;
350
- return __generator(this, function (_b) {
351
- switch (_b.label) {
352
- case 0: return [4 /*yield*/, _withdrawOneCoinCheck.call(this, lpTokenAmount, coin)];
353
- case 1:
354
- _a = _b.sent(), _lpTokenAmount = _a[0], i = _a[1];
355
- return [4 /*yield*/, this._withdrawOneCoin(_lpTokenAmount, i, slippage)];
356
- case 2:
357
- // @ts-ignore
358
- return [2 /*return*/, _b.sent()];
359
- }
360
- });
162
+ withdrawOneCoin(lpTokenAmount, coin, slippage) {
163
+ return __awaiter(this, void 0, void 0, function* () {
164
+ // @ts-ignore
165
+ const [_lpTokenAmount, i] = yield _withdrawOneCoinCheck.call(this, lpTokenAmount, coin);
166
+ // @ts-ignore
167
+ return yield this._withdrawOneCoin(_lpTokenAmount, i, slippage);
361
168
  });
362
169
  },
363
170
  };
364
171
  // @ts-ignore
365
- export var withdrawOneCoinPlainMixin = {
172
+ export const withdrawOneCoinPlainMixin = {
366
173
  // @ts-ignore
367
- _withdrawOneCoin: function (_lpTokenAmount, i, slippage, estimateGas) {
368
- if (estimateGas === void 0) { estimateGas = false; }
369
- return __awaiter(this, void 0, void 0, function () {
370
- var _minAmount, contract, gas, gasLimit;
371
- return __generator(this, function (_a) {
372
- switch (_a.label) {
373
- case 0: return [4 /*yield*/, _withdrawOneCoinMinAmount.call(this, _lpTokenAmount, i, slippage)];
374
- case 1:
375
- _minAmount = _a.sent();
376
- contract = curve.contracts[this.address].contract;
377
- return [4 /*yield*/, contract.remove_liquidity_one_coin.estimateGas(_lpTokenAmount, i, _minAmount, curve.constantOptions)];
378
- case 2:
379
- gas = _a.sent();
380
- if (estimateGas)
381
- return [2 /*return*/, smartNumber(gas)];
382
- gasLimit = mulBy1_3(DIGas(gas));
383
- return [4 /*yield*/, contract.remove_liquidity_one_coin(_lpTokenAmount, i, _minAmount, __assign(__assign({}, curve.options), { gasLimit: gasLimit }))];
384
- case 3: return [2 /*return*/, (_a.sent()).hash];
385
- }
386
- });
174
+ _withdrawOneCoin(_lpTokenAmount, i, slippage, estimateGas = false) {
175
+ return __awaiter(this, void 0, void 0, function* () {
176
+ const _minAmount = yield _withdrawOneCoinMinAmount.call(this, _lpTokenAmount, i, slippage);
177
+ const contract = curve.contracts[this.address].contract;
178
+ const gas = yield contract.remove_liquidity_one_coin.estimateGas(_lpTokenAmount, i, _minAmount, curve.constantOptions);
179
+ if (estimateGas)
180
+ return smartNumber(gas);
181
+ const gasLimit = mulBy1_3(DIGas(gas));
182
+ return (yield contract.remove_liquidity_one_coin(_lpTokenAmount, i, _minAmount, Object.assign(Object.assign({}, curve.options), { gasLimit }))).hash;
387
183
  });
388
184
  },
389
- withdrawOneCoinEstimateGas: function (lpTokenAmount, coin) {
390
- return __awaiter(this, void 0, void 0, function () {
391
- var _a, _lpTokenAmount, i;
392
- return __generator(this, function (_b) {
393
- switch (_b.label) {
394
- case 0: return [4 /*yield*/, _withdrawOneCoinCheck.call(this, lpTokenAmount, coin, true)];
395
- case 1:
396
- _a = _b.sent(), _lpTokenAmount = _a[0], i = _a[1];
397
- return [4 /*yield*/, this._withdrawOneCoin(_lpTokenAmount, i, 0.1, true)];
398
- case 2:
399
- // @ts-ignore
400
- return [2 /*return*/, _b.sent()];
401
- }
402
- });
185
+ withdrawOneCoinEstimateGas(lpTokenAmount, coin) {
186
+ return __awaiter(this, void 0, void 0, function* () {
187
+ // @ts-ignore
188
+ const [_lpTokenAmount, i] = yield _withdrawOneCoinCheck.call(this, lpTokenAmount, coin, true);
189
+ // @ts-ignore
190
+ return yield this._withdrawOneCoin(_lpTokenAmount, i, 0.1, true);
403
191
  });
404
192
  },
405
- withdrawOneCoin: function (lpTokenAmount, coin, slippage) {
406
- return __awaiter(this, void 0, void 0, function () {
407
- var _a, _lpTokenAmount, i;
408
- return __generator(this, function (_b) {
409
- switch (_b.label) {
410
- case 0: return [4 /*yield*/, _withdrawOneCoinCheck.call(this, lpTokenAmount, coin)];
411
- case 1:
412
- _a = _b.sent(), _lpTokenAmount = _a[0], i = _a[1];
413
- return [4 /*yield*/, this._withdrawOneCoin(_lpTokenAmount, i, slippage)];
414
- case 2:
415
- // @ts-ignore
416
- return [2 /*return*/, _b.sent()];
417
- }
418
- });
193
+ withdrawOneCoin(lpTokenAmount, coin, slippage) {
194
+ return __awaiter(this, void 0, void 0, function* () {
195
+ // @ts-ignore
196
+ const [_lpTokenAmount, i] = yield _withdrawOneCoinCheck.call(this, lpTokenAmount, coin);
197
+ // @ts-ignore
198
+ return yield this._withdrawOneCoin(_lpTokenAmount, i, slippage);
419
199
  });
420
200
  },
421
201
  };