@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,68 +1,204 @@
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 _withdrawImbalanceWrappedCheck(amounts) {
5
- const lpTokenAmount = await this.withdrawImbalanceWrappedExpected(amounts);
6
- const lpTokenBalance = (await this.wallet.lpTokenBalances())['lpToken'];
7
- if (Number(lpTokenBalance) < Number(lpTokenAmount)) {
8
- throw Error(`Not enough LP tokens. Actual: ${lpTokenBalance}, required: ${lpTokenAmount}`);
9
- }
10
- await curve.updateFeeData();
11
- return amounts.map((amount, i) => parseUnits(amount, this.wrappedDecimals[i]));
51
+ function _withdrawImbalanceWrappedCheck(amounts) {
52
+ return __awaiter(this, void 0, void 0, function () {
53
+ var lpTokenAmount, lpTokenBalance;
54
+ var _this = this;
55
+ return __generator(this, function (_a) {
56
+ switch (_a.label) {
57
+ case 0: return [4 /*yield*/, this.withdrawImbalanceWrappedExpected(amounts)];
58
+ case 1:
59
+ lpTokenAmount = _a.sent();
60
+ return [4 /*yield*/, this.wallet.lpTokenBalances()];
61
+ case 2:
62
+ lpTokenBalance = (_a.sent())['lpToken'];
63
+ if (Number(lpTokenBalance) < Number(lpTokenAmount)) {
64
+ throw Error("Not enough LP tokens. Actual: ".concat(lpTokenBalance, ", required: ").concat(lpTokenAmount));
65
+ }
66
+ return [4 /*yield*/, curve.updateFeeData()];
67
+ case 3:
68
+ _a.sent();
69
+ return [2 /*return*/, amounts.map(function (amount, i) { return parseUnits(amount, _this.wrappedDecimals[i]); })];
70
+ }
71
+ });
72
+ });
12
73
  }
13
- async function _withdrawImbalanceWrappedMaxBurnAmount(_amounts, slippage = 0.5) {
14
- // @ts-ignore
15
- const _expectedLpTokenAmount = await this._calcLpTokenAmount(_amounts, false, false);
16
- const maxBurnAmountBN = toBN(_expectedLpTokenAmount).times(100 + slippage).div(100);
17
- return fromBN(maxBurnAmountBN);
74
+ function _withdrawImbalanceWrappedMaxBurnAmount(_amounts, slippage) {
75
+ if (slippage === void 0) { slippage = 0.5; }
76
+ return __awaiter(this, void 0, void 0, function () {
77
+ var _expectedLpTokenAmount, maxBurnAmountBN;
78
+ return __generator(this, function (_a) {
79
+ switch (_a.label) {
80
+ case 0: return [4 /*yield*/, this._calcLpTokenAmount(_amounts, false, false)];
81
+ case 1:
82
+ _expectedLpTokenAmount = _a.sent();
83
+ maxBurnAmountBN = toBN(_expectedLpTokenAmount).times(100 + slippage).div(100);
84
+ return [2 /*return*/, fromBN(maxBurnAmountBN)];
85
+ }
86
+ });
87
+ });
18
88
  }
19
89
  // @ts-ignore
20
- export const withdrawImbalanceWrapped2argsMixin = {
90
+ export var withdrawImbalanceWrapped2argsMixin = {
21
91
  // @ts-ignore
22
- async _withdrawImbalanceWrapped(_amounts, slippage, estimateGas = false) {
23
- const _maxBurnAmount = await _withdrawImbalanceWrappedMaxBurnAmount.call(this, _amounts, slippage);
24
- const contract = curve.contracts[this.address].contract;
25
- const gas = await contract.remove_liquidity_imbalance.estimateGas(_amounts, _maxBurnAmount, curve.constantOptions);
26
- if (estimateGas)
27
- return Number(gas);
28
- const gasLimit = mulBy1_3(gas);
29
- return (await contract.remove_liquidity_imbalance(_amounts, _maxBurnAmount, { ...curve.options, gasLimit })).hash;
92
+ _withdrawImbalanceWrapped: function (_amounts, slippage, estimateGas) {
93
+ if (estimateGas === void 0) { estimateGas = false; }
94
+ return __awaiter(this, void 0, void 0, function () {
95
+ var _maxBurnAmount, contract, gas, gasLimit;
96
+ return __generator(this, function (_a) {
97
+ switch (_a.label) {
98
+ case 0: return [4 /*yield*/, _withdrawImbalanceWrappedMaxBurnAmount.call(this, _amounts, slippage)];
99
+ case 1:
100
+ _maxBurnAmount = _a.sent();
101
+ contract = curve.contracts[this.address].contract;
102
+ return [4 /*yield*/, contract.remove_liquidity_imbalance.estimateGas(_amounts, _maxBurnAmount, curve.constantOptions)];
103
+ case 2:
104
+ gas = _a.sent();
105
+ if (estimateGas)
106
+ return [2 /*return*/, Number(gas)];
107
+ gasLimit = mulBy1_3(gas);
108
+ return [4 /*yield*/, contract.remove_liquidity_imbalance(_amounts, _maxBurnAmount, __assign(__assign({}, curve.options), { gasLimit: gasLimit }))];
109
+ case 3: return [2 /*return*/, (_a.sent()).hash];
110
+ }
111
+ });
112
+ });
30
113
  },
31
- async withdrawImbalanceWrappedEstimateGas(amounts) {
32
- // @ts-ignore
33
- const _amounts = await _withdrawImbalanceWrappedCheck.call(this, amounts);
34
- // @ts-ignore
35
- return await this._withdrawImbalanceWrapped(_amounts, 0.1, true);
114
+ withdrawImbalanceWrappedEstimateGas: function (amounts) {
115
+ return __awaiter(this, void 0, void 0, function () {
116
+ var _amounts;
117
+ return __generator(this, function (_a) {
118
+ switch (_a.label) {
119
+ case 0: return [4 /*yield*/, _withdrawImbalanceWrappedCheck.call(this, amounts)];
120
+ case 1:
121
+ _amounts = _a.sent();
122
+ return [4 /*yield*/, this._withdrawImbalanceWrapped(_amounts, 0.1, true)];
123
+ case 2:
124
+ // @ts-ignore
125
+ return [2 /*return*/, _a.sent()];
126
+ }
127
+ });
128
+ });
36
129
  },
37
- async withdrawImbalanceWrapped(amounts, slippage) {
38
- // @ts-ignore
39
- const _amounts = await _withdrawImbalanceWrappedCheck.call(this, amounts);
40
- // @ts-ignore
41
- return await this._withdrawImbalanceWrapped(_amounts, slippage);
130
+ withdrawImbalanceWrapped: function (amounts, slippage) {
131
+ return __awaiter(this, void 0, void 0, function () {
132
+ var _amounts;
133
+ return __generator(this, function (_a) {
134
+ switch (_a.label) {
135
+ case 0: return [4 /*yield*/, _withdrawImbalanceWrappedCheck.call(this, amounts)];
136
+ case 1:
137
+ _amounts = _a.sent();
138
+ return [4 /*yield*/, this._withdrawImbalanceWrapped(_amounts, slippage)];
139
+ case 2:
140
+ // @ts-ignore
141
+ return [2 /*return*/, _a.sent()];
142
+ }
143
+ });
144
+ });
42
145
  },
43
146
  };
44
147
  // @ts-ignore
45
- export const withdrawImbalanceWrapped3argsMixin = {
148
+ export var withdrawImbalanceWrapped3argsMixin = {
46
149
  // @ts-ignore
47
- async _withdrawImbalanceWrapped(_amounts, slippage, estimateGas = false) {
48
- const _maxBurnAmount = await _withdrawImbalanceWrappedMaxBurnAmount.call(this, _amounts, slippage);
49
- const contract = curve.contracts[this.address].contract;
50
- const gas = await contract.remove_liquidity_imbalance.estimateGas(_amounts, _maxBurnAmount, false, curve.constantOptions);
51
- if (estimateGas)
52
- return Number(gas);
53
- const gasLimit = curve.chainId === 137 && this.id === 'ren' ? gas * 140n / 100n : mulBy1_3(gas);
54
- return (await contract.remove_liquidity_imbalance(_amounts, _maxBurnAmount, false, { ...curve.options, gasLimit })).hash;
150
+ _withdrawImbalanceWrapped: function (_amounts, slippage, estimateGas) {
151
+ if (estimateGas === void 0) { estimateGas = false; }
152
+ return __awaiter(this, void 0, void 0, function () {
153
+ var _maxBurnAmount, contract, gas, gasLimit;
154
+ return __generator(this, function (_a) {
155
+ switch (_a.label) {
156
+ case 0: return [4 /*yield*/, _withdrawImbalanceWrappedMaxBurnAmount.call(this, _amounts, slippage)];
157
+ case 1:
158
+ _maxBurnAmount = _a.sent();
159
+ contract = curve.contracts[this.address].contract;
160
+ return [4 /*yield*/, contract.remove_liquidity_imbalance.estimateGas(_amounts, _maxBurnAmount, false, curve.constantOptions)];
161
+ case 2:
162
+ gas = _a.sent();
163
+ if (estimateGas)
164
+ return [2 /*return*/, Number(gas)];
165
+ gasLimit = curve.chainId === 137 && this.id === 'ren' ? gas * curve.parseUnits("140", 0) / curve.parseUnits("100", 0) : mulBy1_3(gas);
166
+ return [4 /*yield*/, contract.remove_liquidity_imbalance(_amounts, _maxBurnAmount, false, __assign(__assign({}, curve.options), { gasLimit: gasLimit }))];
167
+ case 3: return [2 /*return*/, (_a.sent()).hash];
168
+ }
169
+ });
170
+ });
55
171
  },
56
- async withdrawImbalanceWrappedEstimateGas(amounts) {
57
- // @ts-ignore
58
- const _amounts = await _withdrawImbalanceWrappedCheck.call(this, amounts);
59
- // @ts-ignore
60
- return await this._withdrawImbalanceWrapped(_amounts, 0.1, true);
172
+ withdrawImbalanceWrappedEstimateGas: function (amounts) {
173
+ return __awaiter(this, void 0, void 0, function () {
174
+ var _amounts;
175
+ return __generator(this, function (_a) {
176
+ switch (_a.label) {
177
+ case 0: return [4 /*yield*/, _withdrawImbalanceWrappedCheck.call(this, amounts)];
178
+ case 1:
179
+ _amounts = _a.sent();
180
+ return [4 /*yield*/, this._withdrawImbalanceWrapped(_amounts, 0.1, true)];
181
+ case 2:
182
+ // @ts-ignore
183
+ return [2 /*return*/, _a.sent()];
184
+ }
185
+ });
186
+ });
61
187
  },
62
- async withdrawImbalanceWrapped(amounts, slippage) {
63
- // @ts-ignore
64
- const _amounts = await _withdrawImbalanceWrappedCheck.call(this, amounts);
65
- // @ts-ignore
66
- return await this._withdrawImbalanceWrapped(_amounts, slippage);
188
+ withdrawImbalanceWrapped: function (amounts, slippage) {
189
+ return __awaiter(this, void 0, void 0, function () {
190
+ var _amounts;
191
+ return __generator(this, function (_a) {
192
+ switch (_a.label) {
193
+ case 0: return [4 /*yield*/, _withdrawImbalanceWrappedCheck.call(this, amounts)];
194
+ case 1:
195
+ _amounts = _a.sent();
196
+ return [4 /*yield*/, this._withdrawImbalanceWrapped(_amounts, slippage)];
197
+ case 2:
198
+ // @ts-ignore
199
+ return [2 /*return*/, _a.sent()];
200
+ }
201
+ });
202
+ });
67
203
  },
68
204
  };