@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.
@@ -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] || expectedBalances[i].eq(numbers_1.ZERO)) {
165
- return numbers_1.ONE;
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
- // {1} = {wholeTok/wholeShare} / {wholeTok/wholeShare}
170
- return balanceInBasket.div(expectedBalances[i]);
169
+ // {USD/wholeShare} = {wholeTok/wholeShare} * {USD/wholeTok}
170
+ return balanceInBasket.mul(prices[i]);
171
171
  })
172
- .reduce((a, b) => (a.lt(b) ? 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] || expectedBalances[i].eq(numbers_1.ZERO)) {
178
- return numbers_1.ONE;
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
- // {1} = {wholeTok/wholeShare} / {wholeTok/wholeShare}
183
- return balanceInBasket.div(expectedBalances[i]);
183
+ // {USD/wholeShare} = {wholeTok/wholeShare} * {USD/wholeTok}
184
+ return balanceInBasket.mul(prices[i]);
184
185
  })
185
- .reduce((a, b) => (a.lt(b) ? 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
  {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@reserve-protocol/dtf-rebalance-lib",
3
- "version": "2.6.0",
3
+ "version": "2.6.1",
4
4
  "description": "Rebalancing library for DTFs in typescript",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.js",