Skip to Content
docs

Aave V4 User Balances

User balances show a user’s token holdings across chains, aggregated by token type with supply and borrow APY information.

User Balance Data Structure

User balance data provides information about a user’s token holdings, including:

  • Globally unique identifier: for each balance entry
  • Token identification: name, symbol, icon, decimals
  • Balance amounts: individual balances per network, total amounts
  • Yield information: highest and lowest supply/borrow APY for each token
  • Collateral factors: highest and lowest collateral factors for each token
  • Fiat valuations: converted amounts in selected currency

The following TypeScript interfaces illustrate the core UserBalance type:

interface UserBalance {
  __typename: "UserBalance";
  id: UserBalanceId;
  info: TokenInfo;
  balances: TokenAmount[];
  totalAmount: DecimalNumber;
  exchange: ExchangeAmount;
  highestSupplyApy: PercentNumber;
  highestBorrowApy: PercentNumber;
  lowestSupplyApy: PercentNumber;
  lowestBorrowApy: PercentNumber;
  highestCollateralFactor: PercentNumber | null;
  lowestCollateralFactor: PercentNumber | null;
}

Fetching User Balances

Use the useUserBalances hook in React, the userBalances action in TypeScript, or the userBalances query in GraphQL to fetch user token balances. In TypeScript, the examples filter balances by chains, hub, spoke, user position, or tokens.

import { type UserBalancesRequest, useUserBalances } from "@aave/react";

function UserBalancesList({ request }: { request: UserBalancesRequest }) {
  const { data, loading, error } = useUserBalances(request);

  if (loading) return <div>Loading…</div>;

  if (error) return <div>Error: {error.message}</div>;

  // data: UserBalance[]
  return (
    <div>
      {data.map((balance) => (
        <div key={balance.id}>
          <h2>{balance.info.name}</h2>
          <p>
            <strong>Total:</strong>
            {balance.totalAmount.value.toDisplayString(2)}
            {balance.info.symbol}
            <small>
              {balance.exchange.symbol}
              {balance.exchange.value.toDisplayString(2)}
            </small>
          </p>
          <p>
            <strong>Supply APY:</strong>
            {balance.highestSupplyApy.normalized.toFixed(2)}%
          </p>
        </div>
      ))}
    </div>
  );
}

Filter balances by chain, hub, spoke, user position, or token. In GraphQL, specify the user address and pass the filter in filter.

import { evmAddress, chainId } from "@aave/react";

const request: UserBalancesRequest = {
  user: evmAddress("0x456…"),
  filter: {
    chains: {
      chainIds: [chainId(1)],
    },
  },
};

Sort balances by name or balance value. In GraphQL, use the orderBy field.

import { evmAddress, OrderDirection } from "@aave/react";

const request: UserBalancesRequest = {
  user: evmAddress("0x456…"),
  filter: {
    // your filter criteria
  },
  orderBy: { balance: OrderDirection.Desc },
};

Include tokens with zero balances in the results.

Include Zero Balances
const request: UserBalancesRequest = {
  user: evmAddress("0x456…"),
  filter: {
    // your filter criteria
  },
  includeZeroBalances: true,
};

Specify a different currency for displaying fiat amounts. In GraphQL, use the currency argument.

Custom Currency
import { evmAddress, Currency } from "@aave/react";

// …

const { data, loading, error } = useUserBalances({
  user: evmAddress("0x456…"),
  filter: {
    // your filter criteria
  },
  currency: Currency.Eur,
});