hide pnl for private non-owned mangoAccounts
This commit is contained in:
parent
5c0a6e2955
commit
fcf9a36c21
|
@ -19,6 +19,8 @@ import Change from '@components/shared/Change'
|
|||
import SheenLoader from '@components/shared/SheenLoader'
|
||||
import { PerformanceDataItem } from 'types'
|
||||
import useAccountHourlyVolumeStats from 'hooks/useAccountHourlyVolumeStats'
|
||||
import { useHiddenMangoAccounts } from 'hooks/useHiddenMangoAccounts'
|
||||
import { useWallet } from '@solana/wallet-adapter-react'
|
||||
|
||||
const AccountHeroStats = ({
|
||||
accountPnl,
|
||||
|
@ -38,6 +40,12 @@ const AccountHeroStats = ({
|
|||
const { mangoAccount, mangoAccountAddress } = useMangoAccount()
|
||||
const { hourlyVolumeData, loadingHourlyVolume } =
|
||||
useAccountHourlyVolumeStats()
|
||||
const { hiddenAccounts } = useHiddenMangoAccounts()
|
||||
const { connected } = useWallet()
|
||||
const accountHidden =
|
||||
!connected &&
|
||||
mangoAccountAddress &&
|
||||
hiddenAccounts?.includes(mangoAccountAddress)
|
||||
|
||||
const totalInterestData = mangoStore(
|
||||
(s) => s.mangoAccount.interestTotals.data,
|
||||
|
@ -314,7 +322,7 @@ const AccountHeroStats = ({
|
|||
>
|
||||
<p className="tooltip-underline">{t('pnl')}</p>
|
||||
</Tooltip>
|
||||
{mangoAccountAddress ? (
|
||||
{mangoAccountAddress && !accountHidden ? (
|
||||
<div className="flex items-center space-x-3">
|
||||
<Tooltip
|
||||
className="hidden md:block"
|
||||
|
@ -345,17 +353,35 @@ const AccountHeroStats = ({
|
|||
</div>
|
||||
) : null}
|
||||
</div>
|
||||
<p className="mb-0.5 mt-1 text-left text-2xl font-bold text-th-fgd-1 lg:text-xl xl:text-2xl">
|
||||
<FormatNumericValue
|
||||
value={accountPnl}
|
||||
decimals={2}
|
||||
isUsd={true}
|
||||
/>
|
||||
</p>
|
||||
<div className="flex space-x-1.5">
|
||||
<Change change={rollingDailyPnlChange} prefix="$" size="small" />
|
||||
<p className="text-xs text-th-fgd-4">{t('rolling-change')}</p>
|
||||
</div>
|
||||
{!accountHidden ? (
|
||||
<>
|
||||
<p className="mb-0.5 mt-1 text-left text-2xl font-bold text-th-fgd-1 lg:text-xl xl:text-2xl">
|
||||
<FormatNumericValue
|
||||
value={accountPnl}
|
||||
decimals={2}
|
||||
isUsd={true}
|
||||
/>
|
||||
</p>
|
||||
<div className="flex space-x-1.5">
|
||||
<Change
|
||||
change={rollingDailyPnlChange}
|
||||
prefix="$"
|
||||
size="small"
|
||||
/>
|
||||
<p className="text-xs text-th-fgd-4">{t('rolling-change')}</p>
|
||||
</div>
|
||||
</>
|
||||
) : (
|
||||
<>
|
||||
<p className="mb-0.5 mt-1 text-left text-2xl font-bold text-th-fgd-1 lg:text-xl xl:text-2xl">
|
||||
<FormatNumericValue value={0} decimals={2} isUsd={true} />
|
||||
</p>
|
||||
<div className="flex space-x-1.5">
|
||||
<Change change={0} prefix="$" size="small" />
|
||||
<p className="text-xs text-th-fgd-4">{t('rolling-change')}</p>
|
||||
</div>
|
||||
</>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
<div className="col-span-6 border-t border-th-bkg-3 py-3 pl-6 pr-4 md:col-span-3 md:border-l lg:col-span-2 lg:border-l-0 2xl:col-span-1 2xl:border-l 2xl:border-t-0">
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
import HideMangoAccount from '@components/account/HideMangoAccount'
|
||||
import MangoAccountSizeModal from '@components/modals/MangoAccountSizeModal'
|
||||
import { LinkButton } from '@components/shared/Button'
|
||||
import TokenLogo from '@components/shared/TokenLogo'
|
||||
|
@ -286,6 +287,7 @@ const AccountSettings = () => {
|
|||
</Tooltip>
|
||||
<p className="font-mono text-th-fgd-2">{availablePerpOo}</p>
|
||||
</div> */}
|
||||
<HideMangoAccount />
|
||||
{showAccountSizeModal ? (
|
||||
<MangoAccountSizeModal
|
||||
isOpen={showAccountSizeModal}
|
||||
|
|
|
@ -27,7 +27,6 @@ import {
|
|||
import mangoStore from '@store/mangoStore'
|
||||
import Switch from '@components/forms/Switch'
|
||||
import { CUSTOM_SKINS } from 'utils/theme'
|
||||
import HideMangoAccount from '@components/account/HideMangoAccount'
|
||||
|
||||
const NOTIFICATION_POSITIONS = [
|
||||
'bottom-left',
|
||||
|
|
|
@ -0,0 +1,33 @@
|
|||
import { useQuery } from '@tanstack/react-query'
|
||||
import { MANGO_DATA_API_URL } from 'utils/constants'
|
||||
|
||||
const fetchAllHiddenMangoAccounts = async () => {
|
||||
// returns Promise<string[]>
|
||||
try {
|
||||
const hideResponse = await fetch(
|
||||
`${MANGO_DATA_API_URL}/user-data/private-accounts`,
|
||||
)
|
||||
const res = await hideResponse.json()
|
||||
return res?.private_accounts ?? []
|
||||
} catch (e) {
|
||||
console.log('Failed to fetch spot volume', e)
|
||||
}
|
||||
}
|
||||
|
||||
export function useHiddenMangoAccounts() {
|
||||
const { data: hiddenAccounts, isLoading: loadingHiddenAccounts } = useQuery(
|
||||
['all-hidden-accounts'],
|
||||
() => fetchAllHiddenMangoAccounts(),
|
||||
{
|
||||
cacheTime: 1000 * 60 * 10,
|
||||
staleTime: 1000 * 60,
|
||||
retry: 3,
|
||||
refetchOnWindowFocus: false,
|
||||
},
|
||||
)
|
||||
|
||||
return {
|
||||
hiddenAccounts,
|
||||
loadingHiddenAccounts,
|
||||
}
|
||||
}
|
|
@ -2,7 +2,7 @@
|
|||
"assets": "Assets",
|
||||
"assets-liabilities": "Assets & Liabilities",
|
||||
"collateral-value": "Collateral Value",
|
||||
"cumulative-interest-chart": "Cumulative Interst Chart",
|
||||
"cumulative-interest-chart": "Cumulative Interest Chart",
|
||||
"daily-volume": "24h Volume",
|
||||
"export": "Export {{dataType}}",
|
||||
"funding-chart": "Funding Chart",
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
"assets": "Assets",
|
||||
"assets-liabilities": "Assets & Liabilities",
|
||||
"collateral-value": "Collateral Value",
|
||||
"cumulative-interest-chart": "Cumulative Interst Chart",
|
||||
"cumulative-interest-chart": "Cumulative Interest Chart",
|
||||
"daily-volume": "24h Volume",
|
||||
"export": "Export {{dataType}}",
|
||||
"funding-chart": "Funding Chart",
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
"assets": "Assets",
|
||||
"assets-liabilities": "Assets & Liabilities",
|
||||
"collateral-value": "Collateral Value",
|
||||
"cumulative-interest-chart": "Cumulative Interst Chart",
|
||||
"cumulative-interest-chart": "Cumulative Interest Chart",
|
||||
"daily-volume": "24h Volume",
|
||||
"export": "Export {{dataType}}",
|
||||
"funding-chart": "Funding Chart",
|
||||
|
|
Loading…
Reference in New Issue