function usePrepareSwap(params): UsePrepareSwapResult;Defined in: account-kit/react/src/hooks/usePrepareSwap.ts:85
Hook for requesting swap quotes from a smart account.
This hook provides functionality to request swap quotes for token swaps.
import { usePrepareSwap } from "@account-kit/react";
const { prepareSwapAsync, isPreparingSwap, error } = usePrepareSwap();
// Request a swap quote
const quote = await prepareSwapAsync({
fromToken: "0x...",
toToken: "0x...",
minimumToAmount: "0x...",
});| Parameter | Type | Description |
|---|---|---|
| Configuration parameters for the hook |
An object containing:
prepareSwap: Function to request quote and prepare the swap synchronouslyprepareSwapAsync: Async function to request quote and prepare the swap (returns Promise)quote: The result of the last successful quote requestisPreparingSwap: Boolean indicating if a quote is currently being requestederror: Error from the last failed quote request, if any
- This hook only works with smart accounts and does not support EOA wallets
- The hook handles the quote request step of the swap flow
- The returned quote can be used with
useSignAndSendPreparedCallsto complete the swap.