Skip to content

Commit 704be76

Browse files
committed
2.4.3 better threshold
1 parent 51390b2 commit 704be76

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@reserve-protocol/dtf-rebalance-lib",
3-
"version": "2.4.2",
3+
"version": "2.4.3",
44
"description": "Rebalancing library for DTFs in typescript",
55
"main": "dist/index.js",
66
"module": "dist/index.js",

src/open-auction.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -544,6 +544,9 @@ export const getOpenAuction = (
544544
const buyUpTo = (newWeights[i].low * newLimits.low * _supply) / D18n / D27n;
545545
const sellDownTo = (newWeights[i].high * newLimits.high * _supply + (D18n * D27n - 1n)) / D18n / D27n;
546546

547+
// {USD}
548+
const tradeThreshold = round == AuctionRound.EJECT ? ONE : ZERO;
549+
547550
if (_assets[i] < buyUpTo) {
548551
// {wholeTok} = {tok} / {tok/wholeTok}
549552
const deficitAmount = new Decimal((buyUpTo - _assets[i]).toString()).div(decimalScale[i]);
@@ -552,7 +555,7 @@ export const getOpenAuction = (
552555
const tokenDeficitValue = deficitAmount.mul(prices[i]);
553556

554557
// $1 minimum
555-
if (round == AuctionRound.EJECT || tokenDeficitValue.gte(ONE)) {
558+
if (tokenDeficitValue.gt(tradeThreshold)) {
556559
deficitTokens.push(token);
557560
deficitTokenSizes.push(tokenDeficitValue.toNumber());
558561
}
@@ -564,7 +567,7 @@ export const getOpenAuction = (
564567
const tokenSurplusValue = surplusAmount.mul(prices[i]);
565568

566569
// $1 minimum
567-
if (round == AuctionRound.EJECT || tokenSurplusValue.gte(ONE)) {
570+
if (tokenSurplusValue.gt(tradeThreshold)) {
568571
surplusTokens.push(token);
569572
surplusTokenSizes.push(tokenSurplusValue.toNumber());
570573
}

0 commit comments

Comments
 (0)