Handle margined deposit balances in SpotMax (#396)

- Adjust 100% of spotMax to equal deposit amount, not available balance
This commit is contained in:
ImpossiblePairs 2022-08-17 23:07:12 -07:00 committed by GitHub
parent 8fcdbf991b
commit 44aadc2463
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 12 additions and 1 deletions

View File

@ -233,11 +233,22 @@ export default function AdvancedTradeForm({
).toNumber(),
token.decimals
)
const depositBalance = mangoAccount
.getUiDeposit(
mangoCache.rootBankCache[tokenIndex],
mangoGroup,
tokenIndex
)
.toNumber()
spotMax =
side === 'buy'
? availableBalance / priceOrDefault.toNumber()
: availableBalance
: spotMargin
? availableBalance
: depositBalance
}
}
const {