Skip to main content

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.
getTVLByExchange(
  tokenAddress: string,
  simpleDateProps: SimpleDateProps,
  options?: AvnuOptions
): Promise<ExchangeDataPoint[]>

getExchangeTVLFeed

Get historical TVL data over time with configurable resolution.
getExchangeTVLFeed(
  tokenAddress: string,
  feedProps: FeedProps,
  options?: AvnuOptions
): Promise<ExchangeDataPoint[]>

Parameters

tokenAddress
string
required
Token contract address
simpleDateProps
SimpleDateProps
required
Date configuration for snapshot
feedProps
FeedProps
required
Feed configuration with resolution

Returns

interface ExchangeDataPoint {
  date: string;
  value: number;
  valueUsd: number;
  exchange: string;
}

Examples

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)}%)`);
  });