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

# Get TVL Data

> Fetch Total Value Locked data by exchange using the SDK

## Overview

Get TVL (Total Value Locked) data for a token across different exchanges. Two functions are available: TVL snapshot by exchange at a specific date and historical TVL feed.

## SDK Methods

### getTVLByExchange

Get TVL snapshot distribution across exchanges at a specific date.

```typescript theme={null}
getTVLByExchange(
  tokenAddress: string,
  simpleDateProps: SimpleDateProps,
  options?: AvnuOptions
): Promise<ExchangeDataPoint[]>
```

### getExchangeTVLFeed

Get historical TVL data over time with configurable resolution.

```typescript theme={null}
getExchangeTVLFeed(
  tokenAddress: string,
  feedProps: FeedProps,
  options?: AvnuOptions
): Promise<ExchangeDataPoint[]>
```

## Parameters

<ParamField path="tokenAddress" type="string" required>
  Token contract address
</ParamField>

<ParamField path="simpleDateProps" type="SimpleDateProps" required>
  Date configuration for snapshot

  <Expandable title="properties">
    <ParamField path="date" type="string | Date">
      Optional date for snapshot (defaults to current date). Can be ISO 8601 string or Date object.
    </ParamField>
  </Expandable>
</ParamField>

<ParamField path="feedProps" type="FeedProps" required>
  Feed configuration with resolution

  <Expandable title="properties">
    <ParamField path="dateRange" type="FeedDateRange" required>
      `ONE_HOUR`, `ONE_DAY`, `ONE_WEEK`, `ONE_MONTH`, `ONE_YEAR`
    </ParamField>

    <ParamField path="resolution" type="FeedResolution" required>
      `ONE_MIN`, `FIVE_MIN`, `FIFTEEN_MIN`, `HOURLY`, `FOUR_HOUR`, `DAILY`, `WEEKLY`
    </ParamField>
  </Expandable>
</ParamField>

## Returns

```typescript theme={null}
interface ExchangeDataPoint {
  date: string;
  value: number;
  valueUsd: number;
  exchange: string;
}
```

## Examples

<CodeGroup>
  ```typescript TVL Snapshot by Exchange theme={null}
  import { getTVLByExchange } from '@avnu/avnu-sdk';

  const USDC = '0x053c91253bc9682c04929ca02ed00b3e423f6710d2ee7e0d5ebb06f3ecf368a8';

  // Get current TVL snapshot (no date = now)
  const tvlData = await getTVLByExchange(USDC, {});

  // Calculate total TVL and display distribution
  const totalTvl = tvlData.reduce((sum, item) => sum + item.valueUsd, 0);

  tvlData
    .sort((a, b) => b.valueUsd - a.valueUsd)
    .forEach(item => {
      const share = (item.valueUsd / totalTvl) * 100;
      console.log(`${item.exchange}: $${item.valueUsd.toLocaleString()} (${share.toFixed(1)}%)`);
    });
  ```

  ```typescript Historical TVL Snapshot theme={null}
  import { getTVLByExchange } from '@avnu/avnu-sdk';

  const USDC = '0x053c91253bc9682c04929ca02ed00b3e423f6710d2ee7e0d5ebb06f3ecf368a8';

  // Get TVL at a specific date
  const tvlData = await getTVLByExchange(
    USDC,
    { date: '2024-01-01' }
  );

  console.log(`TVL snapshot for ${tvlData[0]?.date || '2024-01-01'}:`);
  tvlData.forEach(item => {
    console.log(`${item.exchange}: $${item.valueUsd.toLocaleString()}`);
  });
  ```

  ```typescript Historical TVL Feed theme={null}
  import { getExchangeTVLFeed, FeedDateRange, FeedResolution } from '@avnu/avnu-sdk';

  const ETH = '0x049d36570d4e46f48e99674bd3fcc84644ddd6b96f7c741b1562b82f9e004dc7';

  const tvlFeed = await getExchangeTVLFeed(
    ETH,
    { dateRange: FeedDateRange.ONE_WEEK, resolution: FeedResolution.DAILY }
  );

  // Group by exchange for charting
  const byExchange = tvlFeed.reduce((acc, item) => {
    if (!acc[item.exchange]) acc[item.exchange] = [];
    acc[item.exchange].push({ date: item.date, value: item.valueUsd });
    return acc;
  }, {} as Record<string, { date: string; value: number }[]>);

  console.log(`Exchanges tracked: ${Object.keys(byExchange).join(', ')}`);
  ```
</CodeGroup>

## Related

<CardGroup cols={2}>
  <Card title="Get Volume Data" icon="chart-bar" href="/docs/markets/get-volume-data">
    Get trading volume by exchange
  </Card>

  <Card title="API Reference" icon="code" href="/api/markets/tvl-by-exchange">
    REST API endpoint
  </Card>
</CardGroup>
