show sol balance warning when connected

This commit is contained in:
saml33 2022-11-19 20:18:01 +11:00
parent 8384bca7e0
commit f2bdd7a54b
1 changed files with 7 additions and 5 deletions

View File

@ -1,16 +1,18 @@
import { TokenInstructions } from '@project-serum/serum'
import { useWallet } from '@solana/wallet-adapter-react'
import mangoStore from '@store/mangoStore'
import { useMemo } from 'react'
import { MIN_SOL_BALANCE } from 'utils/constants'
export default function useSolBalance() {
const walletTokens = mangoStore((s) => s.wallet.tokens)
const { connected } = useWallet()
const solBalance: number = useMemo(() => {
return (
walletTokens.find((t) =>
t.mint.equals(TokenInstructions.WRAPPED_SOL_MINT)
)?.uiAmount || 0
)
return connected
? walletTokens.find((t) =>
t.mint.equals(TokenInstructions.WRAPPED_SOL_MINT)
)?.uiAmount || 0
: 100
}, [walletTokens])
const maxSolDeposit: number = useMemo(() => {