@reserve-protocol/dtf-rebalance-lib 3.2.0 → 3.2.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.
|
@@ -24,12 +24,13 @@ const getOpenAuction = (rebalance, _supply, _initialSupply, _initialAssets = [],
|
|
|
24
24
|
if (debug) {
|
|
25
25
|
console.log("getOpenAuction", rebalance, _supply, _initialSupply, _initialAssets, _targetBasket, _assets, _decimals, _prices, _priceError, _finalStageAt);
|
|
26
26
|
}
|
|
27
|
-
if (rebalance.tokens.length !=
|
|
27
|
+
if (rebalance.tokens.length != _initialAssets.length ||
|
|
28
|
+
_initialAssets.length != _targetBasket.length ||
|
|
28
29
|
_targetBasket.length != _assets.length ||
|
|
29
30
|
_assets.length != _decimals.length ||
|
|
30
31
|
_decimals.length != _prices.length ||
|
|
31
32
|
_prices.length != _priceError.length) {
|
|
32
|
-
throw new Error("length mismatch");
|
|
33
|
+
throw new Error("getOpenAuction: length mismatch");
|
|
33
34
|
}
|
|
34
35
|
if (_finalStageAt > 1) {
|
|
35
36
|
throw new Error("finalStageAt must be less than 1");
|
|
@@ -23,6 +23,13 @@ const getStartRebalance = (_supply, tokens, _assets, decimals, _targetBasket, _p
|
|
|
23
23
|
if (debug) {
|
|
24
24
|
console.log("getStartRebalance", _supply, tokens, _assets, decimals, _targetBasket, _prices, _priceError, weightControl, deferWeights);
|
|
25
25
|
}
|
|
26
|
+
if (tokens.length != _assets.length ||
|
|
27
|
+
_assets.length != decimals.length ||
|
|
28
|
+
decimals.length != _targetBasket.length ||
|
|
29
|
+
_targetBasket.length != _prices.length ||
|
|
30
|
+
_prices.length != _priceError.length) {
|
|
31
|
+
throw new Error("getStartRebalance: length mismatch");
|
|
32
|
+
}
|
|
26
33
|
if (deferWeights && !weightControl) {
|
|
27
34
|
throw new Error("deferWeights is not supported for tracking DTFs");
|
|
28
35
|
}
|
|
@@ -24,12 +24,13 @@ const getOpenAuction = (rebalance, _supply, _initialSupply, _initialAssets = [],
|
|
|
24
24
|
if (debug) {
|
|
25
25
|
console.log("getOpenAuction", rebalance, _supply, _initialSupply, _initialAssets, _targetBasket, _assets, _decimals, _prices, _priceError, _finalStageAt);
|
|
26
26
|
}
|
|
27
|
-
if (rebalance.tokens.length !=
|
|
27
|
+
if (rebalance.tokens.length != _initialAssets.length ||
|
|
28
|
+
_initialAssets.length != _targetBasket.length ||
|
|
28
29
|
_targetBasket.length != _assets.length ||
|
|
29
30
|
_assets.length != _decimals.length ||
|
|
30
31
|
_decimals.length != _prices.length ||
|
|
31
32
|
_prices.length != _priceError.length) {
|
|
32
|
-
throw new Error("length mismatch");
|
|
33
|
+
throw new Error("getOpenAuction: length mismatch");
|
|
33
34
|
}
|
|
34
35
|
if (_finalStageAt > 1) {
|
|
35
36
|
throw new Error("finalStageAt must be less than 1");
|
|
@@ -24,6 +24,14 @@ const getStartRebalance = (_supply, tokens, _assets, decimals, _targetBasket, _p
|
|
|
24
24
|
if (debug) {
|
|
25
25
|
console.log("getStartRebalance", _supply, tokens, _assets, decimals, _targetBasket, _prices, _priceError, _maxAuctionSizes, weightControl, deferWeights);
|
|
26
26
|
}
|
|
27
|
+
if (tokens.length != _assets.length ||
|
|
28
|
+
_assets.length != decimals.length ||
|
|
29
|
+
decimals.length != _targetBasket.length ||
|
|
30
|
+
_targetBasket.length != _prices.length ||
|
|
31
|
+
_prices.length != _priceError.length ||
|
|
32
|
+
_priceError.length != _maxAuctionSizes.length) {
|
|
33
|
+
throw new Error("getStartRebalance: length mismatch");
|
|
34
|
+
}
|
|
27
35
|
if (deferWeights && !weightControl) {
|
|
28
36
|
throw new Error("deferWeights is not supported for tracking DTFs");
|
|
29
37
|
}
|
package/dist/utils.js
CHANGED
|
@@ -18,6 +18,9 @@ exports.Decimal = decimal_js_light_1.default.clone({ precision: 100 });
|
|
|
18
18
|
* @returns D18{1} Current basket, total will be around 1e18 but not exactly
|
|
19
19
|
*/
|
|
20
20
|
const getBasketDistribution = (_bals, _prices, decimals) => {
|
|
21
|
+
if (_bals.length !== _prices.length || _bals.length !== decimals.length) {
|
|
22
|
+
throw new Error("getBasketDistribution: length mismatch");
|
|
23
|
+
}
|
|
21
24
|
const decimalScale = decimals.map((d) => new exports.Decimal(`1e${d}`));
|
|
22
25
|
// {wholeTok} = {tok} / {tok/wholeTok}
|
|
23
26
|
const bals = _bals.map((bal, i) => new exports.Decimal(bal.toString()).div(decimalScale[i]));
|
|
@@ -39,6 +42,9 @@ exports.getBasketDistribution = getBasketDistribution;
|
|
|
39
42
|
* @returns {1} Basket accuracy
|
|
40
43
|
*/
|
|
41
44
|
const getBasketAccuracy = (_bals, _prices, _decimals, _weights) => {
|
|
45
|
+
if (_bals.length !== _prices.length || _bals.length !== _decimals.length || _bals.length !== _weights.length) {
|
|
46
|
+
throw new Error("getBasketAccuracy: length mismatch");
|
|
47
|
+
}
|
|
42
48
|
const decimalScale = _decimals.map((d) => new exports.Decimal(`1e${d}`));
|
|
43
49
|
// {USD/wholeTok} = {USD/wholeTok}
|
|
44
50
|
const prices = _prices.map((a) => new exports.Decimal(a.toString()));
|