UNPKG

@reservoir0x/relay-kit-hooks

Version:

Relay is the Fastest and Cheapest Way to Bridge and Transact Across Chains.

23 lines 864 B
import { MAINNET_RELAY_API, setParams } from '@reservoir0x/relay-sdk'; import fetcher from '../fetcher.js'; import { useQuery } from '@tanstack/react-query'; import { useMemo } from 'react'; export const queryTokenPrice = function (baseApiUrl = MAINNET_RELAY_API, options, headers) { const url = new URL(`${baseApiUrl}/currencies/token/price`); setParams(url, options ?? {}); return fetcher(url.href, headers); }; export default function (baseApiUrl, options, queryOptions) { const response = useQuery({ queryKey: ['useTokenPrice', options], queryFn: () => queryTokenPrice(baseApiUrl, options), retry: false, ...queryOptions }); return useMemo(() => { return { ...response }; }, [response.data, response.error, response.isLoading]); } //# sourceMappingURL=useTokenPrice.js.map