> 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/vault-reads.md).

# Vault Reads

On-chain read functions for querying vault state, balances, and allowances.

## Vault State

```ts
const state = await client.getVaultState(vaultAddress)
```

Returns a `VaultState` object:

| Field           | Type      | Description                              |
| --------------- | --------- | ---------------------------------------- |
| `address`       | `Address` | Vault contract address                   |
| `name`          | `string`  | Vault name (e.g., "YO ETH Vault")        |
| `symbol`        | `string`  | Vault symbol (e.g., "yoETH")             |
| `decimals`      | `number`  | Vault share decimals                     |
| `totalAssets`   | `bigint`  | Total assets under management            |
| `totalSupply`   | `bigint`  | Total shares issued                      |
| `asset`         | `Address` | Underlying asset address                 |
| `assetDecimals` | `number`  | Underlying asset decimals                |
| `exchangeRate`  | `bigint`  | Current exchange rate (shares per asset) |

## Preview Functions

```ts
// How many shares will I get for 1 ETH?
const shares = await client.previewDeposit(vault, parseEther('1'))

// How many assets will I get for 100 shares?
const assets = await client.previewRedeem(vault, 100n)

// Conversion helpers
const assetsFromShares = await client.convertToAssets(vault, shares)
const sharesFromAssets = await client.convertToShares(vault, parseEther('1'))
```

## Gateway Quote Functions

Quote functions read from the Yo Gateway contract and account for fees and routing.

```ts
// Gateway-aware previews
const shares = await client.quotePreviewDeposit(vault, parseEther('1'))
const assets = await client.quotePreviewRedeem(vault, shares)
const sharesNeeded = await client.quotePreviewWithdraw(vault, parseEther('1'))

// Gateway-aware conversions
const assetsOut = await client.quoteConvertToAssets(vault, shares)
const sharesOut = await client.quoteConvertToShares(vault, parseEther('1'))
```

## Balance Queries

```ts
// ERC-20 token balance
const { balance, decimals } = await client.getTokenBalance(tokenAddress, account)

// Vault share balance
const shares = await client.getShareBalance(vaultAddress, account)

// Full user position
const position = await client.getUserPosition(vaultAddress, account)
// position.shares, position.assets
```

## Allowance Queries

```ts
// ERC-20 allowance
const allowance = await client.getAllowance(token, owner, spender)
const sufficient = await client.hasEnoughAllowance(token, owner, spender, amount)

// Gateway-specific allowance helpers
const shareAllowance = await client.getShareAllowance(vault, owner)
const assetAllowance = await client.getAssetAllowance(vault, owner)
```


---

# 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/vault-reads.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.
