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

# findVaultByConfig

> Discover a vault address by asset, yield type, and chain

Looks up a vault configuration by asset address, yield type, and chain ID. Use this to discover the `vaultAddress` needed by [`getVaultAPY`](./getVaultAPY) and [`getVaultTVL`](./getVaultTVL).

## Import

```ts theme={null}
import { findVaultByConfig } from "@paxoslabs/amplify-sdk";
```

## Usage

```ts theme={null}
const vault = await findVaultByConfig({
  assetAddress: "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48", // USDC
  yieldType: YieldType.CORE,
  chainId: 1,
});

if (vault) {
  console.log(vault.vault.boringVaultAddress); // Vault contract address
}
```

## Parameters

| Parameter      | Type        | Required | Description                                     |
| -------------- | ----------- | -------- | ----------------------------------------------- |
| `assetAddress` | `Address`   | Yes      | Token contract address (e.g., USDC)             |
| `yieldType`    | `YieldType` | Yes      | Yield strategy (`CORE`, `TREASURY`, `FRONTIER`) |
| `chainId`      | `number`    | Yes      | Blockchain network ID                           |

```ts theme={null}
interface FindVaultByConfigParams {
  assetAddress: Address;
  yieldType: YieldType;
  chainId: number;
}
```

## Return Type

Returns the matching `AmplifyVault`, or `undefined` if no vault matches.

```ts theme={null}
type FindVaultByConfigReturn = AmplifyVault | undefined
```

```ts theme={null}
interface AmplifyVault {
  id: string;
  name: string;
  chainId: number;
  yieldType: YieldType;
  vault: {
    boringVaultAddress: Address;
    tellerAddress: Address;
    accountantAddress: Address;
    managerAddress: Address;
    rolesAuthorityAddress: Address;
    baseTokenAddress: Address;
    baseTokenStandIn?: Address;
    withdrawQueueAddress?: Address;
  };
  supportedAssets: {
    address: Address;
    symbol: string;
    name: string;
    decimals: number;
    coinGeckoTokenId?: string;
  }[];
}
```

The key field is `vault.boringVaultAddress` — pass this as the `vaultAddress` parameter to `getVaultAPY` and `getVaultTVL`.

## Example: Vault Discovery → APY Display

```ts theme={null}
import {
  findVaultByConfig,
  getVaultAPY,
  getVaultTVL,
  YieldType,
} from "@paxoslabs/amplify-sdk";

const vault = await findVaultByConfig({
  assetAddress: "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48", // USDC
  yieldType: YieldType.CORE,
  chainId: 1,
});

if (vault) {
  const vaultAddress = vault.vault.boringVaultAddress;

  const apyResult = await getVaultAPY({ vaultAddress, chainId: 1 });
  console.log(apyResult.apyFormatted); // "4.50%"

  const tvlResult = await getVaultTVL({ vaultAddress, chainId: 1 });
  console.log(`$${Number(tvlResult.tvl).toLocaleString()} ${tvlResult.tvlAsset}`);
}
```

## Example: React Component

```tsx theme={null}
import { useQuery } from "@tanstack/react-query";
import {
  findVaultByConfig,
  getVaultAPY,
  YieldType,
} from "@paxoslabs/amplify-sdk";

function VaultAPY({ assetAddress, chainId }: { assetAddress: `0x${string}`; chainId: number }) {
  const { data, isLoading } = useQuery({
    queryKey: ["vaultAPY", assetAddress, chainId],
    queryFn: async () => {
      const vault = await findVaultByConfig({
        assetAddress,
        yieldType: YieldType.CORE,
        chainId,
      });
      if (!vault) return null;
      return getVaultAPY({
        vaultAddress: vault.vault.boringVaultAddress,
        chainId,
      });
    },
  });

  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 |

Returns `undefined` (not an error) when no vault matches the given parameters. Always check the return value before accessing vault properties.

## Related

* [getVaultAPY](./getVaultAPY) - Fetch vault APY (requires vault address)
* [getVaultTVL](./getVaultTVL) - Fetch vault TVL (requires vault address)
* [fetchSupportedAssets](/v0.4.2/intro/products/earn/developers/api/fetchSupportedAssets) - Discover supported tokens and chains
