hide action buttons for unowned accounts
This commit is contained in:
parent
0b4da01ee1
commit
6a05e60376
|
@ -34,6 +34,7 @@ import BankAmountWithValue from './shared/BankAmountWithValue'
|
||||||
import useBanksWithBalances, {
|
import useBanksWithBalances, {
|
||||||
BankWithBalance,
|
BankWithBalance,
|
||||||
} from 'hooks/useBanksWithBalances'
|
} from 'hooks/useBanksWithBalances'
|
||||||
|
import useUnownedAccount from 'hooks/useUnownedAccount'
|
||||||
|
|
||||||
const TokenList = () => {
|
const TokenList = () => {
|
||||||
const { t } = useTranslation(['common', 'token', 'trade'])
|
const { t } = useTranslation(['common', 'token', 'trade'])
|
||||||
|
@ -399,7 +400,7 @@ const ActionsMenu = ({
|
||||||
const router = useRouter()
|
const router = useRouter()
|
||||||
const { mangoTokens } = useJupiterMints()
|
const { mangoTokens } = useJupiterMints()
|
||||||
const spotMarkets = mangoStore((s) => s.serumMarkets)
|
const spotMarkets = mangoStore((s) => s.serumMarkets)
|
||||||
const { connected } = useWallet()
|
const isUnownedAccount = useUnownedAccount()
|
||||||
|
|
||||||
const spotMarket = useMemo(() => {
|
const spotMarket = useMemo(() => {
|
||||||
return spotMarkets.find((m) => {
|
return spotMarkets.find((m) => {
|
||||||
|
@ -477,7 +478,7 @@ const ActionsMenu = ({
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
{mangoAccount && !connected ? null : (
|
{isUnownedAccount ? null : (
|
||||||
<IconDropMenu
|
<IconDropMenu
|
||||||
icon={<EllipsisHorizontalIcon className="h-5 w-5" />}
|
icon={<EllipsisHorizontalIcon className="h-5 w-5" />}
|
||||||
postion="leftBottom"
|
postion="leftBottom"
|
||||||
|
|
|
@ -24,6 +24,7 @@ import DepositWithdrawModal from './modals/DepositWithdrawModal'
|
||||||
import { useViewport } from 'hooks/useViewport'
|
import { useViewport } from 'hooks/useViewport'
|
||||||
import { breakpoints } from 'utils/theme'
|
import { breakpoints } from 'utils/theme'
|
||||||
import AccountsButton from './AccountsButton'
|
import AccountsButton from './AccountsButton'
|
||||||
|
import useUnownedAccount from 'hooks/useUnownedAccount'
|
||||||
// import ThemeSwitcher from './ThemeSwitcher'
|
// import ThemeSwitcher from './ThemeSwitcher'
|
||||||
|
|
||||||
const TopBar = () => {
|
const TopBar = () => {
|
||||||
|
@ -41,6 +42,7 @@ const TopBar = () => {
|
||||||
const { query } = router
|
const { query } = router
|
||||||
const { width } = useViewport()
|
const { width } = useViewport()
|
||||||
const isMobile = width ? width < breakpoints.sm : false
|
const isMobile = width ? width < breakpoints.sm : false
|
||||||
|
const isUnownedAccount = useUnownedAccount()
|
||||||
|
|
||||||
const handleCloseSetup = useCallback(() => {
|
const handleCloseSetup = useCallback(() => {
|
||||||
setShowUserSetup(false)
|
setShowUserSetup(false)
|
||||||
|
@ -112,7 +114,7 @@ const TopBar = () => {
|
||||||
{/* <div className="px-3 md:px-4">
|
{/* <div className="px-3 md:px-4">
|
||||||
<ThemeSwitcher />
|
<ThemeSwitcher />
|
||||||
</div> */}
|
</div> */}
|
||||||
{(mangoAccount && !connected) || (!connected && isMobile) ? null : (
|
{isUnownedAccount || (!connected && isMobile) ? null : (
|
||||||
<Button
|
<Button
|
||||||
onClick={() => handleDepositWithdrawModal('deposit')}
|
onClick={() => handleDepositWithdrawModal('deposit')}
|
||||||
secondary
|
secondary
|
||||||
|
|
|
@ -23,6 +23,7 @@ import { useWallet } from '@solana/wallet-adapter-react'
|
||||||
import CreateAccountModal from '@components/modals/CreateAccountModal'
|
import CreateAccountModal from '@components/modals/CreateAccountModal'
|
||||||
import { Popover, Transition } from '@headlessui/react'
|
import { Popover, Transition } from '@headlessui/react'
|
||||||
import ActionsLinkButton from './ActionsLinkButton'
|
import ActionsLinkButton from './ActionsLinkButton'
|
||||||
|
import useUnownedAccount from 'hooks/useUnownedAccount'
|
||||||
|
|
||||||
export const handleCopyAddress = (
|
export const handleCopyAddress = (
|
||||||
mangoAccount: MangoAccount,
|
mangoAccount: MangoAccount,
|
||||||
|
@ -37,7 +38,7 @@ export const handleCopyAddress = (
|
||||||
|
|
||||||
const AccountActions = () => {
|
const AccountActions = () => {
|
||||||
const { t } = useTranslation(['common', 'close-account'])
|
const { t } = useTranslation(['common', 'close-account'])
|
||||||
const { mangoAccount } = useMangoAccount()
|
const { mangoAccount, mangoAccountAddress } = useMangoAccount()
|
||||||
const [showCloseAccountModal, setShowCloseAccountModal] = useState(false)
|
const [showCloseAccountModal, setShowCloseAccountModal] = useState(false)
|
||||||
const [showEditAccountModal, setShowEditAccountModal] = useState(false)
|
const [showEditAccountModal, setShowEditAccountModal] = useState(false)
|
||||||
const [showBorrowModal, setShowBorrowModal] = useState(false)
|
const [showBorrowModal, setShowBorrowModal] = useState(false)
|
||||||
|
@ -45,9 +46,10 @@ const AccountActions = () => {
|
||||||
const [showDelegateModal, setShowDelegateModal] = useState(false)
|
const [showDelegateModal, setShowDelegateModal] = useState(false)
|
||||||
const [showCreateAccountModal, setShowCreateAccountModal] = useState(false)
|
const [showCreateAccountModal, setShowCreateAccountModal] = useState(false)
|
||||||
const { connected } = useWallet()
|
const { connected } = useWallet()
|
||||||
|
const isUnownedAccount = useUnownedAccount()
|
||||||
|
|
||||||
const handleBorrowModal = () => {
|
const handleBorrowModal = () => {
|
||||||
if (!connected || mangoAccount) {
|
if (mangoAccountAddress || !connected) {
|
||||||
setShowBorrowModal(true)
|
setShowBorrowModal(true)
|
||||||
} else {
|
} else {
|
||||||
setShowCreateAccountModal(true)
|
setShowCreateAccountModal(true)
|
||||||
|
@ -56,11 +58,11 @@ const AccountActions = () => {
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
{mangoAccount && !connected ? null : (
|
{isUnownedAccount ? null : (
|
||||||
<div className="flex items-center space-x-2">
|
<div className="flex items-center space-x-2">
|
||||||
<Button
|
<Button
|
||||||
className="flex w-1/3 items-center justify-center md:w-auto"
|
className="flex w-1/3 items-center justify-center md:w-auto"
|
||||||
disabled={!mangoAccount}
|
disabled={!mangoAccountAddress}
|
||||||
onClick={() => setShowRepayModal(true)}
|
onClick={() => setShowRepayModal(true)}
|
||||||
secondary
|
secondary
|
||||||
>
|
>
|
||||||
|
|
|
@ -26,6 +26,7 @@ import BankAmountWithValue from './BankAmountWithValue'
|
||||||
import useBanksWithBalances, {
|
import useBanksWithBalances, {
|
||||||
BankWithBalance,
|
BankWithBalance,
|
||||||
} from 'hooks/useBanksWithBalances'
|
} from 'hooks/useBanksWithBalances'
|
||||||
|
import useUnownedAccount from 'hooks/useUnownedAccount'
|
||||||
|
|
||||||
const BalancesTable = () => {
|
const BalancesTable = () => {
|
||||||
const { t } = useTranslation(['common', 'trade'])
|
const { t } = useTranslation(['common', 'trade'])
|
||||||
|
@ -195,6 +196,7 @@ export default BalancesTable
|
||||||
const Balance = ({ bank }: { bank: BankWithBalance }) => {
|
const Balance = ({ bank }: { bank: BankWithBalance }) => {
|
||||||
const { selectedMarket } = useSelectedMarket()
|
const { selectedMarket } = useSelectedMarket()
|
||||||
const { asPath } = useRouter()
|
const { asPath } = useRouter()
|
||||||
|
const isUnownedAccount = useUnownedAccount()
|
||||||
|
|
||||||
const tokenBank = bank.bank
|
const tokenBank = bank.bank
|
||||||
|
|
||||||
|
@ -293,7 +295,8 @@ const Balance = ({ bank }: { bank: BankWithBalance }) => {
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<p className="flex justify-end">
|
<p className="flex justify-end">
|
||||||
{asPath.includes('/trade') && isBaseOrQuote ? (
|
{!isUnownedAccount ? (
|
||||||
|
asPath.includes('/trade') && isBaseOrQuote ? (
|
||||||
<LinkButton
|
<LinkButton
|
||||||
className="font-normal underline-offset-4"
|
className="font-normal underline-offset-4"
|
||||||
onClick={() =>
|
onClick={() =>
|
||||||
|
@ -319,6 +322,12 @@ const Balance = ({ bank }: { bank: BankWithBalance }) => {
|
||||||
decimals={tokenBank.mintDecimals}
|
decimals={tokenBank.mintDecimals}
|
||||||
/>
|
/>
|
||||||
</LinkButton>
|
</LinkButton>
|
||||||
|
) : (
|
||||||
|
<FormatNumericValue
|
||||||
|
value={balance}
|
||||||
|
decimals={tokenBank.mintDecimals}
|
||||||
|
/>
|
||||||
|
)
|
||||||
) : (
|
) : (
|
||||||
<FormatNumericValue value={balance} decimals={tokenBank.mintDecimals} />
|
<FormatNumericValue value={balance} decimals={tokenBank.mintDecimals} />
|
||||||
)}
|
)}
|
||||||
|
|
|
@ -48,6 +48,7 @@ import useIpAddress from 'hooks/useIpAddress'
|
||||||
import { useEnhancedWallet } from '@components/wallet/EnhancedWalletProvider'
|
import { useEnhancedWallet } from '@components/wallet/EnhancedWalletProvider'
|
||||||
import SwapSettings from './SwapSettings'
|
import SwapSettings from './SwapSettings'
|
||||||
import InlineNotification from '@components/shared/InlineNotification'
|
import InlineNotification from '@components/shared/InlineNotification'
|
||||||
|
import useUnownedAccount from 'hooks/useUnownedAccount'
|
||||||
|
|
||||||
const MAX_DIGITS = 11
|
const MAX_DIGITS = 11
|
||||||
export const withValueLimit = (values: NumberFormatValues): boolean => {
|
export const withValueLimit = (values: NumberFormatValues): boolean => {
|
||||||
|
@ -69,6 +70,7 @@ const SwapForm = () => {
|
||||||
const { group } = useMangoGroup()
|
const { group } = useMangoGroup()
|
||||||
const [swapFormSizeUi] = useLocalStorageState(SIZE_INPUT_UI_KEY, 'slider')
|
const [swapFormSizeUi] = useLocalStorageState(SIZE_INPUT_UI_KEY, 'slider')
|
||||||
const { ipAllowed, ipCountry } = useIpAddress()
|
const { ipAllowed, ipCountry } = useIpAddress()
|
||||||
|
const isUnownedAccount = useUnownedAccount()
|
||||||
|
|
||||||
const {
|
const {
|
||||||
margin: useMargin,
|
margin: useMargin,
|
||||||
|
@ -327,10 +329,12 @@ const SwapForm = () => {
|
||||||
</div>
|
</div>
|
||||||
<div className="mb-2 flex items-end justify-between">
|
<div className="mb-2 flex items-end justify-between">
|
||||||
<p className="text-th-fgd-2 lg:text-base">{t('swap:pay')}</p>
|
<p className="text-th-fgd-2 lg:text-base">{t('swap:pay')}</p>
|
||||||
|
{!isUnownedAccount ? (
|
||||||
<MaxSwapAmount
|
<MaxSwapAmount
|
||||||
useMargin={useMargin}
|
useMargin={useMargin}
|
||||||
setAmountIn={(v) => setAmountInFormValue(v, true)}
|
setAmountIn={(v) => setAmountInFormValue(v, true)}
|
||||||
/>
|
/>
|
||||||
|
) : null}
|
||||||
</div>
|
</div>
|
||||||
<div className="mb-3 grid grid-cols-2" id="swap-step-two">
|
<div className="mb-3 grid grid-cols-2" id="swap-step-two">
|
||||||
<div className="col-span-1 rounded-lg rounded-r-none border border-r-0 border-th-input-border bg-th-input-bkg">
|
<div className="col-span-1 rounded-lg rounded-r-none border border-r-0 border-th-input-border bg-th-input-bkg">
|
||||||
|
|
|
@ -4,6 +4,7 @@ import { FadeInFadeOut } from '@components/shared/Transitions'
|
||||||
import mangoStore from '@store/mangoStore'
|
import mangoStore from '@store/mangoStore'
|
||||||
import useMangoAccount from 'hooks/useMangoAccount'
|
import useMangoAccount from 'hooks/useMangoAccount'
|
||||||
import useSelectedMarket from 'hooks/useSelectedMarket'
|
import useSelectedMarket from 'hooks/useSelectedMarket'
|
||||||
|
import useUnownedAccount from 'hooks/useUnownedAccount'
|
||||||
import { useTranslation } from 'next-i18next'
|
import { useTranslation } from 'next-i18next'
|
||||||
import { useCallback, useMemo } from 'react'
|
import { useCallback, useMemo } from 'react'
|
||||||
import { formatNumericValue } from 'utils/numbers'
|
import { formatNumericValue } from 'utils/numbers'
|
||||||
|
@ -28,6 +29,7 @@ const MaxSizeButton = ({
|
||||||
side,
|
side,
|
||||||
useMargin
|
useMargin
|
||||||
)
|
)
|
||||||
|
const isUnownedAccount = useUnownedAccount()
|
||||||
|
|
||||||
const perpMax = useMemo(() => {
|
const perpMax = useMemo(() => {
|
||||||
const group = mangoStore.getState().group
|
const group = mangoStore.getState().group
|
||||||
|
@ -108,7 +110,7 @@ const MaxSizeButton = ({
|
||||||
return (
|
return (
|
||||||
<div className="mb-2 mt-3 flex items-center justify-between">
|
<div className="mb-2 mt-3 flex items-center justify-between">
|
||||||
<p className="text-xs text-th-fgd-3">{t('trade:size')}</p>
|
<p className="text-xs text-th-fgd-3">{t('trade:size')}</p>
|
||||||
<FadeInFadeOut show={!!price}>
|
<FadeInFadeOut show={!!price && !isUnownedAccount}>
|
||||||
<MaxAmountButton
|
<MaxAmountButton
|
||||||
className="text-xs"
|
className="text-xs"
|
||||||
decimals={minOrderDecimals}
|
decimals={minOrderDecimals}
|
||||||
|
|
|
@ -27,6 +27,7 @@ import { useWallet } from '@solana/wallet-adapter-react'
|
||||||
import { PublicKey } from '@solana/web3.js'
|
import { PublicKey } from '@solana/web3.js'
|
||||||
import mangoStore from '@store/mangoStore'
|
import mangoStore from '@store/mangoStore'
|
||||||
import useMangoAccount from 'hooks/useMangoAccount'
|
import useMangoAccount from 'hooks/useMangoAccount'
|
||||||
|
import useUnownedAccount from 'hooks/useUnownedAccount'
|
||||||
import { useViewport } from 'hooks/useViewport'
|
import { useViewport } from 'hooks/useViewport'
|
||||||
import { useTranslation } from 'next-i18next'
|
import { useTranslation } from 'next-i18next'
|
||||||
import { ChangeEvent, useCallback, useState } from 'react'
|
import { ChangeEvent, useCallback, useState } from 'react'
|
||||||
|
@ -49,6 +50,7 @@ const OpenOrders = () => {
|
||||||
const showTableView = width ? width > breakpoints.md : false
|
const showTableView = width ? width > breakpoints.md : false
|
||||||
const { mangoAccountAddress } = useMangoAccount()
|
const { mangoAccountAddress } = useMangoAccount()
|
||||||
const { connected } = useWallet()
|
const { connected } = useWallet()
|
||||||
|
const isUnownedAccount = useUnownedAccount()
|
||||||
|
|
||||||
const findSerum3MarketPkInOpenOrders = (o: Order): string | undefined => {
|
const findSerum3MarketPkInOpenOrders = (o: Order): string | undefined => {
|
||||||
const openOrders = mangoStore.getState().mangoAccount.openOrders
|
const openOrders = mangoStore.getState().mangoAccount.openOrders
|
||||||
|
@ -237,7 +239,9 @@ const OpenOrders = () => {
|
||||||
<Th className="w-[16.67%] text-right">{t('trade:size')}</Th>
|
<Th className="w-[16.67%] text-right">{t('trade:size')}</Th>
|
||||||
<Th className="w-[16.67%] text-right">{t('price')}</Th>
|
<Th className="w-[16.67%] text-right">{t('price')}</Th>
|
||||||
<Th className="w-[16.67%] text-right">{t('value')}</Th>
|
<Th className="w-[16.67%] text-right">{t('value')}</Th>
|
||||||
<Th className="w-[16.67%] text-right"></Th>
|
{!isUnownedAccount ? (
|
||||||
|
<Th className="w-[16.67%] text-right" />
|
||||||
|
) : null}
|
||||||
</TrHead>
|
</TrHead>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
|
@ -332,6 +336,7 @@ const OpenOrders = () => {
|
||||||
isUsd
|
isUsd
|
||||||
/>
|
/>
|
||||||
</Td>
|
</Td>
|
||||||
|
{!isUnownedAccount ? (
|
||||||
<Td className="w-[16.67%]">
|
<Td className="w-[16.67%]">
|
||||||
<div className="flex justify-end space-x-2">
|
<div className="flex justify-end space-x-2">
|
||||||
{modifyOrderId !== o.orderId.toString() ? (
|
{modifyOrderId !== o.orderId.toString() ? (
|
||||||
|
@ -382,6 +387,7 @@ const OpenOrders = () => {
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
</Td>
|
</Td>
|
||||||
|
) : null}
|
||||||
</TrBody>
|
</TrBody>
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
@ -477,7 +483,7 @@ const OpenOrders = () => {
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
{connected ? (
|
{!isUnownedAccount ? (
|
||||||
<div className="flex items-center space-x-3 pl-8">
|
<div className="flex items-center space-x-3 pl-8">
|
||||||
<div className="flex items-center space-x-2">
|
<div className="flex items-center space-x-2">
|
||||||
{modifyOrderId !== o.orderId.toString() ? (
|
{modifyOrderId !== o.orderId.toString() ? (
|
||||||
|
|
|
@ -9,6 +9,7 @@ import mangoStore from '@store/mangoStore'
|
||||||
import useMangoAccount from 'hooks/useMangoAccount'
|
import useMangoAccount from 'hooks/useMangoAccount'
|
||||||
import useMangoGroup from 'hooks/useMangoGroup'
|
import useMangoGroup from 'hooks/useMangoGroup'
|
||||||
import useSelectedMarket from 'hooks/useSelectedMarket'
|
import useSelectedMarket from 'hooks/useSelectedMarket'
|
||||||
|
import useUnownedAccount from 'hooks/useUnownedAccount'
|
||||||
import { useTranslation } from 'next-i18next'
|
import { useTranslation } from 'next-i18next'
|
||||||
import { useCallback, useState } from 'react'
|
import { useCallback, useState } from 'react'
|
||||||
import { floorToDecimal, getDecimalCount } from 'utils/numbers'
|
import { floorToDecimal, getDecimalCount } from 'utils/numbers'
|
||||||
|
@ -28,6 +29,7 @@ const PerpPositions = () => {
|
||||||
const { selectedMarket } = useSelectedMarket()
|
const { selectedMarket } = useSelectedMarket()
|
||||||
const { connected } = useWallet()
|
const { connected } = useWallet()
|
||||||
const { mangoAccountAddress } = useMangoAccount()
|
const { mangoAccountAddress } = useMangoAccount()
|
||||||
|
const isUnownedAccount = useUnownedAccount()
|
||||||
|
|
||||||
const handlePositionClick = (positionSize: number, market: PerpMarket) => {
|
const handlePositionClick = (positionSize: number, market: PerpMarket) => {
|
||||||
const tradeForm = mangoStore.getState().tradeForm
|
const tradeForm = mangoStore.getState().tradeForm
|
||||||
|
@ -86,7 +88,7 @@ const PerpPositions = () => {
|
||||||
'pnl'
|
'pnl'
|
||||||
)}`}</Th>
|
)}`}</Th>
|
||||||
<Th className="text-right">{t('pnl')}</Th>
|
<Th className="text-right">{t('pnl')}</Th>
|
||||||
<Th />
|
{!isUnownedAccount ? <Th /> : null}
|
||||||
</TrHead>
|
</TrHead>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
|
@ -164,6 +166,7 @@ const PerpPositions = () => {
|
||||||
>
|
>
|
||||||
<FormatNumericValue value={cummulativePnl} isUsd />
|
<FormatNumericValue value={cummulativePnl} isUsd />
|
||||||
</Td>
|
</Td>
|
||||||
|
{!isUnownedAccount ? (
|
||||||
<Td className={`text-right`}>
|
<Td className={`text-right`}>
|
||||||
<Button
|
<Button
|
||||||
className="text-xs"
|
className="text-xs"
|
||||||
|
@ -174,6 +177,7 @@ const PerpPositions = () => {
|
||||||
Close
|
Close
|
||||||
</Button>
|
</Button>
|
||||||
</Td>
|
</Td>
|
||||||
|
) : null}
|
||||||
</TrBody>
|
</TrBody>
|
||||||
)
|
)
|
||||||
})}
|
})}
|
||||||
|
|
|
@ -17,6 +17,7 @@ import useMangoAccount from 'hooks/useMangoAccount'
|
||||||
import { useWallet } from '@solana/wallet-adapter-react'
|
import { useWallet } from '@solana/wallet-adapter-react'
|
||||||
import ConnectEmptyState from '@components/shared/ConnectEmptyState'
|
import ConnectEmptyState from '@components/shared/ConnectEmptyState'
|
||||||
import FormatNumericValue from '@components/shared/FormatNumericValue'
|
import FormatNumericValue from '@components/shared/FormatNumericValue'
|
||||||
|
import useUnownedAccount from 'hooks/useUnownedAccount'
|
||||||
|
|
||||||
const UnsettledTrades = ({
|
const UnsettledTrades = ({
|
||||||
unsettledSpotBalances,
|
unsettledSpotBalances,
|
||||||
|
@ -32,6 +33,7 @@ const UnsettledTrades = ({
|
||||||
const showTableView = width ? width > breakpoints.md : false
|
const showTableView = width ? width > breakpoints.md : false
|
||||||
const { mangoAccountAddress } = useMangoAccount()
|
const { mangoAccountAddress } = useMangoAccount()
|
||||||
const { connected } = useWallet()
|
const { connected } = useWallet()
|
||||||
|
const isUnownedAccount = useUnownedAccount()
|
||||||
|
|
||||||
const handleSettleSerumFunds = useCallback(async (mktAddress: string) => {
|
const handleSettleSerumFunds = useCallback(async (mktAddress: string) => {
|
||||||
const client = mangoStore.getState().client
|
const client = mangoStore.getState().client
|
||||||
|
@ -136,7 +138,9 @@ const UnsettledTrades = ({
|
||||||
<TrHead>
|
<TrHead>
|
||||||
<Th className="bg-th-bkg-1 text-left">{t('market')}</Th>
|
<Th className="bg-th-bkg-1 text-left">{t('market')}</Th>
|
||||||
<Th className="bg-th-bkg-1 text-right">{t('trade:amount')}</Th>
|
<Th className="bg-th-bkg-1 text-right">{t('trade:amount')}</Th>
|
||||||
|
{!isUnownedAccount ? (
|
||||||
<Th className="bg-th-bkg-1 text-right" />
|
<Th className="bg-th-bkg-1 text-right" />
|
||||||
|
) : null}
|
||||||
</TrHead>
|
</TrHead>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
|
@ -168,6 +172,7 @@ const UnsettledTrades = ({
|
||||||
) : null}
|
) : null}
|
||||||
</div>
|
</div>
|
||||||
</Td>
|
</Td>
|
||||||
|
{!isUnownedAccount ? (
|
||||||
<Td>
|
<Td>
|
||||||
<div className="flex justify-end">
|
<div className="flex justify-end">
|
||||||
<Tooltip content={t('trade:settle-funds')}>
|
<Tooltip content={t('trade:settle-funds')}>
|
||||||
|
@ -184,6 +189,7 @@ const UnsettledTrades = ({
|
||||||
</Tooltip>
|
</Tooltip>
|
||||||
</div>
|
</div>
|
||||||
</Td>
|
</Td>
|
||||||
|
) : null}
|
||||||
</TrBody>
|
</TrBody>
|
||||||
)
|
)
|
||||||
})}
|
})}
|
||||||
|
@ -203,6 +209,7 @@ const UnsettledTrades = ({
|
||||||
/>{' '}
|
/>{' '}
|
||||||
<span className="font-body text-th-fgd-4">USDC</span>
|
<span className="font-body text-th-fgd-4">USDC</span>
|
||||||
</Td>
|
</Td>
|
||||||
|
{!isUnownedAccount ? (
|
||||||
<Td>
|
<Td>
|
||||||
<div className="flex justify-end">
|
<div className="flex justify-end">
|
||||||
<Tooltip content={t('trade:settle-funds')}>
|
<Tooltip content={t('trade:settle-funds')}>
|
||||||
|
@ -219,6 +226,7 @@ const UnsettledTrades = ({
|
||||||
</Tooltip>
|
</Tooltip>
|
||||||
</div>
|
</div>
|
||||||
</Td>
|
</Td>
|
||||||
|
) : null}
|
||||||
</TrBody>
|
</TrBody>
|
||||||
)
|
)
|
||||||
})}
|
})}
|
||||||
|
@ -252,6 +260,7 @@ const UnsettledTrades = ({
|
||||||
<span className="font-body text-th-fgd-4">{quote}</span>
|
<span className="font-body text-th-fgd-4">{quote}</span>
|
||||||
</span>
|
</span>
|
||||||
) : null}
|
) : null}
|
||||||
|
{!isUnownedAccount ? (
|
||||||
<IconButton
|
<IconButton
|
||||||
onClick={() => handleSettleSerumFunds(mktAddress)}
|
onClick={() => handleSettleSerumFunds(mktAddress)}
|
||||||
size="medium"
|
size="medium"
|
||||||
|
@ -262,6 +271,7 @@ const UnsettledTrades = ({
|
||||||
<CheckIcon className="h-4 w-4" />
|
<CheckIcon className="h-4 w-4" />
|
||||||
)}
|
)}
|
||||||
</IconButton>
|
</IconButton>
|
||||||
|
) : null}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
|
|
|
@ -0,0 +1,17 @@
|
||||||
|
import { useWallet } from '@solana/wallet-adapter-react'
|
||||||
|
import { useMemo } from 'react'
|
||||||
|
import useMangoAccount from './useMangoAccount'
|
||||||
|
|
||||||
|
const useUnownedAccount = () => {
|
||||||
|
const { connected } = useWallet()
|
||||||
|
const { mangoAccountAddress } = useMangoAccount()
|
||||||
|
|
||||||
|
const isUnownedAccount = useMemo(() => {
|
||||||
|
if (connected) return false
|
||||||
|
return mangoAccountAddress && !connected
|
||||||
|
}, [connected, mangoAccountAddress])
|
||||||
|
|
||||||
|
return isUnownedAccount
|
||||||
|
}
|
||||||
|
|
||||||
|
export default useUnownedAccount
|
Loading…
Reference in New Issue