Skip to main content

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.

Fetches the current total value locked (TVL) for a vault from the backend API.

Import

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

Usage

const result = await getVaultTVL({
  vaultAddress: "0x1234...5678",
});

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

Parameters

ParameterTypeRequiredDescription
vaultAddressAddressYesVault contract address
chainIdnumberNoBlockchain network ID (optional filter)
interface GetVaultTVLParams {
  vaultAddress: Address;
  chainId?: number;
}

Return Type

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

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 PatternDescriptionResolution
"SDK not initialized"SDK not initializedCall initAmplifySDK() first
"No TVL data found"No data for vaultVerify vault address
"Failed to fetch vault TVL"Network or API errorCheck connection and retry