@reserve-protocol/dtf-rebalance-lib 2.2.5 → 2.3.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.
- package/dist/open-auction.js +5 -4
- package/dist/start-rebalance.js +0 -3
- package/package.json +1 -1
package/dist/open-auction.js
CHANGED
|
@@ -208,7 +208,8 @@ const getOpenAuction = (rebalance, _supply, _initialSupply, _initialAssets = [],
|
|
|
208
208
|
if (progression.lt(0.99) && relativeProgression.lt(finalStageAt.sub(0.02))) {
|
|
209
209
|
round = AuctionRound.PROGRESS;
|
|
210
210
|
target = initialProgression.add(numbers_1.ONE.sub(initialProgression).mul(finalStageAt));
|
|
211
|
-
|
|
211
|
+
// never leave more than 1 bps for next auction
|
|
212
|
+
if (target.gt(numbers_1.ONE.sub(1e-4))) {
|
|
212
213
|
target = numbers_1.ONE;
|
|
213
214
|
}
|
|
214
215
|
if (target.eq(numbers_1.ONE)) {
|
|
@@ -331,7 +332,7 @@ const getOpenAuction = (rebalance, _supply, _initialSupply, _initialAssets = [],
|
|
|
331
332
|
// D27{nanoUSD/tok} = {USD/wholeTok} * {nanoUSD/USD} * D27 / {tok/wholeTok}
|
|
332
333
|
const spotPrice = (0, numbers_1.bn)(prices[i].mul(numbers_1.D9d).mul(numbers_1.D27d).div(decimalScale[i]));
|
|
333
334
|
if (spotPrice < initialPrice.low || spotPrice > initialPrice.high) {
|
|
334
|
-
throw new Error(`spot price ${spotPrice.toString()} out of bounds relative to initial range [${initialPrice.low.toString()}, ${initialPrice.high.toString()}]! auction launcher MUST closeRebalance to prevent loss!`);
|
|
335
|
+
throw new Error(`Token ${rebalance.tokens[i]}: spot price ${spotPrice.toString()} out of bounds relative to initial range [${initialPrice.low.toString()}, ${initialPrice.high.toString()}]! auction launcher MUST closeRebalance to prevent loss!`);
|
|
335
336
|
}
|
|
336
337
|
if (rebalance.priceControl == types_1.PriceControl.NONE) {
|
|
337
338
|
return initialPrice;
|
|
@@ -418,9 +419,9 @@ const getOpenAuction = (rebalance, _supply, _initialSupply, _initialAssets = [],
|
|
|
418
419
|
const deficitSize = deficitTokenSizes.reduce((a, b) => a + b, 0);
|
|
419
420
|
const auctionSize = surplusSize > deficitSize ? deficitSize : surplusSize;
|
|
420
421
|
// update targeting estimates
|
|
421
|
-
// {1} = {1} + {USD}
|
|
422
|
+
// {1} = {1} + {USD} / ({share} * {USD/share})
|
|
422
423
|
const adjustedTarget = progression.add(new utils_1.Decimal(auctionSize).div(shareValue.mul(supply)));
|
|
423
|
-
if (adjustedTarget.
|
|
424
|
+
if (adjustedTarget.lte(numbers_1.ONE)) {
|
|
424
425
|
target = adjustedTarget;
|
|
425
426
|
}
|
|
426
427
|
const relativeTarget = target.sub(initialProgression).div(numbers_1.ONE.sub(initialProgression));
|
package/dist/start-rebalance.js
CHANGED
|
@@ -58,9 +58,6 @@ const getStartRebalance = (_supply, tokens, _assets, decimals, _targetBasket, _p
|
|
|
58
58
|
const spotWeight = targetBasket[i].mul(dtfValue).div(prices[i]).div(supply);
|
|
59
59
|
// D27{tok/share}{wholeShare/wholeTok} = D27 * {tok/wholeTok} / {share/wholeShare}
|
|
60
60
|
const limitMultiplier = numbers_1.D27d.mul(new utils_1.Decimal(`1e${decimals[i]}`)).div(numbers_1.D18d);
|
|
61
|
-
if (debug) {
|
|
62
|
-
console.log("limitMultiplier", limitMultiplier.toString());
|
|
63
|
-
}
|
|
64
61
|
if (!weightControl) {
|
|
65
62
|
// TRACKING case
|
|
66
63
|
// D27{tok/BU} = {wholeTok/wholeShare} * D27{tok/share}{wholeShare/wholeTok} / {BU/share}
|