@reserve-protocol/dtf-rebalance-lib 0.0.7 → 0.0.9

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.
@@ -179,7 +179,10 @@ const getOpenAuction = (rebalance, _supply, _initialFolio = [], _targetBasket =
179
179
  else if (relativeProgression.lt(finalStageAt.sub(0.02))) {
180
180
  // wiggle room to prevent having to re-run an auction at the same stage after price movement
181
181
  round = AuctionRound.PROGRESS;
182
- rebalanceTarget = finalStageAt;
182
+ rebalanceTarget = initialProgression.add(numbers_1.ONE.sub(initialProgression).mul(finalStageAt));
183
+ if (rebalanceTarget.gte(numbers_1.ONE)) {
184
+ round = AuctionRound.FINAL;
185
+ }
183
186
  }
184
187
  // {1}
185
188
  const delta = numbers_1.ONE.sub(rebalanceTarget);
@@ -294,7 +297,7 @@ const getOpenAuction = (rebalance, _supply, _initialFolio = [], _targetBasket =
294
297
  if (pricesD27.high > initialPrice.high) {
295
298
  pricesD27.high = initialPrice.high;
296
299
  }
297
- if (pricesD27.low == pricesD27.high) {
300
+ if (pricesD27.low == pricesD27.high && priceError[i].gt(numbers_1.ZERO)) {
298
301
  throw new Error('no price range');
299
302
  }
300
303
  return pricesD27;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@reserve-protocol/dtf-rebalance-lib",
3
- "version": "0.0.7",
3
+ "version": "0.0.9",
4
4
  "description": "Rebalancing library for DTFs in typescript",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.js",
@@ -274,7 +274,10 @@ export const getOpenAuction = (
274
274
  // wiggle room to prevent having to re-run an auction at the same stage after price movement
275
275
  round = AuctionRound.PROGRESS
276
276
 
277
- rebalanceTarget = finalStageAt
277
+ rebalanceTarget = initialProgression.add(ONE.sub(initialProgression).mul(finalStageAt))
278
+ if (rebalanceTarget.gte(ONE)) {
279
+ round = AuctionRound.FINAL
280
+ }
278
281
  }
279
282
 
280
283
  // {1}
@@ -422,7 +425,7 @@ export const getOpenAuction = (
422
425
  pricesD27.high = initialPrice.high
423
426
  }
424
427
 
425
- if (pricesD27.low == pricesD27.high) {
428
+ if (pricesD27.low == pricesD27.high && priceError[i].gt(ZERO)) {
426
429
  throw new Error('no price range')
427
430
  }
428
431