User Positions
Learn how to fetch and monitor user positions on Aave v4.
Each user position captures a user’s activity within a Spoke, simplifying health and performance tracking.
User Positions
Data Structure
User position data provides comprehensive information about a user's lending and borrowing activity on a specific spoke, including:
Identification: id, user, spoke
Position balances: supplied amounts, collateral amounts, debt amounts, net balances
Yield information: supply APY, borrow APY, net APY
Risk metrics: health factor, risk premium
Performance data: net balance percentage changes over time
- TypeScript
- GraphQL
- Solidity
The following TypeScript interfaces illustrate the core UserPosition type:
See the Spoke Data Structure for more details.
Listing User Positions
Fetch all user positions with filtering and ordering options.
- React
- TypeScript
- GraphQL
- Solidity
Use the useUserPositions hook to fetch positions for a given user address.
You can filter positions by the following criteria:
And you can sort positions as follows:
Finally, you can specify a different time window or currency for the data.
Fetching a Single Position
Fetch a specific user position.
- React
- TypeScript
- GraphQL
- Solidity
Use the useUserPosition hook to fetch a specific user position.
See below for examples of how to use the useUserPosition hook.
User Supplies
Data Structure
User supply data provides detailed information about individual user supplies within a spoke, including:
Reserve details: token information, supply APY, lending limits
Position amounts: supplied shares, earned amounts, and token details
Collateral status: whether the supply is used as collateral
Performance metrics: earned interest over time
- TypeScript
- GraphQL
The following TypeScript interfaces illustrate the UserSupplyItem type:
UserSupplyItem
interface UserSupplyItem { __typename: "UserSupplyItem"; id: UserSupplyItemId; reserve: Reserve; principal: Erc20Amount; withdrawable: Erc20Amount; interest: Erc20Amount; isCollateral: boolean;}See the Reserve Data Structure for more details.
Fetching User Supplies
Fetch user supplies within a specific spoke.
- React
- TypeScript
- GraphQL
- Solidity
Use the useUserSupplies hook to fetch user supplies for a user.
See below for examples of how to use the useUserSupplies hook.
Sort user supplies by asset name, amount, or supply APY.
Specify a different currency for displaying fiat amounts.
Custom Currency
import { Currency } from "@aave/react";
const { data, error, loading } = useUserSupplies({ query: { // your query criteria }, currency: Currency.Eur,});Include zero-value entries for all other supply reserves available on the same spoke, typically ordered by descending amount.
Include Zero Balances
import { OrderDirection } from "@aave/react";
const { data, error, loading } = useUserSupplies({ query: { // your query criteria }, includeZeroBalances: true, orderBy: { amount: OrderDirection.Desc },});User Borrows
Data Structure
User borrow data provides detailed information about individual borrow positions within a spoke, including:
Reserve details: token information, borrow APY, borrowing limits
Position amounts: borrowed amounts, repaid amounts, and token details
Debt tracking: outstanding debt and payment history
Performance metrics: interest owed and payment progress
- TypeScript
- GraphQL
The following TypeScript interfaces illustrate the UserBorrowItem type:
UserBorrowItem
interface UserBorrowItem { __typename: "UserBorrowItem"; id: UserBorrowItemId; reserve: Reserve; principal: Erc20Amount; debt: Erc20Amount; interest: Erc20Amount;}See the Reserve Data Structure for more details.
Fetching User Borrows
Fetch user borrows within a specific spoke.
- React
- TypeScript
- GraphQL
- Solidity
Use the useUserBorrows hook to fetch borrow positions for a user.
See below for examples of how to use the useUserBorrows hook.
Sort user borrows by asset name, amount, or borrow APY.
Specify a different currency for displaying fiat amounts.
Custom Currency
import { Currency } from "@aave/react";
const { data, error, loading } = useUserBorrows({ query: { // your query criteria }, currency: Currency.Eur,});Include zero-value entries for all other borrow reserves available on the same spoke, typically ordered by descending amount.
Include Zero Balances
import { OrderDirection } from "@aave/react";
const { data, error, loading } = useUserBorrows({ query: { // your query criteria }, includeZeroBalances: true, orderBy: { amount: OrderDirection.Desc },});User Summary
Data Structure
User summary data provides comprehensive information about a user's aggregated activity across all positions, including:
Position count: total number of positions held by the user
Portfolio totals: supplied amounts, collateral amounts, debt amounts, net balances
Yield information: calculated net APY across all positions
Risk metrics: lowest health factor across all positions
Performance data: net fee earned over time
- TypeScript
- GraphQL
The following TypeScript interfaces illustrate the UserSummary type:
Fetching User Summary
Fetch a comprehensive financial summary for a user across all their positions.
- React
- TypeScript
- GraphQL
Use the useUserSummary hook to fetch the financial summary for a user.
See below for examples of how to use the useUserSummary hook.
Specify a different time window to calculate net balance changes over different periods.
Custom Time Window
import { TimeWindow } from "@aave/react";
const { data, error, loading } = useUserSummary({ user: evmAddress("0x456…"), timeWindow: TimeWindow.LastWeek,});Specify a different currency for displaying fiat amounts.
Custom Currency
import { Currency, useUserSummary } from "@aave/react";
const { data, error, loading } = useUserSummary({ user: evmAddress("0x456…"), currency: Currency.Eur,});User Summary History
Data Structure
User summary history data provides detailed information about a user's activity changes over time, including:
Historical snapshots: portfolio state at different points in time
Portfolio metrics: net balance, borrows, supplies at each snapshot
Risk metrics: health factor changes over time
- TypeScript
- GraphQL
The following TypeScript interfaces illustrate the UserSummaryHistoryItem type:
UserSummaryHistoryItem
interface UserSummaryHistoryItem { __typename: "UserSummaryHistoryItem"; netBalance: FiatAmount; borrows: FiatAmount; supplies: FiatAmount; healthFactor: BigDecimal | null; date: Date;}Fetching User Summary History
Fetch historical financial data for a user over a specified time window.
- React
- TypeScript
- GraphQL
Use the useUserSummaryHistory hook to fetch historical financial data for a user.
See below for examples of how to use the useUserSummaryHistory hook.
Filter the history by specific spokes or chains.
Specify a different currency for displaying fiat amounts.
Custom Currency
import { Currency, evmAddress, TimeWindow } from "@aave/react";
const { data, error, loading } = useUserSummaryHistory({ user: evmAddress("0x456…"), window: TimeWindow.LastWeek, currency: Currency.Eur,});