Skip to Content
docs

Aave V3 User Positions

Monitor user positions and account health across Aave markets.

User Positions

Track user supplied and borrowed assets across Aave markets.

Use the useUserSupplies and useUserBorrows hooks in React, the userSupplies and userBorrows actions in TypeScript, or the userSupplies and userBorrows queries in GraphQL to fetch user supplied and borrowed assets across markets.

In React, both hooks support a loading state and React Suspense.

const { data, loading, error } = useUserSupplies({
  markets: MarketInput[],
  user: EvmAddress,
});

const { data, loading, error } = useUserBorrows({
  markets: MarketInput[],
  user: EvmAddress,
});

Fetch user positions across one or more markets.

import { useUserSupplies, evmAddress } from "@aave/react";
import { markets } from "./markets";

// …

const user = evmAddress("0x742d35cc6e5c4ce3b69a2a8c7c8e5f7e9a0b1234");

const { data, error, loading } = useUserSupplies({
  markets,
  user,
});

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

if (loading) {
  return <p>Loading positions…</p>;
}

// data: MarketUserReserveSupplyPosition[]

Account Health

Monitor user account health and risk metrics across Aave positions.

The health factor is null unless the user has at least one active borrow.

Use the useUserMarketState hook in React, the userMarketState action in TypeScript, or the userMarketState query in GraphQL to fetch user account health and market state.

In React, the useUserMarketState hook supports both a loading state and React Suspense.

const { data, loading, error } = useUserMarketState({
  market: EvmAddress,
  user: EvmAddress,
  chainId: ChainId,
});

Monitor account health for a specific market.

User Market State
import { useUserMarketState, evmAddress, chainId } from "@aave/react";

// …

const { data, loading, error } = useUserMarketState({
  market: evmAddress("0x87870bca3f3fd6335c3f4ce8392d69350b4fa4e2"),
  user: evmAddress("0x742d35cc6e5c4ce3b69a2a8c7c8e5f7e9a0b1234"),
  chainId: chainId(1),
});

if (loading) {
  return <p>Loading account health…</p>;
}

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

return (
  <div>
    <p>Health Factor: {data.healthFactor ?? "N/A"}</p>
    <p>Net Worth: {data.netWorth}</p>
    <p>eMode Enabled: {data.eModeEnabled ? "Yes" : "No"}</p>
  </div>
);