add try catch in useTokenMax

This commit is contained in:
tjs 2023-03-12 16:01:33 -04:00
parent ff6c03d7a7
commit 6c66cdbf20
1 changed files with 12 additions and 9 deletions

View File

@ -116,16 +116,19 @@ export const useTokenMax = (useMargin = true): TokenMaxResults => {
const outputBank = mangoStore((s) => s.swap.outputBank)
const tokenInMax = useMemo(() => {
if (mangoAccount && group && inputBank && outputBank) {
return getTokenInMax(
mangoAccount,
inputBank.mint,
outputBank.mint,
group,
useMargin
)
try {
if (mangoAccount && group && inputBank && outputBank) {
return getTokenInMax(
mangoAccount,
inputBank.mint,
outputBank.mint,
group,
useMargin
)
}
} catch (e) {
console.warn('Error in useTokenMax: ', e)
}
return {
amount: new Decimal(0),
amountWithBorrow: new Decimal(0),