From 5d5856226cd9e24064a5a203050250da04758226 Mon Sep 17 00:00:00 2001 From: saml33 Date: Sun, 12 Jun 2022 12:01:35 +1000 Subject: [PATCH] add unsettled balances to close account --- components/CloseAccountModal.tsx | 16 +++++++++++++++- public/locales/en/close-account.json | 7 ++++--- public/locales/es/close-account.json | 1 + public/locales/zh/close-account.json | 1 + public/locales/zh_tw/close-account.json | 1 + 5 files changed, 22 insertions(+), 4 deletions(-) diff --git a/components/CloseAccountModal.tsx b/components/CloseAccountModal.tsx index fec7e932..fe9e7adb 100644 --- a/components/CloseAccountModal.tsx +++ b/components/CloseAccountModal.tsx @@ -54,6 +54,11 @@ const CloseAccountModal: FunctionComponent = ({ const openOrders = useMangoStore((s) => s.selectedMangoAccount.openOrders) const setMangoStore = useMangoStore((s) => s.set) const activeAlerts = useMangoStore((s) => s.alerts.activeAlerts) + const spotBalances = useMangoStore((s) => s.selectedMangoAccount.spotBalances) + + const unsettledBalances = spotBalances.filter( + (bal) => bal.unsettled && bal.unsettled > 0 + ) const fetchTotalAccountSOL = useCallback(async () => { if (!mangoAccount) { @@ -162,7 +167,10 @@ const CloseAccountModal: FunctionComponent = ({ } const isDisabled = - (openOrders && openOrders.length > 0) || hasBorrows || hasOpenPositions + (openOrders && openOrders.length > 0) || + hasBorrows || + hasOpenPositions || + !!unsettledBalances.length return ( @@ -240,6 +248,12 @@ const CloseAccountModal: FunctionComponent = ({ {t('close-account:close-open-orders')} ) : null} + {unsettledBalances.length ? ( +
+ + {t('close-account:settle-balances')} +
+ ) : null} ) : null} diff --git a/public/locales/en/close-account.json b/public/locales/en/close-account.json index 93430e27..2655fde2 100644 --- a/public/locales/en/close-account.json +++ b/public/locales/en/close-account.json @@ -5,12 +5,13 @@ "close-account": "Close Account", "close-all-borrows": "Close all borrows", "close-open-orders": "Close all open orders", - "close-perp-positions": "Close and settle all Perp positons", + "close-perp-positions": "Close and settle all futures positons", "closing-account-will": "Closing your Mango Account will:", - "delete-your-account": "Delete your Mango account", - "error-deleting-account": "Error deleting account", + "delete-your-account": "Delete your Mango Account", + "error-deleting-account": "Error deleting your Mango Account", "goodbye": "Until next time 👋", "recover-x-sol": "Recover {{amount}} SOL (rent for your account)", + "settle-balances": "Settle all balances", "transaction-confirmed": "Transaction Confirmed", "withdraw-assets-worth": "Withdraw assets worth {{value}}" } \ No newline at end of file diff --git a/public/locales/es/close-account.json b/public/locales/es/close-account.json index 93430e27..555c6600 100644 --- a/public/locales/es/close-account.json +++ b/public/locales/es/close-account.json @@ -11,6 +11,7 @@ "error-deleting-account": "Error deleting account", "goodbye": "Until next time 👋", "recover-x-sol": "Recover {{amount}} SOL (rent for your account)", + "settle-balances": "Settle all balances", "transaction-confirmed": "Transaction Confirmed", "withdraw-assets-worth": "Withdraw assets worth {{value}}" } \ No newline at end of file diff --git a/public/locales/zh/close-account.json b/public/locales/zh/close-account.json index 6583007e..d3b26354 100644 --- a/public/locales/zh/close-account.json +++ b/public/locales/zh/close-account.json @@ -11,6 +11,7 @@ "error-deleting-account": "删除帐户出错", "goodbye": "再见 👋", "recover-x-sol": "收回{{amount}}SOL(帐户租金)", + "settle-balances": "Settle all balances", "transaction-confirmed": "交易成功", "withdraw-assets-worth": "将总价值{{value}}提出到您的钱包" } \ No newline at end of file diff --git a/public/locales/zh_tw/close-account.json b/public/locales/zh_tw/close-account.json index 712d10cf..8153c24b 100644 --- a/public/locales/zh_tw/close-account.json +++ b/public/locales/zh_tw/close-account.json @@ -11,6 +11,7 @@ "error-deleting-account": "刪除帳戶出錯", "goodbye": "再見 👋", "recover-x-sol": "收回{{amount}}SOL(帳戶租金)", + "settle-balances": "Settle all balances", "transaction-confirmed": "交易成功", "withdraw-assets-worth": "將總價值{{value}}提出到您的錢包" } \ No newline at end of file