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 outputBank = mangoStore((s) => s.swap.outputBank)
const tokenInMax = useMemo(() => { const tokenInMax = useMemo(() => {
if (mangoAccount && group && inputBank && outputBank) { try {
return getTokenInMax( if (mangoAccount && group && inputBank && outputBank) {
mangoAccount, return getTokenInMax(
inputBank.mint, mangoAccount,
outputBank.mint, inputBank.mint,
group, outputBank.mint,
useMargin group,
) useMargin
)
}
} catch (e) {
console.warn('Error in useTokenMax: ', e)
} }
return { return {
amount: new Decimal(0), amount: new Decimal(0),
amountWithBorrow: new Decimal(0), amountWithBorrow: new Decimal(0),