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

# getVaultTVL

> Fetch total value locked for an account

Fetches the current total value locked (TVL) for an account from the backend API.

## Import

```ts theme={null}
import { getVaultTVL } from '@paxoslabs/amplify-sdk'
```

## Usage

```ts theme={null}
const result = await getVaultTVL({
  vaultAddress: '0x1234...5678',
})

console.log(result.tvl) // "15000000.00"
console.log(result.tvlAsset) // "USDC"
```

## Parameters

| Parameter      | Type      | Required | Description                                                |
| -------------- | --------- | -------- | ---------------------------------------------------------- |
| `vaultAddress` | `Address` | No       | Account contract address (required if `vaultName` omitted) |
| `vaultName`    | `string`  | No       | Account name — resolved to address via cache               |
| `chainId`      | `number`  | No       | Blockchain network ID (optional filter)                    |

Provide either `vaultAddress` or `vaultName`. When `vaultName` is provided, the SDK resolves the address from cache.

```ts theme={null}
interface GetVaultTVLParams {
  vaultAddress?: Address
  vaultName?: string
  chainId?: number
}
```

## Return Type

```ts theme={null}
interface VaultTVLResult {
  /** Total value locked as string */
  tvl: string
  /** Asset denomination (e.g., "USDC") */
  tvlAsset: string
  /** Vault address */
  vaultAddress: Address
  /** Chain ID */
  chainId: number
  /** Timestamp of the data point */
  timestamp: string
}
```

## Example: TVL Display Component

```tsx theme={null}
import { useQuery } from '@tanstack/react-query'
import { getVaultTVL } from '@paxoslabs/amplify-sdk'

function VaultTVLDisplay({ vaultAddress }: { vaultAddress: `0x${string}` }) {
  const { data, isLoading } = useQuery({
    queryKey: ['vaultTVL', vaultAddress],
    queryFn: () => getVaultTVL({ vaultAddress }),
  })

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

  const formatted = data
    ? `$${Number(data.tvl).toLocaleString()} ${data.tvlAsset}`
    : 'N/A'

  return <span>{formatted}</span>
}
```

## Error Handling

| Error Message Pattern         | Description          | Resolution                    |
| ----------------------------- | -------------------- | ----------------------------- |
| `"SDK not initialized"`       | SDK not initialized  | Call `initAmplifySDK()` first |
| `"No TVL data found"`         | No data for account  | Verify account address        |
| `"Failed to fetch vault TVL"` | Network or API error | Check connection and retry    |

## Related

* [getVaultAPY](./getVaultAPY) - Fetch account APY
* [getSupportedAssets](/v0.5.2/intro/products/earn/developers/api/getSupportedAssets) - Discover available accounts
