> For the complete documentation index, see [llms.txt](https://docs.yo.xyz/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.yo.xyz/integrations/integration-guides/sdk/react/hooks/use-redeem.md).

# use redeem

Mutation hook for redeeming vault shares for underlying assets via the Yo Gateway, with transaction tracking and automatic query invalidation.

```tsx
const { redeem, isPending, isSuccess, hash, instant, assetsOrRequestId } = useRedeem({ vault: 'yoETH' })
```

## Usage

```tsx
import { useRedeem } from '@yo-protocol/react'

function RedeemButton({ shares }: { shares: bigint }) {
  const {
    redeem,
    isPending,
    isSuccess,
    hash,
    instant,
    assetsOrRequestId,
    error,
    reset,
  } = useRedeem({
    vault: 'yoETH',
    onSubmitted: (hash) => console.log('Redeemed:', hash),
  })

  return (
    <div>
      <button onClick={() => redeem(shares)} disabled={isPending}>
        {isPending ? 'Redeeming...' : 'Redeem'}
      </button>

      {isSuccess && (
        <div>
          <p>Redemption complete! Tx: {hash}</p>
          {instant !== undefined && (
            <p>{instant ? 'Instant redemption' : `Pending — request ID: ${assetsOrRequestId}`}</p>
          )}
        </div>
      )}
      {error && (
        <p>
          Error: {error.message}
          <button onClick={reset}>Dismiss</button>
        </p>
      )}
    </div>
  )
}
```

{% hint style="info" %}
**Instant vs async redemptions**

The gateway `redeem` may complete instantly if sufficient liquidity is available. If not, the redemption remains pending for up to 24 hours. The `YoGatewayRedeem` event's `instant` field indicates which path was taken.
{% endhint %}

## Options

| Option        | Type                     | Default | Description                                        |
| ------------- | ------------------------ | ------- | -------------------------------------------------- |
| `vault`       | `Address \| VaultId`     | —       | **Required.** Target vault                         |
| `onSubmitted` | `(hash: Hash) => void`   | —       | Called after the transaction is sent               |
| `onConfirmed` | `(hash: Hash) => void`   | —       | Called after the transaction is confirmed on-chain |
| `onError`     | `(error: Error) => void` | —       | Called on error                                    |

## Return Value

| Field               | Type                                | Description                                                                                 |
| ------------------- | ----------------------------------- | ------------------------------------------------------------------------------------------- |
| `redeem`            | `(shares: bigint) => Promise<Hash>` | Redeem the given share amount for underlying assets                                         |
| `isPending`         | `boolean`                           | `true` while the transaction is being sent or confirmed                                     |
| `isError`           | `boolean`                           | `true` if the transaction failed                                                            |
| `error`             | `Error \| null`                     | Error object                                                                                |
| `isSuccess`         | `boolean`                           | `true` after the transaction is confirmed on-chain                                          |
| `hash`              | `Hash \| undefined`                 | Transaction hash once submitted                                                             |
| `instant`           | `boolean \| undefined`              | `true` if redemption completed instantly, `false` if pending. Available after confirmation. |
| `assetsOrRequestId` | `bigint \| undefined`               | Assets returned (if instant) or pending request ID. Available after confirmation.           |
| `reset`             | `() => void`                        | Reset all state back to idle                                                                |

## Behavior

| Behavior                  | Detail                                                                                 |
| ------------------------- | -------------------------------------------------------------------------------------- |
| **Query invalidation**    | Automatically invalidates `useUserBalance` queries on success                          |
| **Confirmation tracking** | Uses `useWaitForTransactionReceipt` internally                                         |
| **Error propagation**     | Fires both the local `onError` callback and the global `YieldProvider.onError` handler |
| **Slippage protection**   | Uses `quotePreviewRedeem` to calculate `minAssetsOut` with default 0.5% slippage       |


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.yo.xyz/integrations/integration-guides/sdk/react/hooks/use-redeem.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
