@reserve-protocol/dtf-rebalance-lib 0.2.12 → 0.2.13

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.
@@ -27,6 +27,9 @@ const getTargetBasket = (_initialWeights, _prices, _decimals) => {
27
27
  throw new Error("length mismatch");
28
28
  }
29
29
  const vals = _initialWeights.map((initialWeight, i) => {
30
+ if (_prices[i] <= 0) {
31
+ throw new Error(`missing price for token index ${i}`);
32
+ }
30
33
  const price = new utils_1.Decimal(_prices[i]);
31
34
  const decimalScale = new utils_1.Decimal(`1e${_decimals[i]}`);
32
35
  // {USD/wholeBU} = D27{tok/BU} * {BU/wholeBU} / {tok/wholeTok} / D27 * {USD/wholeTok}
@@ -77,7 +80,7 @@ const getOpenAuction = (rebalance, _supply, _initialFolio = [], _targetBasket =
77
80
  // {USD/wholeTok}
78
81
  const prices = _prices.map((a) => new utils_1.Decimal(a));
79
82
  for (let i = 0; i < prices.length; i++) {
80
- if (prices[i].eq(numbers_1.ZERO)) {
83
+ if (prices[i].lte(numbers_1.ZERO)) {
81
84
  throw new Error(`missing price for token ${rebalance.tokens[i]}`);
82
85
  }
83
86
  }
@@ -198,7 +201,7 @@ const getOpenAuction = (rebalance, _supply, _initialFolio = [], _targetBasket =
198
201
  if (progression.lt(0.99) && relativeProgression.lt(finalStageAt.sub(0.02))) {
199
202
  round = AuctionRound.PROGRESS;
200
203
  rebalanceTarget = initialProgression.add(numbers_1.ONE.sub(initialProgression).mul(finalStageAt));
201
- if (rebalanceTarget.gte(0.99)) {
204
+ if (rebalanceTarget.gte(0.999)) {
202
205
  rebalanceTarget = numbers_1.ONE;
203
206
  }
204
207
  if (rebalanceTarget.eq(numbers_1.ONE)) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@reserve-protocol/dtf-rebalance-lib",
3
- "version": "0.2.12",
3
+ "version": "0.2.13",
4
4
  "description": "Rebalancing library for DTFs in typescript",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.js",