/** * Copyright (c) TonTech. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * */ 'use client'; import { getSwapQuoteQueryOptions } from '@ton/appkit/queries'; import type { GetSwapQuoteData, GetSwapQuoteErrorType, GetSwapQuoteQueryConfig } from '@ton/appkit/queries'; import { useAppKit } from '../../settings'; import { useQuery } from '../../../libs/query'; import type { UseQueryReturnType } from '../../../libs/query'; import { useNetwork } from '../../network'; export type UseSwapQuoteParameters = GetSwapQuoteQueryConfig; export type UseSwapQuoteReturnType = UseQueryReturnType< selectData, GetSwapQuoteErrorType >; /** * Hook to get a swap quote for the given token pair and amount. */ export const useSwapQuote = ( parameters: UseSwapQuoteParameters = {}, ): UseSwapQuoteReturnType => { const appKit = useAppKit(); const walletNetwork = useNetwork(); return useQuery(getSwapQuoteQueryOptions(appKit, { ...parameters, network: parameters.network ?? walletNetwork })); };