@reserve-protocol/dtf-rebalance-lib 0.0.15 → 0.0.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.
@@ -186,8 +186,8 @@ const getOpenAuction = (rebalance, _supply, _initialFolio = [], _targetBasket =
186
186
  if (portionBeingEjected.gte(1e-4)) {
187
187
  round = AuctionRound.EJECT;
188
188
  rebalanceTarget = progression.add(portionBeingEjected.mul(1.2)); // set rebalanceTarget to 20% more than needed to ensure ejection completes
189
- if (rebalanceTarget.gt(numbers_1.ONE)) {
190
- rebalanceTarget = numbers_1.ONE;
189
+ if (rebalanceTarget.gte(numbers_1.ONE)) {
190
+ rebalanceTarget = initialProgression.add(numbers_1.ONE.sub(initialProgression).mul(finalStageAt));
191
191
  }
192
192
  }
193
193
  else if (relativeProgression.lt(finalStageAt.sub(0.02))) {
@@ -198,6 +198,12 @@ const getOpenAuction = (rebalance, _supply, _initialFolio = [], _targetBasket =
198
198
  throw new Error('something has gone very wrong');
199
199
  }
200
200
  }
201
+ if (rebalanceTarget.lt(progression)) {
202
+ rebalanceTarget = numbers_1.ONE;
203
+ }
204
+ else if (rebalanceTarget.eq(numbers_1.ONE)) {
205
+ round = AuctionRound.FINAL;
206
+ }
201
207
  if (logging) {
202
208
  console.log('rebalanceTarget', rebalanceTarget.toString());
203
209
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@reserve-protocol/dtf-rebalance-lib",
3
- "version": "0.0.15",
3
+ "version": "0.0.16",
4
4
  "description": "Rebalancing library for DTFs in typescript",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.js",
@@ -281,21 +281,27 @@ export const getOpenAuction = (
281
281
  // make it an eject auction if there is 1 bps or more of value to eject
282
282
  if (portionBeingEjected.gte(1e-4)) {
283
283
  round = AuctionRound.EJECT
284
-
284
+
285
285
  rebalanceTarget = progression.add(portionBeingEjected.mul(1.2)) // set rebalanceTarget to 20% more than needed to ensure ejection completes
286
- if (rebalanceTarget.gt(ONE)) {
287
- rebalanceTarget = ONE
288
- }
286
+ if (rebalanceTarget.gte(ONE)) {
287
+ rebalanceTarget = initialProgression.add(ONE.sub(initialProgression).mul(finalStageAt))
288
+ }
289
289
  } else if (relativeProgression.lt(finalStageAt.sub(0.02))) {
290
- // wiggle room to prevent having to re-run an auction at the same stage after price movement
291
- round = AuctionRound.PROGRESS
292
-
293
- rebalanceTarget = initialProgression.add(ONE.sub(initialProgression).mul(finalStageAt))
294
- if (rebalanceTarget.gt(ONE)) {
295
- throw new Error('something has gone very wrong')
296
- }
290
+ // wiggle room to prevent having to re-run an auction at the same stage after price movement
291
+ round = AuctionRound.PROGRESS
292
+
293
+ rebalanceTarget = initialProgression.add(ONE.sub(initialProgression).mul(finalStageAt))
294
+ if (rebalanceTarget.gt(ONE)) {
295
+ throw new Error('something has gone very wrong')
296
+ }
297
297
  }
298
298
 
299
+ if (rebalanceTarget.lt(progression)) {
300
+ rebalanceTarget = ONE
301
+ } else if (rebalanceTarget.eq(ONE)) {
302
+ round = AuctionRound.FINAL
303
+ }
304
+
299
305
  if (logging) {
300
306
  console.log('rebalanceTarget', rebalanceTarget.toString())
301
307
  }