2023-07-08 16:50:40 -07:00
|
|
|
import { useQuery } from '@tanstack/react-query'
|
|
|
|
import { fetchHourlyVolume } from 'utils/account'
|
|
|
|
import useMangoAccount from './useMangoAccount'
|
|
|
|
|
|
|
|
export default function useAccountHourlyVolumeStats() {
|
|
|
|
const { mangoAccountAddress } = useMangoAccount()
|
|
|
|
|
|
|
|
const {
|
|
|
|
data: hourlyVolumeData,
|
|
|
|
isLoading: loadingHourlyVolumeData,
|
|
|
|
isFetching: fetchingHourlyVolumeData,
|
|
|
|
} = useQuery(
|
|
|
|
['hourly-volume', mangoAccountAddress],
|
|
|
|
() => fetchHourlyVolume(mangoAccountAddress),
|
|
|
|
{
|
|
|
|
cacheTime: 1000 * 60 * 10,
|
|
|
|
staleTime: 1000 * 60,
|
|
|
|
retry: 3,
|
|
|
|
refetchOnWindowFocus: false,
|
|
|
|
enabled: !!mangoAccountAddress,
|
2023-07-21 11:47:53 -07:00
|
|
|
},
|
2023-07-08 16:50:40 -07:00
|
|
|
)
|
|
|
|
|
|
|
|
const loadingHourlyVolume =
|
|
|
|
fetchingHourlyVolumeData || loadingHourlyVolumeData
|
|
|
|
|
|
|
|
return {
|
|
|
|
hourlyVolumeData,
|
|
|
|
loadingHourlyVolume,
|
|
|
|
}
|
|
|
|
}
|