@reserve-protocol/dtf-rebalance-lib 0.2.10 → 0.2.12

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.
@@ -176,6 +176,9 @@ const getOpenAuction = (rebalance, _supply, _initialFolio = [], _targetBasket =
176
176
  .reduce((a, b) => a.add(b))
177
177
  .div(shareValue);
178
178
  if (progression < initialProgression) {
179
+ if (debug) {
180
+ console.log("progression < initialProgression", progression.toString(), initialProgression.toString());
181
+ }
179
182
  progression = initialProgression; // don't go backwards
180
183
  }
181
184
  // {1} = {1} / {1}
@@ -381,16 +384,16 @@ const getOpenAuction = (rebalance, _supply, _initialFolio = [], _targetBasket =
381
384
  const sellDownTo = weightRanges[i].high.mul(actualLimits.high);
382
385
  if (folio[i].lt(buyUpTo)) {
383
386
  // {USD} = {wholeTok/wholeShare} * {USD/wholeTok} * {wholeShare}
384
- const tokenDeficitValue = deficitValue.add(buyUpTo.sub(folio[i]).mul(prices[i]).mul(supply));
387
+ const tokenDeficitValue = buyUpTo.sub(folio[i]).mul(prices[i]).mul(supply);
385
388
  // $1 minimum
386
389
  if (tokenDeficitValue.gte(numbers_1.ONE)) {
387
- deficitValue = tokenDeficitValue;
390
+ deficitValue = deficitValue.add(tokenDeficitValue);
388
391
  deficitTokens.push(token);
389
392
  }
390
393
  }
391
394
  else if (folio[i].gt(sellDownTo)) {
392
395
  // {USD} = {wholeTok/wholeShare} * {USD/wholeTok} * {wholeShare}
393
- const tokenSurplusValue = sellDownTo.sub(folio[i]).mul(prices[i]).mul(supply);
396
+ const tokenSurplusValue = folio[i].sub(sellDownTo).mul(prices[i]).mul(supply);
394
397
  // $1 minimum
395
398
  if (tokenSurplusValue.gte(numbers_1.ONE)) {
396
399
  surplusValue = surplusValue.add(tokenSurplusValue);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@reserve-protocol/dtf-rebalance-lib",
3
- "version": "0.2.10",
3
+ "version": "0.2.12",
4
4
  "description": "Rebalancing library for DTFs in typescript",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.js",