import type { StakingConfig } from '@sodax/sdk'; import { useQuery, type UseQueryResult } from '@tanstack/react-query'; import { useSodaxContext } from '../shared/useSodaxContext.js'; import type { ReadHookParams } from '../shared/types.js'; export type UseStakingConfigParams = ReadHookParams; /** * React hook to fetch the global staking config (unstaking period, min unstaking period, max * penalty). Hub-only read; no chain context required. Throws on `!ok`. */ export function useStakingConfig({ queryOptions, }: UseStakingConfigParams = {}): UseQueryResult { const { sodax } = useSodaxContext(); return useQuery({ queryKey: ['staking', 'config'], queryFn: async () => { const result = await sodax.staking.getStakingConfig(); if (!result.ok) throw result.error; return result.value; }, staleTime: Number.POSITIVE_INFINITY, ...queryOptions, }); }