- onHoverMenu(showExpandChart, 'onMouseEnter')
- }
- onMouseLeave={() =>
- onHoverMenu(showExpandChart, 'onMouseLeave')
- }
+
+
+
+ {TABS.map((tab) => (
+
+ ))}
+
+
+ {activeTab === 'account-value' ? (
+
+
+
+ {animationSettings['number-scroll'] ? (
+ group && mangoAccount ? (
+
+ ) : (
+
+ )
+ ) : (
+
+ )}
+
+
+
+
+ {t('rolling-change')}
+
+
+
+ {!performanceLoading ? (
+ oneDayPerformanceData.length ? (
+
+ onHoverMenu(showExpandChart, 'onMouseEnter')
+ }
+ onMouseLeave={() =>
+ onHoverMenu(showExpandChart, 'onMouseLeave')
+ }
+ >
+
= 0
+ ? COLORS.UP[theme]
+ : COLORS.DOWN[theme]
+ }
+ data={oneDayPerformanceData.concat(latestAccountData)}
+ name="accountValue"
+ xKey="time"
+ yKey="account_equity"
+ />
+
+ handleShowAccountValueChart()}
+ >
+
+
+
+
+ ) : null
+ ) : mangoAccountAddress ? (
+
+
+
+ ) : null}
- ) : null
- ) : mangoAccountAddress ? (
-
-
-
- ) : null}
+ ) : null}
+ {activeTab === 'account:assets-liabilities' ? (
+
+ ) : null}
+
-
diff --git a/components/account/AssetsLiabilities.tsx b/components/account/AssetsLiabilities.tsx
new file mode 100644
index 00000000..b133489e
--- /dev/null
+++ b/components/account/AssetsLiabilities.tsx
@@ -0,0 +1,133 @@
+import { toUiDecimalsForQuote } from '@blockworks-foundation/mango-v4'
+import useMangoAccount from 'hooks/useMangoAccount'
+import useMangoGroup from 'hooks/useMangoGroup'
+import { useTranslation } from 'next-i18next'
+import { useTheme } from 'next-themes'
+import { useMemo } from 'react'
+import { Cell, Pie, PieChart } from 'recharts'
+import { COLORS } from 'styles/colors'
+import { formatCurrencyValue } from 'utils/numbers'
+import FlipNumbers from 'react-flip-numbers'
+import useLocalStorageState from 'hooks/useLocalStorageState'
+import { ANIMATION_SETTINGS_KEY } from 'utils/constants'
+import { INITIAL_ANIMATION_SETTINGS } from '@components/settings/AnimationSettings'
+
+const AssetsLiabilities = ({ isMobile }: { isMobile: boolean }) => {
+ const { t } = useTranslation('account')
+ const { group } = useMangoGroup()
+ const { mangoAccount } = useMangoAccount()
+ const { theme } = useTheme()
+ const [animationSettings] = useLocalStorageState(
+ ANIMATION_SETTINGS_KEY,
+ INITIAL_ANIMATION_SETTINGS
+ )
+
+ const [assetsValue, assetsRatio, liabsValue, liabsRatio] = useMemo(() => {
+ if (!group || !mangoAccount) return [0, 0, 0, 0]
+ const assets = toUiDecimalsForQuote(mangoAccount.getAssetsValue(group))
+ const liabs = toUiDecimalsForQuote(mangoAccount.getLiabsValue(group))
+ const assetsRatio = (assets / (assets + liabs)) * 100
+ const liabsRatio = 100 - assetsRatio
+ return [assets, assetsRatio, liabs, liabsRatio]
+ }, [group, mangoAccount])
+
+ const chartData = useMemo(() => {
+ return [
+ { name: 'assets', value: assetsValue },
+ { name: 'liabilities', value: liabsValue },
+ ]
+ }, [assetsValue, liabsValue])
+
+ const pieSizes = isMobile
+ ? { size: 160, outerRadius: 80, innerRadius: 64 }
+ : { size: 80, outerRadius: 40, innerRadius: 30 }
+ const { size, outerRadius, innerRadius } = pieSizes
+
+ return (
+
+ {mangoAccount ? (
+
+
+ {chartData.map((entry, index) => {
+ const fillColor =
+ entry.name === 'assets' ? COLORS.UP[theme] : COLORS.DOWN[theme]
+ return (
+ |
+ )
+ })}
+
+
+ ) : (
+
+ )}
+
+
+
+ {t('assets')}
+
+ {assetsRatio.toFixed()}%
+
+
+ {animationSettings['number-scroll'] ? (
+
+
+
+ ) : (
+
+ {formatCurrencyValue(assetsValue, 2)}
+
+ )}
+
+
+
+ {t('liabilities')}
+
+ {liabsRatio.toFixed()}%
+
+
+ {animationSettings['number-scroll'] ? (
+
+
+
+ ) : (
+
+ {formatCurrencyValue(liabsValue, 2)}
+
+ )}
+
+
+
+ )
+}
+
+export default AssetsLiabilities
diff --git a/public/locales/en/account.json b/public/locales/en/account.json
index 28d4646c..05e89aee 100644
--- a/public/locales/en/account.json
+++ b/public/locales/en/account.json
@@ -1,4 +1,7 @@
{
+ "assets": "Assets",
+ "assets-liabilities": "Assets & Liabilities",
+ "liabilities": "Liabilities",
"no-pnl-history": "No PnL History",
"pnl-chart": "PnL Chart",
"pnl-history": "PnL History",
diff --git a/public/locales/en/common.json b/public/locales/en/common.json
index 2070e900..afc8ab08 100644
--- a/public/locales/en/common.json
+++ b/public/locales/en/common.json
@@ -56,11 +56,13 @@
"delegate-account-info": "Account delegated to {{address}}",
"delegate-desc": "Delegate your Mango account to another wallet address",
"delegate-placeholder": "Enter a wallet address to delegate to",
+ "delete": "Delete",
"deposit": "Deposit",
"deposit-amount": "Deposit Amount",
"deposit-more-sol": "Your SOL wallet balance is too low. Add more to pay for transactions",
"deposit-rate": "Deposit APR",
"disconnect": "Disconnect",
+ "edit": "Edit",
"edit-account": "Edit Account Name",
"edit-profile-image": "Edit Profile Image",
"explorer": "Explorer",
@@ -88,6 +90,7 @@
"max": "Max",
"max-borrow": "Max Borrow",
"more": "More",
+ "new": "New",
"new-account": "New Account",
"new-account-failed": "Failed to create account",
"new-account-success": "Your new account is ready 😎",
diff --git a/public/locales/es/account.json b/public/locales/es/account.json
index 28d4646c..05e89aee 100644
--- a/public/locales/es/account.json
+++ b/public/locales/es/account.json
@@ -1,4 +1,7 @@
{
+ "assets": "Assets",
+ "assets-liabilities": "Assets & Liabilities",
+ "liabilities": "Liabilities",
"no-pnl-history": "No PnL History",
"pnl-chart": "PnL Chart",
"pnl-history": "PnL History",
diff --git a/public/locales/es/common.json b/public/locales/es/common.json
index 1da50ac2..88b50b99 100644
--- a/public/locales/es/common.json
+++ b/public/locales/es/common.json
@@ -56,11 +56,13 @@
"delegate-account-info": "Account delegated to {{address}}",
"delegate-desc": "Delegate your Mango account to another wallet address",
"delegate-placeholder": "Enter a wallet address to delegate to",
+ "delete": "Delete",
"deposit": "Deposit",
"deposit-amount": "Deposit Amount",
"deposit-more-sol": "Your SOL wallet balance is too low. Add more to pay for transactions",
"deposit-rate": "Deposit APR",
"disconnect": "Disconnect",
+ "edit": "Edit",
"edit-account": "Edit Account Name",
"edit-profile-image": "Edit Profile Image",
"explorer": "Explorer",
@@ -87,6 +89,7 @@
"max": "Max",
"max-borrow": "Max Borrow",
"more": "More",
+ "new": "New",
"new-account": "New Account",
"new-account-failed": "Failed to create account",
"new-account-success": "Your new account is ready 😎",
diff --git a/public/locales/ru/account.json b/public/locales/ru/account.json
index 28d4646c..05e89aee 100644
--- a/public/locales/ru/account.json
+++ b/public/locales/ru/account.json
@@ -1,4 +1,7 @@
{
+ "assets": "Assets",
+ "assets-liabilities": "Assets & Liabilities",
+ "liabilities": "Liabilities",
"no-pnl-history": "No PnL History",
"pnl-chart": "PnL Chart",
"pnl-history": "PnL History",
diff --git a/public/locales/ru/common.json b/public/locales/ru/common.json
index 1da50ac2..88b50b99 100644
--- a/public/locales/ru/common.json
+++ b/public/locales/ru/common.json
@@ -56,11 +56,13 @@
"delegate-account-info": "Account delegated to {{address}}",
"delegate-desc": "Delegate your Mango account to another wallet address",
"delegate-placeholder": "Enter a wallet address to delegate to",
+ "delete": "Delete",
"deposit": "Deposit",
"deposit-amount": "Deposit Amount",
"deposit-more-sol": "Your SOL wallet balance is too low. Add more to pay for transactions",
"deposit-rate": "Deposit APR",
"disconnect": "Disconnect",
+ "edit": "Edit",
"edit-account": "Edit Account Name",
"edit-profile-image": "Edit Profile Image",
"explorer": "Explorer",
@@ -87,6 +89,7 @@
"max": "Max",
"max-borrow": "Max Borrow",
"more": "More",
+ "new": "New",
"new-account": "New Account",
"new-account-failed": "Failed to create account",
"new-account-success": "Your new account is ready 😎",
diff --git a/public/locales/zh/account.json b/public/locales/zh/account.json
index 28d4646c..05e89aee 100644
--- a/public/locales/zh/account.json
+++ b/public/locales/zh/account.json
@@ -1,4 +1,7 @@
{
+ "assets": "Assets",
+ "assets-liabilities": "Assets & Liabilities",
+ "liabilities": "Liabilities",
"no-pnl-history": "No PnL History",
"pnl-chart": "PnL Chart",
"pnl-history": "PnL History",
diff --git a/public/locales/zh/common.json b/public/locales/zh/common.json
index 1da50ac2..88b50b99 100644
--- a/public/locales/zh/common.json
+++ b/public/locales/zh/common.json
@@ -56,11 +56,13 @@
"delegate-account-info": "Account delegated to {{address}}",
"delegate-desc": "Delegate your Mango account to another wallet address",
"delegate-placeholder": "Enter a wallet address to delegate to",
+ "delete": "Delete",
"deposit": "Deposit",
"deposit-amount": "Deposit Amount",
"deposit-more-sol": "Your SOL wallet balance is too low. Add more to pay for transactions",
"deposit-rate": "Deposit APR",
"disconnect": "Disconnect",
+ "edit": "Edit",
"edit-account": "Edit Account Name",
"edit-profile-image": "Edit Profile Image",
"explorer": "Explorer",
@@ -87,6 +89,7 @@
"max": "Max",
"max-borrow": "Max Borrow",
"more": "More",
+ "new": "New",
"new-account": "New Account",
"new-account-failed": "Failed to create account",
"new-account-success": "Your new account is ready 😎",
diff --git a/public/locales/zh_tw/account.json b/public/locales/zh_tw/account.json
index 28d4646c..05e89aee 100644
--- a/public/locales/zh_tw/account.json
+++ b/public/locales/zh_tw/account.json
@@ -1,4 +1,7 @@
{
+ "assets": "Assets",
+ "assets-liabilities": "Assets & Liabilities",
+ "liabilities": "Liabilities",
"no-pnl-history": "No PnL History",
"pnl-chart": "PnL Chart",
"pnl-history": "PnL History",
diff --git a/public/locales/zh_tw/common.json b/public/locales/zh_tw/common.json
index 1da50ac2..88b50b99 100644
--- a/public/locales/zh_tw/common.json
+++ b/public/locales/zh_tw/common.json
@@ -56,11 +56,13 @@
"delegate-account-info": "Account delegated to {{address}}",
"delegate-desc": "Delegate your Mango account to another wallet address",
"delegate-placeholder": "Enter a wallet address to delegate to",
+ "delete": "Delete",
"deposit": "Deposit",
"deposit-amount": "Deposit Amount",
"deposit-more-sol": "Your SOL wallet balance is too low. Add more to pay for transactions",
"deposit-rate": "Deposit APR",
"disconnect": "Disconnect",
+ "edit": "Edit",
"edit-account": "Edit Account Name",
"edit-profile-image": "Edit Profile Image",
"explorer": "Explorer",
@@ -87,6 +89,7 @@
"max": "Max",
"max-borrow": "Max Borrow",
"more": "More",
+ "new": "New",
"new-account": "New Account",
"new-account-failed": "Failed to create account",
"new-account-success": "Your new account is ready 😎",