@curvefi/api 2.48.1 → 2.49.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.
- package/README.md +21 -0
- package/lib/boosting.js +61 -53
- package/lib/constants/L2Networks.d.ts +1 -0
- package/lib/constants/L2Networks.js +1 -0
- package/lib/constants/abis/gas_oracle_optimism.json +1 -0
- package/lib/constants/aliases.js +1 -0
- package/lib/curve.js +36 -4
- package/lib/external-api.d.ts +2 -0
- package/lib/factory/deploy.js +15 -15
- package/lib/index.d.ts +1 -0
- package/lib/index.js +2 -1
- package/lib/interfaces.d.ts +1 -0
- package/lib/pools/PoolTemplate.d.ts +1 -0
- package/lib/pools/PoolTemplate.js +2 -1
- package/lib/pools/mixins/depositMixins.js +11 -11
- package/lib/pools/mixins/depositWrappedMixins.js +5 -5
- package/lib/pools/mixins/swapMixins.js +9 -9
- package/lib/pools/mixins/swapWrappedMixins.js +6 -6
- package/lib/pools/mixins/withdrawImbalanceMixins.js +9 -9
- package/lib/pools/mixins/withdrawImbalanceWrappedMixins.js +5 -5
- package/lib/pools/mixins/withdrawMixins.js +11 -11
- package/lib/pools/mixins/withdrawOneCoinMixins.js +11 -11
- package/lib/pools/mixins/withdrawOneCoinWrappedMixins.js +5 -5
- package/lib/pools/mixins/withdrawWrappedMixins.js +5 -5
- package/lib/router.js +11 -10
- package/lib/utils.d.ts +3 -0
- package/lib/utils.js +58 -26
- package/package.json +1 -1
|
@@ -46,7 +46,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
46
46
|
}
|
|
47
47
|
};
|
|
48
48
|
import { curve } from "../../curve.js";
|
|
49
|
-
import { _ensureAllowance, fromBN, getEthIndex, hasAllowance, toBN, parseUnits, mulBy1_3 } from
|
|
49
|
+
import { _ensureAllowance, fromBN, getEthIndex, hasAllowance, toBN, parseUnits, mulBy1_3, DIGas, smartNumber } from '../../utils.js';
|
|
50
50
|
function _depositWrappedCheck(amounts, estimateGas) {
|
|
51
51
|
if (estimateGas === void 0) { estimateGas = false; }
|
|
52
52
|
return __awaiter(this, void 0, void 0, function () {
|
|
@@ -130,8 +130,8 @@ export var depositWrapped2argsMixin = {
|
|
|
130
130
|
case 4:
|
|
131
131
|
gas = _a.sent();
|
|
132
132
|
if (estimateGas)
|
|
133
|
-
return [2 /*return*/,
|
|
134
|
-
gasLimit = mulBy1_3(gas);
|
|
133
|
+
return [2 /*return*/, smartNumber(gas)];
|
|
134
|
+
gasLimit = mulBy1_3(DIGas(gas));
|
|
135
135
|
return [4 /*yield*/, contract.add_liquidity(_amounts, _minMintAmount, __assign(__assign({}, curve.options), { gasLimit: gasLimit, value: value }))];
|
|
136
136
|
case 5: return [2 /*return*/, (_a.sent()).hash];
|
|
137
137
|
}
|
|
@@ -196,8 +196,8 @@ export var depositWrapped3argsMixin = {
|
|
|
196
196
|
case 4:
|
|
197
197
|
gas = _a.sent();
|
|
198
198
|
if (estimateGas)
|
|
199
|
-
return [2 /*return*/,
|
|
200
|
-
gasLimit = mulBy1_3(gas);
|
|
199
|
+
return [2 /*return*/, smartNumber(gas)];
|
|
200
|
+
gasLimit = mulBy1_3(DIGas(gas));
|
|
201
201
|
return [4 /*yield*/, contract.add_liquidity(_amounts, _minMintAmount, false, __assign(__assign({}, curve.options), { gasLimit: gasLimit, value: value }))];
|
|
202
202
|
case 5: return [2 /*return*/, (_a.sent()).hash];
|
|
203
203
|
}
|
|
@@ -46,7 +46,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
46
46
|
}
|
|
47
47
|
};
|
|
48
48
|
import { curve } from "../../curve.js";
|
|
49
|
-
import { _ensureAllowance, _getCoinDecimals, fromBN, hasAllowance, isEth, toBN, parseUnits, mulBy1_3 } from
|
|
49
|
+
import { _ensureAllowance, _getCoinDecimals, fromBN, hasAllowance, isEth, toBN, parseUnits, mulBy1_3, DIGas, smartNumber } from '../../utils.js';
|
|
50
50
|
// @ts-ignore
|
|
51
51
|
function _swapCheck(inputCoin, outputCoin, amount, estimateGas) {
|
|
52
52
|
if (estimateGas === void 0) { estimateGas = false; }
|
|
@@ -129,8 +129,8 @@ export var swapTricrypto2Mixin = {
|
|
|
129
129
|
case 4:
|
|
130
130
|
gas = _a.sent();
|
|
131
131
|
if (estimateGas)
|
|
132
|
-
return [2 /*return*/,
|
|
133
|
-
gasLimit = mulBy1_3(gas);
|
|
132
|
+
return [2 /*return*/, smartNumber(gas)];
|
|
133
|
+
gasLimit = mulBy1_3(DIGas(gas));
|
|
134
134
|
return [4 /*yield*/, contract[exchangeMethod](i, j, _amount, _minRecvAmount, true, __assign(__assign({}, curve.options), { value: value, gasLimit: gasLimit }))];
|
|
135
135
|
case 5: return [2 /*return*/, (_a.sent()).hash];
|
|
136
136
|
}
|
|
@@ -196,8 +196,8 @@ export var swapMetaFactoryMixin = {
|
|
|
196
196
|
case 4:
|
|
197
197
|
gas = _a.sent();
|
|
198
198
|
if (estimateGas)
|
|
199
|
-
return [2 /*return*/,
|
|
200
|
-
gasLimit = gas * curve.parseUnits("140", 0) / curve.parseUnits("100", 0);
|
|
199
|
+
return [2 /*return*/, smartNumber(gas)];
|
|
200
|
+
gasLimit = DIGas(gas) * curve.parseUnits("140", 0) / curve.parseUnits("100", 0);
|
|
201
201
|
return [4 /*yield*/, contract[exchangeMethod](this.address, i, j, _amount, _minRecvAmount, __assign(__assign({}, curve.options), { value: value, gasLimit: gasLimit }))];
|
|
202
202
|
case 5: return [2 /*return*/, (_a.sent()).hash];
|
|
203
203
|
}
|
|
@@ -263,8 +263,8 @@ export var swapCryptoMetaFactoryMixin = {
|
|
|
263
263
|
case 4:
|
|
264
264
|
gas = _a.sent();
|
|
265
265
|
if (estimateGas)
|
|
266
|
-
return [2 /*return*/,
|
|
267
|
-
gasLimit = gas * curve.parseUnits("140", 0) / curve.parseUnits("100", 0);
|
|
266
|
+
return [2 /*return*/, smartNumber(gas)];
|
|
267
|
+
gasLimit = DIGas(gas) * curve.parseUnits("140", 0) / curve.parseUnits("100", 0);
|
|
268
268
|
return [4 /*yield*/, contract[exchangeMethod](this.address, i, j, _amount, _minRecvAmount, true, __assign(__assign({}, curve.options), { value: value, gasLimit: gasLimit }))];
|
|
269
269
|
case 5: return [2 /*return*/, (_a.sent()).hash];
|
|
270
270
|
}
|
|
@@ -330,11 +330,11 @@ export var swapMixin = {
|
|
|
330
330
|
case 4:
|
|
331
331
|
gas = _a.sent();
|
|
332
332
|
if (estimateGas)
|
|
333
|
-
return [2 /*return*/,
|
|
333
|
+
return [2 /*return*/, smartNumber(gas)];
|
|
334
334
|
return [4 /*yield*/, curve.updateFeeData()];
|
|
335
335
|
case 5:
|
|
336
336
|
_a.sent();
|
|
337
|
-
gasLimit = curve.chainId === 137 && this.id === 'ren' ? gas * curve.parseUnits("160", 0) / curve.parseUnits("100", 0) : mulBy1_3(gas);
|
|
337
|
+
gasLimit = curve.chainId === 137 && this.id === 'ren' ? DIGas(gas) * curve.parseUnits("160", 0) / curve.parseUnits("100", 0) : mulBy1_3(DIGas(gas));
|
|
338
338
|
return [4 /*yield*/, contract[exchangeMethod](i, j, _amount, _minRecvAmount, __assign(__assign({}, curve.options), { value: value, gasLimit: gasLimit }))];
|
|
339
339
|
case 6: return [2 /*return*/, (_a.sent()).hash];
|
|
340
340
|
}
|
|
@@ -46,7 +46,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
46
46
|
}
|
|
47
47
|
};
|
|
48
48
|
import { curve } from "../../curve.js";
|
|
49
|
-
import { _ensureAllowance, _getCoinDecimals, ensureAllowance, ensureAllowanceEstimateGas, fromBN, hasAllowance, isEth, toBN, parseUnits, mulBy1_3, } from
|
|
49
|
+
import { _ensureAllowance, _getCoinDecimals, ensureAllowance, ensureAllowanceEstimateGas, fromBN, hasAllowance, isEth, toBN, parseUnits, mulBy1_3, DIGas, smartNumber } from '../../utils.js';
|
|
50
50
|
// @ts-ignore
|
|
51
51
|
function _swapWrappedCheck(inputCoin, outputCoin, amount, estimateGas) {
|
|
52
52
|
if (estimateGas === void 0) { estimateGas = false; }
|
|
@@ -126,8 +126,8 @@ export var swapWrappedTricrypto2Mixin = {
|
|
|
126
126
|
case 4:
|
|
127
127
|
gas = _a.sent();
|
|
128
128
|
if (estimateGas)
|
|
129
|
-
return [2 /*return*/,
|
|
130
|
-
gasLimit = mulBy1_3(gas);
|
|
129
|
+
return [2 /*return*/, smartNumber(gas)];
|
|
130
|
+
gasLimit = mulBy1_3(DIGas(gas));
|
|
131
131
|
return [4 /*yield*/, contract.exchange(i, j, _amount, _minRecvAmount, false, __assign(__assign({}, curve.options), { value: value, gasLimit: gasLimit }))];
|
|
132
132
|
case 5: return [2 /*return*/, (_a.sent()).hash];
|
|
133
133
|
}
|
|
@@ -191,8 +191,8 @@ export var swapWrappedMixin = {
|
|
|
191
191
|
case 4:
|
|
192
192
|
gas = _a.sent();
|
|
193
193
|
if (estimateGas)
|
|
194
|
-
return [2 /*return*/,
|
|
195
|
-
gasLimit = curve.chainId === 137 && this.id === 'ren' ? gas * curve.parseUnits("140", 0) / curve.parseUnits("100", 0) : mulBy1_3(gas);
|
|
194
|
+
return [2 /*return*/, smartNumber(gas)];
|
|
195
|
+
gasLimit = curve.chainId === 137 && this.id === 'ren' ? DIGas(gas) * curve.parseUnits("140", 0) / curve.parseUnits("100", 0) : mulBy1_3(DIGas(gas));
|
|
196
196
|
return [4 /*yield*/, contract.exchange(i, j, _amount, _minRecvAmount, __assign(__assign({}, curve.options), { value: value, gasLimit: gasLimit }))];
|
|
197
197
|
case 5: return [2 /*return*/, (_a.sent()).hash];
|
|
198
198
|
}
|
|
@@ -309,5 +309,5 @@ export var swapWrappedRequiredMixin = {
|
|
|
309
309
|
}
|
|
310
310
|
});
|
|
311
311
|
});
|
|
312
|
-
}
|
|
312
|
+
},
|
|
313
313
|
};
|
|
@@ -46,7 +46,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
46
46
|
}
|
|
47
47
|
};
|
|
48
48
|
import { curve } from "../../curve.js";
|
|
49
|
-
import { _ensureAllowance, fromBN, hasAllowance, toBN, parseUnits, mulBy1_3 } from
|
|
49
|
+
import { _ensureAllowance, fromBN, hasAllowance, toBN, parseUnits, mulBy1_3, smartNumber, DIGas } from '../../utils.js';
|
|
50
50
|
// @ts-ignore
|
|
51
51
|
function _withdrawImbalanceCheck(amounts, estimateGas) {
|
|
52
52
|
if (estimateGas === void 0) { estimateGas = false; }
|
|
@@ -122,8 +122,8 @@ export var withdrawImbalanceMetaFactoryMixin = {
|
|
|
122
122
|
case 4:
|
|
123
123
|
gas = _a.sent();
|
|
124
124
|
if (estimateGas)
|
|
125
|
-
return [2 /*return*/,
|
|
126
|
-
gasLimit = mulBy1_3(gas);
|
|
125
|
+
return [2 /*return*/, smartNumber(gas)];
|
|
126
|
+
gasLimit = mulBy1_3(DIGas(gas));
|
|
127
127
|
return [4 /*yield*/, contract.remove_liquidity_imbalance(this.address, _amounts, _maxBurnAmount, __assign(__assign({}, curve.options), { gasLimit: gasLimit }))];
|
|
128
128
|
case 5: return [2 /*return*/, (_a.sent()).hash];
|
|
129
129
|
}
|
|
@@ -186,8 +186,8 @@ export var withdrawImbalanceZapMixin = {
|
|
|
186
186
|
case 4:
|
|
187
187
|
gas = _a.sent();
|
|
188
188
|
if (estimateGas)
|
|
189
|
-
return [2 /*return*/,
|
|
190
|
-
gasLimit = mulBy1_3(gas);
|
|
189
|
+
return [2 /*return*/, smartNumber(gas)];
|
|
190
|
+
gasLimit = mulBy1_3(DIGas(gas));
|
|
191
191
|
return [4 /*yield*/, contract.remove_liquidity_imbalance(_amounts, _maxBurnAmount, __assign(__assign({}, curve.options), { gasLimit: gasLimit }))];
|
|
192
192
|
case 5: return [2 /*return*/, (_a.sent()).hash];
|
|
193
193
|
}
|
|
@@ -244,8 +244,8 @@ export var withdrawImbalanceLendingMixin = {
|
|
|
244
244
|
case 2:
|
|
245
245
|
gas = _a.sent();
|
|
246
246
|
if (estimateGas)
|
|
247
|
-
return [2 /*return*/,
|
|
248
|
-
gasLimit = curve.chainId === 137 && this.id === 'ren' ? gas * curve.parseUnits("140", 0) / curve.parseUnits("100", 0) : mulBy1_3(gas);
|
|
247
|
+
return [2 /*return*/, smartNumber(gas)];
|
|
248
|
+
gasLimit = curve.chainId === 137 && this.id === 'ren' ? gas * curve.parseUnits("140", 0) / curve.parseUnits("100", 0) : mulBy1_3(DIGas(gas));
|
|
249
249
|
return [4 /*yield*/, contract.remove_liquidity_imbalance(_amounts, _maxBurnAmount, true, __assign(__assign({}, curve.options), { gasLimit: gasLimit }))];
|
|
250
250
|
case 3: return [2 /*return*/, (_a.sent()).hash];
|
|
251
251
|
}
|
|
@@ -302,8 +302,8 @@ export var withdrawImbalancePlainMixin = {
|
|
|
302
302
|
case 2:
|
|
303
303
|
gas = _a.sent();
|
|
304
304
|
if (estimateGas)
|
|
305
|
-
return [2 /*return*/,
|
|
306
|
-
gasLimit = mulBy1_3(gas);
|
|
305
|
+
return [2 /*return*/, smartNumber(gas)];
|
|
306
|
+
gasLimit = mulBy1_3(DIGas(gas));
|
|
307
307
|
return [4 /*yield*/, contract.remove_liquidity_imbalance(_amounts, _maxBurnAmount, __assign(__assign({}, curve.options), { gasLimit: gasLimit }))];
|
|
308
308
|
case 3: return [2 /*return*/, (_a.sent()).hash];
|
|
309
309
|
}
|
|
@@ -46,7 +46,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
46
46
|
}
|
|
47
47
|
};
|
|
48
48
|
import { curve } from "../../curve.js";
|
|
49
|
-
import { fromBN, toBN, parseUnits, mulBy1_3 } from
|
|
49
|
+
import { fromBN, toBN, parseUnits, mulBy1_3, smartNumber, DIGas } from '../../utils.js';
|
|
50
50
|
// @ts-ignore
|
|
51
51
|
function _withdrawImbalanceWrappedCheck(amounts) {
|
|
52
52
|
return __awaiter(this, void 0, void 0, function () {
|
|
@@ -103,8 +103,8 @@ export var withdrawImbalanceWrapped2argsMixin = {
|
|
|
103
103
|
case 2:
|
|
104
104
|
gas = _a.sent();
|
|
105
105
|
if (estimateGas)
|
|
106
|
-
return [2 /*return*/,
|
|
107
|
-
gasLimit = mulBy1_3(gas);
|
|
106
|
+
return [2 /*return*/, smartNumber(gas)];
|
|
107
|
+
gasLimit = mulBy1_3(DIGas(gas));
|
|
108
108
|
return [4 /*yield*/, contract.remove_liquidity_imbalance(_amounts, _maxBurnAmount, __assign(__assign({}, curve.options), { gasLimit: gasLimit }))];
|
|
109
109
|
case 3: return [2 /*return*/, (_a.sent()).hash];
|
|
110
110
|
}
|
|
@@ -161,8 +161,8 @@ export var withdrawImbalanceWrapped3argsMixin = {
|
|
|
161
161
|
case 2:
|
|
162
162
|
gas = _a.sent();
|
|
163
163
|
if (estimateGas)
|
|
164
|
-
return [2 /*return*/,
|
|
165
|
-
gasLimit = curve.chainId === 137 && this.id === 'ren' ? gas * curve.parseUnits("140", 0) / curve.parseUnits("100", 0) : mulBy1_3(gas);
|
|
164
|
+
return [2 /*return*/, smartNumber(gas)];
|
|
165
|
+
gasLimit = curve.chainId === 137 && this.id === 'ren' ? DIGas(gas) * curve.parseUnits("140", 0) / curve.parseUnits("100", 0) : mulBy1_3(DIGas(gas));
|
|
166
166
|
return [4 /*yield*/, contract.remove_liquidity_imbalance(_amounts, _maxBurnAmount, false, __assign(__assign({}, curve.options), { gasLimit: gasLimit }))];
|
|
167
167
|
case 3: return [2 /*return*/, (_a.sent()).hash];
|
|
168
168
|
}
|
|
@@ -55,7 +55,7 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
|
55
55
|
return to.concat(ar || Array.prototype.slice.call(from));
|
|
56
56
|
};
|
|
57
57
|
import { curve } from "../../curve.js";
|
|
58
|
-
import { _ensureAllowance, fromBN, hasAllowance, toBN, parseUnits, mulBy1_3 } from
|
|
58
|
+
import { _ensureAllowance, fromBN, hasAllowance, toBN, parseUnits, mulBy1_3, smartNumber, DIGas } from '../../utils.js';
|
|
59
59
|
// @ts-ignore
|
|
60
60
|
function _withdrawCheck(lpTokenAmount, estimateGas) {
|
|
61
61
|
if (estimateGas === void 0) { estimateGas = false; }
|
|
@@ -129,8 +129,8 @@ export var withdrawMetaFactoryMixin = {
|
|
|
129
129
|
case 4:
|
|
130
130
|
gas = _b.sent();
|
|
131
131
|
if (estimateGas)
|
|
132
|
-
return [2 /*return*/,
|
|
133
|
-
gasLimit = mulBy1_3(gas);
|
|
132
|
+
return [2 /*return*/, smartNumber(gas)];
|
|
133
|
+
gasLimit = mulBy1_3(DIGas(gas));
|
|
134
134
|
return [4 /*yield*/, contract.remove_liquidity(this.address, _lpTokenAmount, _minAmounts, __assign(__assign({}, curve.options), { gasLimit: gasLimit }))];
|
|
135
135
|
case 5: return [2 /*return*/, (_b.sent()).hash];
|
|
136
136
|
}
|
|
@@ -193,8 +193,8 @@ export var withdrawCryptoMetaFactoryMixin = {
|
|
|
193
193
|
case 4:
|
|
194
194
|
gas = _b.sent();
|
|
195
195
|
if (estimateGas)
|
|
196
|
-
return [2 /*return*/,
|
|
197
|
-
gasLimit = mulBy1_3(gas);
|
|
196
|
+
return [2 /*return*/, smartNumber(gas)];
|
|
197
|
+
gasLimit = mulBy1_3(DIGas(gas));
|
|
198
198
|
return [4 /*yield*/, contract.remove_liquidity(this.address, _lpTokenAmount, _minAmounts, true, __assign(__assign({}, curve.options), { gasLimit: gasLimit }))];
|
|
199
199
|
case 5: return [2 /*return*/, (_b.sent()).hash];
|
|
200
200
|
}
|
|
@@ -261,8 +261,8 @@ export var withdrawZapMixin = {
|
|
|
261
261
|
case 4:
|
|
262
262
|
gas = _c.sent();
|
|
263
263
|
if (estimateGas)
|
|
264
|
-
return [2 /*return*/,
|
|
265
|
-
gasLimit = mulBy1_3(gas);
|
|
264
|
+
return [2 /*return*/, smartNumber(gas)];
|
|
265
|
+
gasLimit = mulBy1_3(DIGas(gas));
|
|
266
266
|
return [4 /*yield*/, contract.remove_liquidity.apply(contract, __spreadArray(__spreadArray([], args, false), [__assign(__assign({}, curve.options), { gasLimit: gasLimit })], false))];
|
|
267
267
|
case 5: return [2 /*return*/, (_c.sent()).hash];
|
|
268
268
|
}
|
|
@@ -319,8 +319,8 @@ export var withdrawLendingOrCryptoMixin = {
|
|
|
319
319
|
case 2:
|
|
320
320
|
gas = _b.sent();
|
|
321
321
|
if (estimateGas)
|
|
322
|
-
return [2 /*return*/,
|
|
323
|
-
gasLimit = mulBy1_3(gas);
|
|
322
|
+
return [2 /*return*/, smartNumber(gas)];
|
|
323
|
+
gasLimit = mulBy1_3(DIGas(gas));
|
|
324
324
|
return [4 /*yield*/, contract.remove_liquidity(_lpTokenAmount, _minAmounts, true, __assign(__assign({}, curve.options), { gasLimit: gasLimit }))];
|
|
325
325
|
case 3: return [2 /*return*/, (_b.sent()).hash];
|
|
326
326
|
}
|
|
@@ -377,8 +377,8 @@ export var withdrawPlainMixin = {
|
|
|
377
377
|
case 2:
|
|
378
378
|
gas = _b.sent();
|
|
379
379
|
if (estimateGas)
|
|
380
|
-
return [2 /*return*/,
|
|
381
|
-
gasLimit = mulBy1_3(gas);
|
|
380
|
+
return [2 /*return*/, smartNumber(gas)];
|
|
381
|
+
gasLimit = mulBy1_3(DIGas(gas));
|
|
382
382
|
return [4 /*yield*/, contract.remove_liquidity(_lpTokenAmount, _minAmounts, __assign(__assign({}, curve.options), { gasLimit: gasLimit }))];
|
|
383
383
|
case 3: return [2 /*return*/, (_b.sent()).hash];
|
|
384
384
|
}
|
|
@@ -55,7 +55,7 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
|
55
55
|
return to.concat(ar || Array.prototype.slice.call(from));
|
|
56
56
|
};
|
|
57
57
|
import { curve } from "../../curve.js";
|
|
58
|
-
import { _ensureAllowance, fromBN, hasAllowance, toBN, parseUnits, mulBy1_3 } from
|
|
58
|
+
import { _ensureAllowance, fromBN, hasAllowance, toBN, parseUnits, mulBy1_3, smartNumber, DIGas } from '../../utils.js';
|
|
59
59
|
// @ts-ignore
|
|
60
60
|
function _withdrawOneCoinCheck(lpTokenAmount, coin, estimateGas) {
|
|
61
61
|
if (estimateGas === void 0) { estimateGas = false; }
|
|
@@ -130,8 +130,8 @@ export var withdrawOneCoinMetaFactoryMixin = {
|
|
|
130
130
|
case 4:
|
|
131
131
|
gas = _a.sent();
|
|
132
132
|
if (estimateGas)
|
|
133
|
-
return [2 /*return*/,
|
|
134
|
-
gasLimit = mulBy1_3(gas);
|
|
133
|
+
return [2 /*return*/, smartNumber(gas)];
|
|
134
|
+
gasLimit = mulBy1_3(DIGas(gas));
|
|
135
135
|
return [4 /*yield*/, contract.remove_liquidity_one_coin(this.address, _lpTokenAmount, i, _minAmount, __assign(__assign({}, curve.options), { gasLimit: gasLimit }))];
|
|
136
136
|
case 5: return [2 /*return*/, (_a.sent()).hash];
|
|
137
137
|
}
|
|
@@ -194,8 +194,8 @@ export var withdrawOneCoinCryptoMetaFactoryMixin = {
|
|
|
194
194
|
case 4:
|
|
195
195
|
gas = _a.sent();
|
|
196
196
|
if (estimateGas)
|
|
197
|
-
return [2 /*return*/,
|
|
198
|
-
gasLimit = mulBy1_3(gas);
|
|
197
|
+
return [2 /*return*/, smartNumber(gas)];
|
|
198
|
+
gasLimit = mulBy1_3(DIGas(gas));
|
|
199
199
|
return [4 /*yield*/, contract.remove_liquidity_one_coin(this.address, _lpTokenAmount, i, _minAmount, true, __assign(__assign({}, curve.options), { gasLimit: gasLimit }))];
|
|
200
200
|
case 5: return [2 /*return*/, (_a.sent()).hash];
|
|
201
201
|
}
|
|
@@ -262,8 +262,8 @@ export var withdrawOneCoinZapMixin = {
|
|
|
262
262
|
case 4:
|
|
263
263
|
gas = _b.sent();
|
|
264
264
|
if (estimateGas)
|
|
265
|
-
return [2 /*return*/,
|
|
266
|
-
gasLimit = mulBy1_3(gas);
|
|
265
|
+
return [2 /*return*/, smartNumber(gas)];
|
|
266
|
+
gasLimit = mulBy1_3(DIGas(gas));
|
|
267
267
|
return [4 /*yield*/, contract.remove_liquidity_one_coin.apply(contract, __spreadArray(__spreadArray([], args, false), [__assign(__assign({}, curve.options), { gasLimit: gasLimit })], false))];
|
|
268
268
|
case 5: return [2 /*return*/, (_b.sent()).hash];
|
|
269
269
|
}
|
|
@@ -320,8 +320,8 @@ export var withdrawOneCoinLendingOrCryptoMixin = {
|
|
|
320
320
|
case 2:
|
|
321
321
|
gas = _a.sent();
|
|
322
322
|
if (estimateGas)
|
|
323
|
-
return [2 /*return*/,
|
|
324
|
-
gasLimit = curve.chainId === 137 && this.id === 'ren' ? gas * curve.parseUnits("160", 0) / curve.parseUnits("100", 0) : mulBy1_3(gas);
|
|
323
|
+
return [2 /*return*/, smartNumber(gas)];
|
|
324
|
+
gasLimit = curve.chainId === 137 && this.id === 'ren' ? gas * curve.parseUnits("160", 0) / curve.parseUnits("100", 0) : mulBy1_3(DIGas(gas));
|
|
325
325
|
return [4 /*yield*/, contract.remove_liquidity_one_coin(_lpTokenAmount, i, _minAmount, true, __assign(__assign({}, curve.options), { gasLimit: gasLimit }))];
|
|
326
326
|
case 3: return [2 /*return*/, (_a.sent()).hash];
|
|
327
327
|
}
|
|
@@ -378,8 +378,8 @@ export var withdrawOneCoinPlainMixin = {
|
|
|
378
378
|
case 2:
|
|
379
379
|
gas = _a.sent();
|
|
380
380
|
if (estimateGas)
|
|
381
|
-
return [2 /*return*/,
|
|
382
|
-
gasLimit = mulBy1_3(gas);
|
|
381
|
+
return [2 /*return*/, smartNumber(gas)];
|
|
382
|
+
gasLimit = mulBy1_3(DIGas(gas));
|
|
383
383
|
return [4 /*yield*/, contract.remove_liquidity_one_coin(_lpTokenAmount, i, _minAmount, __assign(__assign({}, curve.options), { gasLimit: gasLimit }))];
|
|
384
384
|
case 3: return [2 /*return*/, (_a.sent()).hash];
|
|
385
385
|
}
|
|
@@ -46,7 +46,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
46
46
|
}
|
|
47
47
|
};
|
|
48
48
|
import { curve } from "../../curve.js";
|
|
49
|
-
import { fromBN, toBN, parseUnits, mulBy1_3 } from
|
|
49
|
+
import { fromBN, toBN, parseUnits, mulBy1_3, smartNumber, DIGas } from '../../utils.js';
|
|
50
50
|
// @ts-ignore
|
|
51
51
|
function _withdrawOneCoinWrappedCheck(lpTokenAmount, coin) {
|
|
52
52
|
return __awaiter(this, void 0, void 0, function () {
|
|
@@ -101,8 +101,8 @@ export var withdrawOneCoinWrappedLendingOrCryptoMixin = {
|
|
|
101
101
|
case 2:
|
|
102
102
|
gas = _a.sent();
|
|
103
103
|
if (estimateGas)
|
|
104
|
-
return [2 /*return*/,
|
|
105
|
-
gasLimit = curve.chainId === 137 && this.id === 'ren' ? gas * curve.parseUnits("160", 0) / curve.parseUnits("100", 0) : mulBy1_3(gas);
|
|
104
|
+
return [2 /*return*/, smartNumber(gas)];
|
|
105
|
+
gasLimit = curve.chainId === 137 && this.id === 'ren' ? DIGas(gas) * curve.parseUnits("160", 0) / curve.parseUnits("100", 0) : mulBy1_3(DIGas(gas));
|
|
106
106
|
return [4 /*yield*/, contract.remove_liquidity_one_coin(_lpTokenAmount, i, _minAmount, false, __assign(__assign({}, curve.options), { gasLimit: gasLimit }))];
|
|
107
107
|
case 3: return [2 /*return*/, (_a.sent()).hash];
|
|
108
108
|
}
|
|
@@ -159,8 +159,8 @@ export var withdrawOneCoinWrappedMixin = {
|
|
|
159
159
|
case 2:
|
|
160
160
|
gas = _a.sent();
|
|
161
161
|
if (estimateGas)
|
|
162
|
-
return [2 /*return*/,
|
|
163
|
-
gasLimit = mulBy1_3(gas);
|
|
162
|
+
return [2 /*return*/, smartNumber(gas)];
|
|
163
|
+
gasLimit = mulBy1_3(DIGas(gas));
|
|
164
164
|
return [4 /*yield*/, contract.remove_liquidity_one_coin(_lpTokenAmount, i, _minAmount, __assign(__assign({}, curve.options), { gasLimit: gasLimit }))];
|
|
165
165
|
case 3: return [2 /*return*/, (_a.sent()).hash];
|
|
166
166
|
}
|
|
@@ -46,7 +46,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
46
46
|
}
|
|
47
47
|
};
|
|
48
48
|
import { curve } from "../../curve.js";
|
|
49
|
-
import { fromBN, toBN, parseUnits, mulBy1_3 } from
|
|
49
|
+
import { fromBN, toBN, parseUnits, mulBy1_3, smartNumber, DIGas } from '../../utils.js';
|
|
50
50
|
// @ts-ignore
|
|
51
51
|
function _withdrawWrappedCheck(lpTokenAmount) {
|
|
52
52
|
return __awaiter(this, void 0, void 0, function () {
|
|
@@ -101,8 +101,8 @@ export var withdrawWrapped2argsMixin = {
|
|
|
101
101
|
case 2:
|
|
102
102
|
gas = _b.sent();
|
|
103
103
|
if (estimateGas)
|
|
104
|
-
return [2 /*return*/,
|
|
105
|
-
gasLimit = mulBy1_3(gas);
|
|
104
|
+
return [2 /*return*/, smartNumber(gas)];
|
|
105
|
+
gasLimit = mulBy1_3(DIGas(gas));
|
|
106
106
|
return [4 /*yield*/, contract.remove_liquidity(_lpTokenAmount, _minAmounts, __assign(__assign({}, curve.options), { gasLimit: gasLimit }))];
|
|
107
107
|
case 3: return [2 /*return*/, (_b.sent()).hash];
|
|
108
108
|
}
|
|
@@ -159,8 +159,8 @@ export var withdrawWrapped3argsMixin = {
|
|
|
159
159
|
case 2:
|
|
160
160
|
gas = _b.sent();
|
|
161
161
|
if (estimateGas)
|
|
162
|
-
return [2 /*return*/,
|
|
163
|
-
gasLimit = mulBy1_3(gas);
|
|
162
|
+
return [2 /*return*/, smartNumber(gas)];
|
|
163
|
+
gasLimit = mulBy1_3(DIGas(gas));
|
|
164
164
|
return [4 /*yield*/, contract.remove_liquidity(_lpTokenAmount, _minAmounts, false, __assign(__assign({}, curve.options), { gasLimit: gasLimit }))];
|
|
165
165
|
case 3: return [2 /*return*/, (_b.sent()).hash];
|
|
166
166
|
}
|
package/lib/router.js
CHANGED
|
@@ -58,7 +58,7 @@ import axios from "axios";
|
|
|
58
58
|
import memoize from "memoizee";
|
|
59
59
|
import { ethers } from "ethers";
|
|
60
60
|
import { curve } from "./curve.js";
|
|
61
|
-
import { _getCoinAddresses, _getCoinDecimals, _getUsdRate, ensureAllowance, ensureAllowanceEstimateGas, fromBN, hasAllowance, isEth, toBN, BN, parseUnits, _cutZeros, ETH_ADDRESS, _get_small_x, _get_price_impact, } from "./utils.js";
|
|
61
|
+
import { _getCoinAddresses, _getCoinDecimals, _getUsdRate, ensureAllowance, ensureAllowanceEstimateGas, fromBN, hasAllowance, isEth, toBN, BN, parseUnits, _cutZeros, ETH_ADDRESS, _get_small_x, _get_price_impact, DIGas, } from "./utils.js";
|
|
62
62
|
import { getPool } from "./pools/index.js";
|
|
63
63
|
import { _getAmplificationCoefficientsFromApi } from "./pools/utils.js";
|
|
64
64
|
var MAX_STEPS = 5;
|
|
@@ -568,7 +568,7 @@ var _estimateGasForDifferentRoutes = function (routes, inputCoinAddress, outputC
|
|
|
568
568
|
var routeKey = _getRouteKey(route, inputCoinAddress, outputCoinAddress);
|
|
569
569
|
_estimatedGasForDifferentRoutesCache[routeKey] = { 'gas': _gasAmounts_1[i], 'time': Date.now() };
|
|
570
570
|
});
|
|
571
|
-
return [2 /*return*/, _gasAmounts_1.map(function (_g) { return Number(curve.formatUnits(_g, 0)); })];
|
|
571
|
+
return [2 /*return*/, _gasAmounts_1.map(function (_g) { return Number(curve.formatUnits(DIGas(_g), 0)); })];
|
|
572
572
|
case 3:
|
|
573
573
|
err_1 = _c.sent();
|
|
574
574
|
return [2 /*return*/, routes.map(function () { return 0; })];
|
|
@@ -842,18 +842,18 @@ export var swapEstimateGas = function (inputCoin, outputCoin, amount) { return _
|
|
|
842
842
|
export var swap = function (inputCoin, outputCoin, amount, slippage) {
|
|
843
843
|
if (slippage === void 0) { slippage = 0.5; }
|
|
844
844
|
return __awaiter(void 0, void 0, void 0, function () {
|
|
845
|
-
var _a, inputCoinAddress, outputCoinAddress, _b, inputCoinDecimals, outputCoinDecimals, _c, route, output, _d, _route, _swapParams, _pools, _amount, minRecvAmountBN, _minRecvAmount, contract, value, gasLimit;
|
|
846
|
-
return __generator(this, function (
|
|
847
|
-
switch (
|
|
845
|
+
var _a, inputCoinAddress, outputCoinAddress, _b, inputCoinDecimals, outputCoinDecimals, _c, route, output, _d, _route, _swapParams, _pools, _amount, minRecvAmountBN, _minRecvAmount, contract, value, gasLimit, _e;
|
|
846
|
+
return __generator(this, function (_f) {
|
|
847
|
+
switch (_f.label) {
|
|
848
848
|
case 0:
|
|
849
849
|
_a = _getCoinAddresses(inputCoin, outputCoin), inputCoinAddress = _a[0], outputCoinAddress = _a[1];
|
|
850
850
|
_b = _getCoinDecimals(inputCoinAddress, outputCoinAddress), inputCoinDecimals = _b[0], outputCoinDecimals = _b[1];
|
|
851
851
|
return [4 /*yield*/, swapApprove(inputCoin, amount)];
|
|
852
852
|
case 1:
|
|
853
|
-
|
|
853
|
+
_f.sent();
|
|
854
854
|
return [4 /*yield*/, getBestRouteAndOutput(inputCoinAddress, outputCoinAddress, amount)];
|
|
855
855
|
case 2:
|
|
856
|
-
_c =
|
|
856
|
+
_c = _f.sent(), route = _c.route, output = _c.output;
|
|
857
857
|
if (route.length === 0) {
|
|
858
858
|
throw new Error("This pair can't be exchanged");
|
|
859
859
|
}
|
|
@@ -865,12 +865,13 @@ export var swap = function (inputCoin, outputCoin, amount, slippage) {
|
|
|
865
865
|
value = isEth(inputCoinAddress) ? _amount : curve.parseUnits("0");
|
|
866
866
|
return [4 /*yield*/, curve.updateFeeData()];
|
|
867
867
|
case 3:
|
|
868
|
-
|
|
868
|
+
_f.sent();
|
|
869
|
+
_e = DIGas;
|
|
869
870
|
return [4 /*yield*/, contract.exchange.estimateGas(_route, _swapParams, _amount, _minRecvAmount, _pools, __assign(__assign({}, curve.constantOptions), { value: value }))];
|
|
870
871
|
case 4:
|
|
871
|
-
gasLimit = (_e.sent()) * (curve.chainId === 1 ? curve.parseUnits("130", 0) : curve.parseUnits("160", 0)) / curve.parseUnits("100", 0);
|
|
872
|
+
gasLimit = (_e.apply(void 0, [_f.sent()])) * (curve.chainId === 1 ? curve.parseUnits("130", 0) : curve.parseUnits("160", 0)) / curve.parseUnits("100", 0);
|
|
872
873
|
return [4 /*yield*/, contract.exchange(_route, _swapParams, _amount, _minRecvAmount, _pools, __assign(__assign({}, curve.options), { value: value, gasLimit: gasLimit }))];
|
|
873
|
-
case 5: return [2 /*return*/,
|
|
874
|
+
case 5: return [2 /*return*/, _f.sent()];
|
|
874
875
|
}
|
|
875
876
|
});
|
|
876
877
|
});
|
package/lib/utils.d.ts
CHANGED
|
@@ -13,6 +13,8 @@ export declare const fromBN: (bn: BigNumber, decimals?: number) => bigint;
|
|
|
13
13
|
export declare const isEth: (address: string) => boolean;
|
|
14
14
|
export declare const getEthIndex: (addresses: string[]) => number;
|
|
15
15
|
export declare const mulBy1_3: (n: bigint) => bigint;
|
|
16
|
+
export declare const smartNumber: (abstractNumber: bigint | bigint[]) => number | number[];
|
|
17
|
+
export declare const DIGas: (gas: bigint | Array<bigint>) => bigint;
|
|
16
18
|
export declare const _getCoinAddressesNoCheck: (...coins: string[] | string[][]) => string[];
|
|
17
19
|
export declare const _getCoinAddresses: (...coins: string[] | string[][]) => string[];
|
|
18
20
|
export declare const _getCoinDecimals: (...coinAddresses: string[] | string[][]) => number[];
|
|
@@ -31,6 +33,7 @@ export declare const _getCrvApyFromApi: () => Promise<IDict<[number, number]>>;
|
|
|
31
33
|
export declare const _getRewardsFromApi: () => Promise<IDict<IRewardFromApi[]>>;
|
|
32
34
|
export declare const _getUsdRate: (assetId: string) => Promise<number>;
|
|
33
35
|
export declare const getUsdRate: (coin: string) => Promise<number>;
|
|
36
|
+
export declare const getGasPriceFromL1: () => Promise<number>;
|
|
34
37
|
export declare const getTVL: (network?: INetworkName | IChainId) => Promise<number>;
|
|
35
38
|
export declare const getVolume: (network?: INetworkName | IChainId) => Promise<{
|
|
36
39
|
totalVolume: number;
|