-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathhooks.ts
More file actions
37 lines (31 loc) · 962 Bytes
/
hooks.ts
File metadata and controls
37 lines (31 loc) · 962 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
35
36
37
import { ByTokenId, type ConditionalActivation, type LiveUpdateParams } from "@/common/types";
import * as generatedClient from "./internal/client.generated";
import { REQUEST_CONFIG } from "./internal/config";
/**
* https://prices.intear.tech/swagger-ui/#/Token%20Prices/get_get_token_price
*/
export const useTokenUsdPrice = ({
enabled = true,
live = false,
tokenId,
}: ByTokenId & ConditionalActivation & LiveUpdateParams) => {
const queryResult = generatedClient.useGetSuperPrecisePrice(
{ token_id: tokenId },
{
...REQUEST_CONFIG,
swr: {
enabled,
shouldRetryOnError: (err) => err.status !== 404,
...(live
? {}
: {
revalidateIfStale: false,
revalidateOnFocus: false,
revalidateOnMount: false,
revalidateOnReconnect: false,
}),
},
},
);
return { ...queryResult, data: queryResult.data?.data };
};