> ## 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.

# useGetSwapPrices

> Hook for fetching available swap prices and currency information

## Import

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

## Usage

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

function SwapComponent() {
  const { data: swapPrices, isLoading } = useGetSwapPrices({
    userAddress: '0x123...',
    buyCurrencyAddress: '0x456...',
    buyAmount: '1000000000000000000', 
    chainId: 1,
    withContractInfo: true
  })

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

  return (
    <div>
      {swapPrices?.map(swap => (
        <div key={swap.info?.address}>
          Token: {swap.info?.symbol}
          Price: {swap.price.price}
          Balance: {swap.balance.balance}
        </div>
      ))}
    </div>
  )
}
```

## Return Type: `UseQueryResult<SwapPricesWithCurrencyInfo[]>`

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

```tsx theme={null}
interface SwapPrice {
    currencyAddress: string;
    currencyBalance: string;
    price: string;
    maxPrice: string;
    transactionValue: string;
}

interface Balance {
  balance: string
}

interface ContractInfo {
    chainId: number;
    address: string;
    source: string;
    name: string;
    type: string;
    symbol: string;
    decimals?: number;
    logoURI: string;
    deployed: boolean;
    bytecodeHash: string;
    extensions: ContractInfoExtensions;
    updatedAt: string;
    notFound: boolean;
    queuedAt?: string;
    status: ResourceStatus;
}

enum ResourceStatus {
    NOT_AVAILABLE = "NOT_AVAILABLE",
    STALE = "STALE",
    AVAILABLE = "AVAILABLE"
}

interface ContractInfoExtensions {
    link: string;
    description: string;
    categories: Array<string>;
    ogImage: string;
    ogName: string;
    originChainId: number;
    originAddress: string;
    blacklist: boolean;
    verified: boolean;
    verifiedBy: string;
    featured: boolean;
}

type SwapPricesWithCurrencyInfo = {
  price: SwapPrice
  info: ContractInfo | undefined
  balance: Balance
}
```

### Properties

#### data

`SwapPricesWithCurrencyInfo[] | undefined`

Array of swap price objects containing:

##### price (SwapPrice)

* `currencyAddress`: Address of the currency
* `currencyBalance`: Balance of the currency
* `price`: The swap price
* `maxPrice`: The maximum price for the swap
* `transactionValue`: The value of the transaction

##### info (ContractInfo)

* `chainId`: Chain ID where the token exists
* `address`: Token contract address
* `source`: Source of the token information
* `name`: Token name
* `type`: Token type
* `symbol`: Token symbol
* `decimals`: Token decimals
* `logoURI`: Token logo URL
* `deployed`: Whether the token is deployed
* `bytecodeHash`: Hash of the token's bytecode
* `extensions`: Additional token metadata
* `updatedAt`: Last update timestamp
* `notFound`: Whether token was not found
* `queuedAt`: When token was queued for update
* `status`: Token resource status

##### balance (Balance)

* `balance`: User's balance of the currency in base units

#### 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: `UseGetSwapPricesArgs`

```tsx theme={null}
interface UseGetSwapPricesArgs {
  userAddress: string
  buyCurrencyAddress: string
  buyAmount: string
  chainId: number
  withContractInfo?: boolean
}
```

| Parameter            | Type      | Description                                                            |
| -------------------- | --------- | ---------------------------------------------------------------------- |
| `userAddress`        | `string`  | The address of the user's wallet                                       |
| `buyCurrencyAddress` | `string`  | The address of the currency to buy                                     |
| `buyAmount`          | `string`  | The amount of currency to buy (in base units)                          |
| `chainId`            | `number`  | The chain ID where the swap will occur                                 |
| `withContractInfo`   | `boolean` | (Optional) Whether to fetch additional contract info for each currency |

### 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              |
