@curvefi/api 2.31.0 → 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.
- package/lib/boosting.js +137 -402
- package/lib/constants/aliases.d.ts +11 -11
- package/lib/constants/aliases.js +12 -15
- package/lib/constants/coins/arbitrum.js +6 -9
- package/lib/constants/coins/aurora.js +6 -9
- package/lib/constants/coins/avalanche.js +7 -10
- package/lib/constants/coins/celo.js +6 -9
- package/lib/constants/coins/ethereum.js +10 -13
- package/lib/constants/coins/fantom.js +8 -11
- package/lib/constants/coins/kava.js +6 -9
- package/lib/constants/coins/moonbeam.js +6 -9
- package/lib/constants/coins/optimism.js +6 -9
- package/lib/constants/coins/polygon.js +7 -10
- package/lib/constants/coins/xdai.js +6 -9
- package/lib/constants/pools/arbitrum.d.ts +2 -4
- package/lib/constants/pools/arbitrum.js +22 -28
- package/lib/constants/pools/aurora.d.ts +2 -4
- package/lib/constants/pools/aurora.js +6 -12
- package/lib/constants/pools/avalanche.d.ts +2 -4
- package/lib/constants/pools/avalanche.js +21 -27
- package/lib/constants/pools/celo.d.ts +2 -4
- package/lib/constants/pools/celo.js +2 -5
- package/lib/constants/pools/ethereum.js +247 -253
- package/lib/constants/pools/fantom.d.ts +2 -4
- package/lib/constants/pools/fantom.js +28 -34
- package/lib/constants/pools/index.d.ts +11 -11
- package/lib/constants/pools/index.js +12 -25
- package/lib/constants/pools/kava.d.ts +2 -4
- package/lib/constants/pools/kava.js +2 -5
- package/lib/constants/pools/moonbeam.d.ts +2 -4
- package/lib/constants/pools/moonbeam.js +6 -12
- package/lib/constants/pools/optimism.d.ts +2 -4
- package/lib/constants/pools/optimism.js +9 -15
- package/lib/constants/pools/polygon.d.ts +2 -4
- package/lib/constants/pools/polygon.js +22 -28
- package/lib/constants/pools/xdai.d.ts +2 -4
- package/lib/constants/pools/xdai.js +24 -30
- package/lib/constants/utils.js +20 -29
- package/lib/curve.d.ts +9 -7
- package/lib/curve.js +397 -615
- package/lib/external-api.d.ts +1 -1
- package/lib/external-api.js +47 -140
- package/lib/factory/common.js +6 -10
- package/lib/factory/constants-crypto.js +48 -54
- package/lib/factory/constants.js +274 -280
- package/lib/factory/deploy.d.ts +8 -8
- package/lib/factory/deploy.js +177 -347
- package/lib/factory/factory-api.js +195 -278
- package/lib/factory/factory-crypto.js +170 -323
- package/lib/factory/factory.js +195 -350
- package/lib/index.d.ts +24 -25
- package/lib/index.js +87 -143
- package/lib/interfaces.d.ts +5 -5
- package/lib/interfaces.js +1 -2
- package/lib/pools/PoolTemplate.js +1516 -2929
- package/lib/pools/index.d.ts +2 -2
- package/lib/pools/index.js +3 -7
- package/lib/pools/mixins/common.d.ts +3 -4
- package/lib/pools/mixins/common.js +23 -112
- package/lib/pools/mixins/depositBalancedAmountsMixins.d.ts +1 -1
- package/lib/pools/mixins/depositBalancedAmountsMixins.js +50 -139
- package/lib/pools/mixins/depositMixins.d.ts +1 -1
- package/lib/pools/mixins/depositMixins.js +144 -417
- package/lib/pools/mixins/depositWrappedMixins.d.ts +1 -1
- package/lib/pools/mixins/depositWrappedMixins.js +72 -227
- package/lib/pools/mixins/poolBalancesMixin.d.ts +1 -1
- package/lib/pools/mixins/poolBalancesMixin.js +25 -105
- package/lib/pools/mixins/swapMixins.d.ts +1 -1
- package/lib/pools/mixins/swapMixins.js +127 -353
- package/lib/pools/mixins/swapWrappedMixins.d.ts +1 -1
- package/lib/pools/mixins/swapWrappedMixins.js +90 -276
- package/lib/pools/mixins/withdrawExpectedMixins.d.ts +1 -1
- package/lib/pools/mixins/withdrawExpectedMixins.js +26 -110
- package/lib/pools/mixins/withdrawImbalanceMixins.d.ts +1 -1
- package/lib/pools/mixins/withdrawImbalanceMixins.js +99 -321
- package/lib/pools/mixins/withdrawImbalanceWrappedMixins.d.ts +1 -1
- package/lib/pools/mixins/withdrawImbalanceWrappedMixins.js +53 -192
- package/lib/pools/mixins/withdrawMixins.d.ts +1 -1
- package/lib/pools/mixins/withdrawMixins.js +123 -390
- package/lib/pools/mixins/withdrawOneCoinExpectedMixins.d.ts +1 -1
- package/lib/pools/mixins/withdrawOneCoinExpectedMixins.js +17 -92
- package/lib/pools/mixins/withdrawOneCoinMixins.d.ts +1 -1
- package/lib/pools/mixins/withdrawOneCoinMixins.js +124 -390
- package/lib/pools/mixins/withdrawOneCoinWrappedExpectedMixins.d.ts +1 -1
- package/lib/pools/mixins/withdrawOneCoinWrappedExpectedMixins.js +9 -66
- package/lib/pools/mixins/withdrawOneCoinWrappedMixins.d.ts +1 -1
- package/lib/pools/mixins/withdrawOneCoinWrappedMixins.js +55 -190
- package/lib/pools/mixins/withdrawWrappedMixins.d.ts +1 -1
- package/lib/pools/mixins/withdrawWrappedMixins.js +52 -191
- package/lib/pools/poolConstructor.d.ts +1 -1
- package/lib/pools/poolConstructor.js +77 -101
- package/lib/pools/utils.js +298 -500
- package/lib/router.d.ts +2 -2
- package/lib/router.js +390 -653
- package/lib/utils.d.ts +9 -9
- package/lib/utils.js +377 -731
- package/package.json +8 -8
package/lib/pools/index.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { getPool } from "./poolConstructor";
|
|
2
|
-
import { PoolTemplate } from "./PoolTemplate";
|
|
1
|
+
import { getPool } from "./poolConstructor.js";
|
|
2
|
+
import { PoolTemplate } from "./PoolTemplate.js";
|
|
3
3
|
export { getPool, PoolTemplate, };
|
package/lib/pools/index.js
CHANGED
|
@@ -1,7 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
var poolConstructor_1 = require("./poolConstructor");
|
|
5
|
-
Object.defineProperty(exports, "getPool", { enumerable: true, get: function () { return poolConstructor_1.getPool; } });
|
|
6
|
-
var PoolTemplate_1 = require("./PoolTemplate");
|
|
7
|
-
Object.defineProperty(exports, "PoolTemplate", { enumerable: true, get: function () { return PoolTemplate_1.PoolTemplate; } });
|
|
1
|
+
import { getPool } from "./poolConstructor.js";
|
|
2
|
+
import { PoolTemplate } from "./PoolTemplate.js";
|
|
3
|
+
export { getPool, PoolTemplate, };
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
export declare function
|
|
4
|
-
export declare function _calcExpectedUnderlyingAmountsMeta(this: PoolTemplate, _lpTokenAmount: ethers.BigNumber): Promise<ethers.BigNumber[]>;
|
|
1
|
+
import { PoolTemplate } from "../PoolTemplate.js";
|
|
2
|
+
export declare function _calcExpectedAmounts(this: PoolTemplate, _lpTokenAmount: bigint): Promise<bigint[]>;
|
|
3
|
+
export declare function _calcExpectedUnderlyingAmountsMeta(this: PoolTemplate, _lpTokenAmount: bigint): Promise<bigint[]>;
|
|
@@ -1,116 +1,27 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
13
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
|
-
function step(op) {
|
|
16
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
-
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
18
|
-
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;
|
|
19
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
|
-
switch (op[0]) {
|
|
21
|
-
case 0: case 1: t = op; break;
|
|
22
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
23
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
24
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
25
|
-
default:
|
|
26
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
27
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
28
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
29
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
30
|
-
if (t[2]) _.ops.pop();
|
|
31
|
-
_.trys.pop(); continue;
|
|
32
|
-
}
|
|
33
|
-
op = body.call(thisArg, _);
|
|
34
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
35
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
1
|
+
import { PoolTemplate } from "../PoolTemplate.js";
|
|
2
|
+
import { curve } from "../../curve.js";
|
|
3
|
+
import { fromBN, toBN } from "../../utils.js";
|
|
4
|
+
export async function _calcExpectedAmounts(_lpTokenAmount) {
|
|
5
|
+
const coinBalancesBN = [];
|
|
6
|
+
for (let i = 0; i < this.wrappedCoinAddresses.length; i++) {
|
|
7
|
+
const _balance = await curve.contracts[this.address].contract.balances(i, curve.constantOptions);
|
|
8
|
+
coinBalancesBN.push(toBN(_balance, this.wrappedDecimals[i]));
|
|
36
9
|
}
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
42
|
-
ar[i] = from[i];
|
|
43
|
-
}
|
|
10
|
+
const totalSupplyBN = toBN(await curve.contracts[this.lpToken].contract.totalSupply(curve.constantOptions));
|
|
11
|
+
const expectedAmountsBN = [];
|
|
12
|
+
for (const coinBalance of coinBalancesBN) {
|
|
13
|
+
expectedAmountsBN.push(coinBalance.times(toBN(_lpTokenAmount)).div(totalSupplyBN));
|
|
44
14
|
}
|
|
45
|
-
return
|
|
46
|
-
};
|
|
47
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
48
|
-
exports._calcExpectedUnderlyingAmountsMeta = exports._calcExpectedAmounts = void 0;
|
|
49
|
-
var PoolTemplate_1 = require("../PoolTemplate");
|
|
50
|
-
var curve_1 = require("../../curve");
|
|
51
|
-
var utils_1 = require("../../utils");
|
|
52
|
-
function _calcExpectedAmounts(_lpTokenAmount) {
|
|
53
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
54
|
-
var coinBalancesBN, i, _balance, totalSupplyBN, _a, expectedAmountsBN, _i, coinBalancesBN_1, coinBalance;
|
|
55
|
-
var _this = this;
|
|
56
|
-
return __generator(this, function (_b) {
|
|
57
|
-
switch (_b.label) {
|
|
58
|
-
case 0:
|
|
59
|
-
coinBalancesBN = [];
|
|
60
|
-
i = 0;
|
|
61
|
-
_b.label = 1;
|
|
62
|
-
case 1:
|
|
63
|
-
if (!(i < this.wrappedCoinAddresses.length)) return [3 /*break*/, 4];
|
|
64
|
-
return [4 /*yield*/, curve_1.curve.contracts[this.address].contract.balances(i, curve_1.curve.constantOptions)];
|
|
65
|
-
case 2:
|
|
66
|
-
_balance = _b.sent();
|
|
67
|
-
coinBalancesBN.push((0, utils_1.toBN)(_balance, this.wrappedDecimals[i]));
|
|
68
|
-
_b.label = 3;
|
|
69
|
-
case 3:
|
|
70
|
-
i++;
|
|
71
|
-
return [3 /*break*/, 1];
|
|
72
|
-
case 4:
|
|
73
|
-
_a = utils_1.toBN;
|
|
74
|
-
return [4 /*yield*/, curve_1.curve.contracts[this.lpToken].contract.totalSupply(curve_1.curve.constantOptions)];
|
|
75
|
-
case 5:
|
|
76
|
-
totalSupplyBN = _a.apply(void 0, [_b.sent()]);
|
|
77
|
-
expectedAmountsBN = [];
|
|
78
|
-
for (_i = 0, coinBalancesBN_1 = coinBalancesBN; _i < coinBalancesBN_1.length; _i++) {
|
|
79
|
-
coinBalance = coinBalancesBN_1[_i];
|
|
80
|
-
expectedAmountsBN.push(coinBalance.times((0, utils_1.toBN)(_lpTokenAmount)).div(totalSupplyBN));
|
|
81
|
-
}
|
|
82
|
-
return [2 /*return*/, expectedAmountsBN.map(function (amount, i) { return (0, utils_1.fromBN)(amount, _this.wrappedDecimals[i]); })];
|
|
83
|
-
}
|
|
84
|
-
});
|
|
85
|
-
});
|
|
15
|
+
return expectedAmountsBN.map((amount, i) => fromBN(amount, this.wrappedDecimals[i]));
|
|
86
16
|
}
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
_expectedUnderlyingAmounts = _expectedWrappedAmounts;
|
|
98
|
-
basePool = new PoolTemplate_1.PoolTemplate(this.basePool);
|
|
99
|
-
if (!basePool.isMeta) return [3 /*break*/, 3];
|
|
100
|
-
return [4 /*yield*/, _calcExpectedUnderlyingAmountsMeta.call(basePool, _expectedMetaCoinAmount)];
|
|
101
|
-
case 2:
|
|
102
|
-
_a = _b.sent();
|
|
103
|
-
return [3 /*break*/, 5];
|
|
104
|
-
case 3: return [4 /*yield*/, _calcExpectedAmounts.call(basePool, _expectedMetaCoinAmount)];
|
|
105
|
-
case 4:
|
|
106
|
-
_a = _b.sent();
|
|
107
|
-
_b.label = 5;
|
|
108
|
-
case 5:
|
|
109
|
-
_basePoolExpectedAmounts = _a;
|
|
110
|
-
_expectedUnderlyingAmounts.splice.apply(_expectedUnderlyingAmounts, __spreadArray([this.metaCoinIdx, 0], _basePoolExpectedAmounts, false));
|
|
111
|
-
return [2 /*return*/, _expectedUnderlyingAmounts];
|
|
112
|
-
}
|
|
113
|
-
});
|
|
114
|
-
});
|
|
17
|
+
export async function _calcExpectedUnderlyingAmountsMeta(_lpTokenAmount) {
|
|
18
|
+
const _expectedWrappedAmounts = await _calcExpectedAmounts.call(this, _lpTokenAmount);
|
|
19
|
+
const [_expectedMetaCoinAmount] = _expectedWrappedAmounts.splice(this.metaCoinIdx, 1);
|
|
20
|
+
const _expectedUnderlyingAmounts = _expectedWrappedAmounts;
|
|
21
|
+
const basePool = new PoolTemplate(this.basePool);
|
|
22
|
+
const _basePoolExpectedAmounts = basePool.isMeta ?
|
|
23
|
+
await _calcExpectedUnderlyingAmountsMeta.call(basePool, _expectedMetaCoinAmount) :
|
|
24
|
+
await _calcExpectedAmounts.call(basePool, _expectedMetaCoinAmount);
|
|
25
|
+
_expectedUnderlyingAmounts.splice(this.metaCoinIdx, 0, ..._basePoolExpectedAmounts);
|
|
26
|
+
return _expectedUnderlyingAmounts;
|
|
115
27
|
}
|
|
116
|
-
exports._calcExpectedUnderlyingAmountsMeta = _calcExpectedUnderlyingAmountsMeta;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { PoolTemplate } from "../PoolTemplate";
|
|
1
|
+
import { PoolTemplate } from "../PoolTemplate.js";
|
|
2
2
|
export declare const depositBalancedAmountsMixin: PoolTemplate;
|
|
3
3
|
export declare const depositBalancedAmountsCryptoMixin: PoolTemplate;
|
|
4
4
|
export declare const depositWrappedBalancedAmountsMixin: PoolTemplate;
|
|
@@ -1,155 +1,66 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
13
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
|
-
function step(op) {
|
|
16
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
-
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
18
|
-
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;
|
|
19
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
|
-
switch (op[0]) {
|
|
21
|
-
case 0: case 1: t = op; break;
|
|
22
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
23
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
24
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
25
|
-
default:
|
|
26
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
27
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
28
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
29
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
30
|
-
if (t[2]) _.ops.pop();
|
|
31
|
-
_.trys.pop(); continue;
|
|
32
|
-
}
|
|
33
|
-
op = body.call(thisArg, _);
|
|
34
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
35
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
|
-
}
|
|
37
|
-
};
|
|
38
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
39
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
40
|
-
};
|
|
41
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
42
|
-
exports.depositWrappedBalancedAmountsCryptoMixin = exports.depositWrappedBalancedAmountsMixin = exports.depositBalancedAmountsCryptoMixin = exports.depositBalancedAmountsMixin = void 0;
|
|
43
|
-
var bignumber_js_1 = __importDefault(require("bignumber.js"));
|
|
44
|
-
var utils_1 = require("../../utils");
|
|
1
|
+
import BigNumber from 'bignumber.js';
|
|
2
|
+
import { BN } from "../../utils.js";
|
|
45
3
|
function _depositBalancedAmounts(poolBalances, walletBalances, decimals) {
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
4
|
+
const poolBalancesBN = poolBalances.map(BN);
|
|
5
|
+
const walletBalancesBN = walletBalances.map(BN);
|
|
6
|
+
const poolTotalLiquidityBN = poolBalancesBN.reduce((a, b) => a.plus(b));
|
|
7
|
+
const poolBalancesRatiosBN = poolBalancesBN.map((b) => b.div(poolTotalLiquidityBN));
|
|
50
8
|
// Cross factors for each wallet balance used as reference to see the
|
|
51
9
|
// max that can be used according to the lowest relative wallet balance
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
});
|
|
57
|
-
var scenarioWithLowestBalancesBN = firstCoinBalanceForEachScenarioBN.map(String).indexOf(bignumber_js_1.default.min.apply(bignumber_js_1.default, firstCoinBalanceForEachScenarioBN).toString());
|
|
58
|
-
return balancedAmountsForEachScenarioBN[scenarioWithLowestBalancesBN].map(function (a, i) { return a.toFixed(decimals[i]); });
|
|
10
|
+
const balancedAmountsForEachScenarioBN = walletBalancesBN.map((_, i) => (walletBalancesBN.map((_, j) => (poolBalancesRatiosBN[j].times(walletBalancesBN[i]).div(poolBalancesRatiosBN[i])))));
|
|
11
|
+
const firstCoinBalanceForEachScenarioBN = balancedAmountsForEachScenarioBN.map(([a]) => a);
|
|
12
|
+
const scenarioWithLowestBalancesBN = firstCoinBalanceForEachScenarioBN.map(String).indexOf(BigNumber.min(...firstCoinBalanceForEachScenarioBN).toString());
|
|
13
|
+
return balancedAmountsForEachScenarioBN[scenarioWithLowestBalancesBN].map((a, i) => a.toFixed(decimals[i]));
|
|
59
14
|
}
|
|
60
15
|
// @ts-ignore
|
|
61
|
-
|
|
62
|
-
depositBalancedAmounts
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
poolBalances = _c.sent();
|
|
70
|
-
_b = (_a = Object).values;
|
|
71
|
-
return [4 /*yield*/, this.walletUnderlyingCoinBalances()];
|
|
72
|
-
case 2:
|
|
73
|
-
walletBalances = _b.apply(_a, [_c.sent()]);
|
|
74
|
-
balancedAmountsBN = (_depositBalancedAmounts(poolBalances, walletBalances, this.underlyingDecimals));
|
|
75
|
-
return [2 /*return*/, balancedAmountsBN.map(function (b, i) { return bignumber_js_1.default.min((0, utils_1.BN)(b), (0, utils_1.BN)(walletBalances[i])).toString(); })];
|
|
76
|
-
}
|
|
77
|
-
});
|
|
78
|
-
});
|
|
16
|
+
export const depositBalancedAmountsMixin = {
|
|
17
|
+
async depositBalancedAmounts() {
|
|
18
|
+
// @ts-ignore
|
|
19
|
+
const poolBalances = await this.stats.underlyingBalances();
|
|
20
|
+
// @ts-ignore
|
|
21
|
+
const walletBalances = Object.values(await this.walletUnderlyingCoinBalances());
|
|
22
|
+
const balancedAmountsBN = (_depositBalancedAmounts(poolBalances, walletBalances, this.underlyingDecimals));
|
|
23
|
+
return balancedAmountsBN.map((b, i) => BigNumber.min(BN(b), BN(walletBalances[i])).toString());
|
|
79
24
|
},
|
|
80
25
|
};
|
|
81
26
|
// @ts-ignore
|
|
82
|
-
|
|
83
|
-
depositBalancedAmounts
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
case 2:
|
|
95
|
-
walletBalances = _b.apply(_a, [_c.sent()]);
|
|
96
|
-
return [4 /*yield*/, this._underlyingPrices()];
|
|
97
|
-
case 3:
|
|
98
|
-
prices = _c.sent();
|
|
99
|
-
poolBalancesUSD = poolBalances.map(function (b, i) { return (0, utils_1.BN)(b).times(prices[i]).toString(); });
|
|
100
|
-
walletBalancesUSD = walletBalances.map(function (b, i) { return (0, utils_1.BN)(b).times(prices[i]).toString(); });
|
|
101
|
-
balancedAmountsUSD = _depositBalancedAmounts(poolBalancesUSD, walletBalancesUSD, this.underlyingDecimals);
|
|
102
|
-
return [2 /*return*/, balancedAmountsUSD.map(function (b, i) { return bignumber_js_1.default.min((0, utils_1.BN)((0, utils_1.BN)(b).div(prices[i]).toFixed(_this.underlyingDecimals[i])), (0, utils_1.BN)(walletBalances[i])).toString(); })];
|
|
103
|
-
}
|
|
104
|
-
});
|
|
105
|
-
});
|
|
27
|
+
export const depositBalancedAmountsCryptoMixin = {
|
|
28
|
+
async depositBalancedAmounts() {
|
|
29
|
+
// @ts-ignore
|
|
30
|
+
const poolBalances = await this.stats.underlyingBalances();
|
|
31
|
+
// @ts-ignore
|
|
32
|
+
const walletBalances = Object.values(await this.walletUnderlyingCoinBalances());
|
|
33
|
+
// @ts-ignore
|
|
34
|
+
const prices = await this._underlyingPrices();
|
|
35
|
+
const poolBalancesUSD = poolBalances.map((b, i) => BN(b).times(prices[i]).toString());
|
|
36
|
+
const walletBalancesUSD = walletBalances.map((b, i) => BN(b).times(prices[i]).toString());
|
|
37
|
+
const balancedAmountsUSD = _depositBalancedAmounts(poolBalancesUSD, walletBalancesUSD, this.underlyingDecimals);
|
|
38
|
+
return balancedAmountsUSD.map((b, i) => BigNumber.min(BN(BN(b).div(prices[i]).toFixed(this.underlyingDecimals[i])), BN(walletBalances[i])).toString());
|
|
106
39
|
},
|
|
107
40
|
};
|
|
108
41
|
// @ts-ignore
|
|
109
|
-
|
|
110
|
-
depositWrappedBalancedAmounts
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
poolBalances = _c.sent();
|
|
118
|
-
_b = (_a = Object).values;
|
|
119
|
-
return [4 /*yield*/, this.walletWrappedCoinBalances()];
|
|
120
|
-
case 2:
|
|
121
|
-
walletBalances = _b.apply(_a, [_c.sent()]);
|
|
122
|
-
balancedAmountsBN = (_depositBalancedAmounts(poolBalances, walletBalances, this.underlyingDecimals));
|
|
123
|
-
return [2 /*return*/, balancedAmountsBN.map(function (b, i) { return bignumber_js_1.default.min((0, utils_1.BN)(b), (0, utils_1.BN)(walletBalances[i])).toString(); })];
|
|
124
|
-
}
|
|
125
|
-
});
|
|
126
|
-
});
|
|
42
|
+
export const depositWrappedBalancedAmountsMixin = {
|
|
43
|
+
async depositWrappedBalancedAmounts() {
|
|
44
|
+
// @ts-ignore
|
|
45
|
+
const poolBalances = await this.stats.wrappedBalances();
|
|
46
|
+
// @ts-ignore
|
|
47
|
+
const walletBalances = Object.values(await this.walletWrappedCoinBalances());
|
|
48
|
+
const balancedAmountsBN = (_depositBalancedAmounts(poolBalances, walletBalances, this.underlyingDecimals));
|
|
49
|
+
return balancedAmountsBN.map((b, i) => BigNumber.min(BN(b), BN(walletBalances[i])).toString());
|
|
127
50
|
},
|
|
128
51
|
};
|
|
129
52
|
// @ts-ignore
|
|
130
|
-
|
|
131
|
-
depositWrappedBalancedAmounts
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
case 2:
|
|
143
|
-
walletBalances = _b.apply(_a, [_c.sent()]).map(Number);
|
|
144
|
-
return [4 /*yield*/, this._wrappedPrices()];
|
|
145
|
-
case 3:
|
|
146
|
-
prices = _c.sent();
|
|
147
|
-
poolBalancesUSD = poolBalances.map(function (b, i) { return (0, utils_1.BN)(b).times(prices[i]).toString(); });
|
|
148
|
-
walletBalancesUSD = walletBalances.map(function (b, i) { return (0, utils_1.BN)(b).times(prices[i]).toString(); });
|
|
149
|
-
balancedAmountsUSD = _depositBalancedAmounts(poolBalancesUSD, walletBalancesUSD, this.wrappedDecimals);
|
|
150
|
-
return [2 /*return*/, balancedAmountsUSD.map(function (b, i) { return bignumber_js_1.default.min((0, utils_1.BN)((0, utils_1.BN)(b).div(prices[i]).toFixed(_this.wrappedDecimals[i])), (0, utils_1.BN)(walletBalances[i])).toString(); })];
|
|
151
|
-
}
|
|
152
|
-
});
|
|
153
|
-
});
|
|
53
|
+
export const depositWrappedBalancedAmountsCryptoMixin = {
|
|
54
|
+
async depositWrappedBalancedAmounts() {
|
|
55
|
+
// @ts-ignore
|
|
56
|
+
const poolBalances = (await this.stats.wrappedBalances()).map(Number);
|
|
57
|
+
// @ts-ignore
|
|
58
|
+
const walletBalances = Object.values(await this.walletWrappedCoinBalances()).map(Number);
|
|
59
|
+
// @ts-ignore
|
|
60
|
+
const prices = await this._wrappedPrices();
|
|
61
|
+
const poolBalancesUSD = poolBalances.map((b, i) => BN(b).times(prices[i]).toString());
|
|
62
|
+
const walletBalancesUSD = walletBalances.map((b, i) => BN(b).times(prices[i]).toString());
|
|
63
|
+
const balancedAmountsUSD = _depositBalancedAmounts(poolBalancesUSD, walletBalancesUSD, this.wrappedDecimals);
|
|
64
|
+
return balancedAmountsUSD.map((b, i) => BigNumber.min(BN(BN(b).div(prices[i]).toFixed(this.wrappedDecimals[i])), BN(walletBalances[i])).toString());
|
|
154
65
|
},
|
|
155
66
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { PoolTemplate } from "../PoolTemplate";
|
|
1
|
+
import { PoolTemplate } from "../PoolTemplate.js";
|
|
2
2
|
export declare const depositMetaFactoryMixin: PoolTemplate;
|
|
3
3
|
export declare const depositCryptoMetaFactoryMixin: PoolTemplate;
|
|
4
4
|
export declare const depositZapMixin: PoolTemplate;
|