Fix spot buy to close price

This commit is contained in:
Riordan Panayides 2021-12-13 17:23:45 +00:00
parent 90ab7c5eb4
commit ae27720787
1 changed files with 5 additions and 2 deletions

View File

@ -1038,13 +1038,16 @@ async function balanceTokens(
const side = netValues[i][1].gt(ZERO_I80F48) ? 'sell' : 'buy'; const side = netValues[i][1].gt(ZERO_I80F48) ? 'sell' : 'buy';
const price = mangoGroup const price = mangoGroup
.getPrice(marketIndex, cache) .getPrice(marketIndex, cache)
.mul(ONE_I80F48.sub(liquidationFee)) .mul(
side == 'buy'
? ONE_I80F48.add(liquidationFee)
: ONE_I80F48.sub(liquidationFee),
)
.toNumber(); .toNumber();
const quantity = Math.abs(diffs[marketIndex].toNumber()); const quantity = Math.abs(diffs[marketIndex].toNumber());
console.log( console.log(
`${side}ing ${quantity} of ${groupIds?.spotMarkets[marketIndex].baseSymbol} for $${price}`, `${side}ing ${quantity} of ${groupIds?.spotMarkets[marketIndex].baseSymbol} for $${price}`,
ONE_I80F48.sub(liquidationFee).toString(),
); );
await client.placeSpotOrder( await client.placeSpotOrder(
mangoGroup, mangoGroup,