@curvefi/api 2.31.1 → 2.33.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (62) hide show
  1. package/lib/boosting.js +385 -135
  2. package/lib/constants/abis/stable_calc.json +151 -0
  3. package/lib/constants/abis/wbeth/swap.json +1086 -0
  4. package/lib/constants/aliases.js +33 -11
  5. package/lib/constants/coins/arbitrum.js +5 -5
  6. package/lib/constants/coins/aurora.js +5 -5
  7. package/lib/constants/coins/avalanche.js +6 -6
  8. package/lib/constants/coins/celo.js +5 -5
  9. package/lib/constants/coins/ethereum.js +10 -9
  10. package/lib/constants/coins/fantom.js +7 -7
  11. package/lib/constants/coins/kava.js +5 -5
  12. package/lib/constants/coins/moonbeam.js +5 -5
  13. package/lib/constants/coins/optimism.js +5 -5
  14. package/lib/constants/coins/polygon.js +6 -6
  15. package/lib/constants/coins/xdai.js +5 -5
  16. package/lib/constants/pools/arbitrum.js +1 -1
  17. package/lib/constants/pools/aurora.js +1 -1
  18. package/lib/constants/pools/avalanche.js +1 -1
  19. package/lib/constants/pools/celo.js +1 -1
  20. package/lib/constants/pools/ethereum.js +26 -1
  21. package/lib/constants/pools/fantom.js +1 -1
  22. package/lib/constants/pools/kava.js +1 -1
  23. package/lib/constants/pools/moonbeam.js +1 -1
  24. package/lib/constants/pools/optimism.js +1 -1
  25. package/lib/constants/pools/polygon.js +1 -1
  26. package/lib/constants/pools/xdai.js +1 -1
  27. package/lib/constants/utils.d.ts +1 -1
  28. package/lib/constants/utils.js +19 -18
  29. package/lib/curve.js +507 -281
  30. package/lib/external-api.js +132 -45
  31. package/lib/factory/common.js +3 -3
  32. package/lib/factory/constants-crypto.js +21 -21
  33. package/lib/factory/constants.js +32 -31
  34. package/lib/factory/deploy.js +336 -176
  35. package/lib/factory/factory-api.js +256 -180
  36. package/lib/factory/factory-crypto.js +309 -163
  37. package/lib/factory/factory.d.ts +1 -1
  38. package/lib/factory/factory.js +336 -186
  39. package/lib/index.js +98 -44
  40. package/lib/interfaces.d.ts +1 -1
  41. package/lib/pools/PoolTemplate.js +2882 -1511
  42. package/lib/pools/mixins/common.js +106 -22
  43. package/lib/pools/mixins/depositBalancedAmountsMixins.js +131 -48
  44. package/lib/pools/mixins/depositMixins.js +413 -144
  45. package/lib/pools/mixins/depositWrappedMixins.js +223 -72
  46. package/lib/pools/mixins/poolBalancesMixin.js +98 -22
  47. package/lib/pools/mixins/swapMixins.js +347 -125
  48. package/lib/pools/mixins/swapWrappedMixins.js +270 -88
  49. package/lib/pools/mixins/withdrawExpectedMixins.js +104 -23
  50. package/lib/pools/mixins/withdrawImbalanceMixins.js +316 -97
  51. package/lib/pools/mixins/withdrawImbalanceWrappedMixins.js +187 -51
  52. package/lib/pools/mixins/withdrawMixins.js +385 -122
  53. package/lib/pools/mixins/withdrawOneCoinExpectedMixins.js +88 -16
  54. package/lib/pools/mixins/withdrawOneCoinMixins.js +386 -123
  55. package/lib/pools/mixins/withdrawOneCoinWrappedExpectedMixins.js +62 -8
  56. package/lib/pools/mixins/withdrawOneCoinWrappedMixins.js +185 -53
  57. package/lib/pools/mixins/withdrawWrappedMixins.js +185 -50
  58. package/lib/pools/poolConstructor.js +25 -5
  59. package/lib/pools/utils.js +488 -298
  60. package/lib/router.js +636 -378
  61. package/lib/utils.js +675 -354
  62. package/package.json +1 -1
@@ -1,70 +1,202 @@
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
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
13
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
14
+ return new (P || (P = Promise))(function (resolve, reject) {
15
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
16
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
17
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
18
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
19
+ });
20
+ };
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
+ };
1
48
  import { curve } from "../../curve.js";
2
49
  import { fromBN, toBN, parseUnits, mulBy1_3 } from "../../utils.js";
3
50
  // @ts-ignore
4
- async function _withdrawOneCoinWrappedCheck(lpTokenAmount, coin) {
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
- await curve.updateFeeData();
10
- // @ts-ignore
11
- const i = this._getCoinIdx(coin, false);
12
- const _lpTokenAmount = parseUnits(lpTokenAmount);
13
- return [_lpTokenAmount, i];
51
+ function _withdrawOneCoinWrappedCheck(lpTokenAmount, coin) {
52
+ return __awaiter(this, void 0, void 0, function () {
53
+ var lpTokenBalance, i, _lpTokenAmount;
54
+ return __generator(this, function (_a) {
55
+ switch (_a.label) {
56
+ case 0: return [4 /*yield*/, this.wallet.lpTokenBalances()];
57
+ case 1:
58
+ lpTokenBalance = (_a.sent())['lpToken'];
59
+ if (Number(lpTokenBalance) < Number(lpTokenAmount)) {
60
+ throw Error("Not enough LP tokens. Actual: ".concat(lpTokenBalance, ", required: ").concat(lpTokenAmount));
61
+ }
62
+ return [4 /*yield*/, curve.updateFeeData()];
63
+ case 2:
64
+ _a.sent();
65
+ i = this._getCoinIdx(coin, false);
66
+ _lpTokenAmount = parseUnits(lpTokenAmount);
67
+ return [2 /*return*/, [_lpTokenAmount, i]];
68
+ }
69
+ });
70
+ });
14
71
  }
15
- async function _withdrawOneCoinWrappedMinAmount(_lpTokenAmount, i, slippage = 0.5) {
16
- // @ts-ignore
17
- const _expectedLpTokenAmount = await this._withdrawOneCoinWrappedExpected(_lpTokenAmount, i);
18
- const minAmountBN = toBN(_expectedLpTokenAmount).times(100 - slippage).div(100);
19
- return fromBN(minAmountBN);
72
+ function _withdrawOneCoinWrappedMinAmount(_lpTokenAmount, i, slippage) {
73
+ if (slippage === void 0) { slippage = 0.5; }
74
+ return __awaiter(this, void 0, void 0, function () {
75
+ var _expectedLpTokenAmount, minAmountBN;
76
+ return __generator(this, function (_a) {
77
+ switch (_a.label) {
78
+ case 0: return [4 /*yield*/, this._withdrawOneCoinWrappedExpected(_lpTokenAmount, i)];
79
+ case 1:
80
+ _expectedLpTokenAmount = _a.sent();
81
+ minAmountBN = toBN(_expectedLpTokenAmount).times(100 - slippage).div(100);
82
+ return [2 /*return*/, fromBN(minAmountBN)];
83
+ }
84
+ });
85
+ });
20
86
  }
21
87
  // @ts-ignore
22
- export const withdrawOneCoinWrappedLendingOrCryptoMixin = {
88
+ export var withdrawOneCoinWrappedLendingOrCryptoMixin = {
23
89
  // @ts-ignore
24
- async _withdrawOneCoinWrapped(_lpTokenAmount, i, slippage, estimateGas = false) {
25
- const _minAmount = await _withdrawOneCoinWrappedMinAmount.call(this, _lpTokenAmount, i, slippage);
26
- const contract = curve.contracts[this.address].contract;
27
- const gas = await contract.remove_liquidity_one_coin.estimateGas(_lpTokenAmount, i, _minAmount, false, curve.constantOptions);
28
- if (estimateGas)
29
- return Number(gas);
30
- const gasLimit = curve.chainId === 137 && this.id === 'ren' ? gas * 160n / 100n : mulBy1_3(gas);
31
- return (await contract.remove_liquidity_one_coin(_lpTokenAmount, i, _minAmount, false, { ...curve.options, gasLimit })).hash;
90
+ _withdrawOneCoinWrapped: function (_lpTokenAmount, i, slippage, estimateGas) {
91
+ if (estimateGas === void 0) { estimateGas = false; }
92
+ return __awaiter(this, void 0, void 0, function () {
93
+ var _minAmount, contract, gas, gasLimit;
94
+ return __generator(this, function (_a) {
95
+ switch (_a.label) {
96
+ case 0: return [4 /*yield*/, _withdrawOneCoinWrappedMinAmount.call(this, _lpTokenAmount, i, slippage)];
97
+ case 1:
98
+ _minAmount = _a.sent();
99
+ contract = curve.contracts[this.address].contract;
100
+ return [4 /*yield*/, contract.remove_liquidity_one_coin.estimateGas(_lpTokenAmount, i, _minAmount, false, curve.constantOptions)];
101
+ case 2:
102
+ gas = _a.sent();
103
+ if (estimateGas)
104
+ return [2 /*return*/, Number(gas)];
105
+ gasLimit = curve.chainId === 137 && this.id === 'ren' ? gas * curve.parseUnits("160", 0) / curve.parseUnits("100", 0) : mulBy1_3(gas);
106
+ return [4 /*yield*/, contract.remove_liquidity_one_coin(_lpTokenAmount, i, _minAmount, false, __assign(__assign({}, curve.options), { gasLimit: gasLimit }))];
107
+ case 3: return [2 /*return*/, (_a.sent()).hash];
108
+ }
109
+ });
110
+ });
32
111
  },
33
- async withdrawOneCoinWrappedEstimateGas(lpTokenAmount, coin) {
34
- // @ts-ignore
35
- const [_lpTokenAmount, i] = await _withdrawOneCoinWrappedCheck.call(this, lpTokenAmount, coin);
36
- // @ts-ignore
37
- return await this._withdrawOneCoinWrapped(_lpTokenAmount, i, 0.1, true);
112
+ withdrawOneCoinWrappedEstimateGas: function (lpTokenAmount, coin) {
113
+ return __awaiter(this, void 0, void 0, function () {
114
+ var _a, _lpTokenAmount, i;
115
+ return __generator(this, function (_b) {
116
+ switch (_b.label) {
117
+ case 0: return [4 /*yield*/, _withdrawOneCoinWrappedCheck.call(this, lpTokenAmount, coin)];
118
+ case 1:
119
+ _a = _b.sent(), _lpTokenAmount = _a[0], i = _a[1];
120
+ return [4 /*yield*/, this._withdrawOneCoinWrapped(_lpTokenAmount, i, 0.1, true)];
121
+ case 2:
122
+ // @ts-ignore
123
+ return [2 /*return*/, _b.sent()];
124
+ }
125
+ });
126
+ });
38
127
  },
39
- async withdrawOneCoinWrapped(lpTokenAmount, coin, slippage) {
40
- // @ts-ignore
41
- const [_lpTokenAmount, i] = await _withdrawOneCoinWrappedCheck.call(this, lpTokenAmount, coin);
42
- // @ts-ignore
43
- return await this._withdrawOneCoinWrapped(_lpTokenAmount, i, slippage);
128
+ withdrawOneCoinWrapped: function (lpTokenAmount, coin, slippage) {
129
+ return __awaiter(this, void 0, void 0, function () {
130
+ var _a, _lpTokenAmount, i;
131
+ return __generator(this, function (_b) {
132
+ switch (_b.label) {
133
+ case 0: return [4 /*yield*/, _withdrawOneCoinWrappedCheck.call(this, lpTokenAmount, coin)];
134
+ case 1:
135
+ _a = _b.sent(), _lpTokenAmount = _a[0], i = _a[1];
136
+ return [4 /*yield*/, this._withdrawOneCoinWrapped(_lpTokenAmount, i, slippage)];
137
+ case 2:
138
+ // @ts-ignore
139
+ return [2 /*return*/, _b.sent()];
140
+ }
141
+ });
142
+ });
44
143
  },
45
144
  };
46
145
  // @ts-ignore
47
- export const withdrawOneCoinWrappedMixin = {
146
+ export var withdrawOneCoinWrappedMixin = {
48
147
  // @ts-ignore
49
- async _withdrawOneCoinWrapped(_lpTokenAmount, i, slippage, estimateGas = false) {
50
- const _minAmount = await _withdrawOneCoinWrappedMinAmount.call(this, _lpTokenAmount, i, slippage);
51
- const contract = curve.contracts[this.address].contract;
52
- const gas = await contract.remove_liquidity_one_coin.estimateGas(_lpTokenAmount, i, _minAmount, curve.constantOptions);
53
- if (estimateGas)
54
- return Number(gas);
55
- const gasLimit = mulBy1_3(gas);
56
- return (await contract.remove_liquidity_one_coin(_lpTokenAmount, i, _minAmount, { ...curve.options, gasLimit })).hash;
148
+ _withdrawOneCoinWrapped: function (_lpTokenAmount, i, slippage, estimateGas) {
149
+ if (estimateGas === void 0) { estimateGas = false; }
150
+ return __awaiter(this, void 0, void 0, function () {
151
+ var _minAmount, contract, gas, gasLimit;
152
+ return __generator(this, function (_a) {
153
+ switch (_a.label) {
154
+ case 0: return [4 /*yield*/, _withdrawOneCoinWrappedMinAmount.call(this, _lpTokenAmount, i, slippage)];
155
+ case 1:
156
+ _minAmount = _a.sent();
157
+ contract = curve.contracts[this.address].contract;
158
+ return [4 /*yield*/, contract.remove_liquidity_one_coin.estimateGas(_lpTokenAmount, i, _minAmount, curve.constantOptions)];
159
+ case 2:
160
+ gas = _a.sent();
161
+ if (estimateGas)
162
+ return [2 /*return*/, Number(gas)];
163
+ gasLimit = mulBy1_3(gas);
164
+ return [4 /*yield*/, contract.remove_liquidity_one_coin(_lpTokenAmount, i, _minAmount, __assign(__assign({}, curve.options), { gasLimit: gasLimit }))];
165
+ case 3: return [2 /*return*/, (_a.sent()).hash];
166
+ }
167
+ });
168
+ });
57
169
  },
58
- async withdrawOneCoinWrappedEstimateGas(lpTokenAmount, coin) {
59
- // @ts-ignore
60
- const [_lpTokenAmount, i] = await _withdrawOneCoinWrappedCheck.call(this, lpTokenAmount, coin);
61
- // @ts-ignore
62
- return await this._withdrawOneCoinWrapped(_lpTokenAmount, i, 0.1, true);
170
+ withdrawOneCoinWrappedEstimateGas: function (lpTokenAmount, coin) {
171
+ return __awaiter(this, void 0, void 0, function () {
172
+ var _a, _lpTokenAmount, i;
173
+ return __generator(this, function (_b) {
174
+ switch (_b.label) {
175
+ case 0: return [4 /*yield*/, _withdrawOneCoinWrappedCheck.call(this, lpTokenAmount, coin)];
176
+ case 1:
177
+ _a = _b.sent(), _lpTokenAmount = _a[0], i = _a[1];
178
+ return [4 /*yield*/, this._withdrawOneCoinWrapped(_lpTokenAmount, i, 0.1, true)];
179
+ case 2:
180
+ // @ts-ignore
181
+ return [2 /*return*/, _b.sent()];
182
+ }
183
+ });
184
+ });
63
185
  },
64
- async withdrawOneCoinWrapped(lpTokenAmount, coin, slippage) {
65
- // @ts-ignore
66
- const [_lpTokenAmount, i] = await _withdrawOneCoinWrappedCheck.call(this, lpTokenAmount, coin);
67
- // @ts-ignore
68
- return await this._withdrawOneCoinWrapped(_lpTokenAmount, i, slippage);
186
+ withdrawOneCoinWrapped: function (lpTokenAmount, coin, slippage) {
187
+ return __awaiter(this, void 0, void 0, function () {
188
+ var _a, _lpTokenAmount, i;
189
+ return __generator(this, function (_b) {
190
+ switch (_b.label) {
191
+ case 0: return [4 /*yield*/, _withdrawOneCoinWrappedCheck.call(this, lpTokenAmount, coin)];
192
+ case 1:
193
+ _a = _b.sent(), _lpTokenAmount = _a[0], i = _a[1];
194
+ return [4 /*yield*/, this._withdrawOneCoinWrapped(_lpTokenAmount, i, slippage)];
195
+ case 2:
196
+ // @ts-ignore
197
+ return [2 /*return*/, _b.sent()];
198
+ }
199
+ });
200
+ });
69
201
  },
70
202
  };
@@ -1,67 +1,202 @@
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
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
13
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
14
+ return new (P || (P = Promise))(function (resolve, reject) {
15
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
16
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
17
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
18
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
19
+ });
20
+ };
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
+ };
1
48
  import { curve } from "../../curve.js";
2
49
  import { fromBN, toBN, parseUnits, mulBy1_3 } from "../../utils.js";
3
50
  // @ts-ignore
4
- async function _withdrawWrappedCheck(lpTokenAmount) {
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
- await curve.updateFeeData();
10
- return parseUnits(lpTokenAmount);
51
+ function _withdrawWrappedCheck(lpTokenAmount) {
52
+ return __awaiter(this, void 0, void 0, function () {
53
+ var lpTokenBalance;
54
+ return __generator(this, function (_b) {
55
+ switch (_b.label) {
56
+ case 0: return [4 /*yield*/, this.wallet.lpTokenBalances()];
57
+ case 1:
58
+ lpTokenBalance = (_b.sent())['lpToken'];
59
+ if (Number(lpTokenBalance) < Number(lpTokenAmount)) {
60
+ throw Error("Not enough LP tokens. Actual: ".concat(lpTokenBalance, ", required: ").concat(lpTokenAmount));
61
+ }
62
+ return [4 /*yield*/, curve.updateFeeData()];
63
+ case 2:
64
+ _b.sent();
65
+ return [2 /*return*/, parseUnits(lpTokenAmount)];
66
+ }
67
+ });
68
+ });
11
69
  }
12
- async function _withdrawWrappedMinAmounts(_lpTokenAmount, slippage = 0.5) {
13
- const expectedAmounts = await this.withdrawWrappedExpected(curve.formatUnits(_lpTokenAmount));
14
- const _expectedAmounts = expectedAmounts.map((a, i) => curve.parseUnits(a, this.wrappedDecimals[i]));
15
- const minRecvAmountsBN = _expectedAmounts.map((_a, i) => toBN(_a, this.wrappedDecimals[i]).times(100 - slippage).div(100));
16
- return minRecvAmountsBN.map((a, i) => fromBN(a, this.wrappedDecimals[i]));
70
+ function _withdrawWrappedMinAmounts(_lpTokenAmount, slippage) {
71
+ if (slippage === void 0) { slippage = 0.5; }
72
+ return __awaiter(this, void 0, void 0, function () {
73
+ var expectedAmounts, _expectedAmounts, minRecvAmountsBN;
74
+ var _this = this;
75
+ return __generator(this, function (_b) {
76
+ switch (_b.label) {
77
+ case 0: return [4 /*yield*/, this.withdrawWrappedExpected(curve.formatUnits(_lpTokenAmount))];
78
+ case 1:
79
+ expectedAmounts = _b.sent();
80
+ _expectedAmounts = expectedAmounts.map(function (a, i) { return curve.parseUnits(a, _this.wrappedDecimals[i]); });
81
+ minRecvAmountsBN = _expectedAmounts.map(function (_a, i) { return toBN(_a, _this.wrappedDecimals[i]).times(100 - slippage).div(100); });
82
+ return [2 /*return*/, minRecvAmountsBN.map(function (a, i) { return fromBN(a, _this.wrappedDecimals[i]); })];
83
+ }
84
+ });
85
+ });
17
86
  }
18
87
  // @ts-ignore
19
- export const withdrawWrapped2argsMixin = {
88
+ export var withdrawWrapped2argsMixin = {
20
89
  // @ts-ignore
21
- async _withdrawWrapped(_lpTokenAmount, slippage, estimateGas = false) {
22
- const _minAmounts = await _withdrawWrappedMinAmounts.call(this, _lpTokenAmount, slippage);
23
- const contract = curve.contracts[this.address].contract;
24
- const gas = await contract.remove_liquidity.estimateGas(_lpTokenAmount, _minAmounts, curve.constantOptions);
25
- if (estimateGas)
26
- return Number(gas);
27
- const gasLimit = mulBy1_3(gas);
28
- return (await contract.remove_liquidity(_lpTokenAmount, _minAmounts, { ...curve.options, gasLimit })).hash;
90
+ _withdrawWrapped: function (_lpTokenAmount, slippage, estimateGas) {
91
+ if (estimateGas === void 0) { estimateGas = false; }
92
+ return __awaiter(this, void 0, void 0, function () {
93
+ var _minAmounts, contract, gas, gasLimit;
94
+ return __generator(this, function (_b) {
95
+ switch (_b.label) {
96
+ case 0: return [4 /*yield*/, _withdrawWrappedMinAmounts.call(this, _lpTokenAmount, slippage)];
97
+ case 1:
98
+ _minAmounts = _b.sent();
99
+ contract = curve.contracts[this.address].contract;
100
+ return [4 /*yield*/, contract.remove_liquidity.estimateGas(_lpTokenAmount, _minAmounts, curve.constantOptions)];
101
+ case 2:
102
+ gas = _b.sent();
103
+ if (estimateGas)
104
+ return [2 /*return*/, Number(gas)];
105
+ gasLimit = mulBy1_3(gas);
106
+ return [4 /*yield*/, contract.remove_liquidity(_lpTokenAmount, _minAmounts, __assign(__assign({}, curve.options), { gasLimit: gasLimit }))];
107
+ case 3: return [2 /*return*/, (_b.sent()).hash];
108
+ }
109
+ });
110
+ });
29
111
  },
30
- async withdrawWrappedEstimateGas(lpTokenAmount) {
31
- // @ts-ignore
32
- const _lpTokenAmount = await _withdrawWrappedCheck.call(this, lpTokenAmount);
33
- // @ts-ignore
34
- return await this._withdrawWrapped(_lpTokenAmount, 0.1, true);
112
+ withdrawWrappedEstimateGas: function (lpTokenAmount) {
113
+ return __awaiter(this, void 0, void 0, function () {
114
+ var _lpTokenAmount;
115
+ return __generator(this, function (_b) {
116
+ switch (_b.label) {
117
+ case 0: return [4 /*yield*/, _withdrawWrappedCheck.call(this, lpTokenAmount)];
118
+ case 1:
119
+ _lpTokenAmount = _b.sent();
120
+ return [4 /*yield*/, this._withdrawWrapped(_lpTokenAmount, 0.1, true)];
121
+ case 2:
122
+ // @ts-ignore
123
+ return [2 /*return*/, _b.sent()];
124
+ }
125
+ });
126
+ });
35
127
  },
36
- async withdrawWrapped(lpTokenAmount, slippage) {
37
- // @ts-ignore
38
- const _lpTokenAmount = await _withdrawWrappedCheck.call(this, lpTokenAmount);
39
- // @ts-ignore
40
- return await this._withdrawWrapped(_lpTokenAmount, slippage);
128
+ withdrawWrapped: function (lpTokenAmount, slippage) {
129
+ return __awaiter(this, void 0, void 0, function () {
130
+ var _lpTokenAmount;
131
+ return __generator(this, function (_b) {
132
+ switch (_b.label) {
133
+ case 0: return [4 /*yield*/, _withdrawWrappedCheck.call(this, lpTokenAmount)];
134
+ case 1:
135
+ _lpTokenAmount = _b.sent();
136
+ return [4 /*yield*/, this._withdrawWrapped(_lpTokenAmount, slippage)];
137
+ case 2:
138
+ // @ts-ignore
139
+ return [2 /*return*/, _b.sent()];
140
+ }
141
+ });
142
+ });
41
143
  },
42
144
  };
43
145
  // @ts-ignore
44
- export const withdrawWrapped3argsMixin = {
146
+ export var withdrawWrapped3argsMixin = {
45
147
  // @ts-ignore
46
- async _withdrawWrapped(_lpTokenAmount, slippage, estimateGas = false) {
47
- const _minAmounts = await _withdrawWrappedMinAmounts.call(this, _lpTokenAmount, slippage);
48
- const contract = curve.contracts[this.address].contract;
49
- const gas = await contract.remove_liquidity.estimateGas(_lpTokenAmount, _minAmounts, false, curve.constantOptions);
50
- if (estimateGas)
51
- return Number(gas);
52
- const gasLimit = mulBy1_3(gas);
53
- return (await contract.remove_liquidity(_lpTokenAmount, _minAmounts, false, { ...curve.options, gasLimit })).hash;
148
+ _withdrawWrapped: function (_lpTokenAmount, slippage, estimateGas) {
149
+ if (estimateGas === void 0) { estimateGas = false; }
150
+ return __awaiter(this, void 0, void 0, function () {
151
+ var _minAmounts, contract, gas, gasLimit;
152
+ return __generator(this, function (_b) {
153
+ switch (_b.label) {
154
+ case 0: return [4 /*yield*/, _withdrawWrappedMinAmounts.call(this, _lpTokenAmount, slippage)];
155
+ case 1:
156
+ _minAmounts = _b.sent();
157
+ contract = curve.contracts[this.address].contract;
158
+ return [4 /*yield*/, contract.remove_liquidity.estimateGas(_lpTokenAmount, _minAmounts, false, curve.constantOptions)];
159
+ case 2:
160
+ gas = _b.sent();
161
+ if (estimateGas)
162
+ return [2 /*return*/, Number(gas)];
163
+ gasLimit = mulBy1_3(gas);
164
+ return [4 /*yield*/, contract.remove_liquidity(_lpTokenAmount, _minAmounts, false, __assign(__assign({}, curve.options), { gasLimit: gasLimit }))];
165
+ case 3: return [2 /*return*/, (_b.sent()).hash];
166
+ }
167
+ });
168
+ });
54
169
  },
55
- async withdrawWrappedEstimateGas(lpTokenAmount) {
56
- // @ts-ignore
57
- const _lpTokenAmount = await _withdrawWrappedCheck.call(this, lpTokenAmount);
58
- // @ts-ignore
59
- return await this._withdrawWrapped(_lpTokenAmount, 0.1, true);
170
+ withdrawWrappedEstimateGas: function (lpTokenAmount) {
171
+ return __awaiter(this, void 0, void 0, function () {
172
+ var _lpTokenAmount;
173
+ return __generator(this, function (_b) {
174
+ switch (_b.label) {
175
+ case 0: return [4 /*yield*/, _withdrawWrappedCheck.call(this, lpTokenAmount)];
176
+ case 1:
177
+ _lpTokenAmount = _b.sent();
178
+ return [4 /*yield*/, this._withdrawWrapped(_lpTokenAmount, 0.1, true)];
179
+ case 2:
180
+ // @ts-ignore
181
+ return [2 /*return*/, _b.sent()];
182
+ }
183
+ });
184
+ });
60
185
  },
61
- async withdrawWrapped(lpTokenAmount, slippage) {
62
- // @ts-ignore
63
- const _lpTokenAmount = await _withdrawWrappedCheck.call(this, lpTokenAmount);
64
- // @ts-ignore
65
- return await this._withdrawWrapped(_lpTokenAmount, slippage);
186
+ withdrawWrapped: function (lpTokenAmount, slippage) {
187
+ return __awaiter(this, void 0, void 0, function () {
188
+ var _lpTokenAmount;
189
+ return __generator(this, function (_b) {
190
+ switch (_b.label) {
191
+ case 0: return [4 /*yield*/, _withdrawWrappedCheck.call(this, lpTokenAmount)];
192
+ case 1:
193
+ _lpTokenAmount = _b.sent();
194
+ return [4 /*yield*/, this._withdrawWrapped(_lpTokenAmount, slippage)];
195
+ case 2:
196
+ // @ts-ignore
197
+ return [2 /*return*/, _b.sent()];
198
+ }
199
+ });
200
+ });
66
201
  },
67
202
  };
@@ -1,3 +1,18 @@
1
+ var __extends = (this && this.__extends) || (function () {
2
+ var extendStatics = function (d, b) {
3
+ extendStatics = Object.setPrototypeOf ||
4
+ ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
5
+ function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
6
+ return extendStatics(d, b);
7
+ };
8
+ return function (d, b) {
9
+ if (typeof b !== "function" && b !== null)
10
+ throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
11
+ extendStatics(d, b);
12
+ function __() { this.constructor = d; }
13
+ d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
14
+ };
15
+ })();
1
16
  import { curve } from "../curve.js";
2
17
  import { PoolTemplate } from "./PoolTemplate.js";
3
18
  import { poolBalancesMetaMixin, poolBalancesLendingMixin } from "./mixins/poolBalancesMixin.js";
@@ -15,15 +30,20 @@ import { withdrawOneCoinWrappedExpected2argsMixin, withdrawOneCoinWrappedExpecte
15
30
  import { withdrawOneCoinWrappedLendingOrCryptoMixin, withdrawOneCoinWrappedMixin } from "./mixins/withdrawOneCoinWrappedMixins.js";
16
31
  import { swapTricrypto2Mixin, swapMetaFactoryMixin, swapCryptoMetaFactoryMixin, swapMixin } from "./mixins/swapMixins.js";
17
32
  import { swapWrappedExpectedAndApproveMixin, swapWrappedTricrypto2Mixin, swapWrappedMixin } from "./mixins/swapWrappedMixins.js";
18
- export const getPool = (poolId) => {
19
- const poolDummy = new PoolTemplate(poolId);
20
- class Pool extends PoolTemplate {
21
- }
33
+ export var getPool = function (poolId) {
34
+ var poolDummy = new PoolTemplate(poolId);
35
+ var Pool = /** @class */ (function (_super) {
36
+ __extends(Pool, _super);
37
+ function Pool() {
38
+ return _super !== null && _super.apply(this, arguments) || this;
39
+ }
40
+ return Pool;
41
+ }(PoolTemplate));
22
42
  // statsBalances
23
43
  if (poolDummy.isMeta) {
24
44
  Object.assign(Pool.prototype, poolBalancesMetaMixin);
25
45
  }
26
- else if (poolDummy.useLending.reduce((x, y) => x || y)) {
46
+ else if (poolDummy.useLending.reduce(function (x, y) { return x || y; })) {
27
47
  Object.assign(Pool.prototype, poolBalancesLendingMixin);
28
48
  }
29
49
  // depositBalancedAmounts