From 224b1925ad032fcf4e66f4b8d255cdf636db2dad Mon Sep 17 00:00:00 2001 From: Maximilian Schneider Date: Wed, 11 Aug 2021 22:55:05 +0200 Subject: [PATCH] reduce load on rpc --- hooks/useWallet.tsx | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/hooks/useWallet.tsx b/hooks/useWallet.tsx index 2f1d735..205e04f 100644 --- a/hooks/useWallet.tsx +++ b/hooks/useWallet.tsx @@ -10,6 +10,7 @@ import { import useInterval from './useInterval' import useLocalStorageState from './useLocalStorageState' +import usePool from './usePool' const SECONDS = 1000 @@ -22,6 +23,8 @@ export default function useWallet() { set: setWalletStore, actions, } = useWalletStore((state) => state) + + const { endIdo } = usePool() const [savedProviderUrl, setSavedProviderUrl] = useLocalStorageState( 'walletProvider', DEFAULT_PROVIDER.url @@ -109,9 +112,12 @@ export default function useWallet() { // refresh usdc vault regularly useInterval(async () => { - await actions.fetchUsdcVault() - await actions.fetchMNGOVault() - await actions.fetchRedeemableMint() + if (endIdo.isAfter()) { + await actions.fetchUsdcVault() + } else { + await actions.fetchMNGOVault() + await actions.fetchRedeemableMint() + } }, 10 * SECONDS) return { connected, wallet }