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

# getVaultAPY

> Fetch the latest APY for an account

Fetches the most recent APY data for an account from the backend API.

## Import

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

## Usage

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

console.log(result.apy) // 4.5
console.log(result.apyFormatted) // "4.50%"
```

## 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 GetVaultAPYParams {
  vaultAddress?: Address
  vaultName?: string
  chainId?: number
}
```

## Return Type

```ts theme={null}
interface VaultAPYResult {
  /** APY as a number (e.g., 4.5) */
  apy: number
  /** Formatted APY string (e.g., "4.50%") */
  apyFormatted: string
  /** Vault address */
  vaultAddress: Address
  /** Timestamp of the data point */
  timestamp: string
}
```

## Example: APY Display Component

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

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

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

  return <span>{data?.apyFormatted ?? 'N/A'}</span>
}
```

## Error Handling

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

## Related

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