@curvefi/api 2.63.0 → 2.63.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/lib/boosting.js +247 -645
- package/lib/constants/L2Networks.js +1 -1
- package/lib/constants/aliases.js +19 -19
- package/lib/constants/coins/arbitrum.js +5 -5
- package/lib/constants/coins/aurora.js +5 -5
- package/lib/constants/coins/avalanche.js +6 -6
- package/lib/constants/coins/base.js +5 -5
- package/lib/constants/coins/bsc.js +5 -5
- package/lib/constants/coins/celo.js +5 -5
- package/lib/constants/coins/ethereum.js +9 -9
- package/lib/constants/coins/fantom.js +7 -7
- package/lib/constants/coins/fraxtal.js +5 -5
- package/lib/constants/coins/kava.js +5 -5
- package/lib/constants/coins/mantle.js +5 -5
- package/lib/constants/coins/moonbeam.js +5 -5
- package/lib/constants/coins/optimism.js +5 -5
- package/lib/constants/coins/polygon.js +6 -6
- package/lib/constants/coins/xdai.js +5 -5
- package/lib/constants/coins/xlayer.js +5 -5
- package/lib/constants/coins/zksync.js +5 -5
- package/lib/constants/pools/arbitrum.js +1 -1
- package/lib/constants/pools/aurora.js +1 -1
- package/lib/constants/pools/avalanche.js +1 -1
- package/lib/constants/pools/base.js +1 -1
- package/lib/constants/pools/bsc.js +1 -1
- package/lib/constants/pools/celo.js +1 -1
- package/lib/constants/pools/ethereum.js +2 -2
- package/lib/constants/pools/fantom.js +1 -1
- package/lib/constants/pools/fraxtal.js +1 -1
- package/lib/constants/pools/kava.js +1 -1
- package/lib/constants/pools/mantle.js +1 -1
- package/lib/constants/pools/moonbeam.js +1 -1
- package/lib/constants/pools/optimism.js +1 -1
- package/lib/constants/pools/polygon.js +1 -1
- package/lib/constants/pools/xdai.js +1 -1
- package/lib/constants/pools/xlayer.js +1 -1
- package/lib/constants/pools/zksync.js +1 -1
- package/lib/constants/tricryptoDeployImplementations.js +1 -1
- package/lib/constants/utils.js +18 -19
- package/lib/constants/volumeNetworks.js +1 -1
- package/lib/curve.d.ts +3 -1
- package/lib/curve.js +534 -909
- package/lib/dao.js +351 -705
- package/lib/external-api.js +127 -256
- package/lib/factory/common.js +4 -4
- package/lib/factory/constants-crypto.js +33 -33
- package/lib/factory/constants.js +34 -34
- package/lib/factory/deploy.js +542 -907
- package/lib/factory/factory-api.js +205 -269
- package/lib/factory/factory-crypto.js +202 -342
- package/lib/factory/factory-tricrypto.js +164 -286
- package/lib/factory/factory-twocrypto.js +151 -269
- package/lib/factory/factory.js +245 -385
- package/lib/index.js +109 -198
- package/lib/interfaces.d.ts +1 -6
- package/lib/pools/PoolTemplate.js +1773 -3025
- package/lib/pools/gaugePool.js +112 -251
- package/lib/pools/mixins/common.js +22 -93
- package/lib/pools/mixins/depositBalancedAmountsMixins.js +52 -118
- package/lib/pools/mixins/depositMixins.js +160 -386
- package/lib/pools/mixins/depositWrappedMixins.js +79 -205
- package/lib/pools/mixins/poolBalancesMixin.js +24 -87
- package/lib/pools/mixins/swapMixins.js +139 -324
- package/lib/pools/mixins/swapWrappedMixins.js +111 -265
- package/lib/pools/mixins/withdrawExpectedMixins.js +27 -91
- package/lib/pools/mixins/withdrawImbalanceMixins.js +111 -293
- package/lib/pools/mixins/withdrawImbalanceWrappedMixins.js +58 -169
- package/lib/pools/mixins/withdrawMixins.js +139 -359
- package/lib/pools/mixins/withdrawOneCoinExpectedMixins.js +20 -75
- package/lib/pools/mixins/withdrawOneCoinMixins.js +140 -360
- package/lib/pools/mixins/withdrawOneCoinWrappedExpectedMixins.js +10 -51
- package/lib/pools/mixins/withdrawOneCoinWrappedMixins.js +60 -167
- package/lib/pools/mixins/withdrawWrappedMixins.js +57 -167
- package/lib/pools/poolConstructor.js +5 -25
- package/lib/pools/utils.js +301 -469
- package/lib/route-finder.worker.d.ts +9 -0
- package/lib/route-finder.worker.js +112 -0
- package/lib/route-graph.worker.d.ts +11 -0
- package/lib/route-graph.worker.js +334 -0
- package/lib/router.js +323 -912
- package/lib/utils.d.ts +5 -4
- package/lib/utils.js +539 -918
- package/package.json +1 -1
|
@@ -7,143 +7,77 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
7
7
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
8
|
});
|
|
9
9
|
};
|
|
10
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
11
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
12
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
13
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
14
|
-
function step(op) {
|
|
15
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
16
|
-
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
17
|
-
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;
|
|
18
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
19
|
-
switch (op[0]) {
|
|
20
|
-
case 0: case 1: t = op; break;
|
|
21
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
22
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
23
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
24
|
-
default:
|
|
25
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
26
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
27
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
28
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
29
|
-
if (t[2]) _.ops.pop();
|
|
30
|
-
_.trys.pop(); continue;
|
|
31
|
-
}
|
|
32
|
-
op = body.call(thisArg, _);
|
|
33
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
34
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
35
|
-
}
|
|
36
|
-
};
|
|
37
10
|
import BigNumber from 'bignumber.js';
|
|
38
11
|
import { BN } from "../../utils.js";
|
|
39
12
|
function _depositBalancedAmounts(poolBalances, walletBalances, decimals) {
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
13
|
+
const poolBalancesBN = poolBalances.map(BN);
|
|
14
|
+
const walletBalancesBN = walletBalances.map(BN);
|
|
15
|
+
const poolTotalLiquidityBN = poolBalancesBN.reduce((a, b) => a.plus(b));
|
|
16
|
+
const poolBalancesRatiosBN = poolBalancesBN.map((b) => b.div(poolTotalLiquidityBN));
|
|
44
17
|
// Cross factors for each wallet balance used as reference to see the
|
|
45
18
|
// max that can be used according to the lowest relative wallet balance
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
});
|
|
51
|
-
var scenarioWithLowestBalancesBN = firstCoinBalanceForEachScenarioBN.map(String).indexOf(BigNumber.min.apply(BigNumber, firstCoinBalanceForEachScenarioBN).toString());
|
|
52
|
-
return balancedAmountsForEachScenarioBN[scenarioWithLowestBalancesBN].map(function (a, i) { return a.toFixed(decimals[i]); });
|
|
19
|
+
const balancedAmountsForEachScenarioBN = walletBalancesBN.map((_, i) => (walletBalancesBN.map((_, j) => (poolBalancesRatiosBN[j].times(walletBalancesBN[i]).div(poolBalancesRatiosBN[i])))));
|
|
20
|
+
const firstCoinBalanceForEachScenarioBN = balancedAmountsForEachScenarioBN.map(([a]) => a);
|
|
21
|
+
const scenarioWithLowestBalancesBN = firstCoinBalanceForEachScenarioBN.map(String).indexOf(BigNumber.min(...firstCoinBalanceForEachScenarioBN).toString());
|
|
22
|
+
return balancedAmountsForEachScenarioBN[scenarioWithLowestBalancesBN].map((a, i) => a.toFixed(decimals[i]));
|
|
53
23
|
}
|
|
54
24
|
// @ts-ignore
|
|
55
|
-
export
|
|
56
|
-
depositBalancedAmounts
|
|
57
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
_b = (_a = Object).values;
|
|
65
|
-
return [4 /*yield*/, this.walletUnderlyingCoinBalances()];
|
|
66
|
-
case 2:
|
|
67
|
-
walletBalances = _b.apply(_a, [_c.sent()]);
|
|
68
|
-
balancedAmountsBN = (_depositBalancedAmounts(poolBalances, walletBalances, this.underlyingDecimals));
|
|
69
|
-
return [2 /*return*/, balancedAmountsBN.map(function (b, i) { return BigNumber.min(BN(b), BN(walletBalances[i])).toString(); })];
|
|
70
|
-
}
|
|
71
|
-
});
|
|
25
|
+
export const depositBalancedAmountsMixin = {
|
|
26
|
+
depositBalancedAmounts() {
|
|
27
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
28
|
+
// @ts-ignore
|
|
29
|
+
const poolBalances = yield this.stats.underlyingBalances();
|
|
30
|
+
// @ts-ignore
|
|
31
|
+
const walletBalances = Object.values(yield this.walletUnderlyingCoinBalances());
|
|
32
|
+
const balancedAmountsBN = (_depositBalancedAmounts(poolBalances, walletBalances, this.underlyingDecimals));
|
|
33
|
+
return balancedAmountsBN.map((b, i) => BigNumber.min(BN(b), BN(walletBalances[i])).toString());
|
|
72
34
|
});
|
|
73
35
|
},
|
|
74
36
|
};
|
|
75
37
|
// @ts-ignore
|
|
76
|
-
export
|
|
77
|
-
depositBalancedAmounts
|
|
78
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
walletBalances = _b.apply(_a, [_c.sent()]);
|
|
90
|
-
return [4 /*yield*/, this._underlyingPrices()];
|
|
91
|
-
case 3:
|
|
92
|
-
prices = _c.sent();
|
|
93
|
-
poolBalancesUSD = poolBalances.map(function (b, i) { return BN(b).times(prices[i]).toString(); });
|
|
94
|
-
walletBalancesUSD = walletBalances.map(function (b, i) { return BN(b).times(prices[i]).toString(); });
|
|
95
|
-
balancedAmountsUSD = _depositBalancedAmounts(poolBalancesUSD, walletBalancesUSD, this.underlyingDecimals);
|
|
96
|
-
return [2 /*return*/, balancedAmountsUSD.map(function (b, i) { return BigNumber.min(BN(BN(b).div(prices[i]).toFixed(_this.underlyingDecimals[i])), BN(walletBalances[i])).toString(); })];
|
|
97
|
-
}
|
|
98
|
-
});
|
|
38
|
+
export const depositBalancedAmountsCryptoMixin = {
|
|
39
|
+
depositBalancedAmounts() {
|
|
40
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
41
|
+
// @ts-ignore
|
|
42
|
+
const poolBalances = yield this.stats.underlyingBalances();
|
|
43
|
+
// @ts-ignore
|
|
44
|
+
const walletBalances = Object.values(yield this.walletUnderlyingCoinBalances());
|
|
45
|
+
// @ts-ignore
|
|
46
|
+
const prices = yield this._underlyingPrices();
|
|
47
|
+
const poolBalancesUSD = poolBalances.map((b, i) => BN(b).times(prices[i]).toString());
|
|
48
|
+
const walletBalancesUSD = walletBalances.map((b, i) => BN(b).times(prices[i]).toString());
|
|
49
|
+
const balancedAmountsUSD = _depositBalancedAmounts(poolBalancesUSD, walletBalancesUSD, this.underlyingDecimals);
|
|
50
|
+
return balancedAmountsUSD.map((b, i) => BigNumber.min(BN(BN(b).div(prices[i]).toFixed(this.underlyingDecimals[i])), BN(walletBalances[i])).toString());
|
|
99
51
|
});
|
|
100
52
|
},
|
|
101
53
|
};
|
|
102
54
|
// @ts-ignore
|
|
103
|
-
export
|
|
104
|
-
depositWrappedBalancedAmounts
|
|
105
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
_b = (_a = Object).values;
|
|
113
|
-
return [4 /*yield*/, this.walletWrappedCoinBalances()];
|
|
114
|
-
case 2:
|
|
115
|
-
walletBalances = _b.apply(_a, [_c.sent()]);
|
|
116
|
-
balancedAmountsBN = (_depositBalancedAmounts(poolBalances, walletBalances, this.underlyingDecimals));
|
|
117
|
-
return [2 /*return*/, balancedAmountsBN.map(function (b, i) { return BigNumber.min(BN(b), BN(walletBalances[i])).toString(); })];
|
|
118
|
-
}
|
|
119
|
-
});
|
|
55
|
+
export const depositWrappedBalancedAmountsMixin = {
|
|
56
|
+
depositWrappedBalancedAmounts() {
|
|
57
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
58
|
+
// @ts-ignore
|
|
59
|
+
const poolBalances = yield this.stats.wrappedBalances();
|
|
60
|
+
// @ts-ignore
|
|
61
|
+
const walletBalances = Object.values(yield this.walletWrappedCoinBalances());
|
|
62
|
+
const balancedAmountsBN = (_depositBalancedAmounts(poolBalances, walletBalances, this.underlyingDecimals));
|
|
63
|
+
return balancedAmountsBN.map((b, i) => BigNumber.min(BN(b), BN(walletBalances[i])).toString());
|
|
120
64
|
});
|
|
121
65
|
},
|
|
122
66
|
};
|
|
123
67
|
// @ts-ignore
|
|
124
|
-
export
|
|
125
|
-
depositWrappedBalancedAmounts
|
|
126
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
walletBalances = _b.apply(_a, [_c.sent()]).map(Number);
|
|
138
|
-
return [4 /*yield*/, this._wrappedPrices()];
|
|
139
|
-
case 3:
|
|
140
|
-
prices = _c.sent();
|
|
141
|
-
poolBalancesUSD = poolBalances.map(function (b, i) { return BN(b).times(prices[i]).toString(); });
|
|
142
|
-
walletBalancesUSD = walletBalances.map(function (b, i) { return BN(b).times(prices[i]).toString(); });
|
|
143
|
-
balancedAmountsUSD = _depositBalancedAmounts(poolBalancesUSD, walletBalancesUSD, this.wrappedDecimals);
|
|
144
|
-
return [2 /*return*/, balancedAmountsUSD.map(function (b, i) { return BigNumber.min(BN(BN(b).div(prices[i]).toFixed(_this.wrappedDecimals[i])), BN(walletBalances[i])).toString(); })];
|
|
145
|
-
}
|
|
146
|
-
});
|
|
68
|
+
export const depositWrappedBalancedAmountsCryptoMixin = {
|
|
69
|
+
depositWrappedBalancedAmounts() {
|
|
70
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
71
|
+
// @ts-ignore
|
|
72
|
+
const poolBalances = (yield this.stats.wrappedBalances()).map(Number);
|
|
73
|
+
// @ts-ignore
|
|
74
|
+
const walletBalances = Object.values(yield this.walletWrappedCoinBalances()).map(Number);
|
|
75
|
+
// @ts-ignore
|
|
76
|
+
const prices = yield this._wrappedPrices();
|
|
77
|
+
const poolBalancesUSD = poolBalances.map((b, i) => BN(b).times(prices[i]).toString());
|
|
78
|
+
const walletBalancesUSD = walletBalances.map((b, i) => BN(b).times(prices[i]).toString());
|
|
79
|
+
const balancedAmountsUSD = _depositBalancedAmounts(poolBalancesUSD, walletBalancesUSD, this.wrappedDecimals);
|
|
80
|
+
return balancedAmountsUSD.map((b, i) => BigNumber.min(BN(BN(b).div(prices[i]).toFixed(this.wrappedDecimals[i])), BN(walletBalances[i])).toString());
|
|
147
81
|
});
|
|
148
82
|
},
|
|
149
83
|
};
|