@aave/react 4.0.0-next.46 → 4.0.0-next.47
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/ethers.d.cts +1 -1
- package/dist/ethers.d.ts +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +766 -739
- package/dist/index.d.ts +766 -739
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/{misc-COaS62_P.d.ts → misc-BqyLi2XD.d.ts} +1 -1
- package/dist/{misc-DBn3Mp67.d.cts → misc-rpxVotZV.d.cts} +1 -1
- package/dist/privy.d.cts +1 -1
- package/dist/privy.d.ts +1 -1
- package/dist/thirdweb.d.cts +1 -1
- package/dist/thirdweb.d.ts +1 -1
- package/dist/viem/index.d.cts +2 -2
- package/dist/viem/index.d.ts +2 -2
- package/dist/{writes-CcVGQGt5.d.cts → writes-sBt0thuG.d.cts} +5 -1
- package/dist/{writes-CcVGQGt5.d.ts → writes-sBt0thuG.d.ts} +5 -1
- package/package.json +5 -4
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/context.tsx","../src/AaveProvider.tsx","../src/helpers/cache.ts","../src/helpers/results.ts","../src/helpers/reads.ts","../src/helpers/tasks.ts","../src/helpers/writes.ts","../src/hubs.ts","../src/misc.ts","../src/protocol.ts","../src/reserves.ts","../src/rewards.ts","../src/spokes.ts","../src/swap.ts","../src/transactions.ts","../src/user.ts"],"names":["AaveContext","React","AaveContextProvider","children","client","UrqlProvider","useAaveClient","useContext","invariant","AaveProvider","extractUserSuppliesRequestUser","query","user","decodeUserPositionId","extractUserBorrowsRequestUser","refreshUserBalances","UserBalancesQuery","variables","refreshUserSupplies","UserSuppliesQuery","refreshUserBorrows","UserBorrowsQuery","refreshUserPositions","spoke","isMatch","position","ResultAsync","UserPositionsQuery","_","data","UserPositionQuery","refreshReserves","ids","reserve","ReserveQuery","ReservesQuery","refreshUserSummary","UserSummaryQuery","isSpokeInputVariant","isChainIdsVariant","id","refreshSpokes","item","SpokeQuery","SpokesQuery","refreshHubs","chainId","hub","HubQuery","HubsQuery","refreshSpokePositionManagers","SpokePositionManagersQuery","refreshUserPositionById","userPositionId","ReadResult","reloading","error","useSuspendableQuery","document","suspense","pause","selector","ok","pollInterval","batch","loading","setLoading","useState","fetching","stale","executeQuery","useQuery","useMemo","useEffect","timerId","unexpectedError","UnexpectedError","selected","unexpected","AsyncTaskState","useAsyncTask","handler","deps","state","setState","loadingRef","useRef","mountedRef","handle","useCallback","input","previousState","result","value","cancel","message","CancelError","PendingTransaction","_PendingTransaction","wait","okAsync","trySignatureFrom","isSignature","useHub","currency","DEFAULT_QUERY_OPTIONS","timeWindow","request","useHubs","useHubAssets","HubAssetsQuery","useHubSummaryHistory","HubSummaryHistoryQuery","useHubsAction","options","hubs","useChain","ChainQuery","useChainAction","fetchChain","useChains","ChainsFilter","ChainsQuery","useExchangeRateAction","exchangeRate","useExchangeRate","ExchangeRateQuery","useAsset","AssetQuery","useAssetPriceHistory","AssetPriceHistoryQuery","useAssetSupplyHistory","AssetSupplyHistoryQuery","useAssetBorrowHistory","AssetBorrowHistoryQuery","useProtocolHistory","ProtocolHistoryQuery","useReserve","useReserveAction","useReserves","useReservesAction","reserves","useBorrowApyHistory","BorrowApyHistoryQuery","useSupplyApyHistory","SupplyApyHistoryQuery","useUserClaimableRewards","UserClaimableRewardsQuery","useUserClaimableRewardsAction","userClaimableRewards","useSpoke","useSpokes","useSpokePositionManagers","useSpokeUserPositionManagers","SpokeUserPositionManagersQuery","extractTokenSwapQuote","err","ValidationError","toSwapCancelledResult","cancelled","extractPositionSwapQuote","injectTokenSwapQuoteAccuracy","accuracy","injectSupplySwapQuoteAccuracy","injectBorrowSwapQuoteAccuracy","injectRepayWithSupplyQuoteAccuracy","injectWithdrawSwapQuoteAccuracy","useTokenSwapQuote","fastResult","TokenSwapQuoteQuery","QuoteAccuracy","accurateResult","useTokenSwapQuoteAction","tokenSwapQuote","useSwappableTokens","SwappableTokensQuery","useUserSwaps","allTerminal","setAllTerminal","UserSwapsQuery","isTerminalSwapStatus","useSwapStatus","isTerminal","setIsTerminal","SwapStatusQuery","useSupplySwapQuote","SupplySwapQuoteQuery","useSupplySwapQuoteAction","supplySwapQuote","useBorrowSwapQuote","BorrowSwapQuoteQuery","useBorrowSwapQuoteAction","borrowSwapQuote","processApprovals","acc","approval","swapPosition","intent","swap","plan","useSupplySwap","preparePositionSwap","order","signature","useBorrowSwap","useRepayWithSupplyQuote","RepayWithSupplyQuoteQuery","useRepayWithSupplyQuoteAction","repayWithSupplyQuote","useRepayWithSupply","useWithdrawSwapQuote","WithdrawSwapQuoteQuery","useWithdrawSwapQuoteAction","withdrawSwapQuote","useWithdrawSwap","useTokenSwap","executeSwap","pendingTransaction","quoteResult","prepareTokenSwap","supportsPermit","chain","never","CannotCancelSwapError","ResultAwareError","useCancelSwap","swapStatus","status","prepareSwapCancel","cancelSwap","refreshQueriesForReserveChange","address","decodeReserveId","toPermitSignature","permitTypedData","sendApprovalTransactions","pending","handleSingleApproval","onPermit","expectTypename","useSupply","supply","permitSig","injectSupplyPermitSignature","transaction","errAsync","useBorrow","borrow","useRepay","repay","injectRepayPermitSignature","useWithdraw","withdraw","useRenounceSpokeUserPositionManager","renounceSpokeUserPositionManager","useUpdateUserPositionConditions","updateUserPositionConditions","useSetUserSuppliesAsCollateral","reserveIds","change","reserveDetails","reserveId","setUserSuppliesAsCollateral","useLiquidatePosition","liquidatePosition","injectLiquidatePermitSignature","_permitSig","useSetSpokeUserPositionManager","setSpokeUserPositionManager","usePreviewAction","preview","usePreview","PreviewQuery","useActivities","ActivitiesQuery","useActivitiesAction","activities","useClaimRewards","claimRewards","transactionReceipt","useUserSupplies","useUserSuppliesAction","userSupplies","useUserBorrows","useUserBorrowsAction","userBorrows","useUserSummary","useUserPositions","useUserPositionsAction","userPositions","useUserPosition","useUserBalances","useUserRiskPremium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AAe,aACjB,CAAC,CAAA,CACH,CAAC9G,CAAAA,CAAQ8G,CAAAA,CAAQ,QAAQ,CAC3B,CACF,CAyEO,SAASsL,EAAAA,CAAsB,CACpC,QAAA,CAAA7O,CAAAA,CAAW,MACX,KAAA,CAAAC,CAAAA,CAAQ,MACR,QAAA,CAAA4C,CAAAA,CAAWC,6BAAsB,QAAA,CACjC,GAAGE,CACL,CAAA,CAGiE,CAC/D,OAAOlD,CAAAA,CAAoB,CACzB,SAAUgP,+BAAAA,CACV,SAAA,CAAW,CACT,OAAA,CAAA9L,CAAAA,CACA,SAAAH,CACF,CAAA,CACA,SAAA7C,CAAAA,CACA,KAAA,CAAAC,EACA,KAAA,CAAO,KACT,CAAC,CACH","file":"index.cjs","sourcesContent":["import type { AaveClient } from '@aave/client';\nimport { invariant } from '@aave/types';\nimport React, { type ReactNode, useContext } from 'react';\nimport { Provider as UrqlProvider } from 'urql';\n\nconst AaveContext = React.createContext<AaveClient | null>(null);\n\n/**\n * @internal\n */\nexport type AaveContextProviderProps = {\n children: ReactNode;\n client: AaveClient;\n};\n\n/**\n * @internal\n */\nexport function AaveContextProvider({\n children,\n client,\n}: AaveContextProviderProps) {\n return (\n <AaveContext.Provider value={client}>\n <UrqlProvider value={client.urql}>{children}</UrqlProvider>\n </AaveContext.Provider>\n );\n}\n\n/**\n * @internal\n */\nexport function useAaveClient(): AaveClient {\n const client = useContext(AaveContext);\n\n invariant(\n client,\n 'Could not find Aave SDK context, ensure your code is wrapped in a <AaveProvider>',\n );\n\n return client;\n}\n","import type { AaveClient } from '@aave/client';\n// biome-ignore lint/correctness/noUnusedImports: intentional\nimport React, { type ReactNode } from 'react';\n\nimport { AaveContextProvider } from './context';\n\n/**\n * <AaveProvider> props\n */\nexport type AaveProviderProps = {\n /**\n * The children to render\n */\n children: ReactNode;\n /**\n * The Aave client instance to use\n */\n client: AaveClient;\n};\n\n/**\n * Manages the internal state of the Aave SDK.\n *\n * ```tsx\n * import { AaveProvider, AaveClient, production } from '@aave/react';\n *\n * const client = AaveClient.create({\n * environment: production,\n * });\n *\n * function App() {\n * return (\n * <AaveProvider client={client}>\n * // ...\n * </AaveProvider>\n * );\n * }\n * ```\n */\nexport function AaveProvider({ children, client }: AaveProviderProps) {\n return <AaveContextProvider client={client}>{children}</AaveContextProvider>;\n}\n","import type { AaveClient } from '@aave/client';\nimport {\n decodeUserPositionId,\n type Hub,\n HubQuery,\n HubsQuery,\n isChainIdsVariant,\n isSpokeInputVariant,\n type Reserve,\n type ReserveId,\n ReserveQuery,\n ReservesQuery,\n type Spoke,\n type SpokeId,\n type SpokeInput,\n SpokePositionManagersQuery,\n SpokeQuery,\n SpokesQuery,\n UserBalancesQuery,\n UserBorrowsQuery,\n type UserBorrowsRequestQuery,\n type UserPosition,\n type UserPositionId,\n UserPositionQuery,\n UserPositionsQuery,\n UserSummaryQuery,\n UserSuppliesQuery,\n type UserSuppliesRequestQuery,\n} from '@aave/graphql';\nimport { type ChainId, type EvmAddress, ResultAsync } from '@aave/types';\n\nfunction extractUserSuppliesRequestUser(\n query: UserSuppliesRequestQuery,\n): EvmAddress {\n if ('userSpoke' in query) return query.userSpoke.user;\n if ('userToken' in query) return query.userToken.user;\n if ('userChains' in query) return query.userChains.user;\n if ('userHub' in query) return query.userHub.user;\n\n const { user } = decodeUserPositionId(query.userPositionId);\n return user;\n}\n\nfunction extractUserBorrowsRequestUser(\n query: UserBorrowsRequestQuery,\n): EvmAddress {\n if ('userSpoke' in query) return query.userSpoke.user;\n if ('userToken' in query) return query.userToken.user;\n if ('userChains' in query) return query.userChains.user;\n if ('userHub' in query) return query.userHub.user;\n\n const { user } = decodeUserPositionId(query.userPositionId);\n return user;\n}\n\n/**\n * @internal\n */\nexport function refreshUserBalances(client: AaveClient, user: EvmAddress) {\n return client.refreshQueryWhere(\n UserBalancesQuery,\n (variables) => variables.request.user === user,\n );\n}\n\n/**\n * @internal\n */\nexport function refreshUserSupplies(client: AaveClient, user: EvmAddress) {\n return client.refreshQueryWhere(\n UserSuppliesQuery,\n (variables) =>\n extractUserSuppliesRequestUser(variables.request.query) === user,\n );\n}\n\n/**\n * @internal\n */\nexport function refreshUserBorrows(client: AaveClient, user: EvmAddress) {\n return client.refreshQueryWhere(\n UserBorrowsQuery,\n (variables) =>\n extractUserBorrowsRequestUser(variables.request.query) === user,\n );\n}\n\n/**\n * @internal\n */\nexport function refreshUserPositions(\n client: AaveClient,\n user: EvmAddress,\n spoke: SpokeInput,\n) {\n const isMatch = (position: UserPosition) =>\n position.spoke.chain.chainId === spoke.chainId &&\n position.spoke.address === spoke.address &&\n position.user === user;\n\n return ResultAsync.combine([\n client.refreshQueryWhere(UserPositionsQuery, (_, data) =>\n data.some(isMatch),\n ),\n client.refreshQueryWhere(\n UserPositionQuery,\n (_, data) => data !== null && isMatch(data),\n ),\n ]);\n}\n\n/**\n * @internal\n */\nexport function refreshReserves(client: AaveClient, ids: ReserveId[]) {\n const isMatch = (reserve: Reserve) => ids.includes(reserve.id);\n\n return ResultAsync.combine([\n client.refreshQueryWhere(\n ReserveQuery,\n (_, data) => data !== null && isMatch(data),\n ),\n client.refreshQueryWhere(ReservesQuery, (_, data) => data.some(isMatch)),\n ]);\n}\n\n/**\n * @internal\n */\nexport function refreshUserSummary(\n client: AaveClient,\n user: EvmAddress,\n spoke: SpokeInput,\n) {\n return client.refreshQueryWhere(\n UserSummaryQuery,\n (variables) =>\n variables.request.user === user &&\n (isSpokeInputVariant(variables.request.filter)\n ? variables.request.filter.spoke.chainId === spoke.chainId &&\n variables.request.filter.spoke.address === spoke.address\n : isChainIdsVariant(variables.request.filter)\n ? variables.request.filter.chainIds.some((id) => id === spoke.chainId)\n : false),\n );\n}\n\n/**\n * @internal\n */\nexport function refreshSpokes(client: AaveClient, spoke: SpokeInput) {\n const isMatch = (item: Spoke) =>\n item.chain.chainId === spoke.chainId && item.address === spoke.address;\n\n return ResultAsync.combine([\n client.refreshQueryWhere(\n SpokeQuery,\n (_, data) => data !== null && isMatch(data),\n ),\n client.refreshQueryWhere(SpokesQuery, (_, data) => data.some(isMatch)),\n ]);\n}\n\n/**\n * @internal\n */\nexport function refreshHubs(client: AaveClient, chainId: ChainId) {\n const isMatch = (hub: Hub) => hub.chain.chainId === chainId;\n\n return ResultAsync.combine([\n client.refreshQueryWhere(\n HubQuery,\n (_, data) => data !== null && isMatch(data),\n ),\n client.refreshQueryWhere(HubsQuery, (_, data) => data.some(isMatch)),\n ]);\n}\n\n/**\n * @internal\n */\nexport function refreshSpokePositionManagers(\n client: AaveClient,\n spoke: SpokeId,\n) {\n return client.refreshQueryWhere(\n SpokePositionManagersQuery,\n (variables) => variables.request.spoke === spoke,\n );\n}\n\n/**\n * @internal\n */\nexport function refreshUserPositionById(\n client: AaveClient,\n userPositionId: UserPositionId,\n) {\n return ResultAsync.combine([\n client.refreshQueryWhere(UserPositionsQuery, (_, data) =>\n data.some((position) => position.id === userPositionId),\n ),\n client.refreshQueryWhere(\n UserPositionQuery,\n (_, data) => data?.id === userPositionId,\n ),\n ]);\n}\n","import type { UnexpectedError } from '@aave/client';\n\n/**\n * A read hook result.\n *\n * It's a discriminated union of the possible results of a read operation:\n * - Rely on the `loading` value to determine if the `data` or `error` can be evaluated.\n * - If `error` is `undefined`, then `data` value will be available.\n */\nexport type ReadResult<T, E = UnexpectedError> =\n | {\n data: undefined;\n error: undefined;\n loading: true;\n reloading: false;\n }\n | {\n data: T;\n error: undefined;\n loading: false;\n reloading: boolean;\n }\n | {\n data: undefined;\n error: E;\n loading: false;\n reloading: boolean;\n };\n\n/**\n * A read hook result that supports pausing.\n */\nexport type PausableReadResult<T, E = UnexpectedError> =\n | {\n data: T | undefined;\n error: E | undefined;\n loading: false;\n paused: true;\n reloading: false;\n }\n | {\n data: undefined;\n error: undefined;\n loading: true;\n paused: false;\n reloading: false;\n }\n | {\n data: T;\n error: undefined;\n loading: false;\n paused: false;\n reloading: boolean;\n }\n | {\n data: undefined;\n error: E;\n loading: false;\n paused: false;\n reloading: boolean;\n };\n\n/**\n * @internal\n */\nexport const ReadResult = {\n Loading: <T, E = UnexpectedError>(): PausableReadResult<T, E> => ({\n data: undefined,\n error: undefined,\n loading: true,\n paused: false,\n reloading: false,\n }),\n Success: <T, E = UnexpectedError>(\n data: T,\n reloading = false,\n ): PausableReadResult<T, E> => ({\n data,\n error: undefined,\n loading: false,\n paused: false,\n reloading,\n }),\n Failure: <T, E = UnexpectedError>(\n error: E,\n reloading = false,\n ): PausableReadResult<T, E> => ({\n data: undefined,\n error,\n loading: false,\n paused: false,\n reloading,\n }),\n Paused: <T, E = UnexpectedError>(\n data: T | undefined,\n error: E | undefined,\n ): PausableReadResult<T, E> => ({\n data,\n error,\n loading: false,\n paused: true,\n reloading: false,\n }),\n};\n\n/**\n * A read hook result that supports React Suspense.\n */\nexport type SuspenseResult<T> = {\n data: T;\n};\n\n/**\n * A read hook result that supports React Suspense and can be paused.\n */\nexport type PausableSuspenseResult<T> =\n | {\n paused: true;\n data: undefined;\n }\n | {\n paused: false;\n data: T;\n };\n\nexport type SuspendableResult<T, E = UnexpectedError> =\n | ReadResult<T, E>\n | SuspenseResult<T>\n | PausableReadResult<T, E>\n | PausableSuspenseResult<T>;\n","import { type StandardData, UnexpectedError } from '@aave/client';\nimport {\n type AnyVariables,\n invariant,\n type NullishDeep,\n ok,\n type Prettify,\n type Result,\n} from '@aave/types';\nimport { useEffect, useMemo, useState } from 'react';\nimport { type TypedDocumentNode, useQuery } from 'urql';\nimport {\n type PausableReadResult,\n type PausableSuspenseResult,\n ReadResult,\n type SuspendableResult,\n type SuspenseResult,\n} from './results';\n\nexport type Selector<ResponseValue, SelectorData, SelectorError> = (\n data: ResponseValue,\n) => Result<SelectorData, SelectorError>;\n\nexport type Pausable<T, WhenPaused = NullishDeep<T>> = Prettify<\n WhenPaused & {\n /**\n * Prevents the hook from automatically executing GraphQL query operations.\n *\n * @experimental This is an experimental feature and may change in the future.\n *\n * @remarks\n * `pause` may be set to `true` to stop the query operation from executing\n * automatically. The hook will stop receiving updates and won't execute the query\n * operation until it's set to `false`.\n */\n pause: boolean;\n }\n>;\n\nexport type Suspendable = { suspense: true };\n\n/**\n * @internal\n */\nexport type UseSuspendableQueryArgs<\n ResponseValue,\n SelectorData,\n SelectorError,\n Variables extends AnyVariables,\n Suspense extends boolean,\n Pause extends boolean = never,\n> = {\n document: TypedDocumentNode<StandardData<ResponseValue>, Variables>;\n variables?: Pause extends boolean ? NullishDeep<Variables> : Variables;\n suspense: Suspense;\n selector?: Selector<ResponseValue, SelectorData, SelectorError>;\n pollInterval?: number;\n batch?: boolean;\n pause?: Pause;\n};\n\n/**\n * @internal\n */\nexport function useSuspendableQuery<\n ResponseValue,\n SelectorData,\n SelectorError,\n Variables extends AnyVariables,\n Pausable extends boolean = never,\n>({\n document,\n variables,\n suspense,\n pause,\n}: UseSuspendableQueryArgs<\n ResponseValue,\n SelectorData,\n SelectorError,\n Variables,\n false,\n Pausable\n>):\n | ReadResult<SelectorData, SelectorError | UnexpectedError>\n | PausableReadResult<SelectorData, SelectorError | UnexpectedError>;\n/**\n * @internal\n */\nexport function useSuspendableQuery<\n ResponseValue,\n SelectorData,\n SelectorError,\n Variables extends AnyVariables,\n Pausable extends boolean = never,\n>({\n document,\n variables,\n suspense,\n pause,\n}: UseSuspendableQueryArgs<\n ResponseValue,\n SelectorData,\n SelectorError,\n Variables,\n true,\n Pausable\n>): SuspenseResult<SelectorData> | PausableSuspenseResult<SelectorData>;\n/**\n * @internal\n */\nexport function useSuspendableQuery<\n ResponseValue,\n SelectorData,\n SelectorError,\n Variables extends AnyVariables,\n Pausable extends boolean = never,\n>({\n document,\n variables,\n suspense,\n pause,\n}: UseSuspendableQueryArgs<\n ResponseValue,\n SelectorData,\n SelectorError,\n Variables,\n boolean,\n Pausable\n>): SuspendableResult<SelectorData, SelectorError | UnexpectedError>;\n/**\n * Implementation.\n */\nexport function useSuspendableQuery<\n ResponseValue,\n SelectorData,\n SelectorError,\n Variables extends AnyVariables,\n>({\n document,\n variables,\n suspense,\n pause,\n selector = ok as Selector<ResponseValue, SelectorData, SelectorError>,\n pollInterval = 0,\n batch = true,\n}: UseSuspendableQueryArgs<\n ResponseValue,\n SelectorData,\n SelectorError,\n Variables,\n boolean,\n boolean\n>): SuspendableResult<SelectorData, SelectorError | UnexpectedError> {\n const [loading, setLoading] = useState(true);\n const [{ fetching, data, error, stale }, executeQuery] = useQuery({\n query: document,\n variables: variables as Variables,\n pause,\n context: useMemo(\n () => ({\n batch,\n suspense,\n }),\n [batch, suspense],\n ),\n });\n\n useEffect(() => {\n if (pause) return;\n\n if (!fetching) {\n setLoading(false);\n }\n }, [fetching, pause]);\n\n useEffect(() => {\n if (pollInterval <= 0 || fetching || pause) return undefined;\n\n const timerId = setTimeout(() => {\n executeQuery({\n requestPolicy: 'network-only',\n batch: false, // never batch, run now!\n });\n }, pollInterval);\n\n return () => clearTimeout(timerId);\n }, [fetching, executeQuery, pollInterval, pause]);\n\n if (pause) {\n const unexpectedError = error ? UnexpectedError.from(error) : undefined;\n\n if (!data) {\n return ReadResult.Paused<SelectorData, SelectorError | UnexpectedError>(\n undefined,\n unexpectedError,\n );\n }\n\n const selected = selector(data.value);\n\n if (selected.isErr()) {\n return ReadResult.Paused<SelectorData, SelectorError>(\n undefined,\n selected.error,\n );\n }\n\n return ReadResult.Paused<SelectorData, UnexpectedError>(\n selected.value,\n unexpectedError,\n );\n }\n\n if (!suspense && loading) {\n return ReadResult.Loading();\n }\n\n // stale indicates that the useQuery is fetching new data because the variables changed\n // !loading && fetching indicates that a re-fetch is happening as consequence of calling executeQuery (e.g., polling)\n const reloading = stale || (!loading && fetching);\n\n if (error) {\n const unexpected = UnexpectedError.from(error);\n if (suspense) {\n throw unexpected;\n }\n\n return ReadResult.Failure(unexpected, reloading);\n }\n\n invariant(data, 'No data returned');\n\n const selected = selector(data.value);\n\n if (selected.isErr()) {\n if (suspense) {\n throw selected.error;\n }\n return ReadResult.Failure(selected.error, reloading);\n }\n\n return ReadResult.Success(selected.value, reloading);\n}\n","import { invariant, type ResultAsync } from '@aave/types';\nimport {\n type DependencyList,\n useCallback,\n useEffect,\n useRef,\n useState,\n} from 'react';\n\n/**\n * An async task is a function that can be executed multiple times and that can be in a pending state.\n *\n * @internal\n */\nexport type AsyncTask<TInput, TResult extends ResultAsync<unknown, unknown>> = (\n input: TInput,\n) => TResult;\n\n/**\n * The initial state of a async task.\n */\nexport type AsyncTaskIdle = {\n called: boolean;\n loading: false;\n data: undefined;\n error: undefined;\n};\n\n/**\n * The state of a async task during the loading.\n */\nexport type AsyncTaskLoading<TData> = {\n called: true;\n loading: true;\n data: TData | undefined;\n error: undefined;\n};\n\n/**\n * The state of a async task after a successful call.\n */\nexport type AsyncTaskSuccess<TData> = {\n called: true;\n loading: false;\n data: TData;\n error: undefined;\n};\n\n/**\n * The state of a async task after a failed call.\n */\nexport type AsyncTaskError<TError> = {\n called: true;\n loading: false;\n data: undefined;\n error: TError;\n};\n\n/**\n * The possible statuses of a async task.\n */\nexport type AsyncTaskState<TData, TError> =\n | AsyncTaskIdle\n | AsyncTaskLoading<TData>\n | AsyncTaskSuccess<TData>\n | AsyncTaskError<TError>;\n\nconst AsyncTaskState = {\n Idle: <TData, TError>(): AsyncTaskState<TData, TError> => ({\n called: false,\n loading: false,\n data: undefined,\n error: undefined,\n }),\n Loading: <TData, TError>(data?: TData): AsyncTaskState<TData, TError> => ({\n called: true,\n loading: true,\n data,\n error: undefined,\n }),\n Success: <TData, TError>(data: TData): AsyncTaskState<TData, TError> => ({\n called: true,\n loading: false,\n data,\n error: undefined,\n }),\n Failed: <TData, TError>(error: TError): AsyncTaskState<TData, TError> => ({\n called: true,\n loading: false,\n data: undefined,\n error,\n }),\n};\n\n/**\n * A async task React Hook is a lightweight wrapper for an asynchronous function.\n * It allows tracking of the task's execution status and provides access to the\n * last error that occurred during the task's execution, if any.\n *\n * ```ts\n * const [execute, { called, loading, data, error }]: UseAsyncTask<TData, TError, TInput> = useAnyAsyncTask();\n *\n * if (!called) {\n * // data === undefined\n * // error === undefined\n * return <p>Click the button to execute the task</p>;\n * }\n *\n * if (loading) {\n * // data === undefined on first call\n * // data === TData from previous successful call\n * // error === undefined\n * return <Loader />;\n * }\n *\n * if (error) {\n * // data === undefined\n * // error === TError\n * return <p>Something went wrong: {error.message}</p>;\n * }\n *\n * // called === true\n * // data === TData\n * // error === undefined\n * return <p>Task completed: {data}</p>;\n * ```\n */\nexport type UseAsyncTask<TInput, TValue, TError> = [\n AsyncTask<TInput, ResultAsync<TValue, TError>>,\n AsyncTaskState<TValue, TError>,\n];\n\n/**\n * @internal\n */\nexport function useAsyncTask<\n TInput,\n TValue,\n TError,\n TResult extends ResultAsync<TValue, TError>,\n>(\n handler: AsyncTask<TInput, TResult>,\n deps: DependencyList,\n): UseAsyncTask<TInput, TValue, TError> {\n const [state, setState] = useState(AsyncTaskState.Idle<TValue, TError>());\n const loadingRef = useRef(false);\n const mountedRef = useRef(true);\n\n useEffect(() => {\n return () => {\n mountedRef.current = false;\n };\n }, []);\n\n // biome-ignore lint/correctness/useExhaustiveDependencies: useAsyncTask is a low-level hook\n const handle = useCallback(handler, deps);\n\n const execute = useCallback(\n (input: TInput) => {\n invariant(\n mountedRef.current,\n 'Cannot execute a task on an unmounted component.',\n );\n\n invariant(\n !loadingRef.current,\n 'Cannot execute a task while another is in progress.',\n );\n\n loadingRef.current = true;\n\n let previousState: AsyncTaskState<TValue, TError> | undefined;\n setState((state) => {\n previousState = state;\n return {\n called: true,\n loading: true,\n data: state.data,\n error: undefined,\n };\n });\n\n try {\n const result = handle(input);\n\n result.match(\n (value) => {\n loadingRef.current = false;\n setState(AsyncTaskState.Success(value));\n },\n (error) => {\n loadingRef.current = false;\n setState(AsyncTaskState.Failed(error));\n },\n );\n\n return result;\n } catch (error) {\n loadingRef.current = false;\n if (previousState) {\n setState(previousState);\n }\n throw error;\n }\n },\n [handle],\n );\n\n return [execute, state];\n}\n","import type { TransactionResult } from '@aave/client';\nimport {\n CancelError,\n type SigningError,\n type TimeoutError,\n type TransactionError,\n UnexpectedError,\n} from '@aave/core';\nimport type { TransactionRequest } from '@aave/graphql';\nimport type { ResultAsync, Signature } from '@aave/types';\nimport { isSignature, okAsync } from '@aave/types';\nimport type { UseAsyncTask } from './tasks';\n\n/**\n * The errors that could occur in the early stage of sending a transaction.\n */\nexport type SendTransactionError = CancelError | SigningError | UnexpectedError;\n\nexport type CancelOperation = (\n message: string,\n) => ResultAsync<never, CancelError>;\n\n/**\n * @internal\n */\nexport const cancel: CancelOperation = (message: string) =>\n CancelError.from(message).asResultAsync();\n\nexport type TransactionHandlerOptions = {\n cancel: CancelOperation;\n};\n\n/**\n * The errors that could occur in the late stages of a transaction.\n */\nexport type PendingTransactionError =\n | CancelError\n | TimeoutError\n | TransactionError\n | UnexpectedError;\n\nexport class PendingTransaction {\n constructor(\n /**\n * @internal Do NOT rely on this method. It's used internally by the SDK and may be subject to breaking changes.\n */\n public readonly wait: () => ResultAsync<\n TransactionResult,\n PendingTransactionError\n >,\n ) {}\n\n /**\n * @internal\n */\n static isInstanceOf(value: unknown): value is PendingTransaction {\n return value instanceof PendingTransaction;\n }\n\n /**\n * Narrows a value to PendingTransaction.\n * Only accepts types that include PendingTransaction in the union.\n *\n * @internal\n */\n static tryFrom<T>(\n value: PendingTransaction extends T ? T : never,\n ): ResultAsync<PendingTransaction, UnexpectedError> {\n if (PendingTransaction.isInstanceOf(value)) {\n return okAsync(value);\n }\n return UnexpectedError.from(value).asResultAsync();\n }\n}\n\nexport type UseSendTransactionResult = UseAsyncTask<\n TransactionRequest,\n PendingTransaction,\n SendTransactionError\n>;\n\n/**\n * The Aave execution plan handler\n */\nexport type ExecutionPlanHandler<\n T,\n R extends Signature | PendingTransaction,\n> = (\n plan: T,\n options: TransactionHandlerOptions,\n) => ResultAsync<R, SendTransactionError>;\n\n/**\n * Tries to create a Signature from an unknown value.\n *\n * @internal\n */\nexport function trySignatureFrom(\n value: unknown,\n): ResultAsync<Signature, UnexpectedError> {\n if (isSignature(value)) {\n return okAsync(value);\n }\n return UnexpectedError.from(\n `Expected Signature, but got ${String(value)}`,\n ).asResultAsync();\n}\n","import {\n type CurrencyQueryOptions,\n DEFAULT_QUERY_OPTIONS,\n type TimeWindowQueryOptions,\n type UnexpectedError,\n} from '@aave/client';\nimport { hubs } from '@aave/client/actions';\nimport {\n type Hub,\n type HubAsset,\n HubAssetsQuery,\n type HubAssetsRequest,\n HubQuery,\n type HubRequest,\n HubSummaryHistoryQuery,\n type HubSummaryHistoryRequest,\n type HubSummarySample,\n HubsQuery,\n type HubsRequest,\n} from '@aave/graphql';\nimport type { NullishDeep, Prettify } from '@aave/types';\nimport { useAaveClient } from './context';\nimport {\n type Pausable,\n type PausableReadResult,\n type PausableSuspenseResult,\n type ReadResult,\n type Suspendable,\n type SuspendableResult,\n type SuspenseResult,\n type UseAsyncTask,\n useAsyncTask,\n useSuspendableQuery,\n} from './helpers';\n\nexport type UseHubArgs = Prettify<\n HubRequest & CurrencyQueryOptions & TimeWindowQueryOptions\n>;\n\n/**\n * Fetch a specific hub by ID or by address and chain ID.\n *\n * This signature supports React Suspense:\n *\n * ```tsx\n * const { data } = useHub({\n * query: { hubId: hubId('SGVsbG8h') },\n * suspense: true,\n * });\n * // data will be Hub | null\n * ```\n */\nexport function useHub(\n args: UseHubArgs & Suspendable,\n): SuspenseResult<Hub | null>;\n/**\n * Fetch a specific hub by ID or by address and chain ID.\n *\n * Pausable suspense mode.\n *\n * ```tsx\n * const { data } = useHub({\n * query: { hubId: hubId('SGVsbG8h') },\n * suspense: true,\n * pause: true,\n * });\n * ```\n */\nexport function useHub(\n args: Pausable<UseHubArgs> & Suspendable,\n): PausableSuspenseResult<Hub | null>;\n/**\n * Fetch a specific hub by ID or by address and chain ID.\n *\n * ```tsx\n * const { data, error, loading } = useHub({\n * query: { hubId: hubId('SGVsbG8h') },\n * });\n * // data will be Hub | null\n * ```\n */\nexport function useHub(args: UseHubArgs): ReadResult<Hub | null>;\n/**\n * Fetch a specific hub by ID or by address and chain ID.\n *\n * Pausable loading state mode.\n *\n * ```tsx\n * const { data, error, loading, paused } = useHub({\n * query: { hubId: hubId('SGVsbG8h') },\n * pause: true,\n * });\n * ```\n */\nexport function useHub(\n args: Pausable<UseHubArgs>,\n): PausableReadResult<Hub | null>;\n\nexport function useHub({\n suspense = false,\n pause = false,\n currency = DEFAULT_QUERY_OPTIONS.currency,\n timeWindow = DEFAULT_QUERY_OPTIONS.timeWindow,\n ...request\n}: NullishDeep<UseHubArgs> & {\n suspense?: boolean;\n pause?: boolean;\n}): SuspendableResult<Hub | null, UnexpectedError> {\n return useSuspendableQuery({\n document: HubQuery,\n variables: {\n request,\n currency,\n timeWindow,\n },\n suspense,\n pause,\n });\n}\n\nexport type UseHubsArgs = Prettify<\n HubsRequest & CurrencyQueryOptions & TimeWindowQueryOptions\n>;\n\n/**\n * Fetch multiple hubs based on specified criteria.\n *\n * This signature supports React Suspense:\n *\n * ```tsx\n * const { data } = useHubs({\n * query: { chainIds: [chainId(1)] },\n * suspense: true,\n * });\n * ```\n */\nexport function useHubs(args: UseHubsArgs & Suspendable): SuspenseResult<Hub[]>;\n/**\n * Fetch multiple hubs based on specified criteria.\n *\n * Pausable suspense mode.\n *\n * ```tsx\n * const { data } = useHubs({\n * query: { chainIds: [chainId(1)] },\n * suspense: true,\n * pause: true,\n * });\n * ```\n */\nexport function useHubs(\n args: Pausable<UseHubsArgs> & Suspendable,\n): PausableSuspenseResult<Hub[]>;\n/**\n * Fetch multiple hubs based on specified criteria.\n *\n * ```tsx\n * const { data, error, loading } = useHubs({\n * query: { chainIds: [chainId(1)] },\n * });\n * ```\n */\nexport function useHubs(args: UseHubsArgs): ReadResult<Hub[]>;\n/**\n * Fetch multiple hubs based on specified criteria.\n *\n * Pausable loading state mode.\n *\n * ```tsx\n * const { data, error, loading, paused } = useHubs({\n * query: { chainIds: [chainId(1)] },\n * pause: true,\n * });\n * ```\n */\nexport function useHubs(args: Pausable<UseHubsArgs>): PausableReadResult<Hub[]>;\n\nexport function useHubs({\n suspense = false,\n pause = false,\n currency = DEFAULT_QUERY_OPTIONS.currency,\n timeWindow = DEFAULT_QUERY_OPTIONS.timeWindow,\n ...request\n}: NullishDeep<UseHubsArgs> & {\n suspense?: boolean;\n pause?: boolean;\n}): SuspendableResult<Hub[], UnexpectedError> {\n return useSuspendableQuery({\n document: HubsQuery,\n variables: {\n request,\n currency,\n timeWindow,\n },\n suspense,\n pause,\n });\n}\n\nexport type UseHubAssetsArgs = Prettify<\n HubAssetsRequest & CurrencyQueryOptions & TimeWindowQueryOptions\n>;\n\n/**\n * Fetch hub assets for a specific hub by ID or by address and chain ID.\n *\n * This signature supports React Suspense:\n *\n * ```tsx\n * const { data } = useHubAssets({\n * query: { hubId: hubId('SGVsbG8h') },\n * user: evmAddress('0x456...'), // optional\n * suspense: true,\n * });\n * ```\n */\nexport function useHubAssets(\n args: UseHubAssetsArgs & Suspendable,\n): SuspenseResult<HubAsset[]>;\n/**\n * Fetch hub assets for a specific hub by ID or by address and chain ID.\n *\n * Pausable suspense mode.\n *\n * ```tsx\n * const { data } = useHubAssets({\n * query: { hubId: hubId('SGVsbG8h') },\n * user: evmAddress('0x456...'), // optional\n * suspense: true,\n * pause: true,\n * });\n * ```\n */\nexport function useHubAssets(\n args: Pausable<UseHubAssetsArgs> & Suspendable,\n): PausableSuspenseResult<HubAsset[]>;\n/**\n * Fetch hub assets for a specific hub by ID or by address and chain ID.\n *\n * ```tsx\n * const { data, error, loading } = useHubAssets({\n * query: { hubId: hubId('SGVsbG8h') },\n * user: evmAddress('0x456...'), // optional\n * });\n * ```\n */\nexport function useHubAssets(args: UseHubAssetsArgs): ReadResult<HubAsset[]>;\n/**\n * Fetch hub assets for a specific hub by ID or by address and chain ID.\n *\n * Pausable loading state mode.\n *\n * ```tsx\n * const { data, error, loading, paused } = useHubAssets({\n * query: { hubId: hubId('SGVsbG8h') },\n * user: evmAddress('0x456...'), // optional\n * pause: true,\n * });\n * ```\n */\nexport function useHubAssets(\n args: Pausable<UseHubAssetsArgs>,\n): PausableReadResult<HubAsset[]>;\n\nexport function useHubAssets({\n suspense = false,\n pause = false,\n currency = DEFAULT_QUERY_OPTIONS.currency,\n timeWindow = DEFAULT_QUERY_OPTIONS.timeWindow,\n ...request\n}: NullishDeep<UseHubAssetsArgs> & {\n suspense?: boolean;\n pause?: boolean;\n}): SuspendableResult<HubAsset[], UnexpectedError> {\n return useSuspendableQuery({\n document: HubAssetsQuery,\n variables: {\n request,\n currency,\n timeWindow,\n },\n suspense,\n pause,\n });\n}\n\nexport type UseHubSummaryHistoryArgs = HubSummaryHistoryRequest;\n\n/**\n * Fetch historical summary data for a specific hub.\n *\n * This signature supports React Suspense:\n *\n * ```tsx\n * const { data } = useHubSummaryHistory({\n * query: { hubId: hubId('SGVsbG8h') },\n * currency: Currency.Usd,\n * window: TimeWindow.LastWeek,\n * suspense: true,\n * });\n * ```\n */\nexport function useHubSummaryHistory(\n args: UseHubSummaryHistoryArgs & Suspendable,\n): SuspenseResult<HubSummarySample[]>;\n/**\n * Fetch historical summary data for a specific hub.\n *\n * Pausable suspense mode.\n *\n * ```tsx\n * const { data } = useHubSummaryHistory({\n * query: { hubId: hubId('SGVsbG8h') },\n * suspense: true,\n * pause: true,\n * });\n * ```\n */\nexport function useHubSummaryHistory(\n args: Pausable<UseHubSummaryHistoryArgs> & Suspendable,\n): PausableSuspenseResult<HubSummarySample[]>;\n/**\n * Fetch historical summary data for a specific hub.\n *\n * ```tsx\n * const { data, error, loading } = useHubSummaryHistory({\n * query: { hubId: hubId('SGVsbG8h') },\n * currency: Currency.Usd,\n * window: TimeWindow.LastWeek,\n * });\n * ```\n */\nexport function useHubSummaryHistory(\n args: UseHubSummaryHistoryArgs,\n): ReadResult<HubSummarySample[]>;\n/**\n * Fetch historical summary data for a specific hub.\n *\n * Pausable loading state mode.\n *\n * ```tsx\n * const { data, error, loading, paused } = useHubSummaryHistory({\n * query: { hubId: hubId('SGVsbG8h') },\n * pause: true,\n * });\n * ```\n */\nexport function useHubSummaryHistory(\n args: Pausable<UseHubSummaryHistoryArgs>,\n): PausableReadResult<HubSummarySample[]>;\n\nexport function useHubSummaryHistory({\n suspense = false,\n pause = false,\n ...request\n}: NullishDeep<UseHubSummaryHistoryArgs> & {\n suspense?: boolean;\n pause?: boolean;\n}): SuspendableResult<HubSummarySample[], UnexpectedError> {\n return useSuspendableQuery({\n document: HubSummaryHistoryQuery,\n variables: {\n request,\n },\n suspense,\n pause,\n batch: false, // Do not batch this since it's a slower than average query\n });\n}\n\n/**\n * Low-level hook to execute a {@link hubs} action directly.\n *\n * @experimental This hook is experimental and may be subject to breaking changes.\n * @remarks\n * This hook **does not** actively watch for updated data on the hubs.\n * Use this hook to retrieve data on demand as part of a larger workflow\n * (e.g., in an event handler in order to move to the next step).\n *\n * ```ts\n * const [execute, { called, data, error, loading }] = useHubsAction();\n *\n * // …\n *\n * const result = await execute({\n * query: {\n * chainIds: [chainId(1)]\n * }\n * });\n *\n * if (result.isOk()) {\n * console.log(result.value); // Hub[]\n * } else {\n * console.error(result.error);\n * }\n * ```\n */\nexport function useHubsAction(\n options: Required<CurrencyQueryOptions> = DEFAULT_QUERY_OPTIONS,\n): UseAsyncTask<HubsRequest, Hub[], UnexpectedError> {\n const client = useAaveClient();\n\n return useAsyncTask(\n (request: HubsRequest) =>\n hubs(client, request, {\n currency: options.currency,\n requestPolicy: 'cache-first',\n }),\n [client, options.currency],\n );\n}\n","import type { CurrencyQueryOptions } from '@aave/client';\nimport { exchangeRate, chain as fetchChain } from '@aave/client/actions';\nimport type { UnexpectedError } from '@aave/core';\nimport type { Chain, ExchangeAmount, ExchangeRateRequest } from '@aave/graphql';\nimport {\n type ActivityItem,\n ChainQuery,\n type ChainRequest,\n ChainsFilter,\n ChainsQuery,\n type ChainsRequest,\n ExchangeRateQuery,\n type NativeAmount,\n type PreviewAction,\n} from '@aave/graphql';\nimport type { NullishDeep, Prettify } from '@aave/types';\nimport { useAaveClient } from './context';\nimport {\n type Pausable,\n type PausableReadResult,\n type PausableSuspenseResult,\n type ReadResult,\n type Suspendable,\n type SuspendableResult,\n type SuspenseResult,\n useSuspendableQuery,\n} from './helpers';\nimport { type UseAsyncTask, useAsyncTask } from './helpers/tasks';\n\nexport type UseChainArgs = ChainRequest;\n\n/**\n * Fetch a specific chain by chain ID.\n *\n * This signature supports React Suspense:\n *\n * ```tsx\n * const { data } = useChain({\n * chainId: chainId(1),\n * suspense: true,\n * });\n * // data will be Chain | null\n * ```\n */\nexport function useChain(\n args: UseChainArgs & Suspendable,\n): SuspenseResult<Chain | null>;\n/**\n * Fetch a specific chain by chain ID.\n *\n * Pausable suspense mode.\n *\n * ```tsx\n * const { data } = useChain({\n * chainId: chainId(1),\n * suspense: true,\n * pause: true,\n * });\n * ```\n */\nexport function useChain(\n args: Pausable<UseChainArgs> & Suspendable,\n): PausableSuspenseResult<Chain | null>;\n/**\n * Fetch a specific chain by chain ID.\n *\n * ```tsx\n * const { data, error, loading } = useChain({\n * chainId: chainId(1),\n * });\n * // data will be Chain | null\n * ```\n */\nexport function useChain(args: UseChainArgs): ReadResult<Chain | null>;\n/**\n * Fetch a specific chain by chain ID.\n *\n * Pausable loading state mode.\n *\n * ```tsx\n * const { data, error, loading, paused } = useChain({\n * chainId: chainId(1),\n * pause: true,\n * });\n * ```\n */\nexport function useChain(\n args: Pausable<UseChainArgs>,\n): PausableReadResult<Chain | null>;\n\nexport function useChain({\n suspense = false,\n pause = false,\n ...request\n}: NullishDeep<UseChainArgs> & {\n suspense?: boolean;\n pause?: boolean;\n}): SuspendableResult<Chain | null, UnexpectedError> {\n return useSuspendableQuery({\n document: ChainQuery,\n variables: {\n request,\n },\n suspense,\n pause,\n });\n}\n\n/**\n * Low-level hook to execute a {@link chain} action directly.\n *\n * @experimental This hook is experimental and may be subject to breaking changes.\n * @remarks\n * This hook **does not** actively watch for updated data on the chain.\n * Use this hook to retrieve data on demand as part of a larger workflow\n * (e.g., in an event handler in order to move to the next step).\n *\n * ```ts\n * const [execute, { called, data, error, loading }] = useChainAction();\n *\n * // …\n *\n * const result = await execute({\n * chainId: chainId(1),\n * });\n *\n * if (result.isOk()) {\n * console.log(result.value); // Chain | null\n * } else {\n * console.error(result.error);\n * }\n * ```\n */\nexport function useChainAction(): UseAsyncTask<\n ChainRequest,\n Chain | null,\n UnexpectedError\n> {\n const client = useAaveClient();\n\n return useAsyncTask(\n (request: ChainRequest) =>\n fetchChain(client, request, {\n batch: false,\n requestPolicy: 'cache-first',\n }),\n [client],\n );\n}\n\nexport type UseChainsArgs = ChainsRequest;\n/**\n * Fetches the list of supported chains.\n *\n * This signature supports React Suspense:\n *\n * ```tsx\n * const { data } = useChains({\n * query: { filter: ChainsFilter.ALL },\n * suspense: true,\n * });\n * ```\n */\nexport function useChains(\n args: UseChainsArgs & Suspendable,\n): SuspenseResult<Chain[]>;\n/**\n * Fetches the list of supported chains.\n *\n * Pausable suspense mode.\n *\n * ```tsx\n * const { data } = useChains({\n * query: { filter: ChainsFilter.ALL },\n * suspense: true,\n * pause: true,\n * });\n * ```\n */\nexport function useChains(\n args: Pausable<UseChainsArgs> & Suspendable,\n): PausableSuspenseResult<Chain[]>;\n/**\n * Fetches the list of supported chains.\n *\n * ```tsx\n * const { data, error, loading } = useChains({\n * query: { filter: ChainsFilter.ALL },\n * });\n * ```\n */\nexport function useChains(args?: UseChainsArgs): ReadResult<Chain[]>;\n/**\n * Fetches the list of supported chains.\n *\n * Pausable loading state mode.\n *\n * ```tsx\n * const { data, error, loading, paused } = useChains({\n * query: { filter: ChainsFilter.ALL },\n * pause: true,\n * });\n * ```\n */\nexport function useChains(\n args?: Pausable<UseChainsArgs>,\n): PausableReadResult<Chain[]>;\n\nexport function useChains(\n {\n suspense = false,\n pause = false,\n ...request\n }: NullishDeep<UseChainsArgs> & {\n suspense?: boolean;\n pause?: boolean;\n } = { query: { filter: ChainsFilter.ALL } },\n): SuspendableResult<Chain[], UnexpectedError> {\n return useSuspendableQuery({\n document: ChainsQuery,\n variables: { request },\n suspense,\n pause,\n });\n}\n\n/**\n * Fetches exchange rates between tokens and fiat currencies.\n *\n * ```tsx\n * const [getExchangeRate, gettingRate] = useExchangeRateAction();\n *\n * const loading = gettingRate.loading;\n * const error = gettingRate.error;\n *\n * // …\n *\n * const result = await getExchangeRate({\n * from: { erc20: { chainId: chainId(1), address: evmAddress('0xA0b86a33E6...') } },\n * to: Currency.Usd,\n * });\n *\n * if (result.isErr()) {\n * console.error(result.error);\n * return;\n * }\n *\n * console.log('Exchange rate:', result.value);\n * ```\n */\nexport function useExchangeRateAction(): UseAsyncTask<\n ExchangeRateRequest,\n ExchangeAmount,\n UnexpectedError\n> {\n const client = useAaveClient();\n\n return useAsyncTask(\n (request: ExchangeRateRequest) =>\n exchangeRate(client, request, { requestPolicy: 'network-only' }),\n [client],\n );\n}\n\nexport type UseExchangeRateArgs = ExchangeRateRequest;\n\n/**\n * Fetches exchange rates between tokens and fiat currencies with automatic polling.\n *\n * This signature supports React Suspense:\n *\n * ```tsx\n * const { data } = useExchangeRate({\n * from: {\n * erc20: {\n * chainId: chainId(1),\n * address: evmAddress('0xA0b86a33E6...')\n * }\n * },\n * to: Currency.Usd,\n * suspense: true,\n * });\n * ```\n */\nexport function useExchangeRate(\n args: UseExchangeRateArgs & Suspendable,\n): SuspenseResult<ExchangeAmount>;\n/**\n * Fetches exchange rates between tokens and fiat currencies with automatic polling.\n *\n * Pausable suspense mode.\n *\n * ```tsx\n * const { data } = useExchangeRate({\n * from: {\n * erc20: {\n * chainId: chainId(1),\n * address: evmAddress('0xA0b86a33E6...')\n * }\n * },\n * to: Currency.Usd,\n * suspense: true,\n * pause: true,\n * });\n * ```\n */\nexport function useExchangeRate(\n args: Pausable<UseExchangeRateArgs> & Suspendable,\n): PausableSuspenseResult<ExchangeAmount>;\n/**\n * Fetches exchange rates between tokens and fiat currencies with automatic polling.\n *\n * ```tsx\n * const { data, error, loading } = useExchangeRate({\n * from: {\n * erc20: {\n * chainId: chainId(1),\n * address: evmAddress('0xA0b86a33E6...')\n * }\n * },\n * to: Currency.Usd,\n * });\n *\n * <Component value={somewhere} fxRate={data} />\n * ```\n */\nexport function useExchangeRate(\n args: UseExchangeRateArgs,\n): ReadResult<ExchangeAmount>;\n/**\n * Fetches exchange rates between tokens and fiat currencies with automatic polling.\n *\n * Pausable loading state mode.\n *\n * ```tsx\n * const { data, error, loading, paused } = useExchangeRate({\n * from: {\n * erc20: {\n * chainId: chainId(1),\n * address: evmAddress('0xA0b86a33E6...')\n * }\n * },\n * to: Currency.Usd,\n * pause: true,\n * });\n * ```\n */\nexport function useExchangeRate(\n args: Pausable<UseExchangeRateArgs>,\n): PausableReadResult<ExchangeAmount>;\n\nexport function useExchangeRate({\n suspense = false,\n pause = false,\n ...request\n}: NullishDeep<UseExchangeRateArgs> & {\n suspense?: boolean;\n pause?: boolean;\n}): SuspendableResult<ExchangeAmount, UnexpectedError> {\n const client = useAaveClient();\n\n return useSuspendableQuery({\n document: ExchangeRateQuery,\n variables: { request },\n suspense,\n pause,\n pollInterval: request.at\n ? 0\n : client.context.environment.exchangeRateInterval,\n });\n}\n\nexport type UseNetworkFeeRequestQuery =\n | {\n activity: ActivityItem;\n }\n | {\n estimate: PreviewAction;\n };\n\nexport type UseNetworkFeeArgs = Prettify<\n {\n query: UseNetworkFeeRequestQuery;\n } & CurrencyQueryOptions\n>;\n\ntype PausableUseNetworkFeeArgs = Partial<\n {\n query: Partial<UseNetworkFeeRequestQuery>;\n } & CurrencyQueryOptions\n>;\n\n/**\n * Fetch the network fee for an ActivityItem.\n *\n * @experimental This hook is experimental and may be subject to breaking changes.\n */\nexport type UseNetworkFee<T extends NativeAmount = NativeAmount> =\n /**\n * Fetches the network fee for a past ActivityItem.\n *\n * This signature supports React Suspense:\n *\n * ```tsx\n * const { data } = useNetworkFee({\n * query: { activity },\n * suspense: true,\n * });\n *\n * data: NativeAmount\n * ```\n */\n ((args: UseNetworkFeeArgs & Suspendable) => SuspenseResult<T>) &\n /**\n * Fetches the network fee for a past ActivityItem.\n *\n * Pausable suspense mode.\n *\n * ```tsx\n * const { data, paused } = useNetworkFee({\n * query: { activity },\n * suspense: true,\n * pause: true,\n * });\n *\n * data: NativeAmount | undefined\n * ```\n */\n ((\n args: Pausable<UseNetworkFeeArgs, PausableUseNetworkFeeArgs> &\n Suspendable,\n ) => PausableSuspenseResult<T>) &\n /**\n * Fetches the network fee for a past ActivityItem.\n *\n * ```tsx\n * const { data, error, loading } = useNetworkFee({\n * query: { activity },\n * });\n * ```\n */\n ((args: UseNetworkFeeArgs) => ReadResult<T>) &\n /**\n * Fetches the network fee for a past ActivityItem.\n *\n * Pausable loading state mode.\n *\n * ```tsx\n * const { data, error, loading, paused } = useNetworkFee({\n * query: { activity },\n * pause: true,\n * });\n *\n * data: NativeAmount | undefined\n * ```\n */\n ((\n args: Pausable<UseNetworkFeeArgs, PausableUseNetworkFeeArgs>,\n ) => PausableReadResult<T>);\n","import {\n type CurrencyQueryOptions,\n DEFAULT_QUERY_OPTIONS,\n type TimeWindowQueryOptions,\n type UnexpectedError,\n} from '@aave/client';\nimport {\n type Asset,\n AssetBorrowHistoryQuery,\n type AssetBorrowHistoryRequest,\n type AssetBorrowSample,\n AssetPriceHistoryQuery,\n type AssetPriceHistoryRequest,\n type AssetPriceSample,\n AssetQuery,\n type AssetRequest,\n AssetSupplyHistoryQuery,\n type AssetSupplyHistoryRequest,\n type AssetSupplySample,\n ProtocolHistoryQuery,\n type ProtocolHistoryRequest,\n type ProtocolHistorySample,\n} from '@aave/graphql';\nimport type { NullishDeep, Prettify } from '@aave/types';\nimport {\n type Pausable,\n type PausableReadResult,\n type PausableSuspenseResult,\n type ReadResult,\n type Suspendable,\n type SuspendableResult,\n type SuspenseResult,\n useSuspendableQuery,\n} from './helpers';\n\nexport type UseAssetArgs = Prettify<\n AssetRequest & CurrencyQueryOptions & TimeWindowQueryOptions\n>;\n\n/**\n * Fetch information about a specific asset (ERC20 token) in the protocol by ID or by token.\n *\n * This signature supports React Suspense:\n *\n * ```tsx\n * const { data } = useAsset({\n * query: { assetId: assetId('SGVsbG8h') },\n * suspense: true,\n * });\n * // data will be Asset | null\n * ```\n */\nexport function useAsset(\n args: UseAssetArgs & Suspendable,\n): SuspenseResult<Asset | null>;\n/**\n * Fetch information about a specific asset (ERC20 token) in the protocol by ID or by token.\n *\n * Pausable suspense mode.\n *\n * ```tsx\n * const { data } = useAsset({\n * query: { assetId: assetId('SGVsbG8h') },\n * suspense: true,\n * pause: true,\n * });\n * ```\n */\nexport function useAsset(\n args: Pausable<UseAssetArgs> & Suspendable,\n): PausableSuspenseResult<Asset | null>;\n/**\n * Fetch information about a specific asset (ERC20 token) in the protocol by ID or by token.\n *\n * ```tsx\n * const { data, error, loading } = useAsset({\n * query: { assetId: assetId('SGVsbG8h') },\n * });\n * // data will be Asset | null\n * ```\n */\nexport function useAsset(args: UseAssetArgs): ReadResult<Asset | null>;\n/**\n * Fetch information about a specific asset (ERC20 token) in the protocol by ID or by token.\n *\n * Pausable loading state mode.\n *\n * ```tsx\n * const { data, error, loading, paused } = useAsset({\n * query: { assetId: assetId('SGVsbG8h') },\n * pause: true,\n * });\n * ```\n */\nexport function useAsset(\n args: Pausable<UseAssetArgs>,\n): PausableReadResult<Asset | null>;\n\nexport function useAsset({\n suspense = false,\n pause = false,\n currency = DEFAULT_QUERY_OPTIONS.currency,\n timeWindow = DEFAULT_QUERY_OPTIONS.timeWindow,\n ...request\n}: NullishDeep<UseAssetArgs> & {\n suspense?: boolean;\n pause?: boolean;\n}): SuspendableResult<Asset | null, UnexpectedError> {\n return useSuspendableQuery({\n document: AssetQuery,\n variables: {\n request,\n currency,\n timeWindow,\n },\n suspense,\n pause,\n });\n}\n\nexport type UseAssetPriceHistoryArgs = AssetPriceHistoryRequest;\n\n/**\n * Fetch historical price data for a specific asset.\n *\n * This signature supports React Suspense:\n *\n * ```tsx\n * const { data } = useAssetPriceHistory({\n * token: { chainId: chainId(1), address: evmAddress('0x123...') },\n * currency: Currency.Usd,\n * window: TimeWindow.LastWeek,\n * suspense: true,\n * });\n * ```\n */\nexport function useAssetPriceHistory(\n args: UseAssetPriceHistoryArgs & Suspendable,\n): SuspenseResult<AssetPriceSample[]>;\n/**\n * Fetch historical price data for a specific asset.\n *\n * Pausable suspense mode.\n *\n * ```tsx\n * const { data } = useAssetPriceHistory({\n * token: { chainId: chainId(1), address: evmAddress('0x123...') },\n * suspense: true,\n * pause: true,\n * });\n * ```\n */\nexport function useAssetPriceHistory(\n args: Pausable<UseAssetPriceHistoryArgs> & Suspendable,\n): PausableSuspenseResult<AssetPriceSample[]>;\n/**\n * Fetch historical price data for a specific asset.\n *\n * ```tsx\n * const { data, error, loading } = useAssetPriceHistory({\n * token: { chainId: chainId(1), address: evmAddress('0x123...') },\n * currency: Currency.Usd,\n * window: TimeWindow.LastWeek,\n * });\n * ```\n */\nexport function useAssetPriceHistory(\n args: UseAssetPriceHistoryArgs,\n): ReadResult<AssetPriceSample[]>;\n/**\n * Fetch historical price data for a specific asset.\n *\n * Pausable loading state mode.\n *\n * ```tsx\n * const { data, error, loading, paused } = useAssetPriceHistory({\n * token: { chainId: chainId(1), address: evmAddress('0x123...') },\n * pause: true,\n * });\n * ```\n */\nexport function useAssetPriceHistory(\n args: Pausable<UseAssetPriceHistoryArgs>,\n): PausableReadResult<AssetPriceSample[]>;\n\nexport function useAssetPriceHistory({\n suspense = false,\n pause = false,\n ...request\n}: NullishDeep<UseAssetPriceHistoryArgs> & {\n suspense?: boolean;\n pause?: boolean;\n}): SuspendableResult<AssetPriceSample[], UnexpectedError> {\n return useSuspendableQuery({\n document: AssetPriceHistoryQuery,\n variables: {\n request,\n },\n suspense,\n pause,\n batch: false, // Do not batch this since it's a slower than average query\n });\n}\n\nexport type UseAssetSupplyHistoryArgs = Prettify<\n AssetSupplyHistoryRequest & CurrencyQueryOptions & TimeWindowQueryOptions\n>;\n\n/**\n * Fetch historical supply data for a specific asset.\n *\n * This signature supports React Suspense:\n *\n * ```tsx\n * const { data } = useAssetSupplyHistory({\n * token: { chainId: chainId(1), address: evmAddress('0x123...') },\n * window: TimeWindow.LastWeek,\n * suspense: true,\n * });\n * ```\n */\nexport function useAssetSupplyHistory(\n args: UseAssetSupplyHistoryArgs & Suspendable,\n): SuspenseResult<AssetSupplySample[]>;\n/**\n * Fetch historical supply data for a specific asset.\n *\n * Pausable suspense mode.\n *\n * ```tsx\n * const { data } = useAssetSupplyHistory({\n * token: { chainId: chainId(1), address: evmAddress('0x123...') },\n * suspense: true,\n * pause: true,\n * });\n * ```\n */\nexport function useAssetSupplyHistory(\n args: Pausable<UseAssetSupplyHistoryArgs> & Suspendable,\n): PausableSuspenseResult<AssetSupplySample[]>;\n/**\n * Fetch historical supply data for a specific asset.\n *\n * ```tsx\n * const { data, error, loading } = useAssetSupplyHistory({\n * token: { chainId: chainId(1), address: evmAddress('0x123...') },\n * window: TimeWindow.LastWeek,\n * });\n * ```\n */\nexport function useAssetSupplyHistory(\n args: UseAssetSupplyHistoryArgs,\n): ReadResult<AssetSupplySample[]>;\n/**\n * Fetch historical supply data for a specific asset.\n *\n * Pausable loading state mode.\n *\n * ```tsx\n * const { data, error, loading, paused } = useAssetSupplyHistory({\n * token: { chainId: chainId(1), address: evmAddress('0x123...') },\n * pause: true,\n * });\n * ```\n */\nexport function useAssetSupplyHistory(\n args: Pausable<UseAssetSupplyHistoryArgs>,\n): PausableReadResult<AssetSupplySample[]>;\n\nexport function useAssetSupplyHistory({\n suspense = false,\n pause = false,\n currency = DEFAULT_QUERY_OPTIONS.currency,\n timeWindow = DEFAULT_QUERY_OPTIONS.timeWindow,\n ...request\n}: NullishDeep<UseAssetSupplyHistoryArgs> & {\n suspense?: boolean;\n pause?: boolean;\n}): SuspendableResult<AssetSupplySample[], UnexpectedError> {\n return useSuspendableQuery({\n document: AssetSupplyHistoryQuery,\n variables: {\n request,\n currency,\n timeWindow,\n },\n suspense,\n pause,\n batch: false, // Do not batch this since it's a slower than average query\n });\n}\n\nexport type UseAssetBorrowHistoryArgs = Prettify<\n AssetBorrowHistoryRequest & CurrencyQueryOptions & TimeWindowQueryOptions\n>;\n\n/**\n * Fetch historical borrow data for a specific asset.\n *\n * This signature supports React Suspense:\n *\n * ```tsx\n * const { data } = useAssetBorrowHistory({\n * token: { chainId: chainId(1), address: evmAddress('0x123...') },\n * window: TimeWindow.LastWeek,\n * suspense: true,\n * });\n * ```\n */\nexport function useAssetBorrowHistory(\n args: UseAssetBorrowHistoryArgs & Suspendable,\n): SuspenseResult<AssetBorrowSample[]>;\n/**\n * Fetch historical borrow data for a specific asset.\n *\n * Pausable suspense mode.\n *\n * ```tsx\n * const { data } = useAssetBorrowHistory({\n * token: { chainId: chainId(1), address: evmAddress('0x123...') },\n * suspense: true,\n * pause: true,\n * });\n * ```\n */\nexport function useAssetBorrowHistory(\n args: Pausable<UseAssetBorrowHistoryArgs> & Suspendable,\n): PausableSuspenseResult<AssetBorrowSample[]>;\n/**\n * Fetch historical borrow data for a specific asset.\n *\n * ```tsx\n * const { data, error, loading } = useAssetBorrowHistory({\n * token: { chainId: chainId(1), address: evmAddress('0x123...') },\n * window: TimeWindow.LastWeek,\n * });\n * ```\n */\nexport function useAssetBorrowHistory(\n args: UseAssetBorrowHistoryArgs,\n): ReadResult<AssetBorrowSample[]>;\n/**\n * Fetch historical borrow data for a specific asset.\n *\n * Pausable loading state mode.\n *\n * ```tsx\n * const { data, error, loading, paused } = useAssetBorrowHistory({\n * token: { chainId: chainId(1), address: evmAddress('0x123...') },\n * pause: true,\n * });\n * ```\n */\nexport function useAssetBorrowHistory(\n args: Pausable<UseAssetBorrowHistoryArgs>,\n): PausableReadResult<AssetBorrowSample[]>;\n\nexport function useAssetBorrowHistory({\n suspense = false,\n pause = false,\n currency = DEFAULT_QUERY_OPTIONS.currency,\n timeWindow = DEFAULT_QUERY_OPTIONS.timeWindow,\n ...request\n}: NullishDeep<UseAssetBorrowHistoryArgs> & {\n suspense?: boolean;\n pause?: boolean;\n}): SuspendableResult<AssetBorrowSample[], UnexpectedError> {\n return useSuspendableQuery({\n document: AssetBorrowHistoryQuery,\n variables: {\n request,\n currency,\n timeWindow,\n },\n suspense,\n pause,\n batch: false, // Do not batch this since it's a slower than average query\n });\n}\n\nexport type UseProtocolHistoryArgs = ProtocolHistoryRequest;\n\n/**\n * Fetch historical protocol-wide data (deposits, borrows, earnings).\n *\n * This signature supports React Suspense:\n *\n * ```tsx\n * const { data } = useProtocolHistory({\n * currency: Currency.Usd,\n * window: TimeWindow.LastWeek,\n * suspense: true,\n * });\n * ```\n */\nexport function useProtocolHistory(\n args: UseProtocolHistoryArgs & Suspendable,\n): SuspenseResult<ProtocolHistorySample[]>;\n/**\n * Fetch historical protocol-wide data (deposits, borrows, earnings).\n *\n * Pausable suspense mode.\n *\n * ```tsx\n * const { data } = useProtocolHistory({\n * currency: Currency.Usd,\n * window: TimeWindow.LastWeek,\n * suspense: true,\n * pause: true,\n * });\n * ```\n */\nexport function useProtocolHistory(\n args: Pausable<UseProtocolHistoryArgs> & Suspendable,\n): PausableSuspenseResult<ProtocolHistorySample[]>;\n/**\n * Fetch historical protocol-wide data (deposits, borrows, earnings).\n *\n * ```tsx\n * const { data, error, loading } = useProtocolHistory({\n * currency: Currency.Usd,\n * window: TimeWindow.LastWeek,\n * });\n * ```\n */\nexport function useProtocolHistory(\n args: UseProtocolHistoryArgs,\n): ReadResult<ProtocolHistorySample[]>;\n/**\n * Fetch historical protocol-wide data (deposits, borrows, earnings).\n *\n * Pausable loading state mode.\n *\n * ```tsx\n * const { data, error, loading, paused } = useProtocolHistory({\n * currency: Currency.Usd,\n * window: TimeWindow.LastWeek,\n * pause: true,\n * });\n * ```\n */\nexport function useProtocolHistory(\n args: Pausable<UseProtocolHistoryArgs>,\n): PausableReadResult<ProtocolHistorySample[]>;\n\nexport function useProtocolHistory({\n suspense = false,\n pause = false,\n ...request\n}: NullishDeep<UseProtocolHistoryArgs> & {\n suspense?: boolean;\n pause?: boolean;\n}): SuspendableResult<ProtocolHistorySample[], UnexpectedError> {\n return useSuspendableQuery({\n document: ProtocolHistoryQuery,\n variables: {\n request,\n },\n suspense,\n pause,\n batch: false, // Do not batch this since it's a slower than average query\n });\n}\n","import {\n type CurrencyQueryOptions,\n DEFAULT_QUERY_OPTIONS,\n type TimeWindowQueryOptions,\n type UnexpectedError,\n} from '@aave/client';\nimport { reserve, reserves } from '@aave/client/actions';\nimport {\n type ApySample,\n BorrowApyHistoryQuery,\n type BorrowApyHistoryRequest,\n type Reserve,\n ReserveQuery,\n type ReserveRequest,\n ReservesQuery,\n type ReservesRequest,\n SupplyApyHistoryQuery,\n type SupplyApyHistoryRequest,\n} from '@aave/graphql';\nimport type { NullishDeep, Prettify } from '@aave/types';\nimport { useAaveClient } from './context';\nimport {\n type Pausable,\n type PausableReadResult,\n type PausableSuspenseResult,\n type ReadResult,\n type Suspendable,\n type SuspendableResult,\n type SuspenseResult,\n type UseAsyncTask,\n useAsyncTask,\n useSuspendableQuery,\n} from './helpers';\n\nexport type UseReserveArgs = Prettify<\n ReserveRequest & CurrencyQueryOptions & TimeWindowQueryOptions\n>;\n\n/**\n * Fetch a specific reserve by reserve ID, spoke, and chain.\n *\n * This signature supports React Suspense:\n *\n * ```tsx\n * const { data } = useReserve({\n * reserve: reserveId('SGVsbG8h'),\n * user: evmAddress('0xabc...'),\n * suspense: true,\n * });\n * // data will be Reserve | null\n * ```\n */\nexport function useReserve(\n args: UseReserveArgs & Suspendable,\n): SuspenseResult<Reserve | null>;\n/**\n * Fetch a specific reserve by reserve ID, spoke, and chain.\n *\n * Pausable suspense mode.\n *\n * ```tsx\n * const { data } = useReserve({\n * reserve: reserveId('SGVsbG8h'),\n * suspense: true,\n * pause: true,\n * });\n * ```\n */\nexport function useReserve(\n args: Pausable<UseReserveArgs> & Suspendable,\n): PausableSuspenseResult<Reserve | null>;\n/**\n * Fetch a specific reserve by reserve ID, spoke, and chain.\n *\n * ```tsx\n * const { data, error, loading } = useReserve({\n * reserve: reserveId('SGVsbG8h'),\n * user: evmAddress('0xabc...'),\n * });\n * // data will be Reserve | null\n * ```\n */\nexport function useReserve(args: UseReserveArgs): ReadResult<Reserve | null>;\n/**\n * Fetch a specific reserve by reserve ID, spoke, and chain.\n *\n * Pausable loading state mode.\n *\n * ```tsx\n * const { data, error, loading, paused } = useReserve({\n * reserve: reserveId('SGVsbG8h'),\n * pause: true,\n * });\n * ```\n */\nexport function useReserve(\n args: Pausable<UseReserveArgs>,\n): PausableReadResult<Reserve | null>;\n\nexport function useReserve({\n suspense = false,\n pause = false,\n currency = DEFAULT_QUERY_OPTIONS.currency,\n timeWindow = DEFAULT_QUERY_OPTIONS.timeWindow,\n ...request\n}: NullishDeep<UseReserveArgs> & {\n suspense?: boolean;\n pause?: boolean;\n}): SuspendableResult<Reserve | null, UnexpectedError> {\n return useSuspendableQuery({\n document: ReserveQuery,\n variables: {\n request,\n currency,\n timeWindow,\n },\n suspense,\n pause,\n });\n}\n\n/**\n * Low-level hook to execute a {@link reserve} action directly.\n *\n * @experimental This hook is experimental and may be subject to breaking changes.\n * @remarks\n * This hook **does not** actively watch for updated data on the reserve.\n * Use this hook to retrieve data on demand as part of a larger workflow\n * (e.g., in an event handler in order to move to the next step).\n *\n * ```ts\n * const [execute, { called, data, error, loading }] = useReserveAction();\n *\n * // …\n *\n * const result = await execute({\n * reserve: reserveId('SGVsbG8h'),\n * });\n *\n * if (result.isOk()) {\n * console.log(result.value); // Reserve | null\n * } else {\n * console.error(result.error);\n * }\n * ```\n */\nexport function useReserveAction(\n options: CurrencyQueryOptions &\n TimeWindowQueryOptions = DEFAULT_QUERY_OPTIONS,\n): UseAsyncTask<ReserveRequest, Reserve | null, UnexpectedError> {\n const client = useAaveClient();\n\n return useAsyncTask(\n (request: ReserveRequest) =>\n reserve(client, request, {\n currency: options.currency ?? DEFAULT_QUERY_OPTIONS.currency,\n timeWindow: options.timeWindow ?? DEFAULT_QUERY_OPTIONS.timeWindow,\n requestPolicy: 'cache-first',\n }),\n [client, options.currency, options.timeWindow],\n );\n}\n\nexport type UseReservesArgs = Prettify<\n ReservesRequest & CurrencyQueryOptions & TimeWindowQueryOptions\n>;\n\n/**\n * Fetch reserves based on specified criteria.\n *\n * This signature supports React Suspense:\n *\n * ```tsx\n * const { data } = useReserves({\n * query: {\n * spoke: {\n * address: evmAddress('0x123...'),\n * chainId: chainId(1)\n * }\n * },\n * filter: ReservesRequestFilter.All,\n * orderBy: { name: 'ASC' },\n * suspense: true,\n * });\n * ```\n */\nexport function useReserves(\n args: UseReservesArgs & Suspendable,\n): SuspenseResult<Reserve[]>;\n/**\n * Fetch reserves based on specified criteria.\n *\n * Pausable suspense mode.\n *\n * ```tsx\n * const { data } = useReserves({\n * query: {\n * spoke: {\n * address: evmAddress('0x123...'),\n * chainId: chainId(1)\n * }\n * },\n * suspense: true,\n * pause: true,\n * });\n * ```\n */\nexport function useReserves(\n args: Pausable<UseReservesArgs> & Suspendable,\n): PausableSuspenseResult<Reserve[]>;\n/**\n * Fetch reserves based on specified criteria.\n *\n * ```tsx\n * const { data, error, loading } = useReserves({\n * query: {\n * spoke: {\n * address: evmAddress('0x123...'),\n * chainId: chainId(1)\n * }\n * },\n * filter: ReservesRequestFilter.All,\n * orderBy: { name: 'ASC' },\n * });\n * ```\n */\nexport function useReserves(\n args: UseReservesArgs,\n): ReadResult<Reserve[], UnexpectedError>;\n/**\n * Fetch reserves based on specified criteria.\n *\n * Pausable loading state mode.\n *\n * ```tsx\n * const { data, error, loading, paused } = useReserves({\n * query: {\n * spoke: {\n * address: evmAddress('0x123...'),\n * chainId: chainId(1)\n * }\n * },\n * pause: true,\n * });\n * ```\n */\nexport function useReserves(\n args: Pausable<UseReservesArgs>,\n): PausableReadResult<Reserve[], UnexpectedError>;\n\nexport function useReserves({\n suspense = false,\n pause = false,\n currency = DEFAULT_QUERY_OPTIONS.currency,\n timeWindow = DEFAULT_QUERY_OPTIONS.timeWindow,\n ...request\n}: NullishDeep<UseReservesArgs> & {\n suspense?: boolean;\n pause?: boolean;\n}): SuspendableResult<Reserve[], UnexpectedError> {\n return useSuspendableQuery({\n document: ReservesQuery,\n variables: {\n request,\n currency,\n timeWindow,\n },\n suspense,\n pause,\n });\n}\n\n/**\n * Low-level hook to execute a {@link reserves} action directly.\n *\n * @experimental This hook is experimental and may be subject to breaking changes.\n * @remarks\n * This hook **does not** actively watch for updated data on the reserves.\n * Use this hook to retrieve data on demand as part of a larger workflow\n * (e.g., in an event handler in order to move to the next step).\n *\n * ```ts\n * const [execute, { called, data, error, loading }] = useReservesAction();\n *\n * // …\n *\n * const result = await execute({\n * query: {\n * spoke: {\n * address: evmAddress('0x1234…'),\n * chainId: chainId(1)\n * }\n * }\n * });\n *\n * if (result.isOk()) {\n * console.log(result.value); // Reserve[]\n * } else {\n * console.error(result.error);\n * }\n * ```\n */\nexport function useReservesAction(\n options: CurrencyQueryOptions &\n TimeWindowQueryOptions = DEFAULT_QUERY_OPTIONS,\n): UseAsyncTask<ReservesRequest, Reserve[], UnexpectedError> {\n const client = useAaveClient();\n\n return useAsyncTask(\n (request: ReservesRequest) =>\n reserves(client, request, {\n currency: options.currency ?? DEFAULT_QUERY_OPTIONS.currency,\n timeWindow: options.timeWindow ?? DEFAULT_QUERY_OPTIONS.timeWindow,\n requestPolicy: 'cache-first',\n }),\n [client, options.currency, options.timeWindow],\n );\n}\n\nexport type UseBorrowApyHistoryArgs = BorrowApyHistoryRequest;\n\n/**\n * Fetch borrow APY history for a specific reserve over time.\n *\n * This signature supports React Suspense:\n *\n * ```tsx\n * const { data } = useBorrowApyHistory({\n * reserve: reserveId('SGVsbG8h'),\n * window: TimeWindow.LastWeek,\n * suspense: true,\n * });\n * ```\n */\nexport function useBorrowApyHistory(\n args: UseBorrowApyHistoryArgs & Suspendable,\n): SuspenseResult<ApySample[]>;\n/**\n * Fetch borrow APY history for a specific reserve over time.\n *\n * Pausable suspense mode.\n *\n * ```tsx\n * const { data } = useBorrowApyHistory({\n * reserve: reserveId('SGVsbG8h'),\n * window: TimeWindow.LastWeek,\n * suspense: true,\n * pause: true,\n * });\n * ```\n */\nexport function useBorrowApyHistory(\n args: Pausable<UseBorrowApyHistoryArgs> & Suspendable,\n): PausableSuspenseResult<ApySample[]>;\n/**\n * Fetch borrow APY history for a specific reserve over time.\n *\n * ```tsx\n * const { data, error, loading } = useBorrowApyHistory({\n * reserve: reserveId('SGVsbG8h'),\n * window: TimeWindow.LastWeek,\n * });\n * ```\n */\nexport function useBorrowApyHistory(\n args: UseBorrowApyHistoryArgs,\n): ReadResult<ApySample[]>;\n/**\n * Fetch borrow APY history for a specific reserve over time.\n *\n * Pausable loading state mode.\n *\n * ```tsx\n * const { data, error, loading, paused } = useBorrowApyHistory({\n * reserve: reserveId('SGVsbG8h'),\n * window: TimeWindow.LastWeek,\n * pause: true,\n * });\n * ```\n */\nexport function useBorrowApyHistory(\n args: Pausable<UseBorrowApyHistoryArgs>,\n): PausableReadResult<ApySample[]>;\n\nexport function useBorrowApyHistory({\n suspense = false,\n pause = false,\n ...request\n}: NullishDeep<UseBorrowApyHistoryArgs> & {\n suspense?: boolean;\n pause?: boolean;\n}): SuspendableResult<ApySample[], UnexpectedError> {\n return useSuspendableQuery({\n document: BorrowApyHistoryQuery,\n variables: {\n request,\n },\n suspense,\n pause,\n batch: false, // Do not batch this since it's a slower than average query\n });\n}\n\nexport type UseSupplyApyHistoryArgs = SupplyApyHistoryRequest;\n\n/**\n * Fetch supply APY history for a specific reserve over time.\n *\n * This signature supports React Suspense:\n *\n * ```tsx\n * const { data } = useSupplyApyHistory({\n * reserve: reserveId('SGVsbG8h'),\n * window: TimeWindow.LastWeek,\n * suspense: true,\n * });\n * ```\n */\nexport function useSupplyApyHistory(\n args: UseSupplyApyHistoryArgs & Suspendable,\n): SuspenseResult<ApySample[]>;\n/**\n * Fetch supply APY history for a specific reserve over time.\n *\n * Pausable suspense mode.\n *\n * ```tsx\n * const { data } = useSupplyApyHistory({\n * reserve: reserveId('SGVsbG8h'),\n * window: TimeWindow.LastWeek,\n * suspense: true,\n * pause: true,\n * });\n * ```\n */\nexport function useSupplyApyHistory(\n args: Pausable<UseSupplyApyHistoryArgs> & Suspendable,\n): PausableSuspenseResult<ApySample[]>;\n/**\n * Fetch supply APY history for a specific reserve over time.\n *\n * ```tsx\n * const { data, error, loading } = useSupplyApyHistory({\n * reserve: reserveId('SGVsbG8h'),\n * window: TimeWindow.LastWeek,\n * });\n * ```\n */\nexport function useSupplyApyHistory(\n args: UseSupplyApyHistoryArgs,\n): ReadResult<ApySample[]>;\n/**\n * Fetch supply APY history for a specific reserve over time.\n *\n * Pausable loading state mode.\n *\n * ```tsx\n * const { data, error, loading, paused } = useSupplyApyHistory({\n * reserve: reserveId('SGVsbG8h'),\n * window: TimeWindow.LastWeek,\n * pause: true,\n * });\n * ```\n */\nexport function useSupplyApyHistory(\n args: Pausable<UseSupplyApyHistoryArgs>,\n): PausableReadResult<ApySample[]>;\n\nexport function useSupplyApyHistory({\n suspense = false,\n pause = false,\n ...request\n}: NullishDeep<UseSupplyApyHistoryArgs> & {\n suspense?: boolean;\n pause?: boolean;\n}): SuspendableResult<ApySample[], UnexpectedError> {\n return useSuspendableQuery({\n document: SupplyApyHistoryQuery,\n variables: {\n request,\n },\n suspense,\n pause,\n batch: false, // Do not batch this since it's a slower than average query\n });\n}\n","import type { UnexpectedError } from '@aave/client';\nimport { userClaimableRewards } from '@aave/client/actions';\nimport {\n type UserClaimableReward,\n UserClaimableRewardsQuery,\n type UserClaimableRewardsRequest,\n} from '@aave/graphql';\nimport type { NullishDeep, Prettify } from '@aave/types';\nimport { useAaveClient } from './context';\nimport {\n type Pausable,\n type PausableReadResult,\n type PausableSuspenseResult,\n type ReadResult,\n type Suspendable,\n type SuspendableResult,\n type SuspenseResult,\n type UseAsyncTask,\n useAsyncTask,\n useSuspendableQuery,\n} from './helpers';\n\nexport type UseUserClaimableRewardsArgs = Prettify<UserClaimableRewardsRequest>;\n\n/**\n * Fetch all claimable rewards for a user.\n *\n * This signature supports React Suspense:\n *\n * ```tsx\n * const { data } = useUserClaimableRewards({\n * user: evmAddress('0x742d35cc…'),\n * suspense: true,\n * });\n * ```\n */\nexport function useUserClaimableRewards(\n args: UseUserClaimableRewardsArgs & Suspendable,\n): SuspenseResult<UserClaimableReward[]>;\n/**\n * Fetch all claimable rewards for a user.\n *\n * Pausable suspense mode.\n *\n * ```tsx\n * const { data } = useUserClaimableRewards({\n * user: evmAddress('0x742d35cc…'),\n * suspense: true,\n * pause: true,\n * });\n * ```\n */\nexport function useUserClaimableRewards(\n args: Pausable<UseUserClaimableRewardsArgs> & Suspendable,\n): PausableSuspenseResult<UserClaimableReward[]>;\n/**\n * Fetch all claimable rewards for a user.\n *\n * ```tsx\n * const { data, error, loading } = useUserClaimableRewards({\n * user: evmAddress('0x742d35cc…'),\n * });\n * ```\n */\nexport function useUserClaimableRewards(\n args: UseUserClaimableRewardsArgs,\n): ReadResult<UserClaimableReward[]>;\n/**\n * Fetch all claimable rewards for a user.\n *\n * Pausable loading state mode.\n *\n * ```tsx\n * const { data, error, loading, paused } = useUserClaimableRewards({\n * user: evmAddress('0x742d35cc…'),\n * pause: true,\n * });\n * ```\n */\nexport function useUserClaimableRewards(\n args: Pausable<UseUserClaimableRewardsArgs>,\n): PausableReadResult<UserClaimableReward[]>;\n\nexport function useUserClaimableRewards({\n suspense = false,\n pause = false,\n ...request\n}: NullishDeep<UseUserClaimableRewardsArgs> & {\n suspense?: boolean;\n pause?: boolean;\n}): SuspendableResult<UserClaimableReward[], UnexpectedError> {\n return useSuspendableQuery({\n document: UserClaimableRewardsQuery,\n variables: { request },\n suspense,\n pause,\n });\n}\n\n/**\n * Low-level hook to execute a {@link userClaimableRewards} action directly.\n *\n * @experimental This hook is experimental and may be subject to breaking changes.\n * @remarks\n * This hook **does not** actively watch for updated data on claimable rewards.\n * Use this hook to retrieve data on demand as part of a larger workflow\n * (e.g., in an event handler in order to move to the next step).\n *\n * ```ts\n * const [execute, { called, data, error, loading }] = useUserClaimableRewardsAction();\n *\n * // …\n *\n * const result = await execute({\n * user: evmAddress('0x742d35cc…'),\n * });\n *\n * if (result.isOk()) {\n * console.log(result.value); // UserClaimableReward[]\n * } else {\n * console.error(result.error);\n * }\n * ```\n */\nexport function useUserClaimableRewardsAction(): UseAsyncTask<\n UserClaimableRewardsRequest,\n UserClaimableReward[],\n UnexpectedError\n> {\n const client = useAaveClient();\n\n return useAsyncTask(\n (request: UserClaimableRewardsRequest) =>\n userClaimableRewards(client, request, {\n requestPolicy: 'cache-first',\n }),\n [client],\n );\n}\n","import type { UnexpectedError } from '@aave/client';\nimport {\n type PaginatedSpokePositionManagerResult,\n type PaginatedSpokeUserPositionManagerResult,\n type Spoke,\n SpokePositionManagersQuery,\n type SpokePositionManagersRequest,\n SpokeQuery,\n type SpokeRequest,\n SpokesQuery,\n type SpokesRequest,\n SpokeUserPositionManagersQuery,\n type SpokeUserPositionManagersRequest,\n} from '@aave/graphql';\nimport type { NullishDeep } from '@aave/types';\nimport {\n type Pausable,\n type PausableReadResult,\n type PausableSuspenseResult,\n type ReadResult,\n type Suspendable,\n type SuspendableResult,\n type SuspenseResult,\n useSuspendableQuery,\n} from './helpers';\n\nexport type UseSpokeArgs = SpokeRequest;\n\n/**\n * Fetch a specific spoke.\n *\n * This signature supports React Suspense:\n *\n * ```tsx\n * const { data } = useSpoke({\n * query: { spokeId: spokeId('SGVsbG8h') },\n * suspense: true,\n * });\n * // data will be Spoke | null\n * ```\n */\nexport function useSpoke(\n args: UseSpokeArgs & Suspendable,\n): SuspenseResult<Spoke | null>;\n/**\n * Fetch a specific spoke.\n *\n * Pausable suspense mode.\n *\n * ```tsx\n * const { data } = useSpoke({\n * query: { spokeId: spokeId('SGVsbG8h') },\n * suspense: true,\n * pause: true,\n * });\n * ```\n */\nexport function useSpoke(\n args: Pausable<UseSpokeArgs> & Suspendable,\n): PausableSuspenseResult<Spoke | null>;\n/**\n * Fetch a specific spoke.\n *\n * ```tsx\n * const { data, error, loading } = useSpoke({\n * query: { spokeId: spokeId('SGVsbG8h') },\n * });\n * // data will be Spoke | null\n * ```\n */\nexport function useSpoke(args: UseSpokeArgs): ReadResult<Spoke | null>;\n/**\n * Fetch a specific spoke.\n *\n * Pausable loading state mode.\n *\n * ```tsx\n * const { data, error, loading, paused } = useSpoke({\n * query: { spokeId: spokeId('SGVsbG8h') },\n * pause: true,\n * });\n * ```\n */\nexport function useSpoke(\n args: Pausable<UseSpokeArgs>,\n): PausableReadResult<Spoke | null>;\n\nexport function useSpoke({\n suspense = false,\n pause = false,\n ...request\n}: NullishDeep<UseSpokeArgs> & {\n suspense?: boolean;\n pause?: boolean;\n}): SuspendableResult<Spoke | null, UnexpectedError> {\n return useSuspendableQuery({\n document: SpokeQuery,\n variables: {\n request,\n },\n suspense,\n pause,\n });\n}\n\nexport type UseSpokesArgs = SpokesRequest;\n\n/**\n * Fetch spokes based on specified criteria.\n *\n * This signature supports React Suspense:\n *\n * ```tsx\n * const { data } = useSpokes({\n * query: { chainIds: [chainId(1)] },\n * suspense: true,\n * });\n * ```\n */\nexport function useSpokes(\n args: UseSpokesArgs & Suspendable,\n): SuspenseResult<Spoke[]>;\n/**\n * Fetch spokes based on specified criteria.\n *\n * Pausable suspense mode.\n *\n * ```tsx\n * const { data } = useSpokes({\n * query: { chainIds: [chainId(1)] },\n * suspense: true,\n * pause: true,\n * });\n * ```\n */\nexport function useSpokes(\n args: Pausable<UseSpokesArgs> & Suspendable,\n): PausableSuspenseResult<Spoke[]>;\n/**\n * Fetch spokes based on specified criteria.\n *\n * ```tsx\n * const { data, error, loading } = useSpokes({\n * query: { chainIds: [chainId(1)] },\n * });\n * ```\n */\nexport function useSpokes(args: UseSpokesArgs): ReadResult<Spoke[]>;\n/**\n * Fetch spokes based on specified criteria.\n *\n * Pausable loading state mode.\n *\n * ```tsx\n * const { data, error, loading, paused } = useSpokes({\n * query: { chainIds: [chainId(1)] },\n * pause: true,\n * });\n * ```\n */\nexport function useSpokes(\n args: Pausable<UseSpokesArgs>,\n): PausableReadResult<Spoke[]>;\n\nexport function useSpokes({\n suspense = false,\n pause = false,\n ...request\n}: NullishDeep<UseSpokesArgs> & {\n suspense?: boolean;\n pause?: boolean;\n}): SuspendableResult<Spoke[], UnexpectedError> {\n return useSuspendableQuery({\n document: SpokesQuery,\n variables: {\n request,\n },\n suspense,\n pause,\n });\n}\n\nexport type UseSpokePositionManagersArgs = SpokePositionManagersRequest;\n\n/**\n * Fetches all the positions manager for a specific spoke.\n *\n * This signature supports React Suspense:\n *\n * ```tsx\n * const { data } = useSpokePositionManagers({\n * spoke: spokeId('SGVsbG8h'),\n * suspense: true,\n * });\n * ```\n */\nexport function useSpokePositionManagers(\n args: UseSpokePositionManagersArgs & Suspendable,\n): SuspenseResult<PaginatedSpokePositionManagerResult>;\n/**\n * Fetches all the positions manager for a specific spoke.\n *\n * Pausable suspense mode.\n *\n * ```tsx\n * const { data } = useSpokePositionManagers({\n * spoke: spokeId('SGVsbG8h'),\n * suspense: true,\n * pause: true,\n * });\n * ```\n */\nexport function useSpokePositionManagers(\n args: Pausable<UseSpokePositionManagersArgs> & Suspendable,\n): PausableSuspenseResult<PaginatedSpokePositionManagerResult>;\n/**\n * Fetches all the positions manager for a specific spoke.\n *\n * ```tsx\n * const { data, error, loading } = useSpokePositionManagers({\n * spoke: spokeId('SGVsbG8h'),\n * });\n * ```\n */\nexport function useSpokePositionManagers(\n args: UseSpokePositionManagersArgs,\n): ReadResult<PaginatedSpokePositionManagerResult>;\n/**\n * Fetches all the positions manager for a specific spoke.\n *\n * Pausable loading state mode.\n *\n * ```tsx\n * const { data, error, loading, paused } = useSpokePositionManagers({\n * spoke: spokeId('SGVsbG8h'),\n * pause: true,\n * });\n * ```\n */\nexport function useSpokePositionManagers(\n args: Pausable<UseSpokePositionManagersArgs>,\n): PausableReadResult<PaginatedSpokePositionManagerResult>;\n\nexport function useSpokePositionManagers({\n suspense = false,\n pause = false,\n ...request\n}: NullishDeep<UseSpokePositionManagersArgs> & {\n suspense?: boolean;\n pause?: boolean;\n}): SuspendableResult<PaginatedSpokePositionManagerResult, UnexpectedError> {\n return useSuspendableQuery({\n document: SpokePositionManagersQuery,\n variables: {\n request,\n },\n suspense,\n pause,\n });\n}\n\nexport type UseSpokeUserPositionManagersArgs = SpokeUserPositionManagersRequest;\n\n/**\n * Fetches all the position managers of a user for a specific spoke\n *\n * This signature supports React Suspense:\n *\n * ```tsx\n * const { data } = useSpokeUserPositionManagers({\n * spoke: spokeId('SGVsbG8h'),\n * user: evmAddress('0x123...'),\n * suspense: true,\n * });\n * ```\n */\nexport function useSpokeUserPositionManagers(\n args: UseSpokeUserPositionManagersArgs & Suspendable,\n): SuspenseResult<PaginatedSpokeUserPositionManagerResult>;\n/**\n * Fetches all the position managers of a user for a specific spoke\n *\n * Pausable suspense mode.\n *\n * ```tsx\n * const { data } = useSpokeUserPositionManagers({\n * spoke: spokeId('SGVsbG8h'),\n * user: evmAddress('0x123...'),\n * suspense: true,\n * pause: true,\n * });\n * ```\n */\nexport function useSpokeUserPositionManagers(\n args: Pausable<UseSpokeUserPositionManagersArgs> & Suspendable,\n): PausableSuspenseResult<PaginatedSpokeUserPositionManagerResult>;\n/**\n * Fetches all the position managers of a user for a specific spoke\n *\n * ```tsx\n * const { data, error, loading } = useSpokeUserPositionManagers({\n * spoke: spokeId('SGVsbG8h'),\n * user: evmAddress('0x123...'),\n * });\n * ```\n */\nexport function useSpokeUserPositionManagers(\n args: UseSpokeUserPositionManagersArgs,\n): ReadResult<PaginatedSpokeUserPositionManagerResult>;\n/**\n * Fetches all the position managers of a user for a specific spoke\n *\n * Pausable loading state mode.\n *\n * ```tsx\n * const { data, error, loading, paused } = useSpokeUserPositionManagers({\n * spoke: spokeId('SGVsbG8h'),\n * user: evmAddress('0x123...'),\n * pause: true,\n * });\n * ```\n */\nexport function useSpokeUserPositionManagers(\n args: Pausable<UseSpokeUserPositionManagersArgs>,\n): PausableReadResult<PaginatedSpokeUserPositionManagerResult>;\n\nexport function useSpokeUserPositionManagers({\n suspense = false,\n pause = false,\n ...request\n}: NullishDeep<UseSpokeUserPositionManagersArgs> & {\n suspense?: boolean;\n pause?: boolean;\n}): SuspendableResult<\n PaginatedSpokeUserPositionManagerResult,\n UnexpectedError\n> {\n return useSuspendableQuery({\n document: SpokeUserPositionManagersQuery,\n variables: {\n request,\n },\n suspense,\n pause,\n });\n}\n","import {\n type AaveClient,\n type CurrencyQueryOptions,\n DEFAULT_QUERY_OPTIONS,\n supportsPermit,\n type TimeWindowQueryOptions,\n} from '@aave/client';\nimport {\n borrowSwapQuote,\n cancelSwap,\n preparePositionSwap,\n prepareSwapCancel,\n prepareTokenSwap,\n repayWithSupplyQuote,\n supplySwapQuote,\n swap,\n swapStatus,\n tokenSwapQuote,\n withdrawSwapQuote,\n} from '@aave/client/actions';\nimport {\n type CancelError,\n type SigningError,\n type TimeoutError,\n type TransactionError,\n UnexpectedError,\n ValidationError,\n} from '@aave/core';\nimport type {\n InsufficientBalanceError,\n InsufficientLiquidityError,\n PaginatedUserSwapsResult,\n PositionSwapApproval,\n PrepareSwapCancelRequest,\n SupplySwapQuoteRequest,\n SwapCancelled,\n SwapCancelledResult,\n SwapQuote,\n SwapReceipt,\n SwapStatus,\n SwapStatusRequest,\n SwapTransactionRequest,\n TokenSwapQuoteRequest,\n UserSwapsRequest,\n} from '@aave/graphql';\nimport {\n BorrowSwapQuoteQuery,\n type BorrowSwapQuoteRequest,\n type Erc20Approval,\n type PositionSwapByIntentApprovalsRequired,\n type PreparePositionSwapRequest,\n QuoteAccuracy,\n RepayWithSupplyQuoteQuery,\n type RepayWithSupplyQuoteRequest,\n SupplySwapQuoteQuery,\n type SwapByIntentInput,\n SwappableTokensQuery,\n type SwappableTokensRequest,\n type SwapRequest,\n SwapStatusQuery,\n type SwapTypedData,\n type Token,\n TokenSwapQuoteQuery,\n type TokenSwapQuoteResult,\n type TransactionRequest,\n UserSwapsQuery,\n WithdrawSwapQuoteQuery,\n type WithdrawSwapQuoteRequest,\n} from '@aave/graphql';\nimport type {\n NullishDeep,\n Prettify,\n Result,\n ResultAsync,\n Signature,\n} from '@aave/types';\nimport {\n err,\n isSignature,\n never,\n ok,\n okAsync,\n ResultAwareError,\n} from '@aave/types';\nimport { useCallback, useEffect, useState } from 'react';\nimport { useAaveClient } from './context';\nimport {\n type CancelOperation,\n cancel,\n type Pausable,\n type PausableReadResult,\n type PausableSuspenseResult,\n PendingTransaction,\n type PendingTransactionError,\n type ReadResult,\n type SendTransactionError,\n type Suspendable,\n type SuspendableResult,\n type SuspenseResult,\n trySignatureFrom,\n useSuspendableQuery,\n} from './helpers';\nimport { type UseAsyncTask, useAsyncTask } from './helpers/tasks';\n\nfunction extractTokenSwapQuote(\n data: TokenSwapQuoteResult,\n): Result<\n SwapQuote,\n ValidationError<InsufficientLiquidityError> | UnexpectedError\n> {\n switch (data.__typename) {\n case 'SwapByIntent':\n case 'SwapByIntentWithApprovalRequired':\n case 'SwapByTransaction':\n return ok(data.quote);\n case 'InsufficientLiquidityError':\n return err(ValidationError.fromGqlNode(data));\n default:\n return err(\n UnexpectedError.upgradeRequired(\n `Unsupported swap quote result: ${data.__typename}`,\n ),\n );\n }\n}\n\nfunction toSwapCancelledResult(cancelled: SwapCancelled): SwapCancelledResult {\n return {\n __typename: 'SwapCancelledResult',\n swapId: cancelled.swapId,\n createdAt: cancelled.createdAt,\n cancelledAt: cancelled.cancelledAt,\n explorerUrl: cancelled.explorerUrl,\n };\n}\n\nfunction extractPositionSwapQuote(\n data: PositionSwapByIntentApprovalsRequired | InsufficientLiquidityError,\n): Result<\n SwapQuote,\n ValidationError<InsufficientLiquidityError> | UnexpectedError\n> {\n switch (data.__typename) {\n case 'PositionSwapByIntentApprovalsRequired':\n return ok(data.quote);\n case 'InsufficientLiquidityError':\n return err(ValidationError.fromGqlNode(data));\n default:\n return err(\n UnexpectedError.upgradeRequired(\n `Unsupported position swap quote result: ${(data as { __typename: string }).__typename}`,\n ),\n );\n }\n}\n\nfunction injectTokenSwapQuoteAccuracy(\n request: NullishDeep<TokenSwapQuoteRequest>,\n accuracy: QuoteAccuracy,\n): NullishDeep<TokenSwapQuoteRequest> {\n if ('market' in request && request.market) {\n return { market: { ...request.market, accuracy } };\n }\n // Limit orders don't have an accuracy field\n return request;\n}\n\nfunction injectSupplySwapQuoteAccuracy(\n request: NullishDeep<SupplySwapQuoteRequest>,\n accuracy: QuoteAccuracy,\n): NullishDeep<SupplySwapQuoteRequest> {\n if ('market' in request && request.market) {\n return { market: { ...request.market, accuracy } };\n }\n return request;\n}\n\nfunction injectBorrowSwapQuoteAccuracy(\n request: NullishDeep<BorrowSwapQuoteRequest>,\n accuracy: QuoteAccuracy,\n): NullishDeep<BorrowSwapQuoteRequest> {\n if ('market' in request && request.market) {\n return { market: { ...request.market, accuracy } };\n }\n return request;\n}\n\nfunction injectRepayWithSupplyQuoteAccuracy(\n request: NullishDeep<RepayWithSupplyQuoteRequest>,\n accuracy: QuoteAccuracy,\n): NullishDeep<RepayWithSupplyQuoteRequest> {\n if ('market' in request && request.market) {\n return { market: { ...request.market, accuracy } };\n }\n return request;\n}\n\nfunction injectWithdrawSwapQuoteAccuracy(\n request: NullishDeep<WithdrawSwapQuoteRequest>,\n accuracy: QuoteAccuracy,\n): NullishDeep<WithdrawSwapQuoteRequest> {\n if ('market' in request && request.market) {\n return { market: { ...request.market, accuracy } };\n }\n return request;\n}\n\nexport type UseTokenSwapQuoteArgs = Prettify<\n TokenSwapQuoteRequest & CurrencyQueryOptions\n>;\n\n/**\n * Fetch a swap quote for the specified trade parameters.\n *\n * This signature supports React Suspense:\n *\n * ```tsx\n * const { data } = useTokenSwapQuote({\n * market: {\n * buy: { erc20: evmAddress('0xA0b86a33E6…') },\n * sell: { erc20: evmAddress('0x6B175474E…') },\n * amount: bigDecimal('1000'),\n * kind: SwapKind.Sell,\n * user: evmAddress('0x742d35cc…'),\n * },\n * chainId: chainId(1),\n * suspense: true,\n * });\n * ```\n */\nexport function useTokenSwapQuote(\n args: UseTokenSwapQuoteArgs & Suspendable,\n): SuspenseResult<SwapQuote>;\n/**\n * Fetch a swap quote for the specified trade parameters.\n *\n * Pausable suspense mode.\n *\n * ```tsx\n * const { data } = useTokenSwapQuote({\n * market: {\n * chainId: chainId(1),\n * buy: { erc20: evmAddress('0xA0b86a33E6…') },\n * sell: { erc20: evmAddress('0x6B175474E…') },\n * amount: bigDecimal('1000'),\n * kind: SwapKind.Sell,\n * user: evmAddress('0x742d35cc…'),\n * },\n * suspense: true,\n * pause: true,\n * });\n * ```\n */\nexport function useTokenSwapQuote(\n args: Pausable<UseTokenSwapQuoteArgs> & Suspendable,\n): PausableSuspenseResult<SwapQuote>;\n/**\n * Fetch a swap quote for the specified trade parameters.\n *\n * ```tsx\n * const { data, error, loading } = useTokenSwapQuote({\n * market: {\n * chainId: chainId(1),\n * buy: { erc20: evmAddress('0xA0b86a33E6…') },\n * sell: { erc20: evmAddress('0x6B175474E…') },\n * amount: bigDecimal('1000'),\n * kind: SwapKind.Sell,\n * user: evmAddress('0x742d35cc…'),\n * },\n * });\n * ```\n */\nexport function useTokenSwapQuote(\n args: UseTokenSwapQuoteArgs,\n): ReadResult<SwapQuote>;\n/**\n * Fetch a swap quote for the specified trade parameters.\n *\n * Pausable loading state mode.\n *\n * ```tsx\n * const { data, error, loading, paused } = useTokenSwapQuote({\n * market: {\n * chainId: chainId(1),\n * buy: { erc20: evmAddress('0xA0b86a33E6…') },\n * sell: { erc20: evmAddress('0x6B175474E…') },\n * amount: bigDecimal('1000'),\n * kind: SwapKind.Sell,\n * user: evmAddress('0x742d35cc…'),\n * },\n * pause: true,\n * });\n * ```\n */\nexport function useTokenSwapQuote(\n args: Pausable<UseTokenSwapQuoteArgs>,\n): PausableReadResult<SwapQuote>;\n\nexport function useTokenSwapQuote({\n suspense = false,\n pause = false,\n currency = DEFAULT_QUERY_OPTIONS.currency,\n ...request\n}: NullishDeep<UseTokenSwapQuoteArgs> & {\n suspense?: boolean;\n pause?: boolean;\n}): SuspendableResult<\n SwapQuote,\n UnexpectedError | ValidationError<InsufficientLiquidityError>\n> {\n const client = useAaveClient();\n\n // Fast query - no polling, suspends in suspense mode for quick initial render\n const fastResult = useSuspendableQuery({\n document: TokenSwapQuoteQuery,\n variables: {\n request: injectTokenSwapQuoteAccuracy(request, QuoteAccuracy.Fast),\n currency,\n },\n selector: extractTokenSwapQuote,\n suspense,\n pause,\n batch: false, // Don't batch with Accurate query\n });\n\n // Accurate query - with polling, never suspends, fires after Fast in suspense mode\n const accurateResult = useSuspendableQuery({\n document: TokenSwapQuoteQuery,\n variables: {\n request: injectTokenSwapQuoteAccuracy(request, QuoteAccuracy.Accurate),\n currency,\n },\n selector: extractTokenSwapQuote,\n suspense: false, // Never suspend on Accurate (would cause re-suspend)\n pause: pause || (suspense && !fastResult.data),\n pollInterval: client.context.environment.swapQuoteInterval,\n batch: false, // Don't batch with Fast query\n });\n\n if (accurateResult.data) {\n return accurateResult;\n }\n\n return fastResult;\n}\n\n/**\n * Low-level hook to execute a swap quote action directly.\n *\n * @remarks\n * This hook **does not** actively watch for updated data on the swap quote.\n * Use this hook to retrieve quotes on demand as part of a larger workflow\n * (e.g., in an event handler to get a fresh quote before executing a swap).\n *\n * ```ts\n * const [getQuote, { called, data, error, loading }] = useTokenSwapQuoteAction();\n *\n * // …\n *\n * const result = await getQuote({\n * market: {\n * chainId: chainId(1),\n * buy: { erc20: evmAddress('0xA0b86a33E6…') },\n * sell: { erc20: evmAddress('0x6B175474E…') },\n * amount: bigDecimal('1000'),\n * kind: SwapKind.Sell,\n * },\n * });\n *\n * if (result.isOk()) {\n * console.log('Swap quote:', result.value);\n * } else {\n * console.error(result.error);\n * }\n * ```\n */\nexport function useTokenSwapQuoteAction(\n options: Required<CurrencyQueryOptions> = DEFAULT_QUERY_OPTIONS,\n): UseAsyncTask<\n TokenSwapQuoteRequest,\n SwapQuote,\n UnexpectedError | ValidationError<InsufficientLiquidityError>\n> {\n const client = useAaveClient();\n\n return useAsyncTask(\n (request: TokenSwapQuoteRequest) =>\n tokenSwapQuote(client, request, {\n currency: options.currency,\n requestPolicy: 'network-only',\n }).andThen(extractTokenSwapQuote),\n [client, options.currency],\n );\n}\n\nexport type UseSwappableTokensArgs = SwappableTokensRequest;\n\n/**\n * Fetch the list of tokens available for swapping on a specific chain.\n *\n * This signature supports React Suspense:\n *\n * ```tsx\n * const { data } = useSwappableTokens({\n * query: { chainIds: [chainId(1)] },\n * suspense: true,\n * });\n * ```\n */\nexport function useSwappableTokens(\n args: UseSwappableTokensArgs & Suspendable,\n): SuspenseResult<Token[]>;\n/**\n * Fetch the list of tokens available for swapping on a specific chain.\n *\n * Pausable suspense mode.\n *\n * ```tsx\n * const { data } = useSwappableTokens({\n * query: { chainIds: [chainId(1)] },\n * suspense: true,\n * pause: true,\n * });\n * ```\n */\nexport function useSwappableTokens(\n args: Pausable<UseSwappableTokensArgs> & Suspendable,\n): PausableSuspenseResult<Token[]>;\n/**\n * Fetch the list of tokens available for swapping on a specific chain.\n *\n * ```tsx\n * const { data, error, loading } = useSwappableTokens({\n * query: { chainIds: [chainId(1)] },\n * });\n * ```\n */\nexport function useSwappableTokens(\n args: UseSwappableTokensArgs,\n): ReadResult<Token[]>;\n/**\n * Fetch the list of tokens available for swapping on a specific chain.\n *\n * Pausable loading state mode.\n *\n * ```tsx\n * const { data, error, loading, paused } = useSwappableTokens({\n * query: { chainIds: [chainId(1)] },\n * pause: true,\n * });\n * ```\n */\nexport function useSwappableTokens(\n args: Pausable<UseSwappableTokensArgs>,\n): PausableReadResult<Token[]>;\n\nexport function useSwappableTokens({\n suspense = false,\n pause = false,\n ...request\n}: NullishDeep<UseSwappableTokensArgs> & {\n suspense?: boolean;\n pause?: boolean;\n}): SuspendableResult<Token[], UnexpectedError> {\n return useSuspendableQuery({\n document: SwappableTokensQuery,\n variables: {\n request,\n },\n suspense,\n pause,\n });\n}\n\nexport type UseUserSwapsArgs = Prettify<\n UserSwapsRequest & CurrencyQueryOptions & TimeWindowQueryOptions\n>;\n\n/**\n * Fetch the user's swap history for a specific chain.\n *\n * This signature supports React Suspense:\n *\n * ```tsx\n * const { data } = useUserSwaps({\n * chainId: chainId(1),\n * user: evmAddress('0x742d35cc…'),\n * filterBy: [SwapStatusFilter.FULFILLED, SwapStatusFilter.OPEN],\n * suspense: true,\n * });\n * ```\n */\nexport function useUserSwaps(\n args: UseUserSwapsArgs & Suspendable,\n): SuspenseResult<PaginatedUserSwapsResult>;\n/**\n * Fetch the user's swap history for a specific chain.\n *\n * Pausable suspense mode.\n *\n * ```tsx\n * const { data } = useUserSwaps({\n * chainId: chainId(1),\n * user: evmAddress('0x742d35cc…'),\n * filterBy: [SwapStatusFilter.FULFILLED, SwapStatusFilter.OPEN],\n * suspense: true,\n * pause: true,\n * });\n * ```\n */\nexport function useUserSwaps(\n args: Pausable<UseUserSwapsArgs> & Suspendable,\n): PausableSuspenseResult<PaginatedUserSwapsResult>;\n/**\n * Fetch the user's swap history for a specific chain.\n *\n * ```tsx\n * const { data, error, loading } = useUserSwaps({\n * chainId: chainId(1),\n * user: evmAddress('0x742d35cc…'),\n * filterBy: [SwapStatusFilter.FULFILLED, SwapStatusFilter.OPEN],\n * });\n * ```\n */\nexport function useUserSwaps(\n args: UseUserSwapsArgs,\n): ReadResult<PaginatedUserSwapsResult>;\n/**\n * Fetch the user's swap history for a specific chain.\n *\n * Pausable loading state mode.\n *\n * ```tsx\n * const { data, error, loading, paused } = useUserSwaps({\n * chainId: chainId(1),\n * user: evmAddress('0x742d35cc…'),\n * filterBy: [SwapStatusFilter.FULFILLED, SwapStatusFilter.OPEN],\n * pause: true,\n * });\n * ```\n */\nexport function useUserSwaps(\n args: Pausable<UseUserSwapsArgs>,\n): PausableReadResult<PaginatedUserSwapsResult>;\n\nexport function useUserSwaps({\n suspense = false,\n pause = false,\n currency = DEFAULT_QUERY_OPTIONS.currency,\n timeWindow = DEFAULT_QUERY_OPTIONS.timeWindow,\n ...request\n}: NullishDeep<UseUserSwapsArgs> & {\n suspense?: boolean;\n pause?: boolean;\n}): SuspendableResult<PaginatedUserSwapsResult, UnexpectedError> {\n const client = useAaveClient();\n const [allTerminal, setAllTerminal] = useState(false);\n\n const result: SuspendableResult<PaginatedUserSwapsResult, UnexpectedError> =\n useSuspendableQuery({\n document: UserSwapsQuery,\n variables: { request, currency, timeWindow },\n suspense,\n pause: pause || allTerminal,\n pollInterval: client.context.environment.swapStatusInterval,\n });\n\n useEffect(() => {\n if (result.data && result.data.items.length > 0) {\n const allItemsTerminal = result.data.items.every(isTerminalSwapStatus);\n if (allItemsTerminal) {\n setAllTerminal(true);\n }\n }\n }, [result.data]);\n\n return result;\n}\n\n// ------------------------------------------------------------\n\nfunction isTerminalSwapStatus(data: SwapStatus): boolean {\n return (\n data.__typename === 'SwapFulfilled' ||\n data.__typename === 'SwapCancelled' ||\n data.__typename === 'SwapExpired'\n );\n}\n\nexport type UseSwapStatusArgs = Prettify<\n SwapStatusRequest & CurrencyQueryOptions & TimeWindowQueryOptions\n>;\n\n/**\n * Monitor the status of a single swap operation in real-time.\n *\n * Polls automatically until the swap reaches a terminal state (fulfilled, cancelled, or expired).\n *\n * This signature supports React Suspense:\n *\n * ```tsx\n * const { data } = useSwapStatus({\n * id: swapReceipt.id,\n * suspense: true,\n * });\n * ```\n */\nexport function useSwapStatus(\n args: UseSwapStatusArgs & Suspendable,\n): SuspenseResult<SwapStatus>;\n/**\n * Monitor the status of a single swap operation in real-time.\n *\n * Pausable suspense mode.\n *\n * ```tsx\n * const { data } = useSwapStatus({\n * id: swapReceipt.id,\n * suspense: true,\n * pause: shouldPause,\n * });\n * ```\n */\nexport function useSwapStatus(\n args: Pausable<UseSwapStatusArgs> & Suspendable,\n): PausableSuspenseResult<SwapStatus>;\n/**\n * Monitor the status of a single swap operation in real-time.\n *\n * Polls automatically until the swap reaches a terminal state (fulfilled, cancelled, or expired).\n *\n * ```tsx\n * const { data, error, loading } = useSwapStatus({\n * id: swapReceipt.id,\n * });\n * ```\n */\nexport function useSwapStatus(args: UseSwapStatusArgs): ReadResult<SwapStatus>;\n/**\n * Monitor the status of a single swap operation in real-time.\n *\n * Pausable loading state mode.\n *\n * ```tsx\n * const { data, error, loading, paused } = useSwapStatus({\n * id: swapReceipt.id,\n * pause: shouldPause,\n * });\n * ```\n */\nexport function useSwapStatus(\n args: Pausable<UseSwapStatusArgs>,\n): PausableReadResult<SwapStatus>;\n\nexport function useSwapStatus({\n suspense = false,\n pause = false,\n currency = DEFAULT_QUERY_OPTIONS.currency,\n timeWindow = DEFAULT_QUERY_OPTIONS.timeWindow,\n ...request\n}: NullishDeep<UseSwapStatusArgs> & {\n suspense?: boolean;\n pause?: boolean;\n}): SuspendableResult<SwapStatus, UnexpectedError> {\n const client = useAaveClient();\n const [isTerminal, setIsTerminal] = useState(false);\n\n const result: SuspendableResult<SwapStatus, UnexpectedError> =\n useSuspendableQuery({\n document: SwapStatusQuery,\n variables: { request, currency, timeWindow },\n suspense,\n pause: pause || isTerminal,\n pollInterval: client.context.environment.swapStatusInterval,\n });\n\n useEffect(() => {\n if (result.data && isTerminalSwapStatus(result.data)) {\n setIsTerminal(true);\n }\n }, [result.data]);\n\n return result;\n}\n\n// ------------------------------------------------------------\n\nexport type UseSupplySwapQuoteArgs = Prettify<\n SupplySwapQuoteRequest & CurrencyQueryOptions\n>;\n\n/**\n * Fetch a quote for a supply swap operation with the specified parameters.\n *\n * This signature supports React Suspense:\n *\n * ```tsx\n * const { data } = useSupplySwapQuote({\n * market: {\n * sellPosition: userSupplyItem.id,\n * buyReserve: reserve.id,\n * amount: bigDecimal('1000'),\n * user: evmAddress('0x742d35cc…'),\n * },\n * suspense: true,\n * });\n * ```\n */\nexport function useSupplySwapQuote(\n args: UseSupplySwapQuoteArgs & Suspendable,\n): SuspenseResult<SwapQuote>;\n/**\n * Fetch a quote for a supply swap operation with the specified parameters.\n *\n * Pausable suspense mode.\n *\n * ```tsx\n * const { data } = useSupplySwapQuote({\n * market: {\n * sellPosition: userSupplyItem.id,\n * buyReserve: reserve.id,\n * amount: bigDecimal('1000'),\n * user: evmAddress('0x742d35cc…'),\n * },\n * suspense: true,\n * pause: true,\n * });\n * ```\n */\nexport function useSupplySwapQuote(\n args: Pausable<UseSupplySwapQuoteArgs> & Suspendable,\n): PausableSuspenseResult<SwapQuote>;\n/**\n * Fetch a quote for a supply swap operation with the specified parameters.\n *\n * ```tsx\n * const { data, error, loading } = useSupplySwapQuote({\n * market: {\n * sellPosition: userSupplyItem.id,\n * buyReserve: reserve.id,\n * amount: bigDecimal('1000'),\n * user: evmAddress('0x742d35cc…'),\n * },\n * });\n * ```\n */\nexport function useSupplySwapQuote(\n args: UseSupplySwapQuoteArgs,\n): ReadResult<SwapQuote>;\n/**\n * Fetch a quote for a supply swap operation with the specified parameters.\n *\n * Pausable loading state mode.\n *\n * ```tsx\n * const { data, error, loading, paused } = useSupplySwapQuote({\n * market: {\n * sellPosition: userSupplyItem.id,\n * buyReserve: reserve.id,\n * amount: bigDecimal('1000'),\n * user: evmAddress('0x742d35cc…'),\n * },\n * pause: true,\n * });\n * ```\n */\nexport function useSupplySwapQuote(\n args: Pausable<UseSupplySwapQuoteArgs>,\n): PausableReadResult<SwapQuote>;\n\nexport function useSupplySwapQuote({\n suspense = false,\n pause = false,\n currency = DEFAULT_QUERY_OPTIONS.currency,\n ...request\n}: NullishDeep<UseSupplySwapQuoteArgs> & {\n suspense?: boolean;\n pause?: boolean;\n}): SuspendableResult<\n SwapQuote,\n UnexpectedError | ValidationError<InsufficientLiquidityError>\n> {\n const client = useAaveClient();\n\n // Fast query - no polling, suspends in suspense mode for quick initial render\n const fastResult = useSuspendableQuery({\n document: SupplySwapQuoteQuery,\n variables: {\n request: injectSupplySwapQuoteAccuracy(request, QuoteAccuracy.Fast),\n currency,\n },\n selector: extractPositionSwapQuote,\n suspense,\n pause,\n batch: false, // Don't batch with Accurate query\n });\n\n // Accurate query - with polling, never suspends, fires after Fast in suspense mode\n const accurateResult = useSuspendableQuery({\n document: SupplySwapQuoteQuery,\n variables: {\n request: injectSupplySwapQuoteAccuracy(request, QuoteAccuracy.Accurate),\n currency,\n },\n selector: extractPositionSwapQuote,\n suspense: false, // Never suspend on Accurate (would cause re-suspend)\n pause: pause || (suspense && !fastResult.data),\n pollInterval: client.context.environment.swapQuoteInterval,\n batch: false, // Don't batch with Fast query\n });\n\n if (accurateResult.data) {\n return accurateResult;\n }\n\n return fastResult;\n}\n\n/**\n * Low-level hook to execute a supply swap quote action directly.\n *\n * @remarks\n * This hook **does not** actively watch for updated data on the swap quote.\n * Use this hook to retrieve quotes on demand as part of a larger workflow.\n *\n * ```ts\n * const [getQuote, { called, data, error, loading }] = useSupplySwapQuoteAction();\n *\n * // …\n *\n * const result = await getQuote({\n * sellPosition: userSupplyItem.id,\n * buyReserve: reserve.id,\n * amount: bigDecimal('1000'),\n * user: evmAddress('0x742d35cc…'),\n * });\n *\n * if (result.isOk()) {\n * console.log('Supply swap quote:', result.value);\n * } else {\n * console.error(result.error);\n * }\n * ```\n */\nexport function useSupplySwapQuoteAction(\n options: Required<CurrencyQueryOptions> = DEFAULT_QUERY_OPTIONS,\n): UseAsyncTask<\n SupplySwapQuoteRequest,\n SwapQuote,\n UnexpectedError | ValidationError<InsufficientLiquidityError>\n> {\n const client = useAaveClient();\n\n return useAsyncTask(\n (request: SupplySwapQuoteRequest) =>\n supplySwapQuote(client, request, {\n currency: options.currency,\n requestPolicy: 'network-only',\n }).andThen(extractPositionSwapQuote),\n [client, options.currency],\n );\n}\n\n// ------------------------------------------------------------\n\nexport type UseBorrowSwapQuoteArgs = Prettify<\n BorrowSwapQuoteRequest & CurrencyQueryOptions\n>;\n\n/**\n * Fetch a quote for a borrow swap operation with the specified parameters.\n *\n * This signature supports React Suspense:\n *\n * ```tsx\n * const { data } = useBorrowSwapQuote({\n * market: {\n * sellPosition: userBorrowItem.id,\n * buyReserve: reserve.id,\n * amount: bigDecimal('1000'),\n * user: evmAddress('0x742d35cc…'),\n * },\n * suspense: true,\n * });\n * ```\n */\nexport function useBorrowSwapQuote(\n args: UseBorrowSwapQuoteArgs & Suspendable,\n): SuspenseResult<SwapQuote>;\n/**\n * Fetch a quote for a borrow swap operation with the specified parameters.\n *\n * Pausable suspense mode.\n *\n * ```tsx\n * const { data } = useBorrowSwapQuote({\n * market: {\n * sellPosition: userBorrowItem.id,\n * buyReserve: reserve.id,\n * amount: bigDecimal('1000'),\n * user: evmAddress('0x742d35cc…'),\n * },\n * suspense: true,\n * pause: true,\n * });\n * ```\n */\nexport function useBorrowSwapQuote(\n args: Pausable<UseBorrowSwapQuoteArgs> & Suspendable,\n): PausableSuspenseResult<SwapQuote>;\n/**\n * Fetch a quote for a borrow swap operation with the specified parameters.\n *\n * ```tsx\n * const { data, error, loading } = useBorrowSwapQuote({\n * market: {\n * sellPosition: userBorrowItem.id,\n * buyReserve: reserve.id,\n * amount: bigDecimal('1000'),\n * user: evmAddress('0x742d35cc…'),\n * },\n * });\n * ```\n */\nexport function useBorrowSwapQuote(\n args: UseBorrowSwapQuoteArgs,\n): ReadResult<SwapQuote>;\n/**\n * Fetch a quote for a borrow swap operation with the specified parameters.\n *\n * Pausable loading state mode.\n *\n * ```tsx\n * const { data, error, loading, paused } = useBorrowSwapQuote({\n * market: {\n * sellPosition: userBorrowItem.id,\n * buyReserve: reserve.id,\n * amount: bigDecimal('1000'),\n * user: evmAddress('0x742d35cc…'),\n * },\n * pause: true,\n * });\n * ```\n */\nexport function useBorrowSwapQuote(\n args: Pausable<UseBorrowSwapQuoteArgs>,\n): PausableReadResult<SwapQuote>;\n\nexport function useBorrowSwapQuote({\n suspense = false,\n pause = false,\n currency = DEFAULT_QUERY_OPTIONS.currency,\n ...request\n}: NullishDeep<UseBorrowSwapQuoteArgs> & {\n suspense?: boolean;\n pause?: boolean;\n}): SuspendableResult<\n SwapQuote,\n UnexpectedError | ValidationError<InsufficientLiquidityError>\n> {\n const client = useAaveClient();\n\n // Fast query - no polling, suspends in suspense mode for quick initial render\n const fastResult = useSuspendableQuery({\n document: BorrowSwapQuoteQuery,\n variables: {\n request: injectBorrowSwapQuoteAccuracy(request, QuoteAccuracy.Fast),\n currency,\n },\n selector: extractPositionSwapQuote,\n suspense,\n pause,\n batch: false, // Don't batch with Accurate query\n });\n\n // Accurate query - with polling, never suspends, fires after Fast in suspense mode\n const accurateResult = useSuspendableQuery({\n document: BorrowSwapQuoteQuery,\n variables: {\n request: injectBorrowSwapQuoteAccuracy(request, QuoteAccuracy.Accurate),\n currency,\n },\n selector: extractPositionSwapQuote,\n suspense: false, // Never suspend on Accurate (would cause re-suspend)\n pause: pause || (suspense && !fastResult.data),\n pollInterval: client.context.environment.swapQuoteInterval,\n batch: false, // Don't batch with Fast query\n });\n\n if (accurateResult.data) {\n return accurateResult;\n }\n\n return fastResult;\n}\n\n/**\n * Low-level hook to execute a borrow swap quote action directly.\n *\n * @remarks\n * This hook **does not** actively watch for updated data on the swap quote.\n * Use this hook to retrieve quotes on demand as part of a larger workflow.\n *\n * ```ts\n * const [getQuote, { called, data, error, loading }] = useBorrowSwapQuoteAction();\n *\n * // …\n *\n * const result = await getQuote({\n * debtPosition: userBorrowItem.id,\n * buyReserve: reserve.id,\n * amount: bigDecimal('1000'),\n * user: evmAddress('0x742d35cc…'),\n * });\n *\n * if (result.isOk()) {\n * console.log('Borrow swap quote:', result.value);\n * } else {\n * console.error(result.error);\n * }\n * ```\n */\nexport function useBorrowSwapQuoteAction(\n options: Required<CurrencyQueryOptions> = DEFAULT_QUERY_OPTIONS,\n): UseAsyncTask<\n BorrowSwapQuoteRequest,\n SwapQuote,\n UnexpectedError | ValidationError<InsufficientLiquidityError>\n> {\n const client = useAaveClient();\n\n return useAsyncTask(\n (request: BorrowSwapQuoteRequest) =>\n borrowSwapQuote(client, request, {\n currency: options.currency,\n requestPolicy: 'network-only',\n }).andThen(extractPositionSwapQuote),\n [client, options.currency],\n );\n}\n\n// ------------------------------------------------------------\n\nexport type SwapHandlerOptions = {\n cancel: CancelOperation;\n};\n\nexport type SwapSignerError = CancelError | SigningError | UnexpectedError;\n\n// ------------------------------------------------------------\n\nexport type PositionSwapPlan = PositionSwapApproval | SwapTypedData;\n\nexport type PositionSwapHandler = (\n plan: PositionSwapPlan,\n options: SwapHandlerOptions,\n) => ResultAsync<PendingTransaction | Signature, SwapSignerError>;\n\nexport type PositionSwapValue = {\n quote?: SwapQuote;\n};\n\nfunction processApprovals(result: PositionSwapByIntentApprovalsRequired) {\n return {\n with: (\n handler: PositionSwapHandler,\n ): ResultAsync<PreparePositionSwapRequest, SwapSignerError> =>\n result.approvals.reduce<\n ResultAsync<PreparePositionSwapRequest, SwapSignerError>\n >(\n (acc, approval) =>\n acc.andThen((request) =>\n handler(approval, { cancel }).map((value) => {\n switch (approval.__typename) {\n case 'PositionSwapAdapterContractApproval':\n request.adapterContractSignature = isSignature(value)\n ? value\n : null;\n break;\n case 'PositionSwapPositionManagerApproval':\n request.positionManagerSignature = isSignature(value)\n ? value\n : null;\n break;\n }\n return request;\n }),\n ),\n okAsync({\n quoteId: result.quote.quoteId,\n adapterContractSignature: null,\n positionManagerSignature: null,\n }),\n ),\n };\n}\n\nfunction swapPosition(\n client: AaveClient,\n intent: SwapByIntentInput,\n): ResultAsync<\n SwapReceipt,\n ValidationError<InsufficientBalanceError> | UnexpectedError\n> {\n return swap(client, { intent }).andThen((plan) => {\n switch (plan.__typename) {\n case 'SwapReceipt':\n return okAsync(plan);\n default:\n return UnexpectedError.from(plan).asResultAsync();\n }\n });\n}\n\n// ------------------------------------------------------------\n\nexport type UseSupplySwapRequest = Prettify<\n SupplySwapQuoteRequest & CurrencyQueryOptions\n>;\n\n/**\n * Orchestrate the supply swap execution plan.\n *\n * ```tsx\n * const [signTypedData] = useSignTypedData(wallet);\n *\n * const [swapSupply, { loading, error }] = useSupplySwap((plan) => {\n * switch (plan.__typename) {\n * case 'PositionSwapAdapterContractApproval':\n * case 'PositionSwapPositionManagerApproval':\n * return signTypedData(plan.bySignature);\n *\n * case 'SwapTypedData':\n * return signTypedData(plan);\n * }\n * });\n *\n * const result = await swapSupply({\n * market: {\n * sellPosition: supplyPosition.id,\n * buyReserve: targetReserve.id,\n * amount: bigDecimal('1000'),\n * user: evmAddress('0x742d35cc…'),\n * enableCollateral: true,\n * },\n * });\n *\n * if (result.isErr()) {\n * console.error(result.error);\n * return;\n * }\n *\n * // result.value: SwapReceipt\n * ```\n */\nexport function useSupplySwap(\n handler: PositionSwapHandler,\n): UseAsyncTask<\n SupplySwapQuoteRequest,\n SwapReceipt,\n | SwapSignerError\n | SendTransactionError\n | PendingTransactionError\n | ValidationError<InsufficientBalanceError | InsufficientLiquidityError>\n> {\n const client = useAaveClient();\n\n return useAsyncTask(\n ({\n currency = DEFAULT_QUERY_OPTIONS.currency,\n ...request\n }: UseSupplySwapRequest) => {\n return supplySwapQuote(client, request, { currency }).andThen(\n (result) => {\n return processApprovals(result)\n .with(handler)\n .andThen((request) => preparePositionSwap(client, request))\n .andThen((order) =>\n handler(order.data, { cancel })\n .andThen(trySignatureFrom)\n .andThen((signature) =>\n swapPosition(client, {\n quoteId: order.newQuoteId,\n signature,\n }),\n ),\n );\n },\n );\n },\n [client, handler],\n );\n}\n\n// ------------------------------------------------------------\n\nexport type UseBorrowSwapRequest = Prettify<\n BorrowSwapQuoteRequest & CurrencyQueryOptions\n>;\n\n/**\n * Orchestrate the borrow swap execution plan.\n *\n * ```tsx\n * const [signTypedData] = useSignTypedData(wallet);\n *\n * const [swapBorrow, { loading, error }] = useBorrowSwap((plan) => {\n * switch (plan.__typename) {\n * case 'PositionSwapAdapterContractApproval':\n * case 'PositionSwapPositionManagerApproval':\n * return signTypedData(plan.bySignature);\n *\n * case 'SwapTypedData':\n * return signTypedData(plan);\n * }\n * });\n *\n * const result = await swapBorrow({\n * market: {\n * debtPosition: userBorrowItem.id,\n * buyReserve: targetReserve.id,\n * amount: bigDecimal('1000'),\n * user: evmAddress('0x742d35cc…'),\n * },\n * });\n *\n * if (result.isErr()) {\n * console.error(result.error);\n * return;\n * }\n *\n * // result.value: SwapReceipt\n * ```\n */\nexport function useBorrowSwap(\n handler: PositionSwapHandler,\n): UseAsyncTask<\n BorrowSwapQuoteRequest,\n SwapReceipt,\n | SwapSignerError\n | SendTransactionError\n | PendingTransactionError\n | ValidationError<InsufficientBalanceError | InsufficientLiquidityError>\n> {\n const client = useAaveClient();\n\n return useAsyncTask(\n ({\n currency = DEFAULT_QUERY_OPTIONS.currency,\n ...request\n }: UseBorrowSwapRequest) => {\n return borrowSwapQuote(client, request, { currency }).andThen(\n (result) => {\n return processApprovals(result)\n .with(handler)\n .andThen((request) => preparePositionSwap(client, request))\n .andThen((order) =>\n handler(order.data, { cancel })\n .andThen(trySignatureFrom)\n .andThen((signature) =>\n swapPosition(client, {\n quoteId: order.newQuoteId,\n signature,\n }),\n ),\n );\n },\n );\n },\n [client, handler],\n );\n}\n\n// ------------------------------------------------------------\n\nexport type UseRepayWithSupplyQuoteArgs = Prettify<\n RepayWithSupplyQuoteRequest & CurrencyQueryOptions\n>;\n\n/**\n * Fetch a quote for a repay with supply operation with the specified parameters.\n *\n * This signature supports React Suspense:\n *\n * ```tsx\n * const { data } = useRepayWithSupplyQuote({\n * market: {\n * sellPosition: userSupplyItem.id,\n * buyPosition: userBorrowItem.id,\n * amount: bigDecimal('1000'),\n * user: evmAddress('0x742d35cc…'),\n * },\n * suspense: true,\n * });\n * ```\n */\nexport function useRepayWithSupplyQuote(\n args: UseRepayWithSupplyQuoteArgs & Suspendable,\n): SuspenseResult<SwapQuote>;\n/**\n * Fetch a quote for a repay with supply operation with the specified parameters.\n *\n * Pausable suspense mode.\n *\n * ```tsx\n * const { data } = useRepayWithSupplyQuote({\n * market: {\n * sellPosition: userSupplyItem.id,\n * buyPosition: userBorrowItem.id,\n * amount: bigDecimal('1000'),\n * user: evmAddress('0x742d35cc…'),\n * },\n * suspense: true,\n * pause: true,\n * });\n * ```\n */\nexport function useRepayWithSupplyQuote(\n args: Pausable<UseRepayWithSupplyQuoteArgs> & Suspendable,\n): PausableSuspenseResult<SwapQuote>;\n/**\n * Fetch a quote for a repay with supply operation with the specified parameters.\n *\n * ```tsx\n * const { data, error, loading } = useRepayWithSupplyQuote({\n * market: {\n * sellPosition: userSupplyItem.id,\n * buyPosition: userBorrowItem.id,\n * amount: bigDecimal('1000'),\n * user: evmAddress('0x742d35cc…'),\n * },\n * });\n * ```\n */\nexport function useRepayWithSupplyQuote(\n args: UseRepayWithSupplyQuoteArgs,\n): ReadResult<SwapQuote>;\n/**\n * Fetch a quote for a repay with supply operation with the specified parameters.\n *\n * Pausable loading state mode.\n *\n * ```tsx\n * const { data, error, loading, paused } = useRepayWithSupplyQuote({\n * market: {\n * sellPosition: userSupplyItem.id,\n * buyPosition: userBorrowItem.id,\n * amount: bigDecimal('1000'),\n * user: evmAddress('0x742d35cc…'),\n * },\n * pause: true,\n * });\n * ```\n */\nexport function useRepayWithSupplyQuote(\n args: Pausable<UseRepayWithSupplyQuoteArgs>,\n): PausableReadResult<SwapQuote>;\n\nexport function useRepayWithSupplyQuote({\n suspense = false,\n pause = false,\n currency = DEFAULT_QUERY_OPTIONS.currency,\n ...request\n}: NullishDeep<UseRepayWithSupplyQuoteArgs> & {\n suspense?: boolean;\n pause?: boolean;\n}): SuspendableResult<\n SwapQuote,\n UnexpectedError | ValidationError<InsufficientLiquidityError>\n> {\n const client = useAaveClient();\n\n // Fast query - no polling, suspends in suspense mode for quick initial render\n const fastResult = useSuspendableQuery({\n document: RepayWithSupplyQuoteQuery,\n variables: {\n request: injectRepayWithSupplyQuoteAccuracy(request, QuoteAccuracy.Fast),\n currency,\n },\n selector: extractPositionSwapQuote,\n suspense,\n pause,\n batch: false, // Don't batch with Accurate query\n });\n\n // Accurate query - with polling, never suspends, fires after Fast in suspense mode\n const accurateResult = useSuspendableQuery({\n document: RepayWithSupplyQuoteQuery,\n variables: {\n request: injectRepayWithSupplyQuoteAccuracy(\n request,\n QuoteAccuracy.Accurate,\n ),\n currency,\n },\n selector: extractPositionSwapQuote,\n suspense: false, // Never suspend on Accurate (would cause re-suspend)\n pause: pause || (suspense && !fastResult.data),\n pollInterval: client.context.environment.swapQuoteInterval,\n batch: false, // Don't batch with Fast query\n });\n\n if (accurateResult.data) {\n return accurateResult;\n }\n\n return fastResult;\n}\n\n/**\n * Low-level hook to execute a repay with supply quote action directly.\n *\n * @remarks\n * This hook **does not** actively watch for updated data on the swap quote.\n * Use this hook to retrieve quotes on demand as part of a larger workflow.\n *\n * ```ts\n * const [getQuote, { called, data, error, loading }] = useRepayWithSupplyQuoteAction();\n *\n * // …\n *\n * const result = await getQuote({\n * repayWithReserve: reserve.id,\n * debtPosition: userBorrowItem.id,\n * amount: bigDecimal('1000'),\n * user: evmAddress('0x742d35cc…'),\n * });\n *\n * if (result.isOk()) {\n * console.log('Repay with supply quote:', result.value);\n * } else {\n * console.error(result.error);\n * }\n * ```\n */\nexport function useRepayWithSupplyQuoteAction(\n options: Required<CurrencyQueryOptions> = DEFAULT_QUERY_OPTIONS,\n): UseAsyncTask<\n RepayWithSupplyQuoteRequest,\n SwapQuote,\n UnexpectedError | ValidationError<InsufficientLiquidityError>\n> {\n const client = useAaveClient();\n\n return useAsyncTask(\n (request: RepayWithSupplyQuoteRequest) =>\n repayWithSupplyQuote(client, request, {\n currency: options.currency,\n requestPolicy: 'network-only',\n }).andThen(extractPositionSwapQuote),\n [client, options.currency],\n );\n}\n\n// ------------------------------------------------------------\n\nexport type UseRepayWithSupplyRequest = Prettify<\n RepayWithSupplyQuoteRequest & CurrencyQueryOptions\n>;\n\n/**\n * Orchestrate the repay with supply execution plan.\n *\n * ```tsx\n * const [signTypedData] = useSignTypedData(wallet);\n *\n * const [repayWithSupply, { loading, error }] = useRepayWithSupply((plan) => {\n * switch (plan.__typename) {\n * case 'PositionSwapAdapterContractApproval':\n * case 'PositionSwapPositionManagerApproval':\n * return signTypedData(plan.bySignature);\n *\n * case 'SwapTypedData':\n * return signTypedData(plan);\n * }\n * });\n *\n * const result = await repayWithSupply({\n * market: {\n * sellPosition: userSupplyItem.id,\n * buyPosition: userBorrowItem.id,\n * amount: bigDecimal('1000'),\n * user: evmAddress('0x742d35cc…'),\n * },\n * });\n *\n * if (result.isErr()) {\n * console.error(result.error);\n * return;\n * }\n *\n * // result.value: SwapReceipt\n * ```\n */\nexport function useRepayWithSupply(\n handler: PositionSwapHandler,\n): UseAsyncTask<\n RepayWithSupplyQuoteRequest,\n SwapReceipt,\n | SwapSignerError\n | SendTransactionError\n | PendingTransactionError\n | ValidationError<InsufficientBalanceError | InsufficientLiquidityError>\n> {\n const client = useAaveClient();\n\n return useAsyncTask(\n ({\n currency = DEFAULT_QUERY_OPTIONS.currency,\n ...request\n }: UseRepayWithSupplyRequest) => {\n return repayWithSupplyQuote(client, request, { currency }).andThen(\n (result) => {\n return processApprovals(result)\n .with(handler)\n .andThen((request) => preparePositionSwap(client, request))\n .andThen((order) =>\n handler(order.data, { cancel })\n .andThen(trySignatureFrom)\n .andThen((signature) =>\n swapPosition(client, {\n quoteId: order.newQuoteId,\n signature,\n }),\n ),\n );\n },\n );\n },\n [client, handler],\n );\n}\n\n// ------------------------------------------------------------\n\nexport type UseWithdrawSwapQuoteArgs = Prettify<\n WithdrawSwapQuoteRequest & CurrencyQueryOptions\n>;\n\n/**\n * Fetch a quote for a withdraw swap operation with the specified parameters.\n *\n * This signature supports React Suspense:\n *\n * ```tsx\n * const { data } = useWithdrawSwapQuote({\n * market: {\n * position: userSupplyItem.id,\n * buyReserve: reserve.id,\n * amount: bigDecimal('1000'),\n * user: evmAddress('0x742d35cc…'),\n * },\n * suspense: true,\n * });\n * ```\n */\nexport function useWithdrawSwapQuote(\n args: UseWithdrawSwapQuoteArgs & Suspendable,\n): SuspenseResult<SwapQuote>;\n/**\n * Fetch a quote for a withdraw swap operation with the specified parameters.\n *\n * Pausable suspense mode.\n *\n * ```tsx\n * const { data } = useWithdrawSwapQuote({\n * market: {\n * position: userSupplyItem.id,\n * buyReserve: reserve.id,\n * amount: bigDecimal('1000'),\n * user: evmAddress('0x742d35cc…'),\n * },\n * suspense: true,\n * pause: true,\n * });\n * ```\n */\nexport function useWithdrawSwapQuote(\n args: Pausable<UseWithdrawSwapQuoteArgs> & Suspendable,\n): PausableSuspenseResult<SwapQuote>;\n/**\n * Fetch a quote for a withdraw swap operation with the specified parameters.\n *\n * ```tsx\n * const { data, error, loading } = useWithdrawSwapQuote({\n * market: {\n * position: userSupplyItem.id,\n * buyReserve: reserve.id,\n * amount: bigDecimal('1000'),\n * user: evmAddress('0x742d35cc…'),\n * },\n * });\n * ```\n */\nexport function useWithdrawSwapQuote(\n args: UseWithdrawSwapQuoteArgs,\n): ReadResult<SwapQuote>;\n/**\n * Fetch a quote for a withdraw swap operation with the specified parameters.\n *\n * Pausable loading state mode.\n *\n * ```tsx\n * const { data, error, loading, paused } = useWithdrawSwapQuote({\n * market: {\n * position: userSupplyItem.id,\n * buyReserve: reserve.id,\n * amount: bigDecimal('1000'),\n * user: evmAddress('0x742d35cc…'),\n * },\n * pause: true,\n * });\n * ```\n */\nexport function useWithdrawSwapQuote(\n args: Pausable<UseWithdrawSwapQuoteArgs>,\n): PausableReadResult<SwapQuote>;\n\nexport function useWithdrawSwapQuote({\n suspense = false,\n pause = false,\n currency = DEFAULT_QUERY_OPTIONS.currency,\n ...request\n}: NullishDeep<UseWithdrawSwapQuoteArgs> & {\n suspense?: boolean;\n pause?: boolean;\n}): SuspendableResult<\n SwapQuote,\n UnexpectedError | ValidationError<InsufficientLiquidityError>\n> {\n const client = useAaveClient();\n\n // Fast query - no polling, suspends in suspense mode for quick initial render\n const fastResult = useSuspendableQuery({\n document: WithdrawSwapQuoteQuery,\n variables: {\n request: injectWithdrawSwapQuoteAccuracy(request, QuoteAccuracy.Fast),\n currency,\n },\n selector: extractPositionSwapQuote,\n suspense,\n pause,\n batch: false, // Don't batch with Accurate query\n });\n\n // Accurate query - with polling, never suspends, fires after Fast in suspense mode\n const accurateResult = useSuspendableQuery({\n document: WithdrawSwapQuoteQuery,\n variables: {\n request: injectWithdrawSwapQuoteAccuracy(request, QuoteAccuracy.Accurate),\n currency,\n },\n selector: extractPositionSwapQuote,\n suspense: false, // Never suspend on Accurate (would cause re-suspend)\n pause: pause || (suspense && !fastResult.data),\n pollInterval: client.context.environment.swapQuoteInterval,\n batch: false, // Don't batch with Fast query\n });\n\n if (accurateResult.data) {\n return accurateResult;\n }\n\n return fastResult;\n}\n\n/**\n * Low-level hook to execute a withdraw swap quote action directly.\n *\n * @remarks\n * This hook **does not** actively watch for updated data on the swap quote.\n * Use this hook to retrieve quotes on demand as part of a larger workflow.\n *\n * ```ts\n * const [getQuote, { called, data, error, loading }] = useWithdrawSwapQuoteAction();\n *\n * // …\n *\n * const result = await getQuote({\n * position: userSupplyItem.id,\n * buyReserve: reserve.id,\n * amount: bigDecimal('1000'),\n * user: evmAddress('0x742d35cc…'),\n * });\n *\n * if (result.isOk()) {\n * console.log('Withdraw swap quote:', result.value);\n * } else {\n * console.error(result.error);\n * }\n * ```\n */\nexport function useWithdrawSwapQuoteAction(\n options: Required<CurrencyQueryOptions> = DEFAULT_QUERY_OPTIONS,\n): UseAsyncTask<\n WithdrawSwapQuoteRequest,\n SwapQuote,\n UnexpectedError | ValidationError<InsufficientLiquidityError>\n> {\n const client = useAaveClient();\n\n return useAsyncTask(\n (request: WithdrawSwapQuoteRequest) =>\n withdrawSwapQuote(client, request, {\n currency: options.currency,\n requestPolicy: 'network-only',\n }).andThen(extractPositionSwapQuote),\n [client, options.currency],\n );\n}\n\n// ------------------------------------------------------------\n\nexport type UseWithdrawSwapRequest = Prettify<\n WithdrawSwapQuoteRequest & CurrencyQueryOptions\n>;\n\n/**\n * Orchestrate the withdraw swap execution plan.\n *\n * ```tsx\n * const [signTypedData] = useSignTypedData(wallet);\n *\n * const [withdrawSwap, { loading, error }] = useWithdrawSwap((plan) => {\n * switch (plan.__typename) {\n * case 'PositionSwapAdapterContractApproval':\n * case 'PositionSwapPositionManagerApproval':\n * return signTypedData(plan.bySignature);\n *\n * case 'SwapTypedData':\n * return signTypedData(plan);\n * }\n * });\n *\n * const result = await withdrawSwap({\n * market: {\n * position: userSupplyItem.id,\n * buyToken: { erc20: evmAddress('0xA0b86a33E6…') },\n * amount: bigDecimal('1000'),\n * user: evmAddress('0x742d35cc…'),\n * },\n * });\n *\n * if (result.isErr()) {\n * console.error(result.error);\n * return;\n * }\n *\n * // result.value: SwapReceipt\n * ```\n */\nexport function useWithdrawSwap(\n handler: PositionSwapHandler,\n): UseAsyncTask<\n WithdrawSwapQuoteRequest,\n SwapReceipt,\n | SwapSignerError\n | SendTransactionError\n | PendingTransactionError\n | ValidationError<InsufficientBalanceError | InsufficientLiquidityError>\n> {\n const client = useAaveClient();\n\n return useAsyncTask(\n ({\n currency = DEFAULT_QUERY_OPTIONS.currency,\n ...request\n }: UseWithdrawSwapRequest) => {\n return withdrawSwapQuote(client, request, { currency }).andThen(\n (result) => {\n return processApprovals(result)\n .with(handler)\n .andThen((request) => preparePositionSwap(client, request))\n .andThen((order) =>\n handler(order.data, { cancel })\n .andThen(trySignatureFrom)\n .andThen((signature) =>\n swapPosition(client, {\n quoteId: order.newQuoteId,\n signature,\n }),\n ),\n );\n },\n );\n },\n [client, handler],\n );\n}\n\n// ------------------------------------------------------------\n\nexport type UseTokenSwapRequest = Prettify<\n TokenSwapQuoteRequest & CurrencyQueryOptions\n>;\n\nexport type TokenSwapPlan =\n | SwapTypedData\n | Erc20Approval\n | SwapTransactionRequest;\n\nexport type TokenSwapHandler = (\n plan: TokenSwapPlan,\n options: SwapHandlerOptions,\n) => ResultAsync<PendingTransaction | Signature, SwapSignerError>;\n\n/**\n * Orchestrate the token swap execution plan.\n *\n * ```tsx\n * const [sendTransaction] = useSendTransaction(wallet);\n * const [signTypedData] = useSignTypedData(wallet);\n *\n * const [swap, { loading, error }] = useTokenSwap((plan) => {\n * switch (plan.__typename) {\n * case 'Erc20Approval':\n * if (plan.bySignature) {\n * return signTypedData(plan.bySignature);\n * }\n * return sendTransaction(plan.byTransaction);\n *\n * case 'SwapTransactionRequest':\n * return sendTransaction(plan.transaction);\n *\n * case 'SwapTypedData':\n * return signTypedData(plan);\n * }\n * });\n *\n * const result = await swap({\n * fromQuote: {\n * quoteId: quote.quoteId,\n * },\n * });\n *\n * if (result.isErr()) {\n * console.error(result.error);\n * return;\n * }\n *\n * // result.value: SwapReceipt\n * ```\n */\nexport function useTokenSwap(\n handler: TokenSwapHandler,\n): UseAsyncTask<\n UseTokenSwapRequest,\n SwapReceipt,\n | SendTransactionError\n | PendingTransactionError\n | ValidationError<InsufficientBalanceError | InsufficientLiquidityError>\n> {\n const client = useAaveClient();\n\n const executeSwap = useCallback(\n (\n request: SwapRequest,\n ): ResultAsync<\n SwapReceipt,\n | SendTransactionError\n | PendingTransactionError\n | ValidationError<InsufficientBalanceError>\n > => {\n return swap(client, request).andThen((plan) => {\n switch (plan.__typename) {\n case 'SwapTransactionRequest':\n return handler(plan, { cancel })\n .andThen(PendingTransaction.tryFrom)\n .andThen((pendingTransaction) => pendingTransaction.wait())\n .andThen(() => okAsync(plan.orderReceipt));\n\n case 'SwapReceipt':\n return okAsync(plan);\n }\n });\n },\n [client, handler],\n );\n\n return useAsyncTask(\n ({\n currency = DEFAULT_QUERY_OPTIONS.currency,\n ...request\n }: UseTokenSwapRequest) =>\n tokenSwapQuote(client, request, { currency }).andThen((quoteResult) => {\n switch (quoteResult.__typename) {\n case 'SwapByTransaction':\n return executeSwap({\n transaction: { quoteId: quoteResult.quote.quoteId },\n });\n\n case 'SwapByIntent':\n return prepareTokenSwap(client, {\n quoteId: quoteResult.quote.quoteId,\n }).andThen((order) =>\n handler(order.data, { cancel })\n .andThen(trySignatureFrom)\n .andThen((signature) =>\n executeSwap({\n intent: { quoteId: order.newQuoteId, signature },\n }),\n ),\n );\n\n case 'SwapByIntentWithApprovalRequired':\n if (supportsPermit(quoteResult)) {\n const approval = quoteResult.approvals[0];\n return handler(approval, { cancel })\n .andThen((result) => {\n if (isSignature(result)) {\n return prepareTokenSwap(client, {\n quoteId: quoteResult.quote.quoteId,\n permitSig: {\n deadline: approval.bySignature.message\n .deadline as number,\n value: result,\n },\n });\n }\n if (PendingTransaction.isInstanceOf(result)) {\n return result.wait().andThen(() =>\n prepareTokenSwap(client, {\n quoteId: quoteResult.quote.quoteId,\n }),\n );\n }\n return UnexpectedError.from(result).asResultAsync();\n })\n .andThen((order) =>\n handler(order.data, { cancel })\n .andThen(trySignatureFrom)\n .andThen((signature) =>\n executeSwap({\n intent: {\n quoteId: order.newQuoteId,\n signature,\n },\n }),\n ),\n );\n }\n\n return quoteResult.approvals\n .reduce(\n (chain, approval) =>\n chain.andThen(() =>\n handler({ ...approval, bySignature: null }, { cancel })\n .andThen(PendingTransaction.tryFrom)\n .andThen((pendingTransaction) =>\n pendingTransaction.wait(),\n ),\n ),\n okAsync(undefined) as ResultAsync<\n unknown,\n SendTransactionError | PendingTransactionError\n >,\n )\n .andThen(() =>\n prepareTokenSwap(client, {\n quoteId: quoteResult.quote.quoteId,\n }),\n )\n .andThen((order) => handler(order.data, { cancel }))\n .andThen(trySignatureFrom)\n .andThen((signature) =>\n executeSwap({\n intent: { quoteId: quoteResult.quote.quoteId, signature },\n }),\n );\n default:\n never(\n `Unsupported swap quote result: ${quoteResult.__typename}. To be removed from API soon.`,\n );\n }\n }),\n [client, handler, executeSwap],\n );\n}\n\nexport type CancelSwapHandler = (\n data: SwapTypedData | TransactionRequest,\n options: SwapHandlerOptions,\n) => ResultAsync<PendingTransaction | Signature, SwapSignerError>;\n\nexport class CannotCancelSwapError extends ResultAwareError {\n name = 'CannotCancelSwapError' as const;\n}\n\nexport type CancelSwapError =\n | CancelError\n | CannotCancelSwapError\n | SigningError\n | TimeoutError\n | TransactionError\n | UnexpectedError;\n\n/**\n * Executes the complete swap cancellation workflow combining preparation and execution.\n *\n * ```tsx\n * const [sendTransaction] = useSendTransaction(wallet);\n * const [signTypedData] = useSignTypedData(wallet);\n *\n * const [cancelSwap, { loading, error }] = useCancelSwap((plan) => {\n * switch (plan.__typename) {\n * case 'TransactionRequest':\n * return sendTransaction(plan);\n *\n * case 'SwapTypedData':\n * return signTypedData(plan);\n * }\n * });\n *\n * const result = await cancelSwap({\n * id: swapId('123…'),\n * });\n *\n * if (result.isErr()) {\n * console.error(result.error);\n * return;\n * }\n *\n * // result.value: SwapCancelledResult\n * console.log('Swap cancelled:', result.value);\n * ```\n */\nexport function useCancelSwap(\n handler: CancelSwapHandler,\n): UseAsyncTask<\n PrepareSwapCancelRequest,\n SwapCancelledResult,\n CancelSwapError\n> {\n const client = useAaveClient();\n\n return useAsyncTask(\n (request) =>\n swapStatus(client, { id: request.id }).andThen((status) => {\n if (status === null) {\n return UnexpectedError.from('Swap not found').asResultAsync();\n }\n\n switch (status.__typename) {\n case 'SwapOpen':\n case 'SwapPendingSignature':\n return prepareSwapCancel(client, request)\n .andThen((result) => handler(result.data, { cancel }))\n .andThen(trySignatureFrom)\n .andThen((signature) =>\n cancelSwap(client, {\n intent: { id: request.id, signature },\n }),\n )\n .andThen((plan) => {\n if (plan.__typename === 'SwapCancelledResult') {\n return okAsync(plan);\n }\n\n return (\n handler(plan, { cancel })\n .andThen(PendingTransaction.tryFrom)\n .andThen((pendingTransaction) => pendingTransaction.wait())\n // TODO: verify that if fails cause too early, we need to waitForSwapOutcome(client)({ id: request.id })\n .andThen(() => swapStatus(client, { id: request.id }))\n .andThen((status) => {\n if (status?.__typename === 'SwapCancelled') {\n return okAsync(toSwapCancelledResult(status));\n }\n return new CannotCancelSwapError(\n 'Failed to cancel swap',\n ).asResultAsync();\n })\n );\n });\n\n case 'SwapCancelled':\n return okAsync(toSwapCancelledResult(status));\n\n case 'SwapExpired':\n return new CannotCancelSwapError(\n 'Swap cannot longer be cancelled',\n ).asResultAsync();\n\n default:\n return UnexpectedError.upgradeRequired(\n `Unsupported swap status: ${status.__typename}`,\n ).asResultAsync();\n }\n }),\n [client, handler],\n );\n}\n","import {\n type AaveClient,\n type ActivitiesRequest,\n type CurrencyQueryOptions,\n DEFAULT_QUERY_OPTIONS,\n type PaginatedActivitiesResult,\n supportsPermit,\n type TimeWindowQueryOptions,\n type TransactionReceipt,\n transactionReceipt,\n UnexpectedError,\n} from '@aave/client';\nimport {\n activities,\n borrow,\n claimRewards,\n liquidatePosition,\n preview,\n renounceSpokeUserPositionManager,\n repay,\n setSpokeUserPositionManager,\n setUserSuppliesAsCollateral,\n supply,\n updateUserPositionConditions,\n withdraw,\n} from '@aave/client/actions';\nimport { ValidationError } from '@aave/core';\nimport {\n ActivitiesQuery,\n type BorrowRequest,\n type ClaimRewardsRequest,\n decodeReserveId,\n type ERC20PermitSignature,\n type Erc20Approval,\n type Erc20ApprovalRequired,\n type ExecutionPlan,\n type InsufficientBalanceError,\n type LiquidatePositionRequest,\n type PermitTypedData,\n type PreContractActionRequired,\n PreviewQuery,\n type PreviewRequest,\n type PreviewUserPosition,\n type RenounceSpokeUserPositionManagerRequest,\n type RepayRequest,\n type SetSpokeUserPositionManagerRequest,\n type SetUserSuppliesAsCollateralRequest,\n type SpokeInput,\n type SupplyRequest,\n type TransactionRequest,\n type UpdateUserPositionConditionsRequest,\n type WithdrawRequest,\n} from '@aave/graphql';\nimport {\n errAsync,\n expectTypename,\n isSignature,\n type NullishDeep,\n okAsync,\n type Prettify,\n ResultAsync,\n type Signature,\n} from '@aave/types';\n\nimport { useAaveClient } from './context';\nimport {\n cancel,\n type ExecutionPlanHandler,\n type Pausable,\n type PausableReadResult,\n type PausableSuspenseResult,\n PendingTransaction,\n type PendingTransactionError,\n type ReadResult,\n refreshHubs,\n refreshReserves,\n refreshSpokePositionManagers,\n refreshSpokes,\n refreshUserBalances,\n refreshUserBorrows,\n refreshUserPositionById,\n refreshUserPositions,\n refreshUserSummary,\n refreshUserSupplies,\n type SendTransactionError,\n type Suspendable,\n type SuspendableResult,\n type SuspenseResult,\n type UseAsyncTask,\n useAsyncTask,\n useSuspendableQuery,\n} from './helpers';\n\nfunction refreshQueriesForReserveChange(\n client: AaveClient,\n request: SupplyRequest | BorrowRequest | RepayRequest | WithdrawRequest,\n) {\n const { chainId, spoke: address } = decodeReserveId(request.reserve);\n const spoke: SpokeInput = { chainId, address };\n return ResultAsync.combine([\n refreshUserPositions(client, request.sender, spoke),\n refreshUserSummary(client, request.sender, spoke),\n refreshReserves(client, [request.reserve]),\n refreshSpokes(client, spoke),\n refreshUserBalances(client, request.sender),\n refreshUserSupplies(client, request.sender),\n refreshUserBorrows(client, request.sender),\n refreshHubs(client, chainId),\n ]);\n}\n\nfunction toPermitSignature(\n signature: Signature,\n permitTypedData: PermitTypedData,\n): ERC20PermitSignature {\n return {\n deadline: permitTypedData.message.deadline as number,\n value: signature,\n };\n}\n\ntype ApprovalHandler = ExecutionPlanHandler<\n TransactionRequest | Erc20Approval,\n Signature | PendingTransaction\n>;\n\n/**\n * Sends all approvals sequentially via transactions (no permit).\n */\nfunction sendApprovalTransactions(\n plan: Erc20ApprovalRequired,\n handler: ApprovalHandler,\n): ResultAsync<\n TransactionRequest,\n SendTransactionError | PendingTransactionError\n> {\n return plan.approvals\n .reduce<\n ResultAsync<unknown, SendTransactionError | PendingTransactionError>\n >(\n (chain, approval) =>\n chain.andThen(() =>\n handler({ ...approval, bySignature: null }, { cancel })\n .andThen(PendingTransaction.tryFrom)\n .andThen((pending) => pending.wait()),\n ),\n okAsync(undefined),\n )\n .map(() => plan.originalTransaction);\n}\n\ntype SingleApprovalPlan = Erc20ApprovalRequired & {\n approvals: [Erc20Approval & { bySignature: PermitTypedData }];\n};\n\n/**\n * Processes a single approval that supports permit.\n * The handler decides whether to use a permit signature or a transaction.\n * Returns either a new TransactionRequest (from permit callback) or the plan's original transaction.\n */\nfunction handleSingleApproval(\n plan: SingleApprovalPlan,\n handler: ApprovalHandler,\n onPermit: (\n permitSig: ERC20PermitSignature,\n ) => ResultAsync<ExecutionPlan, UnexpectedError>,\n): ResultAsync<\n TransactionRequest,\n SendTransactionError | PendingTransactionError | UnexpectedError\n> {\n const approval = plan.approvals[0];\n\n return handler(approval, { cancel }).andThen((result) => {\n if (isSignature(result)) {\n return onPermit(toPermitSignature(result, approval.bySignature)).map(\n expectTypename('TransactionRequest'),\n );\n }\n return result.wait().map(() => plan.originalTransaction);\n });\n}\n\n// ------------------------------------------------------------\n\n/**\n * A hook that provides a way to supply assets to an Aave reserve.\n *\n * ```ts\n * const [sendTransaction] = useSendTransaction(wallet);\n * const [supply, { loading, error }] = useSupply((plan, { cancel }) => {\n * switch (plan.__typename) {\n * case 'TransactionRequest':\n * return sendTransaction(plan);\n *\n * case 'Erc20Approval':\n * return sendTransaction(plan.byTransaction);\n *\n * case 'PreContractActionRequired':\n * return sendTransaction(plan.transaction);\n * }\n * });\n *\n * // …\n *\n * const result = await supply({ ... });\n *\n * if (result.isErr()) {\n * switch (result.error.name) {\n * case 'CancelError':\n * // The user cancelled the operation\n * return;\n *\n * case 'SigningError':\n * console.error(`Failed to sign the transaction: ${result.error.message}`);\n * break;\n *\n * case 'TimeoutError':\n * console.error(`Transaction timed out: ${result.error.message}`);\n * break;\n *\n * case 'TransactionError':\n * console.error(`Transaction failed: ${result.error.message}`);\n * break;\n *\n * case 'ValidationError':\n * console.error(`Insufficient balance: ${result.error.cause.required.value} required.`);\n * break;\n *\n * case 'UnexpectedError':\n * console.error(result.error.message);\n * break;\n * }\n * return;\n * }\n *\n * console.log('Transaction sent with hash:', result.value.txHash);\n * ```\n *\n * @param handler - The handler that will be used to handle the transactions.\n */\nexport function useSupply(\n handler: ExecutionPlanHandler<\n TransactionRequest | Erc20Approval | PreContractActionRequired,\n Signature | PendingTransaction\n >,\n): UseAsyncTask<\n SupplyRequest,\n TransactionReceipt,\n | SendTransactionError\n | PendingTransactionError\n | ValidationError<InsufficientBalanceError>\n> {\n const client = useAaveClient();\n\n return useAsyncTask(\n (request: SupplyRequest) =>\n supply(client, request)\n .andThen((plan) => {\n switch (plan.__typename) {\n case 'TransactionRequest':\n return handler(plan, { cancel });\n\n case 'Erc20ApprovalRequired':\n if (supportsPermit(plan)) {\n return handleSingleApproval(plan, handler, (permitSig) =>\n supply(\n client,\n injectSupplyPermitSignature(request, permitSig),\n ),\n ).andThen((transaction) => handler(transaction, { cancel }));\n }\n return sendApprovalTransactions(plan, handler).andThen(\n (transaction) => handler(transaction, { cancel }),\n );\n\n case 'PreContractActionRequired':\n return handler(plan, { cancel })\n .andThen(PendingTransaction.tryFrom)\n .andThen((pending) => pending.wait())\n .andThen(() => handler(plan.originalTransaction, { cancel }));\n\n case 'InsufficientBalanceError':\n return errAsync(ValidationError.fromGqlNode(plan));\n }\n })\n .andThen(PendingTransaction.tryFrom)\n .andThen((pending) => pending.wait())\n .andThen(client.waitForTransaction)\n .andThrough(() => refreshQueriesForReserveChange(client, request)),\n [client, handler],\n );\n}\n\nfunction injectSupplyPermitSignature(\n request: SupplyRequest,\n permitSig: ERC20PermitSignature,\n): SupplyRequest {\n if ('erc20' in request.amount) {\n return {\n ...request,\n amount: {\n erc20: {\n ...request.amount.erc20,\n permitSig,\n },\n },\n };\n }\n return request;\n}\n\n/**\n * A hook that provides a way to borrow assets from an Aave reserve.\n *\n * ```ts\n * const [sendTransaction] = useSendTransaction(wallet);\n * const [borrow, { loading, error }] = useBorrow((plan, { cancel }) => {\n * switch (plan.__typename) {\n * case 'TransactionRequest':\n * return sendTransaction(plan);\n *\n * case 'PreContractActionRequired':\n * return sendTransaction(plan.transaction);\n * }\n * });\n *\n * // …\n *\n * const result = await borrow({ ... });\n *\n * if (result.isErr()) {\n * switch (result.error.name) {\n * case 'CancelError':\n * // The user cancelled the operation\n * return;\n *\n * case 'SigningError':\n * console.error(`Failed to sign the transaction: ${result.error.message}`);\n * break;\n *\n * case 'TimeoutError':\n * console.error(`Transaction timed out: ${result.error.message}`);\n * break;\n *\n * case 'TransactionError':\n * console.error(`Transaction failed: ${result.error.message}`);\n * break;\n *\n * case 'ValidationError':\n * console.error(`Insufficient balance: ${result.error.cause.required.value} required.`);\n * break;\n *\n * case 'UnexpectedError':\n * console.error(result.error.message);\n * break;\n * }\n * return;\n * }\n *\n * console.log('Transaction sent with hash:', result.value.txHash);\n * ```\n *\n * @param handler - The handler that will be used to handle the transactions.\n */\nexport function useBorrow(\n handler: ExecutionPlanHandler<\n TransactionRequest | PreContractActionRequired,\n PendingTransaction\n >,\n): UseAsyncTask<\n BorrowRequest,\n TransactionReceipt,\n | SendTransactionError\n | PendingTransactionError\n | ValidationError<InsufficientBalanceError>\n> {\n const client = useAaveClient();\n\n return useAsyncTask(\n (request: BorrowRequest) =>\n borrow(client, request)\n .andThen((plan) => {\n switch (plan.__typename) {\n case 'TransactionRequest':\n return handler(plan, { cancel });\n\n case 'PreContractActionRequired':\n return handler(plan, { cancel })\n .andThen((pending) => pending.wait())\n .andThen(() => handler(plan.originalTransaction, { cancel }));\n\n case 'InsufficientBalanceError':\n return errAsync(ValidationError.fromGqlNode(plan));\n\n case 'Erc20ApprovalRequired':\n return UnexpectedError.from(plan).asResultAsync();\n }\n })\n .andThen((pending) => pending.wait())\n .andThen(client.waitForTransaction)\n .andThrough(() => refreshQueriesForReserveChange(client, request)),\n [client, handler],\n );\n}\n\n/**\n * A hook that provides a way to repay borrowed assets to an Aave reserve.\n *\n * ```ts\n * const [sendTransaction] = useSendTransaction(wallet);\n * const [repay, { loading, error }] = useRepay((plan, { cancel }) => {\n * switch (plan.__typename) {\n * case 'TransactionRequest':\n * return sendTransaction(plan);\n *\n * case 'Erc20Approval':\n * return sendTransaction(plan.byTransaction);\n *\n * case 'PreContractActionRequired':\n * return sendTransaction(plan.transaction);\n * }\n * });\n *\n * // …\n *\n * const result = await repay({ ... });\n *\n * if (result.isErr()) {\n * switch (result.error.name) {\n * case 'CancelError':\n * // The user cancelled the operation\n * return;\n *\n * case 'SigningError':\n * console.error(`Failed to sign the transaction: ${result.error.message}`);\n * break;\n *\n * case 'TimeoutError':\n * console.error(`Transaction timed out: ${result.error.message}`);\n * break;\n *\n * case 'TransactionError':\n * console.error(`Transaction failed: ${result.error.message}`);\n * break;\n *\n * case 'ValidationError':\n * console.error(`Insufficient balance: ${result.error.cause.required.value} required.`);\n * break;\n *\n * case 'UnexpectedError':\n * console.error(result.error.message);\n * break;\n * }\n * return;\n * }\n *\n * console.log('Transaction sent with hash:', result.value.txHash);\n * ```\n *\n * @param handler - The handler that will be used to handle the transactions.\n */\nexport function useRepay(\n handler: ExecutionPlanHandler<\n TransactionRequest | Erc20Approval | PreContractActionRequired,\n Signature | PendingTransaction\n >,\n): UseAsyncTask<\n RepayRequest,\n TransactionReceipt,\n | SendTransactionError\n | PendingTransactionError\n | ValidationError<InsufficientBalanceError>\n> {\n const client = useAaveClient();\n\n return useAsyncTask(\n (request: RepayRequest) =>\n repay(client, request)\n .andThen((plan) => {\n switch (plan.__typename) {\n case 'TransactionRequest':\n return handler(plan, { cancel });\n\n case 'Erc20ApprovalRequired':\n if (supportsPermit(plan)) {\n return handleSingleApproval(plan, handler, (permitSig) =>\n repay(client, injectRepayPermitSignature(request, permitSig)),\n ).andThen((transaction) => handler(transaction, { cancel }));\n }\n return sendApprovalTransactions(plan, handler).andThen(\n (transaction) => handler(transaction, { cancel }),\n );\n\n case 'PreContractActionRequired':\n return handler(plan, { cancel })\n .andThen(PendingTransaction.tryFrom)\n .andThen((pending) => pending.wait())\n .andThen(() => handler(plan.originalTransaction, { cancel }));\n\n case 'InsufficientBalanceError':\n return errAsync(ValidationError.fromGqlNode(plan));\n }\n })\n .andThen(PendingTransaction.tryFrom)\n .andThen((pending) => pending.wait())\n .andThen(client.waitForTransaction)\n .andThrough(() => refreshQueriesForReserveChange(client, request)),\n [client, handler],\n );\n}\n\nfunction injectRepayPermitSignature(\n request: RepayRequest,\n permitSig: ERC20PermitSignature,\n): RepayRequest {\n if ('erc20' in request.amount) {\n return {\n ...request,\n amount: {\n erc20: {\n ...request.amount.erc20,\n permitSig,\n },\n },\n };\n }\n return request;\n}\n\n/**\n * A hook that provides a way to withdraw supplied assets from an Aave reserve.\n *\n * ```ts\n * const [sendTransaction] = useSendTransaction(wallet);\n * const [withdraw, { loading, error }] = useWithdraw((plan, { cancel }) => {\n * switch (plan.__typename) {\n * case 'TransactionRequest':\n * return sendTransaction(plan);\n *\n * case 'PreContractActionRequired':\n * return sendTransaction(plan.transaction);\n * }\n * });\n *\n * // …\n *\n * const result = await withdraw({ ... });\n *\n * if (result.isErr()) {\n * switch (result.error.name) {\n * case 'CancelError':\n * // The user cancelled the operation\n * return;\n *\n * case 'SigningError':\n * console.error(`Failed to sign the transaction: ${result.error.message}`);\n * break;\n *\n * case 'TimeoutError':\n * console.error(`Transaction timed out: ${result.error.message}`);\n * break;\n *\n * case 'TransactionError':\n * console.error(`Transaction failed: ${result.error.message}`);\n * break;\n *\n * case 'ValidationError':\n * console.error(`Insufficient balance: ${result.error.cause.required.value} required.`);\n * break;\n *\n * case 'UnexpectedError':\n * console.error(result.error.message);\n * break;\n * }\n * return;\n * }\n *\n * console.log('Transaction sent with hash:', result.value.txHash);\n * ```\n *\n * @param handler - The handler that will be used to handle the transactions.\n */\nexport function useWithdraw(\n handler: ExecutionPlanHandler<\n TransactionRequest | PreContractActionRequired,\n PendingTransaction\n >,\n): UseAsyncTask<\n WithdrawRequest,\n TransactionReceipt,\n | SendTransactionError\n | PendingTransactionError\n | ValidationError<InsufficientBalanceError>\n> {\n const client = useAaveClient();\n\n return useAsyncTask(\n (request: WithdrawRequest) =>\n withdraw(client, request)\n .andThen((plan) => {\n switch (plan.__typename) {\n case 'TransactionRequest':\n return handler(plan, { cancel });\n\n case 'PreContractActionRequired':\n return handler(plan, { cancel })\n .andThen((pending) => pending.wait())\n .andThen(() => handler(plan.originalTransaction, { cancel }));\n\n case 'InsufficientBalanceError':\n return errAsync(ValidationError.fromGqlNode(plan));\n\n case 'Erc20ApprovalRequired':\n return UnexpectedError.from(plan).asResultAsync();\n }\n })\n .andThen((pending) => pending.wait())\n .andThen(client.waitForTransaction)\n .andThrough(() => refreshQueriesForReserveChange(client, request)),\n [client, handler],\n );\n}\n\n/**\n * A hook that provides a way to renounce a position manager of a user for a specific spoke.\n *\n * ```ts\n * const [sendTransaction] = useSendTransaction(wallet);\n * const [renounceSpokeUserPositionManager, { loading, error }] = useRenounceSpokeUserPositionManager(sendTransaction);\n *\n * // …\n *\n * const result = await renounceSpokeUserPositionManager({ ... });\n *\n * if (result.isErr()) {\n * switch (result.error.name) {\n * case 'CancelError':\n * // The user cancelled the operation\n * return;\n *\n * case 'SigningError':\n * console.error(`Failed to sign the transaction: ${result.error.message}`);\n * break;\n *\n * case 'TimeoutError':\n * console.error(`Transaction timed out: ${result.error.message}`);\n * break;\n *\n * case 'TransactionError':\n * console.error(`Transaction failed: ${result.error.message}`);\n * break;\n *\n * case 'UnexpectedError':\n * console.error(result.error.message);\n * break;\n * }\n * return;\n * }\n *\n * console.log('Transaction sent with hash:', result.value.txHash);\n * ```\n *\n * @param handler - The handler that will be used to handle the transaction.\n */\n\nexport function useRenounceSpokeUserPositionManager(\n handler: ExecutionPlanHandler<TransactionRequest, PendingTransaction>,\n): UseAsyncTask<\n RenounceSpokeUserPositionManagerRequest,\n TransactionReceipt,\n SendTransactionError | PendingTransactionError\n> {\n const client = useAaveClient();\n\n return useAsyncTask(\n (request: RenounceSpokeUserPositionManagerRequest) =>\n renounceSpokeUserPositionManager(client, request)\n .andThen((transaction) => handler(transaction, { cancel }))\n .andThen((pending) => pending.wait())\n .andThen(client.waitForTransaction)\n .andThrough(() => refreshSpokePositionManagers(client, request.spoke)),\n [client, handler],\n );\n}\n\n/**\n * Hook for updating user position conditions (dynamic config and/or risk premium).\n *\n * ```ts\n * const [sendTransaction] = useSendTransaction(wallet);\n * const [update, { loading, error }] = useUpdateUserPositionConditions((transaction, { cancel }) => {\n * return sendTransaction(transaction);\n * });\n *\n * // …\n *\n * const result = await update({\n * userPositionId: userPosition.id,\n * update: UserPositionConditionsUpdate.AllDynamicConfig,\n * });\n *\n * if (result.isErr()) {\n * switch (result.error.name) {\n * case 'CancelError':\n * // The user cancelled the operation\n * return;\n *\n * case 'SigningError':\n * console.error(`Failed to sign the transaction: ${result.error.message}`);\n * break;\n *\n * case 'TimeoutError':\n * console.error(`Transaction timed out: ${result.error.message}`);\n * break;\n *\n * case 'TransactionError':\n * console.error(`Transaction failed: ${result.error.message}`);\n * break;\n *\n * case 'UnexpectedError':\n * console.error(result.error.message);\n * break;\n * }\n * return;\n * }\n *\n * console.log('Transaction sent with hash:', result.value.txHash);\n * ```\n *\n * @param handler - The handler that will be used to handle the transaction.\n */\n\nexport function useUpdateUserPositionConditions(\n handler: ExecutionPlanHandler<TransactionRequest, PendingTransaction>,\n): UseAsyncTask<\n UpdateUserPositionConditionsRequest,\n TransactionReceipt,\n SendTransactionError | PendingTransactionError\n> {\n const client = useAaveClient();\n\n return useAsyncTask(\n (request: UpdateUserPositionConditionsRequest) =>\n updateUserPositionConditions(client, request)\n .andThen((transaction) => handler(transaction, { cancel }))\n .andThen((pending) => pending.wait())\n .andThen(client.waitForTransaction)\n .andThrough(() =>\n refreshUserPositionById(client, request.userPositionId),\n ),\n [client, handler],\n );\n}\n\n/**\n * Hook for updating the collateral status of user's supplies.\n *\n * ```ts\n * const [sendTransaction] = useSendTransaction(wallet);\n * const [setUserSuppliesAsCollateral, { loading, error }] = useSetUserSuppliesAsCollateral((transaction, { cancel }) => {\n * return sendTransaction(transaction);\n * });\n *\n * const result = await setUserSuppliesAsCollateral({\n * changes: [\n * {\n * reserve: reserve.id,\n * enableCollateral: true\n * }\n * ],\n * sender: evmAddress('0x456...')\n * });\n *\n * if (result.isErr()) {\n * switch (result.error.name) {\n * case 'CancelError':\n * // The user cancelled the operation\n * return;\n *\n * case 'SigningError':\n * console.error(`Failed to sign the transaction: ${result.error.message}`);\n * break;\n *\n * case 'TimeoutError':\n * console.error(`Transaction timed out: ${result.error.message}`);\n * break;\n *\n * case 'TransactionError':\n * console.error(`Transaction failed: ${result.error.message}`);\n * break;\n *\n * case 'UnexpectedError':\n * console.error(result.error.message);\n * break;\n * }\n * return;\n * }\n *\n * console.log('Transaction sent with hash:', result.value.txHash);\n * ```\n *\n * @param handler - The handler that will be used to handle the transaction.\n */\nexport function useSetUserSuppliesAsCollateral(\n handler: ExecutionPlanHandler<TransactionRequest, PendingTransaction>,\n): UseAsyncTask<\n SetUserSuppliesAsCollateralRequest,\n TransactionReceipt,\n SendTransactionError | PendingTransactionError\n> {\n const client = useAaveClient();\n\n return useAsyncTask(\n (request: SetUserSuppliesAsCollateralRequest) => {\n const reserveIds = request.changes.map((change) => change.reserve);\n const reserveDetails = reserveIds.map((reserveId) =>\n decodeReserveId(reserveId),\n );\n return setUserSuppliesAsCollateral(client, request)\n .andThen((transaction) => handler(transaction, { cancel }))\n .andThen((pending) => pending.wait())\n .andThen(client.waitForTransaction)\n .andThrough(() =>\n ResultAsync.combine([\n // update user supplies\n refreshUserSupplies(client, request.sender),\n\n // update user borrows\n refreshUserBorrows(client, request.sender),\n\n ...reserveDetails.flatMap(({ chainId, spoke }) => [\n // update user positions\n refreshUserPositions(client, request.sender, {\n chainId,\n address: spoke,\n }),\n\n // update user summary\n refreshUserSummary(client, request.sender, {\n chainId,\n address: spoke,\n }),\n\n // update spokes\n refreshSpokes(client, { chainId, address: spoke }),\n ]),\n\n // update reserves\n refreshReserves(client, reserveIds),\n\n // update hubs\n ...reserveDetails.map(({ chainId }) =>\n refreshHubs(client, chainId),\n ),\n ]),\n );\n },\n [client, handler],\n );\n}\n\n/**\n * A hook that provides a way to liquidate a user's position.\n *\n * ```ts\n * const [sendTransaction] = useSendTransaction(wallet);\n * const [liquidatePosition, { loading, error }] = useLiquidatePosition((plan, { cancel }) => {\n * switch (plan.__typename) {\n * case 'TransactionRequest':\n * return sendTransaction(plan);\n *\n * case 'Erc20Approval':\n * return sendTransaction(plan.byTransaction);\n *\n * case 'PreContractActionRequired':\n * return sendTransaction(plan.transaction);\n * }\n * });\n *\n * // …\n *\n * const result = await liquidatePosition({\n * collateral: reserveId('SGVsbG8h'),\n * debt: reserveId('Q2lhbyE= '),\n * amount: amount,\n * liquidator: liquidator,\n * borrower: borrower,\n * });\n *\n * if (result.isErr()) {\n * switch (result.error.name) {\n * case 'CancelError':\n * // The user cancelled the operation\n * return;\n *\n * case 'SigningError':\n * console.error(`Failed to sign the transaction: ${result.error.message}`);\n * break;\n *\n * case 'TimeoutError':\n * console.error(`Transaction timed out: ${result.error.message}`);\n * break;\n *\n * case 'TransactionError':\n * console.error(`Transaction failed: ${result.error.message}`);\n * break;\n *\n * case 'ValidationError':\n * console.error(`Insufficient balance: ${result.error.cause.required.value} required.`);\n * break;\n *\n * case 'UnexpectedError':\n * console.error(result.error.message);\n * break;\n * }\n * return;\n * }\n *\n * console.log('Transaction sent with hash:', result.value.txHash);\n * ```\n *\n * @param handler - The handler that will be used to handle the transactions.\n */\nexport function useLiquidatePosition(\n handler: ExecutionPlanHandler<\n TransactionRequest | Erc20Approval | PreContractActionRequired,\n PendingTransaction | Signature\n >,\n): UseAsyncTask<\n LiquidatePositionRequest,\n TransactionReceipt,\n | SendTransactionError\n | PendingTransactionError\n | ValidationError<InsufficientBalanceError>\n> {\n const client = useAaveClient();\n\n return useAsyncTask(\n (request: LiquidatePositionRequest) =>\n // TODO: update the relevant read queries\n liquidatePosition(client, request)\n .andThen((plan) => {\n switch (plan.__typename) {\n case 'TransactionRequest':\n return handler(plan, { cancel });\n\n case 'Erc20ApprovalRequired':\n if (supportsPermit(plan)) {\n return handleSingleApproval(plan, handler, (permitSig) =>\n liquidatePosition(\n client,\n injectLiquidatePermitSignature(request, permitSig),\n ),\n ).andThen((transaction) => handler(transaction, { cancel }));\n }\n return sendApprovalTransactions(plan, handler).andThen(\n (transaction) => handler(transaction, { cancel }),\n );\n\n case 'PreContractActionRequired':\n return handler(plan, { cancel })\n .andThen(PendingTransaction.tryFrom)\n .andThen((pending) => pending.wait())\n .andThen(() => handler(plan.originalTransaction, { cancel }));\n\n case 'InsufficientBalanceError':\n return errAsync(ValidationError.fromGqlNode(plan));\n }\n })\n .andThen(PendingTransaction.tryFrom)\n .andThen((pending) => pending.wait())\n .andThen(client.waitForTransaction),\n [client, handler],\n );\n}\n\nfunction injectLiquidatePermitSignature(\n request: LiquidatePositionRequest,\n _permitSig: ERC20PermitSignature,\n): LiquidatePositionRequest {\n // TODO inject permitSig in the appropriate place once supported in the GQL schema\n return request;\n}\n\n/**\n * A hook that provides a way to set or remove a position manager for a user on a specific spoke.\n *\n * **Position managers** can perform transactions on behalf of other users, including:\n * - Supply assets\n * - Borrow assets\n * - Withdraw assets\n * - Enable/disable collateral\n *\n * The `signature` parameter is an **ERC712 signature** that must be signed by the **user**\n * (the account granting permissions) to authorize the position manager. The signature contains:\n * - `value`: The actual cryptographic signature\n * - `deadline`: Unix timestamp when the authorization expires\n *\n * ```ts\n * const [sendTransaction] = useSendTransaction(wallet);\n * const [setSpokeUserPositionManager, { loading, error }] = useSetSpokeUserPositionManager((transaction, { cancel }) => {\n * return sendTransaction(transaction);\n * });\n *\n * const result = await setSpokeUserPositionManager({\n * spoke: spokeId('SGVsbG8h'),\n * manager: evmAddress('0x9abc…'), // Address that will become the position manager\n * approve: true, // true to approve, false to remove the manager\n * user: evmAddress('0xdef0…'), // User granting the permission (must sign the signature)\n * signature: {\n * value: '0x1234...', // ERC712 signature signed by the user\n * deadline: 1735689600, // Unix timestamp when signature expires\n * },\n * });\n *\n * if (result.isErr()) {\n * switch (result.error.name) {\n * case 'CancelError':\n * // The user cancelled the operation\n * return;\n *\n * case 'SigningError':\n * console.error(`Failed to sign the transaction: ${result.error.message}`);\n * break;\n *\n * case 'TimeoutError':\n * console.error(`Transaction timed out: ${result.error.message}`);\n * break;\n *\n * case 'TransactionError':\n * console.error(`Transaction failed: ${result.error.message}`);\n * break;\n *\n * case 'UnexpectedError':\n * console.error(result.error.message);\n * break;\n * }\n * return;\n * }\n *\n * console.log('Transaction sent with hash:', result.value.txHash);\n * ```\n *\n * @param handler - The handler that will be used to handle the transaction.\n */\nexport function useSetSpokeUserPositionManager(\n handler: ExecutionPlanHandler<TransactionRequest, PendingTransaction>,\n): UseAsyncTask<\n SetSpokeUserPositionManagerRequest,\n TransactionReceipt,\n SendTransactionError | PendingTransactionError\n> {\n const client = useAaveClient();\n\n return useAsyncTask(\n (request: SetSpokeUserPositionManagerRequest) =>\n setSpokeUserPositionManager(client, request)\n .andThen((transaction) => handler(transaction, { cancel }))\n .andThen((pending) => pending.wait())\n .andThen(client.waitForTransaction)\n .andThrough(() => refreshSpokePositionManagers(client, request.spoke)),\n [client, handler],\n );\n}\n\n/**\n * Preview the impact of a potential action on a user's position.\n *\n * ```tsx\n * const [getPreview, previewing] = usePreviewAction();\n *\n * const loading = previewing.loading;\n * const error = previewing.error;\n *\n * // …\n *\n * const result = await getPreview({\n * action: {\n * supply: {\n * reserve: reserveId('SGVsbG8h'),\n * amount: {\n * erc20: {\n * value: '1000',\n * },\n * },\n * sender: evmAddress('0x9abc…'),\n * },\n * },\n * });\n *\n * if (result.isErr()) {\n * console.error(result.error);\n * return;\n * }\n *\n * console.log('Preview result:', result.value);\n * ```\n */\nexport function usePreviewAction(\n options: Required<CurrencyQueryOptions> = DEFAULT_QUERY_OPTIONS,\n): UseAsyncTask<PreviewRequest, PreviewUserPosition, UnexpectedError> {\n const client = useAaveClient();\n\n return useAsyncTask(\n (request: PreviewRequest) =>\n preview(client, request, {\n currency: options.currency,\n requestPolicy: 'network-only',\n }),\n [client, options.currency],\n );\n}\n\nexport type UsePreviewArgs = Prettify<PreviewRequest & CurrencyQueryOptions>;\n\n/**\n * Fetch a preview of the impact of a potential action on a user's position.\n *\n * This signature supports React Suspense:\n *\n * ```tsx\n * const { data } = usePreview({\n * action: {\n * supply: {\n * reserve: reserveId('SGVsbG8h'),\n * amount: {\n * erc20: {\n * currency: evmAddress('0x5678…'),\n * value: '1000',\n * },\n * },\n * supplier: evmAddress('0x9abc…'),\n * },\n * },\n * suspense: true,\n * });\n * ```\n */\nexport function usePreview(\n args: UsePreviewArgs & Suspendable,\n): SuspenseResult<PreviewUserPosition>;\n/**\n * Fetch a preview of the impact of a potential action on a user's position.\n *\n * Pausable suspense mode.\n *\n * ```tsx\n * const { data } = usePreview({\n * action: {\n * supply: {\n * reserve: reserveId('SGVsbG8h'),\n * amount: {\n * erc20: {\n * currency: evmAddress('0x5678…'),\n * value: '1000',\n * },\n * },\n * supplier: evmAddress('0x9abc…'),\n * },\n * },\n * suspense: true,\n * pause: true,\n * });\n * ```\n */\nexport function usePreview(\n args: Pausable<UsePreviewArgs> & Suspendable,\n): PausableSuspenseResult<PreviewUserPosition>;\n/**\n * Fetch a preview of the impact of a potential action on a user's position.\n *\n * ```tsx\n * const { data, error, loading } = usePreview({\n * action: {\n * supply: {\n * reserve: reserveId('SGVsbG8h'),\n * amount: {\n * erc20: {\n * currency: evmAddress('0x5678…'),\n * value: '1000',\n * },\n * },\n * supplier: evmAddress('0x9abc…'),\n * },\n * },\n * });\n * ```\n */\nexport function usePreview(\n args: UsePreviewArgs,\n): ReadResult<PreviewUserPosition>;\n/**\n * Fetch a preview of the impact of a potential action on a user's position.\n *\n * Pausable loading state mode.\n *\n * ```tsx\n * const { data, error, loading, paused } = usePreview({\n * action: {\n * supply: {\n * reserve: reserveId('SGVsbG8h'),\n * amount: {\n * erc20: {\n * currency: evmAddress('0x5678…'),\n * value: '1000',\n * },\n * },\n * supplier: evmAddress('0x9abc…'),\n * },\n * },\n * pause: true,\n * });\n * ```\n */\nexport function usePreview(\n args: Pausable<UsePreviewArgs>,\n): PausableReadResult<PreviewUserPosition>;\n\nexport function usePreview({\n suspense = false,\n pause = false,\n currency = DEFAULT_QUERY_OPTIONS.currency,\n ...request\n}: NullishDeep<UsePreviewArgs> & {\n suspense?: boolean;\n pause?: boolean;\n}): SuspendableResult<PreviewUserPosition, UnexpectedError> {\n return useSuspendableQuery({\n document: PreviewQuery,\n variables: {\n request,\n currency,\n },\n suspense,\n pause,\n });\n}\n\nexport type UseActivitiesArgs = Prettify<\n ActivitiesRequest & CurrencyQueryOptions & TimeWindowQueryOptions\n>;\n\n/**\n * Fetch paginated list of activities.\n *\n * This signature supports React Suspense:\n *\n * ```tsx\n * const { data } = useActivities({\n * query: {\n * chainId: chainId(1),\n * },\n * user: evmAddress('0x742d35cc…'),\n * suspense: true,\n * });\n *\n * // data.items: ActivityItem[]\n * ```\n */\nexport function useActivities(\n args: UseActivitiesArgs & Suspendable,\n): SuspenseResult<PaginatedActivitiesResult>;\n/**\n * Fetch paginated list of activities.\n *\n * Pausable suspense mode.\n *\n * ```tsx\n * const { data } = useActivities({\n * query: {\n * chainId: chainId(1),\n * },\n * user: evmAddress('0x742d35cc…'),\n * suspense: true,\n * pause: true,\n * });\n *\n * // data?.items: ActivityItem[] | undefined\n * ```\n */\nexport function useActivities(\n args: Pausable<UseActivitiesArgs> & Suspendable,\n): PausableSuspenseResult<PaginatedActivitiesResult>;\n/**\n * Fetch paginated list of activities.\n *\n * ```tsx\n * const { data, error, loading } = useActivities({\n * query: {\n * chainId: chainId(1),\n * },\n * user: evmAddress('0x742d35cc…'),\n * });\n * ```\n */\nexport function useActivities(\n args: UseActivitiesArgs,\n): ReadResult<PaginatedActivitiesResult>;\n/**\n * Fetch paginated list of activities.\n *\n * Pausable loading state mode.\n *\n * ```tsx\n * const { data, error, loading } = useActivities({\n * query: {\n * chainId: chainId(1),\n * },\n * user: evmAddress('0x742d35cc…'),\n * pause: true,\n * });\n *\n * // data?.items: ActivityItem[] | undefined\n * // error: UnexpectedError | undefined\n * // loading: boolean | undefined\n * ```\n */\nexport function useActivities(\n args: Pausable<UseActivitiesArgs>,\n): PausableReadResult<PaginatedActivitiesResult>;\n\nexport function useActivities({\n suspense = false,\n pause = false,\n currency = DEFAULT_QUERY_OPTIONS.currency,\n timeWindow = DEFAULT_QUERY_OPTIONS.timeWindow,\n ...request\n}: NullishDeep<UseActivitiesArgs> & {\n suspense?: boolean;\n pause?: boolean;\n}): SuspendableResult<PaginatedActivitiesResult, UnexpectedError> {\n return useSuspendableQuery({\n document: ActivitiesQuery,\n variables: {\n request,\n currency,\n timeWindow,\n },\n suspense,\n pause,\n });\n}\n\n/**\n * Low-level hook to execute a {@link activities} action directly.\n *\n * @experimental This hook is experimental and may be subject to breaking changes.\n * @remarks\n * This hook does not actively watch for updates. Use it to fetch activities on demand\n * (e.g., in an event handler when paginating or refining filters).\n *\n * @param options - The query options.\n * @returns The user history.\n */\nexport function useActivitiesAction(\n options: CurrencyQueryOptions &\n TimeWindowQueryOptions = DEFAULT_QUERY_OPTIONS,\n): UseAsyncTask<ActivitiesRequest, PaginatedActivitiesResult, UnexpectedError> {\n const client = useAaveClient();\n\n return useAsyncTask(\n (request: ActivitiesRequest) =>\n activities(client, request, {\n currency: options.currency ?? DEFAULT_QUERY_OPTIONS.currency,\n timeWindow: options.timeWindow ?? DEFAULT_QUERY_OPTIONS.timeWindow,\n requestPolicy: 'cache-first',\n }),\n [client, options.currency, options.timeWindow],\n );\n}\n\n/**\n * A hook that provides a way to claim rewards.\n *\n * ```ts\n * const [sendTransaction] = useSendTransaction(wallet);\n * const [claim, { loading, error }] = useClaimRewards((transaction, { cancel }) => {\n * return sendTransaction(transaction);\n * });\n *\n * // …\n *\n * const result = await claim({\n * ids: [rewardId('abc123')],\n * });\n *\n * if (result.isErr()) {\n * switch (result.error.name) {\n * case 'CancelError':\n * // The user cancelled the operation\n * return;\n *\n * case 'SigningError':\n * console.error(`Failed to sign the transaction: ${result.error.message}`);\n * break;\n *\n * case 'TimeoutError':\n * console.error(`Transaction timed out: ${result.error.message}`);\n * break;\n *\n * case 'TransactionError':\n * console.error(`Transaction failed: ${result.error.message}`);\n * break;\n *\n * case 'UnexpectedError':\n * console.error(result.error.message);\n * break;\n * }\n * return;\n * }\n *\n * console.log('Transaction sent with hash:', result.value.txHash);\n * ```\n *\n * @param handler - The handler that will be used to handle the transaction.\n */\nexport function useClaimRewards(\n handler: ExecutionPlanHandler<TransactionRequest, PendingTransaction>,\n): UseAsyncTask<\n ClaimRewardsRequest,\n TransactionReceipt,\n SendTransactionError | PendingTransactionError\n> {\n const client = useAaveClient();\n\n return useAsyncTask(\n (request: ClaimRewardsRequest) =>\n claimRewards(client, request)\n .andThen((transaction) => handler(transaction, { cancel }))\n .andThen(PendingTransaction.tryFrom)\n .andThen((pending) => pending.wait())\n .map((result) => transactionReceipt(result.txHash)),\n [client, handler],\n );\n}\n","import {\n type CurrencyQueryOptions,\n DEFAULT_QUERY_OPTIONS,\n type TimeWindowQueryOptions,\n type UnexpectedError,\n} from '@aave/client';\nimport type { UserPositionQueryOptions } from '@aave/client/actions';\nimport {\n userBalances,\n userBorrows,\n userPositions,\n userSupplies,\n} from '@aave/client/actions';\nimport {\n type UserBalance,\n UserBalancesQuery,\n type UserBalancesRequest,\n type UserBorrowItem,\n UserBorrowsQuery,\n type UserBorrowsRequest,\n type UserPosition,\n UserPositionQuery,\n type UserPositionRequest,\n UserPositionsQuery,\n type UserPositionsRequest,\n type UserRiskPremiumBreakdownItem,\n UserRiskPremiumBreakdownQuery,\n type UserRiskPremiumBreakdownRequest,\n type UserSummary,\n type UserSummaryHistoryItem,\n UserSummaryHistoryQuery,\n type UserSummaryHistoryRequest,\n UserSummaryQuery,\n type UserSummaryRequest,\n UserSuppliesQuery,\n type UserSuppliesRequest,\n type UserSupplyItem,\n} from '@aave/graphql';\nimport type { NullishDeep, Prettify } from '@aave/types';\nimport { useAaveClient } from './context';\nimport {\n type Pausable,\n type PausableReadResult,\n type PausableSuspenseResult,\n type ReadResult,\n type Suspendable,\n type SuspendableResult,\n type SuspenseResult,\n type UseAsyncTask,\n useAsyncTask,\n useSuspendableQuery,\n} from './helpers';\n\nexport type UseUserSuppliesArgs = Prettify<\n UserSuppliesRequest & CurrencyQueryOptions & TimeWindowQueryOptions\n>;\n\n/**\n * Fetch all user supply positions.\n *\n * This signature supports React Suspense:\n *\n * ```tsx\n * const { data } = useUserSupplies({\n * query: {\n * userSpoke: {\n * spoke: { address: evmAddress('0x87870bca…'), chainId: chainId(1) },\n * user: evmAddress('0x742d35cc…'),\n * },\n * },\n * orderBy: { name: 'ASC' },\n * suspense: true,\n * });\n * ```\n */\nexport function useUserSupplies(\n args: UseUserSuppliesArgs & Suspendable,\n): SuspenseResult<UserSupplyItem[]>;\n/**\n * Fetch all user supply positions.\n *\n * Pausable suspense mode.\n *\n * ```tsx\n * const { data } = useUserSupplies({\n * query: {\n * userSpoke: {\n * spoke: { address: evmAddress('0x87870bca…'), chainId: chainId(1) },\n * user: evmAddress('0x742d35cc…'),\n * },\n * },\n * orderBy: { name: 'ASC' },\n * suspense: true,\n * pause: true,\n * });\n *\n * // data?.length: number | undefined\n * ```\n */\nexport function useUserSupplies(\n args: Pausable<UseUserSuppliesArgs> & Suspendable,\n): PausableSuspenseResult<UserSupplyItem[]>;\n/**\n * Fetch all user supply positions.\n *\n * ```tsx\n * const { data, error, loading } = useUserSupplies({\n * query: {\n * userSpoke: {\n * spoke: { address: evmAddress('0x87870bca…'), chainId: chainId(1) },\n * user: evmAddress('0x742d35cc…'),\n * },\n * },\n * orderBy: { name: 'ASC' },\n * });\n * ```\n */\nexport function useUserSupplies(\n args: UseUserSuppliesArgs,\n): ReadResult<UserSupplyItem[]>;\n/**\n * Fetch all user supply positions.\n *\n * Pausable loading state mode.\n *\n * ```tsx\n * const { data, error, loading, paused } = useUserSupplies({\n * query: {\n * userSpoke: {\n * spoke: { address: evmAddress('0x87870bca…'), chainId: chainId(1) },\n * user: evmAddress('0x742d35cc…'),\n * },\n * },\n * orderBy: { name: 'ASC' },\n * pause: true,\n * });\n *\n * // data?.length: number | undefined\n * // error: UnexpectedError | undefined\n * // loading: boolean | undefined\n * // paused: boolean\n * ```\n */\nexport function useUserSupplies(\n args: Pausable<UseUserSuppliesArgs>,\n): PausableReadResult<UserSupplyItem[]>;\n\nexport function useUserSupplies({\n suspense = false,\n pause = false,\n currency = DEFAULT_QUERY_OPTIONS.currency,\n timeWindow = DEFAULT_QUERY_OPTIONS.timeWindow,\n ...request\n}: NullishDeep<UseUserSuppliesArgs> & {\n suspense?: boolean;\n pause?: boolean;\n}): SuspendableResult<UserSupplyItem[], UnexpectedError> {\n return useSuspendableQuery({\n document: UserSuppliesQuery,\n variables: {\n request,\n currency,\n timeWindow,\n },\n suspense,\n pause,\n });\n}\n\n/**\n * Low-level hook to execute a {@link userSupplies} action directly.\n *\n * @experimental This hook is experimental and may be subject to breaking changes.\n * @remarks\n * This hook **does not** actively watch for updated data on user supplies.\n * Use this hook to retrieve data on demand as part of a larger workflow\n * (e.g., in an event handler in order to move to the next step).\n *\n * ```ts\n * const [execute, { called, data, error, loading }] = useUserSuppliesAction();\n *\n * // …\n *\n * const result = await execute({\n * query: {\n * userSpoke: {\n * spoke: { address: evmAddress('0x87870bca…'), chainId: chainId(1) },\n * user: evmAddress('0x742d35cc…'),\n * },\n * },\n * orderBy: { name: 'ASC' },\n * });\n *\n * if (result.isOk()) {\n * console.log(result.value); // UserSupplyItem[]\n * } else {\n * console.error(result.error);\n * }\n * ```\n */\nexport function useUserSuppliesAction(\n options: CurrencyQueryOptions &\n TimeWindowQueryOptions = DEFAULT_QUERY_OPTIONS,\n): UseAsyncTask<UserSuppliesRequest, UserSupplyItem[], UnexpectedError> {\n const client = useAaveClient();\n\n return useAsyncTask(\n (request: UserSuppliesRequest) =>\n userSupplies(client, request, {\n currency: options.currency ?? DEFAULT_QUERY_OPTIONS.currency,\n timeWindow: options.timeWindow ?? DEFAULT_QUERY_OPTIONS.timeWindow,\n requestPolicy: 'cache-first',\n }),\n [client, options.currency, options.timeWindow],\n );\n}\n\nexport type UseUserBorrowsArgs = Prettify<\n UserBorrowsRequest & CurrencyQueryOptions & TimeWindowQueryOptions\n>;\n\n/**\n * Fetch all user borrow positions.\n *\n * This signature supports React Suspense:\n *\n * ```tsx\n * const { data } = useUserBorrows({\n * query: {\n * userSpoke: {\n * spoke: { address: evmAddress('0x87870bca…'), chainId: chainId(1) },\n * user: evmAddress('0x742d35cc…'),\n * },\n * },\n * orderBy: { name: 'ASC' },\n * suspense: true,\n * });\n * ```\n */\nexport function useUserBorrows(\n args: UseUserBorrowsArgs & Suspendable,\n): SuspenseResult<UserBorrowItem[]>;\n/**\n * Fetch all user borrow positions.\n *\n * Pausable suspense mode.\n *\n * ```tsx\n * const { data } = useUserBorrows({\n * query: {\n * userSpoke: {\n * spoke: { address: evmAddress('0x87870bca…'), chainId: chainId(1) },\n * user: evmAddress('0x742d35cc…'),\n * },\n * },\n * orderBy: { name: 'ASC' },\n * suspense: true,\n * pause: true,\n * });\n * ```\n */\nexport function useUserBorrows(\n args: Pausable<UseUserBorrowsArgs> & Suspendable,\n): PausableSuspenseResult<UserBorrowItem[]>;\n/**\n * Fetch all user borrow positions.\n *\n * ```tsx\n * const { data, error, loading } = useUserBorrows({\n * query: {\n * userSpoke: {\n * spoke: { address: evmAddress('0x87870bca…'), chainId: chainId(1) },\n * user: evmAddress('0x742d35cc…'),\n * },\n * },\n * orderBy: { name: 'ASC' },\n * });\n * ```\n */\nexport function useUserBorrows(\n args: UseUserBorrowsArgs,\n): ReadResult<UserBorrowItem[]>;\n/**\n * Fetch all user borrow positions.\n *\n * Pausable loading state mode.\n *\n * ```tsx\n * const { data, error, loading, paused } = useUserBorrows({\n * query: {\n * userSpoke: {\n * spoke: { address: evmAddress('0x87870bca…'), chainId: chainId(1) },\n * user: evmAddress('0x742d35cc…'),\n * },\n * },\n * orderBy: { name: 'ASC' },\n * pause: true,\n * });\n * ```\n */\nexport function useUserBorrows(\n args: Pausable<UseUserBorrowsArgs>,\n): PausableReadResult<UserBorrowItem[]>;\n\nexport function useUserBorrows({\n suspense = false,\n pause = false,\n currency = DEFAULT_QUERY_OPTIONS.currency,\n timeWindow = DEFAULT_QUERY_OPTIONS.timeWindow,\n ...request\n}: NullishDeep<UseUserBorrowsArgs> & {\n suspense?: boolean;\n pause?: boolean;\n}): SuspendableResult<UserBorrowItem[], UnexpectedError> {\n return useSuspendableQuery({\n document: UserBorrowsQuery,\n variables: {\n request,\n currency,\n timeWindow,\n },\n suspense,\n pause,\n });\n}\n\n/**\n * Low-level hook to execute a {@link userBorrows} action directly.\n *\n * @experimental This hook is experimental and may be subject to breaking changes.\n * @remarks\n * This hook **does not** actively watch for updated data on user borrows.\n * Use this hook to retrieve data on demand as part of a larger workflow\n * (e.g., in an event handler in order to move to the next step).\n *\n * ```ts\n * const [execute, { called, data, error, loading }] = useUserBorrowsAction();\n *\n * // …\n *\n * const result = await execute({\n * query: {\n * userSpoke: {\n * spoke: { address: evmAddress('0x87870bca…'), chainId: chainId(1) },\n * user: evmAddress('0x742d35cc…'),\n * },\n * },\n * orderBy: { name: 'ASC' },\n * });\n *\n * if (result.isOk()) {\n * console.log(result.value); // UserBorrowItem[]\n * } else {\n * console.error(result.error);\n * }\n * ```\n */\nexport function useUserBorrowsAction(\n options: CurrencyQueryOptions &\n TimeWindowQueryOptions = DEFAULT_QUERY_OPTIONS,\n): UseAsyncTask<UserBorrowsRequest, UserBorrowItem[], UnexpectedError> {\n const client = useAaveClient();\n\n return useAsyncTask(\n (request: UserBorrowsRequest) =>\n userBorrows(client, request, {\n currency: options.currency ?? DEFAULT_QUERY_OPTIONS.currency,\n timeWindow: options.timeWindow ?? DEFAULT_QUERY_OPTIONS.timeWindow,\n requestPolicy: 'cache-first',\n }),\n [client, options.currency, options.timeWindow],\n );\n}\n\nexport type UseUserSummaryArgs = Prettify<\n UserSummaryRequest & TimeWindowQueryOptions & CurrencyQueryOptions\n>;\n\n/**\n * Fetch a user's financial summary.\n *\n * This signature supports React Suspense:\n *\n * ```tsx\n * const { data } = useUserSummary({\n * user: evmAddress('0x742d35cc…'),\n * filter: {\n * spoke: { address: evmAddress('0x87870bca…'), chainId: chainId(1) },\n * },\n * suspense: true,\n * });\n * ```\n */\nexport function useUserSummary(\n args: UseUserSummaryArgs & Suspendable,\n): SuspenseResult<UserSummary>;\n/**\n * Fetch a user's financial summary.\n *\n * Pausable suspense mode.\n *\n * ```tsx\n * const { data } = useUserSummary({\n * user: evmAddress('0x742d35cc…'),\n * filter: {\n * spoke: { address: evmAddress('0x87870bca…'), chainId: chainId(1) },\n * },\n * suspense: true,\n * pause: true,\n * });\n * ```\n */\nexport function useUserSummary(\n args: Pausable<UseUserSummaryArgs> & Suspendable,\n): PausableSuspenseResult<UserSummary>;\n/**\n * Fetch a user's financial summary.\n *\n * ```tsx\n * const { data, error, loading } = useUserSummary({\n * user: evmAddress('0x742d35cc…'),\n * filter: {\n * spoke: { address: evmAddress('0x87870bca…'), chainId: chainId(1) },\n * },\n * });\n * ```\n */\nexport function useUserSummary(\n args: UseUserSummaryArgs,\n): ReadResult<UserSummary>;\n/**\n * Fetch a user's financial summary.\n *\n * Pausable loading state mode.\n *\n * ```tsx\n * const { data, error, loading, paused } = useUserSummary({\n * user: evmAddress('0x742d35cc…'),\n * filter: {\n * spoke: { address: evmAddress('0x87870bca…'), chainId: chainId(1) },\n * },\n * pause: true,\n * });\n * ```\n */\nexport function useUserSummary(\n args: Pausable<UseUserSummaryArgs>,\n): PausableReadResult<UserSummary>;\n\nexport function useUserSummary({\n suspense = false,\n pause = false,\n currency = DEFAULT_QUERY_OPTIONS.currency,\n timeWindow = DEFAULT_QUERY_OPTIONS.timeWindow,\n ...request\n}: NullishDeep<UseUserSummaryArgs> & {\n suspense?: boolean;\n pause?: boolean;\n}): SuspendableResult<UserSummary, UnexpectedError> {\n return useSuspendableQuery({\n document: UserSummaryQuery,\n variables: {\n request,\n currency,\n timeWindow,\n },\n suspense,\n pause,\n });\n}\n\nexport type UseUserPositionsArgs = Prettify<\n UserPositionsRequest & UserPositionQueryOptions\n>;\n\n/**\n * Fetch all user positions across specified chains.\n *\n * This signature supports React Suspense:\n *\n * ```tsx\n * const { data } = useUserPositions({\n * user: evmAddress('0x742d35cc…'),\n * chainIds: [chainId(1), chainId(137)],\n * orderBy: { balance: 'DESC' },\n * suspense: true,\n * });\n * ```\n */\nexport function useUserPositions(\n args: UseUserPositionsArgs & Suspendable,\n): SuspenseResult<UserPosition[]>;\n/**\n * Fetch all user positions across specified chains.\n *\n * Pausable suspense mode.\n *\n * ```tsx\n * const { data } = useUserPositions({\n * user: evmAddress('0x742d35cc…'),\n * chainIds: [chainId(1), chainId(137)],\n * orderBy: { balance: 'DESC' },\n * suspense: true,\n * pause: true,\n * });\n * ```\n */\nexport function useUserPositions(\n args: Pausable<UseUserPositionsArgs> & Suspendable,\n): PausableSuspenseResult<UserPosition[]>;\n/**\n * Fetch all user positions across specified chains.\n *\n * ```tsx\n * const { data, error, loading } = useUserPositions({\n * user: evmAddress('0x742d35cc…'),\n * chainIds: [chainId(1), chainId(137)],\n * orderBy: { balance: 'DESC' },\n * });\n * ```\n */\nexport function useUserPositions(\n args: UseUserPositionsArgs,\n): ReadResult<UserPosition[]>;\n/**\n * Fetch all user positions across specified chains.\n *\n * Pausable loading state mode.\n *\n * ```tsx\n * const { data, error, loading, paused } = useUserPositions({\n * user: evmAddress('0x742d35cc…'),\n * chainIds: [chainId(1), chainId(137)],\n * orderBy: { balance: 'DESC' },\n * pause: true,\n * });\n * ```\n */\nexport function useUserPositions(\n args: Pausable<UseUserPositionsArgs>,\n): PausableReadResult<UserPosition[]>;\n\nexport function useUserPositions({\n suspense = false,\n pause = false,\n currency = DEFAULT_QUERY_OPTIONS.currency,\n timeWindow = DEFAULT_QUERY_OPTIONS.timeWindow,\n ...request\n}: NullishDeep<UseUserPositionsArgs> & {\n suspense?: boolean;\n pause?: boolean;\n}): SuspendableResult<UserPosition[], UnexpectedError> {\n return useSuspendableQuery({\n document: UserPositionsQuery,\n variables: {\n request,\n currency,\n timeWindow,\n },\n suspense,\n pause,\n });\n}\n\n/**\n * Low-level hook to execute a {@link userPositions} action directly.\n *\n * @experimental This hook is experimental and may be subject to breaking changes.\n * @remarks\n * This hook **does not** actively watch for updated data on user positions.\n * Use this hook to retrieve data on demand as part of a larger workflow\n * (e.g., in an event handler in order to move to the next step).\n *\n * ```ts\n * const [execute, { called, data, error, loading }] = useUserPositionsAction();\n *\n * // …\n *\n * const result = await execute({\n * user: evmAddress('0x742d35cc…'),\n * filter: {\n * chainIds: [chainId(1), chainId(137)]\n * },\n * orderBy: { balance: 'DESC' },\n * });\n *\n * if (result.isOk()) {\n * console.log(result.value); // UserPosition[]\n * } else {\n * console.error(result.error);\n * }\n * ```\n */\nexport function useUserPositionsAction(\n options: UserPositionQueryOptions = DEFAULT_QUERY_OPTIONS,\n): UseAsyncTask<UserPositionsRequest, UserPosition[], UnexpectedError> {\n const client = useAaveClient();\n\n return useAsyncTask(\n (request: UserPositionsRequest) =>\n userPositions(client, request, {\n currency: options.currency,\n timeWindow: options.timeWindow,\n requestPolicy: 'cache-first',\n }),\n [client, options.currency, options.timeWindow],\n );\n}\n\nexport type UseUserPositionArgs = Prettify<\n UserPositionRequest & UserPositionQueryOptions\n>;\n\n/**\n * Fetch a specific user position by ID.\n *\n * This signature supports React Suspense:\n *\n * ```tsx\n * const { data } = useUserPosition({\n * id: userPositionId('SGVsbG8h'),\n * user: evmAddress('0x742d35cc…'),\n * suspense: true,\n * });\n * ```\n */\nexport function useUserPosition(\n args: UseUserPositionArgs & Suspendable,\n): SuspenseResult<UserPosition>;\n/**\n * Fetch a specific user position by ID.\n *\n * Pausable suspense mode.\n *\n * ```tsx\n * const { data } = useUserPosition({\n * id: userPositionId('SGVsbG8h'),\n * user: evmAddress('0x742d35cc…'),\n * suspense: true,\n * pause: true,\n * });\n * ```\n */\nexport function useUserPosition(\n args: Pausable<UseUserPositionArgs> & Suspendable,\n): PausableSuspenseResult<UserPosition>;\n/**\n * Fetch a specific user position by ID.\n *\n * ```tsx\n * const { data, error, loading } = useUserPosition({\n * id: userPositionId('SGVsbG8h'),\n * user: evmAddress('0x742d35cc…'),\n * });\n * ```\n */\nexport function useUserPosition(\n args: UseUserPositionArgs,\n): ReadResult<UserPosition>;\n/**\n * Fetch a specific user position by ID.\n *\n * Pausable loading state mode.\n *\n * ```tsx\n * const { data, error, loading, paused } = useUserPosition({\n * id: userPositionId('SGVsbG8h'),\n * user: evmAddress('0x742d35cc…'),\n * pause: true,\n * });\n * ```\n */\nexport function useUserPosition(\n args: Pausable<UseUserPositionArgs>,\n): PausableReadResult<UserPosition>;\n\nexport function useUserPosition({\n suspense = false,\n pause = false,\n currency = DEFAULT_QUERY_OPTIONS.currency,\n timeWindow = DEFAULT_QUERY_OPTIONS.timeWindow,\n ...request\n}: NullishDeep<UseUserPositionArgs> & {\n suspense?: boolean;\n pause?: boolean;\n}): SuspendableResult<UserPosition | null, UnexpectedError> {\n return useSuspendableQuery({\n document: UserPositionQuery,\n variables: {\n request,\n currency,\n timeWindow,\n },\n suspense,\n pause,\n });\n}\n\nexport type UseUserBalancesArgs = Prettify<\n UserBalancesRequest & CurrencyQueryOptions\n>;\n\n/**\n * Fetch all user balances across specified chains.\n *\n * This signature supports React Suspense:\n *\n * ```tsx\n * const { data } = useUserBalances({\n * user: evmAddress('0x742d35cc…'),\n * chainIds: [chainId(1), chainId(137)],\n * suspense: true,\n * });\n * ```\n */\nexport function useUserBalances(\n args: UseUserBalancesArgs & Suspendable,\n): SuspenseResult<UserBalance[]>;\n/**\n * Fetch all user balances across specified chains.\n *\n * Pausable suspense mode.\n *\n * ```tsx\n * const { data } = useUserBalances({\n * user: evmAddress('0x742d35cc…'),\n * chainIds: [chainId(1), chainId(137)],\n * suspense: true,\n * pause: true,\n * });\n * ```\n */\nexport function useUserBalances(\n args: Pausable<UseUserBalancesArgs> & Suspendable,\n): PausableSuspenseResult<UserBalance[]>;\n/**\n * Fetch all user balances across specified chains.\n *\n * ```tsx\n * const { data, error, loading } = useUserBalances({\n * user: evmAddress('0x742d35cc…'),\n * chainIds: [chainId(1), chainId(137)],\n * });\n * ```\n */\nexport function useUserBalances(\n args: UseUserBalancesArgs,\n): ReadResult<UserBalance[]>;\n/**\n * Fetch all user balances across specified chains.\n *\n * Pausable loading state mode.\n *\n * ```tsx\n * const { data, error, loading, paused } = useUserBalances({\n * user: evmAddress('0x742d35cc…'),\n * chainIds: [chainId(1), chainId(137)],\n * pause: true,\n * });\n * ```\n */\nexport function useUserBalances(\n args: Pausable<UseUserBalancesArgs>,\n): PausableReadResult<UserBalance[]>;\n\nexport function useUserBalances({\n suspense = false,\n pause = false,\n currency = DEFAULT_QUERY_OPTIONS.currency,\n ...request\n}: NullishDeep<UseUserBalancesArgs> & {\n suspense?: boolean;\n pause?: boolean;\n}): SuspendableResult<UserBalance[], UnexpectedError> {\n return useSuspendableQuery({\n document: UserBalancesQuery,\n variables: {\n request,\n currency,\n },\n suspense,\n pause,\n });\n}\n\nexport type UseUserRiskPremiumBreakdownArgs = UserRiskPremiumBreakdownRequest;\n\n/**\n * Fetch the risk premium breakdown for a user position or spoke.\n *\n * This signature supports React Suspense:\n *\n * ```tsx\n * const { data } = useUserRiskPremiumBreakdown({\n * query: {\n * userPositionId: userPositionId('SGVsbG8h'),\n * },\n * user: evmAddress('0x742d35cc…'),\n * suspense: true,\n * });\n * ```\n */\nexport function useUserRiskPremiumBreakdown(\n args: UseUserRiskPremiumBreakdownArgs & Suspendable,\n): SuspenseResult<UserRiskPremiumBreakdownItem[]>;\n/**\n * Fetch the risk premium breakdown for a user position or spoke.\n *\n * Pausable suspense mode.\n *\n * ```tsx\n * const { data } = useUserRiskPremiumBreakdown({\n * query: {\n * userPositionId: userPositionId('SGVsbG8h'),\n * },\n * user: evmAddress('0x742d35cc…'),\n * suspense: true,\n * pause: true,\n * });\n * ```\n */\nexport function useUserRiskPremiumBreakdown(\n args: Pausable<UseUserRiskPremiumBreakdownArgs> & Suspendable,\n): PausableSuspenseResult<UserRiskPremiumBreakdownItem[]>;\n/**\n * Fetch the risk premium breakdown for a user position or spoke.\n *\n * ```tsx\n * const { data, error, loading } = useUserRiskPremiumBreakdown({\n * query: {\n * userPositionId: userPositionId('SGVsbG8h'),\n * },\n * user: evmAddress('0x742d35cc…'),\n * });\n * ```\n */\nexport function useUserRiskPremiumBreakdown(\n args: UseUserRiskPremiumBreakdownArgs,\n): ReadResult<UserRiskPremiumBreakdownItem[]>;\n/**\n * Fetch the risk premium breakdown for a user position or spoke.\n *\n * Pausable loading state mode.\n *\n * ```tsx\n * const { data, error, loading, paused } = useUserRiskPremiumBreakdown({\n * query: {\n * userPositionId: userPositionId('SGVsbG8h'),\n * },\n * user: evmAddress('0x742d35cc…'),\n * pause: true,\n * });\n * ```\n */\nexport function useUserRiskPremiumBreakdown(\n args: Pausable<UseUserRiskPremiumBreakdownArgs>,\n): PausableReadResult<UserRiskPremiumBreakdownItem[]>;\n\nexport function useUserRiskPremiumBreakdown({\n suspense = false,\n pause = false,\n ...request\n}: NullishDeep<UseUserRiskPremiumBreakdownArgs> & {\n suspense?: boolean;\n pause?: boolean;\n}): SuspendableResult<UserRiskPremiumBreakdownItem[], UnexpectedError> {\n return useSuspendableQuery({\n document: UserRiskPremiumBreakdownQuery,\n variables: {\n request,\n },\n suspense,\n pause,\n batch: false, // Do not batch this since it's a slower than average query\n });\n}\n\n/**\n * Low-level hook to execute a {@link userBalances} action directly.\n *\n * @experimental This hook is experimental and may be subject to breaking changes.\n * @remarks\n * This hook **does not** actively watch for updated data on user balances.\n * Use this hook to retrieve data on demand as part of a larger workflow\n * (e.g., in an event handler in order to move to the next step).\n *\n * ```ts\n * const [execute, { called, data, error, loading }] = useUserBalancesAction();\n *\n * // …\n *\n * const result = await execute({\n * user: evmAddress('0x742d35cc…'),\n * filter: {\n * chainIds: [chainId(1), chainId(137)]\n * },\n * });\n *\n * if (result.isOk()) {\n * console.log(result.value); // UserBalance[]\n * } else {\n * console.error(result.error);\n * }\n * ```\n */\nexport function useUserBalancesAction(\n options: Required<CurrencyQueryOptions> = DEFAULT_QUERY_OPTIONS,\n): UseAsyncTask<UserBalancesRequest, UserBalance[], UnexpectedError> {\n const client = useAaveClient();\n\n return useAsyncTask(\n (request: UserBalancesRequest) =>\n userBalances(client, request, {\n currency: options.currency,\n requestPolicy: 'cache-first',\n }),\n [client, options.currency],\n );\n}\n\nexport type UseUserSummaryHistoryArgs = Prettify<\n UserSummaryHistoryRequest & CurrencyQueryOptions\n>;\n\n/**\n * Fetch user summary history over time.\n *\n * This signature supports React Suspense:\n *\n * ```tsx\n * const { data } = useUserSummaryHistory({\n * user: evmAddress('0x742d35cc…'),\n * window: TimeWindow.LastWeek,\n * filter: { chainIds: [chainId(1)] },\n * suspense: true,\n * });\n * ```\n */\nexport function useUserSummaryHistory(\n args: UseUserSummaryHistoryArgs & Suspendable,\n): SuspenseResult<UserSummaryHistoryItem[]>;\n/**\n * Fetch user summary history over time.\n *\n * Pausable suspense mode.\n *\n * ```tsx\n * const { data } = useUserSummaryHistory({\n * user: evmAddress('0x742d35cc…'),\n * window: TimeWindow.LastWeek,\n * filter: { chainIds: [chainId(1)] },\n * suspense: true,\n * pause: true,\n * });\n * ```\n */\nexport function useUserSummaryHistory(\n args: Pausable<UseUserSummaryHistoryArgs> & Suspendable,\n): PausableSuspenseResult<UserSummaryHistoryItem[]>;\n/**\n * Fetch user summary history over time.\n *\n * ```tsx\n * const { data, error, loading } = useUserSummaryHistory({\n * user: evmAddress('0x742d35cc…'),\n * window: TimeWindow.LastWeek,\n * filter: { chainIds: [chainId(1)] },\n * });\n * ```\n */\nexport function useUserSummaryHistory(\n args: UseUserSummaryHistoryArgs,\n): ReadResult<UserSummaryHistoryItem[]>;\n/**\n * Fetch user summary history over time.\n *\n * Pausable loading state mode.\n *\n * ```tsx\n * const { data, error, loading, paused } = useUserSummaryHistory({\n * user: evmAddress('0x742d35cc…'),\n * window: TimeWindow.LastWeek,\n * filter: { chainIds: [chainId(1)] },\n * pause: true,\n * });\n * ```\n */\nexport function useUserSummaryHistory(\n args: Pausable<UseUserSummaryHistoryArgs>,\n): PausableReadResult<UserSummaryHistoryItem[]>;\n\nexport function useUserSummaryHistory({\n suspense = false,\n pause = false,\n currency = DEFAULT_QUERY_OPTIONS.currency,\n ...request\n}: NullishDeep<UseUserSummaryHistoryArgs> & {\n suspense?: boolean;\n pause?: boolean;\n}): SuspendableResult<UserSummaryHistoryItem[], UnexpectedError> {\n return useSuspendableQuery({\n document: UserSummaryHistoryQuery,\n variables: {\n request,\n currency,\n },\n suspense,\n pause,\n batch: false, // Do not batch this since it's a slower than average query\n });\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/context.tsx","../src/AaveProvider.tsx","../src/helpers/cache.ts","../src/helpers/results.ts","../src/helpers/reads.ts","../src/helpers/tasks.ts","../src/helpers/writes.ts","../src/hubs.ts","../src/misc.ts","../src/protocol.ts","../src/reserves.ts","../src/rewards.ts","../src/spokes.ts","../src/swap/helpers.ts","../src/swap/useBorrowSwap.ts","../src/swap/useBorrowSwapQuote.ts","../src/swap/useCancelSwap.ts","../src/swap/useRepayWithSupply.ts","../src/swap/useRepayWithSupplyQuote.ts","../src/swap/useSupplySwap.ts","../src/swap/useSupplySwapQuote.ts","../src/swap/useSwappableTokens.ts","../src/swap/useSwapStatus.ts","../src/swap/useTokenSwap.ts","../src/swap/useTokenSwapQuote.ts","../src/swap/useUserSwaps.ts","../src/swap/useWithdrawSwap.ts","../src/swap/useWithdrawSwapQuote.ts","../src/transactions/useActivities.ts","../src/transactions/useBorrow.ts","../src/transactions/useClaimRewards.ts","../src/transactions/approvals.ts","../src/transactions/useLiquidatePosition.ts","../src/transactions/usePreview.ts","../src/transactions/useRenounceSpokeUserPositionManager.ts","../src/transactions/useRepay.ts","../src/transactions/useSetSpokeUserPositionManager.ts","../src/transactions/useSetUserSuppliesAsCollateral.ts","../src/transactions/useSupply.ts","../src/transactions/useUpdateUserPositionConditions.ts","../src/transactions/useWithdraw.ts","../src/user.ts"],"names":["AaveContext","React","AaveContextProvider","children","client","UrqlProvider","useAaveClient","useContext","invariant","AaveProvider","extractUserSuppliesRequestUser","query","user","decodeUserPositionId","extractUserBorrowsRequestUser","refreshUserBalances","UserBalancesQuery","variables","refreshUserSupplies","UserSuppliesQuery","refreshUserBorrows","UserBorrowsQuery","refreshUserPositions","spoke","isMatch","position","ResultAsync","UserPositionsQuery","_","data","UserPositionQuery","refreshReserves","ids","reserve","ReserveQuery","ReservesQuery","refreshUserSummary","UserSummaryQuery","isSpokeInputVariant","isChainIdsVariant","id","refreshSpokes","item","SpokeQuery","SpokesQuery","refreshHubs","chainId","hub","HubQuery","HubsQuery","refreshSpokePositionManagers","SpokePositionManagersQuery","refreshUserPositionById","userPositionId","refreshQueriesForReserveChange","request","address","decodeReserveId","refreshAfterTokenSwap","refreshAfterSupplySwap","refreshAfterBorrowSwap","refreshAfterRepayWithSupply","refreshAfterWithdrawSwap","ReadResult","reloading","error","useSuspendableQuery","document","suspense","pause","selector","ok","pollInterval","batch","loading","setLoading","useState","fetching","stale","executeQuery","useQuery","useMemo","useEffect","timerId","unexpectedError","UnexpectedError","selected","unexpected","AsyncTaskState","useAsyncTask","handler","deps","state","setState","loadingRef","useRef","mountedRef","handle","useCallback","input","previousState","result","value","cancel","message","CancelError","PendingTransaction","_PendingTransaction","wait","okAsync","trySignatureFrom","isSignature","useHub","currency","DEFAULT_QUERY_OPTIONS","timeWindow","useHubs","useHubAssets","HubAssetsQuery","useHubSummaryHistory","HubSummaryHistoryQuery","useHubsAction","options","hubs","useChain","ChainQuery","useChainAction","fetchChain","useChains","ChainsFilter","ChainsQuery","useExchangeRateAction","exchangeRate","useExchangeRate","ExchangeRateQuery","useAsset","AssetQuery","useAssetPriceHistory","AssetPriceHistoryQuery","useAssetSupplyHistory","AssetSupplyHistoryQuery","useAssetBorrowHistory","AssetBorrowHistoryQuery","useProtocolHistory","ProtocolHistoryQuery","useReserve","useReserveAction","useReserves","useReservesAction","reserves","useBorrowApyHistory","BorrowApyHistoryQuery","useSupplyApyHistory","SupplyApyHistoryQuery","useUserClaimableRewards","UserClaimableRewardsQuery","useUserClaimableRewardsAction","userClaimableRewards","useSpoke","useSpokes","useSpokePositionManagers","useSpokeUserPositionManagers","SpokeUserPositionManagersQuery","extractPositionSwapQuote","err","ValidationError","isTerminalSwapStatus","processApprovals","acc","approval","swapPosition","intent","swap","plan","useBorrowSwap","borrowSwapQuote","preparePositionSwap","order","signature","injectBorrowSwapQuoteAccuracy","accuracy","useBorrowSwapQuote","fastResult","BorrowSwapQuoteQuery","QuoteAccuracy","accurateResult","useBorrowSwapQuoteAction","toSwapCancelledResult","cancelled","CannotCancelSwapError","ResultAwareError","useCancelSwap","swapStatus","status","prepareSwapCancel","cancelSwap","pendingTransaction","useRepayWithSupply","repayWithSupplyQuote","injectRepayWithSupplyQuoteAccuracy","useRepayWithSupplyQuote","RepayWithSupplyQuoteQuery","useRepayWithSupplyQuoteAction","useSupplySwap","supplySwapQuote","injectSupplySwapQuoteAccuracy","useSupplySwapQuote","SupplySwapQuoteQuery","useSupplySwapQuoteAction","useSwappableTokens","SwappableTokensQuery","useSwapStatus","isTerminal","setIsTerminal","SwapStatusQuery","useTokenSwap","executeSwap","tokenSwapQuote","quoteResult","prepareTokenSwap","supportsPermit","chain","never","extractTokenSwapQuote","injectTokenSwapQuoteAccuracy","useTokenSwapQuote","TokenSwapQuoteQuery","useTokenSwapQuoteAction","findNewlyFulfilledSwaps","items","prevItems","prevTypenames","useUserSwaps","allTerminal","setAllTerminal","UserSwapsQuery","useDeferredValue","useWithdrawSwap","withdrawSwapQuote","injectWithdrawSwapQuoteAccuracy","useWithdrawSwapQuote","WithdrawSwapQuoteQuery","useWithdrawSwapQuoteAction","useActivities","ActivitiesQuery","useActivitiesAction","activities","useBorrow","borrow","pending","errAsync","useClaimRewards","claimRewards","transaction","transactionReceipt","toPermitSignature","permitTypedData","sendApprovalTransactions","handleSingleApproval","onPermit","expectTypename","injectLiquidatePermitSignature","_permitSig","useLiquidatePosition","liquidatePosition","permitSig","usePreviewAction","preview","usePreview","PreviewQuery","useRenounceSpokeUserPositionManager","renounceSpokeUserPositionManager","injectRepayPermitSignature","useRepay","repay","useSetSpokeUserPositionManager","setSpokeUserPositionManager","useSetUserSuppliesAsCollateral","reserveIds","change","reserveDetails","reserveId","setUserSuppliesAsCollateral","injectSupplyPermitSignature","useSupply","supply","useUpdateUserPositionConditions","updateUserPositionConditions","useWithdraw","withdraw","useUserSupplies","useUserSuppliesAction","userSupplies","useUserBorrows","useUserBorrowsAction","userBorrows","useUserSummary","useUserPositions","useUserPositionsAction","userPositions","useUserPosition","useUserBalances","useUserRiskPremiumBreakdown","UserRiskPremiumBreakdownQuery","useUserBalancesAction","userBalances","useUserSummaryHistory","UserSummaryHistoryQuery"],"mappings":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CAAAC,CAAAA,CAAQ,KAAA,CACR,QAAA,CAAA4C,CAAAA,CAAWC,4BAAAA,CAAsB,SACjC,GAAG3D,CACL,EAGiE,CAC/D,OAAOW,EAAoB,CACzB,QAAA,CAAUiP,+BAAAA,CACV,SAAA,CAAW,CACT,OAAA,CAAA5P,EACA,QAAA,CAAA0D,CACF,EACA,QAAA,CAAA7C,CAAAA,CACA,MAAAC,CAAAA,CACA,KAAA,CAAO,KACT,CAAC,CACH","file":"index.cjs","sourcesContent":["import type { AaveClient } from '@aave/client';\nimport { invariant } from '@aave/types';\nimport React, { type ReactNode, useContext } from 'react';\nimport { Provider as UrqlProvider } from 'urql';\n\nconst AaveContext = React.createContext<AaveClient | null>(null);\n\n/**\n * @internal\n */\nexport type AaveContextProviderProps = {\n children: ReactNode;\n client: AaveClient;\n};\n\n/**\n * @internal\n */\nexport function AaveContextProvider({\n children,\n client,\n}: AaveContextProviderProps) {\n return (\n <AaveContext.Provider value={client}>\n <UrqlProvider value={client.urql}>{children}</UrqlProvider>\n </AaveContext.Provider>\n );\n}\n\n/**\n * @internal\n */\nexport function useAaveClient(): AaveClient {\n const client = useContext(AaveContext);\n\n invariant(\n client,\n 'Could not find Aave SDK context, ensure your code is wrapped in a <AaveProvider>',\n );\n\n return client;\n}\n","import type { AaveClient } from '@aave/client';\n// biome-ignore lint/correctness/noUnusedImports: intentional\nimport React, { type ReactNode } from 'react';\n\nimport { AaveContextProvider } from './context';\n\n/**\n * <AaveProvider> props\n */\nexport type AaveProviderProps = {\n /**\n * The children to render\n */\n children: ReactNode;\n /**\n * The Aave client instance to use\n */\n client: AaveClient;\n};\n\n/**\n * Manages the internal state of the Aave SDK.\n *\n * ```tsx\n * import { AaveProvider, AaveClient, production } from '@aave/react';\n *\n * const client = AaveClient.create({\n * environment: production,\n * });\n *\n * function App() {\n * return (\n * <AaveProvider client={client}>\n * // ...\n * </AaveProvider>\n * );\n * }\n * ```\n */\nexport function AaveProvider({ children, client }: AaveProviderProps) {\n return <AaveContextProvider client={client}>{children}</AaveContextProvider>;\n}\n","import type { AaveClient } from '@aave/client';\nimport {\n type BorrowRequest,\n decodeReserveId,\n decodeUserPositionId,\n type Hub,\n HubQuery,\n HubsQuery,\n isChainIdsVariant,\n isSpokeInputVariant,\n type RepayRequest,\n type Reserve,\n type ReserveId,\n ReserveQuery,\n ReservesQuery,\n type Spoke,\n type SpokeId,\n type SpokeInput,\n SpokePositionManagersQuery,\n SpokeQuery,\n SpokesQuery,\n type SupplyRequest,\n UserBalancesQuery,\n UserBorrowsQuery,\n type UserBorrowsRequestQuery,\n type UserPosition,\n type UserPositionId,\n UserPositionQuery,\n UserPositionsQuery,\n UserSummaryQuery,\n UserSuppliesQuery,\n type UserSuppliesRequestQuery,\n type WithdrawRequest,\n} from '@aave/graphql';\nimport { type ChainId, type EvmAddress, ResultAsync } from '@aave/types';\n\nfunction extractUserSuppliesRequestUser(\n query: UserSuppliesRequestQuery,\n): EvmAddress {\n if ('userSpoke' in query) return query.userSpoke.user;\n if ('userToken' in query) return query.userToken.user;\n if ('userChains' in query) return query.userChains.user;\n if ('userHub' in query) return query.userHub.user;\n\n const { user } = decodeUserPositionId(query.userPositionId);\n return user;\n}\n\nfunction extractUserBorrowsRequestUser(\n query: UserBorrowsRequestQuery,\n): EvmAddress {\n if ('userSpoke' in query) return query.userSpoke.user;\n if ('userToken' in query) return query.userToken.user;\n if ('userChains' in query) return query.userChains.user;\n if ('userHub' in query) return query.userHub.user;\n\n const { user } = decodeUserPositionId(query.userPositionId);\n return user;\n}\n\n/**\n * @internal\n */\nexport function refreshUserBalances(client: AaveClient, user: EvmAddress) {\n return client.refreshQueryWhere(\n UserBalancesQuery,\n (variables) => variables.request.user === user,\n );\n}\n\n/**\n * @internal\n */\nexport function refreshUserSupplies(client: AaveClient, user: EvmAddress) {\n return client.refreshQueryWhere(\n UserSuppliesQuery,\n (variables) =>\n extractUserSuppliesRequestUser(variables.request.query) === user,\n );\n}\n\n/**\n * @internal\n */\nexport function refreshUserBorrows(client: AaveClient, user: EvmAddress) {\n return client.refreshQueryWhere(\n UserBorrowsQuery,\n (variables) =>\n extractUserBorrowsRequestUser(variables.request.query) === user,\n );\n}\n\n/**\n * @internal\n */\nexport function refreshUserPositions(\n client: AaveClient,\n user: EvmAddress,\n spoke: SpokeInput,\n) {\n const isMatch = (position: UserPosition) =>\n position.spoke.chain.chainId === spoke.chainId &&\n position.spoke.address === spoke.address &&\n position.user === user;\n\n return ResultAsync.combine([\n client.refreshQueryWhere(UserPositionsQuery, (_, data) =>\n data.some(isMatch),\n ),\n client.refreshQueryWhere(\n UserPositionQuery,\n (_, data) => data !== null && isMatch(data),\n ),\n ]);\n}\n\n/**\n * @internal\n */\nexport function refreshReserves(client: AaveClient, ids: ReserveId[]) {\n const isMatch = (reserve: Reserve) => ids.includes(reserve.id);\n\n return ResultAsync.combine([\n client.refreshQueryWhere(\n ReserveQuery,\n (_, data) => data !== null && isMatch(data),\n ),\n client.refreshQueryWhere(ReservesQuery, (_, data) => data.some(isMatch)),\n ]);\n}\n\n/**\n * @internal\n */\nexport function refreshUserSummary(\n client: AaveClient,\n user: EvmAddress,\n spoke: SpokeInput,\n) {\n return client.refreshQueryWhere(\n UserSummaryQuery,\n (variables) =>\n variables.request.user === user &&\n (isSpokeInputVariant(variables.request.filter)\n ? variables.request.filter.spoke.chainId === spoke.chainId &&\n variables.request.filter.spoke.address === spoke.address\n : isChainIdsVariant(variables.request.filter)\n ? variables.request.filter.chainIds.some((id) => id === spoke.chainId)\n : false),\n );\n}\n\n/**\n * @internal\n */\nexport function refreshSpokes(client: AaveClient, spoke: SpokeInput) {\n const isMatch = (item: Spoke) =>\n item.chain.chainId === spoke.chainId && item.address === spoke.address;\n\n return ResultAsync.combine([\n client.refreshQueryWhere(\n SpokeQuery,\n (_, data) => data !== null && isMatch(data),\n ),\n client.refreshQueryWhere(SpokesQuery, (_, data) => data.some(isMatch)),\n ]);\n}\n\n/**\n * @internal\n */\nexport function refreshHubs(client: AaveClient, chainId: ChainId) {\n const isMatch = (hub: Hub) => hub.chain.chainId === chainId;\n\n return ResultAsync.combine([\n client.refreshQueryWhere(\n HubQuery,\n (_, data) => data !== null && isMatch(data),\n ),\n client.refreshQueryWhere(HubsQuery, (_, data) => data.some(isMatch)),\n ]);\n}\n\n/**\n * @internal\n */\nexport function refreshSpokePositionManagers(\n client: AaveClient,\n spoke: SpokeId,\n) {\n return client.refreshQueryWhere(\n SpokePositionManagersQuery,\n (variables) => variables.request.spoke === spoke,\n );\n}\n\n/**\n * @internal\n */\nexport function refreshUserPositionById(\n client: AaveClient,\n userPositionId: UserPositionId,\n) {\n return ResultAsync.combine([\n client.refreshQueryWhere(UserPositionsQuery, (_, data) =>\n data.some((position) => position.id === userPositionId),\n ),\n client.refreshQueryWhere(\n UserPositionQuery,\n (_, data) => data?.id === userPositionId,\n ),\n ]);\n}\n\n/**\n * @internal\n */\nexport function refreshQueriesForReserveChange(\n client: AaveClient,\n request: SupplyRequest | BorrowRequest | RepayRequest | WithdrawRequest,\n) {\n const { chainId, spoke: address } = decodeReserveId(request.reserve);\n const spoke: SpokeInput = { chainId, address };\n return ResultAsync.combine([\n refreshUserPositions(client, request.sender, spoke),\n refreshUserSummary(client, request.sender, spoke),\n refreshReserves(client, [request.reserve]),\n refreshSpokes(client, spoke),\n refreshUserBalances(client, request.sender),\n refreshUserSupplies(client, request.sender),\n refreshUserBorrows(client, request.sender),\n refreshHubs(client, chainId),\n ]);\n}\n\n/**\n * @internal\n */\nexport function refreshAfterTokenSwap(client: AaveClient, user: EvmAddress) {\n return refreshUserBalances(client, user);\n}\n\n/**\n * @internal\n */\nexport function refreshAfterSupplySwap(client: AaveClient, user: EvmAddress) {\n return ResultAsync.combine([\n refreshUserSupplies(client, user),\n refreshUserBalances(client, user),\n ]);\n}\n\n/**\n * @internal\n */\nexport function refreshAfterBorrowSwap(client: AaveClient, user: EvmAddress) {\n return ResultAsync.combine([\n refreshUserBorrows(client, user),\n refreshUserBalances(client, user),\n ]);\n}\n\n/**\n * @internal\n */\nexport function refreshAfterRepayWithSupply(\n client: AaveClient,\n user: EvmAddress,\n) {\n return ResultAsync.combine([\n refreshUserSupplies(client, user),\n refreshUserBorrows(client, user),\n refreshUserBalances(client, user),\n ]);\n}\n\n/**\n * @internal\n */\nexport function refreshAfterWithdrawSwap(client: AaveClient, user: EvmAddress) {\n return ResultAsync.combine([\n refreshUserSupplies(client, user),\n refreshUserBalances(client, user),\n ]);\n}\n","import type { UnexpectedError } from '@aave/client';\n\n/**\n * A read hook result.\n *\n * It's a discriminated union of the possible results of a read operation:\n * - Rely on the `loading` value to determine if the `data` or `error` can be evaluated.\n * - If `error` is `undefined`, then `data` value will be available.\n */\nexport type ReadResult<T, E = UnexpectedError> =\n | {\n data: undefined;\n error: undefined;\n loading: true;\n reloading: false;\n }\n | {\n data: T;\n error: undefined;\n loading: false;\n reloading: boolean;\n }\n | {\n data: undefined;\n error: E;\n loading: false;\n reloading: boolean;\n };\n\n/**\n * A read hook result that supports pausing.\n */\nexport type PausableReadResult<T, E = UnexpectedError> =\n | {\n data: T | undefined;\n error: E | undefined;\n loading: false;\n paused: true;\n reloading: false;\n }\n | {\n data: undefined;\n error: undefined;\n loading: true;\n paused: false;\n reloading: false;\n }\n | {\n data: T;\n error: undefined;\n loading: false;\n paused: false;\n reloading: boolean;\n }\n | {\n data: undefined;\n error: E;\n loading: false;\n paused: false;\n reloading: boolean;\n };\n\n/**\n * @internal\n */\nexport const ReadResult = {\n Loading: <T, E = UnexpectedError>(): PausableReadResult<T, E> => ({\n data: undefined,\n error: undefined,\n loading: true,\n paused: false,\n reloading: false,\n }),\n Success: <T, E = UnexpectedError>(\n data: T,\n reloading = false,\n ): PausableReadResult<T, E> => ({\n data,\n error: undefined,\n loading: false,\n paused: false,\n reloading,\n }),\n Failure: <T, E = UnexpectedError>(\n error: E,\n reloading = false,\n ): PausableReadResult<T, E> => ({\n data: undefined,\n error,\n loading: false,\n paused: false,\n reloading,\n }),\n Paused: <T, E = UnexpectedError>(\n data: T | undefined,\n error: E | undefined,\n ): PausableReadResult<T, E> => ({\n data,\n error,\n loading: false,\n paused: true,\n reloading: false,\n }),\n};\n\n/**\n * A read hook result that supports React Suspense.\n */\nexport type SuspenseResult<T> = {\n data: T;\n};\n\n/**\n * A read hook result that supports React Suspense and can be paused.\n */\nexport type PausableSuspenseResult<T> =\n | {\n paused: true;\n data: undefined;\n }\n | {\n paused: false;\n data: T;\n };\n\nexport type SuspendableResult<T, E = UnexpectedError> =\n | ReadResult<T, E>\n | SuspenseResult<T>\n | PausableReadResult<T, E>\n | PausableSuspenseResult<T>;\n","import { type StandardData, UnexpectedError } from '@aave/client';\nimport {\n type AnyVariables,\n invariant,\n type NullishDeep,\n ok,\n type Prettify,\n type Result,\n} from '@aave/types';\nimport { useEffect, useMemo, useState } from 'react';\nimport { type TypedDocumentNode, useQuery } from 'urql';\nimport {\n type PausableReadResult,\n type PausableSuspenseResult,\n ReadResult,\n type SuspendableResult,\n type SuspenseResult,\n} from './results';\n\nexport type Selector<ResponseValue, SelectorData, SelectorError> = (\n data: ResponseValue,\n) => Result<SelectorData, SelectorError>;\n\nexport type Pausable<T, WhenPaused = NullishDeep<T>> = Prettify<\n WhenPaused & {\n /**\n * Prevents the hook from automatically executing GraphQL query operations.\n *\n * @experimental This is an experimental feature and may change in the future.\n *\n * @remarks\n * `pause` may be set to `true` to stop the query operation from executing\n * automatically. The hook will stop receiving updates and won't execute the query\n * operation until it's set to `false`.\n */\n pause: boolean;\n }\n>;\n\nexport type Suspendable = { suspense: true };\n\n/**\n * @internal\n */\nexport type UseSuspendableQueryArgs<\n ResponseValue,\n SelectorData,\n SelectorError,\n Variables extends AnyVariables,\n Suspense extends boolean,\n Pause extends boolean = never,\n> = {\n document: TypedDocumentNode<StandardData<ResponseValue>, Variables>;\n variables?: Pause extends boolean ? NullishDeep<Variables> : Variables;\n suspense: Suspense;\n selector?: Selector<ResponseValue, SelectorData, SelectorError>;\n pollInterval?: number;\n batch?: boolean;\n pause?: Pause;\n};\n\n/**\n * @internal\n */\nexport function useSuspendableQuery<\n ResponseValue,\n SelectorData,\n SelectorError,\n Variables extends AnyVariables,\n Pausable extends boolean = never,\n>({\n document,\n variables,\n suspense,\n pause,\n}: UseSuspendableQueryArgs<\n ResponseValue,\n SelectorData,\n SelectorError,\n Variables,\n false,\n Pausable\n>):\n | ReadResult<SelectorData, SelectorError | UnexpectedError>\n | PausableReadResult<SelectorData, SelectorError | UnexpectedError>;\n/**\n * @internal\n */\nexport function useSuspendableQuery<\n ResponseValue,\n SelectorData,\n SelectorError,\n Variables extends AnyVariables,\n Pausable extends boolean = never,\n>({\n document,\n variables,\n suspense,\n pause,\n}: UseSuspendableQueryArgs<\n ResponseValue,\n SelectorData,\n SelectorError,\n Variables,\n true,\n Pausable\n>): SuspenseResult<SelectorData> | PausableSuspenseResult<SelectorData>;\n/**\n * @internal\n */\nexport function useSuspendableQuery<\n ResponseValue,\n SelectorData,\n SelectorError,\n Variables extends AnyVariables,\n Pausable extends boolean = never,\n>({\n document,\n variables,\n suspense,\n pause,\n}: UseSuspendableQueryArgs<\n ResponseValue,\n SelectorData,\n SelectorError,\n Variables,\n boolean,\n Pausable\n>): SuspendableResult<SelectorData, SelectorError | UnexpectedError>;\n/**\n * Implementation.\n */\nexport function useSuspendableQuery<\n ResponseValue,\n SelectorData,\n SelectorError,\n Variables extends AnyVariables,\n>({\n document,\n variables,\n suspense,\n pause,\n selector = ok as Selector<ResponseValue, SelectorData, SelectorError>,\n pollInterval = 0,\n batch = true,\n}: UseSuspendableQueryArgs<\n ResponseValue,\n SelectorData,\n SelectorError,\n Variables,\n boolean,\n boolean\n>): SuspendableResult<SelectorData, SelectorError | UnexpectedError> {\n const [loading, setLoading] = useState(true);\n const [{ fetching, data, error, stale }, executeQuery] = useQuery({\n query: document,\n variables: variables as Variables,\n pause,\n context: useMemo(\n () => ({\n batch,\n suspense,\n }),\n [batch, suspense],\n ),\n });\n\n useEffect(() => {\n if (pause) return;\n\n if (!fetching) {\n setLoading(false);\n }\n }, [fetching, pause]);\n\n useEffect(() => {\n if (pollInterval <= 0 || fetching || pause) return undefined;\n\n const timerId = setTimeout(() => {\n executeQuery({\n requestPolicy: 'network-only',\n batch: false, // never batch, run now!\n });\n }, pollInterval);\n\n return () => clearTimeout(timerId);\n }, [fetching, executeQuery, pollInterval, pause]);\n\n if (pause) {\n const unexpectedError = error ? UnexpectedError.from(error) : undefined;\n\n if (!data) {\n return ReadResult.Paused<SelectorData, SelectorError | UnexpectedError>(\n undefined,\n unexpectedError,\n );\n }\n\n const selected = selector(data.value);\n\n if (selected.isErr()) {\n return ReadResult.Paused<SelectorData, SelectorError>(\n undefined,\n selected.error,\n );\n }\n\n return ReadResult.Paused<SelectorData, UnexpectedError>(\n selected.value,\n unexpectedError,\n );\n }\n\n if (!suspense && loading) {\n return ReadResult.Loading();\n }\n\n // stale indicates that the useQuery is fetching new data because the variables changed\n // !loading && fetching indicates that a re-fetch is happening as consequence of calling executeQuery (e.g., polling)\n const reloading = stale || (!loading && fetching);\n\n if (error) {\n const unexpected = UnexpectedError.from(error);\n if (suspense) {\n throw unexpected;\n }\n\n return ReadResult.Failure(unexpected, reloading);\n }\n\n invariant(data, 'No data returned');\n\n const selected = selector(data.value);\n\n if (selected.isErr()) {\n if (suspense) {\n throw selected.error;\n }\n return ReadResult.Failure(selected.error, reloading);\n }\n\n return ReadResult.Success(selected.value, reloading);\n}\n","import { invariant, type ResultAsync } from '@aave/types';\nimport {\n type DependencyList,\n useCallback,\n useEffect,\n useRef,\n useState,\n} from 'react';\n\n/**\n * An async task is a function that can be executed multiple times and that can be in a pending state.\n *\n * @internal\n */\nexport type AsyncTask<TInput, TResult extends ResultAsync<unknown, unknown>> = (\n input: TInput,\n) => TResult;\n\n/**\n * The initial state of a async task.\n */\nexport type AsyncTaskIdle = {\n called: boolean;\n loading: false;\n data: undefined;\n error: undefined;\n};\n\n/**\n * The state of a async task during the loading.\n */\nexport type AsyncTaskLoading<TData> = {\n called: true;\n loading: true;\n data: TData | undefined;\n error: undefined;\n};\n\n/**\n * The state of a async task after a successful call.\n */\nexport type AsyncTaskSuccess<TData> = {\n called: true;\n loading: false;\n data: TData;\n error: undefined;\n};\n\n/**\n * The state of a async task after a failed call.\n */\nexport type AsyncTaskError<TError> = {\n called: true;\n loading: false;\n data: undefined;\n error: TError;\n};\n\n/**\n * The possible statuses of a async task.\n */\nexport type AsyncTaskState<TData, TError> =\n | AsyncTaskIdle\n | AsyncTaskLoading<TData>\n | AsyncTaskSuccess<TData>\n | AsyncTaskError<TError>;\n\nconst AsyncTaskState = {\n Idle: <TData, TError>(): AsyncTaskState<TData, TError> => ({\n called: false,\n loading: false,\n data: undefined,\n error: undefined,\n }),\n Loading: <TData, TError>(data?: TData): AsyncTaskState<TData, TError> => ({\n called: true,\n loading: true,\n data,\n error: undefined,\n }),\n Success: <TData, TError>(data: TData): AsyncTaskState<TData, TError> => ({\n called: true,\n loading: false,\n data,\n error: undefined,\n }),\n Failed: <TData, TError>(error: TError): AsyncTaskState<TData, TError> => ({\n called: true,\n loading: false,\n data: undefined,\n error,\n }),\n};\n\n/**\n * A async task React Hook is a lightweight wrapper for an asynchronous function.\n * It allows tracking of the task's execution status and provides access to the\n * last error that occurred during the task's execution, if any.\n *\n * ```ts\n * const [execute, { called, loading, data, error }]: UseAsyncTask<TData, TError, TInput> = useAnyAsyncTask();\n *\n * if (!called) {\n * // data === undefined\n * // error === undefined\n * return <p>Click the button to execute the task</p>;\n * }\n *\n * if (loading) {\n * // data === undefined on first call\n * // data === TData from previous successful call\n * // error === undefined\n * return <Loader />;\n * }\n *\n * if (error) {\n * // data === undefined\n * // error === TError\n * return <p>Something went wrong: {error.message}</p>;\n * }\n *\n * // called === true\n * // data === TData\n * // error === undefined\n * return <p>Task completed: {data}</p>;\n * ```\n */\nexport type UseAsyncTask<TInput, TValue, TError> = [\n AsyncTask<TInput, ResultAsync<TValue, TError>>,\n AsyncTaskState<TValue, TError>,\n];\n\n/**\n * @internal\n */\nexport function useAsyncTask<\n TInput,\n TValue,\n TError,\n TResult extends ResultAsync<TValue, TError>,\n>(\n handler: AsyncTask<TInput, TResult>,\n deps: DependencyList,\n): UseAsyncTask<TInput, TValue, TError> {\n const [state, setState] = useState(AsyncTaskState.Idle<TValue, TError>());\n const loadingRef = useRef(false);\n const mountedRef = useRef(true);\n\n useEffect(() => {\n return () => {\n mountedRef.current = false;\n };\n }, []);\n\n // biome-ignore lint/correctness/useExhaustiveDependencies: useAsyncTask is a low-level hook\n const handle = useCallback(handler, deps);\n\n const execute = useCallback(\n (input: TInput) => {\n invariant(\n mountedRef.current,\n 'Cannot execute a task on an unmounted component.',\n );\n\n invariant(\n !loadingRef.current,\n 'Cannot execute a task while another is in progress.',\n );\n\n loadingRef.current = true;\n\n let previousState: AsyncTaskState<TValue, TError> | undefined;\n setState((state) => {\n previousState = state;\n return {\n called: true,\n loading: true,\n data: state.data,\n error: undefined,\n };\n });\n\n try {\n const result = handle(input);\n\n result.match(\n (value) => {\n loadingRef.current = false;\n setState(AsyncTaskState.Success(value));\n },\n (error) => {\n loadingRef.current = false;\n setState(AsyncTaskState.Failed(error));\n },\n );\n\n return result;\n } catch (error) {\n loadingRef.current = false;\n if (previousState) {\n setState(previousState);\n }\n throw error;\n }\n },\n [handle],\n );\n\n return [execute, state];\n}\n","import type { TransactionResult } from '@aave/client';\nimport {\n CancelError,\n type SigningError,\n type TimeoutError,\n type TransactionError,\n UnexpectedError,\n} from '@aave/core';\nimport type { TransactionRequest } from '@aave/graphql';\nimport type { ResultAsync, Signature } from '@aave/types';\nimport { isSignature, okAsync } from '@aave/types';\nimport type { UseAsyncTask } from './tasks';\n\n/**\n * The errors that could occur in the early stage of sending a transaction.\n */\nexport type SendTransactionError = CancelError | SigningError | UnexpectedError;\n\nexport type CancelOperation = (\n message: string,\n) => ResultAsync<never, CancelError>;\n\n/**\n * @internal\n */\nexport const cancel: CancelOperation = (message: string) =>\n CancelError.from(message).asResultAsync();\n\nexport type TransactionHandlerOptions = {\n cancel: CancelOperation;\n};\n\n/**\n * The errors that could occur in the late stages of a transaction.\n */\nexport type PendingTransactionError =\n | CancelError\n | TimeoutError\n | TransactionError\n | UnexpectedError;\n\nexport class PendingTransaction {\n constructor(\n /**\n * @internal Do NOT rely on this method. It's used internally by the SDK and may be subject to breaking changes.\n */\n public readonly wait: () => ResultAsync<\n TransactionResult,\n PendingTransactionError\n >,\n ) {}\n\n /**\n * @internal\n */\n static isInstanceOf(value: unknown): value is PendingTransaction {\n return value instanceof PendingTransaction;\n }\n\n /**\n * Narrows a value to PendingTransaction.\n * Only accepts types that include PendingTransaction in the union.\n *\n * @internal\n */\n static tryFrom<T>(\n value: PendingTransaction extends T ? T : never,\n ): ResultAsync<PendingTransaction, UnexpectedError> {\n if (PendingTransaction.isInstanceOf(value)) {\n return okAsync(value);\n }\n return UnexpectedError.from(value).asResultAsync();\n }\n}\n\nexport type UseSendTransactionResult = UseAsyncTask<\n TransactionRequest,\n PendingTransaction,\n SendTransactionError\n>;\n\n/**\n * The Aave execution plan handler\n */\nexport type ExecutionPlanHandler<\n T,\n R extends Signature | PendingTransaction,\n> = (\n plan: T,\n options: TransactionHandlerOptions,\n) => ResultAsync<R, SendTransactionError>;\n\n/**\n * Tries to create a Signature from an unknown value.\n *\n * @internal\n */\nexport function trySignatureFrom(\n value: unknown,\n): ResultAsync<Signature, UnexpectedError> {\n if (isSignature(value)) {\n return okAsync(value);\n }\n return UnexpectedError.from(\n `Expected Signature, but got ${String(value)}`,\n ).asResultAsync();\n}\n","import {\n type CurrencyQueryOptions,\n DEFAULT_QUERY_OPTIONS,\n type TimeWindowQueryOptions,\n type UnexpectedError,\n} from '@aave/client';\nimport { hubs } from '@aave/client/actions';\nimport {\n type Hub,\n type HubAsset,\n HubAssetsQuery,\n type HubAssetsRequest,\n HubQuery,\n type HubRequest,\n HubSummaryHistoryQuery,\n type HubSummaryHistoryRequest,\n type HubSummarySample,\n HubsQuery,\n type HubsRequest,\n} from '@aave/graphql';\nimport type { NullishDeep, Prettify } from '@aave/types';\nimport { useAaveClient } from './context';\nimport {\n type Pausable,\n type PausableReadResult,\n type PausableSuspenseResult,\n type ReadResult,\n type Suspendable,\n type SuspendableResult,\n type SuspenseResult,\n type UseAsyncTask,\n useAsyncTask,\n useSuspendableQuery,\n} from './helpers';\n\nexport type UseHubArgs = Prettify<\n HubRequest & CurrencyQueryOptions & TimeWindowQueryOptions\n>;\n\n/**\n * Fetch a specific hub by ID or by address and chain ID.\n *\n * This signature supports React Suspense:\n *\n * ```tsx\n * const { data } = useHub({\n * query: { hubId: hubId('SGVsbG8h') },\n * suspense: true,\n * });\n * // data will be Hub | null\n * ```\n */\nexport function useHub(\n args: UseHubArgs & Suspendable,\n): SuspenseResult<Hub | null>;\n/**\n * Fetch a specific hub by ID or by address and chain ID.\n *\n * Pausable suspense mode.\n *\n * ```tsx\n * const { data } = useHub({\n * query: { hubId: hubId('SGVsbG8h') },\n * suspense: true,\n * pause: true,\n * });\n * ```\n */\nexport function useHub(\n args: Pausable<UseHubArgs> & Suspendable,\n): PausableSuspenseResult<Hub | null>;\n/**\n * Fetch a specific hub by ID or by address and chain ID.\n *\n * ```tsx\n * const { data, error, loading } = useHub({\n * query: { hubId: hubId('SGVsbG8h') },\n * });\n * // data will be Hub | null\n * ```\n */\nexport function useHub(args: UseHubArgs): ReadResult<Hub | null>;\n/**\n * Fetch a specific hub by ID or by address and chain ID.\n *\n * Pausable loading state mode.\n *\n * ```tsx\n * const { data, error, loading, paused } = useHub({\n * query: { hubId: hubId('SGVsbG8h') },\n * pause: true,\n * });\n * ```\n */\nexport function useHub(\n args: Pausable<UseHubArgs>,\n): PausableReadResult<Hub | null>;\n\nexport function useHub({\n suspense = false,\n pause = false,\n currency = DEFAULT_QUERY_OPTIONS.currency,\n timeWindow = DEFAULT_QUERY_OPTIONS.timeWindow,\n ...request\n}: NullishDeep<UseHubArgs> & {\n suspense?: boolean;\n pause?: boolean;\n}): SuspendableResult<Hub | null, UnexpectedError> {\n return useSuspendableQuery({\n document: HubQuery,\n variables: {\n request,\n currency,\n timeWindow,\n },\n suspense,\n pause,\n });\n}\n\nexport type UseHubsArgs = Prettify<\n HubsRequest & CurrencyQueryOptions & TimeWindowQueryOptions\n>;\n\n/**\n * Fetch multiple hubs based on specified criteria.\n *\n * This signature supports React Suspense:\n *\n * ```tsx\n * const { data } = useHubs({\n * query: { chainIds: [chainId(1)] },\n * suspense: true,\n * });\n * ```\n */\nexport function useHubs(args: UseHubsArgs & Suspendable): SuspenseResult<Hub[]>;\n/**\n * Fetch multiple hubs based on specified criteria.\n *\n * Pausable suspense mode.\n *\n * ```tsx\n * const { data } = useHubs({\n * query: { chainIds: [chainId(1)] },\n * suspense: true,\n * pause: true,\n * });\n * ```\n */\nexport function useHubs(\n args: Pausable<UseHubsArgs> & Suspendable,\n): PausableSuspenseResult<Hub[]>;\n/**\n * Fetch multiple hubs based on specified criteria.\n *\n * ```tsx\n * const { data, error, loading } = useHubs({\n * query: { chainIds: [chainId(1)] },\n * });\n * ```\n */\nexport function useHubs(args: UseHubsArgs): ReadResult<Hub[]>;\n/**\n * Fetch multiple hubs based on specified criteria.\n *\n * Pausable loading state mode.\n *\n * ```tsx\n * const { data, error, loading, paused } = useHubs({\n * query: { chainIds: [chainId(1)] },\n * pause: true,\n * });\n * ```\n */\nexport function useHubs(args: Pausable<UseHubsArgs>): PausableReadResult<Hub[]>;\n\nexport function useHubs({\n suspense = false,\n pause = false,\n currency = DEFAULT_QUERY_OPTIONS.currency,\n timeWindow = DEFAULT_QUERY_OPTIONS.timeWindow,\n ...request\n}: NullishDeep<UseHubsArgs> & {\n suspense?: boolean;\n pause?: boolean;\n}): SuspendableResult<Hub[], UnexpectedError> {\n return useSuspendableQuery({\n document: HubsQuery,\n variables: {\n request,\n currency,\n timeWindow,\n },\n suspense,\n pause,\n });\n}\n\nexport type UseHubAssetsArgs = Prettify<\n HubAssetsRequest & CurrencyQueryOptions & TimeWindowQueryOptions\n>;\n\n/**\n * Fetch hub assets for a specific hub by ID or by address and chain ID.\n *\n * This signature supports React Suspense:\n *\n * ```tsx\n * const { data } = useHubAssets({\n * query: { hubId: hubId('SGVsbG8h') },\n * user: evmAddress('0x456...'), // optional\n * suspense: true,\n * });\n * ```\n */\nexport function useHubAssets(\n args: UseHubAssetsArgs & Suspendable,\n): SuspenseResult<HubAsset[]>;\n/**\n * Fetch hub assets for a specific hub by ID or by address and chain ID.\n *\n * Pausable suspense mode.\n *\n * ```tsx\n * const { data } = useHubAssets({\n * query: { hubId: hubId('SGVsbG8h') },\n * user: evmAddress('0x456...'), // optional\n * suspense: true,\n * pause: true,\n * });\n * ```\n */\nexport function useHubAssets(\n args: Pausable<UseHubAssetsArgs> & Suspendable,\n): PausableSuspenseResult<HubAsset[]>;\n/**\n * Fetch hub assets for a specific hub by ID or by address and chain ID.\n *\n * ```tsx\n * const { data, error, loading } = useHubAssets({\n * query: { hubId: hubId('SGVsbG8h') },\n * user: evmAddress('0x456...'), // optional\n * });\n * ```\n */\nexport function useHubAssets(args: UseHubAssetsArgs): ReadResult<HubAsset[]>;\n/**\n * Fetch hub assets for a specific hub by ID or by address and chain ID.\n *\n * Pausable loading state mode.\n *\n * ```tsx\n * const { data, error, loading, paused } = useHubAssets({\n * query: { hubId: hubId('SGVsbG8h') },\n * user: evmAddress('0x456...'), // optional\n * pause: true,\n * });\n * ```\n */\nexport function useHubAssets(\n args: Pausable<UseHubAssetsArgs>,\n): PausableReadResult<HubAsset[]>;\n\nexport function useHubAssets({\n suspense = false,\n pause = false,\n currency = DEFAULT_QUERY_OPTIONS.currency,\n timeWindow = DEFAULT_QUERY_OPTIONS.timeWindow,\n ...request\n}: NullishDeep<UseHubAssetsArgs> & {\n suspense?: boolean;\n pause?: boolean;\n}): SuspendableResult<HubAsset[], UnexpectedError> {\n return useSuspendableQuery({\n document: HubAssetsQuery,\n variables: {\n request,\n currency,\n timeWindow,\n },\n suspense,\n pause,\n });\n}\n\nexport type UseHubSummaryHistoryArgs = HubSummaryHistoryRequest;\n\n/**\n * Fetch historical summary data for a specific hub.\n *\n * This signature supports React Suspense:\n *\n * ```tsx\n * const { data } = useHubSummaryHistory({\n * query: { hubId: hubId('SGVsbG8h') },\n * currency: Currency.Usd,\n * window: TimeWindow.LastWeek,\n * suspense: true,\n * });\n * ```\n */\nexport function useHubSummaryHistory(\n args: UseHubSummaryHistoryArgs & Suspendable,\n): SuspenseResult<HubSummarySample[]>;\n/**\n * Fetch historical summary data for a specific hub.\n *\n * Pausable suspense mode.\n *\n * ```tsx\n * const { data } = useHubSummaryHistory({\n * query: { hubId: hubId('SGVsbG8h') },\n * suspense: true,\n * pause: true,\n * });\n * ```\n */\nexport function useHubSummaryHistory(\n args: Pausable<UseHubSummaryHistoryArgs> & Suspendable,\n): PausableSuspenseResult<HubSummarySample[]>;\n/**\n * Fetch historical summary data for a specific hub.\n *\n * ```tsx\n * const { data, error, loading } = useHubSummaryHistory({\n * query: { hubId: hubId('SGVsbG8h') },\n * currency: Currency.Usd,\n * window: TimeWindow.LastWeek,\n * });\n * ```\n */\nexport function useHubSummaryHistory(\n args: UseHubSummaryHistoryArgs,\n): ReadResult<HubSummarySample[]>;\n/**\n * Fetch historical summary data for a specific hub.\n *\n * Pausable loading state mode.\n *\n * ```tsx\n * const { data, error, loading, paused } = useHubSummaryHistory({\n * query: { hubId: hubId('SGVsbG8h') },\n * pause: true,\n * });\n * ```\n */\nexport function useHubSummaryHistory(\n args: Pausable<UseHubSummaryHistoryArgs>,\n): PausableReadResult<HubSummarySample[]>;\n\nexport function useHubSummaryHistory({\n suspense = false,\n pause = false,\n ...request\n}: NullishDeep<UseHubSummaryHistoryArgs> & {\n suspense?: boolean;\n pause?: boolean;\n}): SuspendableResult<HubSummarySample[], UnexpectedError> {\n return useSuspendableQuery({\n document: HubSummaryHistoryQuery,\n variables: {\n request,\n },\n suspense,\n pause,\n batch: false, // Do not batch this since it's a slower than average query\n });\n}\n\n/**\n * Low-level hook to execute a {@link hubs} action directly.\n *\n * @experimental This hook is experimental and may be subject to breaking changes.\n * @remarks\n * This hook **does not** actively watch for updated data on the hubs.\n * Use this hook to retrieve data on demand as part of a larger workflow\n * (e.g., in an event handler in order to move to the next step).\n *\n * ```ts\n * const [execute, { called, data, error, loading }] = useHubsAction();\n *\n * // …\n *\n * const result = await execute({\n * query: {\n * chainIds: [chainId(1)]\n * }\n * });\n *\n * if (result.isOk()) {\n * console.log(result.value); // Hub[]\n * } else {\n * console.error(result.error);\n * }\n * ```\n */\nexport function useHubsAction(\n options: Required<CurrencyQueryOptions> = DEFAULT_QUERY_OPTIONS,\n): UseAsyncTask<HubsRequest, Hub[], UnexpectedError> {\n const client = useAaveClient();\n\n return useAsyncTask(\n (request: HubsRequest) =>\n hubs(client, request, {\n currency: options.currency,\n requestPolicy: 'cache-first',\n }),\n [client, options.currency],\n );\n}\n","import type { CurrencyQueryOptions } from '@aave/client';\nimport { exchangeRate, chain as fetchChain } from '@aave/client/actions';\nimport type { UnexpectedError } from '@aave/core';\nimport type { Chain, ExchangeAmount, ExchangeRateRequest } from '@aave/graphql';\nimport {\n type ActivityItem,\n ChainQuery,\n type ChainRequest,\n ChainsFilter,\n ChainsQuery,\n type ChainsRequest,\n ExchangeRateQuery,\n type NativeAmount,\n type PreviewAction,\n} from '@aave/graphql';\nimport type { NullishDeep, Prettify } from '@aave/types';\nimport { useAaveClient } from './context';\nimport {\n type Pausable,\n type PausableReadResult,\n type PausableSuspenseResult,\n type ReadResult,\n type Suspendable,\n type SuspendableResult,\n type SuspenseResult,\n useSuspendableQuery,\n} from './helpers';\nimport { type UseAsyncTask, useAsyncTask } from './helpers/tasks';\n\nexport type UseChainArgs = ChainRequest;\n\n/**\n * Fetch a specific chain by chain ID.\n *\n * This signature supports React Suspense:\n *\n * ```tsx\n * const { data } = useChain({\n * chainId: chainId(1),\n * suspense: true,\n * });\n * // data will be Chain | null\n * ```\n */\nexport function useChain(\n args: UseChainArgs & Suspendable,\n): SuspenseResult<Chain | null>;\n/**\n * Fetch a specific chain by chain ID.\n *\n * Pausable suspense mode.\n *\n * ```tsx\n * const { data } = useChain({\n * chainId: chainId(1),\n * suspense: true,\n * pause: true,\n * });\n * ```\n */\nexport function useChain(\n args: Pausable<UseChainArgs> & Suspendable,\n): PausableSuspenseResult<Chain | null>;\n/**\n * Fetch a specific chain by chain ID.\n *\n * ```tsx\n * const { data, error, loading } = useChain({\n * chainId: chainId(1),\n * });\n * // data will be Chain | null\n * ```\n */\nexport function useChain(args: UseChainArgs): ReadResult<Chain | null>;\n/**\n * Fetch a specific chain by chain ID.\n *\n * Pausable loading state mode.\n *\n * ```tsx\n * const { data, error, loading, paused } = useChain({\n * chainId: chainId(1),\n * pause: true,\n * });\n * ```\n */\nexport function useChain(\n args: Pausable<UseChainArgs>,\n): PausableReadResult<Chain | null>;\n\nexport function useChain({\n suspense = false,\n pause = false,\n ...request\n}: NullishDeep<UseChainArgs> & {\n suspense?: boolean;\n pause?: boolean;\n}): SuspendableResult<Chain | null, UnexpectedError> {\n return useSuspendableQuery({\n document: ChainQuery,\n variables: {\n request,\n },\n suspense,\n pause,\n });\n}\n\n/**\n * Low-level hook to execute a {@link chain} action directly.\n *\n * @experimental This hook is experimental and may be subject to breaking changes.\n * @remarks\n * This hook **does not** actively watch for updated data on the chain.\n * Use this hook to retrieve data on demand as part of a larger workflow\n * (e.g., in an event handler in order to move to the next step).\n *\n * ```ts\n * const [execute, { called, data, error, loading }] = useChainAction();\n *\n * // …\n *\n * const result = await execute({\n * chainId: chainId(1),\n * });\n *\n * if (result.isOk()) {\n * console.log(result.value); // Chain | null\n * } else {\n * console.error(result.error);\n * }\n * ```\n */\nexport function useChainAction(): UseAsyncTask<\n ChainRequest,\n Chain | null,\n UnexpectedError\n> {\n const client = useAaveClient();\n\n return useAsyncTask(\n (request: ChainRequest) =>\n fetchChain(client, request, {\n batch: false,\n requestPolicy: 'cache-first',\n }),\n [client],\n );\n}\n\nexport type UseChainsArgs = ChainsRequest;\n/**\n * Fetches the list of supported chains.\n *\n * This signature supports React Suspense:\n *\n * ```tsx\n * const { data } = useChains({\n * query: { filter: ChainsFilter.ALL },\n * suspense: true,\n * });\n * ```\n */\nexport function useChains(\n args: UseChainsArgs & Suspendable,\n): SuspenseResult<Chain[]>;\n/**\n * Fetches the list of supported chains.\n *\n * Pausable suspense mode.\n *\n * ```tsx\n * const { data } = useChains({\n * query: { filter: ChainsFilter.ALL },\n * suspense: true,\n * pause: true,\n * });\n * ```\n */\nexport function useChains(\n args: Pausable<UseChainsArgs> & Suspendable,\n): PausableSuspenseResult<Chain[]>;\n/**\n * Fetches the list of supported chains.\n *\n * ```tsx\n * const { data, error, loading } = useChains({\n * query: { filter: ChainsFilter.ALL },\n * });\n * ```\n */\nexport function useChains(args?: UseChainsArgs): ReadResult<Chain[]>;\n/**\n * Fetches the list of supported chains.\n *\n * Pausable loading state mode.\n *\n * ```tsx\n * const { data, error, loading, paused } = useChains({\n * query: { filter: ChainsFilter.ALL },\n * pause: true,\n * });\n * ```\n */\nexport function useChains(\n args?: Pausable<UseChainsArgs>,\n): PausableReadResult<Chain[]>;\n\nexport function useChains(\n {\n suspense = false,\n pause = false,\n ...request\n }: NullishDeep<UseChainsArgs> & {\n suspense?: boolean;\n pause?: boolean;\n } = { query: { filter: ChainsFilter.ALL } },\n): SuspendableResult<Chain[], UnexpectedError> {\n return useSuspendableQuery({\n document: ChainsQuery,\n variables: { request },\n suspense,\n pause,\n });\n}\n\n/**\n * Fetches exchange rates between tokens and fiat currencies.\n *\n * ```tsx\n * const [getExchangeRate, gettingRate] = useExchangeRateAction();\n *\n * const loading = gettingRate.loading;\n * const error = gettingRate.error;\n *\n * // …\n *\n * const result = await getExchangeRate({\n * from: { erc20: { chainId: chainId(1), address: evmAddress('0xA0b86a33E6...') } },\n * to: Currency.Usd,\n * });\n *\n * if (result.isErr()) {\n * console.error(result.error);\n * return;\n * }\n *\n * console.log('Exchange rate:', result.value);\n * ```\n */\nexport function useExchangeRateAction(): UseAsyncTask<\n ExchangeRateRequest,\n ExchangeAmount,\n UnexpectedError\n> {\n const client = useAaveClient();\n\n return useAsyncTask(\n (request: ExchangeRateRequest) =>\n exchangeRate(client, request, { requestPolicy: 'network-only' }),\n [client],\n );\n}\n\nexport type UseExchangeRateArgs = ExchangeRateRequest;\n\n/**\n * Fetches exchange rates between tokens and fiat currencies with automatic polling.\n *\n * This signature supports React Suspense:\n *\n * ```tsx\n * const { data } = useExchangeRate({\n * from: {\n * erc20: {\n * chainId: chainId(1),\n * address: evmAddress('0xA0b86a33E6...')\n * }\n * },\n * to: Currency.Usd,\n * suspense: true,\n * });\n * ```\n */\nexport function useExchangeRate(\n args: UseExchangeRateArgs & Suspendable,\n): SuspenseResult<ExchangeAmount>;\n/**\n * Fetches exchange rates between tokens and fiat currencies with automatic polling.\n *\n * Pausable suspense mode.\n *\n * ```tsx\n * const { data } = useExchangeRate({\n * from: {\n * erc20: {\n * chainId: chainId(1),\n * address: evmAddress('0xA0b86a33E6...')\n * }\n * },\n * to: Currency.Usd,\n * suspense: true,\n * pause: true,\n * });\n * ```\n */\nexport function useExchangeRate(\n args: Pausable<UseExchangeRateArgs> & Suspendable,\n): PausableSuspenseResult<ExchangeAmount>;\n/**\n * Fetches exchange rates between tokens and fiat currencies with automatic polling.\n *\n * ```tsx\n * const { data, error, loading } = useExchangeRate({\n * from: {\n * erc20: {\n * chainId: chainId(1),\n * address: evmAddress('0xA0b86a33E6...')\n * }\n * },\n * to: Currency.Usd,\n * });\n *\n * <Component value={somewhere} fxRate={data} />\n * ```\n */\nexport function useExchangeRate(\n args: UseExchangeRateArgs,\n): ReadResult<ExchangeAmount>;\n/**\n * Fetches exchange rates between tokens and fiat currencies with automatic polling.\n *\n * Pausable loading state mode.\n *\n * ```tsx\n * const { data, error, loading, paused } = useExchangeRate({\n * from: {\n * erc20: {\n * chainId: chainId(1),\n * address: evmAddress('0xA0b86a33E6...')\n * }\n * },\n * to: Currency.Usd,\n * pause: true,\n * });\n * ```\n */\nexport function useExchangeRate(\n args: Pausable<UseExchangeRateArgs>,\n): PausableReadResult<ExchangeAmount>;\n\nexport function useExchangeRate({\n suspense = false,\n pause = false,\n ...request\n}: NullishDeep<UseExchangeRateArgs> & {\n suspense?: boolean;\n pause?: boolean;\n}): SuspendableResult<ExchangeAmount, UnexpectedError> {\n const client = useAaveClient();\n\n return useSuspendableQuery({\n document: ExchangeRateQuery,\n variables: { request },\n suspense,\n pause,\n pollInterval: request.at\n ? 0\n : client.context.environment.exchangeRateInterval,\n });\n}\n\nexport type UseNetworkFeeRequestQuery =\n | {\n activity: ActivityItem;\n }\n | {\n estimate: PreviewAction;\n };\n\nexport type UseNetworkFeeArgs = Prettify<\n {\n query: UseNetworkFeeRequestQuery;\n } & CurrencyQueryOptions\n>;\n\ntype PausableUseNetworkFeeArgs = Partial<\n {\n query: Partial<UseNetworkFeeRequestQuery>;\n } & CurrencyQueryOptions\n>;\n\n/**\n * Fetch the network fee for an ActivityItem.\n *\n * @experimental This hook is experimental and may be subject to breaking changes.\n */\nexport type UseNetworkFee<T extends NativeAmount = NativeAmount> =\n /**\n * Fetches the network fee for a past ActivityItem.\n *\n * This signature supports React Suspense:\n *\n * ```tsx\n * const { data } = useNetworkFee({\n * query: { activity },\n * suspense: true,\n * });\n *\n * data: NativeAmount\n * ```\n */\n ((args: UseNetworkFeeArgs & Suspendable) => SuspenseResult<T>) &\n /**\n * Fetches the network fee for a past ActivityItem.\n *\n * Pausable suspense mode.\n *\n * ```tsx\n * const { data, paused } = useNetworkFee({\n * query: { activity },\n * suspense: true,\n * pause: true,\n * });\n *\n * data: NativeAmount | undefined\n * ```\n */\n ((\n args: Pausable<UseNetworkFeeArgs, PausableUseNetworkFeeArgs> &\n Suspendable,\n ) => PausableSuspenseResult<T>) &\n /**\n * Fetches the network fee for a past ActivityItem.\n *\n * ```tsx\n * const { data, error, loading } = useNetworkFee({\n * query: { activity },\n * });\n * ```\n */\n ((args: UseNetworkFeeArgs) => ReadResult<T>) &\n /**\n * Fetches the network fee for a past ActivityItem.\n *\n * Pausable loading state mode.\n *\n * ```tsx\n * const { data, error, loading, paused } = useNetworkFee({\n * query: { activity },\n * pause: true,\n * });\n *\n * data: NativeAmount | undefined\n * ```\n */\n ((\n args: Pausable<UseNetworkFeeArgs, PausableUseNetworkFeeArgs>,\n ) => PausableReadResult<T>);\n","import {\n type CurrencyQueryOptions,\n DEFAULT_QUERY_OPTIONS,\n type TimeWindowQueryOptions,\n type UnexpectedError,\n} from '@aave/client';\nimport {\n type Asset,\n AssetBorrowHistoryQuery,\n type AssetBorrowHistoryRequest,\n type AssetBorrowSample,\n AssetPriceHistoryQuery,\n type AssetPriceHistoryRequest,\n type AssetPriceSample,\n AssetQuery,\n type AssetRequest,\n AssetSupplyHistoryQuery,\n type AssetSupplyHistoryRequest,\n type AssetSupplySample,\n ProtocolHistoryQuery,\n type ProtocolHistoryRequest,\n type ProtocolHistorySample,\n} from '@aave/graphql';\nimport type { NullishDeep, Prettify } from '@aave/types';\nimport {\n type Pausable,\n type PausableReadResult,\n type PausableSuspenseResult,\n type ReadResult,\n type Suspendable,\n type SuspendableResult,\n type SuspenseResult,\n useSuspendableQuery,\n} from './helpers';\n\nexport type UseAssetArgs = Prettify<\n AssetRequest & CurrencyQueryOptions & TimeWindowQueryOptions\n>;\n\n/**\n * Fetch information about a specific asset (ERC20 token) in the protocol by ID or by token.\n *\n * This signature supports React Suspense:\n *\n * ```tsx\n * const { data } = useAsset({\n * query: { assetId: assetId('SGVsbG8h') },\n * suspense: true,\n * });\n * // data will be Asset | null\n * ```\n */\nexport function useAsset(\n args: UseAssetArgs & Suspendable,\n): SuspenseResult<Asset | null>;\n/**\n * Fetch information about a specific asset (ERC20 token) in the protocol by ID or by token.\n *\n * Pausable suspense mode.\n *\n * ```tsx\n * const { data } = useAsset({\n * query: { assetId: assetId('SGVsbG8h') },\n * suspense: true,\n * pause: true,\n * });\n * ```\n */\nexport function useAsset(\n args: Pausable<UseAssetArgs> & Suspendable,\n): PausableSuspenseResult<Asset | null>;\n/**\n * Fetch information about a specific asset (ERC20 token) in the protocol by ID or by token.\n *\n * ```tsx\n * const { data, error, loading } = useAsset({\n * query: { assetId: assetId('SGVsbG8h') },\n * });\n * // data will be Asset | null\n * ```\n */\nexport function useAsset(args: UseAssetArgs): ReadResult<Asset | null>;\n/**\n * Fetch information about a specific asset (ERC20 token) in the protocol by ID or by token.\n *\n * Pausable loading state mode.\n *\n * ```tsx\n * const { data, error, loading, paused } = useAsset({\n * query: { assetId: assetId('SGVsbG8h') },\n * pause: true,\n * });\n * ```\n */\nexport function useAsset(\n args: Pausable<UseAssetArgs>,\n): PausableReadResult<Asset | null>;\n\nexport function useAsset({\n suspense = false,\n pause = false,\n currency = DEFAULT_QUERY_OPTIONS.currency,\n timeWindow = DEFAULT_QUERY_OPTIONS.timeWindow,\n ...request\n}: NullishDeep<UseAssetArgs> & {\n suspense?: boolean;\n pause?: boolean;\n}): SuspendableResult<Asset | null, UnexpectedError> {\n return useSuspendableQuery({\n document: AssetQuery,\n variables: {\n request,\n currency,\n timeWindow,\n },\n suspense,\n pause,\n });\n}\n\nexport type UseAssetPriceHistoryArgs = AssetPriceHistoryRequest;\n\n/**\n * Fetch historical price data for a specific asset.\n *\n * This signature supports React Suspense:\n *\n * ```tsx\n * const { data } = useAssetPriceHistory({\n * token: { chainId: chainId(1), address: evmAddress('0x123...') },\n * currency: Currency.Usd,\n * window: TimeWindow.LastWeek,\n * suspense: true,\n * });\n * ```\n */\nexport function useAssetPriceHistory(\n args: UseAssetPriceHistoryArgs & Suspendable,\n): SuspenseResult<AssetPriceSample[]>;\n/**\n * Fetch historical price data for a specific asset.\n *\n * Pausable suspense mode.\n *\n * ```tsx\n * const { data } = useAssetPriceHistory({\n * token: { chainId: chainId(1), address: evmAddress('0x123...') },\n * suspense: true,\n * pause: true,\n * });\n * ```\n */\nexport function useAssetPriceHistory(\n args: Pausable<UseAssetPriceHistoryArgs> & Suspendable,\n): PausableSuspenseResult<AssetPriceSample[]>;\n/**\n * Fetch historical price data for a specific asset.\n *\n * ```tsx\n * const { data, error, loading } = useAssetPriceHistory({\n * token: { chainId: chainId(1), address: evmAddress('0x123...') },\n * currency: Currency.Usd,\n * window: TimeWindow.LastWeek,\n * });\n * ```\n */\nexport function useAssetPriceHistory(\n args: UseAssetPriceHistoryArgs,\n): ReadResult<AssetPriceSample[]>;\n/**\n * Fetch historical price data for a specific asset.\n *\n * Pausable loading state mode.\n *\n * ```tsx\n * const { data, error, loading, paused } = useAssetPriceHistory({\n * token: { chainId: chainId(1), address: evmAddress('0x123...') },\n * pause: true,\n * });\n * ```\n */\nexport function useAssetPriceHistory(\n args: Pausable<UseAssetPriceHistoryArgs>,\n): PausableReadResult<AssetPriceSample[]>;\n\nexport function useAssetPriceHistory({\n suspense = false,\n pause = false,\n ...request\n}: NullishDeep<UseAssetPriceHistoryArgs> & {\n suspense?: boolean;\n pause?: boolean;\n}): SuspendableResult<AssetPriceSample[], UnexpectedError> {\n return useSuspendableQuery({\n document: AssetPriceHistoryQuery,\n variables: {\n request,\n },\n suspense,\n pause,\n batch: false, // Do not batch this since it's a slower than average query\n });\n}\n\nexport type UseAssetSupplyHistoryArgs = Prettify<\n AssetSupplyHistoryRequest & CurrencyQueryOptions & TimeWindowQueryOptions\n>;\n\n/**\n * Fetch historical supply data for a specific asset.\n *\n * This signature supports React Suspense:\n *\n * ```tsx\n * const { data } = useAssetSupplyHistory({\n * token: { chainId: chainId(1), address: evmAddress('0x123...') },\n * window: TimeWindow.LastWeek,\n * suspense: true,\n * });\n * ```\n */\nexport function useAssetSupplyHistory(\n args: UseAssetSupplyHistoryArgs & Suspendable,\n): SuspenseResult<AssetSupplySample[]>;\n/**\n * Fetch historical supply data for a specific asset.\n *\n * Pausable suspense mode.\n *\n * ```tsx\n * const { data } = useAssetSupplyHistory({\n * token: { chainId: chainId(1), address: evmAddress('0x123...') },\n * suspense: true,\n * pause: true,\n * });\n * ```\n */\nexport function useAssetSupplyHistory(\n args: Pausable<UseAssetSupplyHistoryArgs> & Suspendable,\n): PausableSuspenseResult<AssetSupplySample[]>;\n/**\n * Fetch historical supply data for a specific asset.\n *\n * ```tsx\n * const { data, error, loading } = useAssetSupplyHistory({\n * token: { chainId: chainId(1), address: evmAddress('0x123...') },\n * window: TimeWindow.LastWeek,\n * });\n * ```\n */\nexport function useAssetSupplyHistory(\n args: UseAssetSupplyHistoryArgs,\n): ReadResult<AssetSupplySample[]>;\n/**\n * Fetch historical supply data for a specific asset.\n *\n * Pausable loading state mode.\n *\n * ```tsx\n * const { data, error, loading, paused } = useAssetSupplyHistory({\n * token: { chainId: chainId(1), address: evmAddress('0x123...') },\n * pause: true,\n * });\n * ```\n */\nexport function useAssetSupplyHistory(\n args: Pausable<UseAssetSupplyHistoryArgs>,\n): PausableReadResult<AssetSupplySample[]>;\n\nexport function useAssetSupplyHistory({\n suspense = false,\n pause = false,\n currency = DEFAULT_QUERY_OPTIONS.currency,\n timeWindow = DEFAULT_QUERY_OPTIONS.timeWindow,\n ...request\n}: NullishDeep<UseAssetSupplyHistoryArgs> & {\n suspense?: boolean;\n pause?: boolean;\n}): SuspendableResult<AssetSupplySample[], UnexpectedError> {\n return useSuspendableQuery({\n document: AssetSupplyHistoryQuery,\n variables: {\n request,\n currency,\n timeWindow,\n },\n suspense,\n pause,\n batch: false, // Do not batch this since it's a slower than average query\n });\n}\n\nexport type UseAssetBorrowHistoryArgs = Prettify<\n AssetBorrowHistoryRequest & CurrencyQueryOptions & TimeWindowQueryOptions\n>;\n\n/**\n * Fetch historical borrow data for a specific asset.\n *\n * This signature supports React Suspense:\n *\n * ```tsx\n * const { data } = useAssetBorrowHistory({\n * token: { chainId: chainId(1), address: evmAddress('0x123...') },\n * window: TimeWindow.LastWeek,\n * suspense: true,\n * });\n * ```\n */\nexport function useAssetBorrowHistory(\n args: UseAssetBorrowHistoryArgs & Suspendable,\n): SuspenseResult<AssetBorrowSample[]>;\n/**\n * Fetch historical borrow data for a specific asset.\n *\n * Pausable suspense mode.\n *\n * ```tsx\n * const { data } = useAssetBorrowHistory({\n * token: { chainId: chainId(1), address: evmAddress('0x123...') },\n * suspense: true,\n * pause: true,\n * });\n * ```\n */\nexport function useAssetBorrowHistory(\n args: Pausable<UseAssetBorrowHistoryArgs> & Suspendable,\n): PausableSuspenseResult<AssetBorrowSample[]>;\n/**\n * Fetch historical borrow data for a specific asset.\n *\n * ```tsx\n * const { data, error, loading } = useAssetBorrowHistory({\n * token: { chainId: chainId(1), address: evmAddress('0x123...') },\n * window: TimeWindow.LastWeek,\n * });\n * ```\n */\nexport function useAssetBorrowHistory(\n args: UseAssetBorrowHistoryArgs,\n): ReadResult<AssetBorrowSample[]>;\n/**\n * Fetch historical borrow data for a specific asset.\n *\n * Pausable loading state mode.\n *\n * ```tsx\n * const { data, error, loading, paused } = useAssetBorrowHistory({\n * token: { chainId: chainId(1), address: evmAddress('0x123...') },\n * pause: true,\n * });\n * ```\n */\nexport function useAssetBorrowHistory(\n args: Pausable<UseAssetBorrowHistoryArgs>,\n): PausableReadResult<AssetBorrowSample[]>;\n\nexport function useAssetBorrowHistory({\n suspense = false,\n pause = false,\n currency = DEFAULT_QUERY_OPTIONS.currency,\n timeWindow = DEFAULT_QUERY_OPTIONS.timeWindow,\n ...request\n}: NullishDeep<UseAssetBorrowHistoryArgs> & {\n suspense?: boolean;\n pause?: boolean;\n}): SuspendableResult<AssetBorrowSample[], UnexpectedError> {\n return useSuspendableQuery({\n document: AssetBorrowHistoryQuery,\n variables: {\n request,\n currency,\n timeWindow,\n },\n suspense,\n pause,\n batch: false, // Do not batch this since it's a slower than average query\n });\n}\n\nexport type UseProtocolHistoryArgs = ProtocolHistoryRequest;\n\n/**\n * Fetch historical protocol-wide data (deposits, borrows, earnings).\n *\n * This signature supports React Suspense:\n *\n * ```tsx\n * const { data } = useProtocolHistory({\n * currency: Currency.Usd,\n * window: TimeWindow.LastWeek,\n * suspense: true,\n * });\n * ```\n */\nexport function useProtocolHistory(\n args: UseProtocolHistoryArgs & Suspendable,\n): SuspenseResult<ProtocolHistorySample[]>;\n/**\n * Fetch historical protocol-wide data (deposits, borrows, earnings).\n *\n * Pausable suspense mode.\n *\n * ```tsx\n * const { data } = useProtocolHistory({\n * currency: Currency.Usd,\n * window: TimeWindow.LastWeek,\n * suspense: true,\n * pause: true,\n * });\n * ```\n */\nexport function useProtocolHistory(\n args: Pausable<UseProtocolHistoryArgs> & Suspendable,\n): PausableSuspenseResult<ProtocolHistorySample[]>;\n/**\n * Fetch historical protocol-wide data (deposits, borrows, earnings).\n *\n * ```tsx\n * const { data, error, loading } = useProtocolHistory({\n * currency: Currency.Usd,\n * window: TimeWindow.LastWeek,\n * });\n * ```\n */\nexport function useProtocolHistory(\n args: UseProtocolHistoryArgs,\n): ReadResult<ProtocolHistorySample[]>;\n/**\n * Fetch historical protocol-wide data (deposits, borrows, earnings).\n *\n * Pausable loading state mode.\n *\n * ```tsx\n * const { data, error, loading, paused } = useProtocolHistory({\n * currency: Currency.Usd,\n * window: TimeWindow.LastWeek,\n * pause: true,\n * });\n * ```\n */\nexport function useProtocolHistory(\n args: Pausable<UseProtocolHistoryArgs>,\n): PausableReadResult<ProtocolHistorySample[]>;\n\nexport function useProtocolHistory({\n suspense = false,\n pause = false,\n ...request\n}: NullishDeep<UseProtocolHistoryArgs> & {\n suspense?: boolean;\n pause?: boolean;\n}): SuspendableResult<ProtocolHistorySample[], UnexpectedError> {\n return useSuspendableQuery({\n document: ProtocolHistoryQuery,\n variables: {\n request,\n },\n suspense,\n pause,\n batch: false, // Do not batch this since it's a slower than average query\n });\n}\n","import {\n type CurrencyQueryOptions,\n DEFAULT_QUERY_OPTIONS,\n type TimeWindowQueryOptions,\n type UnexpectedError,\n} from '@aave/client';\nimport { reserve, reserves } from '@aave/client/actions';\nimport {\n type ApySample,\n BorrowApyHistoryQuery,\n type BorrowApyHistoryRequest,\n type Reserve,\n ReserveQuery,\n type ReserveRequest,\n ReservesQuery,\n type ReservesRequest,\n SupplyApyHistoryQuery,\n type SupplyApyHistoryRequest,\n} from '@aave/graphql';\nimport type { NullishDeep, Prettify } from '@aave/types';\nimport { useAaveClient } from './context';\nimport {\n type Pausable,\n type PausableReadResult,\n type PausableSuspenseResult,\n type ReadResult,\n type Suspendable,\n type SuspendableResult,\n type SuspenseResult,\n type UseAsyncTask,\n useAsyncTask,\n useSuspendableQuery,\n} from './helpers';\n\nexport type UseReserveArgs = Prettify<\n ReserveRequest & CurrencyQueryOptions & TimeWindowQueryOptions\n>;\n\n/**\n * Fetch a specific reserve by reserve ID, spoke, and chain.\n *\n * This signature supports React Suspense:\n *\n * ```tsx\n * const { data } = useReserve({\n * reserve: reserveId('SGVsbG8h'),\n * user: evmAddress('0xabc...'),\n * suspense: true,\n * });\n * // data will be Reserve | null\n * ```\n */\nexport function useReserve(\n args: UseReserveArgs & Suspendable,\n): SuspenseResult<Reserve | null>;\n/**\n * Fetch a specific reserve by reserve ID, spoke, and chain.\n *\n * Pausable suspense mode.\n *\n * ```tsx\n * const { data } = useReserve({\n * reserve: reserveId('SGVsbG8h'),\n * suspense: true,\n * pause: true,\n * });\n * ```\n */\nexport function useReserve(\n args: Pausable<UseReserveArgs> & Suspendable,\n): PausableSuspenseResult<Reserve | null>;\n/**\n * Fetch a specific reserve by reserve ID, spoke, and chain.\n *\n * ```tsx\n * const { data, error, loading } = useReserve({\n * reserve: reserveId('SGVsbG8h'),\n * user: evmAddress('0xabc...'),\n * });\n * // data will be Reserve | null\n * ```\n */\nexport function useReserve(args: UseReserveArgs): ReadResult<Reserve | null>;\n/**\n * Fetch a specific reserve by reserve ID, spoke, and chain.\n *\n * Pausable loading state mode.\n *\n * ```tsx\n * const { data, error, loading, paused } = useReserve({\n * reserve: reserveId('SGVsbG8h'),\n * pause: true,\n * });\n * ```\n */\nexport function useReserve(\n args: Pausable<UseReserveArgs>,\n): PausableReadResult<Reserve | null>;\n\nexport function useReserve({\n suspense = false,\n pause = false,\n currency = DEFAULT_QUERY_OPTIONS.currency,\n timeWindow = DEFAULT_QUERY_OPTIONS.timeWindow,\n ...request\n}: NullishDeep<UseReserveArgs> & {\n suspense?: boolean;\n pause?: boolean;\n}): SuspendableResult<Reserve | null, UnexpectedError> {\n return useSuspendableQuery({\n document: ReserveQuery,\n variables: {\n request,\n currency,\n timeWindow,\n },\n suspense,\n pause,\n });\n}\n\n/**\n * Low-level hook to execute a {@link reserve} action directly.\n *\n * @experimental This hook is experimental and may be subject to breaking changes.\n * @remarks\n * This hook **does not** actively watch for updated data on the reserve.\n * Use this hook to retrieve data on demand as part of a larger workflow\n * (e.g., in an event handler in order to move to the next step).\n *\n * ```ts\n * const [execute, { called, data, error, loading }] = useReserveAction();\n *\n * // …\n *\n * const result = await execute({\n * reserve: reserveId('SGVsbG8h'),\n * });\n *\n * if (result.isOk()) {\n * console.log(result.value); // Reserve | null\n * } else {\n * console.error(result.error);\n * }\n * ```\n */\nexport function useReserveAction(\n options: CurrencyQueryOptions &\n TimeWindowQueryOptions = DEFAULT_QUERY_OPTIONS,\n): UseAsyncTask<ReserveRequest, Reserve | null, UnexpectedError> {\n const client = useAaveClient();\n\n return useAsyncTask(\n (request: ReserveRequest) =>\n reserve(client, request, {\n currency: options.currency ?? DEFAULT_QUERY_OPTIONS.currency,\n timeWindow: options.timeWindow ?? DEFAULT_QUERY_OPTIONS.timeWindow,\n requestPolicy: 'cache-first',\n }),\n [client, options.currency, options.timeWindow],\n );\n}\n\nexport type UseReservesArgs = Prettify<\n ReservesRequest & CurrencyQueryOptions & TimeWindowQueryOptions\n>;\n\n/**\n * Fetch reserves based on specified criteria.\n *\n * This signature supports React Suspense:\n *\n * ```tsx\n * const { data } = useReserves({\n * query: {\n * spoke: {\n * address: evmAddress('0x123...'),\n * chainId: chainId(1)\n * }\n * },\n * filter: ReservesRequestFilter.All,\n * orderBy: { name: 'ASC' },\n * suspense: true,\n * });\n * ```\n */\nexport function useReserves(\n args: UseReservesArgs & Suspendable,\n): SuspenseResult<Reserve[]>;\n/**\n * Fetch reserves based on specified criteria.\n *\n * Pausable suspense mode.\n *\n * ```tsx\n * const { data } = useReserves({\n * query: {\n * spoke: {\n * address: evmAddress('0x123...'),\n * chainId: chainId(1)\n * }\n * },\n * suspense: true,\n * pause: true,\n * });\n * ```\n */\nexport function useReserves(\n args: Pausable<UseReservesArgs> & Suspendable,\n): PausableSuspenseResult<Reserve[]>;\n/**\n * Fetch reserves based on specified criteria.\n *\n * ```tsx\n * const { data, error, loading } = useReserves({\n * query: {\n * spoke: {\n * address: evmAddress('0x123...'),\n * chainId: chainId(1)\n * }\n * },\n * filter: ReservesRequestFilter.All,\n * orderBy: { name: 'ASC' },\n * });\n * ```\n */\nexport function useReserves(\n args: UseReservesArgs,\n): ReadResult<Reserve[], UnexpectedError>;\n/**\n * Fetch reserves based on specified criteria.\n *\n * Pausable loading state mode.\n *\n * ```tsx\n * const { data, error, loading, paused } = useReserves({\n * query: {\n * spoke: {\n * address: evmAddress('0x123...'),\n * chainId: chainId(1)\n * }\n * },\n * pause: true,\n * });\n * ```\n */\nexport function useReserves(\n args: Pausable<UseReservesArgs>,\n): PausableReadResult<Reserve[], UnexpectedError>;\n\nexport function useReserves({\n suspense = false,\n pause = false,\n currency = DEFAULT_QUERY_OPTIONS.currency,\n timeWindow = DEFAULT_QUERY_OPTIONS.timeWindow,\n ...request\n}: NullishDeep<UseReservesArgs> & {\n suspense?: boolean;\n pause?: boolean;\n}): SuspendableResult<Reserve[], UnexpectedError> {\n return useSuspendableQuery({\n document: ReservesQuery,\n variables: {\n request,\n currency,\n timeWindow,\n },\n suspense,\n pause,\n });\n}\n\n/**\n * Low-level hook to execute a {@link reserves} action directly.\n *\n * @experimental This hook is experimental and may be subject to breaking changes.\n * @remarks\n * This hook **does not** actively watch for updated data on the reserves.\n * Use this hook to retrieve data on demand as part of a larger workflow\n * (e.g., in an event handler in order to move to the next step).\n *\n * ```ts\n * const [execute, { called, data, error, loading }] = useReservesAction();\n *\n * // …\n *\n * const result = await execute({\n * query: {\n * spoke: {\n * address: evmAddress('0x1234…'),\n * chainId: chainId(1)\n * }\n * }\n * });\n *\n * if (result.isOk()) {\n * console.log(result.value); // Reserve[]\n * } else {\n * console.error(result.error);\n * }\n * ```\n */\nexport function useReservesAction(\n options: CurrencyQueryOptions &\n TimeWindowQueryOptions = DEFAULT_QUERY_OPTIONS,\n): UseAsyncTask<ReservesRequest, Reserve[], UnexpectedError> {\n const client = useAaveClient();\n\n return useAsyncTask(\n (request: ReservesRequest) =>\n reserves(client, request, {\n currency: options.currency ?? DEFAULT_QUERY_OPTIONS.currency,\n timeWindow: options.timeWindow ?? DEFAULT_QUERY_OPTIONS.timeWindow,\n requestPolicy: 'cache-first',\n }),\n [client, options.currency, options.timeWindow],\n );\n}\n\nexport type UseBorrowApyHistoryArgs = BorrowApyHistoryRequest;\n\n/**\n * Fetch borrow APY history for a specific reserve over time.\n *\n * This signature supports React Suspense:\n *\n * ```tsx\n * const { data } = useBorrowApyHistory({\n * reserve: reserveId('SGVsbG8h'),\n * window: TimeWindow.LastWeek,\n * suspense: true,\n * });\n * ```\n */\nexport function useBorrowApyHistory(\n args: UseBorrowApyHistoryArgs & Suspendable,\n): SuspenseResult<ApySample[]>;\n/**\n * Fetch borrow APY history for a specific reserve over time.\n *\n * Pausable suspense mode.\n *\n * ```tsx\n * const { data } = useBorrowApyHistory({\n * reserve: reserveId('SGVsbG8h'),\n * window: TimeWindow.LastWeek,\n * suspense: true,\n * pause: true,\n * });\n * ```\n */\nexport function useBorrowApyHistory(\n args: Pausable<UseBorrowApyHistoryArgs> & Suspendable,\n): PausableSuspenseResult<ApySample[]>;\n/**\n * Fetch borrow APY history for a specific reserve over time.\n *\n * ```tsx\n * const { data, error, loading } = useBorrowApyHistory({\n * reserve: reserveId('SGVsbG8h'),\n * window: TimeWindow.LastWeek,\n * });\n * ```\n */\nexport function useBorrowApyHistory(\n args: UseBorrowApyHistoryArgs,\n): ReadResult<ApySample[]>;\n/**\n * Fetch borrow APY history for a specific reserve over time.\n *\n * Pausable loading state mode.\n *\n * ```tsx\n * const { data, error, loading, paused } = useBorrowApyHistory({\n * reserve: reserveId('SGVsbG8h'),\n * window: TimeWindow.LastWeek,\n * pause: true,\n * });\n * ```\n */\nexport function useBorrowApyHistory(\n args: Pausable<UseBorrowApyHistoryArgs>,\n): PausableReadResult<ApySample[]>;\n\nexport function useBorrowApyHistory({\n suspense = false,\n pause = false,\n ...request\n}: NullishDeep<UseBorrowApyHistoryArgs> & {\n suspense?: boolean;\n pause?: boolean;\n}): SuspendableResult<ApySample[], UnexpectedError> {\n return useSuspendableQuery({\n document: BorrowApyHistoryQuery,\n variables: {\n request,\n },\n suspense,\n pause,\n batch: false, // Do not batch this since it's a slower than average query\n });\n}\n\nexport type UseSupplyApyHistoryArgs = SupplyApyHistoryRequest;\n\n/**\n * Fetch supply APY history for a specific reserve over time.\n *\n * This signature supports React Suspense:\n *\n * ```tsx\n * const { data } = useSupplyApyHistory({\n * reserve: reserveId('SGVsbG8h'),\n * window: TimeWindow.LastWeek,\n * suspense: true,\n * });\n * ```\n */\nexport function useSupplyApyHistory(\n args: UseSupplyApyHistoryArgs & Suspendable,\n): SuspenseResult<ApySample[]>;\n/**\n * Fetch supply APY history for a specific reserve over time.\n *\n * Pausable suspense mode.\n *\n * ```tsx\n * const { data } = useSupplyApyHistory({\n * reserve: reserveId('SGVsbG8h'),\n * window: TimeWindow.LastWeek,\n * suspense: true,\n * pause: true,\n * });\n * ```\n */\nexport function useSupplyApyHistory(\n args: Pausable<UseSupplyApyHistoryArgs> & Suspendable,\n): PausableSuspenseResult<ApySample[]>;\n/**\n * Fetch supply APY history for a specific reserve over time.\n *\n * ```tsx\n * const { data, error, loading } = useSupplyApyHistory({\n * reserve: reserveId('SGVsbG8h'),\n * window: TimeWindow.LastWeek,\n * });\n * ```\n */\nexport function useSupplyApyHistory(\n args: UseSupplyApyHistoryArgs,\n): ReadResult<ApySample[]>;\n/**\n * Fetch supply APY history for a specific reserve over time.\n *\n * Pausable loading state mode.\n *\n * ```tsx\n * const { data, error, loading, paused } = useSupplyApyHistory({\n * reserve: reserveId('SGVsbG8h'),\n * window: TimeWindow.LastWeek,\n * pause: true,\n * });\n * ```\n */\nexport function useSupplyApyHistory(\n args: Pausable<UseSupplyApyHistoryArgs>,\n): PausableReadResult<ApySample[]>;\n\nexport function useSupplyApyHistory({\n suspense = false,\n pause = false,\n ...request\n}: NullishDeep<UseSupplyApyHistoryArgs> & {\n suspense?: boolean;\n pause?: boolean;\n}): SuspendableResult<ApySample[], UnexpectedError> {\n return useSuspendableQuery({\n document: SupplyApyHistoryQuery,\n variables: {\n request,\n },\n suspense,\n pause,\n batch: false, // Do not batch this since it's a slower than average query\n });\n}\n","import type { UnexpectedError } from '@aave/client';\nimport { userClaimableRewards } from '@aave/client/actions';\nimport {\n type UserClaimableReward,\n UserClaimableRewardsQuery,\n type UserClaimableRewardsRequest,\n} from '@aave/graphql';\nimport type { NullishDeep, Prettify } from '@aave/types';\nimport { useAaveClient } from './context';\nimport {\n type Pausable,\n type PausableReadResult,\n type PausableSuspenseResult,\n type ReadResult,\n type Suspendable,\n type SuspendableResult,\n type SuspenseResult,\n type UseAsyncTask,\n useAsyncTask,\n useSuspendableQuery,\n} from './helpers';\n\nexport type UseUserClaimableRewardsArgs = Prettify<UserClaimableRewardsRequest>;\n\n/**\n * Fetch all claimable rewards for a user.\n *\n * This signature supports React Suspense:\n *\n * ```tsx\n * const { data } = useUserClaimableRewards({\n * user: evmAddress('0x742d35cc…'),\n * suspense: true,\n * });\n * ```\n */\nexport function useUserClaimableRewards(\n args: UseUserClaimableRewardsArgs & Suspendable,\n): SuspenseResult<UserClaimableReward[]>;\n/**\n * Fetch all claimable rewards for a user.\n *\n * Pausable suspense mode.\n *\n * ```tsx\n * const { data } = useUserClaimableRewards({\n * user: evmAddress('0x742d35cc…'),\n * suspense: true,\n * pause: true,\n * });\n * ```\n */\nexport function useUserClaimableRewards(\n args: Pausable<UseUserClaimableRewardsArgs> & Suspendable,\n): PausableSuspenseResult<UserClaimableReward[]>;\n/**\n * Fetch all claimable rewards for a user.\n *\n * ```tsx\n * const { data, error, loading } = useUserClaimableRewards({\n * user: evmAddress('0x742d35cc…'),\n * });\n * ```\n */\nexport function useUserClaimableRewards(\n args: UseUserClaimableRewardsArgs,\n): ReadResult<UserClaimableReward[]>;\n/**\n * Fetch all claimable rewards for a user.\n *\n * Pausable loading state mode.\n *\n * ```tsx\n * const { data, error, loading, paused } = useUserClaimableRewards({\n * user: evmAddress('0x742d35cc…'),\n * pause: true,\n * });\n * ```\n */\nexport function useUserClaimableRewards(\n args: Pausable<UseUserClaimableRewardsArgs>,\n): PausableReadResult<UserClaimableReward[]>;\n\nexport function useUserClaimableRewards({\n suspense = false,\n pause = false,\n ...request\n}: NullishDeep<UseUserClaimableRewardsArgs> & {\n suspense?: boolean;\n pause?: boolean;\n}): SuspendableResult<UserClaimableReward[], UnexpectedError> {\n return useSuspendableQuery({\n document: UserClaimableRewardsQuery,\n variables: { request },\n suspense,\n pause,\n });\n}\n\n/**\n * Low-level hook to execute a {@link userClaimableRewards} action directly.\n *\n * @experimental This hook is experimental and may be subject to breaking changes.\n * @remarks\n * This hook **does not** actively watch for updated data on claimable rewards.\n * Use this hook to retrieve data on demand as part of a larger workflow\n * (e.g., in an event handler in order to move to the next step).\n *\n * ```ts\n * const [execute, { called, data, error, loading }] = useUserClaimableRewardsAction();\n *\n * // …\n *\n * const result = await execute({\n * user: evmAddress('0x742d35cc…'),\n * });\n *\n * if (result.isOk()) {\n * console.log(result.value); // UserClaimableReward[]\n * } else {\n * console.error(result.error);\n * }\n * ```\n */\nexport function useUserClaimableRewardsAction(): UseAsyncTask<\n UserClaimableRewardsRequest,\n UserClaimableReward[],\n UnexpectedError\n> {\n const client = useAaveClient();\n\n return useAsyncTask(\n (request: UserClaimableRewardsRequest) =>\n userClaimableRewards(client, request, {\n requestPolicy: 'cache-first',\n }),\n [client],\n );\n}\n","import type { UnexpectedError } from '@aave/client';\nimport {\n type PaginatedSpokePositionManagerResult,\n type PaginatedSpokeUserPositionManagerResult,\n type Spoke,\n SpokePositionManagersQuery,\n type SpokePositionManagersRequest,\n SpokeQuery,\n type SpokeRequest,\n SpokesQuery,\n type SpokesRequest,\n SpokeUserPositionManagersQuery,\n type SpokeUserPositionManagersRequest,\n} from '@aave/graphql';\nimport type { NullishDeep } from '@aave/types';\nimport {\n type Pausable,\n type PausableReadResult,\n type PausableSuspenseResult,\n type ReadResult,\n type Suspendable,\n type SuspendableResult,\n type SuspenseResult,\n useSuspendableQuery,\n} from './helpers';\n\nexport type UseSpokeArgs = SpokeRequest;\n\n/**\n * Fetch a specific spoke.\n *\n * This signature supports React Suspense:\n *\n * ```tsx\n * const { data } = useSpoke({\n * query: { spokeId: spokeId('SGVsbG8h') },\n * suspense: true,\n * });\n * // data will be Spoke | null\n * ```\n */\nexport function useSpoke(\n args: UseSpokeArgs & Suspendable,\n): SuspenseResult<Spoke | null>;\n/**\n * Fetch a specific spoke.\n *\n * Pausable suspense mode.\n *\n * ```tsx\n * const { data } = useSpoke({\n * query: { spokeId: spokeId('SGVsbG8h') },\n * suspense: true,\n * pause: true,\n * });\n * ```\n */\nexport function useSpoke(\n args: Pausable<UseSpokeArgs> & Suspendable,\n): PausableSuspenseResult<Spoke | null>;\n/**\n * Fetch a specific spoke.\n *\n * ```tsx\n * const { data, error, loading } = useSpoke({\n * query: { spokeId: spokeId('SGVsbG8h') },\n * });\n * // data will be Spoke | null\n * ```\n */\nexport function useSpoke(args: UseSpokeArgs): ReadResult<Spoke | null>;\n/**\n * Fetch a specific spoke.\n *\n * Pausable loading state mode.\n *\n * ```tsx\n * const { data, error, loading, paused } = useSpoke({\n * query: { spokeId: spokeId('SGVsbG8h') },\n * pause: true,\n * });\n * ```\n */\nexport function useSpoke(\n args: Pausable<UseSpokeArgs>,\n): PausableReadResult<Spoke | null>;\n\nexport function useSpoke({\n suspense = false,\n pause = false,\n ...request\n}: NullishDeep<UseSpokeArgs> & {\n suspense?: boolean;\n pause?: boolean;\n}): SuspendableResult<Spoke | null, UnexpectedError> {\n return useSuspendableQuery({\n document: SpokeQuery,\n variables: {\n request,\n },\n suspense,\n pause,\n });\n}\n\nexport type UseSpokesArgs = SpokesRequest;\n\n/**\n * Fetch spokes based on specified criteria.\n *\n * This signature supports React Suspense:\n *\n * ```tsx\n * const { data } = useSpokes({\n * query: { chainIds: [chainId(1)] },\n * suspense: true,\n * });\n * ```\n */\nexport function useSpokes(\n args: UseSpokesArgs & Suspendable,\n): SuspenseResult<Spoke[]>;\n/**\n * Fetch spokes based on specified criteria.\n *\n * Pausable suspense mode.\n *\n * ```tsx\n * const { data } = useSpokes({\n * query: { chainIds: [chainId(1)] },\n * suspense: true,\n * pause: true,\n * });\n * ```\n */\nexport function useSpokes(\n args: Pausable<UseSpokesArgs> & Suspendable,\n): PausableSuspenseResult<Spoke[]>;\n/**\n * Fetch spokes based on specified criteria.\n *\n * ```tsx\n * const { data, error, loading } = useSpokes({\n * query: { chainIds: [chainId(1)] },\n * });\n * ```\n */\nexport function useSpokes(args: UseSpokesArgs): ReadResult<Spoke[]>;\n/**\n * Fetch spokes based on specified criteria.\n *\n * Pausable loading state mode.\n *\n * ```tsx\n * const { data, error, loading, paused } = useSpokes({\n * query: { chainIds: [chainId(1)] },\n * pause: true,\n * });\n * ```\n */\nexport function useSpokes(\n args: Pausable<UseSpokesArgs>,\n): PausableReadResult<Spoke[]>;\n\nexport function useSpokes({\n suspense = false,\n pause = false,\n ...request\n}: NullishDeep<UseSpokesArgs> & {\n suspense?: boolean;\n pause?: boolean;\n}): SuspendableResult<Spoke[], UnexpectedError> {\n return useSuspendableQuery({\n document: SpokesQuery,\n variables: {\n request,\n },\n suspense,\n pause,\n });\n}\n\nexport type UseSpokePositionManagersArgs = SpokePositionManagersRequest;\n\n/**\n * Fetches all the positions manager for a specific spoke.\n *\n * This signature supports React Suspense:\n *\n * ```tsx\n * const { data } = useSpokePositionManagers({\n * spoke: spokeId('SGVsbG8h'),\n * suspense: true,\n * });\n * ```\n */\nexport function useSpokePositionManagers(\n args: UseSpokePositionManagersArgs & Suspendable,\n): SuspenseResult<PaginatedSpokePositionManagerResult>;\n/**\n * Fetches all the positions manager for a specific spoke.\n *\n * Pausable suspense mode.\n *\n * ```tsx\n * const { data } = useSpokePositionManagers({\n * spoke: spokeId('SGVsbG8h'),\n * suspense: true,\n * pause: true,\n * });\n * ```\n */\nexport function useSpokePositionManagers(\n args: Pausable<UseSpokePositionManagersArgs> & Suspendable,\n): PausableSuspenseResult<PaginatedSpokePositionManagerResult>;\n/**\n * Fetches all the positions manager for a specific spoke.\n *\n * ```tsx\n * const { data, error, loading } = useSpokePositionManagers({\n * spoke: spokeId('SGVsbG8h'),\n * });\n * ```\n */\nexport function useSpokePositionManagers(\n args: UseSpokePositionManagersArgs,\n): ReadResult<PaginatedSpokePositionManagerResult>;\n/**\n * Fetches all the positions manager for a specific spoke.\n *\n * Pausable loading state mode.\n *\n * ```tsx\n * const { data, error, loading, paused } = useSpokePositionManagers({\n * spoke: spokeId('SGVsbG8h'),\n * pause: true,\n * });\n * ```\n */\nexport function useSpokePositionManagers(\n args: Pausable<UseSpokePositionManagersArgs>,\n): PausableReadResult<PaginatedSpokePositionManagerResult>;\n\nexport function useSpokePositionManagers({\n suspense = false,\n pause = false,\n ...request\n}: NullishDeep<UseSpokePositionManagersArgs> & {\n suspense?: boolean;\n pause?: boolean;\n}): SuspendableResult<PaginatedSpokePositionManagerResult, UnexpectedError> {\n return useSuspendableQuery({\n document: SpokePositionManagersQuery,\n variables: {\n request,\n },\n suspense,\n pause,\n });\n}\n\nexport type UseSpokeUserPositionManagersArgs = SpokeUserPositionManagersRequest;\n\n/**\n * Fetches all the position managers of a user for a specific spoke\n *\n * This signature supports React Suspense:\n *\n * ```tsx\n * const { data } = useSpokeUserPositionManagers({\n * spoke: spokeId('SGVsbG8h'),\n * user: evmAddress('0x123...'),\n * suspense: true,\n * });\n * ```\n */\nexport function useSpokeUserPositionManagers(\n args: UseSpokeUserPositionManagersArgs & Suspendable,\n): SuspenseResult<PaginatedSpokeUserPositionManagerResult>;\n/**\n * Fetches all the position managers of a user for a specific spoke\n *\n * Pausable suspense mode.\n *\n * ```tsx\n * const { data } = useSpokeUserPositionManagers({\n * spoke: spokeId('SGVsbG8h'),\n * user: evmAddress('0x123...'),\n * suspense: true,\n * pause: true,\n * });\n * ```\n */\nexport function useSpokeUserPositionManagers(\n args: Pausable<UseSpokeUserPositionManagersArgs> & Suspendable,\n): PausableSuspenseResult<PaginatedSpokeUserPositionManagerResult>;\n/**\n * Fetches all the position managers of a user for a specific spoke\n *\n * ```tsx\n * const { data, error, loading } = useSpokeUserPositionManagers({\n * spoke: spokeId('SGVsbG8h'),\n * user: evmAddress('0x123...'),\n * });\n * ```\n */\nexport function useSpokeUserPositionManagers(\n args: UseSpokeUserPositionManagersArgs,\n): ReadResult<PaginatedSpokeUserPositionManagerResult>;\n/**\n * Fetches all the position managers of a user for a specific spoke\n *\n * Pausable loading state mode.\n *\n * ```tsx\n * const { data, error, loading, paused } = useSpokeUserPositionManagers({\n * spoke: spokeId('SGVsbG8h'),\n * user: evmAddress('0x123...'),\n * pause: true,\n * });\n * ```\n */\nexport function useSpokeUserPositionManagers(\n args: Pausable<UseSpokeUserPositionManagersArgs>,\n): PausableReadResult<PaginatedSpokeUserPositionManagerResult>;\n\nexport function useSpokeUserPositionManagers({\n suspense = false,\n pause = false,\n ...request\n}: NullishDeep<UseSpokeUserPositionManagersArgs> & {\n suspense?: boolean;\n pause?: boolean;\n}): SuspendableResult<\n PaginatedSpokeUserPositionManagerResult,\n UnexpectedError\n> {\n return useSuspendableQuery({\n document: SpokeUserPositionManagersQuery,\n variables: {\n request,\n },\n suspense,\n pause,\n });\n}\n","import {\n type AaveClient,\n type CurrencyQueryOptions,\n DEFAULT_QUERY_OPTIONS,\n} from '@aave/client';\nimport { swap } from '@aave/client/actions';\nimport {\n type CancelError,\n type SigningError,\n UnexpectedError,\n ValidationError,\n} from '@aave/core';\nimport type {\n InsufficientBalanceError,\n InsufficientLiquidityError,\n PositionSwapApproval,\n PositionSwapByIntentApprovalsRequired,\n PreparePositionSwapRequest,\n SwapByIntentInput,\n SwapQuote,\n SwapReceipt,\n SwapStatus,\n SwapTypedData,\n} from '@aave/graphql';\nimport type { Result, ResultAsync, Signature } from '@aave/types';\nimport { err, isSignature, ok, okAsync } from '@aave/types';\n\nimport {\n type CancelOperation,\n cancel,\n PendingTransaction,\n type PendingTransactionError,\n type SendTransactionError,\n trySignatureFrom,\n} from '../helpers';\nimport { type UseAsyncTask, useAsyncTask } from '../helpers/tasks';\n\nexport function extractPositionSwapQuote(\n data: PositionSwapByIntentApprovalsRequired | InsufficientLiquidityError,\n): Result<\n SwapQuote,\n ValidationError<InsufficientLiquidityError> | UnexpectedError\n> {\n switch (data.__typename) {\n case 'PositionSwapByIntentApprovalsRequired':\n return ok(data.quote);\n case 'InsufficientLiquidityError':\n return err(ValidationError.fromGqlNode(data));\n default:\n return err(\n UnexpectedError.upgradeRequired(\n `Unsupported position swap quote result: ${(data as { __typename: string }).__typename}`,\n ),\n );\n }\n}\n\nexport function isTerminalSwapStatus(data: SwapStatus): boolean {\n return (\n data.__typename === 'SwapFulfilled' ||\n data.__typename === 'SwapCancelled' ||\n data.__typename === 'SwapExpired'\n );\n}\n\n// ------------------------------------------------------------\n\nexport type SwapHandlerOptions = {\n cancel: CancelOperation;\n};\n\nexport type SwapSignerError = CancelError | SigningError | UnexpectedError;\n\n// ------------------------------------------------------------\n\nexport type PositionSwapPlan = PositionSwapApproval | SwapTypedData;\n\nexport type PositionSwapHandler = (\n plan: PositionSwapPlan,\n options: SwapHandlerOptions,\n) => ResultAsync<PendingTransaction | Signature, SwapSignerError>;\n\nexport type PositionSwapValue = {\n quote?: SwapQuote;\n};\n\nexport function processApprovals(\n result: PositionSwapByIntentApprovalsRequired,\n) {\n return {\n with: (\n handler: PositionSwapHandler,\n ): ResultAsync<PreparePositionSwapRequest, SwapSignerError> =>\n result.approvals.reduce<\n ResultAsync<PreparePositionSwapRequest, SwapSignerError>\n >(\n (acc, approval) =>\n acc.andThen((request) =>\n handler(approval, { cancel }).map((value) => {\n switch (approval.__typename) {\n case 'PositionSwapAdapterContractApproval':\n request.adapterContractSignature = isSignature(value)\n ? value\n : null;\n break;\n case 'PositionSwapPositionManagerApproval':\n request.positionManagerSignature = isSignature(value)\n ? value\n : null;\n break;\n }\n return request;\n }),\n ),\n okAsync({\n quoteId: result.quote.quoteId,\n adapterContractSignature: null,\n positionManagerSignature: null,\n }),\n ),\n };\n}\n\nexport function swapPosition(\n client: AaveClient,\n intent: SwapByIntentInput,\n): ResultAsync<\n SwapReceipt,\n ValidationError<InsufficientBalanceError> | UnexpectedError\n> {\n return swap(client, { intent }).andThen((plan) => {\n switch (plan.__typename) {\n case 'SwapReceipt':\n return okAsync(plan);\n default:\n return UnexpectedError.from(plan).asResultAsync();\n }\n });\n}\n\nexport {\n cancel,\n DEFAULT_QUERY_OPTIONS,\n isSignature,\n okAsync,\n PendingTransaction,\n trySignatureFrom,\n useAsyncTask,\n};\nexport type {\n CancelOperation,\n CurrencyQueryOptions,\n PendingTransactionError,\n SendTransactionError,\n UseAsyncTask,\n};\n","import { borrowSwapQuote, preparePositionSwap } from '@aave/client/actions';\nimport type { ValidationError } from '@aave/core';\nimport type {\n BorrowSwapQuoteRequest,\n InsufficientBalanceError,\n InsufficientLiquidityError,\n SwapReceipt,\n} from '@aave/graphql';\nimport type { Prettify } from '@aave/types';\n\nimport { useAaveClient } from '../context';\nimport type { PendingTransactionError, SendTransactionError } from '../helpers';\n\nimport {\n type CurrencyQueryOptions,\n cancel,\n DEFAULT_QUERY_OPTIONS,\n type PositionSwapHandler,\n processApprovals,\n type SwapSignerError,\n swapPosition,\n trySignatureFrom,\n type UseAsyncTask,\n useAsyncTask,\n} from './helpers';\n\nexport type UseBorrowSwapRequest = Prettify<\n BorrowSwapQuoteRequest & CurrencyQueryOptions\n>;\n\n/**\n * Orchestrate the borrow swap execution plan.\n *\n * ```tsx\n * const [signTypedData] = useSignTypedData(wallet);\n *\n * const [swapBorrow, { loading, error }] = useBorrowSwap((plan) => {\n * switch (plan.__typename) {\n * case 'PositionSwapAdapterContractApproval':\n * case 'PositionSwapPositionManagerApproval':\n * return signTypedData(plan.bySignature);\n *\n * case 'SwapTypedData':\n * return signTypedData(plan);\n * }\n * });\n *\n * const result = await swapBorrow({\n * market: {\n * debtPosition: userBorrowItem.id,\n * buyReserve: targetReserve.id,\n * amount: bigDecimal('1000'),\n * user: evmAddress('0x742d35cc…'),\n * },\n * });\n *\n * if (result.isErr()) {\n * console.error(result.error);\n * return;\n * }\n *\n * // result.value: SwapReceipt\n * ```\n */\nexport function useBorrowSwap(\n handler: PositionSwapHandler,\n): UseAsyncTask<\n BorrowSwapQuoteRequest,\n SwapReceipt,\n | SwapSignerError\n | SendTransactionError\n | PendingTransactionError\n | ValidationError<InsufficientBalanceError | InsufficientLiquidityError>\n> {\n const client = useAaveClient();\n\n return useAsyncTask(\n ({\n currency = DEFAULT_QUERY_OPTIONS.currency,\n ...request\n }: UseBorrowSwapRequest) => {\n return borrowSwapQuote(client, request, { currency }).andThen(\n (result) => {\n return processApprovals(result)\n .with(handler)\n .andThen((request) => preparePositionSwap(client, request))\n .andThen((order) =>\n handler(order.data, { cancel })\n .andThen(trySignatureFrom)\n .andThen((signature) =>\n swapPosition(client, {\n quoteId: order.newQuoteId,\n signature,\n }),\n ),\n );\n },\n );\n },\n [client, handler],\n );\n}\n","import { borrowSwapQuote } from '@aave/client/actions';\nimport type { UnexpectedError, ValidationError } from '@aave/core';\nimport type { InsufficientLiquidityError, SwapQuote } from '@aave/graphql';\nimport {\n BorrowSwapQuoteQuery,\n type BorrowSwapQuoteRequest,\n QuoteAccuracy,\n} from '@aave/graphql';\nimport type { NullishDeep, Prettify } from '@aave/types';\n\nimport { useAaveClient } from '../context';\nimport {\n type Pausable,\n type PausableReadResult,\n type PausableSuspenseResult,\n type ReadResult,\n type Suspendable,\n type SuspendableResult,\n type SuspenseResult,\n useSuspendableQuery,\n} from '../helpers';\nimport { type UseAsyncTask, useAsyncTask } from '../helpers/tasks';\n\nimport {\n type CurrencyQueryOptions,\n DEFAULT_QUERY_OPTIONS,\n extractPositionSwapQuote,\n} from './helpers';\n\nfunction injectBorrowSwapQuoteAccuracy(\n request: NullishDeep<BorrowSwapQuoteRequest>,\n accuracy: QuoteAccuracy,\n): NullishDeep<BorrowSwapQuoteRequest> {\n if ('market' in request && request.market) {\n return { market: { ...request.market, accuracy } };\n }\n return request;\n}\n\nexport type UseBorrowSwapQuoteArgs = Prettify<\n BorrowSwapQuoteRequest & CurrencyQueryOptions\n>;\n\n/**\n * Fetch a quote for a borrow swap operation with the specified parameters.\n *\n * This signature supports React Suspense:\n *\n * ```tsx\n * const { data } = useBorrowSwapQuote({\n * market: {\n * sellPosition: userBorrowItem.id,\n * buyReserve: reserve.id,\n * amount: bigDecimal('1000'),\n * user: evmAddress('0x742d35cc…'),\n * },\n * suspense: true,\n * });\n * ```\n */\nexport function useBorrowSwapQuote(\n args: UseBorrowSwapQuoteArgs & Suspendable,\n): SuspenseResult<SwapQuote>;\n/**\n * Fetch a quote for a borrow swap operation with the specified parameters.\n *\n * Pausable suspense mode.\n *\n * ```tsx\n * const { data } = useBorrowSwapQuote({\n * market: {\n * sellPosition: userBorrowItem.id,\n * buyReserve: reserve.id,\n * amount: bigDecimal('1000'),\n * user: evmAddress('0x742d35cc…'),\n * },\n * suspense: true,\n * pause: true,\n * });\n * ```\n */\nexport function useBorrowSwapQuote(\n args: Pausable<UseBorrowSwapQuoteArgs> & Suspendable,\n): PausableSuspenseResult<SwapQuote>;\n/**\n * Fetch a quote for a borrow swap operation with the specified parameters.\n *\n * ```tsx\n * const { data, error, loading } = useBorrowSwapQuote({\n * market: {\n * sellPosition: userBorrowItem.id,\n * buyReserve: reserve.id,\n * amount: bigDecimal('1000'),\n * user: evmAddress('0x742d35cc…'),\n * },\n * });\n * ```\n */\nexport function useBorrowSwapQuote(\n args: UseBorrowSwapQuoteArgs,\n): ReadResult<SwapQuote>;\n/**\n * Fetch a quote for a borrow swap operation with the specified parameters.\n *\n * Pausable loading state mode.\n *\n * ```tsx\n * const { data, error, loading, paused } = useBorrowSwapQuote({\n * market: {\n * sellPosition: userBorrowItem.id,\n * buyReserve: reserve.id,\n * amount: bigDecimal('1000'),\n * user: evmAddress('0x742d35cc…'),\n * },\n * pause: true,\n * });\n * ```\n */\nexport function useBorrowSwapQuote(\n args: Pausable<UseBorrowSwapQuoteArgs>,\n): PausableReadResult<SwapQuote>;\n\nexport function useBorrowSwapQuote({\n suspense = false,\n pause = false,\n currency = DEFAULT_QUERY_OPTIONS.currency,\n ...request\n}: NullishDeep<UseBorrowSwapQuoteArgs> & {\n suspense?: boolean;\n pause?: boolean;\n}): SuspendableResult<\n SwapQuote,\n UnexpectedError | ValidationError<InsufficientLiquidityError>\n> {\n const client = useAaveClient();\n\n // Fast query - no polling, suspends in suspense mode for quick initial render\n const fastResult = useSuspendableQuery({\n document: BorrowSwapQuoteQuery,\n variables: {\n request: injectBorrowSwapQuoteAccuracy(request, QuoteAccuracy.Fast),\n currency,\n },\n selector: extractPositionSwapQuote,\n suspense,\n pause,\n batch: false, // Don't batch with Accurate query\n });\n\n // Accurate query - with polling, never suspends, fires after Fast in suspense mode\n const accurateResult = useSuspendableQuery({\n document: BorrowSwapQuoteQuery,\n variables: {\n request: injectBorrowSwapQuoteAccuracy(request, QuoteAccuracy.Accurate),\n currency,\n },\n selector: extractPositionSwapQuote,\n suspense: false, // Never suspend on Accurate (would cause re-suspend)\n pause: pause || (suspense && !fastResult.data),\n pollInterval: client.context.environment.swapQuoteInterval,\n batch: false, // Don't batch with Fast query\n });\n\n if (accurateResult.data) {\n return accurateResult;\n }\n\n return fastResult;\n}\n\n/**\n * Low-level hook to execute a borrow swap quote action directly.\n *\n * @remarks\n * This hook **does not** actively watch for updated data on the swap quote.\n * Use this hook to retrieve quotes on demand as part of a larger workflow.\n *\n * ```ts\n * const [getQuote, { called, data, error, loading }] = useBorrowSwapQuoteAction();\n *\n * // …\n *\n * const result = await getQuote({\n * debtPosition: userBorrowItem.id,\n * buyReserve: reserve.id,\n * amount: bigDecimal('1000'),\n * user: evmAddress('0x742d35cc…'),\n * });\n *\n * if (result.isOk()) {\n * console.log('Borrow swap quote:', result.value);\n * } else {\n * console.error(result.error);\n * }\n * ```\n */\nexport function useBorrowSwapQuoteAction(\n options: Required<CurrencyQueryOptions> = DEFAULT_QUERY_OPTIONS,\n): UseAsyncTask<\n BorrowSwapQuoteRequest,\n SwapQuote,\n UnexpectedError | ValidationError<InsufficientLiquidityError>\n> {\n const client = useAaveClient();\n\n return useAsyncTask(\n (request: BorrowSwapQuoteRequest) =>\n borrowSwapQuote(client, request, {\n currency: options.currency,\n requestPolicy: 'network-only',\n }).andThen(extractPositionSwapQuote),\n [client, options.currency],\n );\n}\n","import {\n cancelSwap,\n prepareSwapCancel,\n swapStatus,\n} from '@aave/client/actions';\nimport {\n type CancelError,\n type SigningError,\n type TimeoutError,\n type TransactionError,\n UnexpectedError,\n} from '@aave/core';\nimport type {\n PrepareSwapCancelRequest,\n SwapCancelled,\n SwapCancelledResult,\n SwapTypedData,\n TransactionRequest,\n} from '@aave/graphql';\nimport type { ResultAsync, Signature } from '@aave/types';\nimport { ResultAwareError } from '@aave/types';\n\nimport { useAaveClient } from '../context';\n\nimport {\n cancel,\n okAsync,\n PendingTransaction,\n type SwapSignerError,\n trySignatureFrom,\n type UseAsyncTask,\n useAsyncTask,\n} from './helpers';\n\nfunction toSwapCancelledResult(cancelled: SwapCancelled): SwapCancelledResult {\n return {\n __typename: 'SwapCancelledResult',\n swapId: cancelled.swapId,\n createdAt: cancelled.createdAt,\n cancelledAt: cancelled.cancelledAt,\n explorerUrl: cancelled.explorerUrl,\n };\n}\n\nexport type CancelSwapHandler = (\n data: SwapTypedData | TransactionRequest,\n options: { cancel: typeof cancel },\n) => ResultAsync<PendingTransaction | Signature, SwapSignerError>;\n\nexport class CannotCancelSwapError extends ResultAwareError {\n name = 'CannotCancelSwapError' as const;\n}\n\nexport type CancelSwapError =\n | CancelError\n | CannotCancelSwapError\n | SigningError\n | TimeoutError\n | TransactionError\n | UnexpectedError;\n\n/**\n * Executes the complete swap cancellation workflow combining preparation and execution.\n *\n * ```tsx\n * const [sendTransaction] = useSendTransaction(wallet);\n * const [signTypedData] = useSignTypedData(wallet);\n *\n * const [cancelSwap, { loading, error }] = useCancelSwap((plan) => {\n * switch (plan.__typename) {\n * case 'TransactionRequest':\n * return sendTransaction(plan);\n *\n * case 'SwapTypedData':\n * return signTypedData(plan);\n * }\n * });\n *\n * const result = await cancelSwap({\n * id: swapId('123…'),\n * });\n *\n * if (result.isErr()) {\n * console.error(result.error);\n * return;\n * }\n *\n * // result.value: SwapCancelledResult\n * console.log('Swap cancelled:', result.value);\n * ```\n */\nexport function useCancelSwap(\n handler: CancelSwapHandler,\n): UseAsyncTask<\n PrepareSwapCancelRequest,\n SwapCancelledResult,\n CancelSwapError\n> {\n const client = useAaveClient();\n\n return useAsyncTask(\n (request) =>\n swapStatus(client, { id: request.id }).andThen((status) => {\n if (status === null) {\n return UnexpectedError.from('Swap not found').asResultAsync();\n }\n\n switch (status.__typename) {\n case 'SwapOpen':\n case 'SwapPendingSignature':\n return prepareSwapCancel(client, request)\n .andThen((result) => handler(result.data, { cancel }))\n .andThen(trySignatureFrom)\n .andThen((signature) =>\n cancelSwap(client, {\n intent: { id: request.id, signature },\n }),\n )\n .andThen((plan) => {\n if (plan.__typename === 'SwapCancelledResult') {\n return okAsync(plan);\n }\n\n return (\n handler(plan, { cancel })\n .andThen(PendingTransaction.tryFrom)\n .andThen((pendingTransaction) => pendingTransaction.wait())\n // TODO: verify that if fails cause too early, we need to waitForSwapOutcome(client)({ id: request.id })\n .andThen(() => swapStatus(client, { id: request.id }))\n .andThen((status) => {\n if (status?.__typename === 'SwapCancelled') {\n return okAsync(toSwapCancelledResult(status));\n }\n return new CannotCancelSwapError(\n 'Failed to cancel swap',\n ).asResultAsync();\n })\n );\n });\n\n case 'SwapCancelled':\n return okAsync(toSwapCancelledResult(status));\n\n case 'SwapExpired':\n return new CannotCancelSwapError(\n 'Swap cannot longer be cancelled',\n ).asResultAsync();\n\n default:\n return UnexpectedError.upgradeRequired(\n `Unsupported swap status: ${status.__typename}`,\n ).asResultAsync();\n }\n }),\n [client, handler],\n );\n}\n","import {\n preparePositionSwap,\n repayWithSupplyQuote,\n} from '@aave/client/actions';\nimport type { ValidationError } from '@aave/core';\nimport type {\n InsufficientBalanceError,\n InsufficientLiquidityError,\n RepayWithSupplyQuoteRequest,\n SwapReceipt,\n} from '@aave/graphql';\nimport type { Prettify } from '@aave/types';\n\nimport { useAaveClient } from '../context';\nimport type { PendingTransactionError, SendTransactionError } from '../helpers';\n\nimport {\n type CurrencyQueryOptions,\n cancel,\n DEFAULT_QUERY_OPTIONS,\n type PositionSwapHandler,\n processApprovals,\n type SwapSignerError,\n swapPosition,\n trySignatureFrom,\n type UseAsyncTask,\n useAsyncTask,\n} from './helpers';\n\nexport type UseRepayWithSupplyRequest = Prettify<\n RepayWithSupplyQuoteRequest & CurrencyQueryOptions\n>;\n\n/**\n * Orchestrate the repay with supply execution plan.\n *\n * ```tsx\n * const [signTypedData] = useSignTypedData(wallet);\n *\n * const [repayWithSupply, { loading, error }] = useRepayWithSupply((plan) => {\n * switch (plan.__typename) {\n * case 'PositionSwapAdapterContractApproval':\n * case 'PositionSwapPositionManagerApproval':\n * return signTypedData(plan.bySignature);\n *\n * case 'SwapTypedData':\n * return signTypedData(plan);\n * }\n * });\n *\n * const result = await repayWithSupply({\n * market: {\n * sellPosition: userSupplyItem.id,\n * buyPosition: userBorrowItem.id,\n * amount: bigDecimal('1000'),\n * user: evmAddress('0x742d35cc…'),\n * },\n * });\n *\n * if (result.isErr()) {\n * console.error(result.error);\n * return;\n * }\n *\n * // result.value: SwapReceipt\n * ```\n */\nexport function useRepayWithSupply(\n handler: PositionSwapHandler,\n): UseAsyncTask<\n RepayWithSupplyQuoteRequest,\n SwapReceipt,\n | SwapSignerError\n | SendTransactionError\n | PendingTransactionError\n | ValidationError<InsufficientBalanceError | InsufficientLiquidityError>\n> {\n const client = useAaveClient();\n\n return useAsyncTask(\n ({\n currency = DEFAULT_QUERY_OPTIONS.currency,\n ...request\n }: UseRepayWithSupplyRequest) => {\n return repayWithSupplyQuote(client, request, { currency }).andThen(\n (result) => {\n return processApprovals(result)\n .with(handler)\n .andThen((request) => preparePositionSwap(client, request))\n .andThen((order) =>\n handler(order.data, { cancel })\n .andThen(trySignatureFrom)\n .andThen((signature) =>\n swapPosition(client, {\n quoteId: order.newQuoteId,\n signature,\n }),\n ),\n );\n },\n );\n },\n [client, handler],\n );\n}\n","import { repayWithSupplyQuote } from '@aave/client/actions';\nimport type { UnexpectedError, ValidationError } from '@aave/core';\nimport type { InsufficientLiquidityError, SwapQuote } from '@aave/graphql';\nimport {\n QuoteAccuracy,\n RepayWithSupplyQuoteQuery,\n type RepayWithSupplyQuoteRequest,\n} from '@aave/graphql';\nimport type { NullishDeep, Prettify } from '@aave/types';\n\nimport { useAaveClient } from '../context';\nimport {\n type Pausable,\n type PausableReadResult,\n type PausableSuspenseResult,\n type ReadResult,\n type Suspendable,\n type SuspendableResult,\n type SuspenseResult,\n useSuspendableQuery,\n} from '../helpers';\nimport { type UseAsyncTask, useAsyncTask } from '../helpers/tasks';\n\nimport {\n type CurrencyQueryOptions,\n DEFAULT_QUERY_OPTIONS,\n extractPositionSwapQuote,\n} from './helpers';\n\nfunction injectRepayWithSupplyQuoteAccuracy(\n request: NullishDeep<RepayWithSupplyQuoteRequest>,\n accuracy: QuoteAccuracy,\n): NullishDeep<RepayWithSupplyQuoteRequest> {\n if ('market' in request && request.market) {\n return { market: { ...request.market, accuracy } };\n }\n return request;\n}\n\nexport type UseRepayWithSupplyQuoteArgs = Prettify<\n RepayWithSupplyQuoteRequest & CurrencyQueryOptions\n>;\n\n/**\n * Fetch a quote for a repay with supply operation with the specified parameters.\n *\n * This signature supports React Suspense:\n *\n * ```tsx\n * const { data } = useRepayWithSupplyQuote({\n * market: {\n * sellPosition: userSupplyItem.id,\n * buyPosition: userBorrowItem.id,\n * amount: bigDecimal('1000'),\n * user: evmAddress('0x742d35cc…'),\n * },\n * suspense: true,\n * });\n * ```\n */\nexport function useRepayWithSupplyQuote(\n args: UseRepayWithSupplyQuoteArgs & Suspendable,\n): SuspenseResult<SwapQuote>;\n/**\n * Fetch a quote for a repay with supply operation with the specified parameters.\n *\n * Pausable suspense mode.\n *\n * ```tsx\n * const { data } = useRepayWithSupplyQuote({\n * market: {\n * sellPosition: userSupplyItem.id,\n * buyPosition: userBorrowItem.id,\n * amount: bigDecimal('1000'),\n * user: evmAddress('0x742d35cc…'),\n * },\n * suspense: true,\n * pause: true,\n * });\n * ```\n */\nexport function useRepayWithSupplyQuote(\n args: Pausable<UseRepayWithSupplyQuoteArgs> & Suspendable,\n): PausableSuspenseResult<SwapQuote>;\n/**\n * Fetch a quote for a repay with supply operation with the specified parameters.\n *\n * ```tsx\n * const { data, error, loading } = useRepayWithSupplyQuote({\n * market: {\n * sellPosition: userSupplyItem.id,\n * buyPosition: userBorrowItem.id,\n * amount: bigDecimal('1000'),\n * user: evmAddress('0x742d35cc…'),\n * },\n * });\n * ```\n */\nexport function useRepayWithSupplyQuote(\n args: UseRepayWithSupplyQuoteArgs,\n): ReadResult<SwapQuote>;\n/**\n * Fetch a quote for a repay with supply operation with the specified parameters.\n *\n * Pausable loading state mode.\n *\n * ```tsx\n * const { data, error, loading, paused } = useRepayWithSupplyQuote({\n * market: {\n * sellPosition: userSupplyItem.id,\n * buyPosition: userBorrowItem.id,\n * amount: bigDecimal('1000'),\n * user: evmAddress('0x742d35cc…'),\n * },\n * pause: true,\n * });\n * ```\n */\nexport function useRepayWithSupplyQuote(\n args: Pausable<UseRepayWithSupplyQuoteArgs>,\n): PausableReadResult<SwapQuote>;\n\nexport function useRepayWithSupplyQuote({\n suspense = false,\n pause = false,\n currency = DEFAULT_QUERY_OPTIONS.currency,\n ...request\n}: NullishDeep<UseRepayWithSupplyQuoteArgs> & {\n suspense?: boolean;\n pause?: boolean;\n}): SuspendableResult<\n SwapQuote,\n UnexpectedError | ValidationError<InsufficientLiquidityError>\n> {\n const client = useAaveClient();\n\n // Fast query - no polling, suspends in suspense mode for quick initial render\n const fastResult = useSuspendableQuery({\n document: RepayWithSupplyQuoteQuery,\n variables: {\n request: injectRepayWithSupplyQuoteAccuracy(request, QuoteAccuracy.Fast),\n currency,\n },\n selector: extractPositionSwapQuote,\n suspense,\n pause,\n batch: false, // Don't batch with Accurate query\n });\n\n // Accurate query - with polling, never suspends, fires after Fast in suspense mode\n const accurateResult = useSuspendableQuery({\n document: RepayWithSupplyQuoteQuery,\n variables: {\n request: injectRepayWithSupplyQuoteAccuracy(\n request,\n QuoteAccuracy.Accurate,\n ),\n currency,\n },\n selector: extractPositionSwapQuote,\n suspense: false, // Never suspend on Accurate (would cause re-suspend)\n pause: pause || (suspense && !fastResult.data),\n pollInterval: client.context.environment.swapQuoteInterval,\n batch: false, // Don't batch with Fast query\n });\n\n if (accurateResult.data) {\n return accurateResult;\n }\n\n return fastResult;\n}\n\n/**\n * Low-level hook to execute a repay with supply quote action directly.\n *\n * @remarks\n * This hook **does not** actively watch for updated data on the swap quote.\n * Use this hook to retrieve quotes on demand as part of a larger workflow.\n *\n * ```ts\n * const [getQuote, { called, data, error, loading }] = useRepayWithSupplyQuoteAction();\n *\n * // …\n *\n * const result = await getQuote({\n * repayWithReserve: reserve.id,\n * debtPosition: userBorrowItem.id,\n * amount: bigDecimal('1000'),\n * user: evmAddress('0x742d35cc…'),\n * });\n *\n * if (result.isOk()) {\n * console.log('Repay with supply quote:', result.value);\n * } else {\n * console.error(result.error);\n * }\n * ```\n */\nexport function useRepayWithSupplyQuoteAction(\n options: Required<CurrencyQueryOptions> = DEFAULT_QUERY_OPTIONS,\n): UseAsyncTask<\n RepayWithSupplyQuoteRequest,\n SwapQuote,\n UnexpectedError | ValidationError<InsufficientLiquidityError>\n> {\n const client = useAaveClient();\n\n return useAsyncTask(\n (request: RepayWithSupplyQuoteRequest) =>\n repayWithSupplyQuote(client, request, {\n currency: options.currency,\n requestPolicy: 'network-only',\n }).andThen(extractPositionSwapQuote),\n [client, options.currency],\n );\n}\n","import { preparePositionSwap, supplySwapQuote } from '@aave/client/actions';\nimport type { ValidationError } from '@aave/core';\nimport type {\n InsufficientBalanceError,\n InsufficientLiquidityError,\n SupplySwapQuoteRequest,\n SwapReceipt,\n} from '@aave/graphql';\nimport type { Prettify } from '@aave/types';\n\nimport { useAaveClient } from '../context';\nimport type { PendingTransactionError, SendTransactionError } from '../helpers';\n\nimport {\n type CurrencyQueryOptions,\n cancel,\n DEFAULT_QUERY_OPTIONS,\n type PositionSwapHandler,\n processApprovals,\n type SwapSignerError,\n swapPosition,\n trySignatureFrom,\n type UseAsyncTask,\n useAsyncTask,\n} from './helpers';\n\nexport type UseSupplySwapRequest = Prettify<\n SupplySwapQuoteRequest & CurrencyQueryOptions\n>;\n\n/**\n * Orchestrate the supply swap execution plan.\n *\n * ```tsx\n * const [signTypedData] = useSignTypedData(wallet);\n *\n * const [swapSupply, { loading, error }] = useSupplySwap((plan) => {\n * switch (plan.__typename) {\n * case 'PositionSwapAdapterContractApproval':\n * case 'PositionSwapPositionManagerApproval':\n * return signTypedData(plan.bySignature);\n *\n * case 'SwapTypedData':\n * return signTypedData(plan);\n * }\n * });\n *\n * const result = await swapSupply({\n * market: {\n * sellPosition: supplyPosition.id,\n * buyReserve: targetReserve.id,\n * amount: bigDecimal('1000'),\n * user: evmAddress('0x742d35cc…'),\n * enableCollateral: true,\n * },\n * });\n *\n * if (result.isErr()) {\n * console.error(result.error);\n * return;\n * }\n *\n * // result.value: SwapReceipt\n * ```\n */\nexport function useSupplySwap(\n handler: PositionSwapHandler,\n): UseAsyncTask<\n SupplySwapQuoteRequest,\n SwapReceipt,\n | SwapSignerError\n | SendTransactionError\n | PendingTransactionError\n | ValidationError<InsufficientBalanceError | InsufficientLiquidityError>\n> {\n const client = useAaveClient();\n\n return useAsyncTask(\n ({\n currency = DEFAULT_QUERY_OPTIONS.currency,\n ...request\n }: UseSupplySwapRequest) => {\n return supplySwapQuote(client, request, { currency }).andThen(\n (result) => {\n return processApprovals(result)\n .with(handler)\n .andThen((request) => preparePositionSwap(client, request))\n .andThen((order) =>\n handler(order.data, { cancel })\n .andThen(trySignatureFrom)\n .andThen((signature) =>\n swapPosition(client, {\n quoteId: order.newQuoteId,\n signature,\n }),\n ),\n );\n },\n );\n },\n [client, handler],\n );\n}\n","import { supplySwapQuote } from '@aave/client/actions';\nimport type { UnexpectedError, ValidationError } from '@aave/core';\nimport type {\n InsufficientLiquidityError,\n SupplySwapQuoteRequest,\n SwapQuote,\n} from '@aave/graphql';\nimport { QuoteAccuracy, SupplySwapQuoteQuery } from '@aave/graphql';\nimport type { NullishDeep, Prettify } from '@aave/types';\n\nimport { useAaveClient } from '../context';\nimport {\n type Pausable,\n type PausableReadResult,\n type PausableSuspenseResult,\n type ReadResult,\n type Suspendable,\n type SuspendableResult,\n type SuspenseResult,\n useSuspendableQuery,\n} from '../helpers';\nimport { type UseAsyncTask, useAsyncTask } from '../helpers/tasks';\n\nimport {\n type CurrencyQueryOptions,\n DEFAULT_QUERY_OPTIONS,\n extractPositionSwapQuote,\n} from './helpers';\n\nfunction injectSupplySwapQuoteAccuracy(\n request: NullishDeep<SupplySwapQuoteRequest>,\n accuracy: QuoteAccuracy,\n): NullishDeep<SupplySwapQuoteRequest> {\n if ('market' in request && request.market) {\n return { market: { ...request.market, accuracy } };\n }\n return request;\n}\n\nexport type UseSupplySwapQuoteArgs = Prettify<\n SupplySwapQuoteRequest & CurrencyQueryOptions\n>;\n\n/**\n * Fetch a quote for a supply swap operation with the specified parameters.\n *\n * This signature supports React Suspense:\n *\n * ```tsx\n * const { data } = useSupplySwapQuote({\n * market: {\n * sellPosition: userSupplyItem.id,\n * buyReserve: reserve.id,\n * amount: bigDecimal('1000'),\n * user: evmAddress('0x742d35cc…'),\n * },\n * suspense: true,\n * });\n * ```\n */\nexport function useSupplySwapQuote(\n args: UseSupplySwapQuoteArgs & Suspendable,\n): SuspenseResult<SwapQuote>;\n/**\n * Fetch a quote for a supply swap operation with the specified parameters.\n *\n * Pausable suspense mode.\n *\n * ```tsx\n * const { data } = useSupplySwapQuote({\n * market: {\n * sellPosition: userSupplyItem.id,\n * buyReserve: reserve.id,\n * amount: bigDecimal('1000'),\n * user: evmAddress('0x742d35cc…'),\n * },\n * suspense: true,\n * pause: true,\n * });\n * ```\n */\nexport function useSupplySwapQuote(\n args: Pausable<UseSupplySwapQuoteArgs> & Suspendable,\n): PausableSuspenseResult<SwapQuote>;\n/**\n * Fetch a quote for a supply swap operation with the specified parameters.\n *\n * ```tsx\n * const { data, error, loading } = useSupplySwapQuote({\n * market: {\n * sellPosition: userSupplyItem.id,\n * buyReserve: reserve.id,\n * amount: bigDecimal('1000'),\n * user: evmAddress('0x742d35cc…'),\n * },\n * });\n * ```\n */\nexport function useSupplySwapQuote(\n args: UseSupplySwapQuoteArgs,\n): ReadResult<SwapQuote>;\n/**\n * Fetch a quote for a supply swap operation with the specified parameters.\n *\n * Pausable loading state mode.\n *\n * ```tsx\n * const { data, error, loading, paused } = useSupplySwapQuote({\n * market: {\n * sellPosition: userSupplyItem.id,\n * buyReserve: reserve.id,\n * amount: bigDecimal('1000'),\n * user: evmAddress('0x742d35cc…'),\n * },\n * pause: true,\n * });\n * ```\n */\nexport function useSupplySwapQuote(\n args: Pausable<UseSupplySwapQuoteArgs>,\n): PausableReadResult<SwapQuote>;\n\nexport function useSupplySwapQuote({\n suspense = false,\n pause = false,\n currency = DEFAULT_QUERY_OPTIONS.currency,\n ...request\n}: NullishDeep<UseSupplySwapQuoteArgs> & {\n suspense?: boolean;\n pause?: boolean;\n}): SuspendableResult<\n SwapQuote,\n UnexpectedError | ValidationError<InsufficientLiquidityError>\n> {\n const client = useAaveClient();\n\n // Fast query - no polling, suspends in suspense mode for quick initial render\n const fastResult = useSuspendableQuery({\n document: SupplySwapQuoteQuery,\n variables: {\n request: injectSupplySwapQuoteAccuracy(request, QuoteAccuracy.Fast),\n currency,\n },\n selector: extractPositionSwapQuote,\n suspense,\n pause,\n batch: false, // Don't batch with Accurate query\n });\n\n // Accurate query - with polling, never suspends, fires after Fast in suspense mode\n const accurateResult = useSuspendableQuery({\n document: SupplySwapQuoteQuery,\n variables: {\n request: injectSupplySwapQuoteAccuracy(request, QuoteAccuracy.Accurate),\n currency,\n },\n selector: extractPositionSwapQuote,\n suspense: false, // Never suspend on Accurate (would cause re-suspend)\n pause: pause || (suspense && !fastResult.data),\n pollInterval: client.context.environment.swapQuoteInterval,\n batch: false, // Don't batch with Fast query\n });\n\n if (accurateResult.data) {\n return accurateResult;\n }\n\n return fastResult;\n}\n\n/**\n * Low-level hook to execute a supply swap quote action directly.\n *\n * @remarks\n * This hook **does not** actively watch for updated data on the swap quote.\n * Use this hook to retrieve quotes on demand as part of a larger workflow.\n *\n * ```ts\n * const [getQuote, { called, data, error, loading }] = useSupplySwapQuoteAction();\n *\n * // …\n *\n * const result = await getQuote({\n * sellPosition: userSupplyItem.id,\n * buyReserve: reserve.id,\n * amount: bigDecimal('1000'),\n * user: evmAddress('0x742d35cc…'),\n * });\n *\n * if (result.isOk()) {\n * console.log('Supply swap quote:', result.value);\n * } else {\n * console.error(result.error);\n * }\n * ```\n */\nexport function useSupplySwapQuoteAction(\n options: Required<CurrencyQueryOptions> = DEFAULT_QUERY_OPTIONS,\n): UseAsyncTask<\n SupplySwapQuoteRequest,\n SwapQuote,\n UnexpectedError | ValidationError<InsufficientLiquidityError>\n> {\n const client = useAaveClient();\n\n return useAsyncTask(\n (request: SupplySwapQuoteRequest) =>\n supplySwapQuote(client, request, {\n currency: options.currency,\n requestPolicy: 'network-only',\n }).andThen(extractPositionSwapQuote),\n [client, options.currency],\n );\n}\n","import type { UnexpectedError } from '@aave/core';\nimport type { Token } from '@aave/graphql';\nimport {\n SwappableTokensQuery,\n type SwappableTokensRequest,\n} from '@aave/graphql';\nimport type { NullishDeep } from '@aave/types';\n\nimport {\n type Pausable,\n type PausableReadResult,\n type PausableSuspenseResult,\n type ReadResult,\n type Suspendable,\n type SuspendableResult,\n type SuspenseResult,\n useSuspendableQuery,\n} from '../helpers';\n\nexport type UseSwappableTokensArgs = SwappableTokensRequest;\n\n/**\n * Fetch the list of tokens available for swapping on a specific chain.\n *\n * This signature supports React Suspense:\n *\n * ```tsx\n * const { data } = useSwappableTokens({\n * query: { chainIds: [chainId(1)] },\n * suspense: true,\n * });\n * ```\n */\nexport function useSwappableTokens(\n args: UseSwappableTokensArgs & Suspendable,\n): SuspenseResult<Token[]>;\n/**\n * Fetch the list of tokens available for swapping on a specific chain.\n *\n * Pausable suspense mode.\n *\n * ```tsx\n * const { data } = useSwappableTokens({\n * query: { chainIds: [chainId(1)] },\n * suspense: true,\n * pause: true,\n * });\n * ```\n */\nexport function useSwappableTokens(\n args: Pausable<UseSwappableTokensArgs> & Suspendable,\n): PausableSuspenseResult<Token[]>;\n/**\n * Fetch the list of tokens available for swapping on a specific chain.\n *\n * ```tsx\n * const { data, error, loading } = useSwappableTokens({\n * query: { chainIds: [chainId(1)] },\n * });\n * ```\n */\nexport function useSwappableTokens(\n args: UseSwappableTokensArgs,\n): ReadResult<Token[]>;\n/**\n * Fetch the list of tokens available for swapping on a specific chain.\n *\n * Pausable loading state mode.\n *\n * ```tsx\n * const { data, error, loading, paused } = useSwappableTokens({\n * query: { chainIds: [chainId(1)] },\n * pause: true,\n * });\n * ```\n */\nexport function useSwappableTokens(\n args: Pausable<UseSwappableTokensArgs>,\n): PausableReadResult<Token[]>;\n\nexport function useSwappableTokens({\n suspense = false,\n pause = false,\n ...request\n}: NullishDeep<UseSwappableTokensArgs> & {\n suspense?: boolean;\n pause?: boolean;\n}): SuspendableResult<Token[], UnexpectedError> {\n return useSuspendableQuery({\n document: SwappableTokensQuery,\n variables: {\n request,\n },\n suspense,\n pause,\n });\n}\n","import {\n type CurrencyQueryOptions,\n DEFAULT_QUERY_OPTIONS,\n type TimeWindowQueryOptions,\n} from '@aave/client';\nimport type { UnexpectedError } from '@aave/core';\nimport type { SwapStatus, SwapStatusRequest } from '@aave/graphql';\nimport { SwapStatusQuery } from '@aave/graphql';\nimport type { NullishDeep, Prettify } from '@aave/types';\nimport { useEffect, useState } from 'react';\n\nimport { useAaveClient } from '../context';\nimport {\n type Pausable,\n type PausableReadResult,\n type PausableSuspenseResult,\n type ReadResult,\n type Suspendable,\n type SuspendableResult,\n type SuspenseResult,\n useSuspendableQuery,\n} from '../helpers';\n\nimport { isTerminalSwapStatus } from './helpers';\n\nexport type UseSwapStatusArgs = Prettify<\n SwapStatusRequest & CurrencyQueryOptions & TimeWindowQueryOptions\n>;\n\n/**\n * Monitor the status of a single swap operation in real-time.\n *\n * Polls automatically until the swap reaches a terminal state (fulfilled, cancelled, or expired).\n *\n * This signature supports React Suspense:\n *\n * ```tsx\n * const { data } = useSwapStatus({\n * id: swapReceipt.id,\n * suspense: true,\n * });\n * ```\n */\nexport function useSwapStatus(\n args: UseSwapStatusArgs & Suspendable,\n): SuspenseResult<SwapStatus>;\n/**\n * Monitor the status of a single swap operation in real-time.\n *\n * Pausable suspense mode.\n *\n * ```tsx\n * const { data } = useSwapStatus({\n * id: swapReceipt.id,\n * suspense: true,\n * pause: shouldPause,\n * });\n * ```\n */\nexport function useSwapStatus(\n args: Pausable<UseSwapStatusArgs> & Suspendable,\n): PausableSuspenseResult<SwapStatus>;\n/**\n * Monitor the status of a single swap operation in real-time.\n *\n * Polls automatically until the swap reaches a terminal state (fulfilled, cancelled, or expired).\n *\n * ```tsx\n * const { data, error, loading } = useSwapStatus({\n * id: swapReceipt.id,\n * });\n * ```\n */\nexport function useSwapStatus(args: UseSwapStatusArgs): ReadResult<SwapStatus>;\n/**\n * Monitor the status of a single swap operation in real-time.\n *\n * Pausable loading state mode.\n *\n * ```tsx\n * const { data, error, loading, paused } = useSwapStatus({\n * id: swapReceipt.id,\n * pause: shouldPause,\n * });\n * ```\n */\nexport function useSwapStatus(\n args: Pausable<UseSwapStatusArgs>,\n): PausableReadResult<SwapStatus>;\n\nexport function useSwapStatus({\n suspense = false,\n pause = false,\n currency = DEFAULT_QUERY_OPTIONS.currency,\n timeWindow = DEFAULT_QUERY_OPTIONS.timeWindow,\n ...request\n}: NullishDeep<UseSwapStatusArgs> & {\n suspense?: boolean;\n pause?: boolean;\n}): SuspendableResult<SwapStatus, UnexpectedError> {\n const client = useAaveClient();\n const [isTerminal, setIsTerminal] = useState(false);\n\n const result: SuspendableResult<SwapStatus, UnexpectedError> =\n useSuspendableQuery({\n document: SwapStatusQuery,\n variables: { request, currency, timeWindow },\n suspense,\n pause: pause || isTerminal,\n pollInterval: client.context.environment.swapStatusInterval,\n });\n\n useEffect(() => {\n if (result.data && isTerminalSwapStatus(result.data)) {\n setIsTerminal(true);\n }\n }, [result.data]);\n\n return result;\n}\n","import { supportsPermit } from '@aave/client';\nimport { prepareTokenSwap, swap, tokenSwapQuote } from '@aave/client/actions';\nimport { UnexpectedError, type ValidationError } from '@aave/core';\nimport type {\n Erc20Approval,\n InsufficientBalanceError,\n InsufficientLiquidityError,\n SwapReceipt,\n SwapRequest,\n SwapTransactionRequest,\n SwapTypedData,\n TokenSwapQuoteRequest,\n} from '@aave/graphql';\nimport type { Prettify, ResultAsync, Signature } from '@aave/types';\nimport { never } from '@aave/types';\nimport { useCallback } from 'react';\n\nimport { useAaveClient } from '../context';\nimport type { PendingTransactionError, SendTransactionError } from '../helpers';\n\nimport {\n type CurrencyQueryOptions,\n cancel,\n DEFAULT_QUERY_OPTIONS,\n isSignature,\n okAsync,\n PendingTransaction,\n type SwapHandlerOptions,\n type SwapSignerError,\n trySignatureFrom,\n type UseAsyncTask,\n useAsyncTask,\n} from './helpers';\n\nexport type UseTokenSwapRequest = Prettify<\n TokenSwapQuoteRequest & CurrencyQueryOptions\n>;\n\nexport type TokenSwapPlan =\n | SwapTypedData\n | Erc20Approval\n | SwapTransactionRequest;\n\nexport type TokenSwapHandler = (\n plan: TokenSwapPlan,\n options: SwapHandlerOptions,\n) => ResultAsync<PendingTransaction | Signature, SwapSignerError>;\n\n/**\n * Orchestrate the token swap execution plan.\n *\n * ```tsx\n * const [sendTransaction] = useSendTransaction(wallet);\n * const [signTypedData] = useSignTypedData(wallet);\n *\n * const [swap, { loading, error }] = useTokenSwap((plan) => {\n * switch (plan.__typename) {\n * case 'Erc20Approval':\n * if (plan.bySignature) {\n * return signTypedData(plan.bySignature);\n * }\n * return sendTransaction(plan.byTransaction);\n *\n * case 'SwapTransactionRequest':\n * return sendTransaction(plan.transaction);\n *\n * case 'SwapTypedData':\n * return signTypedData(plan);\n * }\n * });\n *\n * const result = await swap({\n * fromQuote: {\n * quoteId: quote.quoteId,\n * },\n * });\n *\n * if (result.isErr()) {\n * console.error(result.error);\n * return;\n * }\n *\n * // result.value: SwapReceipt\n * ```\n */\nexport function useTokenSwap(\n handler: TokenSwapHandler,\n): UseAsyncTask<\n UseTokenSwapRequest,\n SwapReceipt,\n | SendTransactionError\n | PendingTransactionError\n | ValidationError<InsufficientBalanceError | InsufficientLiquidityError>\n> {\n const client = useAaveClient();\n\n const executeSwap = useCallback(\n (\n request: SwapRequest,\n ): ResultAsync<\n SwapReceipt,\n | SendTransactionError\n | PendingTransactionError\n | ValidationError<InsufficientBalanceError>\n > => {\n return swap(client, request).andThen((plan) => {\n switch (plan.__typename) {\n case 'SwapTransactionRequest':\n return handler(plan, { cancel })\n .andThen(PendingTransaction.tryFrom)\n .andThen((pendingTransaction) => pendingTransaction.wait())\n .andThen(() => okAsync(plan.orderReceipt));\n\n case 'SwapReceipt':\n return okAsync(plan);\n }\n });\n },\n [client, handler],\n );\n\n return useAsyncTask(\n ({\n currency = DEFAULT_QUERY_OPTIONS.currency,\n ...request\n }: UseTokenSwapRequest) =>\n tokenSwapQuote(client, request, { currency }).andThen((quoteResult) => {\n switch (quoteResult.__typename) {\n case 'SwapByTransaction':\n return executeSwap({\n transaction: { quoteId: quoteResult.quote.quoteId },\n });\n\n case 'SwapByIntent':\n return prepareTokenSwap(client, {\n quoteId: quoteResult.quote.quoteId,\n }).andThen((order) =>\n handler(order.data, { cancel })\n .andThen(trySignatureFrom)\n .andThen((signature) =>\n executeSwap({\n intent: { quoteId: order.newQuoteId, signature },\n }),\n ),\n );\n\n case 'SwapByIntentWithApprovalRequired':\n if (supportsPermit(quoteResult)) {\n const approval = quoteResult.approvals[0];\n return handler(approval, { cancel })\n .andThen((result) => {\n if (isSignature(result)) {\n return prepareTokenSwap(client, {\n quoteId: quoteResult.quote.quoteId,\n permitSig: {\n deadline: approval.bySignature.message\n .deadline as number,\n value: result,\n },\n });\n }\n if (PendingTransaction.isInstanceOf(result)) {\n return result.wait().andThen(() =>\n prepareTokenSwap(client, {\n quoteId: quoteResult.quote.quoteId,\n }),\n );\n }\n return UnexpectedError.from(result).asResultAsync();\n })\n .andThen((order) =>\n handler(order.data, { cancel })\n .andThen(trySignatureFrom)\n .andThen((signature) =>\n executeSwap({\n intent: {\n quoteId: order.newQuoteId,\n signature,\n },\n }),\n ),\n );\n }\n\n return quoteResult.approvals\n .reduce(\n (chain, approval) =>\n chain.andThen(() =>\n handler({ ...approval, bySignature: null }, { cancel })\n .andThen(PendingTransaction.tryFrom)\n .andThen((pendingTransaction) =>\n pendingTransaction.wait(),\n ),\n ),\n okAsync(undefined) as ResultAsync<\n unknown,\n SendTransactionError | PendingTransactionError\n >,\n )\n .andThen(() =>\n prepareTokenSwap(client, {\n quoteId: quoteResult.quote.quoteId,\n }),\n )\n .andThen((order) => handler(order.data, { cancel }))\n .andThen(trySignatureFrom)\n .andThen((signature) =>\n executeSwap({\n intent: { quoteId: quoteResult.quote.quoteId, signature },\n }),\n );\n default:\n never(\n `Unsupported swap quote result: ${quoteResult.__typename}. To be removed from API soon.`,\n );\n }\n }),\n [client, handler, executeSwap],\n );\n}\n","import { tokenSwapQuote } from '@aave/client/actions';\nimport { UnexpectedError, ValidationError } from '@aave/core';\nimport type {\n InsufficientLiquidityError,\n SwapQuote,\n TokenSwapQuoteRequest,\n} from '@aave/graphql';\nimport {\n QuoteAccuracy,\n TokenSwapQuoteQuery,\n type TokenSwapQuoteResult,\n} from '@aave/graphql';\nimport type { NullishDeep, Prettify, Result } from '@aave/types';\nimport { err, ok } from '@aave/types';\n\nimport { useAaveClient } from '../context';\nimport {\n type Pausable,\n type PausableReadResult,\n type PausableSuspenseResult,\n type ReadResult,\n type Suspendable,\n type SuspendableResult,\n type SuspenseResult,\n useSuspendableQuery,\n} from '../helpers';\nimport { type UseAsyncTask, useAsyncTask } from '../helpers/tasks';\n\nimport { type CurrencyQueryOptions, DEFAULT_QUERY_OPTIONS } from './helpers';\n\nfunction extractTokenSwapQuote(\n data: TokenSwapQuoteResult,\n): Result<\n SwapQuote,\n ValidationError<InsufficientLiquidityError> | UnexpectedError\n> {\n switch (data.__typename) {\n case 'SwapByIntent':\n case 'SwapByIntentWithApprovalRequired':\n case 'SwapByTransaction':\n return ok(data.quote);\n case 'InsufficientLiquidityError':\n return err(ValidationError.fromGqlNode(data));\n default:\n return err(\n UnexpectedError.upgradeRequired(\n `Unsupported swap quote result: ${data.__typename}`,\n ),\n );\n }\n}\n\nfunction injectTokenSwapQuoteAccuracy(\n request: NullishDeep<TokenSwapQuoteRequest>,\n accuracy: QuoteAccuracy,\n): NullishDeep<TokenSwapQuoteRequest> {\n if ('market' in request && request.market) {\n return { market: { ...request.market, accuracy } };\n }\n // Limit orders don't have an accuracy field\n return request;\n}\n\nexport type UseTokenSwapQuoteArgs = Prettify<\n TokenSwapQuoteRequest & CurrencyQueryOptions\n>;\n\n/**\n * Fetch a swap quote for the specified trade parameters.\n *\n * This signature supports React Suspense:\n *\n * ```tsx\n * const { data } = useTokenSwapQuote({\n * market: {\n * buy: { erc20: evmAddress('0xA0b86a33E6…') },\n * sell: { erc20: evmAddress('0x6B175474E…') },\n * amount: bigDecimal('1000'),\n * kind: SwapKind.Sell,\n * user: evmAddress('0x742d35cc…'),\n * },\n * chainId: chainId(1),\n * suspense: true,\n * });\n * ```\n */\nexport function useTokenSwapQuote(\n args: UseTokenSwapQuoteArgs & Suspendable,\n): SuspenseResult<SwapQuote>;\n/**\n * Fetch a swap quote for the specified trade parameters.\n *\n * Pausable suspense mode.\n *\n * ```tsx\n * const { data } = useTokenSwapQuote({\n * market: {\n * chainId: chainId(1),\n * buy: { erc20: evmAddress('0xA0b86a33E6…') },\n * sell: { erc20: evmAddress('0x6B175474E…') },\n * amount: bigDecimal('1000'),\n * kind: SwapKind.Sell,\n * user: evmAddress('0x742d35cc…'),\n * },\n * suspense: true,\n * pause: true,\n * });\n * ```\n */\nexport function useTokenSwapQuote(\n args: Pausable<UseTokenSwapQuoteArgs> & Suspendable,\n): PausableSuspenseResult<SwapQuote>;\n/**\n * Fetch a swap quote for the specified trade parameters.\n *\n * ```tsx\n * const { data, error, loading } = useTokenSwapQuote({\n * market: {\n * chainId: chainId(1),\n * buy: { erc20: evmAddress('0xA0b86a33E6…') },\n * sell: { erc20: evmAddress('0x6B175474E…') },\n * amount: bigDecimal('1000'),\n * kind: SwapKind.Sell,\n * user: evmAddress('0x742d35cc…'),\n * },\n * });\n * ```\n */\nexport function useTokenSwapQuote(\n args: UseTokenSwapQuoteArgs,\n): ReadResult<SwapQuote>;\n/**\n * Fetch a swap quote for the specified trade parameters.\n *\n * Pausable loading state mode.\n *\n * ```tsx\n * const { data, error, loading, paused } = useTokenSwapQuote({\n * market: {\n * chainId: chainId(1),\n * buy: { erc20: evmAddress('0xA0b86a33E6…') },\n * sell: { erc20: evmAddress('0x6B175474E…') },\n * amount: bigDecimal('1000'),\n * kind: SwapKind.Sell,\n * user: evmAddress('0x742d35cc…'),\n * },\n * pause: true,\n * });\n * ```\n */\nexport function useTokenSwapQuote(\n args: Pausable<UseTokenSwapQuoteArgs>,\n): PausableReadResult<SwapQuote>;\n\nexport function useTokenSwapQuote({\n suspense = false,\n pause = false,\n currency = DEFAULT_QUERY_OPTIONS.currency,\n ...request\n}: NullishDeep<UseTokenSwapQuoteArgs> & {\n suspense?: boolean;\n pause?: boolean;\n}): SuspendableResult<\n SwapQuote,\n UnexpectedError | ValidationError<InsufficientLiquidityError>\n> {\n const client = useAaveClient();\n\n // Fast query - no polling, suspends in suspense mode for quick initial render\n const fastResult = useSuspendableQuery({\n document: TokenSwapQuoteQuery,\n variables: {\n request: injectTokenSwapQuoteAccuracy(request, QuoteAccuracy.Fast),\n currency,\n },\n selector: extractTokenSwapQuote,\n suspense,\n pause,\n batch: false, // Don't batch with Accurate query\n });\n\n // Accurate query - with polling, never suspends, fires after Fast in suspense mode\n const accurateResult = useSuspendableQuery({\n document: TokenSwapQuoteQuery,\n variables: {\n request: injectTokenSwapQuoteAccuracy(request, QuoteAccuracy.Accurate),\n currency,\n },\n selector: extractTokenSwapQuote,\n suspense: false, // Never suspend on Accurate (would cause re-suspend)\n pause: pause || (suspense && !fastResult.data),\n pollInterval: client.context.environment.swapQuoteInterval,\n batch: false, // Don't batch with Fast query\n });\n\n if (accurateResult.data) {\n return accurateResult;\n }\n\n return fastResult;\n}\n\n/**\n * Low-level hook to execute a swap quote action directly.\n *\n * @remarks\n * This hook **does not** actively watch for updated data on the swap quote.\n * Use this hook to retrieve quotes on demand as part of a larger workflow\n * (e.g., in an event handler to get a fresh quote before executing a swap).\n *\n * ```ts\n * const [getQuote, { called, data, error, loading }] = useTokenSwapQuoteAction();\n *\n * // …\n *\n * const result = await getQuote({\n * market: {\n * chainId: chainId(1),\n * buy: { erc20: evmAddress('0xA0b86a33E6…') },\n * sell: { erc20: evmAddress('0x6B175474E…') },\n * amount: bigDecimal('1000'),\n * kind: SwapKind.Sell,\n * },\n * });\n *\n * if (result.isOk()) {\n * console.log('Swap quote:', result.value);\n * } else {\n * console.error(result.error);\n * }\n * ```\n */\nexport function useTokenSwapQuoteAction(\n options: Required<CurrencyQueryOptions> = DEFAULT_QUERY_OPTIONS,\n): UseAsyncTask<\n TokenSwapQuoteRequest,\n SwapQuote,\n UnexpectedError | ValidationError<InsufficientLiquidityError>\n> {\n const client = useAaveClient();\n\n return useAsyncTask(\n (request: TokenSwapQuoteRequest) =>\n tokenSwapQuote(client, request, {\n currency: options.currency,\n requestPolicy: 'network-only',\n }).andThen(extractTokenSwapQuote),\n [client, options.currency],\n );\n}\n","import {\n type CurrencyQueryOptions,\n DEFAULT_QUERY_OPTIONS,\n type TimeWindowQueryOptions,\n} from '@aave/client';\nimport type { UnexpectedError } from '@aave/core';\nimport type {\n PaginatedUserSwapsResult,\n SwapFulfilled,\n SwapStatus,\n UserSwapsRequest,\n} from '@aave/graphql';\nimport { UserSwapsQuery } from '@aave/graphql';\nimport type { NullishDeep, Prettify } from '@aave/types';\nimport { useDeferredValue, useEffect, useState } from 'react';\n\nimport { useAaveClient } from '../context';\nimport {\n type Pausable,\n type PausableReadResult,\n type PausableSuspenseResult,\n type ReadResult,\n type Suspendable,\n type SuspendableResult,\n type SuspenseResult,\n useSuspendableQuery,\n} from '../helpers';\n\nimport {\n refreshAfterBorrowSwap,\n refreshAfterRepayWithSupply,\n refreshAfterSupplySwap,\n refreshAfterTokenSwap,\n refreshAfterWithdrawSwap,\n} from '../helpers/cache';\n\nimport { isTerminalSwapStatus } from './helpers';\n\nfunction findNewlyFulfilledSwaps(\n items: readonly SwapStatus[],\n prevItems: readonly SwapStatus[],\n): SwapFulfilled[] {\n const prevTypenames = new Map(\n prevItems.map((item) => [item.swapId, item.__typename]),\n );\n\n return items.filter(\n (item): item is SwapFulfilled =>\n item.__typename === 'SwapFulfilled' &&\n prevTypenames.get(item.swapId) !== 'SwapFulfilled',\n );\n}\n\nexport type UseUserSwapsArgs = Prettify<\n UserSwapsRequest & CurrencyQueryOptions & TimeWindowQueryOptions\n>;\n\n/**\n * Fetch the user's swap history for a specific chain.\n *\n * This signature supports React Suspense:\n *\n * ```tsx\n * const { data } = useUserSwaps({\n * chainId: chainId(1),\n * user: evmAddress('0x742d35cc…'),\n * filterBy: [SwapStatusFilter.FULFILLED, SwapStatusFilter.OPEN],\n * suspense: true,\n * });\n * ```\n */\nexport function useUserSwaps(\n args: UseUserSwapsArgs & Suspendable,\n): SuspenseResult<PaginatedUserSwapsResult>;\n/**\n * Fetch the user's swap history for a specific chain.\n *\n * Pausable suspense mode.\n *\n * ```tsx\n * const { data } = useUserSwaps({\n * chainId: chainId(1),\n * user: evmAddress('0x742d35cc…'),\n * filterBy: [SwapStatusFilter.FULFILLED, SwapStatusFilter.OPEN],\n * suspense: true,\n * pause: true,\n * });\n * ```\n */\nexport function useUserSwaps(\n args: Pausable<UseUserSwapsArgs> & Suspendable,\n): PausableSuspenseResult<PaginatedUserSwapsResult>;\n/**\n * Fetch the user's swap history for a specific chain.\n *\n * ```tsx\n * const { data, error, loading } = useUserSwaps({\n * chainId: chainId(1),\n * user: evmAddress('0x742d35cc…'),\n * filterBy: [SwapStatusFilter.FULFILLED, SwapStatusFilter.OPEN],\n * });\n * ```\n */\nexport function useUserSwaps(\n args: UseUserSwapsArgs,\n): ReadResult<PaginatedUserSwapsResult>;\n/**\n * Fetch the user's swap history for a specific chain.\n *\n * Pausable loading state mode.\n *\n * ```tsx\n * const { data, error, loading, paused } = useUserSwaps({\n * chainId: chainId(1),\n * user: evmAddress('0x742d35cc…'),\n * filterBy: [SwapStatusFilter.FULFILLED, SwapStatusFilter.OPEN],\n * pause: true,\n * });\n * ```\n */\nexport function useUserSwaps(\n args: Pausable<UseUserSwapsArgs>,\n): PausableReadResult<PaginatedUserSwapsResult>;\n\nexport function useUserSwaps({\n suspense = false,\n pause = false,\n currency = DEFAULT_QUERY_OPTIONS.currency,\n timeWindow = DEFAULT_QUERY_OPTIONS.timeWindow,\n ...request\n}: NullishDeep<UseUserSwapsArgs> & {\n suspense?: boolean;\n pause?: boolean;\n}): SuspendableResult<PaginatedUserSwapsResult, UnexpectedError> {\n const client = useAaveClient();\n const [allTerminal, setAllTerminal] = useState(false);\n\n const result: SuspendableResult<PaginatedUserSwapsResult, UnexpectedError> =\n useSuspendableQuery({\n document: UserSwapsQuery,\n variables: { request, currency, timeWindow },\n suspense,\n pause: pause || allTerminal,\n pollInterval: client.context.environment.swapStatusInterval,\n });\n\n const items = result.data?.items ?? [];\n const prevItems = useDeferredValue(items);\n\n useEffect(() => {\n if (items.length === 0) return;\n\n const allItemsTerminal = items.every(isTerminalSwapStatus);\n if (allItemsTerminal) {\n setAllTerminal(true);\n }\n\n for (const item of findNewlyFulfilledSwaps(items, prevItems)) {\n switch (item.operation.__typename) {\n case 'TokenSwap':\n if (request.user) {\n refreshAfterTokenSwap(client, request.user);\n }\n break;\n\n case 'BorrowSwap':\n if (request.user) {\n refreshAfterBorrowSwap(client, request.user);\n }\n break;\n\n case 'RepayWithSupply':\n if (request.user) {\n refreshAfterRepayWithSupply(client, request.user);\n }\n break;\n\n case 'SupplySwap':\n if (request.user) {\n refreshAfterSupplySwap(client, request.user);\n }\n break;\n\n case 'WithdrawSwap':\n if (request.user) {\n refreshAfterWithdrawSwap(client, request.user);\n }\n break;\n }\n }\n }, [items, prevItems, client, request.user]);\n\n return result;\n}\n","import { preparePositionSwap, withdrawSwapQuote } from '@aave/client/actions';\nimport type { ValidationError } from '@aave/core';\nimport type {\n InsufficientBalanceError,\n InsufficientLiquidityError,\n SwapReceipt,\n WithdrawSwapQuoteRequest,\n} from '@aave/graphql';\nimport type { Prettify } from '@aave/types';\n\nimport { useAaveClient } from '../context';\nimport type { PendingTransactionError, SendTransactionError } from '../helpers';\n\nimport {\n type CurrencyQueryOptions,\n cancel,\n DEFAULT_QUERY_OPTIONS,\n type PositionSwapHandler,\n processApprovals,\n type SwapSignerError,\n swapPosition,\n trySignatureFrom,\n type UseAsyncTask,\n useAsyncTask,\n} from './helpers';\n\nexport type UseWithdrawSwapRequest = Prettify<\n WithdrawSwapQuoteRequest & CurrencyQueryOptions\n>;\n\n/**\n * Orchestrate the withdraw swap execution plan.\n *\n * ```tsx\n * const [signTypedData] = useSignTypedData(wallet);\n *\n * const [withdrawSwap, { loading, error }] = useWithdrawSwap((plan) => {\n * switch (plan.__typename) {\n * case 'PositionSwapAdapterContractApproval':\n * case 'PositionSwapPositionManagerApproval':\n * return signTypedData(plan.bySignature);\n *\n * case 'SwapTypedData':\n * return signTypedData(plan);\n * }\n * });\n *\n * const result = await withdrawSwap({\n * market: {\n * position: userSupplyItem.id,\n * buyToken: { erc20: evmAddress('0xA0b86a33E6…') },\n * amount: bigDecimal('1000'),\n * user: evmAddress('0x742d35cc…'),\n * },\n * });\n *\n * if (result.isErr()) {\n * console.error(result.error);\n * return;\n * }\n *\n * // result.value: SwapReceipt\n * ```\n */\nexport function useWithdrawSwap(\n handler: PositionSwapHandler,\n): UseAsyncTask<\n WithdrawSwapQuoteRequest,\n SwapReceipt,\n | SwapSignerError\n | SendTransactionError\n | PendingTransactionError\n | ValidationError<InsufficientBalanceError | InsufficientLiquidityError>\n> {\n const client = useAaveClient();\n\n return useAsyncTask(\n ({\n currency = DEFAULT_QUERY_OPTIONS.currency,\n ...request\n }: UseWithdrawSwapRequest) => {\n return withdrawSwapQuote(client, request, { currency }).andThen(\n (result) => {\n return processApprovals(result)\n .with(handler)\n .andThen((request) => preparePositionSwap(client, request))\n .andThen((order) =>\n handler(order.data, { cancel })\n .andThen(trySignatureFrom)\n .andThen((signature) =>\n swapPosition(client, {\n quoteId: order.newQuoteId,\n signature,\n }),\n ),\n );\n },\n );\n },\n [client, handler],\n );\n}\n","import { withdrawSwapQuote } from '@aave/client/actions';\nimport type { UnexpectedError, ValidationError } from '@aave/core';\nimport type { InsufficientLiquidityError, SwapQuote } from '@aave/graphql';\nimport {\n QuoteAccuracy,\n WithdrawSwapQuoteQuery,\n type WithdrawSwapQuoteRequest,\n} from '@aave/graphql';\nimport type { NullishDeep, Prettify } from '@aave/types';\n\nimport { useAaveClient } from '../context';\nimport {\n type Pausable,\n type PausableReadResult,\n type PausableSuspenseResult,\n type ReadResult,\n type Suspendable,\n type SuspendableResult,\n type SuspenseResult,\n useSuspendableQuery,\n} from '../helpers';\nimport { type UseAsyncTask, useAsyncTask } from '../helpers/tasks';\n\nimport {\n type CurrencyQueryOptions,\n DEFAULT_QUERY_OPTIONS,\n extractPositionSwapQuote,\n} from './helpers';\n\nfunction injectWithdrawSwapQuoteAccuracy(\n request: NullishDeep<WithdrawSwapQuoteRequest>,\n accuracy: QuoteAccuracy,\n): NullishDeep<WithdrawSwapQuoteRequest> {\n if ('market' in request && request.market) {\n return { market: { ...request.market, accuracy } };\n }\n return request;\n}\n\nexport type UseWithdrawSwapQuoteArgs = Prettify<\n WithdrawSwapQuoteRequest & CurrencyQueryOptions\n>;\n\n/**\n * Fetch a quote for a withdraw swap operation with the specified parameters.\n *\n * This signature supports React Suspense:\n *\n * ```tsx\n * const { data } = useWithdrawSwapQuote({\n * market: {\n * position: userSupplyItem.id,\n * buyReserve: reserve.id,\n * amount: bigDecimal('1000'),\n * user: evmAddress('0x742d35cc…'),\n * },\n * suspense: true,\n * });\n * ```\n */\nexport function useWithdrawSwapQuote(\n args: UseWithdrawSwapQuoteArgs & Suspendable,\n): SuspenseResult<SwapQuote>;\n/**\n * Fetch a quote for a withdraw swap operation with the specified parameters.\n *\n * Pausable suspense mode.\n *\n * ```tsx\n * const { data } = useWithdrawSwapQuote({\n * market: {\n * position: userSupplyItem.id,\n * buyReserve: reserve.id,\n * amount: bigDecimal('1000'),\n * user: evmAddress('0x742d35cc…'),\n * },\n * suspense: true,\n * pause: true,\n * });\n * ```\n */\nexport function useWithdrawSwapQuote(\n args: Pausable<UseWithdrawSwapQuoteArgs> & Suspendable,\n): PausableSuspenseResult<SwapQuote>;\n/**\n * Fetch a quote for a withdraw swap operation with the specified parameters.\n *\n * ```tsx\n * const { data, error, loading } = useWithdrawSwapQuote({\n * market: {\n * position: userSupplyItem.id,\n * buyReserve: reserve.id,\n * amount: bigDecimal('1000'),\n * user: evmAddress('0x742d35cc…'),\n * },\n * });\n * ```\n */\nexport function useWithdrawSwapQuote(\n args: UseWithdrawSwapQuoteArgs,\n): ReadResult<SwapQuote>;\n/**\n * Fetch a quote for a withdraw swap operation with the specified parameters.\n *\n * Pausable loading state mode.\n *\n * ```tsx\n * const { data, error, loading, paused } = useWithdrawSwapQuote({\n * market: {\n * position: userSupplyItem.id,\n * buyReserve: reserve.id,\n * amount: bigDecimal('1000'),\n * user: evmAddress('0x742d35cc…'),\n * },\n * pause: true,\n * });\n * ```\n */\nexport function useWithdrawSwapQuote(\n args: Pausable<UseWithdrawSwapQuoteArgs>,\n): PausableReadResult<SwapQuote>;\n\nexport function useWithdrawSwapQuote({\n suspense = false,\n pause = false,\n currency = DEFAULT_QUERY_OPTIONS.currency,\n ...request\n}: NullishDeep<UseWithdrawSwapQuoteArgs> & {\n suspense?: boolean;\n pause?: boolean;\n}): SuspendableResult<\n SwapQuote,\n UnexpectedError | ValidationError<InsufficientLiquidityError>\n> {\n const client = useAaveClient();\n\n // Fast query - no polling, suspends in suspense mode for quick initial render\n const fastResult = useSuspendableQuery({\n document: WithdrawSwapQuoteQuery,\n variables: {\n request: injectWithdrawSwapQuoteAccuracy(request, QuoteAccuracy.Fast),\n currency,\n },\n selector: extractPositionSwapQuote,\n suspense,\n pause,\n batch: false, // Don't batch with Accurate query\n });\n\n // Accurate query - with polling, never suspends, fires after Fast in suspense mode\n const accurateResult = useSuspendableQuery({\n document: WithdrawSwapQuoteQuery,\n variables: {\n request: injectWithdrawSwapQuoteAccuracy(request, QuoteAccuracy.Accurate),\n currency,\n },\n selector: extractPositionSwapQuote,\n suspense: false, // Never suspend on Accurate (would cause re-suspend)\n pause: pause || (suspense && !fastResult.data),\n pollInterval: client.context.environment.swapQuoteInterval,\n batch: false, // Don't batch with Fast query\n });\n\n if (accurateResult.data) {\n return accurateResult;\n }\n\n return fastResult;\n}\n\n/**\n * Low-level hook to execute a withdraw swap quote action directly.\n *\n * @remarks\n * This hook **does not** actively watch for updated data on the swap quote.\n * Use this hook to retrieve quotes on demand as part of a larger workflow.\n *\n * ```ts\n * const [getQuote, { called, data, error, loading }] = useWithdrawSwapQuoteAction();\n *\n * // …\n *\n * const result = await getQuote({\n * position: userSupplyItem.id,\n * buyReserve: reserve.id,\n * amount: bigDecimal('1000'),\n * user: evmAddress('0x742d35cc…'),\n * });\n *\n * if (result.isOk()) {\n * console.log('Withdraw swap quote:', result.value);\n * } else {\n * console.error(result.error);\n * }\n * ```\n */\nexport function useWithdrawSwapQuoteAction(\n options: Required<CurrencyQueryOptions> = DEFAULT_QUERY_OPTIONS,\n): UseAsyncTask<\n WithdrawSwapQuoteRequest,\n SwapQuote,\n UnexpectedError | ValidationError<InsufficientLiquidityError>\n> {\n const client = useAaveClient();\n\n return useAsyncTask(\n (request: WithdrawSwapQuoteRequest) =>\n withdrawSwapQuote(client, request, {\n currency: options.currency,\n requestPolicy: 'network-only',\n }).andThen(extractPositionSwapQuote),\n [client, options.currency],\n );\n}\n","import {\n type ActivitiesRequest,\n type CurrencyQueryOptions,\n DEFAULT_QUERY_OPTIONS,\n type PaginatedActivitiesResult,\n type TimeWindowQueryOptions,\n type UnexpectedError,\n} from '@aave/client';\nimport { activities } from '@aave/client/actions';\nimport { ActivitiesQuery } from '@aave/graphql';\nimport type { NullishDeep, Prettify } from '@aave/types';\n\nimport { useAaveClient } from '../context';\nimport {\n type Pausable,\n type PausableReadResult,\n type PausableSuspenseResult,\n type ReadResult,\n type Suspendable,\n type SuspendableResult,\n type SuspenseResult,\n type UseAsyncTask,\n useAsyncTask,\n useSuspendableQuery,\n} from '../helpers';\n\nexport type UseActivitiesArgs = Prettify<\n ActivitiesRequest & CurrencyQueryOptions & TimeWindowQueryOptions\n>;\n\n/**\n * Fetch paginated list of activities.\n *\n * This signature supports React Suspense:\n *\n * ```tsx\n * const { data } = useActivities({\n * query: {\n * chainId: chainId(1),\n * },\n * user: evmAddress('0x742d35cc…'),\n * suspense: true,\n * });\n *\n * // data.items: ActivityItem[]\n * ```\n */\nexport function useActivities(\n args: UseActivitiesArgs & Suspendable,\n): SuspenseResult<PaginatedActivitiesResult>;\n/**\n * Fetch paginated list of activities.\n *\n * Pausable suspense mode.\n *\n * ```tsx\n * const { data } = useActivities({\n * query: {\n * chainId: chainId(1),\n * },\n * user: evmAddress('0x742d35cc…'),\n * suspense: true,\n * pause: true,\n * });\n *\n * // data?.items: ActivityItem[] | undefined\n * ```\n */\nexport function useActivities(\n args: Pausable<UseActivitiesArgs> & Suspendable,\n): PausableSuspenseResult<PaginatedActivitiesResult>;\n/**\n * Fetch paginated list of activities.\n *\n * ```tsx\n * const { data, error, loading } = useActivities({\n * query: {\n * chainId: chainId(1),\n * },\n * user: evmAddress('0x742d35cc…'),\n * });\n * ```\n */\nexport function useActivities(\n args: UseActivitiesArgs,\n): ReadResult<PaginatedActivitiesResult>;\n/**\n * Fetch paginated list of activities.\n *\n * Pausable loading state mode.\n *\n * ```tsx\n * const { data, error, loading } = useActivities({\n * query: {\n * chainId: chainId(1),\n * },\n * user: evmAddress('0x742d35cc…'),\n * pause: true,\n * });\n *\n * // data?.items: ActivityItem[] | undefined\n * // error: UnexpectedError | undefined\n * // loading: boolean | undefined\n * ```\n */\nexport function useActivities(\n args: Pausable<UseActivitiesArgs>,\n): PausableReadResult<PaginatedActivitiesResult>;\n\nexport function useActivities({\n suspense = false,\n pause = false,\n currency = DEFAULT_QUERY_OPTIONS.currency,\n timeWindow = DEFAULT_QUERY_OPTIONS.timeWindow,\n ...request\n}: NullishDeep<UseActivitiesArgs> & {\n suspense?: boolean;\n pause?: boolean;\n}): SuspendableResult<PaginatedActivitiesResult, UnexpectedError> {\n return useSuspendableQuery({\n document: ActivitiesQuery,\n variables: {\n request,\n currency,\n timeWindow,\n },\n suspense,\n pause,\n });\n}\n\n/**\n * Low-level hook to execute a {@link activities} action directly.\n *\n * @experimental This hook is experimental and may be subject to breaking changes.\n * @remarks\n * This hook does not actively watch for updates. Use it to fetch activities on demand\n * (e.g., in an event handler when paginating or refining filters).\n *\n * @param options - The query options.\n * @returns The user history.\n */\nexport function useActivitiesAction(\n options: CurrencyQueryOptions &\n TimeWindowQueryOptions = DEFAULT_QUERY_OPTIONS,\n): UseAsyncTask<ActivitiesRequest, PaginatedActivitiesResult, UnexpectedError> {\n const client = useAaveClient();\n\n return useAsyncTask(\n (request: ActivitiesRequest) =>\n activities(client, request, {\n currency: options.currency ?? DEFAULT_QUERY_OPTIONS.currency,\n timeWindow: options.timeWindow ?? DEFAULT_QUERY_OPTIONS.timeWindow,\n requestPolicy: 'cache-first',\n }),\n [client, options.currency, options.timeWindow],\n );\n}\n","import { type TransactionReceipt, UnexpectedError } from '@aave/client';\nimport { borrow } from '@aave/client/actions';\nimport { ValidationError } from '@aave/core';\nimport type {\n BorrowRequest,\n InsufficientBalanceError,\n PreContractActionRequired,\n TransactionRequest,\n} from '@aave/graphql';\nimport { errAsync } from '@aave/types';\n\nimport { useAaveClient } from '../context';\nimport {\n cancel,\n type ExecutionPlanHandler,\n type PendingTransaction,\n type PendingTransactionError,\n refreshQueriesForReserveChange,\n type SendTransactionError,\n type UseAsyncTask,\n useAsyncTask,\n} from '../helpers';\n\n/**\n * A hook that provides a way to borrow assets from an Aave reserve.\n *\n * ```ts\n * const [sendTransaction] = useSendTransaction(wallet);\n * const [borrow, { loading, error }] = useBorrow((plan, { cancel }) => {\n * switch (plan.__typename) {\n * case 'TransactionRequest':\n * return sendTransaction(plan);\n *\n * case 'PreContractActionRequired':\n * return sendTransaction(plan.transaction);\n * }\n * });\n *\n * // …\n *\n * const result = await borrow({ ... });\n *\n * if (result.isErr()) {\n * switch (result.error.name) {\n * case 'CancelError':\n * // The user cancelled the operation\n * return;\n *\n * case 'SigningError':\n * console.error(`Failed to sign the transaction: ${result.error.message}`);\n * break;\n *\n * case 'TimeoutError':\n * console.error(`Transaction timed out: ${result.error.message}`);\n * break;\n *\n * case 'TransactionError':\n * console.error(`Transaction failed: ${result.error.message}`);\n * break;\n *\n * case 'ValidationError':\n * console.error(`Insufficient balance: ${result.error.cause.required.value} required.`);\n * break;\n *\n * case 'UnexpectedError':\n * console.error(result.error.message);\n * break;\n * }\n * return;\n * }\n *\n * console.log('Transaction sent with hash:', result.value.txHash);\n * ```\n *\n * @param handler - The handler that will be used to handle the transactions.\n */\nexport function useBorrow(\n handler: ExecutionPlanHandler<\n TransactionRequest | PreContractActionRequired,\n PendingTransaction\n >,\n): UseAsyncTask<\n BorrowRequest,\n TransactionReceipt,\n | SendTransactionError\n | PendingTransactionError\n | ValidationError<InsufficientBalanceError>\n> {\n const client = useAaveClient();\n\n return useAsyncTask(\n (request: BorrowRequest) =>\n borrow(client, request)\n .andThen((plan) => {\n switch (plan.__typename) {\n case 'TransactionRequest':\n return handler(plan, { cancel });\n\n case 'PreContractActionRequired':\n return handler(plan, { cancel })\n .andThen((pending) => pending.wait())\n .andThen(() => handler(plan.originalTransaction, { cancel }));\n\n case 'InsufficientBalanceError':\n return errAsync(ValidationError.fromGqlNode(plan));\n\n case 'Erc20ApprovalRequired':\n return UnexpectedError.from(plan).asResultAsync();\n }\n })\n .andThen((pending) => pending.wait())\n .andThen(client.waitForTransaction)\n .andThrough(() => refreshQueriesForReserveChange(client, request)),\n [client, handler],\n );\n}\n","import { type TransactionReceipt, transactionReceipt } from '@aave/client';\nimport { claimRewards } from '@aave/client/actions';\nimport type { ClaimRewardsRequest, TransactionRequest } from '@aave/graphql';\n\nimport { useAaveClient } from '../context';\nimport {\n cancel,\n type ExecutionPlanHandler,\n PendingTransaction,\n type PendingTransactionError,\n type SendTransactionError,\n type UseAsyncTask,\n useAsyncTask,\n} from '../helpers';\n\n/**\n * A hook that provides a way to claim rewards.\n *\n * ```ts\n * const [sendTransaction] = useSendTransaction(wallet);\n * const [claim, { loading, error }] = useClaimRewards((transaction, { cancel }) => {\n * return sendTransaction(transaction);\n * });\n *\n * // …\n *\n * const result = await claim({\n * ids: [rewardId('abc123')],\n * });\n *\n * if (result.isErr()) {\n * switch (result.error.name) {\n * case 'CancelError':\n * // The user cancelled the operation\n * return;\n *\n * case 'SigningError':\n * console.error(`Failed to sign the transaction: ${result.error.message}`);\n * break;\n *\n * case 'TimeoutError':\n * console.error(`Transaction timed out: ${result.error.message}`);\n * break;\n *\n * case 'TransactionError':\n * console.error(`Transaction failed: ${result.error.message}`);\n * break;\n *\n * case 'UnexpectedError':\n * console.error(result.error.message);\n * break;\n * }\n * return;\n * }\n *\n * console.log('Transaction sent with hash:', result.value.txHash);\n * ```\n *\n * @param handler - The handler that will be used to handle the transaction.\n */\nexport function useClaimRewards(\n handler: ExecutionPlanHandler<TransactionRequest, PendingTransaction>,\n): UseAsyncTask<\n ClaimRewardsRequest,\n TransactionReceipt,\n SendTransactionError | PendingTransactionError\n> {\n const client = useAaveClient();\n\n return useAsyncTask(\n (request: ClaimRewardsRequest) =>\n claimRewards(client, request)\n .andThen((transaction) => handler(transaction, { cancel }))\n .andThen(PendingTransaction.tryFrom)\n .andThen((pending) => pending.wait())\n .map((result) => transactionReceipt(result.txHash)),\n [client, handler],\n );\n}\n","import type { UnexpectedError } from '@aave/client';\nimport type {\n ERC20PermitSignature,\n Erc20Approval,\n Erc20ApprovalRequired,\n ExecutionPlan,\n PermitTypedData,\n TransactionRequest,\n} from '@aave/graphql';\nimport {\n expectTypename,\n isSignature,\n okAsync,\n type ResultAsync,\n type Signature,\n} from '@aave/types';\n\nimport {\n cancel,\n type ExecutionPlanHandler,\n PendingTransaction,\n type PendingTransactionError,\n type SendTransactionError,\n} from '../helpers';\n\nexport type ApprovalHandler = ExecutionPlanHandler<\n TransactionRequest | Erc20Approval,\n Signature | PendingTransaction\n>;\n\nfunction toPermitSignature(\n signature: Signature,\n permitTypedData: PermitTypedData,\n): ERC20PermitSignature {\n return {\n deadline: permitTypedData.message.deadline as number,\n value: signature,\n };\n}\n\n/**\n * Sends all approvals sequentially via transactions (no permit).\n */\nexport function sendApprovalTransactions(\n plan: Erc20ApprovalRequired,\n handler: ApprovalHandler,\n): ResultAsync<\n TransactionRequest,\n SendTransactionError | PendingTransactionError\n> {\n return plan.approvals\n .reduce<\n ResultAsync<unknown, SendTransactionError | PendingTransactionError>\n >(\n (chain, approval) =>\n chain.andThen(() =>\n handler({ ...approval, bySignature: null }, { cancel })\n .andThen(PendingTransaction.tryFrom)\n .andThen((pending) => pending.wait()),\n ),\n okAsync(undefined),\n )\n .map(() => plan.originalTransaction);\n}\n\ntype SingleApprovalPlan = Erc20ApprovalRequired & {\n approvals: [Erc20Approval & { bySignature: PermitTypedData }];\n};\n\n/**\n * Processes a single approval that supports permit.\n * The handler decides whether to use a permit signature or a transaction.\n * Returns either a new TransactionRequest (from permit callback) or the plan's original transaction.\n */\nexport function handleSingleApproval(\n plan: SingleApprovalPlan,\n handler: ApprovalHandler,\n onPermit: (\n permitSig: ERC20PermitSignature,\n ) => ResultAsync<ExecutionPlan, UnexpectedError>,\n): ResultAsync<\n TransactionRequest,\n SendTransactionError | PendingTransactionError | UnexpectedError\n> {\n const approval = plan.approvals[0];\n\n return handler(approval, { cancel }).andThen((result) => {\n if (isSignature(result)) {\n return onPermit(toPermitSignature(result, approval.bySignature)).map(\n expectTypename('TransactionRequest'),\n );\n }\n return result.wait().map(() => plan.originalTransaction);\n });\n}\n","import { supportsPermit, type TransactionReceipt } from '@aave/client';\nimport { liquidatePosition } from '@aave/client/actions';\nimport { ValidationError } from '@aave/core';\nimport type {\n ERC20PermitSignature,\n Erc20Approval,\n InsufficientBalanceError,\n LiquidatePositionRequest,\n PreContractActionRequired,\n TransactionRequest,\n} from '@aave/graphql';\nimport { errAsync, type Signature } from '@aave/types';\n\nimport { useAaveClient } from '../context';\nimport {\n cancel,\n type ExecutionPlanHandler,\n PendingTransaction,\n type PendingTransactionError,\n type SendTransactionError,\n type UseAsyncTask,\n useAsyncTask,\n} from '../helpers';\n\nimport { handleSingleApproval, sendApprovalTransactions } from './approvals';\n\nfunction injectLiquidatePermitSignature(\n request: LiquidatePositionRequest,\n _permitSig: ERC20PermitSignature,\n): LiquidatePositionRequest {\n // TODO inject permitSig in the appropriate place once supported in the GQL schema\n return request;\n}\n\n/**\n * A hook that provides a way to liquidate a user's position.\n *\n * ```ts\n * const [sendTransaction] = useSendTransaction(wallet);\n * const [liquidatePosition, { loading, error }] = useLiquidatePosition((plan, { cancel }) => {\n * switch (plan.__typename) {\n * case 'TransactionRequest':\n * return sendTransaction(plan);\n *\n * case 'Erc20Approval':\n * return sendTransaction(plan.byTransaction);\n *\n * case 'PreContractActionRequired':\n * return sendTransaction(plan.transaction);\n * }\n * });\n *\n * // …\n *\n * const result = await liquidatePosition({\n * collateral: reserveId('SGVsbG8h'),\n * debt: reserveId('Q2lhbyE= '),\n * amount: amount,\n * liquidator: liquidator,\n * borrower: borrower,\n * });\n *\n * if (result.isErr()) {\n * switch (result.error.name) {\n * case 'CancelError':\n * // The user cancelled the operation\n * return;\n *\n * case 'SigningError':\n * console.error(`Failed to sign the transaction: ${result.error.message}`);\n * break;\n *\n * case 'TimeoutError':\n * console.error(`Transaction timed out: ${result.error.message}`);\n * break;\n *\n * case 'TransactionError':\n * console.error(`Transaction failed: ${result.error.message}`);\n * break;\n *\n * case 'ValidationError':\n * console.error(`Insufficient balance: ${result.error.cause.required.value} required.`);\n * break;\n *\n * case 'UnexpectedError':\n * console.error(result.error.message);\n * break;\n * }\n * return;\n * }\n *\n * console.log('Transaction sent with hash:', result.value.txHash);\n * ```\n *\n * @param handler - The handler that will be used to handle the transactions.\n */\nexport function useLiquidatePosition(\n handler: ExecutionPlanHandler<\n TransactionRequest | Erc20Approval | PreContractActionRequired,\n PendingTransaction | Signature\n >,\n): UseAsyncTask<\n LiquidatePositionRequest,\n TransactionReceipt,\n | SendTransactionError\n | PendingTransactionError\n | ValidationError<InsufficientBalanceError>\n> {\n const client = useAaveClient();\n\n return useAsyncTask(\n (request: LiquidatePositionRequest) =>\n // TODO: update the relevant read queries\n liquidatePosition(client, request)\n .andThen((plan) => {\n switch (plan.__typename) {\n case 'TransactionRequest':\n return handler(plan, { cancel });\n\n case 'Erc20ApprovalRequired':\n if (supportsPermit(plan)) {\n return handleSingleApproval(plan, handler, (permitSig) =>\n liquidatePosition(\n client,\n injectLiquidatePermitSignature(request, permitSig),\n ),\n ).andThen((transaction) => handler(transaction, { cancel }));\n }\n return sendApprovalTransactions(plan, handler).andThen(\n (transaction) => handler(transaction, { cancel }),\n );\n\n case 'PreContractActionRequired':\n return handler(plan, { cancel })\n .andThen(PendingTransaction.tryFrom)\n .andThen((pending) => pending.wait())\n .andThen(() => handler(plan.originalTransaction, { cancel }));\n\n case 'InsufficientBalanceError':\n return errAsync(ValidationError.fromGqlNode(plan));\n }\n })\n .andThen(PendingTransaction.tryFrom)\n .andThen((pending) => pending.wait())\n .andThen(client.waitForTransaction),\n [client, handler],\n );\n}\n","import {\n type CurrencyQueryOptions,\n DEFAULT_QUERY_OPTIONS,\n type UnexpectedError,\n} from '@aave/client';\nimport { preview } from '@aave/client/actions';\nimport {\n PreviewQuery,\n type PreviewRequest,\n type PreviewUserPosition,\n} from '@aave/graphql';\nimport type { NullishDeep, Prettify } from '@aave/types';\n\nimport { useAaveClient } from '../context';\nimport {\n type Pausable,\n type PausableReadResult,\n type PausableSuspenseResult,\n type ReadResult,\n type Suspendable,\n type SuspendableResult,\n type SuspenseResult,\n type UseAsyncTask,\n useAsyncTask,\n useSuspendableQuery,\n} from '../helpers';\n\n/**\n * Preview the impact of a potential action on a user's position.\n *\n * ```tsx\n * const [getPreview, previewing] = usePreviewAction();\n *\n * const loading = previewing.loading;\n * const error = previewing.error;\n *\n * // …\n *\n * const result = await getPreview({\n * action: {\n * supply: {\n * reserve: reserveId('SGVsbG8h'),\n * amount: {\n * erc20: {\n * value: '1000',\n * },\n * },\n * sender: evmAddress('0x9abc…'),\n * },\n * },\n * });\n *\n * if (result.isErr()) {\n * console.error(result.error);\n * return;\n * }\n *\n * console.log('Preview result:', result.value);\n * ```\n */\nexport function usePreviewAction(\n options: Required<CurrencyQueryOptions> = DEFAULT_QUERY_OPTIONS,\n): UseAsyncTask<PreviewRequest, PreviewUserPosition, UnexpectedError> {\n const client = useAaveClient();\n\n return useAsyncTask(\n (request: PreviewRequest) =>\n preview(client, request, {\n currency: options.currency,\n requestPolicy: 'network-only',\n }),\n [client, options.currency],\n );\n}\n\nexport type UsePreviewArgs = Prettify<PreviewRequest & CurrencyQueryOptions>;\n\n/**\n * Fetch a preview of the impact of a potential action on a user's position.\n *\n * This signature supports React Suspense:\n *\n * ```tsx\n * const { data } = usePreview({\n * action: {\n * supply: {\n * reserve: reserveId('SGVsbG8h'),\n * amount: {\n * erc20: {\n * currency: evmAddress('0x5678…'),\n * value: '1000',\n * },\n * },\n * supplier: evmAddress('0x9abc…'),\n * },\n * },\n * suspense: true,\n * });\n * ```\n */\nexport function usePreview(\n args: UsePreviewArgs & Suspendable,\n): SuspenseResult<PreviewUserPosition>;\n/**\n * Fetch a preview of the impact of a potential action on a user's position.\n *\n * Pausable suspense mode.\n *\n * ```tsx\n * const { data } = usePreview({\n * action: {\n * supply: {\n * reserve: reserveId('SGVsbG8h'),\n * amount: {\n * erc20: {\n * currency: evmAddress('0x5678…'),\n * value: '1000',\n * },\n * },\n * supplier: evmAddress('0x9abc…'),\n * },\n * },\n * suspense: true,\n * pause: true,\n * });\n * ```\n */\nexport function usePreview(\n args: Pausable<UsePreviewArgs> & Suspendable,\n): PausableSuspenseResult<PreviewUserPosition>;\n/**\n * Fetch a preview of the impact of a potential action on a user's position.\n *\n * ```tsx\n * const { data, error, loading } = usePreview({\n * action: {\n * supply: {\n * reserve: reserveId('SGVsbG8h'),\n * amount: {\n * erc20: {\n * currency: evmAddress('0x5678…'),\n * value: '1000',\n * },\n * },\n * supplier: evmAddress('0x9abc…'),\n * },\n * },\n * });\n * ```\n */\nexport function usePreview(\n args: UsePreviewArgs,\n): ReadResult<PreviewUserPosition>;\n/**\n * Fetch a preview of the impact of a potential action on a user's position.\n *\n * Pausable loading state mode.\n *\n * ```tsx\n * const { data, error, loading, paused } = usePreview({\n * action: {\n * supply: {\n * reserve: reserveId('SGVsbG8h'),\n * amount: {\n * erc20: {\n * currency: evmAddress('0x5678…'),\n * value: '1000',\n * },\n * },\n * supplier: evmAddress('0x9abc…'),\n * },\n * },\n * pause: true,\n * });\n * ```\n */\nexport function usePreview(\n args: Pausable<UsePreviewArgs>,\n): PausableReadResult<PreviewUserPosition>;\n\nexport function usePreview({\n suspense = false,\n pause = false,\n currency = DEFAULT_QUERY_OPTIONS.currency,\n ...request\n}: NullishDeep<UsePreviewArgs> & {\n suspense?: boolean;\n pause?: boolean;\n}): SuspendableResult<PreviewUserPosition, UnexpectedError> {\n return useSuspendableQuery({\n document: PreviewQuery,\n variables: {\n request,\n currency,\n },\n suspense,\n pause,\n });\n}\n","import type { TransactionReceipt } from '@aave/client';\nimport { renounceSpokeUserPositionManager } from '@aave/client/actions';\nimport type {\n RenounceSpokeUserPositionManagerRequest,\n TransactionRequest,\n} from '@aave/graphql';\n\nimport { useAaveClient } from '../context';\nimport {\n cancel,\n type ExecutionPlanHandler,\n type PendingTransaction,\n type PendingTransactionError,\n refreshSpokePositionManagers,\n type SendTransactionError,\n type UseAsyncTask,\n useAsyncTask,\n} from '../helpers';\n\n/**\n * A hook that provides a way to renounce a position manager of a user for a specific spoke.\n *\n * ```ts\n * const [sendTransaction] = useSendTransaction(wallet);\n * const [renounceSpokeUserPositionManager, { loading, error }] = useRenounceSpokeUserPositionManager(sendTransaction);\n *\n * // …\n *\n * const result = await renounceSpokeUserPositionManager({ ... });\n *\n * if (result.isErr()) {\n * switch (result.error.name) {\n * case 'CancelError':\n * // The user cancelled the operation\n * return;\n *\n * case 'SigningError':\n * console.error(`Failed to sign the transaction: ${result.error.message}`);\n * break;\n *\n * case 'TimeoutError':\n * console.error(`Transaction timed out: ${result.error.message}`);\n * break;\n *\n * case 'TransactionError':\n * console.error(`Transaction failed: ${result.error.message}`);\n * break;\n *\n * case 'UnexpectedError':\n * console.error(result.error.message);\n * break;\n * }\n * return;\n * }\n *\n * console.log('Transaction sent with hash:', result.value.txHash);\n * ```\n *\n * @param handler - The handler that will be used to handle the transaction.\n */\n\nexport function useRenounceSpokeUserPositionManager(\n handler: ExecutionPlanHandler<TransactionRequest, PendingTransaction>,\n): UseAsyncTask<\n RenounceSpokeUserPositionManagerRequest,\n TransactionReceipt,\n SendTransactionError | PendingTransactionError\n> {\n const client = useAaveClient();\n\n return useAsyncTask(\n (request: RenounceSpokeUserPositionManagerRequest) =>\n renounceSpokeUserPositionManager(client, request)\n .andThen((transaction) => handler(transaction, { cancel }))\n .andThen((pending) => pending.wait())\n .andThen(client.waitForTransaction)\n .andThrough(() => refreshSpokePositionManagers(client, request.spoke)),\n [client, handler],\n );\n}\n","import { supportsPermit, type TransactionReceipt } from '@aave/client';\nimport { repay } from '@aave/client/actions';\nimport { ValidationError } from '@aave/core';\nimport type {\n ERC20PermitSignature,\n Erc20Approval,\n InsufficientBalanceError,\n PreContractActionRequired,\n RepayRequest,\n TransactionRequest,\n} from '@aave/graphql';\nimport { errAsync, type Signature } from '@aave/types';\n\nimport { useAaveClient } from '../context';\nimport {\n cancel,\n type ExecutionPlanHandler,\n PendingTransaction,\n type PendingTransactionError,\n refreshQueriesForReserveChange,\n type SendTransactionError,\n type UseAsyncTask,\n useAsyncTask,\n} from '../helpers';\nimport { handleSingleApproval, sendApprovalTransactions } from './approvals';\n\nfunction injectRepayPermitSignature(\n request: RepayRequest,\n permitSig: ERC20PermitSignature,\n): RepayRequest {\n if ('erc20' in request.amount) {\n return {\n ...request,\n amount: {\n erc20: {\n ...request.amount.erc20,\n permitSig,\n },\n },\n };\n }\n return request;\n}\n\n/**\n * A hook that provides a way to repay borrowed assets to an Aave reserve.\n *\n * ```ts\n * const [sendTransaction] = useSendTransaction(wallet);\n * const [repay, { loading, error }] = useRepay((plan, { cancel }) => {\n * switch (plan.__typename) {\n * case 'TransactionRequest':\n * return sendTransaction(plan);\n *\n * case 'Erc20Approval':\n * return sendTransaction(plan.byTransaction);\n *\n * case 'PreContractActionRequired':\n * return sendTransaction(plan.transaction);\n * }\n * });\n *\n * // …\n *\n * const result = await repay({ ... });\n *\n * if (result.isErr()) {\n * switch (result.error.name) {\n * case 'CancelError':\n * // The user cancelled the operation\n * return;\n *\n * case 'SigningError':\n * console.error(`Failed to sign the transaction: ${result.error.message}`);\n * break;\n *\n * case 'TimeoutError':\n * console.error(`Transaction timed out: ${result.error.message}`);\n * break;\n *\n * case 'TransactionError':\n * console.error(`Transaction failed: ${result.error.message}`);\n * break;\n *\n * case 'ValidationError':\n * console.error(`Insufficient balance: ${result.error.cause.required.value} required.`);\n * break;\n *\n * case 'UnexpectedError':\n * console.error(result.error.message);\n * break;\n * }\n * return;\n * }\n *\n * console.log('Transaction sent with hash:', result.value.txHash);\n * ```\n *\n * @param handler - The handler that will be used to handle the transactions.\n */\nexport function useRepay(\n handler: ExecutionPlanHandler<\n TransactionRequest | Erc20Approval | PreContractActionRequired,\n Signature | PendingTransaction\n >,\n): UseAsyncTask<\n RepayRequest,\n TransactionReceipt,\n | SendTransactionError\n | PendingTransactionError\n | ValidationError<InsufficientBalanceError>\n> {\n const client = useAaveClient();\n\n return useAsyncTask(\n (request: RepayRequest) =>\n repay(client, request)\n .andThen((plan) => {\n switch (plan.__typename) {\n case 'TransactionRequest':\n return handler(plan, { cancel });\n\n case 'Erc20ApprovalRequired':\n if (supportsPermit(plan)) {\n return handleSingleApproval(plan, handler, (permitSig) =>\n repay(client, injectRepayPermitSignature(request, permitSig)),\n ).andThen((transaction) => handler(transaction, { cancel }));\n }\n return sendApprovalTransactions(plan, handler).andThen(\n (transaction) => handler(transaction, { cancel }),\n );\n\n case 'PreContractActionRequired':\n return handler(plan, { cancel })\n .andThen(PendingTransaction.tryFrom)\n .andThen((pending) => pending.wait())\n .andThen(() => handler(plan.originalTransaction, { cancel }));\n\n case 'InsufficientBalanceError':\n return errAsync(ValidationError.fromGqlNode(plan));\n }\n })\n .andThen(PendingTransaction.tryFrom)\n .andThen((pending) => pending.wait())\n .andThen(client.waitForTransaction)\n .andThrough(() => refreshQueriesForReserveChange(client, request)),\n [client, handler],\n );\n}\n","import type { TransactionReceipt } from '@aave/client';\nimport { setSpokeUserPositionManager } from '@aave/client/actions';\nimport type {\n SetSpokeUserPositionManagerRequest,\n TransactionRequest,\n} from '@aave/graphql';\n\nimport { useAaveClient } from '../context';\nimport {\n cancel,\n type ExecutionPlanHandler,\n type PendingTransaction,\n type PendingTransactionError,\n refreshSpokePositionManagers,\n type SendTransactionError,\n type UseAsyncTask,\n useAsyncTask,\n} from '../helpers';\n\n/**\n * A hook that provides a way to set or remove a position manager for a user on a specific spoke.\n *\n * **Position managers** can perform transactions on behalf of other users, including:\n * - Supply assets\n * - Borrow assets\n * - Withdraw assets\n * - Enable/disable collateral\n *\n * The `signature` parameter is an **ERC712 signature** that must be signed by the **user**\n * (the account granting permissions) to authorize the position manager. The signature contains:\n * - `value`: The actual cryptographic signature\n * - `deadline`: Unix timestamp when the authorization expires\n *\n * ```ts\n * const [sendTransaction] = useSendTransaction(wallet);\n * const [setSpokeUserPositionManager, { loading, error }] = useSetSpokeUserPositionManager((transaction, { cancel }) => {\n * return sendTransaction(transaction);\n * });\n *\n * const result = await setSpokeUserPositionManager({\n * spoke: spokeId('SGVsbG8h'),\n * manager: evmAddress('0x9abc…'), // Address that will become the position manager\n * approve: true, // true to approve, false to remove the manager\n * user: evmAddress('0xdef0…'), // User granting the permission (must sign the signature)\n * signature: {\n * value: '0x1234...', // ERC712 signature signed by the user\n * deadline: 1735689600, // Unix timestamp when signature expires\n * },\n * });\n *\n * if (result.isErr()) {\n * switch (result.error.name) {\n * case 'CancelError':\n * // The user cancelled the operation\n * return;\n *\n * case 'SigningError':\n * console.error(`Failed to sign the transaction: ${result.error.message}`);\n * break;\n *\n * case 'TimeoutError':\n * console.error(`Transaction timed out: ${result.error.message}`);\n * break;\n *\n * case 'TransactionError':\n * console.error(`Transaction failed: ${result.error.message}`);\n * break;\n *\n * case 'UnexpectedError':\n * console.error(result.error.message);\n * break;\n * }\n * return;\n * }\n *\n * console.log('Transaction sent with hash:', result.value.txHash);\n * ```\n *\n * @param handler - The handler that will be used to handle the transaction.\n */\nexport function useSetSpokeUserPositionManager(\n handler: ExecutionPlanHandler<TransactionRequest, PendingTransaction>,\n): UseAsyncTask<\n SetSpokeUserPositionManagerRequest,\n TransactionReceipt,\n SendTransactionError | PendingTransactionError\n> {\n const client = useAaveClient();\n\n return useAsyncTask(\n (request: SetSpokeUserPositionManagerRequest) =>\n setSpokeUserPositionManager(client, request)\n .andThen((transaction) => handler(transaction, { cancel }))\n .andThen((pending) => pending.wait())\n .andThen(client.waitForTransaction)\n .andThrough(() => refreshSpokePositionManagers(client, request.spoke)),\n [client, handler],\n );\n}\n","import type { TransactionReceipt } from '@aave/client';\nimport { setUserSuppliesAsCollateral } from '@aave/client/actions';\nimport {\n decodeReserveId,\n type SetUserSuppliesAsCollateralRequest,\n type TransactionRequest,\n} from '@aave/graphql';\nimport { ResultAsync } from '@aave/types';\n\nimport { useAaveClient } from '../context';\nimport {\n cancel,\n type ExecutionPlanHandler,\n type PendingTransaction,\n type PendingTransactionError,\n refreshHubs,\n refreshReserves,\n refreshSpokes,\n refreshUserBorrows,\n refreshUserPositions,\n refreshUserSummary,\n refreshUserSupplies,\n type SendTransactionError,\n type UseAsyncTask,\n useAsyncTask,\n} from '../helpers';\n\n/**\n * Hook for updating the collateral status of user's supplies.\n *\n * ```ts\n * const [sendTransaction] = useSendTransaction(wallet);\n * const [setUserSuppliesAsCollateral, { loading, error }] = useSetUserSuppliesAsCollateral((transaction, { cancel }) => {\n * return sendTransaction(transaction);\n * });\n *\n * const result = await setUserSuppliesAsCollateral({\n * changes: [\n * {\n * reserve: reserve.id,\n * enableCollateral: true\n * }\n * ],\n * sender: evmAddress('0x456...')\n * });\n *\n * if (result.isErr()) {\n * switch (result.error.name) {\n * case 'CancelError':\n * // The user cancelled the operation\n * return;\n *\n * case 'SigningError':\n * console.error(`Failed to sign the transaction: ${result.error.message}`);\n * break;\n *\n * case 'TimeoutError':\n * console.error(`Transaction timed out: ${result.error.message}`);\n * break;\n *\n * case 'TransactionError':\n * console.error(`Transaction failed: ${result.error.message}`);\n * break;\n *\n * case 'UnexpectedError':\n * console.error(result.error.message);\n * break;\n * }\n * return;\n * }\n *\n * console.log('Transaction sent with hash:', result.value.txHash);\n * ```\n *\n * @param handler - The handler that will be used to handle the transaction.\n */\nexport function useSetUserSuppliesAsCollateral(\n handler: ExecutionPlanHandler<TransactionRequest, PendingTransaction>,\n): UseAsyncTask<\n SetUserSuppliesAsCollateralRequest,\n TransactionReceipt,\n SendTransactionError | PendingTransactionError\n> {\n const client = useAaveClient();\n\n return useAsyncTask(\n (request: SetUserSuppliesAsCollateralRequest) => {\n const reserveIds = request.changes.map((change) => change.reserve);\n const reserveDetails = reserveIds.map((reserveId) =>\n decodeReserveId(reserveId),\n );\n return setUserSuppliesAsCollateral(client, request)\n .andThen((transaction) => handler(transaction, { cancel }))\n .andThen((pending) => pending.wait())\n .andThen(client.waitForTransaction)\n .andThrough(() =>\n ResultAsync.combine([\n // update user supplies\n refreshUserSupplies(client, request.sender),\n\n // update user borrows\n refreshUserBorrows(client, request.sender),\n\n ...reserveDetails.flatMap(({ chainId, spoke }) => [\n // update user positions\n refreshUserPositions(client, request.sender, {\n chainId,\n address: spoke,\n }),\n\n // update user summary\n refreshUserSummary(client, request.sender, {\n chainId,\n address: spoke,\n }),\n\n // update spokes\n refreshSpokes(client, { chainId, address: spoke }),\n ]),\n\n // update reserves\n refreshReserves(client, reserveIds),\n\n // update hubs\n ...reserveDetails.map(({ chainId }) =>\n refreshHubs(client, chainId),\n ),\n ]),\n );\n },\n [client, handler],\n );\n}\n","import { supportsPermit, type TransactionReceipt } from '@aave/client';\nimport { supply } from '@aave/client/actions';\nimport { ValidationError } from '@aave/core';\nimport type {\n ERC20PermitSignature,\n Erc20Approval,\n InsufficientBalanceError,\n PreContractActionRequired,\n SupplyRequest,\n TransactionRequest,\n} from '@aave/graphql';\nimport { errAsync, type Signature } from '@aave/types';\n\nimport { useAaveClient } from '../context';\nimport {\n cancel,\n type ExecutionPlanHandler,\n PendingTransaction,\n type PendingTransactionError,\n refreshQueriesForReserveChange,\n type SendTransactionError,\n type UseAsyncTask,\n useAsyncTask,\n} from '../helpers';\nimport { handleSingleApproval, sendApprovalTransactions } from './approvals';\n\nfunction injectSupplyPermitSignature(\n request: SupplyRequest,\n permitSig: ERC20PermitSignature,\n): SupplyRequest {\n if ('erc20' in request.amount) {\n return {\n ...request,\n amount: {\n erc20: {\n ...request.amount.erc20,\n permitSig,\n },\n },\n };\n }\n return request;\n}\n\n/**\n * A hook that provides a way to supply assets to an Aave reserve.\n *\n * ```ts\n * const [sendTransaction] = useSendTransaction(wallet);\n * const [supply, { loading, error }] = useSupply((plan, { cancel }) => {\n * switch (plan.__typename) {\n * case 'TransactionRequest':\n * return sendTransaction(plan);\n *\n * case 'Erc20Approval':\n * return sendTransaction(plan.byTransaction);\n *\n * case 'PreContractActionRequired':\n * return sendTransaction(plan.transaction);\n * }\n * });\n *\n * // …\n *\n * const result = await supply({ ... });\n *\n * if (result.isErr()) {\n * switch (result.error.name) {\n * case 'CancelError':\n * // The user cancelled the operation\n * return;\n *\n * case 'SigningError':\n * console.error(`Failed to sign the transaction: ${result.error.message}`);\n * break;\n *\n * case 'TimeoutError':\n * console.error(`Transaction timed out: ${result.error.message}`);\n * break;\n *\n * case 'TransactionError':\n * console.error(`Transaction failed: ${result.error.message}`);\n * break;\n *\n * case 'ValidationError':\n * console.error(`Insufficient balance: ${result.error.cause.required.value} required.`);\n * break;\n *\n * case 'UnexpectedError':\n * console.error(result.error.message);\n * break;\n * }\n * return;\n * }\n *\n * console.log('Transaction sent with hash:', result.value.txHash);\n * ```\n *\n * @param handler - The handler that will be used to handle the transactions.\n */\nexport function useSupply(\n handler: ExecutionPlanHandler<\n TransactionRequest | Erc20Approval | PreContractActionRequired,\n Signature | PendingTransaction\n >,\n): UseAsyncTask<\n SupplyRequest,\n TransactionReceipt,\n | SendTransactionError\n | PendingTransactionError\n | ValidationError<InsufficientBalanceError>\n> {\n const client = useAaveClient();\n\n return useAsyncTask(\n (request: SupplyRequest) =>\n supply(client, request)\n .andThen((plan) => {\n switch (plan.__typename) {\n case 'TransactionRequest':\n return handler(plan, { cancel });\n\n case 'Erc20ApprovalRequired':\n if (supportsPermit(plan)) {\n return handleSingleApproval(plan, handler, (permitSig) =>\n supply(\n client,\n injectSupplyPermitSignature(request, permitSig),\n ),\n ).andThen((transaction) => handler(transaction, { cancel }));\n }\n return sendApprovalTransactions(plan, handler).andThen(\n (transaction) => handler(transaction, { cancel }),\n );\n\n case 'PreContractActionRequired':\n return handler(plan, { cancel })\n .andThen(PendingTransaction.tryFrom)\n .andThen((pending) => pending.wait())\n .andThen(() => handler(plan.originalTransaction, { cancel }));\n\n case 'InsufficientBalanceError':\n return errAsync(ValidationError.fromGqlNode(plan));\n }\n })\n .andThen(PendingTransaction.tryFrom)\n .andThen((pending) => pending.wait())\n .andThen(client.waitForTransaction)\n .andThrough(() => refreshQueriesForReserveChange(client, request)),\n [client, handler],\n );\n}\n","import type { TransactionReceipt } from '@aave/client';\nimport { updateUserPositionConditions } from '@aave/client/actions';\nimport type {\n TransactionRequest,\n UpdateUserPositionConditionsRequest,\n} from '@aave/graphql';\n\nimport { useAaveClient } from '../context';\nimport {\n cancel,\n type ExecutionPlanHandler,\n type PendingTransaction,\n type PendingTransactionError,\n refreshUserPositionById,\n type SendTransactionError,\n type UseAsyncTask,\n useAsyncTask,\n} from '../helpers';\n\n/**\n * Hook for updating user position conditions (dynamic config and/or risk premium).\n *\n * ```ts\n * const [sendTransaction] = useSendTransaction(wallet);\n * const [update, { loading, error }] = useUpdateUserPositionConditions((transaction, { cancel }) => {\n * return sendTransaction(transaction);\n * });\n *\n * // …\n *\n * const result = await update({\n * userPositionId: userPosition.id,\n * update: UserPositionConditionsUpdate.AllDynamicConfig,\n * });\n *\n * if (result.isErr()) {\n * switch (result.error.name) {\n * case 'CancelError':\n * // The user cancelled the operation\n * return;\n *\n * case 'SigningError':\n * console.error(`Failed to sign the transaction: ${result.error.message}`);\n * break;\n *\n * case 'TimeoutError':\n * console.error(`Transaction timed out: ${result.error.message}`);\n * break;\n *\n * case 'TransactionError':\n * console.error(`Transaction failed: ${result.error.message}`);\n * break;\n *\n * case 'UnexpectedError':\n * console.error(result.error.message);\n * break;\n * }\n * return;\n * }\n *\n * console.log('Transaction sent with hash:', result.value.txHash);\n * ```\n *\n * @param handler - The handler that will be used to handle the transaction.\n */\n\nexport function useUpdateUserPositionConditions(\n handler: ExecutionPlanHandler<TransactionRequest, PendingTransaction>,\n): UseAsyncTask<\n UpdateUserPositionConditionsRequest,\n TransactionReceipt,\n SendTransactionError | PendingTransactionError\n> {\n const client = useAaveClient();\n\n return useAsyncTask(\n (request: UpdateUserPositionConditionsRequest) =>\n updateUserPositionConditions(client, request)\n .andThen((transaction) => handler(transaction, { cancel }))\n .andThen((pending) => pending.wait())\n .andThen(client.waitForTransaction)\n .andThrough(() =>\n refreshUserPositionById(client, request.userPositionId),\n ),\n [client, handler],\n );\n}\n","import { type TransactionReceipt, UnexpectedError } from '@aave/client';\nimport { withdraw } from '@aave/client/actions';\nimport { ValidationError } from '@aave/core';\nimport type {\n InsufficientBalanceError,\n PreContractActionRequired,\n TransactionRequest,\n WithdrawRequest,\n} from '@aave/graphql';\nimport { errAsync } from '@aave/types';\n\nimport { useAaveClient } from '../context';\nimport {\n cancel,\n type ExecutionPlanHandler,\n type PendingTransaction,\n type PendingTransactionError,\n refreshQueriesForReserveChange,\n type SendTransactionError,\n type UseAsyncTask,\n useAsyncTask,\n} from '../helpers';\n\n/**\n * A hook that provides a way to withdraw supplied assets from an Aave reserve.\n *\n * ```ts\n * const [sendTransaction] = useSendTransaction(wallet);\n * const [withdraw, { loading, error }] = useWithdraw((plan, { cancel }) => {\n * switch (plan.__typename) {\n * case 'TransactionRequest':\n * return sendTransaction(plan);\n *\n * case 'PreContractActionRequired':\n * return sendTransaction(plan.transaction);\n * }\n * });\n *\n * // …\n *\n * const result = await withdraw({ ... });\n *\n * if (result.isErr()) {\n * switch (result.error.name) {\n * case 'CancelError':\n * // The user cancelled the operation\n * return;\n *\n * case 'SigningError':\n * console.error(`Failed to sign the transaction: ${result.error.message}`);\n * break;\n *\n * case 'TimeoutError':\n * console.error(`Transaction timed out: ${result.error.message}`);\n * break;\n *\n * case 'TransactionError':\n * console.error(`Transaction failed: ${result.error.message}`);\n * break;\n *\n * case 'ValidationError':\n * console.error(`Insufficient balance: ${result.error.cause.required.value} required.`);\n * break;\n *\n * case 'UnexpectedError':\n * console.error(result.error.message);\n * break;\n * }\n * return;\n * }\n *\n * console.log('Transaction sent with hash:', result.value.txHash);\n * ```\n *\n * @param handler - The handler that will be used to handle the transactions.\n */\nexport function useWithdraw(\n handler: ExecutionPlanHandler<\n TransactionRequest | PreContractActionRequired,\n PendingTransaction\n >,\n): UseAsyncTask<\n WithdrawRequest,\n TransactionReceipt,\n | SendTransactionError\n | PendingTransactionError\n | ValidationError<InsufficientBalanceError>\n> {\n const client = useAaveClient();\n\n return useAsyncTask(\n (request: WithdrawRequest) =>\n withdraw(client, request)\n .andThen((plan) => {\n switch (plan.__typename) {\n case 'TransactionRequest':\n return handler(plan, { cancel });\n\n case 'PreContractActionRequired':\n return handler(plan, { cancel })\n .andThen((pending) => pending.wait())\n .andThen(() => handler(plan.originalTransaction, { cancel }));\n\n case 'InsufficientBalanceError':\n return errAsync(ValidationError.fromGqlNode(plan));\n\n case 'Erc20ApprovalRequired':\n return UnexpectedError.from(plan).asResultAsync();\n }\n })\n .andThen((pending) => pending.wait())\n .andThen(client.waitForTransaction)\n .andThrough(() => refreshQueriesForReserveChange(client, request)),\n [client, handler],\n );\n}\n","import {\n type CurrencyQueryOptions,\n DEFAULT_QUERY_OPTIONS,\n type TimeWindowQueryOptions,\n type UnexpectedError,\n} from '@aave/client';\nimport type { UserPositionQueryOptions } from '@aave/client/actions';\nimport {\n userBalances,\n userBorrows,\n userPositions,\n userSupplies,\n} from '@aave/client/actions';\nimport {\n type UserBalance,\n UserBalancesQuery,\n type UserBalancesRequest,\n type UserBorrowItem,\n UserBorrowsQuery,\n type UserBorrowsRequest,\n type UserPosition,\n UserPositionQuery,\n type UserPositionRequest,\n UserPositionsQuery,\n type UserPositionsRequest,\n type UserRiskPremiumBreakdownItem,\n UserRiskPremiumBreakdownQuery,\n type UserRiskPremiumBreakdownRequest,\n type UserSummary,\n type UserSummaryHistoryItem,\n UserSummaryHistoryQuery,\n type UserSummaryHistoryRequest,\n UserSummaryQuery,\n type UserSummaryRequest,\n UserSuppliesQuery,\n type UserSuppliesRequest,\n type UserSupplyItem,\n} from '@aave/graphql';\nimport type { NullishDeep, Prettify } from '@aave/types';\nimport { useAaveClient } from './context';\nimport {\n type Pausable,\n type PausableReadResult,\n type PausableSuspenseResult,\n type ReadResult,\n type Suspendable,\n type SuspendableResult,\n type SuspenseResult,\n type UseAsyncTask,\n useAsyncTask,\n useSuspendableQuery,\n} from './helpers';\n\nexport type UseUserSuppliesArgs = Prettify<\n UserSuppliesRequest & CurrencyQueryOptions & TimeWindowQueryOptions\n>;\n\n/**\n * Fetch all user supply positions.\n *\n * This signature supports React Suspense:\n *\n * ```tsx\n * const { data } = useUserSupplies({\n * query: {\n * userSpoke: {\n * spoke: { address: evmAddress('0x87870bca…'), chainId: chainId(1) },\n * user: evmAddress('0x742d35cc…'),\n * },\n * },\n * orderBy: { name: 'ASC' },\n * suspense: true,\n * });\n * ```\n */\nexport function useUserSupplies(\n args: UseUserSuppliesArgs & Suspendable,\n): SuspenseResult<UserSupplyItem[]>;\n/**\n * Fetch all user supply positions.\n *\n * Pausable suspense mode.\n *\n * ```tsx\n * const { data } = useUserSupplies({\n * query: {\n * userSpoke: {\n * spoke: { address: evmAddress('0x87870bca…'), chainId: chainId(1) },\n * user: evmAddress('0x742d35cc…'),\n * },\n * },\n * orderBy: { name: 'ASC' },\n * suspense: true,\n * pause: true,\n * });\n *\n * // data?.length: number | undefined\n * ```\n */\nexport function useUserSupplies(\n args: Pausable<UseUserSuppliesArgs> & Suspendable,\n): PausableSuspenseResult<UserSupplyItem[]>;\n/**\n * Fetch all user supply positions.\n *\n * ```tsx\n * const { data, error, loading } = useUserSupplies({\n * query: {\n * userSpoke: {\n * spoke: { address: evmAddress('0x87870bca…'), chainId: chainId(1) },\n * user: evmAddress('0x742d35cc…'),\n * },\n * },\n * orderBy: { name: 'ASC' },\n * });\n * ```\n */\nexport function useUserSupplies(\n args: UseUserSuppliesArgs,\n): ReadResult<UserSupplyItem[]>;\n/**\n * Fetch all user supply positions.\n *\n * Pausable loading state mode.\n *\n * ```tsx\n * const { data, error, loading, paused } = useUserSupplies({\n * query: {\n * userSpoke: {\n * spoke: { address: evmAddress('0x87870bca…'), chainId: chainId(1) },\n * user: evmAddress('0x742d35cc…'),\n * },\n * },\n * orderBy: { name: 'ASC' },\n * pause: true,\n * });\n *\n * // data?.length: number | undefined\n * // error: UnexpectedError | undefined\n * // loading: boolean | undefined\n * // paused: boolean\n * ```\n */\nexport function useUserSupplies(\n args: Pausable<UseUserSuppliesArgs>,\n): PausableReadResult<UserSupplyItem[]>;\n\nexport function useUserSupplies({\n suspense = false,\n pause = false,\n currency = DEFAULT_QUERY_OPTIONS.currency,\n timeWindow = DEFAULT_QUERY_OPTIONS.timeWindow,\n ...request\n}: NullishDeep<UseUserSuppliesArgs> & {\n suspense?: boolean;\n pause?: boolean;\n}): SuspendableResult<UserSupplyItem[], UnexpectedError> {\n return useSuspendableQuery({\n document: UserSuppliesQuery,\n variables: {\n request,\n currency,\n timeWindow,\n },\n suspense,\n pause,\n });\n}\n\n/**\n * Low-level hook to execute a {@link userSupplies} action directly.\n *\n * @experimental This hook is experimental and may be subject to breaking changes.\n * @remarks\n * This hook **does not** actively watch for updated data on user supplies.\n * Use this hook to retrieve data on demand as part of a larger workflow\n * (e.g., in an event handler in order to move to the next step).\n *\n * ```ts\n * const [execute, { called, data, error, loading }] = useUserSuppliesAction();\n *\n * // …\n *\n * const result = await execute({\n * query: {\n * userSpoke: {\n * spoke: { address: evmAddress('0x87870bca…'), chainId: chainId(1) },\n * user: evmAddress('0x742d35cc…'),\n * },\n * },\n * orderBy: { name: 'ASC' },\n * });\n *\n * if (result.isOk()) {\n * console.log(result.value); // UserSupplyItem[]\n * } else {\n * console.error(result.error);\n * }\n * ```\n */\nexport function useUserSuppliesAction(\n options: CurrencyQueryOptions &\n TimeWindowQueryOptions = DEFAULT_QUERY_OPTIONS,\n): UseAsyncTask<UserSuppliesRequest, UserSupplyItem[], UnexpectedError> {\n const client = useAaveClient();\n\n return useAsyncTask(\n (request: UserSuppliesRequest) =>\n userSupplies(client, request, {\n currency: options.currency ?? DEFAULT_QUERY_OPTIONS.currency,\n timeWindow: options.timeWindow ?? DEFAULT_QUERY_OPTIONS.timeWindow,\n requestPolicy: 'cache-first',\n }),\n [client, options.currency, options.timeWindow],\n );\n}\n\nexport type UseUserBorrowsArgs = Prettify<\n UserBorrowsRequest & CurrencyQueryOptions & TimeWindowQueryOptions\n>;\n\n/**\n * Fetch all user borrow positions.\n *\n * This signature supports React Suspense:\n *\n * ```tsx\n * const { data } = useUserBorrows({\n * query: {\n * userSpoke: {\n * spoke: { address: evmAddress('0x87870bca…'), chainId: chainId(1) },\n * user: evmAddress('0x742d35cc…'),\n * },\n * },\n * orderBy: { name: 'ASC' },\n * suspense: true,\n * });\n * ```\n */\nexport function useUserBorrows(\n args: UseUserBorrowsArgs & Suspendable,\n): SuspenseResult<UserBorrowItem[]>;\n/**\n * Fetch all user borrow positions.\n *\n * Pausable suspense mode.\n *\n * ```tsx\n * const { data } = useUserBorrows({\n * query: {\n * userSpoke: {\n * spoke: { address: evmAddress('0x87870bca…'), chainId: chainId(1) },\n * user: evmAddress('0x742d35cc…'),\n * },\n * },\n * orderBy: { name: 'ASC' },\n * suspense: true,\n * pause: true,\n * });\n * ```\n */\nexport function useUserBorrows(\n args: Pausable<UseUserBorrowsArgs> & Suspendable,\n): PausableSuspenseResult<UserBorrowItem[]>;\n/**\n * Fetch all user borrow positions.\n *\n * ```tsx\n * const { data, error, loading } = useUserBorrows({\n * query: {\n * userSpoke: {\n * spoke: { address: evmAddress('0x87870bca…'), chainId: chainId(1) },\n * user: evmAddress('0x742d35cc…'),\n * },\n * },\n * orderBy: { name: 'ASC' },\n * });\n * ```\n */\nexport function useUserBorrows(\n args: UseUserBorrowsArgs,\n): ReadResult<UserBorrowItem[]>;\n/**\n * Fetch all user borrow positions.\n *\n * Pausable loading state mode.\n *\n * ```tsx\n * const { data, error, loading, paused } = useUserBorrows({\n * query: {\n * userSpoke: {\n * spoke: { address: evmAddress('0x87870bca…'), chainId: chainId(1) },\n * user: evmAddress('0x742d35cc…'),\n * },\n * },\n * orderBy: { name: 'ASC' },\n * pause: true,\n * });\n * ```\n */\nexport function useUserBorrows(\n args: Pausable<UseUserBorrowsArgs>,\n): PausableReadResult<UserBorrowItem[]>;\n\nexport function useUserBorrows({\n suspense = false,\n pause = false,\n currency = DEFAULT_QUERY_OPTIONS.currency,\n timeWindow = DEFAULT_QUERY_OPTIONS.timeWindow,\n ...request\n}: NullishDeep<UseUserBorrowsArgs> & {\n suspense?: boolean;\n pause?: boolean;\n}): SuspendableResult<UserBorrowItem[], UnexpectedError> {\n return useSuspendableQuery({\n document: UserBorrowsQuery,\n variables: {\n request,\n currency,\n timeWindow,\n },\n suspense,\n pause,\n });\n}\n\n/**\n * Low-level hook to execute a {@link userBorrows} action directly.\n *\n * @experimental This hook is experimental and may be subject to breaking changes.\n * @remarks\n * This hook **does not** actively watch for updated data on user borrows.\n * Use this hook to retrieve data on demand as part of a larger workflow\n * (e.g., in an event handler in order to move to the next step).\n *\n * ```ts\n * const [execute, { called, data, error, loading }] = useUserBorrowsAction();\n *\n * // …\n *\n * const result = await execute({\n * query: {\n * userSpoke: {\n * spoke: { address: evmAddress('0x87870bca…'), chainId: chainId(1) },\n * user: evmAddress('0x742d35cc…'),\n * },\n * },\n * orderBy: { name: 'ASC' },\n * });\n *\n * if (result.isOk()) {\n * console.log(result.value); // UserBorrowItem[]\n * } else {\n * console.error(result.error);\n * }\n * ```\n */\nexport function useUserBorrowsAction(\n options: CurrencyQueryOptions &\n TimeWindowQueryOptions = DEFAULT_QUERY_OPTIONS,\n): UseAsyncTask<UserBorrowsRequest, UserBorrowItem[], UnexpectedError> {\n const client = useAaveClient();\n\n return useAsyncTask(\n (request: UserBorrowsRequest) =>\n userBorrows(client, request, {\n currency: options.currency ?? DEFAULT_QUERY_OPTIONS.currency,\n timeWindow: options.timeWindow ?? DEFAULT_QUERY_OPTIONS.timeWindow,\n requestPolicy: 'cache-first',\n }),\n [client, options.currency, options.timeWindow],\n );\n}\n\nexport type UseUserSummaryArgs = Prettify<\n UserSummaryRequest & TimeWindowQueryOptions & CurrencyQueryOptions\n>;\n\n/**\n * Fetch a user's financial summary.\n *\n * This signature supports React Suspense:\n *\n * ```tsx\n * const { data } = useUserSummary({\n * user: evmAddress('0x742d35cc…'),\n * filter: {\n * spoke: { address: evmAddress('0x87870bca…'), chainId: chainId(1) },\n * },\n * suspense: true,\n * });\n * ```\n */\nexport function useUserSummary(\n args: UseUserSummaryArgs & Suspendable,\n): SuspenseResult<UserSummary>;\n/**\n * Fetch a user's financial summary.\n *\n * Pausable suspense mode.\n *\n * ```tsx\n * const { data } = useUserSummary({\n * user: evmAddress('0x742d35cc…'),\n * filter: {\n * spoke: { address: evmAddress('0x87870bca…'), chainId: chainId(1) },\n * },\n * suspense: true,\n * pause: true,\n * });\n * ```\n */\nexport function useUserSummary(\n args: Pausable<UseUserSummaryArgs> & Suspendable,\n): PausableSuspenseResult<UserSummary>;\n/**\n * Fetch a user's financial summary.\n *\n * ```tsx\n * const { data, error, loading } = useUserSummary({\n * user: evmAddress('0x742d35cc…'),\n * filter: {\n * spoke: { address: evmAddress('0x87870bca…'), chainId: chainId(1) },\n * },\n * });\n * ```\n */\nexport function useUserSummary(\n args: UseUserSummaryArgs,\n): ReadResult<UserSummary>;\n/**\n * Fetch a user's financial summary.\n *\n * Pausable loading state mode.\n *\n * ```tsx\n * const { data, error, loading, paused } = useUserSummary({\n * user: evmAddress('0x742d35cc…'),\n * filter: {\n * spoke: { address: evmAddress('0x87870bca…'), chainId: chainId(1) },\n * },\n * pause: true,\n * });\n * ```\n */\nexport function useUserSummary(\n args: Pausable<UseUserSummaryArgs>,\n): PausableReadResult<UserSummary>;\n\nexport function useUserSummary({\n suspense = false,\n pause = false,\n currency = DEFAULT_QUERY_OPTIONS.currency,\n timeWindow = DEFAULT_QUERY_OPTIONS.timeWindow,\n ...request\n}: NullishDeep<UseUserSummaryArgs> & {\n suspense?: boolean;\n pause?: boolean;\n}): SuspendableResult<UserSummary, UnexpectedError> {\n return useSuspendableQuery({\n document: UserSummaryQuery,\n variables: {\n request,\n currency,\n timeWindow,\n },\n suspense,\n pause,\n });\n}\n\nexport type UseUserPositionsArgs = Prettify<\n UserPositionsRequest & UserPositionQueryOptions\n>;\n\n/**\n * Fetch all user positions across specified chains.\n *\n * This signature supports React Suspense:\n *\n * ```tsx\n * const { data } = useUserPositions({\n * user: evmAddress('0x742d35cc…'),\n * chainIds: [chainId(1), chainId(137)],\n * orderBy: { balance: 'DESC' },\n * suspense: true,\n * });\n * ```\n */\nexport function useUserPositions(\n args: UseUserPositionsArgs & Suspendable,\n): SuspenseResult<UserPosition[]>;\n/**\n * Fetch all user positions across specified chains.\n *\n * Pausable suspense mode.\n *\n * ```tsx\n * const { data } = useUserPositions({\n * user: evmAddress('0x742d35cc…'),\n * chainIds: [chainId(1), chainId(137)],\n * orderBy: { balance: 'DESC' },\n * suspense: true,\n * pause: true,\n * });\n * ```\n */\nexport function useUserPositions(\n args: Pausable<UseUserPositionsArgs> & Suspendable,\n): PausableSuspenseResult<UserPosition[]>;\n/**\n * Fetch all user positions across specified chains.\n *\n * ```tsx\n * const { data, error, loading } = useUserPositions({\n * user: evmAddress('0x742d35cc…'),\n * chainIds: [chainId(1), chainId(137)],\n * orderBy: { balance: 'DESC' },\n * });\n * ```\n */\nexport function useUserPositions(\n args: UseUserPositionsArgs,\n): ReadResult<UserPosition[]>;\n/**\n * Fetch all user positions across specified chains.\n *\n * Pausable loading state mode.\n *\n * ```tsx\n * const { data, error, loading, paused } = useUserPositions({\n * user: evmAddress('0x742d35cc…'),\n * chainIds: [chainId(1), chainId(137)],\n * orderBy: { balance: 'DESC' },\n * pause: true,\n * });\n * ```\n */\nexport function useUserPositions(\n args: Pausable<UseUserPositionsArgs>,\n): PausableReadResult<UserPosition[]>;\n\nexport function useUserPositions({\n suspense = false,\n pause = false,\n currency = DEFAULT_QUERY_OPTIONS.currency,\n timeWindow = DEFAULT_QUERY_OPTIONS.timeWindow,\n ...request\n}: NullishDeep<UseUserPositionsArgs> & {\n suspense?: boolean;\n pause?: boolean;\n}): SuspendableResult<UserPosition[], UnexpectedError> {\n return useSuspendableQuery({\n document: UserPositionsQuery,\n variables: {\n request,\n currency,\n timeWindow,\n },\n suspense,\n pause,\n });\n}\n\n/**\n * Low-level hook to execute a {@link userPositions} action directly.\n *\n * @experimental This hook is experimental and may be subject to breaking changes.\n * @remarks\n * This hook **does not** actively watch for updated data on user positions.\n * Use this hook to retrieve data on demand as part of a larger workflow\n * (e.g., in an event handler in order to move to the next step).\n *\n * ```ts\n * const [execute, { called, data, error, loading }] = useUserPositionsAction();\n *\n * // …\n *\n * const result = await execute({\n * user: evmAddress('0x742d35cc…'),\n * filter: {\n * chainIds: [chainId(1), chainId(137)]\n * },\n * orderBy: { balance: 'DESC' },\n * });\n *\n * if (result.isOk()) {\n * console.log(result.value); // UserPosition[]\n * } else {\n * console.error(result.error);\n * }\n * ```\n */\nexport function useUserPositionsAction(\n options: UserPositionQueryOptions = DEFAULT_QUERY_OPTIONS,\n): UseAsyncTask<UserPositionsRequest, UserPosition[], UnexpectedError> {\n const client = useAaveClient();\n\n return useAsyncTask(\n (request: UserPositionsRequest) =>\n userPositions(client, request, {\n currency: options.currency,\n timeWindow: options.timeWindow,\n requestPolicy: 'cache-first',\n }),\n [client, options.currency, options.timeWindow],\n );\n}\n\nexport type UseUserPositionArgs = Prettify<\n UserPositionRequest & UserPositionQueryOptions\n>;\n\n/**\n * Fetch a specific user position by ID.\n *\n * This signature supports React Suspense:\n *\n * ```tsx\n * const { data } = useUserPosition({\n * id: userPositionId('SGVsbG8h'),\n * user: evmAddress('0x742d35cc…'),\n * suspense: true,\n * });\n * ```\n */\nexport function useUserPosition(\n args: UseUserPositionArgs & Suspendable,\n): SuspenseResult<UserPosition>;\n/**\n * Fetch a specific user position by ID.\n *\n * Pausable suspense mode.\n *\n * ```tsx\n * const { data } = useUserPosition({\n * id: userPositionId('SGVsbG8h'),\n * user: evmAddress('0x742d35cc…'),\n * suspense: true,\n * pause: true,\n * });\n * ```\n */\nexport function useUserPosition(\n args: Pausable<UseUserPositionArgs> & Suspendable,\n): PausableSuspenseResult<UserPosition>;\n/**\n * Fetch a specific user position by ID.\n *\n * ```tsx\n * const { data, error, loading } = useUserPosition({\n * id: userPositionId('SGVsbG8h'),\n * user: evmAddress('0x742d35cc…'),\n * });\n * ```\n */\nexport function useUserPosition(\n args: UseUserPositionArgs,\n): ReadResult<UserPosition>;\n/**\n * Fetch a specific user position by ID.\n *\n * Pausable loading state mode.\n *\n * ```tsx\n * const { data, error, loading, paused } = useUserPosition({\n * id: userPositionId('SGVsbG8h'),\n * user: evmAddress('0x742d35cc…'),\n * pause: true,\n * });\n * ```\n */\nexport function useUserPosition(\n args: Pausable<UseUserPositionArgs>,\n): PausableReadResult<UserPosition>;\n\nexport function useUserPosition({\n suspense = false,\n pause = false,\n currency = DEFAULT_QUERY_OPTIONS.currency,\n timeWindow = DEFAULT_QUERY_OPTIONS.timeWindow,\n ...request\n}: NullishDeep<UseUserPositionArgs> & {\n suspense?: boolean;\n pause?: boolean;\n}): SuspendableResult<UserPosition | null, UnexpectedError> {\n return useSuspendableQuery({\n document: UserPositionQuery,\n variables: {\n request,\n currency,\n timeWindow,\n },\n suspense,\n pause,\n });\n}\n\nexport type UseUserBalancesArgs = Prettify<\n UserBalancesRequest & CurrencyQueryOptions\n>;\n\n/**\n * Fetch all user balances across specified chains.\n *\n * This signature supports React Suspense:\n *\n * ```tsx\n * const { data } = useUserBalances({\n * user: evmAddress('0x742d35cc…'),\n * chainIds: [chainId(1), chainId(137)],\n * suspense: true,\n * });\n * ```\n */\nexport function useUserBalances(\n args: UseUserBalancesArgs & Suspendable,\n): SuspenseResult<UserBalance[]>;\n/**\n * Fetch all user balances across specified chains.\n *\n * Pausable suspense mode.\n *\n * ```tsx\n * const { data } = useUserBalances({\n * user: evmAddress('0x742d35cc…'),\n * chainIds: [chainId(1), chainId(137)],\n * suspense: true,\n * pause: true,\n * });\n * ```\n */\nexport function useUserBalances(\n args: Pausable<UseUserBalancesArgs> & Suspendable,\n): PausableSuspenseResult<UserBalance[]>;\n/**\n * Fetch all user balances across specified chains.\n *\n * ```tsx\n * const { data, error, loading } = useUserBalances({\n * user: evmAddress('0x742d35cc…'),\n * chainIds: [chainId(1), chainId(137)],\n * });\n * ```\n */\nexport function useUserBalances(\n args: UseUserBalancesArgs,\n): ReadResult<UserBalance[]>;\n/**\n * Fetch all user balances across specified chains.\n *\n * Pausable loading state mode.\n *\n * ```tsx\n * const { data, error, loading, paused } = useUserBalances({\n * user: evmAddress('0x742d35cc…'),\n * chainIds: [chainId(1), chainId(137)],\n * pause: true,\n * });\n * ```\n */\nexport function useUserBalances(\n args: Pausable<UseUserBalancesArgs>,\n): PausableReadResult<UserBalance[]>;\n\nexport function useUserBalances({\n suspense = false,\n pause = false,\n currency = DEFAULT_QUERY_OPTIONS.currency,\n ...request\n}: NullishDeep<UseUserBalancesArgs> & {\n suspense?: boolean;\n pause?: boolean;\n}): SuspendableResult<UserBalance[], UnexpectedError> {\n return useSuspendableQuery({\n document: UserBalancesQuery,\n variables: {\n request,\n currency,\n },\n suspense,\n pause,\n });\n}\n\nexport type UseUserRiskPremiumBreakdownArgs = UserRiskPremiumBreakdownRequest;\n\n/**\n * Fetch the risk premium breakdown for a user position or spoke.\n *\n * This signature supports React Suspense:\n *\n * ```tsx\n * const { data } = useUserRiskPremiumBreakdown({\n * query: {\n * userPositionId: userPositionId('SGVsbG8h'),\n * },\n * user: evmAddress('0x742d35cc…'),\n * suspense: true,\n * });\n * ```\n */\nexport function useUserRiskPremiumBreakdown(\n args: UseUserRiskPremiumBreakdownArgs & Suspendable,\n): SuspenseResult<UserRiskPremiumBreakdownItem[]>;\n/**\n * Fetch the risk premium breakdown for a user position or spoke.\n *\n * Pausable suspense mode.\n *\n * ```tsx\n * const { data } = useUserRiskPremiumBreakdown({\n * query: {\n * userPositionId: userPositionId('SGVsbG8h'),\n * },\n * user: evmAddress('0x742d35cc…'),\n * suspense: true,\n * pause: true,\n * });\n * ```\n */\nexport function useUserRiskPremiumBreakdown(\n args: Pausable<UseUserRiskPremiumBreakdownArgs> & Suspendable,\n): PausableSuspenseResult<UserRiskPremiumBreakdownItem[]>;\n/**\n * Fetch the risk premium breakdown for a user position or spoke.\n *\n * ```tsx\n * const { data, error, loading } = useUserRiskPremiumBreakdown({\n * query: {\n * userPositionId: userPositionId('SGVsbG8h'),\n * },\n * user: evmAddress('0x742d35cc…'),\n * });\n * ```\n */\nexport function useUserRiskPremiumBreakdown(\n args: UseUserRiskPremiumBreakdownArgs,\n): ReadResult<UserRiskPremiumBreakdownItem[]>;\n/**\n * Fetch the risk premium breakdown for a user position or spoke.\n *\n * Pausable loading state mode.\n *\n * ```tsx\n * const { data, error, loading, paused } = useUserRiskPremiumBreakdown({\n * query: {\n * userPositionId: userPositionId('SGVsbG8h'),\n * },\n * user: evmAddress('0x742d35cc…'),\n * pause: true,\n * });\n * ```\n */\nexport function useUserRiskPremiumBreakdown(\n args: Pausable<UseUserRiskPremiumBreakdownArgs>,\n): PausableReadResult<UserRiskPremiumBreakdownItem[]>;\n\nexport function useUserRiskPremiumBreakdown({\n suspense = false,\n pause = false,\n ...request\n}: NullishDeep<UseUserRiskPremiumBreakdownArgs> & {\n suspense?: boolean;\n pause?: boolean;\n}): SuspendableResult<UserRiskPremiumBreakdownItem[], UnexpectedError> {\n return useSuspendableQuery({\n document: UserRiskPremiumBreakdownQuery,\n variables: {\n request,\n },\n suspense,\n pause,\n batch: false, // Do not batch this since it's a slower than average query\n });\n}\n\n/**\n * Low-level hook to execute a {@link userBalances} action directly.\n *\n * @experimental This hook is experimental and may be subject to breaking changes.\n * @remarks\n * This hook **does not** actively watch for updated data on user balances.\n * Use this hook to retrieve data on demand as part of a larger workflow\n * (e.g., in an event handler in order to move to the next step).\n *\n * ```ts\n * const [execute, { called, data, error, loading }] = useUserBalancesAction();\n *\n * // …\n *\n * const result = await execute({\n * user: evmAddress('0x742d35cc…'),\n * filter: {\n * chainIds: [chainId(1), chainId(137)]\n * },\n * });\n *\n * if (result.isOk()) {\n * console.log(result.value); // UserBalance[]\n * } else {\n * console.error(result.error);\n * }\n * ```\n */\nexport function useUserBalancesAction(\n options: Required<CurrencyQueryOptions> = DEFAULT_QUERY_OPTIONS,\n): UseAsyncTask<UserBalancesRequest, UserBalance[], UnexpectedError> {\n const client = useAaveClient();\n\n return useAsyncTask(\n (request: UserBalancesRequest) =>\n userBalances(client, request, {\n currency: options.currency,\n requestPolicy: 'cache-first',\n }),\n [client, options.currency],\n );\n}\n\nexport type UseUserSummaryHistoryArgs = Prettify<\n UserSummaryHistoryRequest & CurrencyQueryOptions\n>;\n\n/**\n * Fetch user summary history over time.\n *\n * This signature supports React Suspense:\n *\n * ```tsx\n * const { data } = useUserSummaryHistory({\n * user: evmAddress('0x742d35cc…'),\n * window: TimeWindow.LastWeek,\n * filter: { chainIds: [chainId(1)] },\n * suspense: true,\n * });\n * ```\n */\nexport function useUserSummaryHistory(\n args: UseUserSummaryHistoryArgs & Suspendable,\n): SuspenseResult<UserSummaryHistoryItem[]>;\n/**\n * Fetch user summary history over time.\n *\n * Pausable suspense mode.\n *\n * ```tsx\n * const { data } = useUserSummaryHistory({\n * user: evmAddress('0x742d35cc…'),\n * window: TimeWindow.LastWeek,\n * filter: { chainIds: [chainId(1)] },\n * suspense: true,\n * pause: true,\n * });\n * ```\n */\nexport function useUserSummaryHistory(\n args: Pausable<UseUserSummaryHistoryArgs> & Suspendable,\n): PausableSuspenseResult<UserSummaryHistoryItem[]>;\n/**\n * Fetch user summary history over time.\n *\n * ```tsx\n * const { data, error, loading } = useUserSummaryHistory({\n * user: evmAddress('0x742d35cc…'),\n * window: TimeWindow.LastWeek,\n * filter: { chainIds: [chainId(1)] },\n * });\n * ```\n */\nexport function useUserSummaryHistory(\n args: UseUserSummaryHistoryArgs,\n): ReadResult<UserSummaryHistoryItem[]>;\n/**\n * Fetch user summary history over time.\n *\n * Pausable loading state mode.\n *\n * ```tsx\n * const { data, error, loading, paused } = useUserSummaryHistory({\n * user: evmAddress('0x742d35cc…'),\n * window: TimeWindow.LastWeek,\n * filter: { chainIds: [chainId(1)] },\n * pause: true,\n * });\n * ```\n */\nexport function useUserSummaryHistory(\n args: Pausable<UseUserSummaryHistoryArgs>,\n): PausableReadResult<UserSummaryHistoryItem[]>;\n\nexport function useUserSummaryHistory({\n suspense = false,\n pause = false,\n currency = DEFAULT_QUERY_OPTIONS.currency,\n ...request\n}: NullishDeep<UseUserSummaryHistoryArgs> & {\n suspense?: boolean;\n pause?: boolean;\n}): SuspendableResult<UserSummaryHistoryItem[], UnexpectedError> {\n return useSuspendableQuery({\n document: UserSummaryHistoryQuery,\n variables: {\n request,\n currency,\n },\n suspense,\n pause,\n batch: false, // Do not batch this since it's a slower than average query\n });\n}\n"]}
|