React Hooks
All public Aave v4 React SDK hooks.
useChain
Declarative hook to fetch a specific chain by ID.
Arguments:
request.chainId: ChainId - Chain ID to query
pause?: boolean - Pause the query (default: false)
Returns:
data: Chain | null | undefined - Chain information or null if not found
loading: boolean - Loading state
error: UnexpectedError | undefined - Error fetching the chain
useChains
Declarative hook to fetch all supported chains.
Arguments:
filter: ChainsFilter - Filter for chains (e.g., ChainsFilter.ALL)
pause?: boolean - Pause the query (default: false)
Returns:
data: Chain[] | undefined - Array of supported chains
loading: boolean - Loading state
error: UnexpectedError | undefined - Error fetching the chains
useActivities
Declarative hook to fetch paginated list of user activities.
Arguments:
- request.query: ActivitiesRequestQuery one of:
hub: HubInput - Fetch by hub
spoke: SpokeInput - Fetch by spoke
chainIds: [ChainId!] - Fetch by chain IDs
txHash: TxHashInput - Fetch by transaction hash
request.user?: EvmAddress - User address (optional)
request.currency?: Currency - Currency for value conversions (default: USD)
pause?: boolean - Pause the query (default: false)
Returns:
data?.items: ActivityItem[] - List of activities
data?.pageInfo: PageInfo - Pagination information
loading: boolean - Loading state
error: UnexpectedError | undefined - Error fetching the activities
useActivitiesAction
Imperative hook to fetch paginated list of user activities.
import { useActivitiesAction } from "@aave/react";
const [execute, state] = useActivitiesAction(options);
const result = await execute(request);Options:
options.currency?: Currency - Currency for value conversions (default: USD)
Arguments:
- request.query: ActivitiesRequestQuery one of:
hub: HubInput - Fetch by hub
spoke: SpokeInput - Fetch by spoke
chainIds: [ChainId!] - Fetch by chain IDs
txHash: TxHashInput - Fetch by transaction hash
request.user?: EvmAddress - User address (optional)
Returns:
state.loading: boolean - Loading state
state.error: UnexpectedError | undefined - Error fetching the activities
state.called: boolean - Whether the hook has been called
state.data: PaginatedActivitiesResult | undefined - Paginated activities result
- result: Result<PaginatedActivitiesResult, UnexpectedError> - Type-safe success or failure value:
Ok<PaginatedActivitiesResult> - Paginated activities result
Err<UnexpectedError> - Error fetching the activities
useAsset
Declarative hook to fetch information about a specific asset (ERC20 token).
Arguments:
- request.query: AssetRequestQuery one of:
- token: Erc20Input - ERC-20 token
address: EvmAddress - Token contract address
chainId: ChainId - Chain ID where the token exists
assetId: AssetId - Asset ID
- token: Erc20Input - ERC-20 token
request.currency?: Currency - Currency for value conversions (optional)
request.timeWindow?: TimeWindow - Time window for historical data (optional)
pause?: boolean - Pause the query (default: false)
Returns:
data: Asset | null | undefined - Asset information or null if not found
loading: boolean - Loading state
error: UnexpectedError | undefined - Error fetching the asset
useAssetBorrowHistory
Declarative hook to fetch historical borrow data for an asset.
Arguments:
request.token.address: EvmAddress - Asset contract address
request.token.chainId: ChainId - Chain ID
request.window: TimeWindow - Time window for historical data
pause?: boolean - Pause the query (default: false)
Returns:
data: AssetBorrowSample[] | undefined - Array of historical borrow data points
loading: boolean - Loading state
error: UnexpectedError | undefined - Error fetching the borrow history
useAssetPriceHistory
Declarative hook to fetch historical price data for an asset.
Arguments:
request.token.address: EvmAddress - Asset contract address
request.token.chainId: ChainId - Chain ID
request.currency: Currency - Currency for the data
request.window: TimeWindow - Time window for historical data
pause?: boolean - Pause the query (default: false)
Returns:
data: AssetPriceSample[] | undefined - Array of historical price data points
loading: boolean - Loading state
error: UnexpectedError | undefined - Error fetching the price history
useAssetSupplyHistory
Declarative hook to fetch historical supply data for an asset.
Arguments:
request.token.address: EvmAddress - Asset contract address
request.token.chainId: ChainId - Chain ID
request.window: TimeWindow - Time window for historical data
pause?: boolean - Pause the query (default: false)
Returns:
data: AssetSupplySample[] | undefined - Array of historical supply data points
loading: boolean - Loading state
error: UnexpectedError | undefined - Error fetching the supply history
useBorrow
Imperative transaction hook to borrow assets from the protocol.
import { useBorrow } from "@aave/react";
const [execute, state] = useBorrow((plan) => { switch (plan.__typename) { case "TransactionRequest": return sendTransaction(plan); case "PreContractActionRequired": return sendTransaction(plan.transaction); }});
const result = await execute(request);Arguments:
request.chainId: ChainId - Chain ID
request.reserve: EvmAddress - Reserve address
request.amount: BigDecimal - Amount to borrow
request.onBehalfOf?: EvmAddress - Borrow on behalf of another address (optional)
Returns:
state.loading: boolean - Loading state
state.error: E | undefined - Error executing the transaction
state.called: boolean - Whether the hook has been called
state.data: TxHash | undefined - Transaction hash
- result: Result<TxHash, E> - Type-safe success or failure value:
Ok<TxHash> - Transaction hash
Err<E> - Error executing the transaction
Where E is one of:
SendTransactionError
CancelError
TimeoutError
TransactionError
ValidationError<InsufficientBalanceError>
useBorrowApyHistory
Declarative hook to fetch borrow APY history for a specific reserve over time.
Arguments:
request.spoke.address: EvmAddress - Spoke contract address
request.spoke.chainId: ChainId - Chain ID
request.reserve: ReserveId - Reserve ID
request.window: TimeWindow - Time window for historical data
pause?: boolean - Pause the query (default: false)
Returns:
data: APYSample[] | undefined - Array of historical APY data points
loading: boolean - Loading state
error: UnexpectedError | undefined - Error fetching the borrow APY history
useERC20Permit
Imperative transaction hook to sign ERC20 permit for gasless approvals.
Arguments:
request.token: EvmAddress - Token address
request.spender: EvmAddress - Spender address
request.value: BigDecimal - Amount to permit
request.deadline: bigint - Permit expiration timestamp
Returns:
state.loading: boolean - Loading state
state.error: SignERC20PermitError | undefined - Error signing the permit
state.called: boolean - Whether the hook has been called
state.data: ERC20PermitSignature | undefined - ERC20 permit signature
- result: Result<ERC20PermitSignature, SignERC20PermitError> - Type-safe success or failure value:
Ok<ERC20PermitSignature> - ERC20 permit signature
Err<SignERC20PermitError> - Error signing the permit
useExchangeRate
Declarative hook to fetch the current exchange rate between two currencies.
Arguments:
request.from: AssetInput - Source asset (erc20 or native)
request.to: Currency - Target currency
pause?: boolean - Pause the query (default: false)
Returns:
data: FiatAmount | undefined - Exchange rate value
loading: boolean - Loading state
error: UnexpectedError | undefined - Error fetching the exchange rate
useExchangeRateAction
Imperative hook to fetch exchange rate between two currencies.
import { useExchangeRateAction } from "@aave/react";
const [execute, state] = useExchangeRateAction();
const result = await execute(request);Arguments:
request.from: AssetInput - Source asset (erc20 or native)
request.to: Currency - Target currency
request.at?: Date - Historical date (optional)
Returns:
state.loading: boolean - Loading state
state.error: UnexpectedError | undefined - Error fetching the exchange rate
state.called: boolean - Whether the hook has been called
state.data: FiatAmount | undefined - Exchange rate value
- result: Result<FiatAmount, UnexpectedError> - Type-safe success or failure value:
Ok<FiatAmount> - Exchange rate value
Err<UnexpectedError> - Error fetching the exchange rate
useHub
Declarative hook to fetch a specific hub by address and chain ID.
Arguments:
- request.query: HubRequestQuery one of:
- hubInput: HubInput - Hub address and chain ID
address: EvmAddress - Hub contract address
chainId: ChainId - Chain ID where the hub exists
hubId: HubId - Hub ID
- hubInput: HubInput - Hub address and chain ID
request.currency?: Currency - Currency for value conversions (optional)
pause?: boolean - Pause the query (default: false)
Returns:
data: Hub | null | undefined - Hub information or null if not found
loading: boolean - Loading state
error: UnexpectedError | undefined - Error fetching the hub
useHubAssets
Declarative hook to fetch hub assets for a specific chain and optional hub/user filtering.
Arguments:
- request.query: HubAssetsRequestQuery one of:
- hubInput: HubInput - Hub address and chain ID
address: EvmAddress - Hub contract address
chainId: ChainId - Chain ID
hubId: HubId - Hub ID
- hubInput: HubInput - Hub address and chain ID
request.user?: EvmAddress - Filter by user address (optional)
- request.orderBy?: HubAssetsRequestOrderBy one of:
assetName: OrderDirection - Sort by asset name
availableLiquidity: OrderDirection - Sort by available liquidity
supplyApy: OrderDirection - Sort by supply APY
borrowApy: OrderDirection - Sort by borrow APY
request.currency?: Currency - Currency for value conversions (optional)
pause?: boolean - Pause the query (default: false)
Returns:
data: HubAsset[] | undefined - Array of hub assets
loading: boolean - Loading state
error: UnexpectedError | undefined - Error fetching the hub assets
useHubs
Declarative hook to fetch all available hubs.
Arguments:
- request.query: HubsRequestQuery one of:
- tokens: [Erc20Input!] - Filter by underlying tokens
address: EvmAddress - Token contract address
chainId: ChainId - Token chain ID
chainIds: [ChainId!] - Filter by chain IDs
- tokens: [Erc20Input!] - Filter by underlying tokens
- request.orderBy?: HubsRequestOrderBy one of:
name: OrderDirection - Sort by hub name
totalBorrowed: OrderDirection - Sort by total borrowed amount
totalSupplied: OrderDirection - Sort by total supplied amount
pause?: boolean - Pause the query (default: false)
Returns:
data: Hub[] | undefined - Array of hubs
loading: boolean - Loading state
error: UnexpectedError | undefined - Error fetching the hubs
useHubsAction
Imperative hook to fetch hubs data.
import { useHubsAction } from "@aave/react";
const [execute, state] = useHubsAction(options);
const result = await execute(request);Options:
options.currency?: Currency - Currency for value conversions (default: USD)
Arguments:
- request.query: HubsRequestQuery one of:
- tokens: [Erc20Input!] - Filter by underlying tokens
address: EvmAddress - Token contract address
chainId: ChainId - Token chain ID
chainIds: [ChainId!] - Filter by chain IDs
- tokens: [Erc20Input!] - Filter by underlying tokens
- request.orderBy?: HubsRequestOrderBy one of:
name: OrderDirection - Sort by hub name
totalBorrowed: OrderDirection - Sort by total borrowed amount
totalSupplied: OrderDirection - Sort by total supplied amount
Returns:
state.loading: boolean - Loading state
state.error: UnexpectedError | undefined - Error fetching the hubs
state.called: boolean - Whether the hook has been called
state.data: Hub[] | undefined - Array of hubs
- result: Result<Hub[], UnexpectedError> - Type-safe success or failure value:
Ok<Hub[]> - Array of hubs
Err<UnexpectedError> - Error fetching the hubs
useLiquidatePosition
Imperative transaction hook to liquidate an undercollateralized position.
import { useLiquidatePosition } from "@aave/react";
const [execute, state] = useLiquidatePosition((plan) => { switch (plan.__typename) { case "TransactionRequest": return sendTransaction(plan); case "Erc20ApprovalRequired": return sendTransaction(plan.transaction); }});
const result = await execute(request);Arguments:
request.chainId: ChainId - Chain ID
request.debtReserve: EvmAddress - Debt reserve address
request.collateralReserve: EvmAddress - Collateral reserve address
request.user: EvmAddress - User address to liquidate
request.debtToCover: BigDecimal - Amount of debt to cover
Returns:
state.loading: boolean - Loading state
state.error: E | undefined - Error executing the transaction
state.called: boolean - Whether the hook has been called
state.data: TxHash | undefined - Transaction hash
- result: Result<TxHash, E> - Type-safe success or failure value:
Ok<TxHash> - Transaction hash
Err<E> - Error executing the transaction
Where E is one of:
SendTransactionError
CancelError
TimeoutError
TransactionError
ValidationError<InsufficientBalanceError>
useNetworkFee
Declarative hook to fetch the network fee for an activity (experimental).
Arguments:
- request.query: UseNetworkFeeRequestQuery one of:
activity: ActivityItem - Calculate fee for past activity
- estimate: PreviewAction - Estimate fee for preview action, one of:
supply: SupplyRequest - Supply action
borrow: BorrowRequest - Borrow action
repay: RepayRequest - Repay action
withdraw: WithdrawRequest - Withdraw action
setUserSupplyAsCollateral: SetUserSupplyAsCollateralRequest - Collateral change
request.currency?: Currency - Currency for value conversions (optional)
pause?: boolean - Pause the query (default: false)
Returns:
data: NativeAmount | undefined - Network fee amount
loading: boolean - Loading state
error: UnexpectedError | undefined - Error fetching the network fee
usePreview
Declarative hook to preview the outcome of a transaction before executing.
Arguments:
- request.action: PreviewActionInput one of:
supply: SupplyRequest - Preview a supply action
borrow: BorrowRequest - Preview a borrow action
repay: RepayRequest - Preview a repay action
withdraw: WithdrawRequest - Preview a withdraw action
setUserSupplyAsCollateral: SetUserSupplyAsCollateralRequest - Preview a collateral change
request.currency?: Currency - Currency for value conversions (optional)
pause?: boolean - Pause the query (default: false)
Returns:
data: PreviewUserPosition | undefined - Preview of user position after the action
loading: boolean - Loading state
error: UnexpectedError | undefined - Error fetching the preview
usePreviewAction
Imperative hook to preview the outcome of a transaction before executing.
import { usePreviewAction } from "@aave/react";
const [execute, state] = usePreviewAction(options);
const result = await execute(request);Options:
options.currency?: Currency - Currency for value conversions (default: USD)
Arguments:
- request.action: PreviewActionInput one of:
supply: SupplyRequest - Preview a supply action
borrow: BorrowRequest - Preview a borrow action
repay: RepayRequest - Preview a repay action
withdraw: WithdrawRequest - Preview a withdraw action
setUserSupplyAsCollateral: SetUserSupplyAsCollateralRequest - Preview a collateral change
Returns:
state.loading: boolean - Loading state
state.error: UnexpectedError | undefined - Error fetching the preview
state.called: boolean - Whether the hook has been called
state.data: PreviewUserPosition | undefined - Preview of user position after the action
- result: Result<PreviewUserPosition, UnexpectedError> - Type-safe success or failure value:
Ok<PreviewUserPosition> - Preview of user position after the action
Err<UnexpectedError> - Error fetching the preview
useRepay
Imperative transaction hook to repay borrowed assets.
import { useRepay } from "@aave/react";
const [execute, state] = useRepay((plan) => { switch (plan.__typename) { case "TransactionRequest": return sendTransaction(plan); case "Erc20ApprovalRequired": return sendTransaction(plan.transaction); }});
const result = await execute(request);Arguments:
request.chainId: ChainId - Chain ID
request.reserve: EvmAddress - Reserve address
request.amount: BigDecimal - Amount to repay
request.onBehalfOf?: EvmAddress - Repay on behalf of another address (optional)
Returns:
state.loading: boolean - Loading state
state.error: E | undefined - Error executing the transaction
state.called: boolean - Whether the hook has been called
state.data: TxHash | undefined - Transaction hash
- result: Result<TxHash, E> - Type-safe success or failure value:
Ok<TxHash> - Transaction hash
Err<E> - Error executing the transaction
Where E is one of:
SendTransactionError
CancelError
TimeoutError
TransactionError
ValidationError<InsufficientBalanceError>
useReserve
Declarative hook to fetch a specific reserve by reserve ID, spoke, and chain.
Arguments:
- request.query: ReserveRequestQuery one of:
reserveId: ReserveId - Reserve ID
- reserveInput: ReserveInput - Reserve input
chainId: ChainId - Chain ID
spoke: EvmAddress - Spoke contract address
onChainId: OnChainReserveId - On-chain reserve ID
request.user?: EvmAddress - User address for position-specific data (optional)
request.currency?: Currency - Currency for value conversions (optional)
pause?: boolean - Pause the query (default: false)
Returns:
data: Reserve | null | undefined - Reserve information or null if not found
loading: boolean - Loading state
error: UnexpectedError | undefined - Error fetching the reserve
useReserveAction
Imperative hook to fetch reserve data.
import { useReserveAction } from "@aave/react";
const [execute, state] = useReserveAction(options);
const result = await execute(request);Options:
options.currency?: Currency - Currency for value conversions (default: USD)
Arguments:
request.reserve: ReserveId - Reserve ID
request.user?: EvmAddress - User address for position-specific data (optional)
Returns:
state.loading: boolean - Loading state
state.error: UnexpectedError | undefined - Error fetching the reserve
state.called: boolean - Whether the hook has been called
state.data: Reserve | null | undefined - Reserve data or null if not found
- result: Result<Reserve | null, UnexpectedError> - Type-safe success or failure value:
Ok<Reserve | null> - Reserve data or null if not found
Err<UnexpectedError> - Error fetching the reserve
useReserves
Declarative hook to fetch reserves based on specified criteria.
Arguments:
- request.query: ReservesRequestQuery one of:
- spoke: SpokeInput - Get reserves for a spoke
address: EvmAddress - Spoke contract address
chainId: ChainId - Chain ID
spokeId: SpokeId - Get reserves by spoke ID
- tokens: [Erc20Input!] - Get reserves with underlying tokens
address: EvmAddress - Token contract address
chainId: ChainId - Token chain ID
- hubToken: HubTokenInput - Get reserves on hub for underlying
chainId: ChainId - Chain ID
hub: EvmAddress - Hub contract address
token: EvmAddress - Token address
chainIds: [ChainId!] - Get reserves on chains
- spokeToken: SpokeTokenInput - Get reserves for spoke for underlying
spoke: SpokeId - Spoke ID
token: EvmAddress - Token address
hub: HubInput - Get reserves on hub
userPositionId: UserPositionId - Get reserves by user position ID
- spoke: SpokeInput - Get reserves for a spoke
request.filter?: ReservesRequestFilter - Filter criteria (optional)
- request.orderBy?: ReservesRequestOrderBy one of:
assetName: OrderDirection - Sort by asset name
userBalance: OrderDirection - Sort by user balance
supplyApy: OrderDirection - Sort by supply APY
supplyAvailable: OrderDirection - Sort by available supply
borrowApy: OrderDirection - Sort by borrow APY
borrowAvailable: OrderDirection - Sort by available borrow
collateralFactor: OrderDirection - Sort by collateral factor
request.currency?: Currency - Currency for value conversions (optional)
pause?: boolean - Pause the query (default: false)
Returns:
data: Reserve[] | undefined - Array of reserves
loading: boolean - Loading state
error: UnexpectedError | undefined - Error fetching reserves
useReservesAction
Imperative hook to fetch reserves list.
import { useReservesAction } from "@aave/react";
const [execute, state] = useReservesAction(options);
const result = await execute(request);Options:
options.currency?: Currency - Currency for value conversions (default: USD)
Arguments:
- request.query: ReservesRequestQuery one of:
spoke: SpokeInput - Get all reserves for a spoke
- tokens: [Erc20Input!] - Get all reserves with underlying tokens
address: EvmAddress - Token contract address
chainId: ChainId - Token chain ID
- hubToken: HubTokenInput - Get all reserves on a hub for an underlying
chainId: ChainId - Chain ID
hub: EvmAddress - Hub contract address
token: EvmAddress - Token address
chainIds: [ChainId!] - Get all reserves on a list of chains
- spokeToken: SpokeTokenInput - Get all reserves for a spoke for an underlying
spoke: SpokeId - Spoke ID
token: EvmAddress - Token address
hub: HubInput - Get all tokens on a hub
request.filter?: ReservesRequestFilter - Filter criteria (optional)
Returns:
state.loading: boolean - Loading state
state.error: UnexpectedError | undefined - Error fetching reserves
state.called: boolean - Whether the hook has been called
state.data: Reserve[] | undefined - Array of reserves
- result: Result<Reserve[], UnexpectedError> - Type-safe success or failure value:
Ok<Reserve[]> - Array of reserves
Err<UnexpectedError> - Error fetching reserves
useSendTransaction
Send transactions through connected wallet.
useSetSpokeUserPositionManager
Imperative transaction hook to set a position manager for a spoke.
import { useSetSpokeUserPositionManager } from "@aave/react";
const [execute, state] = useSetSpokeUserPositionManager((transaction) => sendTransaction(transaction));
const result = await execute(request);Arguments:
request.chainId: ChainId - Chain ID
request.spoke: SpokeId - Spoke ID
request.manager: EvmAddress - Position manager address
Returns:
state.loading: boolean - Loading state
state.error: E | undefined - Error executing the transaction
state.called: boolean - Whether the hook has been called
state.data: TxHash | undefined - Transaction hash
- result: Result<TxHash, E> - Type-safe success or failure value:
Ok<TxHash> - Transaction hash
Err<E> - Error executing the transaction
Where E is one of:
SendTransactionError
CancelError
TimeoutError
TransactionError
useSetUserSupplyAsCollateral
Imperative transaction hook to enable or disable an asset as collateral.
import { useSetUserSupplyAsCollateral } from "@aave/react";
const [execute, state] = useSetUserSupplyAsCollateral((transaction) => sendTransaction(transaction));
const result = await execute(request);Arguments:
request.chainId: ChainId - Chain ID
request.reserve: EvmAddress - Reserve address
request.useAsCollateral: boolean - Enable or disable as collateral
Returns:
state.loading: boolean - Loading state
state.error: E | undefined - Error executing the transaction
state.called: boolean - Whether the hook has been called
state.data: TxHash | undefined - Transaction hash
- result: Result<TxHash, E> - Type-safe success or failure value:
Ok<TxHash> - Transaction hash
Err<Error> - Error executing the transaction
Where E is one of:
SendTransactionError
CancelError
TimeoutError
TransactionError
useSpoke
Declarative hook to fetch a specific spoke by address and chain ID.
Arguments:
request.query.spoke.address: EvmAddress - Spoke contract address
request.query.spoke.chainId: ChainId - Chain ID
pause?: boolean - Pause the query (default: false)
Returns:
data: Spoke | null | undefined - Spoke information or null if not found
loading: boolean - Loading state
error: UnexpectedError | undefined - Error fetching the spoke
useSpokePositionManagers
Declarative hook to fetch paginated list of position managers for a spoke.
Arguments:
request.spoke: SpokeInput - Spoke address and chain ID
pause?: boolean - Pause the query (default: false)
Returns:
data: PaginatedSpokePositionManagerResult | undefined - Paginated list of position managers
loading: boolean - Loading state
error: UnexpectedError | undefined - Error fetching position managers
useSpokes
Declarative hook to fetch spokes based on specified criteria.
Arguments:
request.chainIds?: ChainId[] - Filter by specific chain IDs (optional)
pause?: boolean - Pause the query (default: false)
Returns:
data: Spoke[] | undefined - Array of spokes
loading: boolean - Loading state
error: UnexpectedError | undefined - Error fetching the spokes
useSpokeUserPositionManagers
Declarative hook to fetch paginated list of user's position managers for a spoke.
Arguments:
request.spoke: SpokeInput - Spoke address and chain ID
request.user: EvmAddress - User address
pause?: boolean - Pause the query (default: false)
Returns:
data: PaginatedSpokeUserPositionManagerResult | undefined - Paginated list of user's position managers
loading: boolean - Loading state
error: UnexpectedError | undefined - Error fetching user position managers
useSupply
Imperative transaction hook to supply assets to the protocol.
import { useSupply } from "@aave/react";
const [sendTransaction] = useSendTransaction(walletClient);const [execute, state] = useSupply((plan) => { switch (plan.__typename) { case "TransactionRequest": return sendTransaction(plan); case "Erc20ApprovalRequired": return sendTransaction(plan.transaction); }});
const result = await execute(request);Arguments:
request.chainId: ChainId - Chain ID
request.reserve: EvmAddress - Reserve address
request.amount: BigDecimal - Amount to supply
request.onBehalfOf?: EvmAddress - Supply on behalf of another address (optional)
Returns:
state.loading: boolean - Loading state
state.error: E | undefined - Error executing the transaction
state.called: boolean - Whether the hook has been called
state.data: TxHash | undefined - Transaction hash
- result: Result<TxHash, E> - Type-safe success or failure value:
Ok<TxHash> - Transaction hash
Err<E> - Error executing the transaction
Where E is one of:
SendTransactionError
CancelError
TimeoutError
TransactionError
ValidationError<InsufficientBalanceError>
useSupplyApyHistory
Declarative hook to fetch supply APY history for a specific reserve over time.
Arguments:
request.spoke.address: EvmAddress - Spoke contract address
request.spoke.chainId: ChainId - Chain ID
request.reserve: ReserveId - Reserve ID
request.window: TimeWindow - Time window for historical data
pause?: boolean - Pause the query (default: false)
Returns:
data: APYSample[] | undefined - Array of historical APY data points
loading: boolean - Loading state
error: UnexpectedError | undefined - Error fetching the supply APY history
Imperative transaction hook to update a user's risk premium to the latest value configured by the protocol.
import { useUpdateUserRiskPremium } from "@aave/react";
const [execute, state] = useUpdateUserRiskPremium((transaction) => sendTransaction(transaction));
const result = await execute(request);Arguments:
request.spoke: SpokeId - Spoke identifier where the position exists
request.sender: EvmAddress - User address sending the transaction
request.onBehalfOf?: EvmAddress - User whose risk premium is being updated (optional)
Returns:
state.loading: boolean - Loading state
state.error: E | undefined - Error executing the transaction
state.called: boolean - Whether the hook has been called
state.data: TxHash | undefined - Transaction hash
- result: Result<TxHash, E> - Type-safe success or failure value:
Ok<TxHash> - Transaction hash
Err<E> - Error executing the transaction
Where E is one of:
SendTransactionError
CancelError
TimeoutError
TransactionError
UnexpectedError
useUserBalances
Declarative hook to fetch user wallet balances across specified chains.
Arguments:
request.user: EvmAddress - User address
- request.filter: UserBalancesRequestFilter one of:
- chains: UserBalancesByChains - Balances on specified chains
chainIds: ChainId[] - Chain IDs to query
byReservesType: ReservesRequestFilter - Reserve type filter (default: ALL)
- hub: UserBalancesByHub - Balances for hub assets
address: EvmAddress - Hub address
chainId: ChainId - Hub chain ID
byReservesType: ReservesRequestFilter - Reserve type filter (default: ALL)
- spoke: UserBalancesBySpoke - Balances for spoke reserves
address: EvmAddress - Spoke address
chainId: ChainId - Spoke chain ID
byReservesType: ReservesRequestFilter - Reserve type filter (default: ALL)
- userPosition: UserBalancesByUserPosition - Balances for user position
userPositionId: UserPositionId - User position ID
byReservesType: ReservesRequestFilter - Reserve type filter (default: ALL)
- chains: UserBalancesByChains - Balances on specified chains
- request.orderBy?: UserBalancesRequestOrderBy one of:
name: OrderDirection - Sort by token name
balance: OrderDirection - Sort by balance
request.includeZeroBalances?: boolean - Include zero balances (default: false)
request.currency?: Currency - Currency for value conversions (optional)
pause?: boolean - Pause the query (default: false)
Returns:
data: UserBalance[] | undefined - Array of user wallet balances
loading: boolean - Loading state
error: UnexpectedError | undefined - Error fetching user balances
useUserBalancesAction
Imperative hook to fetch user wallet balances.
import { useUserBalancesAction } from "@aave/react";
const [execute, state] = useUserBalancesAction(options);
const result = await execute(request);Options:
options.currency?: Currency - Currency for value conversions (default: USD)
Arguments:
request.user: EvmAddress - User address
- request.filter: UserBalancesRequestFilter one of:
- chains: UserBalancesByChains - Balances on specified chains
chainIds: ChainId[] - Chain IDs to query
byReservesType: ReservesRequestFilter - Reserve type filter (default: ALL)
- hub: UserBalancesByHub - Balances for hub assets
address: EvmAddress - Hub address
chainId: ChainId - Hub chain ID
byReservesType: ReservesRequestFilter - Reserve type filter (default: ALL)
- spoke: UserBalancesBySpoke - Balances for spoke reserves
address: EvmAddress - Spoke address
chainId: ChainId - Spoke chain ID
byReservesType: ReservesRequestFilter - Reserve type filter (default: ALL)
- userPosition: UserBalancesByUserPosition - Balances for user position
userPositionId: UserPositionId - User position ID
byReservesType: ReservesRequestFilter - Reserve type filter (default: ALL)
- chains: UserBalancesByChains - Balances on specified chains
- request.orderBy?: UserBalancesRequestOrderBy one of:
name: OrderDirection - Sort by token name
balance: OrderDirection - Sort by balance
request.includeZeroBalances?: boolean - Include zero balances (default: false)
Returns:
state.loading: boolean - Loading state
state.error: UnexpectedError | undefined - Error fetching user balances
state.called: boolean - Whether the hook has been called
state.data: UserBalance[] | undefined - Array of user wallet balances
- result: Result<UserBalance[], UnexpectedError> - Type-safe success or failure value:
Ok<UserBalance[]> - Array of user wallet balances
Err<UnexpectedError> - Error fetching user balances
useUserBorrows
Declarative hook to fetch all user borrow positions.
Arguments:
- request.query: UserBorrowsQueryRequest one of:
- userSpoke: UserSpokeInput - Get borrows for user on spoke
spoke: SpokeId - Spoke ID
user: EvmAddress - User address
- userToken: UserToken - Get borrows for user for token
user: EvmAddress - User address
- token: Erc20Input - Token input
address: EvmAddress - Token contract address
chainId: ChainId - Token chain ID
userPositionId: UserPositionId - Get borrows for user position
- userChains: UserChains - Get borrows for user across chains
user: EvmAddress - User address
chainIds: [ChainId!] - Chain IDs
- userSpoke: UserSpokeInput - Get borrows for user on spoke
- request.orderBy?: UserBorrowsRequestOrderBy one of:
assetName: OrderDirection - Sort by asset name
created: OrderDirection - Sort by creation date
amount: OrderDirection - Sort by borrow amount
apy: OrderDirection - Sort by APY
request.includeZeroBalances?: boolean - Include zero balances (default: false)
request.currency?: Currency - Currency for value conversions (optional)
pause?: boolean - Pause the query (default: false)
Returns:
data: UserBorrowItem[] | undefined - Array of user borrow positions
loading: boolean - Loading state
error: UnexpectedError | undefined - Error fetching user borrows
useUserBorrowsAction
Imperative hook to fetch user borrow positions.
import { useUserBorrowsAction } from "@aave/react";
const [execute, state] = useUserBorrowsAction(options);
const result = await execute(request);Options:
options.currency?: Currency - Currency for value conversions (default: USD)
Arguments:
- request.query: UserBorrowsRequestQuery one of:
- userSpoke: UserSpokeInput - Get borrows for user on a spoke
spoke: SpokeId - Spoke ID
user: EvmAddress - User address
- userToken: UserToken - Get borrows for user for a specific token
user: EvmAddress - User address
- token: Erc20Input - Token input
address: EvmAddress - Token contract address
chainId: ChainId - Token chain ID
userPositionId: UserPositionId - Get borrows for a user position
- userChains: UserChains - Get borrows for user across chains
user: EvmAddress - User address
chainIds: [ChainId!] - Chain IDs
- userSpoke: UserSpokeInput - Get borrows for user on a spoke
request.from?: EvmAddress - User address (optional)
- request.orderBy?: UserBorrowsRequestOrderBy one of:
assetName: OrderDirection - Sort by asset name
created: OrderDirection - Sort by creation date
amount: OrderDirection - Sort by borrow amount
apy: OrderDirection - Sort by APY
Returns:
state.loading: boolean - Loading state
state.error: UnexpectedError | undefined - Error fetching user borrows
state.called: boolean - Whether the hook has been called
state.data: UserBorrowItem[] | undefined - Array of user borrow positions
- result: Result<UserBorrowItem[], UnexpectedError> - Type-safe success or failure value:
Ok<UserBorrowItem[]> - Array of user borrow positions
Err<UnexpectedError> - Error fetching user borrows
useUserPosition
Declarative hook to fetch a specific user position by ID.
Arguments:
request.id: UserPositionId - Unique position identifier
request.user: EvmAddress - User address
request.currency?: Currency - Currency for value conversions (optional)
request.timeWindow?: TimeWindow - Time window for historical data (optional)
pause?: boolean - Pause the query (default: false)
Returns:
data: UserPosition | null | undefined - User position or null if not found
loading: boolean - Loading state
error: UnexpectedError | undefined - Error fetching the user position
useUserPositions
Declarative hook to fetch all user positions across specified chains.
Arguments:
request.user: EvmAddress - User address
- request.filter: UserPositionsRequestFilter one of:
- tokens: [Erc20Input!] - Filter by tokens
address: EvmAddress - Token contract address
chainId: ChainId - Token chain ID
chainIds: [ChainId!] - Filter by chain IDs
- tokens: [Erc20Input!] - Filter by tokens
- request.orderBy?: UserPositionsRequestOrderBy one of:
created: OrderDirection - Sort by creation date
balance: OrderDirection - Sort by position balance
netApy: OrderDirection - Sort by net APY
healthFactor: OrderDirection - Sort by health factor
netCollateral: OrderDirection - Sort by net collateral
request.currency?: Currency - Currency for value conversions (optional)
request.timeWindow?: TimeWindow - Time window for historical data (optional)
pause?: boolean - Pause the query (default: false)
Returns:
data: UserPosition[] | undefined - Array of user positions
loading: boolean - Loading state
error: UnexpectedError | undefined - Error fetching user positions
useUserPositionsAction
Imperative hook to fetch user positions.
import { useUserPositionsAction } from "@aave/react";
const [execute, state] = useUserPositionsAction(options);
const result = await execute(request);Options:
options.currency?: Currency - Currency for value conversions (default: USD)
options.timeWindow?: TimeWindow - Time window for historical data (optional)
Arguments:
request.user: EvmAddress - User address
- request.filter: UserPositionsRequestFilter one of:
- tokens: [Erc20Input!] - Filter by tokens
address: EvmAddress - Token contract address
chainId: ChainId - Token chain ID
chainIds: [ChainId!] - Filter by chain IDs
- tokens: [Erc20Input!] - Filter by tokens
- request.orderBy?: UserPositionsRequestOrderBy one of:
created: OrderDirection - Sort by creation date
balance: OrderDirection - Sort by position balance
netApy: OrderDirection - Sort by net APY
healthFactor: OrderDirection - Sort by health factor
netCollateral: OrderDirection - Sort by net collateral
Returns:
state.loading: boolean - Loading state
state.error: UnexpectedError | undefined - Error fetching user positions
state.called: boolean - Whether the hook has been called
state.data: UserPosition[] | undefined - Array of user positions
- result: Result<UserPosition[], UnexpectedError> - Type-safe success or failure value:
Ok<UserPosition[]> - Array of user positions
Err<UnexpectedError> - Error fetching user positions
useUserSupplies
Declarative hook to fetch all user supply positions.
Arguments:
- request.query: UserSuppliesQueryRequest one of:
- userSpoke: UserSpokeInput - Get supplies for user on spoke
spoke: SpokeId - Spoke ID
user: EvmAddress - User address
- userToken: UserToken - Get supplies for user for token
user: EvmAddress - User address
- token: Erc20Input - Token input
address: EvmAddress - Token contract address
chainId: ChainId - Token chain ID
userPositionId: UserPositionId - Get supplies for user position
- userChains: UserChains - Get supplies for user across chains
user: EvmAddress - User address
chainIds: [ChainId!] - Chain IDs
- userSpoke: UserSpokeInput - Get supplies for user on spoke
- request.orderBy?: UserSuppliesRequestOrderBy one of:
assetName: OrderDirection - Sort by asset name
created: OrderDirection - Sort by creation date
amount: OrderDirection - Sort by supply amount
apy: OrderDirection - Sort by APY
request.includeZeroBalances?: boolean - Include zero balances (default: false)
request.currency?: Currency - Currency for value conversions (optional)
pause?: boolean - Pause the query (default: false)
Returns:
data: UserSupplyItem[] | undefined - Array of user supply positions
loading: boolean - Loading state
error: UnexpectedError | undefined - Error fetching user supplies
useUserSuppliesAction
Imperative hook to fetch user supply positions.
import { useUserSuppliesAction } from "@aave/react";
const [execute, state] = useUserSuppliesAction(options);
const result = await execute(request);Options:
options.currency?: Currency - Currency for value conversions (default: USD)
Arguments:
- request.query: UserSuppliesRequestQuery one of:
- userSpoke: UserSpokeInput - Get supplies for user on a spoke
spoke: SpokeId - Spoke ID
user: EvmAddress - User address
- userToken: UserToken - Get supplies for user for a specific token
user: EvmAddress - User address
- token: Erc20Input - Token input
address: EvmAddress - Token contract address
chainId: ChainId - Token chain ID
userPositionId: UserPositionId - Get supplies for a user position
- userChains: UserChains - Get supplies for user across chains
user: EvmAddress - User address
chainIds: [ChainId!] - Chain IDs
- userSpoke: UserSpokeInput - Get supplies for user on a spoke
request.from?: EvmAddress - User address (optional)
- request.orderBy?: UserSuppliesRequestOrderBy one of:
assetName: OrderDirection - Sort by asset name
created: OrderDirection - Sort by creation date
amount: OrderDirection - Sort by supply amount
apy: OrderDirection - Sort by APY
Returns:
state.loading: boolean - Loading state
state.error: UnexpectedError | undefined - Error fetching user supplies
state.called: boolean - Whether the hook has been called
state.data: UserSupplyItem[] | undefined - Array of user supply positions
- result: Result<UserSupplyItem[], UnexpectedError> - Type-safe success or failure value:
Ok<UserSupplyItem[]> - Array of user supply positions
Err<UnexpectedError> - Error fetching user supplies
useUserSummary
Declarative hook to fetch a user's financial summary.
Arguments:
request.user: EvmAddress - User address
request.filter?.spoke.address: EvmAddress - Filter by spoke address (optional)
request.filter?.spoke.chainId: ChainId - Filter by chain ID (optional)
request.currency?: Currency - Currency for value conversions (optional)
request.timeWindow?: TimeWindow - Time window for historical data (optional)
pause?: boolean - Pause the query (default: false)
Returns:
data: UserSummary | undefined - Aggregated metrics including total collateral, total debt, health factor, etc.
loading: boolean - Loading state
error: UnexpectedError | undefined - Error fetching the user summary
useUserSummaryHistory
Declarative hook to fetch user summary history over time.
Arguments:
request.user: EvmAddress - User address
request.window: TimeWindow - Time window for historical data
request.filter?.chainIds: ChainId[] - Filter by specific chain IDs (optional)
request.currency?: Currency - Currency for value conversions (optional)
pause?: boolean - Pause the query (default: false)
Returns:
data: UserSummaryHistoryItem[] | undefined - Array of historical user summary data points
loading: boolean - Loading state
error: UnexpectedError | undefined - Error fetching the user summary history
useWithdraw
Imperative transaction hook to withdraw supplied assets.
import { useWithdraw } from "@aave/react";
const [execute, state] = useWithdraw((transaction) => sendTransaction(transaction));
const result = await execute(request);Arguments:
request.chainId: ChainId - Chain ID
request.reserve: EvmAddress - Reserve address
request.amount: BigDecimal - Amount to withdraw
request.to?: EvmAddress - Recipient address (optional, defaults to caller)
Returns:
state.loading: boolean - Loading state
state.error: E | undefined - Error executing the transaction
state.called: boolean - Whether the hook has been called
state.data: TxHash | undefined - Transaction hash
- result: Result<TxHash, E> - Type-safe success or failure value:
Ok<TxHash> - Transaction hash
Err<E> - Error executing the transaction
Where E is one of:
SendTransactionError
CancelError
TimeoutError
TransactionError
UnexpectedError
ValidationError<InsufficientBalanceError>