@reserve-protocol/dtf-rebalance-lib 0.3.0 → 1.0.0

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.
@@ -416,14 +416,6 @@ const getOpenAuction = (rebalance, _supply, _initialFolio = [], _targetBasket =
416
416
  });
417
417
  // {USD}
418
418
  const valueBeingTraded = surplusValue.gt(deficitValue) ? deficitValue : surplusValue;
419
- // // completed if nothing to trade
420
- // if (valueBeingTraded.eq(ZERO)) {
421
- // round = AuctionRound.FINAL;
422
- // rebalanceTarget = ONE;
423
- // relativeProgression = ONE;
424
- // progression = ONE;
425
- // }
426
- // // TODO maybe add back
427
419
  // ================================================================
428
420
  // filter tokens that are not in the rebalance
429
421
  const returnTokens = [];
@@ -15,8 +15,9 @@ export interface StartRebalanceArgsPartial {
15
15
  * @param decimals Decimals of each token
16
16
  * @param _targetBasket D18{1} Ideal basket
17
17
  * @param _prices {USD/wholeTok} USD prices for each *whole* token
18
- * @param _priceError {1} Price error per token to use in the rebalanc; should be larger than price error during openAuction
18
+ * @param _priceError {1} Price error per token to use in the rebalance; should be larger than price error during openAuction
19
19
  * @param _dtfPrice {USD/wholeShare} DTF price
20
20
  * @param weightControl TRACKING=false, NATIVE=true
21
+ * @param lastMinuteRemovals If the low weight for tokens in the basket should always be 1 to support last minute removal
21
22
  */
22
- export declare const getStartRebalance: (_supply: bigint, tokens: string[], _folio: bigint[], decimals: bigint[], _targetBasket: bigint[], _prices: number[], _priceError: number[], weightControl: boolean, debug?: boolean) => StartRebalanceArgsPartial;
23
+ export declare const getStartRebalance: (_supply: bigint, tokens: string[], _folio: bigint[], decimals: bigint[], _targetBasket: bigint[], _prices: number[], _priceError: number[], weightControl: boolean, lastMinuteRemovals: boolean, debug?: boolean) => StartRebalanceArgsPartial;
@@ -14,13 +14,14 @@ const numbers_1 = require("./numbers");
14
14
  * @param decimals Decimals of each token
15
15
  * @param _targetBasket D18{1} Ideal basket
16
16
  * @param _prices {USD/wholeTok} USD prices for each *whole* token
17
- * @param _priceError {1} Price error per token to use in the rebalanc; should be larger than price error during openAuction
17
+ * @param _priceError {1} Price error per token to use in the rebalance; should be larger than price error during openAuction
18
18
  * @param _dtfPrice {USD/wholeShare} DTF price
19
19
  * @param weightControl TRACKING=false, NATIVE=true
20
+ * @param lastMinuteRemovals If the low weight for tokens in the basket should always be 1 to support last minute removal
20
21
  */
21
- const getStartRebalance = (_supply, tokens, _folio, decimals, _targetBasket, _prices, _priceError, weightControl, debug) => {
22
+ const getStartRebalance = (_supply, tokens, _folio, decimals, _targetBasket, _prices, _priceError, weightControl, lastMinuteRemovals, debug) => {
22
23
  if (debug) {
23
- console.log("getStartRebalance", _supply, tokens, _folio, decimals, _targetBasket, _prices, _priceError, weightControl);
24
+ console.log("getStartRebalance", _supply, tokens, _folio, decimals, _targetBasket, _prices, _priceError, weightControl, lastMinuteRemovals);
24
25
  }
25
26
  // {wholeTok/wholeShare} = D18{tok/share} * {share/wholeShare} / {tok/wholeTok} / D18
26
27
  const folio = _folio.map((c, i) => new utils_1.Decimal(c.toString()).div(new utils_1.Decimal(`1e${decimals[i]}`)));
@@ -81,6 +82,10 @@ const getStartRebalance = (_supply, tokens, _folio, decimals, _targetBasket, _pr
81
82
  high: (0, numbers_1.bn)(highWeight.mul(limitMultiplier)),
82
83
  });
83
84
  }
85
+ // lastMinuteRemovals: set smallest low weight possible to support virtual removal from the basket
86
+ if (lastMinuteRemovals && newWeights[i].low > 0n) {
87
+ newWeights[i].low = 1n;
88
+ }
84
89
  // === newPrices ===
85
90
  // D27{wholeTok/tok} = D27 / {tok/wholeTok}
86
91
  const priceMultiplier = numbers_1.D27d.div(new utils_1.Decimal(`1e${decimals[i]}`));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@reserve-protocol/dtf-rebalance-lib",
3
- "version": "0.3.0",
3
+ "version": "1.0.0",
4
4
  "description": "Rebalancing library for DTFs in typescript",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.js",