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 to fetch user supplied and borrowed assets.

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, loading } = useUserSupplies({  markets,  user,});
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 calculated only when a user has at least one active borrow position. If the user has no positions or only supply positions, the health factor will be null.

Use the useUserMarketState hook to fetch user account health and market state.

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}</p>    <p>Net Worth: {data.netWorth}</p>    <p>eMode Enabled: {data.eModeEnabled}</p>  </div>);