Skip to Content
docs

Aave V4 User Activities

View detailed activity history covering supplies, borrows, repayments, withdrawals, liquidations, and swaps, with built-in pagination support.

Activity Data Structure

Activity data provides detailed information about all user activities, including:

  • Transaction details: timestamp, transaction hash, chain, amount
  • Activity types: core operations (supply, borrow, withdraw, repay), liquidations, position settings, and swaps
  • User performing the activity
  • Type-specific details like reserve, spoke, and amounts

The following TypeScript interfaces illustrate the core activity types:

type ActivityItem =
  | BorrowActivity
  | SupplyActivity
  | WithdrawActivity
  | RepayActivity
  | LiquidatedActivity
  | UsingAsCollateralActivity
  | UpdatedDynamicConfigActivity
  | UpdatedRiskPremiumActivity
  | TokenSwapActivity
  | SupplySwapActivity
  | BorrowSwapActivity
  | RepayWithSupplyActivity
  | WithdrawSwapActivity
  | LeverageActivity;

Fetching User Activities

Fetch users' activities with filtering and pagination.

Use the useActivities hook in React, the activities action in TypeScript, or the activities query in GraphQL to fetch paginated activities for a user.

import { type ActivitiesRequest, useActivities } from "@aave/react";

function ActivitiesList({ request }: { request: ActivitiesRequest }) {
  const { data, loading, error } = useActivities(request);

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

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

  // data: PaginatedActivitiesResult
  return (
    <div>
      {data.items.map((activity) => (
        <div key={activity.id}>
          <h4>{activity.__typename}</h4>
          <p>Time: {activity.timestamp.toLocaleString()}</p>
          <p>Tx: {activity.txHash}</p>
        </div>
      ))}
    </div>
  );
}

In React and GraphQL, see below some examples of how to use the hook or query.

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

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

Filter by specific activity types. In GraphQL, use the types field.

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

const request: ActivitiesRequest = {
  query: {
    // your query criteria
  },
  user: evmAddress("0x456…"),
  types: [
    ActivityType.Borrow,
    ActivityType.Supply,
    ActivityType.Repay,
    ActivityType.Withdraw,
  ],
};

Finally, specify a different currency for displaying fiat amounts.

  • React: You can also specify a different time window.
  • GraphQL: Use the currency argument.
import { evmAddress, TimeWindow } from "@aave/react";

const { data, loading, error } = useActivities({
  query: {
    // your query criteria
  },
  user: evmAddress("0x456…"),
  timeWindow: TimeWindow.LastWeek,
});

Handle Pagination

Navigate through large activity history sets using cursor-based pagination.

Use the pageInfo field from the response to implement cursor-based pagination. Navigate back and forward using the prev and next cursors.

Basic Pagination
import {
  useActivities,
  evmAddress,
  chainId,
  PageSize,
  type Cursor,
} from "@aave/react";
import { useState } from "react";

function PaginatedActivities() {
  const [cursor, setCursor] = useState<Cursor | null>();

  const { data, loading, error } = useActivities({
    query: { chainIds: [chainId(1)] },
    user: evmAddress("0x456…"),
    pageSize: PageSize.Ten,
    cursor,
  });

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

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

  return (
    <div>
      <h3>Transaction History</h3>
      {data.items.map((activity) => (
        <p key={activity.id}>
          {activity.__typename}: {activity.txHash}
        </p>
      ))}

      <div>
        <button
          onClick={() => setCursor(data.pageInfo.prev)}
          disabled={!data.pageInfo.prev}
        >
          Previous
        </button>
        <button
          onClick={() => setCursor(data.pageInfo.next)}
          disabled={!data.pageInfo.next}
        >
          Next
        </button>
      </div>
    </div>
  );
}

In GraphQL, the response includes pagination information as follows.

Response with Pagination
{
  "data": {
    "activities": {
      "items": […],
      "pageInfo": {
        "prev": "abc123…",
        "next": "xyz789…"
      }
    }
  }
}

In GraphQL, navigate to subsequent or previous pages using respectively the next or prev cursors from pageInfo.

Fetch Next Page
{
  "request": {
    "query": {
      // your query criteria
    },
    "user": "0x456…",
    "pageSize": "TEN",
    "cursor": "xyz789…"
  }
}

Network Fees

Fetch the network fee (gas cost) and its historical fiat value for a specific activity transaction.

This experimental hook works only with Viem or Wagmi integrations.

Use the useNetworkFee hook to fetch the network fee for an activity by fetching the transaction receipt and converting the gas cost to both native and fiat amounts.

Viem
import { type ActivityItem, Currency } from "@aave/react";
import { useNetworkFee } from "@aave/react/viem";

function ActivityFee({ activity }: { activity: ActivityItem }) {
  const {
    data: fee,
    loading,
    error,
  } = useNetworkFee({
    query: { activity },
    currency: Currency.Eur,
  });

  if (loading) return <p>Loading fee…</p>;
  if (error) return <p>Error: {error.message}</p>;

  return (
    <p>
      Network Fee: {fee.amount.value.toDisplayString(2)} {fee.token.info.symbol}
      <span>
        ≈{fee.exchange.symbol}
        {fee.exchange.value.toDisplayString(2)}
      </span>
    </p>
  );
}

Like other declarative hooks, the useNetworkFee hook can be used in React Suspense mode and implements pausable mode.

const { data: fee } = useNetworkFee({
  query: { activity },
  currency: Currency.Eur,
  suspense: true,
});