-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathuseRewardParams.ts
More file actions
34 lines (29 loc) · 875 Bytes
/
useRewardParams.ts
File metadata and controls
34 lines (29 loc) · 875 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import { Decimal } from "@cosmjs/math";
import { useQuery } from "@tanstack/react-query";
import invariant from "tiny-invariant";
import { useDexEnvironment } from "~/domains/core/envs";
import { useTokenRegistryQuery } from "~/domains/tokenRegistry";
import useSifnodeQuery from "~/hooks/useSifnodeQuery";
export function useRewardParams(
options: {
refetchInterval?: number;
enabled?: boolean;
} = {},
) {
const { data: paramsRes } = useSifnodeQuery("clp.getRewardParams", [{}]);
const { data: env } = useDexEnvironment();
return useQuery(
["rewardParams"],
() => {
invariant(paramsRes !== undefined, "paramsRes is undefined");
invariant(env !== undefined, "env is undefined");
return {
...paramsRes,
};
},
{
enabled: paramsRes !== undefined && env !== undefined,
...options,
},
);
}