> 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/core/actions.md).

# Actions

Transaction-building functions that require a `walletClient` on the `YoClient`.

## Deposit

Deposits assets into a vault via the Yo Gateway contract. Uses `quotePreviewDeposit` to calculate slippage protection.

```ts
const result = await client.deposit({
  vault: '0x3a43aec...',
  amount: parseEther('1'),
  slippageBps: 50,       // 0.5% slippage (optional, default: 50)
  recipient: account,    // optional, defaults to signer
})

console.log(result.hash)   // transaction hash
console.log(result.shares) // expected shares
```

## Redeem

Redeems vault shares for underlying assets via the Yo Gateway. Uses `quotePreviewRedeem` to calculate slippage protection.

```ts
const result = await client.redeem({
  vault: vaultAddress,
  shares: parseEther('10'),
  slippageBps: 50,         // optional, default: 50
  recipient: account,      // optional, defaults to signer
  minAssetsOut: 0n,        // optional, overrides slippageBps
})

console.log(result.hash)
console.log(result.assets) // expected assets
```

## Approve

Approves token spending. Defaults to the Yo Gateway as spender.

```ts
// Approve specific amount
await client.approve(tokenAddress, parseEther('10'))

// Approve max
await client.approveMax(tokenAddress)

// Custom spender
await client.approve(tokenAddress, parseEther('10'), spenderAddress)
```

## Deposit with Approval

Checks allowance and approves if needed before depositing — all in one call.

```ts
const result = await client.depositWithApproval({
  vault: vaultAddress,
  token: underlyingTokenAddress,
  amount: parseUnits('100', 6),
  slippageBps: 50,
})

console.log(result.approveHash)  // undefined if approval wasn't needed
console.log(result.depositHash)
console.log(result.shares)
```

## Prepared Transactions

Build `{ to, data, value }` call data without executing. Useful for AA wallet bundling or custom transaction flows.

```ts
import { createYoClient } from '@yo-protocol/core'

const client = createYoClient({ chainId: 8453 })

// Build approve call data
const approveTx = client.prepareApprove({
  token: underlyingTokenAddress,
  amount: parseUnits('100', 6),
})

// Build deposit call data (needs RPC for preview quote)
const depositTx = await client.prepareDeposit({
  vault: vaultAddress,
  amount: parseUnits('100', 6),
})

// Build redeem call data
const redeemTx = await client.prepareRedeem({
  vault: vaultAddress,
  shares: parseEther('10'),
})

// Build approve + deposit bundle (checks allowance, returns 1 or 2 txs)
const bundle = await client.prepareDepositWithApproval({
  vault: vaultAddress,
  token: underlyingTokenAddress,
  owner: accountAddress,
  amount: parseUnits('100', 6),
})

// Send via AA wallet bundler
await bundler.sendBundle(bundle.map(tx => ({
  to: tx.to,
  data: tx.data,
  value: tx.value,
})))
```

## Transaction Confirmation

Wait for transaction confirmation and decode events.

```ts
// General-purpose wait
const receipt = await client.waitForTransaction(hash)
console.log(receipt.status)      // 'success' | 'reverted'
console.log(receipt.blockNumber)

// Redeem-specific: decodes the YoGatewayRedeem event
const redeemReceipt = await client.waitForRedeemReceipt(hash)
console.log(redeemReceipt.instant)           // true if redeemed instantly
console.log(redeemReceipt.assetsOrRequestId) // assets returned or pending request ID
console.log(redeemReceipt.shares)            // shares redeemed
```


---

# 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 dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.yo.xyz/integrations/integration-guides/sdk/core/actions.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
