@reserve-protocol/dtf-rebalance-lib 0.1.5 → 0.1.7

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.
@@ -11,6 +11,7 @@ export declare enum AuctionRound {
11
11
  * @param absoluteProgression {1} The progression of the auction on an absolute scale
12
12
  * @param relativeProgression {1} The relative progression of the auction
13
13
  * @param target {1} The target of the auction on an absolute scale
14
+ * @param relativeTarget {1} The relative target of the auction
14
15
  * @param auctionSize {USD} The total value on sale in the auction
15
16
  * @param surplusTokens The list of tokens in surplus
16
17
  * @param deficitTokens The list of tokens in deficit
@@ -21,6 +22,7 @@ export interface AuctionMetrics {
21
22
  absoluteProgression: number;
22
23
  relativeProgression: number;
23
24
  target: number;
25
+ relativeTarget: number;
24
26
  auctionSize: number;
25
27
  surplusTokens: string[];
26
28
  deficitTokens: string[];
@@ -103,7 +103,7 @@ const getOpenAuction = (rebalance, _supply, _initialFolio = [], _targetBasket =
103
103
  // {USD/wholeShare} = {wholeTok/wholeShare} * {USD/wholeTok}
104
104
  const shareValue = folio
105
105
  .map((f, i) => {
106
- return rebalance.inRebalance[i] ? f.mul(prices[i]) : numbers_1.ZERO;
106
+ return f.mul(prices[i]);
107
107
  })
108
108
  .reduce((a, b) => a.add(b));
109
109
  // {USD/wholeBU} = {wholeTok/wholeBU} * {USD/wholeTok}
@@ -128,7 +128,7 @@ const getOpenAuction = (rebalance, _supply, _initialFolio = [], _targetBasket =
128
128
  // {1} = {wholeTok/wholeShare} * {USD/wholeTok} / {USD/wholeShare}
129
129
  const portionBeingEjected = ejectionIndices
130
130
  .map((i) => {
131
- return rebalance.inRebalance[i] ? folio[i].mul(prices[i]) : numbers_1.ZERO;
131
+ return folio[i].mul(prices[i]);
132
132
  })
133
133
  .reduce((a, b) => a.add(b), numbers_1.ZERO)
134
134
  .div(shareValue);
@@ -198,12 +198,14 @@ const getOpenAuction = (rebalance, _supply, _initialFolio = [], _targetBasket =
198
198
  }
199
199
  }
200
200
  }
201
- if (rebalanceTarget.lte(numbers_1.ZERO) || rebalanceTarget.gt(numbers_1.ONE)) {
201
+ if (rebalanceTarget.lte(numbers_1.ZERO) || rebalanceTarget.lt(initialProgression) || rebalanceTarget.gt(numbers_1.ONE)) {
202
202
  throw new Error("something has gone very wrong");
203
203
  }
204
+ const relativeTarget = rebalanceTarget.sub(initialProgression).div(numbers_1.ONE.sub(initialProgression));
204
205
  if (debug) {
205
206
  console.log("round", round);
206
207
  console.log("rebalanceTarget", rebalanceTarget.toString());
208
+ console.log("relativeTarget", relativeTarget.toString());
207
209
  }
208
210
  // {1}
209
211
  const delta = numbers_1.ONE.sub(rebalanceTarget);
@@ -366,10 +368,10 @@ const getOpenAuction = (rebalance, _supply, _initialFolio = [], _targetBasket =
366
368
  // {wholeTok/wholeShare} = {wholeTok/wholeBU} * {wholeBU/wholeShare}
367
369
  const buyUpTo = weightRanges[i].low.mul(actualLimits.low);
368
370
  const sellDownTo = weightRanges[i].high.mul(actualLimits.high);
369
- if (rebalance.inRebalance[i] && folio[i].lt(buyUpTo)) {
371
+ if (folio[i].lt(buyUpTo)) {
370
372
  deficitTokens.push(token);
371
373
  }
372
- else if (rebalance.inRebalance[i] && folio[i].gt(sellDownTo)) {
374
+ else if (folio[i].gt(sellDownTo)) {
373
375
  surplusTokens.push(token);
374
376
  }
375
377
  });
@@ -399,6 +401,7 @@ const getOpenAuction = (rebalance, _supply, _initialFolio = [], _targetBasket =
399
401
  absoluteProgression: progression.toNumber(),
400
402
  relativeProgression: relativeProgression.toNumber(),
401
403
  target: rebalanceTarget.toNumber(),
404
+ relativeTarget: relativeTarget.toNumber(),
402
405
  auctionSize: valueBeingTraded.toNumber(),
403
406
  surplusTokens: surplusTokens,
404
407
  deficitTokens: deficitTokens,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@reserve-protocol/dtf-rebalance-lib",
3
- "version": "0.1.5",
3
+ "version": "0.1.7",
4
4
  "description": "Rebalancing library for DTFs in typescript",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.js",