Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mmui: Fix Basic MM allocation bug #3052

Merged
merged 1 commit into from
Oct 31, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions client/webserver/site/src/js/mmutil.ts
Original file line number Diff line number Diff line change
Expand Up @@ -537,7 +537,10 @@ export class BotMarket {
// In these available balance calcs, only subtract the available balance of
// running bots, since the locked/reserved/immature is already subtracted
// from the wallet's total available balance.
const [cexBaseAvail, cexQuoteAvail] = [(cexBaseBalance?.available || 0) - bInv.cex.avail, (cexQuoteBalance?.available || 0) - qInv.cex.avail]
let cexBaseAvail = 0
let cexQuoteAvail = 0
if (cexBaseBalance) cexBaseAvail = (cexBaseBalance.available || 0) - bInv.cex.avail
if (cexQuoteBalance) cexQuoteAvail = (cexQuoteBalance.available || 0) - qInv.cex.avail
const [dexBaseAvail, dexQuoteAvail] = [baseWallet.balance.available - bInv.dex.avail, quoteWallet.balance.available - qInv.dex.avail]
const baseAvail = dexBaseAvail + cexBaseAvail
const quoteAvail = dexQuoteAvail + cexQuoteAvail
Expand All @@ -548,14 +551,14 @@ export class BotMarket {
if (baseFeeID !== baseID) {
const bFeeInv = runningBotInventory(baseID)
dexBaseFeeAvail = baseFeeWallet.balance.available - bFeeInv.dex.total
cexBaseFeeAvail = (cexBaseBalance?.available || 0) - bFeeInv.cex.total
if (cexBaseBalance) cexBaseFeeAvail = (cexBaseBalance.available || 0) - bFeeInv.cex.total
baseFeeAvail = dexBaseFeeAvail + cexBaseFeeAvail
}
let [quoteFeeAvail, dexQuoteFeeAvail, cexQuoteFeeAvail] = [quoteAvail, dexQuoteAvail, cexQuoteAvail]
if (quoteFeeID !== quoteID) {
const qFeeInv = runningBotInventory(quoteID)
dexQuoteFeeAvail = quoteFeeWallet.balance.available - qFeeInv.dex.total
cexQuoteFeeAvail = (cexQuoteBalance?.available || 0) - qFeeInv.cex.total
if (cexQuoteBalance) cexQuoteFeeAvail = (cexQuoteBalance.available || 0) - qFeeInv.cex.total
quoteFeeAvail = dexQuoteFeeAvail + cexQuoteFeeAvail
}
return { // convert to conventioanl.
Expand Down
Loading