> ## Documentation Index
> Fetch the complete documentation index at: https://frenglish.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# useGetSwapQuote

> Hook for fetching executable swap quotes with transaction data

## Import

```tsx theme={null}
import { useGetSwapQuote } from '@0xsequence/hooks'
```

## Usage

```tsx theme={null}
import { useGetSwapQuote } from '@0xsequence/hooks'

function SwapComponent() {
  const { data: swapQuote, isLoading } = useGetSwapQuote({
    userAddress: '0x123...',
    buyCurrencyAddress: '0x456...',
    sellCurrencyAddress: '0x789...',
    buyAmount: '1000000000000000000', 
    chainId: 1,
    includeApprove: true
  })

  if (isLoading) return <div>Loading...</div>

  return (
    <div>
      {swapQuote && (
        <div>
          Currency: {swapQuote.currencyAddress}
          Price: {swapQuote.price}
          Max Price: {swapQuote.maxPrice}
          Transaction Value: {swapQuote.transactionValue}
        </div>
      )}
    </div>
  )
}
```

## Return Type: `UseQueryResult<SwapQuote>`

The hook returns all properties from React Query's `UseQueryResult` with swap quote data. Here's the detailed structure:

```tsx theme={null}
interface SwapQuote {
  currencyAddress: string
  currencyBalance: string
  price: string
  maxPrice: string
  to: string
  transactionData: string
  transactionValue: string
  approveData: string
}
```

### Properties

#### data

`SwapQuote | undefined`

The swap quote object containing:

* `currencyAddress`: Address of the currency to be swapped
* `currencyBalance`: Balance of the currency in the user's wallet
* `price`: The current price for the swap
* `maxPrice`: Maximum price allowed for the swap (includes slippage)
* `to`: The target contract address for the swap
* `transactionData`: Encoded transaction data for executing the swap
* `transactionValue`: The value to be sent with the transaction
* `approveData`: Encoded approval transaction data (if includeApprove is true)

#### isLoading

`boolean`

Loading state for the data fetch.

#### isError

`boolean`

Error state indicating if the query failed.

#### error

`Error | null`

Any error that occurred during data fetching.

## Parameters

The hook accepts two parameters:

### args: `UseGetSwapQuoteArgs`

```tsx theme={null}
interface UseGetSwapQuoteArgs {
  userAddress: string
  buyCurrencyAddress: string
  sellCurrencyAddress: string
  buyAmount: string
  chainId: number
  includeApprove?: boolean
  slippagePercentage?: number
}
```

| Parameter             | Type      | Description                                             |
| --------------------- | --------- | ------------------------------------------------------- |
| `userAddress`         | `string`  | The address of the user's wallet                        |
| `buyCurrencyAddress`  | `string`  | The address of the currency to buy                      |
| `sellCurrencyAddress` | `string`  | The address of the currency to sell                     |
| `buyAmount`           | `string`  | The amount of currency to buy (in base units)           |
| `chainId`             | `number`  | The chain ID where the swap will occur                  |
| `includeApprove`      | `boolean` | (Optional) Whether to include approval transaction data |
| `slippagePercentage`  | `number`  | (Optional) Maximum allowed slippage percentage          |

### options: `HooksOptions`

```tsx theme={null}
interface HooksOptions {
  disabled?: boolean
  retry?: boolean
}
```

| Parameter  | Type      | Description                                             |
| ---------- | --------- | ------------------------------------------------------- |
| `disabled` | `boolean` | (Optional) Disable the query from automatically running |
| `retry`    | `boolean` | (Optional) Whether to retry failed queries              |
