diff --git a/components/AccountInfo.tsx b/components/AccountInfo.tsx index f8f125f6..81ac6ef0 100644 --- a/components/AccountInfo.tsx +++ b/components/AccountInfo.tsx @@ -347,7 +347,6 @@ export default function AccountInfo() { - {mangoAccount && mangoAccount.beingLiquidated ? (
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/components/GlobalNotification.tsx b/components/GlobalNotification.tsx index 6c08564d..aa3d9faa 100644 --- a/components/GlobalNotification.tsx +++ b/components/GlobalNotification.tsx @@ -1,7 +1,7 @@ import { useEffect, useState } from 'react' import sumBy from 'lodash/sumBy' import useInterval from '../hooks/useInterval' -import { SECONDS } from '../stores/useMangoStore' +import { CLUSTER, SECONDS } from '../stores/useMangoStore' import { useTranslation } from 'next-i18next' import { ExclamationIcon } from '@heroicons/react/outline' import { Connection } from '@solana/web3.js' @@ -43,7 +43,7 @@ const GlobalNotification = () => { getRecentPerformance(setShow, setTps) }, 45 * SECONDS) - if (show) { + if (show && CLUSTER == 'mainnet') { return (
diff --git a/hooks/useSrmAccount.tsx b/hooks/useSrmAccount.tsx index c920c009..1c5fe9c0 100644 --- a/hooks/useSrmAccount.tsx +++ b/hooks/useSrmAccount.tsx @@ -3,6 +3,7 @@ import useMangoStore from '../stores/useMangoStore' import { getMultipleAccounts, nativeToUi, + zeroKey, } from '@blockworks-foundation/mango-client' import { MSRM_DECIMALS, @@ -66,7 +67,9 @@ const useSrmAccount = () => { ) setSrmAccount(srmAccountInfo.accountInfo) - setMsrmAccount(msrmAccountInfo.accountInfo) + if (!msrmPk.equals(zeroKey)) { + setMsrmAccount(msrmAccountInfo.accountInfo) + } } fetchAccounts() diff --git a/package.json b/package.json index 0e4fb512..4c99664a 100644 --- a/package.json +++ b/package.json @@ -5,7 +5,8 @@ "version": "1.0.0", "scripts": { "dev": "next dev", - "devnet": "NEXT_PUBLIC_CLUSTER=devnet NEXT_PUBLIC_ENDPOINT=https://mango.devnet.rpcpool.com/ NEXT_PUBLIC_GROUP=devnet.2 next dev", + "devnet": "NEXT_PUBLIC_CLUSTER=devnet NEXT_PUBLIC_ENDPOINT=https://mango.devnet.rpcpool.com/ NEXT_PUBLIC_GROUP=devnet.4 next dev", + "testnet": "NEXT_PUBLIC_CLUSTER=testnet NEXT_PUBLIC_ENDPOINT=https://api.testnet.solana.com NEXT_PUBLIC_GROUP=testnet.0 next dev", "build": "next build", "start": "next start", "prepare": "husky install", @@ -17,7 +18,7 @@ "analyze": "ANALYZE=true yarn build" }, "dependencies": { - "@blockworks-foundation/mango-client": "^3.5.5", + "@blockworks-foundation/mango-client": "^3.5.7", "@headlessui/react": "^0.0.0-insiders.2dbc38c", "@heroicons/react": "^1.0.0", "@jup-ag/react-hook": "^1.0.0-beta.22", 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 diff --git a/stores/useMangoStore.tsx b/stores/useMangoStore.tsx index 6a69ff3d..80a99ea2 100644 --- a/stores/useMangoStore.tsx +++ b/stores/useMangoStore.tsx @@ -63,9 +63,15 @@ export const ENDPOINTS: EndpointInfo[] = [ websocket: 'https://api.devnet.solana.com', custom: false, }, + { + name: 'testnet', + url: 'https://api.testnet.solana.com', + websocket: 'https://api.testnet.solana.com', + custom: false, + }, ] -type ClusterType = 'mainnet' | 'devnet' +type ClusterType = 'mainnet' | 'devnet' | 'testnet' const DEFAULT_MANGO_GROUP_NAME = process.env.NEXT_PUBLIC_GROUP || 'mainnet.1' export const CLUSTER = DEFAULT_MANGO_GROUP_NAME.split('.')[0] as ClusterType const ENDPOINT = ENDPOINTS.find((e) => e.name === CLUSTER) as EndpointInfo diff --git a/yarn.lock b/yarn.lock index c503cb65..103bf8e6 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1008,10 +1008,10 @@ "@babel/helper-validator-identifier" "^7.16.7" to-fast-properties "^2.0.0" -"@blockworks-foundation/mango-client@^3.5.5": - version "3.5.5" - resolved "https://registry.yarnpkg.com/@blockworks-foundation/mango-client/-/mango-client-3.5.5.tgz#de71141571e97acae5165b8d94d1149b67f00e4f" - integrity sha512-FSGSo8rqWthfa1ClLmbFrZr6J7iEpw+/rrI04x3a4pPZwpQfiIRaBlwc5SCrD7+q+DR1MD+9vFDRxBpU9hKwfw== +"@blockworks-foundation/mango-client@^3.5.7": + version "3.5.7" + resolved "https://registry.yarnpkg.com/@blockworks-foundation/mango-client/-/mango-client-3.5.7.tgz#14a2ac00f2bec9198293179d507358f8f6f916d9" + integrity sha512-Yc9UEjEJBaoaV6ZvbAhAZAUYQr/fpjGrub1uUuQYmtiknZwfLb1kZo01+Rfbs/YpMfyZoKTAGHg2ianAMITT6A== dependencies: "@project-serum/anchor" "^0.21.0" "@project-serum/serum" "0.13.55"