Adds more null checks

This commit is contained in:
Kieran Gillen 2022-03-28 16:18:35 +02:00
parent 140c26542a
commit 2deb4ec75f
14 changed files with 306 additions and 223 deletions

View File

@ -31,16 +31,23 @@ const BalancesTable = ({
const [actionSymbol, setActionSymbol] = useState('')
const balances = useBalances()
const { items, requestSort, sortConfig } = useSortableData(
balances
.filter(
(bal) =>
showZeroBalances ||
+bal.deposits > 0 ||
+bal.borrows > 0 ||
bal.orders > 0 ||
bal.unsettled > 0
)
.sort((a, b) => Math.abs(+b.value) - Math.abs(+a.value))
balances?.length > 0
? balances
.filter((bal) => {
return (
showZeroBalances ||
(bal.deposits && +bal.deposits > 0) ||
(bal.borrows && +bal.borrows > 0) ||
(bal.orders && bal.orders > 0) ||
(bal.unsettled && bal.unsettled > 0)
)
})
.sort((a, b) => {
const aV = a.value ? Math.abs(+a.value) : 0
const bV = b.value ? Math.abs(+b.value) : 0
return bV - aV
})
: []
)
const actions = useMangoStore((s) => s.actions)
const mangoGroup = useMangoStore((s) => s.selectedMangoGroup.current)
@ -61,13 +68,21 @@ const BalancesTable = ({
const { asPath } = useRouter()
const handleSizeClick = (size, symbol) => {
const minOrderSize = selectedMarket.minOrderSize
const sizePrecisionDigits = getPrecisionDigits(minOrderSize)
const minOrderSize = selectedMarket?.minOrderSize
const sizePrecisionDigits = minOrderSize
? getPrecisionDigits(minOrderSize)
: null
const marketIndex = marketConfig.marketIndex
const priceOrDefault = price
? price
: mangoGroup.getPriceUi(marketIndex, mangoGroupCache)
: mangoGroup && mangoGroupCache
? mangoGroup.getPriceUi(marketIndex, mangoGroupCache)
: null
if (!priceOrDefault || !sizePrecisionDigits || !minOrderSize) {
return
}
let roundedSize, side
if (symbol === 'USDC') {
@ -114,6 +129,10 @@ const BalancesTable = ({
(mkt) => mkt instanceof Market
) as Market[]
if (!mangoGroup || !mangoAccount || !wallet) {
return
}
const txids: TransactionSignature[] = await mangoClient.settleAll(
mangoGroup,
mangoAccount,
@ -146,7 +165,9 @@ const BalancesTable = ({
}
}
const unsettledBalances = balances.filter((bal) => bal.unsettled > 0)
const unsettledBalances = balances.filter(
(bal) => bal.unsettled && bal.unsettled > 0
)
return (
<div className={`flex flex-col pb-2 sm:pb-4`}>
@ -185,9 +206,14 @@ const BalancesTable = ({
<p className="mb-0 text-xs text-th-fgd-1">
{bal.symbol}
</p>
<div className="font-bold text-th-green">
{floorToDecimal(bal.unsettled, tokenConfig.decimals)}
</div>
{bal.unsettled ? (
<div className="font-bold text-th-green">
{floorToDecimal(
bal.unsettled,
tokenConfig.decimals
)}
</div>
) : null}
</div>
</div>
</div>
@ -361,7 +387,16 @@ const BalancesTable = ({
</thead>
<tbody>
{items.map((balance, index) => {
if (!balance) {
if (
!balance ||
typeof balance.decimals !== 'number' ||
!balance.deposits ||
!balance.borrows ||
!balance.net ||
!balance.value ||
!balance.borrowRate ||
!balance.depositRate
) {
return null
}
return (
@ -487,121 +522,137 @@ const BalancesTable = ({
colOneHeader={t('asset')}
colTwoHeader={t('net-balance')}
/>
{items.map((balance, index) => (
<ExpandableRow
buttonTemplate={
<div className="flex w-full items-center justify-between text-th-fgd-1">
<div className="flex items-center text-th-fgd-1">
<img
alt=""
width="20"
height="20"
src={`/assets/icons/${balance.symbol.toLowerCase()}.svg`}
className={`mr-2.5`}
/>
{items.map((balance, index) => {
if (
!balance ||
typeof balance.decimals !== 'number' ||
typeof balance.orders !== 'number' ||
typeof balance.unsettled !== 'number' ||
!balance.deposits ||
!balance.borrows ||
!balance.net ||
!balance.value ||
!balance.borrowRate ||
!balance.depositRate
) {
return null
}
return (
<ExpandableRow
buttonTemplate={
<div className="flex w-full items-center justify-between text-th-fgd-1">
<div className="flex items-center text-th-fgd-1">
<img
alt=""
width="20"
height="20"
src={`/assets/icons/${balance.symbol.toLowerCase()}.svg`}
className={`mr-2.5`}
/>
{balance.symbol}
</div>
<div className="text-right text-th-fgd-1">
{balance.net.toFormat(balance.decimals)}
</div>
</div>
}
key={`${balance.symbol}${index}`}
panelTemplate={
<>
<div className="grid grid-flow-row grid-cols-2 gap-4 pb-4">
<div className="text-left">
<div className="pb-0.5 text-xs text-th-fgd-3">
{t('deposits')}
</div>
{balance.deposits.toFormat(balance.decimals)}
{balance.symbol}
</div>
<div className="text-left">
<div className="pb-0.5 text-xs text-th-fgd-3">
{t('borrows')}
</div>
{balance.borrows.toFormat(balance.decimals)}
</div>
<div className="text-left">
<div className="pb-0.5 text-xs text-th-fgd-3">
{t('in-orders')}
</div>
{balance.orders.toLocaleString(undefined, {
maximumFractionDigits: balance.decimals,
})}
</div>
<div className="text-left">
<div className="pb-0.5 text-xs text-th-fgd-3">
{t('unsettled')}
</div>
{balance.unsettled.toLocaleString(undefined, {
maximumFractionDigits: balance.decimals,
})}
</div>
<div className="text-left">
<div className="pb-0.5 text-xs text-th-fgd-3">
{t('value')}
</div>
{formatUsdValue(balance.value.toNumber())}
</div>
<div className="text-left text-th-fgd-4">
<div className="pb-0.5 text-xs text-th-fgd-3">
{t('rates')}
</div>
<span className="mr-1 text-th-green">
{balance.depositRate.toFixed(2)}%
</span>
/
<span className="ml-1 text-th-red">
{balance.borrowRate.toFixed(2)}%
</span>
<div className="text-right text-th-fgd-1">
{balance.net.toFormat(balance.decimals)}
</div>
</div>
<div className="flex space-x-4">
<Button
className="h-7 w-1/2 pt-0 pb-0 pl-3 pr-3 text-xs"
onClick={() =>
handleOpenDepositModal(balance.symbol)
}
>
{balance.borrows.toNumber() > 0
? t('repay')
: t('deposit')}
</Button>
<Button
className="h-7 w-1/2 pt-0 pb-0 pl-3 pr-3 text-xs"
onClick={() =>
handleOpenWithdrawModal(balance.symbol)
}
>
{t('withdraw')}
</Button>
</div>
}
key={`${balance.symbol}${index}`}
panelTemplate={
<>
<div className="grid grid-flow-row grid-cols-2 gap-4 pb-4">
<div className="text-left">
<div className="pb-0.5 text-xs text-th-fgd-3">
{t('deposits')}
</div>
{balance.deposits.toFormat(balance.decimals)}
</div>
<div className="text-left">
<div className="pb-0.5 text-xs text-th-fgd-3">
{t('borrows')}
</div>
{balance.borrows.toFormat(balance.decimals)}
</div>
<div className="text-left">
<div className="pb-0.5 text-xs text-th-fgd-3">
{t('in-orders')}
</div>
{balance.orders.toLocaleString(undefined, {
maximumFractionDigits: balance.decimals,
})}
</div>
<div className="text-left">
<div className="pb-0.5 text-xs text-th-fgd-3">
{t('unsettled')}
</div>
{balance.unsettled.toLocaleString(undefined, {
maximumFractionDigits: balance.decimals,
})}
</div>
<div className="text-left">
<div className="pb-0.5 text-xs text-th-fgd-3">
{t('value')}
</div>
{formatUsdValue(balance.value.toNumber())}
</div>
<div className="text-left text-th-fgd-4">
<div className="pb-0.5 text-xs text-th-fgd-3">
{t('rates')}
</div>
<span className="mr-1 text-th-green">
{balance.depositRate.toFixed(2)}%
</span>
/
<span className="ml-1 text-th-red">
{balance.borrowRate.toFixed(2)}%
</span>
</div>
</div>
<div className="flex space-x-4">
<Button
className="h-7 w-1/2 pt-0 pb-0 pl-3 pr-3 text-xs"
onClick={() =>
handleOpenDepositModal(balance.symbol)
}
>
{balance.borrows.toNumber() > 0
? t('repay')
: t('deposit')}
</Button>
<Button
className="h-7 w-1/2 pt-0 pb-0 pl-3 pr-3 text-xs"
onClick={() =>
handleOpenWithdrawModal(balance.symbol)
}
>
{t('withdraw')}
</Button>
</div>
{showDepositModal && (
<DepositModal
isOpen={showDepositModal}
onClose={() => setShowDepositModal(false)}
tokenSymbol={actionSymbol}
repayAmount={
balance.borrows.toNumber() > 0
? balance.borrows.toFormat(balance.decimals)
: ''
}
/>
)}
{showWithdrawModal && (
<WithdrawModal
isOpen={showWithdrawModal}
onClose={() => setShowWithdrawModal(false)}
tokenSymbol={actionSymbol}
/>
)}
</>
}
/>
))}
{showDepositModal && (
<DepositModal
isOpen={showDepositModal}
onClose={() => setShowDepositModal(false)}
tokenSymbol={actionSymbol}
repayAmount={
balance.borrows.toNumber() > 0
? balance.borrows.toFormat(balance.decimals)
: ''
}
/>
)}
{showWithdrawModal && (
<WithdrawModal
isOpen={showWithdrawModal}
onClose={() => setShowWithdrawModal(false)}
tokenSymbol={actionSymbol}
/>
)}
</>
}
/>
)
})}
</div>
)
) : (

View File

@ -18,6 +18,9 @@ const DepositMsrmModal = ({ onClose, isOpen }) => {
const cluster = useMangoStore.getState().connection.cluster
const handleMsrmDeposit = async () => {
if (!mangoGroup || !mangoAccount || !wallet) {
return
}
setSubmitting(true)
const mangoClient = useMangoStore.getState().connection.client
const ownerMsrmAccount = walletTokens.find((t) =>

View File

@ -34,6 +34,9 @@ const MangoAccountSelect = ({
const mangoAccount = mangoAccounts.find(
(ma) => ma.publicKey.toString() === value
)
if (!mangoAccount) {
return
}
setSelectedMangoAccount(mangoAccount)
if (onChange) {
onChange(mangoAccount)

View File

@ -20,13 +20,16 @@ const OraclePrice = () => {
const selectedMarket = useMangoStore((s) => s.selectedMarket.current)
const decimals = useMemo(
() => getPrecisionDigits(selectedMarket?.tickSize),
() =>
selectedMarket?.tickSize !== undefined
? getPrecisionDigits(selectedMarket?.tickSize)
: null,
[selectedMarket]
)
return (
<div className="text-th-fgd-1 md:text-xs">
{oraclePrice && selectedMarket
{decimals && oraclePrice && selectedMarket
? oraclePrice.toNumber().toLocaleString(undefined, {
minimumFractionDigits: decimals,
maximumFractionDigits: decimals,

View File

@ -5,9 +5,10 @@ import Link from 'next/link'
import * as MonoIcons from './icons'
import { initialMarket } from './SettingsModal'
// const isMarketSelected = ()
export default function MarketMenuItem({ menuTitle = '', linksArray = [] }) {
const MarketMenuItem: React.FC<{ menuTitle: string; linksArray: any[] }> = ({
menuTitle = '',
linksArray = [],
}) => {
const { asPath } = useRouter()
const [openState, setOpenState] = useState(false)
@ -76,3 +77,5 @@ export default function MarketMenuItem({ menuTitle = '', linksArray = [] }) {
</div>
)
}
export default MarketMenuItem

View File

@ -135,12 +135,12 @@ export default function Orderbook({ depth = 8 }) {
const { width } = useViewport()
const isMobile = width ? width < breakpoints.sm : false
const currentOrderbookData = useRef(null)
const currentOrderbookData = useRef<any>(null)
const nextOrderbookData = useRef(null)
const previousDepth = usePrevious(depth)
const [openOrderPrices, setOpenOrderPrices] = useState([])
const [orderbookData, setOrderbookData] = useState(null)
const [orderbookData, setOrderbookData] = useState<any | null>(null)
const [defaultLayout, setDefaultLayout] = useState(true)
const [displayCumulativeSize, setDisplayCumulativeSize] = useState(false)
const [grouping, setGrouping] = useState(0.01)
@ -641,7 +641,7 @@ const OrderbookRow = React.memo<any>(
grouping: number
market: Market | PerpMarket
}) => {
const element = useRef(null)
const element = useRef<HTMLDivElement>(null)
const setMangoStore = useMangoStore(setStoreSelector)
const [showOrderbookFlash] = useLocalStorageState(ORDERBOOK_FLASH_KEY, true)
const flashClassName = side === 'sell' ? 'red-flash' : 'green-flash'

View File

@ -17,7 +17,7 @@ const MenuButton: React.FC<{
className={`default-transition flex items-center justify-end whitespace-nowrap pb-2.5 text-xs tracking-wider hover:cursor-pointer hover:text-th-primary ${
disabled ? 'pointer-events-none text-th-fgd-4' : 'text-th-fgd-1'
}`}
onClick={disabled ? null : onClick}
onClick={disabled ? () => null : onClick}
>
{text}
</div>
@ -55,8 +55,7 @@ export const RedeemDropdown: React.FC = () => {
setOpen(false)
setSettlingPosPnl(true)
for (const p of unsettledPositivePositions) {
console.log('settlePosPnl', p)
await settlePosPnl([p.perpMarket], p.perpAccount, t, null)
await settlePosPnl([p.perpMarket], p.perpAccount, t, undefined)
}
setSettlingPosPnl(false)
}

View File

@ -32,7 +32,7 @@ const SwitchMarketDropdown = () => {
[marketsInfo]
)
const [suggestions, setSuggestions] = useState([])
const [suggestions, setSuggestions] = useState<any[]>([])
const [searchString, setSearchString] = useState('')
const buttonRef = useRef(null)
const { t } = useTranslation('common')
@ -43,7 +43,7 @@ const SwitchMarketDropdown = () => {
const onSearch = (searchString) => {
if (searchString.length > 0) {
const newSuggestions = suggestions.filter((v) =>
v.name.toLowerCase().includes(searchString.toLowerCase())
v.name?.toLowerCase().includes(searchString.toLowerCase())
)
setSuggestions(newSuggestions)
}

View File

@ -23,7 +23,7 @@ const ThemeSwitch = () => {
<DropMenu
button={
<div className="default-transition flex h-8 w-8 items-center justify-center rounded-full bg-th-bkg-4 text-th-fgd-1 hover:text-th-primary focus:outline-none">
{THEMES.find((t) => t.name === theme).icon}
{THEMES?.find((t) => t?.name === theme)?.icon}
</div>
}
value={theme}

View File

@ -62,7 +62,7 @@ const AccountInterest = () => {
const [loadHourlyStats, setLoadHourlyStats] = useState(false)
const [loadTotalStats, setLoadTotalStats] = useState(false)
const [selectedAsset, setSelectedAsset] = useState<string>('')
const [chartData, setChartData] = useState([])
const [chartData, setChartData] = useState<any[]>([])
const {
paginatedData,
setData,
@ -81,7 +81,9 @@ const AccountInterest = () => {
)
const mangoAccountPk = useMemo(() => {
return mangoAccount.publicKey.toString()
if (mangoAccount) {
return mangoAccount.publicKey.toString()
}
}, [mangoAccount])
const token = useMemo(() => {
@ -92,7 +94,7 @@ const AccountInterest = () => {
const exportInterestDataToCSV = () => {
const assets = Object.keys(hourlyInterestStats)
let dataToExport = []
let dataToExport: any[] = []
for (const asset of assets) {
dataToExport = [
@ -110,7 +112,7 @@ const AccountInterest = () => {
}
const title = `${
mangoAccount.name || mangoAccount.publicKey
mangoAccount?.name || mangoAccount?.publicKey
}-Interest-${new Date().toLocaleDateString()}`
const headers = [
'Timestamp',
@ -135,7 +137,7 @@ const AccountInterest = () => {
}, [hourlyInterestStats])
useEffect(() => {
const hideDust = []
const hideDust: any[] = []
const fetchInterestStats = async () => {
setLoadTotalStats(true)
const response = await fetch(
@ -147,6 +149,9 @@ const AccountInterest = () => {
Object.entries(parsedResponse).forEach((r) => {
const tokens = groupConfig.tokens
const token = tokens.find((t) => t.symbol === r[0])
if (!token || !mangoGroup || !mangoCache) {
return
}
const tokenIndex = mangoGroup.getTokenIndex(token.mintKey)
const price = mangoGroup.getPrice(tokenIndex, mangoCache).toNumber()
const interest =
@ -240,7 +245,7 @@ const AccountInterest = () => {
(d) => new Date(d.time).getTime() > start
)
const dailyInterest = []
const dailyInterest: any[] = []
for (let i = 0; i < 30; i++) {
dailyInterest.push({
@ -486,9 +491,13 @@ const AccountInterest = () => {
xAxis="time"
yAxis="interest"
data={chartData}
labelFormat={(x) =>
x === 0 ? 0 : x.toFixed(token.decimals + 1)
}
labelFormat={(x) => {
return x === 0
? 0
: token
? x.toFixed(token.decimals + 1)
: null
}}
tickFormat={handleDustTicks}
titleValue={chartData.reduce(
(a, c) => a + c.interest,
@ -506,31 +515,35 @@ const AccountInterest = () => {
className="relative mb-6 w-full rounded-md border border-th-bkg-4 p-4 sm:w-1/2"
style={{ height: '330px' }}
>
<Chart
hideRangeFilters
title={t('interest-chart-value-title', {
symbol: selectedAsset,
})}
xAxis="time"
yAxis="value"
data={chartData}
labelFormat={(x) =>
x === 0
? 0
: x < 0
? `-$${Math.abs(x)?.toFixed(token.decimals + 1)}`
: `$${x?.toFixed(token.decimals + 1)}`
}
tickFormat={handleUsdDustTicks}
titleValue={chartData.reduce(
(a, c) => a + c.value,
0
)}
type="bar"
useMulticoloredBars
yAxisWidth={increaseYAxisWidth ? 70 : 50}
zeroLine
/>
{token ? (
<Chart
hideRangeFilters
title={t('interest-chart-value-title', {
symbol: selectedAsset,
})}
xAxis="time"
yAxis="value"
data={chartData}
labelFormat={(x) =>
x === 0
? 0
: x < 0
? `-$${Math.abs(x)?.toFixed(
token.decimals + 1
)}`
: `$${x?.toFixed(token.decimals + 1)}`
}
tickFormat={handleUsdDustTicks}
titleValue={chartData.reduce(
(a, c) => a + c.value,
0
)}
type="bar"
useMulticoloredBars
yAxisWidth={increaseYAxisWidth ? 70 : 50}
zeroLine
/>
) : null}
</div>
) : null}
</div>
@ -555,25 +568,29 @@ const AccountInterest = () => {
<Td className="w-1/3">
<TableDateDisplay date={utc} />
</Td>
<Td className="w-1/3">
{stat.borrow_interest > 0
? `-${stat.borrow_interest.toFixed(
token.decimals + 1
)}`
: stat.deposit_interest.toFixed(
token.decimals + 1
)}{' '}
{selectedAsset}
</Td>
<Td className="w-1/3">
{stat.borrow_interest > 0
? `-$${(
stat.borrow_interest * stat.price
).toFixed(token.decimals + 1)}`
: `$${(
stat.deposit_interest * stat.price
).toFixed(token.decimals + 1)}`}
</Td>
{token ? (
<Td className="w-1/3">
{stat.borrow_interest > 0
? `-${stat.borrow_interest.toFixed(
token.decimals + 1
)}`
: stat.deposit_interest.toFixed(
token.decimals + 1
)}{' '}
{selectedAsset}
</Td>
) : null}
{token ? (
<Td className="w-1/3">
{stat.borrow_interest > 0
? `-$${(
stat.borrow_interest * stat.price
).toFixed(token.decimals + 1)}`
: `$${(
stat.deposit_interest * stat.price
).toFixed(token.decimals + 1)}`}
</Td>
) : null}
</TrBody>
)
})}

View File

@ -1095,9 +1095,11 @@ export default function AdvancedTradeForm({
</Tooltip>
</div>
<div className="flex">
<span className="text-th-fgd-1">
{(parseFloat(maxSlippage) * 100).toFixed(2)}%
</span>
{maxSlippage ? (
<span className="text-th-fgd-1">
{(parseFloat(maxSlippage) * 100).toFixed(2)}%
</span>
) : null}
<LinkButton
className="ml-2 text-xs"
onClick={() => setEditMaxSlippage(true)}

View File

@ -3,7 +3,7 @@ import { MangoAccount } from '@blockworks-foundation/mango-client'
import shallow from 'zustand/shallow'
export default function useMangoAccount(): {
mangoAccount: MangoAccount
mangoAccount: MangoAccount | null
initialLoad: boolean
} {
const { mangoAccount, initialLoad } = useMangoStore(

View File

@ -1,6 +1,6 @@
import { useEffect, useRef } from 'react'
export default function usePrevious(value) {
export default function usePrevious(value): any {
// The ref object is a generic container whose current property is mutable ...
// ... and can hold any value, similar to an instance property on a class
const ref = useRef()

View File

@ -15,11 +15,20 @@ export async function deposit({
}) {
const mangoGroup = useMangoStore.getState().selectedMangoGroup.current
const wallet = useMangoStore.getState().wallet.current
const tokenIndex = mangoGroup.getTokenIndex(fromTokenAcc.mint)
const tokenIndex = mangoGroup?.getTokenIndex(fromTokenAcc.mint)
const mangoClient = useMangoStore.getState().connection.client
const referrer = useMangoStore.getState().referrerPk
console.log('referrerPk', referrer)
if (!mangoGroup) return
if (typeof tokenIndex !== 'number') {
return
}
const mangoGroupPublicKey =
mangoGroup?.rootBankAccounts?.[tokenIndex]?.nodeBankAccounts[0].publicKey
const vault =
mangoGroup?.rootBankAccounts?.[tokenIndex]?.nodeBankAccounts[0].vault
if (!mangoGroup || !mangoGroupPublicKey || !vault) return
if (mangoAccount) {
return await mangoClient.deposit(
@ -27,8 +36,8 @@ export async function deposit({
mangoAccount,
wallet,
mangoGroup.tokens[tokenIndex].rootBank,
mangoGroup.rootBankAccounts[tokenIndex].nodeBankAccounts[0].publicKey,
mangoGroup.rootBankAccounts[tokenIndex].nodeBankAccounts[0].vault,
mangoGroupPublicKey,
vault,
fromTokenAcc.publicKey,
Number(amount)
)
@ -43,8 +52,8 @@ export async function deposit({
mangoGroup,
wallet,
mangoGroup.tokens[tokenIndex].rootBank,
mangoGroup.rootBankAccounts[tokenIndex].nodeBankAccounts[0].publicKey,
mangoGroup.rootBankAccounts[tokenIndex].nodeBankAccounts[0].vault,
mangoGroupPublicKey,
vault,
fromTokenAcc.publicKey,
Number(amount),
existingAccounts.length,
@ -69,24 +78,17 @@ export async function withdraw({
const tokenIndex = mangoGroup.getTokenIndex(token)
const mangoClient = useMangoStore.getState().connection.client
const publicKey =
mangoGroup?.rootBankAccounts?.[tokenIndex]?.nodeBankAccounts[0].publicKey
const vault =
mangoGroup?.rootBankAccounts?.[tokenIndex]?.nodeBankAccounts[0].vault
if (
typeof tokenIndex !== 'number' ||
!mangoGroup ||
!mangoAccount ||
!wallet ||
!mangoGroup.rootBankAccounts[tokenIndex]
) {
return
}
if (
typeof tokenIndex === 'number' &&
mangoGroup &&
mangoAccount &&
wallet &&
mangoGroup.rootBankAccounts?.[tokenIndex] &&
mangoGroup.rootBankAccounts[tokenIndex] !== undefined &&
mangoGroup.rootBankAccounts[tokenIndex]?.nodeBankAccounts?.[0]
?.publicKey !== undefined &&
vault &&
publicKey &&
mangoGroup.rootBankAccounts[tokenIndex]?.nodeBankAccounts?.[0].vault !==
undefined
) {
@ -95,8 +97,8 @@ export async function withdraw({
mangoAccount,
wallet,
mangoGroup.tokens[tokenIndex].rootBank,
mangoGroup.rootBankAccounts[tokenIndex].nodeBankAccounts[0].publicKey,
mangoGroup.rootBankAccounts[tokenIndex].nodeBankAccounts[0].vault,
publicKey,
vault,
Number(amount),
allowBorrow
)