@reserve-protocol/dtf-rebalance-lib 0.2.14 → 0.2.16

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.
@@ -23,6 +23,7 @@ var AuctionRound;
23
23
  * @returns D18{1} The target basket
24
24
  */
25
25
  const getTargetBasket = (_initialWeights, _prices, _decimals) => {
26
+ console.log("getTargetBasket", _initialWeights, _prices, _decimals);
26
27
  if (_initialWeights.length != _prices.length) {
27
28
  throw new Error("length mismatch");
28
29
  }
@@ -149,7 +150,7 @@ const getOpenAuction = (rebalance, _supply, _initialFolio = [], _targetBasket =
149
150
  // calculate progressions
150
151
  // {wholeBU/wholeShare} = D18{BU/share} / D18
151
152
  const prevSpotLimit = new utils_1.Decimal(rebalance.limits.spot.toString()).div(numbers_1.D18d);
152
- // {wholeTok/wholeBU} = {wholeTok/wholeBU} * {wholeBU/wholeShare}
153
+ // {wholeTok/wholeShare} = {wholeTok/wholeBU} * {wholeBU/wholeShare}
153
154
  const expectedBalances = weightRanges.map((weightRange) => weightRange.spot.mul(prevSpotLimit));
154
155
  // {1} = {USD/wholeShare} / {USD/wholeShare}
155
156
  let progression = folio
@@ -86,7 +86,8 @@ const getStartRebalance = (_supply, tokens, _folio, decimals, _targetBasket, _pr
86
86
  const priceMultiplier = numbers_1.D27d.div(new utils_1.Decimal(`1e${decimals[i]}`));
87
87
  // {USD/wholeTok} = {USD/wholeTok} * {1}
88
88
  const lowPrice = prices[i].mul(numbers_1.ONE.sub(priceError[i]));
89
- const highPrice = prices[i].mul(numbers_1.ONE.add(priceError[i]));
89
+ // {USD/wholeTok} = {USD/wholeTok} / {1}
90
+ const highPrice = prices[i].div(numbers_1.ONE.sub(priceError[i]));
90
91
  // D27{USD/tok} = {USD/wholeTok} * D27{wholeTok/tok}
91
92
  newPrices.push({
92
93
  low: (0, numbers_1.bn)(lowPrice.mul(priceMultiplier)),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@reserve-protocol/dtf-rebalance-lib",
3
- "version": "0.2.14",
3
+ "version": "0.2.16",
4
4
  "description": "Rebalancing library for DTFs in typescript",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.js",