reduce load on rpc

This commit is contained in:
Maximilian Schneider 2021-08-11 22:55:05 +02:00
parent ec04c38fc7
commit 224b1925ad
1 changed files with 9 additions and 3 deletions

View File

@ -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 }