@reserve-protocol/dtf-rebalance-lib 0.2.11 → 0.2.13
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/dist/open-auction.js +6 -3
- package/package.json +1 -1
package/dist/open-auction.js
CHANGED
@@ -27,6 +27,9 @@ const getTargetBasket = (_initialWeights, _prices, _decimals) => {
|
|
27
27
|
throw new Error("length mismatch");
|
28
28
|
}
|
29
29
|
const vals = _initialWeights.map((initialWeight, i) => {
|
30
|
+
if (_prices[i] <= 0) {
|
31
|
+
throw new Error(`missing price for token index ${i}`);
|
32
|
+
}
|
30
33
|
const price = new utils_1.Decimal(_prices[i]);
|
31
34
|
const decimalScale = new utils_1.Decimal(`1e${_decimals[i]}`);
|
32
35
|
// {USD/wholeBU} = D27{tok/BU} * {BU/wholeBU} / {tok/wholeTok} / D27 * {USD/wholeTok}
|
@@ -77,7 +80,7 @@ const getOpenAuction = (rebalance, _supply, _initialFolio = [], _targetBasket =
|
|
77
80
|
// {USD/wholeTok}
|
78
81
|
const prices = _prices.map((a) => new utils_1.Decimal(a));
|
79
82
|
for (let i = 0; i < prices.length; i++) {
|
80
|
-
if (prices[i].
|
83
|
+
if (prices[i].lte(numbers_1.ZERO)) {
|
81
84
|
throw new Error(`missing price for token ${rebalance.tokens[i]}`);
|
82
85
|
}
|
83
86
|
}
|
@@ -198,7 +201,7 @@ const getOpenAuction = (rebalance, _supply, _initialFolio = [], _targetBasket =
|
|
198
201
|
if (progression.lt(0.99) && relativeProgression.lt(finalStageAt.sub(0.02))) {
|
199
202
|
round = AuctionRound.PROGRESS;
|
200
203
|
rebalanceTarget = initialProgression.add(numbers_1.ONE.sub(initialProgression).mul(finalStageAt));
|
201
|
-
if (rebalanceTarget.gte(0.
|
204
|
+
if (rebalanceTarget.gte(0.999)) {
|
202
205
|
rebalanceTarget = numbers_1.ONE;
|
203
206
|
}
|
204
207
|
if (rebalanceTarget.eq(numbers_1.ONE)) {
|
@@ -393,7 +396,7 @@ const getOpenAuction = (rebalance, _supply, _initialFolio = [], _targetBasket =
|
|
393
396
|
}
|
394
397
|
else if (folio[i].gt(sellDownTo)) {
|
395
398
|
// {USD} = {wholeTok/wholeShare} * {USD/wholeTok} * {wholeShare}
|
396
|
-
const tokenSurplusValue =
|
399
|
+
const tokenSurplusValue = folio[i].sub(sellDownTo).mul(prices[i]).mul(supply);
|
397
400
|
// $1 minimum
|
398
401
|
if (tokenSurplusValue.gte(numbers_1.ONE)) {
|
399
402
|
surplusValue = surplusValue.add(tokenSurplusValue);
|