Skip to main content
Looks up a vault configuration by asset address, yield type, and chain ID. Use this to discover the vaultAddress needed by getVaultAPY and getVaultTVL.

Import

import { findVaultByConfig } from "@paxoslabs/amplify-sdk";

Usage

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

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

Parameters

ParameterTypeRequiredDescription
assetAddressAddressYesToken contract address (e.g., USDC)
yieldTypeYieldTypeYesYield strategy (CORE, TREASURY, FRONTIER)
chainIdnumberYesBlockchain network ID
interface FindVaultByConfigParams {
  assetAddress: Address;
  yieldType: YieldType;
  chainId: number;
}

Return Type

Returns the matching vault configuration, or undefined if no vault matches.
interface VaultConfig {
  vault: {
    boringVaultAddress: Address;
    // Additional vault contract addresses and metadata
  };
  // Vault configuration details
}
The key field is vault.boringVaultAddress — pass this as the vaultAddress parameter to getVaultAPY and getVaultTVL.

Example: Vault Discovery → APY Display

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

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 PatternDescriptionResolution
"SDK not initialized"SDK not initializedCall initAmplifySDK() first
Returns undefined (not an error) when no vault matches the given parameters. Always check the return value before accessing vault properties.