reload wallet balances after borrow
This commit is contained in:
parent
6a1a55adbc
commit
18decda62c
|
@ -10,6 +10,7 @@ import {
|
||||||
import Decimal from 'decimal.js'
|
import Decimal from 'decimal.js'
|
||||||
import { useTranslation } from 'next-i18next'
|
import { useTranslation } from 'next-i18next'
|
||||||
import Image from 'next/legacy/image'
|
import Image from 'next/legacy/image'
|
||||||
|
import { Wallet } from '@project-serum/anchor'
|
||||||
import React, { useCallback, useMemo, useState } from 'react'
|
import React, { useCallback, useMemo, useState } from 'react'
|
||||||
import NumberFormat, {
|
import NumberFormat, {
|
||||||
NumberFormatValues,
|
NumberFormatValues,
|
||||||
|
@ -63,7 +64,7 @@ function BorrowForm({ onSuccess, token }: BorrowFormProps) {
|
||||||
const [sizePercentage, setSizePercentage] = useState('')
|
const [sizePercentage, setSizePercentage] = useState('')
|
||||||
const { mangoTokens } = useJupiterMints()
|
const { mangoTokens } = useJupiterMints()
|
||||||
const { mangoAccount } = useMangoAccount()
|
const { mangoAccount } = useMangoAccount()
|
||||||
const { connected } = useWallet()
|
const { connected, wallet } = useWallet()
|
||||||
const { handleConnect } = useEnhancedWallet()
|
const { handleConnect } = useEnhancedWallet()
|
||||||
|
|
||||||
const bank = useMemo(() => {
|
const bank = useMemo(() => {
|
||||||
|
@ -124,7 +125,7 @@ function BorrowForm({ onSuccess, token }: BorrowFormProps) {
|
||||||
setShowTokenList(false)
|
setShowTokenList(false)
|
||||||
}
|
}
|
||||||
|
|
||||||
const handleBorrow = async () => {
|
const handleBorrow = useCallback(async () => {
|
||||||
const client = mangoStore.getState().client
|
const client = mangoStore.getState().client
|
||||||
const group = mangoStore.getState().group
|
const group = mangoStore.getState().group
|
||||||
const mangoAccount = mangoStore.getState().mangoAccount.current
|
const mangoAccount = mangoStore.getState().mangoAccount.current
|
||||||
|
@ -145,6 +146,7 @@ function BorrowForm({ onSuccess, token }: BorrowFormProps) {
|
||||||
txid: tx,
|
txid: tx,
|
||||||
})
|
})
|
||||||
await actions.reloadMangoAccount()
|
await actions.reloadMangoAccount()
|
||||||
|
actions.fetchWalletTokens(wallet!.adapter as unknown as Wallet)
|
||||||
setSubmitting(false)
|
setSubmitting(false)
|
||||||
onSuccess()
|
onSuccess()
|
||||||
} catch (e: any) {
|
} catch (e: any) {
|
||||||
|
@ -157,7 +159,7 @@ function BorrowForm({ onSuccess, token }: BorrowFormProps) {
|
||||||
})
|
})
|
||||||
setSubmitting(false)
|
setSubmitting(false)
|
||||||
}
|
}
|
||||||
}
|
}, [bank, inputAmount, onSuccess, wallet])
|
||||||
|
|
||||||
const banks = useMemo(() => {
|
const banks = useMemo(() => {
|
||||||
if (mangoAccount) {
|
if (mangoAccount) {
|
||||||
|
|
Loading…
Reference in New Issue