@reserve-protocol/dtf-rebalance-lib 2.2.4 → 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 +6 -8
- package/dist/start-rebalance.js +0 -3
- package/package.json +1 -1
package/dist/open-auction.js
CHANGED
|
@@ -155,11 +155,8 @@ const getOpenAuction = (rebalance, _supply, _initialSupply, _initialAssets = [],
|
|
|
155
155
|
// calculate progressions
|
|
156
156
|
// {wholeBU/wholeShare} = {USD/wholeShare} / {USD/wholeBU}
|
|
157
157
|
const spotLimit = shareValue.div(buValue);
|
|
158
|
-
// {wholeBU/wholeShare} = D18{BU/share} / D18
|
|
159
|
-
const prevSpotLimit = new utils_1.Decimal(rebalance.limits.spot.toString()).div(numbers_1.D18d);
|
|
160
|
-
const maxSpotLimit = spotLimit.gt(prevSpotLimit) ? spotLimit : prevSpotLimit;
|
|
161
158
|
// {wholeTok/wholeShare} = {wholeTok/wholeBU} * {wholeBU/wholeShare}
|
|
162
|
-
const expectedBalances = weightRanges.map((weightRange) => weightRange.spot.mul(
|
|
159
|
+
const expectedBalances = weightRanges.map((weightRange) => weightRange.spot.mul(spotLimit));
|
|
163
160
|
// absoluteProgression
|
|
164
161
|
// {1} = {USD/wholeShare} / {USD/wholeShare}
|
|
165
162
|
let progression = folio
|
|
@@ -211,7 +208,8 @@ const getOpenAuction = (rebalance, _supply, _initialSupply, _initialAssets = [],
|
|
|
211
208
|
if (progression.lt(0.99) && relativeProgression.lt(finalStageAt.sub(0.02))) {
|
|
212
209
|
round = AuctionRound.PROGRESS;
|
|
213
210
|
target = initialProgression.add(numbers_1.ONE.sub(initialProgression).mul(finalStageAt));
|
|
214
|
-
|
|
211
|
+
// never leave more than 1 bps for next auction
|
|
212
|
+
if (target.gt(numbers_1.ONE.sub(1e-4))) {
|
|
215
213
|
target = numbers_1.ONE;
|
|
216
214
|
}
|
|
217
215
|
if (target.eq(numbers_1.ONE)) {
|
|
@@ -334,7 +332,7 @@ const getOpenAuction = (rebalance, _supply, _initialSupply, _initialAssets = [],
|
|
|
334
332
|
// D27{nanoUSD/tok} = {USD/wholeTok} * {nanoUSD/USD} * D27 / {tok/wholeTok}
|
|
335
333
|
const spotPrice = (0, numbers_1.bn)(prices[i].mul(numbers_1.D9d).mul(numbers_1.D27d).div(decimalScale[i]));
|
|
336
334
|
if (spotPrice < initialPrice.low || spotPrice > initialPrice.high) {
|
|
337
|
-
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!`);
|
|
338
336
|
}
|
|
339
337
|
if (rebalance.priceControl == types_1.PriceControl.NONE) {
|
|
340
338
|
return initialPrice;
|
|
@@ -421,9 +419,9 @@ const getOpenAuction = (rebalance, _supply, _initialSupply, _initialAssets = [],
|
|
|
421
419
|
const deficitSize = deficitTokenSizes.reduce((a, b) => a + b, 0);
|
|
422
420
|
const auctionSize = surplusSize > deficitSize ? deficitSize : surplusSize;
|
|
423
421
|
// update targeting estimates
|
|
424
|
-
// {1} = {1} + {USD}
|
|
422
|
+
// {1} = {1} + {USD} / ({share} * {USD/share})
|
|
425
423
|
const adjustedTarget = progression.add(new utils_1.Decimal(auctionSize).div(shareValue.mul(supply)));
|
|
426
|
-
if (adjustedTarget.
|
|
424
|
+
if (adjustedTarget.lte(numbers_1.ONE)) {
|
|
427
425
|
target = adjustedTarget;
|
|
428
426
|
}
|
|
429
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}
|