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