11import type { UnexpectedError } from '@aave/client' ;
2- import type { ExecutionPlan , SupplyRequest } from '@aave/graphql' ;
3- import { supply } from '../../client/src/actions' ;
2+ import type {
3+ ExecutionPlan ,
4+ SupplyRequest ,
5+ BorrowRequest ,
6+ RepayRequest ,
7+ WithdrawRequest ,
8+ EModeToggleRequest ,
9+ TransactionRequest ,
10+ } from '@aave/graphql' ;
11+ import {
12+ supply ,
13+ borrow ,
14+ repay ,
15+ withdraw ,
16+ eModeToggle ,
17+ } from '../../client/src/actions' ;
418import { useAaveClient } from './context' ;
519import { type UseAsyncTask , useAsyncTask } from './helpers' ;
620
@@ -20,3 +34,71 @@ export function useSupply(): UseAsyncTask<
2034
2135 return useAsyncTask ( ( request : SupplyRequest ) => supply ( client , request ) ) ;
2236}
37+
38+ /**
39+ * A hook that provides a way to borrow assets from an Aave market.
40+ *
41+ * ```ts
42+ * const [borrow, { loading, error, data }] = useBorrow();
43+ * ```
44+ */
45+ export function useBorrow ( ) : UseAsyncTask <
46+ BorrowRequest ,
47+ ExecutionPlan ,
48+ UnexpectedError
49+ > {
50+ const client = useAaveClient ( ) ;
51+
52+ return useAsyncTask ( ( request : BorrowRequest ) => borrow ( client , request ) ) ;
53+ }
54+
55+ /**
56+ * A hook that provides a way to repay borrowed assets to an Aave market.
57+ *
58+ * ```ts
59+ * const [repay, { loading, error, data }] = useRepay();
60+ * ```
61+ */
62+ export function useRepay ( ) : UseAsyncTask <
63+ RepayRequest ,
64+ ExecutionPlan ,
65+ UnexpectedError
66+ > {
67+ const client = useAaveClient ( ) ;
68+
69+ return useAsyncTask ( ( request : RepayRequest ) => repay ( client , request ) ) ;
70+ }
71+
72+ /**
73+ * A hook that provides a way to withdraw supplied assets from an Aave market.
74+ *
75+ * ```ts
76+ * const [withdraw, { loading, error, data }] = useWithdraw();
77+ * ```
78+ */
79+ export function useWithdraw ( ) : UseAsyncTask <
80+ WithdrawRequest ,
81+ ExecutionPlan ,
82+ UnexpectedError
83+ > {
84+ const client = useAaveClient ( ) ;
85+
86+ return useAsyncTask ( ( request : WithdrawRequest ) => withdraw ( client , request ) ) ;
87+ }
88+
89+ /**
90+ * A hook that provides a way to toggle eMode for a user in an Aave market.
91+ *
92+ * ```ts
93+ * const [toggleEMode, { loading, error, data }] = useEModeToggle();
94+ * ```
95+ */
96+ export function useEModeToggle ( ) : UseAsyncTask <
97+ EModeToggleRequest ,
98+ TransactionRequest ,
99+ UnexpectedError
100+ > {
101+ const client = useAaveClient ( ) ;
102+
103+ return useAsyncTask ( ( request : EModeToggleRequest ) => eModeToggle ( client , request ) ) ;
104+ }
0 commit comments