@curvefi/api 2.30.1 → 2.31.1

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