@reserve-protocol/dtf-rebalance-lib 2.6.0 → 2.6.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/dist/open-auction.js +18 -10
- package/package.json +1 -1
package/dist/open-auction.js
CHANGED
|
@@ -161,28 +161,30 @@ const getOpenAuction = (rebalance, _supply, _initialSupply, _initialAssets = [],
|
|
|
161
161
|
// {1} = {USD/wholeShare} / {USD/wholeShare}
|
|
162
162
|
const progression = folio
|
|
163
163
|
.map((actualBalance, i) => {
|
|
164
|
-
if (!rebalance.inRebalance[i]
|
|
165
|
-
return numbers_1.
|
|
164
|
+
if (!rebalance.inRebalance[i]) {
|
|
165
|
+
return numbers_1.ZERO;
|
|
166
166
|
}
|
|
167
167
|
// {wholeTok/wholeShare}
|
|
168
168
|
const balanceInBasket = expectedBalances[i].gt(actualBalance) ? actualBalance : expectedBalances[i];
|
|
169
|
-
// {
|
|
170
|
-
return balanceInBasket.
|
|
169
|
+
// {USD/wholeShare} = {wholeTok/wholeShare} * {USD/wholeTok}
|
|
170
|
+
return balanceInBasket.mul(prices[i]);
|
|
171
171
|
})
|
|
172
|
-
.reduce((a, b) =>
|
|
172
|
+
.reduce((a, b) => a.add(b))
|
|
173
|
+
.div(shareValue);
|
|
173
174
|
// absolute
|
|
174
175
|
// {1} = {USD/wholeShare} / {USD/wholeShare}
|
|
175
176
|
let initialProgression = initialFolio
|
|
176
177
|
.map((initialBalance, i) => {
|
|
177
|
-
if (!rebalance.inRebalance[i]
|
|
178
|
-
return numbers_1.
|
|
178
|
+
if (!rebalance.inRebalance[i]) {
|
|
179
|
+
return numbers_1.ZERO;
|
|
179
180
|
}
|
|
180
181
|
// {wholeTok/wholeShare}
|
|
181
182
|
const balanceInBasket = expectedBalances[i].gt(initialBalance) ? initialBalance : expectedBalances[i];
|
|
182
|
-
// {
|
|
183
|
-
return balanceInBasket.
|
|
183
|
+
// {USD/wholeShare} = {wholeTok/wholeShare} * {USD/wholeTok}
|
|
184
|
+
return balanceInBasket.mul(prices[i]);
|
|
184
185
|
})
|
|
185
|
-
.reduce((a, b) =>
|
|
186
|
+
.reduce((a, b) => a.add(b))
|
|
187
|
+
.div(shareValue);
|
|
186
188
|
if (progression < initialProgression) {
|
|
187
189
|
if (debug) {
|
|
188
190
|
console.log("progression < initialProgression", progression.toString(), initialProgression.toString());
|
|
@@ -396,6 +398,12 @@ const getOpenAuction = (rebalance, _supply, _initialSupply, _initialAssets = [],
|
|
|
396
398
|
const surplusSize = surplusTokenSizes.reduce((a, b) => a + b, 0);
|
|
397
399
|
const deficitSize = deficitTokenSizes.reduce((a, b) => a + b, 0);
|
|
398
400
|
const auctionSize = surplusSize > deficitSize ? deficitSize : surplusSize;
|
|
401
|
+
// update targeting estimates
|
|
402
|
+
// {1} = {1} + {USD} / ({share} * {USD/share})
|
|
403
|
+
const adjustedTarget = progression.add(new utils_1.Decimal(auctionSize).div(shareValue.mul(supply)));
|
|
404
|
+
if (adjustedTarget.lte(numbers_1.ONE)) {
|
|
405
|
+
target = adjustedTarget;
|
|
406
|
+
}
|
|
399
407
|
const relativeTarget = target.sub(initialProgression).div(numbers_1.ONE.sub(initialProgression));
|
|
400
408
|
return [
|
|
401
409
|
{
|