@curvefi/api 2.32.0 → 2.33.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 +385 -135
- package/lib/constants/aliases.js +22 -11
- 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/celo.js +5 -5
- package/lib/constants/coins/ethereum.js +10 -9
- package/lib/constants/coins/fantom.js +7 -7
- package/lib/constants/coins/kava.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/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/celo.js +1 -1
- package/lib/constants/pools/ethereum.js +1 -1
- package/lib/constants/pools/fantom.js +1 -1
- package/lib/constants/pools/kava.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/utils.js +19 -18
- package/lib/curve.js +506 -282
- package/lib/external-api.js +132 -45
- package/lib/factory/common.js +3 -3
- package/lib/factory/constants-crypto.js +21 -21
- package/lib/factory/constants.js +32 -31
- package/lib/factory/deploy.js +336 -176
- package/lib/factory/factory-api.js +256 -180
- package/lib/factory/factory-crypto.js +309 -163
- package/lib/factory/factory.d.ts +1 -1
- package/lib/factory/factory.js +336 -186
- package/lib/index.js +98 -44
- package/lib/interfaces.d.ts +5 -0
- package/lib/pools/PoolTemplate.js +2879 -1468
- package/lib/pools/mixins/common.js +106 -22
- package/lib/pools/mixins/depositBalancedAmountsMixins.js +131 -48
- package/lib/pools/mixins/depositMixins.js +413 -144
- package/lib/pools/mixins/depositWrappedMixins.js +223 -72
- package/lib/pools/mixins/poolBalancesMixin.js +98 -22
- package/lib/pools/mixins/swapMixins.js +347 -125
- package/lib/pools/mixins/swapWrappedMixins.js +270 -88
- package/lib/pools/mixins/withdrawExpectedMixins.js +104 -23
- package/lib/pools/mixins/withdrawImbalanceMixins.js +316 -97
- package/lib/pools/mixins/withdrawImbalanceWrappedMixins.js +187 -51
- package/lib/pools/mixins/withdrawMixins.js +385 -122
- package/lib/pools/mixins/withdrawOneCoinExpectedMixins.js +88 -16
- package/lib/pools/mixins/withdrawOneCoinMixins.js +386 -123
- package/lib/pools/mixins/withdrawOneCoinWrappedExpectedMixins.js +62 -8
- package/lib/pools/mixins/withdrawOneCoinWrappedMixins.js +185 -53
- package/lib/pools/mixins/withdrawWrappedMixins.js +185 -50
- package/lib/pools/poolConstructor.js +25 -5
- package/lib/pools/utils.js +488 -299
- package/lib/router.js +675 -212
- package/lib/utils.js +675 -354
- package/package.json +1 -2
|
@@ -1,27 +1,111 @@
|
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
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
|
+
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
38
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
39
|
+
if (ar || !(i in from)) {
|
|
40
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
41
|
+
ar[i] = from[i];
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
45
|
+
};
|
|
1
46
|
import { PoolTemplate } from "../PoolTemplate.js";
|
|
2
47
|
import { curve } from "../../curve.js";
|
|
3
48
|
import { fromBN, toBN } from "../../utils.js";
|
|
4
|
-
export
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
49
|
+
export function _calcExpectedAmounts(_lpTokenAmount) {
|
|
50
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
51
|
+
var coinBalancesBN, i, _balance, totalSupplyBN, _a, expectedAmountsBN, _i, coinBalancesBN_1, coinBalance;
|
|
52
|
+
var _this = this;
|
|
53
|
+
return __generator(this, function (_b) {
|
|
54
|
+
switch (_b.label) {
|
|
55
|
+
case 0:
|
|
56
|
+
coinBalancesBN = [];
|
|
57
|
+
i = 0;
|
|
58
|
+
_b.label = 1;
|
|
59
|
+
case 1:
|
|
60
|
+
if (!(i < this.wrappedCoinAddresses.length)) return [3 /*break*/, 4];
|
|
61
|
+
return [4 /*yield*/, curve.contracts[this.address].contract.balances(i, curve.constantOptions)];
|
|
62
|
+
case 2:
|
|
63
|
+
_balance = _b.sent();
|
|
64
|
+
coinBalancesBN.push(toBN(_balance, this.wrappedDecimals[i]));
|
|
65
|
+
_b.label = 3;
|
|
66
|
+
case 3:
|
|
67
|
+
i++;
|
|
68
|
+
return [3 /*break*/, 1];
|
|
69
|
+
case 4:
|
|
70
|
+
_a = toBN;
|
|
71
|
+
return [4 /*yield*/, curve.contracts[this.lpToken].contract.totalSupply(curve.constantOptions)];
|
|
72
|
+
case 5:
|
|
73
|
+
totalSupplyBN = _a.apply(void 0, [_b.sent()]);
|
|
74
|
+
expectedAmountsBN = [];
|
|
75
|
+
for (_i = 0, coinBalancesBN_1 = coinBalancesBN; _i < coinBalancesBN_1.length; _i++) {
|
|
76
|
+
coinBalance = coinBalancesBN_1[_i];
|
|
77
|
+
expectedAmountsBN.push(coinBalance.times(toBN(_lpTokenAmount)).div(totalSupplyBN));
|
|
78
|
+
}
|
|
79
|
+
return [2 /*return*/, expectedAmountsBN.map(function (amount, i) { return fromBN(amount, _this.wrappedDecimals[i]); })];
|
|
80
|
+
}
|
|
81
|
+
});
|
|
82
|
+
});
|
|
16
83
|
}
|
|
17
|
-
export
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
84
|
+
export function _calcExpectedUnderlyingAmountsMeta(_lpTokenAmount) {
|
|
85
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
86
|
+
var _expectedWrappedAmounts, _expectedMetaCoinAmount, _expectedUnderlyingAmounts, basePool, _basePoolExpectedAmounts, _a;
|
|
87
|
+
return __generator(this, function (_b) {
|
|
88
|
+
switch (_b.label) {
|
|
89
|
+
case 0: return [4 /*yield*/, _calcExpectedAmounts.call(this, _lpTokenAmount)];
|
|
90
|
+
case 1:
|
|
91
|
+
_expectedWrappedAmounts = _b.sent();
|
|
92
|
+
_expectedMetaCoinAmount = _expectedWrappedAmounts.splice(this.metaCoinIdx, 1)[0];
|
|
93
|
+
_expectedUnderlyingAmounts = _expectedWrappedAmounts;
|
|
94
|
+
basePool = new PoolTemplate(this.basePool);
|
|
95
|
+
if (!basePool.isMeta) return [3 /*break*/, 3];
|
|
96
|
+
return [4 /*yield*/, _calcExpectedUnderlyingAmountsMeta.call(basePool, _expectedMetaCoinAmount)];
|
|
97
|
+
case 2:
|
|
98
|
+
_a = _b.sent();
|
|
99
|
+
return [3 /*break*/, 5];
|
|
100
|
+
case 3: return [4 /*yield*/, _calcExpectedAmounts.call(basePool, _expectedMetaCoinAmount)];
|
|
101
|
+
case 4:
|
|
102
|
+
_a = _b.sent();
|
|
103
|
+
_b.label = 5;
|
|
104
|
+
case 5:
|
|
105
|
+
_basePoolExpectedAmounts = _a;
|
|
106
|
+
_expectedUnderlyingAmounts.splice.apply(_expectedUnderlyingAmounts, __spreadArray([this.metaCoinIdx, 0], _basePoolExpectedAmounts, false));
|
|
107
|
+
return [2 /*return*/, _expectedUnderlyingAmounts];
|
|
108
|
+
}
|
|
109
|
+
});
|
|
110
|
+
});
|
|
27
111
|
}
|
|
@@ -1,66 +1,149 @@
|
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
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
|
+
};
|
|
1
37
|
import BigNumber from 'bignumber.js';
|
|
2
38
|
import { BN } from "../../utils.js";
|
|
3
39
|
function _depositBalancedAmounts(poolBalances, walletBalances, decimals) {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
40
|
+
var poolBalancesBN = poolBalances.map(BN);
|
|
41
|
+
var walletBalancesBN = walletBalances.map(BN);
|
|
42
|
+
var poolTotalLiquidityBN = poolBalancesBN.reduce(function (a, b) { return a.plus(b); });
|
|
43
|
+
var poolBalancesRatiosBN = poolBalancesBN.map(function (b) { return b.div(poolTotalLiquidityBN); });
|
|
8
44
|
// Cross factors for each wallet balance used as reference to see the
|
|
9
45
|
// max that can be used according to the lowest relative wallet balance
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
46
|
+
var balancedAmountsForEachScenarioBN = walletBalancesBN.map(function (_, i) { return (walletBalancesBN.map(function (_, j) { return (poolBalancesRatiosBN[j].times(walletBalancesBN[i]).div(poolBalancesRatiosBN[i])); })); });
|
|
47
|
+
var firstCoinBalanceForEachScenarioBN = balancedAmountsForEachScenarioBN.map(function (_a) {
|
|
48
|
+
var a = _a[0];
|
|
49
|
+
return a;
|
|
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]); });
|
|
14
53
|
}
|
|
15
54
|
// @ts-ignore
|
|
16
|
-
export
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
55
|
+
export var depositBalancedAmountsMixin = {
|
|
56
|
+
depositBalancedAmounts: function () {
|
|
57
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
58
|
+
var poolBalances, walletBalances, _a, _b, balancedAmountsBN;
|
|
59
|
+
return __generator(this, function (_c) {
|
|
60
|
+
switch (_c.label) {
|
|
61
|
+
case 0: return [4 /*yield*/, this.stats.underlyingBalances()];
|
|
62
|
+
case 1:
|
|
63
|
+
poolBalances = _c.sent();
|
|
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
|
+
});
|
|
72
|
+
});
|
|
24
73
|
},
|
|
25
74
|
};
|
|
26
75
|
// @ts-ignore
|
|
27
|
-
export
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
76
|
+
export var depositBalancedAmountsCryptoMixin = {
|
|
77
|
+
depositBalancedAmounts: function () {
|
|
78
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
79
|
+
var poolBalances, walletBalances, _a, _b, prices, poolBalancesUSD, walletBalancesUSD, balancedAmountsUSD;
|
|
80
|
+
var _this = this;
|
|
81
|
+
return __generator(this, function (_c) {
|
|
82
|
+
switch (_c.label) {
|
|
83
|
+
case 0: return [4 /*yield*/, this.stats.underlyingBalances()];
|
|
84
|
+
case 1:
|
|
85
|
+
poolBalances = _c.sent();
|
|
86
|
+
_b = (_a = Object).values;
|
|
87
|
+
return [4 /*yield*/, this.walletUnderlyingCoinBalances()];
|
|
88
|
+
case 2:
|
|
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
|
+
});
|
|
99
|
+
});
|
|
39
100
|
},
|
|
40
101
|
};
|
|
41
102
|
// @ts-ignore
|
|
42
|
-
export
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
103
|
+
export var depositWrappedBalancedAmountsMixin = {
|
|
104
|
+
depositWrappedBalancedAmounts: function () {
|
|
105
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
106
|
+
var poolBalances, walletBalances, _a, _b, balancedAmountsBN;
|
|
107
|
+
return __generator(this, function (_c) {
|
|
108
|
+
switch (_c.label) {
|
|
109
|
+
case 0: return [4 /*yield*/, this.stats.wrappedBalances()];
|
|
110
|
+
case 1:
|
|
111
|
+
poolBalances = _c.sent();
|
|
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
|
+
});
|
|
120
|
+
});
|
|
50
121
|
},
|
|
51
122
|
};
|
|
52
123
|
// @ts-ignore
|
|
53
|
-
export
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
124
|
+
export var depositWrappedBalancedAmountsCryptoMixin = {
|
|
125
|
+
depositWrappedBalancedAmounts: function () {
|
|
126
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
127
|
+
var poolBalances, walletBalances, _a, _b, prices, poolBalancesUSD, walletBalancesUSD, balancedAmountsUSD;
|
|
128
|
+
var _this = this;
|
|
129
|
+
return __generator(this, function (_c) {
|
|
130
|
+
switch (_c.label) {
|
|
131
|
+
case 0: return [4 /*yield*/, this.stats.wrappedBalances()];
|
|
132
|
+
case 1:
|
|
133
|
+
poolBalances = (_c.sent()).map(Number);
|
|
134
|
+
_b = (_a = Object).values;
|
|
135
|
+
return [4 /*yield*/, this.walletWrappedCoinBalances()];
|
|
136
|
+
case 2:
|
|
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
|
+
});
|
|
147
|
+
});
|
|
65
148
|
},
|
|
66
149
|
};
|