@reserve-protocol/dtf-rebalance-lib 0.0.6 → 0.0.8

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.
@@ -32,6 +32,18 @@ export interface OpenAuctionArgs {
32
32
  newPrices: PriceRange[];
33
33
  newLimits: RebalanceLimits;
34
34
  }
35
+ /**
36
+ * Generator for the `targetBasket` parameter
37
+ *
38
+ * Depending on the usecase, pass either:
39
+ * - TRACKING: CURRENT prices
40
+ * - NATIVE: HISTORICAL prices
41
+ *
42
+ * @param _initialWeights D27{tok/BU} The initial historical weights emitted in the RebalanceStarted event
43
+ * @param _prices {USD/wholeTok} either CURRENT or HISTORICAL prices
44
+ * @returns D18{1} The target basket
45
+ */
46
+ export declare const getTargetBasket: (_initialWeights: WeightRange[], _prices: number[], _decimals: bigint[]) => bigint[];
35
47
  /**
36
48
  * Get the values needed to call `folio.openAuction()` as the AUCTION_LAUNCHER
37
49
  *
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.getOpenAuction = exports.AuctionRound = void 0;
6
+ exports.getOpenAuction = exports.getTargetBasket = exports.AuctionRound = void 0;
7
7
  const decimal_js_light_1 = __importDefault(require("decimal.js-light"));
8
8
  const numbers_1 = require("./numbers");
9
9
  const types_1 = require("./types");
@@ -43,6 +43,7 @@ const getTargetBasket = (_initialWeights, _prices, _decimals) => {
43
43
  // D18{1} = {USD/wholeBU} / {USD/wholeBU} * D18
44
44
  return vals.map((val) => (0, numbers_1.bn)(val.div(totalValue).mul(numbers_1.D18d)));
45
45
  };
46
+ exports.getTargetBasket = getTargetBasket;
46
47
  /**
47
48
  * Get the values needed to call `folio.openAuction()` as the AUCTION_LAUNCHER
48
49
  *
@@ -178,7 +179,10 @@ const getOpenAuction = (rebalance, _supply, _initialFolio = [], _targetBasket =
178
179
  else if (relativeProgression.lt(finalStageAt.sub(0.02))) {
179
180
  // wiggle room to prevent having to re-run an auction at the same stage after price movement
180
181
  round = AuctionRound.PROGRESS;
181
- 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
+ }
182
186
  }
183
187
  // {1}
184
188
  const delta = numbers_1.ONE.sub(rebalanceTarget);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@reserve-protocol/dtf-rebalance-lib",
3
- "version": "0.0.6",
3
+ "version": "0.0.8",
4
4
  "description": "Rebalancing library for DTFs in typescript",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.js",
@@ -59,7 +59,7 @@ export interface OpenAuctionArgs {
59
59
  * @param _prices {USD/wholeTok} either CURRENT or HISTORICAL prices
60
60
  * @returns D18{1} The target basket
61
61
  */
62
- const getTargetBasket = (
62
+ export const getTargetBasket = (
63
63
  _initialWeights: WeightRange[],
64
64
  _prices: number[],
65
65
  _decimals: bigint[]
@@ -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}