Fix spot buy to close price
This commit is contained in:
parent
90ab7c5eb4
commit
ae27720787
|
@ -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,
|
||||||
|
|
Loading…
Reference in New Issue