reduce load on rpc
This commit is contained in:
parent
ec04c38fc7
commit
224b1925ad
|
@ -10,6 +10,7 @@ import {
|
||||||
|
|
||||||
import useInterval from './useInterval'
|
import useInterval from './useInterval'
|
||||||
import useLocalStorageState from './useLocalStorageState'
|
import useLocalStorageState from './useLocalStorageState'
|
||||||
|
import usePool from './usePool'
|
||||||
|
|
||||||
const SECONDS = 1000
|
const SECONDS = 1000
|
||||||
|
|
||||||
|
@ -22,6 +23,8 @@ export default function useWallet() {
|
||||||
set: setWalletStore,
|
set: setWalletStore,
|
||||||
actions,
|
actions,
|
||||||
} = useWalletStore((state) => state)
|
} = useWalletStore((state) => state)
|
||||||
|
|
||||||
|
const { endIdo } = usePool()
|
||||||
const [savedProviderUrl, setSavedProviderUrl] = useLocalStorageState(
|
const [savedProviderUrl, setSavedProviderUrl] = useLocalStorageState(
|
||||||
'walletProvider',
|
'walletProvider',
|
||||||
DEFAULT_PROVIDER.url
|
DEFAULT_PROVIDER.url
|
||||||
|
@ -109,9 +112,12 @@ export default function useWallet() {
|
||||||
|
|
||||||
// refresh usdc vault regularly
|
// refresh usdc vault regularly
|
||||||
useInterval(async () => {
|
useInterval(async () => {
|
||||||
|
if (endIdo.isAfter()) {
|
||||||
await actions.fetchUsdcVault()
|
await actions.fetchUsdcVault()
|
||||||
|
} else {
|
||||||
await actions.fetchMNGOVault()
|
await actions.fetchMNGOVault()
|
||||||
await actions.fetchRedeemableMint()
|
await actions.fetchRedeemableMint()
|
||||||
|
}
|
||||||
}, 10 * SECONDS)
|
}, 10 * SECONDS)
|
||||||
|
|
||||||
return { connected, wallet }
|
return { connected, wallet }
|
||||||
|
|
Loading…
Reference in New Issue