@sodax/dapp-kit 0.0.1-rc.6 → 0.0.1-rc.8

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.
Files changed (54) hide show
  1. package/README.md +11 -10
  2. package/dist/hooks/mm/index.d.ts +2 -0
  3. package/dist/hooks/mm/index.d.ts.map +1 -1
  4. package/dist/hooks/mm/useBorrow.d.ts +10 -1
  5. package/dist/hooks/mm/useBorrow.d.ts.map +1 -1
  6. package/dist/hooks/mm/useMMAllowance.d.ts +26 -0
  7. package/dist/hooks/mm/useMMAllowance.d.ts.map +1 -0
  8. package/dist/hooks/mm/useMMApprove.d.ts +27 -0
  9. package/dist/hooks/mm/useMMApprove.d.ts.map +1 -0
  10. package/dist/hooks/mm/useRepay.d.ts +10 -1
  11. package/dist/hooks/mm/useRepay.d.ts.map +1 -1
  12. package/dist/hooks/mm/useSupply.d.ts +3 -1
  13. package/dist/hooks/mm/useSupply.d.ts.map +1 -1
  14. package/dist/hooks/mm/useUserReservesData.d.ts +1 -1
  15. package/dist/hooks/mm/useUserReservesData.d.ts.map +1 -1
  16. package/dist/hooks/mm/useWithdraw.d.ts +8 -1
  17. package/dist/hooks/mm/useWithdraw.d.ts.map +1 -1
  18. package/dist/hooks/provider/useSpokeProvider.d.ts +16 -2
  19. package/dist/hooks/provider/useSpokeProvider.d.ts.map +1 -1
  20. package/dist/hooks/shared/index.d.ts +0 -2
  21. package/dist/hooks/shared/index.d.ts.map +1 -1
  22. package/dist/hooks/swap/index.d.ts +2 -0
  23. package/dist/hooks/swap/index.d.ts.map +1 -1
  24. package/dist/hooks/swap/useCreateIntentOrder.d.ts +4 -4
  25. package/dist/hooks/swap/useCreateIntentOrder.d.ts.map +1 -1
  26. package/dist/hooks/swap/useSwapAllowance.d.ts +23 -0
  27. package/dist/hooks/swap/useSwapAllowance.d.ts.map +1 -0
  28. package/dist/hooks/swap/useSwapApprove.d.ts +26 -0
  29. package/dist/hooks/swap/useSwapApprove.d.ts.map +1 -0
  30. package/dist/index.js +161 -101
  31. package/dist/index.js.map +1 -1
  32. package/dist/index.mjs +159 -101
  33. package/dist/index.mjs.map +1 -1
  34. package/package.json +4 -4
  35. package/src/hooks/mm/index.ts +2 -0
  36. package/src/hooks/mm/useBorrow.ts +14 -5
  37. package/src/hooks/mm/useMMAllowance.ts +55 -0
  38. package/src/hooks/mm/useMMApprove.ts +67 -0
  39. package/src/hooks/mm/useRepay.ts +14 -4
  40. package/src/hooks/mm/useSupply.ts +7 -4
  41. package/src/hooks/mm/useUserReservesData.ts +6 -12
  42. package/src/hooks/mm/useWithdraw.ts +12 -4
  43. package/src/hooks/provider/useSpokeProvider.ts +44 -8
  44. package/src/hooks/shared/index.ts +0 -2
  45. package/src/hooks/swap/index.ts +2 -0
  46. package/src/hooks/swap/useCreateIntentOrder.ts +4 -6
  47. package/src/hooks/swap/useSwapAllowance.ts +44 -0
  48. package/src/hooks/swap/useSwapApprove.ts +68 -0
  49. package/dist/hooks/shared/useAllowance.d.ts +0 -3
  50. package/dist/hooks/shared/useAllowance.d.ts.map +0 -1
  51. package/dist/hooks/shared/useApprove.d.ts +0 -10
  52. package/dist/hooks/shared/useApprove.d.ts.map +0 -1
  53. package/src/hooks/shared/useAllowance.ts +0 -31
  54. package/src/hooks/shared/useApprove.ts +0 -53
package/README.md CHANGED
@@ -13,22 +13,21 @@ dApp Kit is a collection of React components, hooks, and utilities designed to s
13
13
  - Get user reserves data (`useUserReservesData`)
14
14
  - Calculate hub wallet address by using spoke chain id and spoke chain wallet address (`useHubWalletAddress`)
15
15
  - Get reserves data (`useReservesData`)
16
+ - Check token allowance (`useMMAllowance`)
17
+ - Approve token spending (`useMMApprove`)
16
18
 
17
19
  - Swap/Intent
18
20
  - Get quote for an intent order (`useQuote`)
19
21
  - Create and submit an intent order (`useCreateIntentOrder`)
20
22
  - Get status of an intent order (`useStatus`)
23
+ - Check token allowance (`useSwapAllowance`)
24
+ - Approve token spending (`useSwapApprove`)
21
25
 
22
26
  - Provider
23
27
  - Get hub chain provider (`useHubProvider`)
24
28
  - Get spoke chain provider (`useSpokeProvider`)
25
29
  - Get wallet provider (`useWalletProvider`)
26
30
 
27
- - Token Management
28
- - Check token allowance (`useAllowance`)
29
- - Approve token spending (`useApprove`)
30
-
31
-
32
31
  ## Installation
33
32
 
34
33
  ```bash
@@ -66,7 +65,7 @@ const sodaxConfig = {
66
65
  moneyMarket: getMoneyMarketConfig(SONIC_MAINNET_CHAIN_ID),
67
66
  solver: {
68
67
  intentsContract: '0x6382D6ccD780758C5e8A6123c33ee8F4472F96ef',
69
- solverApiEndpoint: 'https://staging-new-world.iconblockchain.xyz',
68
+ solverApiEndpoint: 'https://sodax-solver.iconblockchain.xyz',
70
69
  partnerFee: {
71
70
  address: '0x0Ab764AB3816cD036Ea951bE973098510D8105A6',
72
71
  percentage: 100, // 1%
@@ -147,11 +146,11 @@ function MoneyMarketComponent() {
147
146
  }
148
147
 
149
148
  // Token Management
150
- import { useAllowance, useApprove } from '@sodax/dapp-kit';
149
+ import { useMMAllowance, useApprove } from '@sodax/dapp-kit';
151
150
 
152
151
  function TokenManagementComponent() {
153
152
  // Check token allowance
154
- const { data: hasAllowed } = useAllowance(token, amount);
153
+ const { data: hasAllowed } = useMMAllowance(token, amount);
155
154
 
156
155
  // Approve token spending
157
156
  const { approve, isLoading: isApproving } = useApprove(token);
@@ -214,16 +213,18 @@ function SwapComponent() {
214
213
  - [`useUserReservesData()`](./src/hooks/mm/useUserReservesData.ts) - Get user's reserves data(supplied asset and debt)
215
214
  - [`useHubWalletAddress()`](./src/hooks/mm/useHubWalletAddress.ts) - Get hub wallet address for a spoke chain
216
215
  - [`useReservesData()`](./src/hooks/mm/useReservesData.ts) - Get reserves data
216
+ - [`useMMAllowance()`](./src/hooks/mm/useMMAllowance.ts) - Check token allowance for a specific amount
217
+ - [`useMMApprove()`](./src/hooks/mm/useMMApprove.ts) - Approve token spending
217
218
 
218
219
  #### Swap Hooks
219
220
  - [`useQuote()`](./src/hooks/swap/useQuote.ts) - Get quote for an intent order
220
221
  - [`useCreateIntentOrder()`](./src/hooks/swap/useCreateIntentOrder.ts) - Create and submit an intent order
221
222
  - [`useStatus()`](./src/hooks/swap/useStatus.ts) - Get status of an intent order
223
+ - [`useSwapAllowance()`](./src/hooks/swap/useSwapAllowance.ts) - Check token allowance for an intent order
224
+ - [`useSwapApprove()`](./src/hooks/swap/useSwapApprove.ts) - Approve token spending
222
225
 
223
226
  #### Shared Hooks
224
227
  - [`useSodaxContext()`](./src/hooks/shared/useSodaxContext.ts) - Access Sodax context and configuration
225
- - [`useAllowance()`](./src/hooks/shared/useAllowance.ts) - Check token allowance for a specific amount
226
- - [`useApprove()`](./src/hooks/shared/useApprove.ts) - Approve token spending
227
228
 
228
229
 
229
230
  ## Contributing
@@ -5,4 +5,6 @@ export * from './useWithdraw';
5
5
  export * from './useUserReservesData';
6
6
  export * from './useHubWalletAddress';
7
7
  export * from './useReservesData';
8
+ export * from './useMMAllowance';
9
+ export * from './useMMApprove';
8
10
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/hooks/mm/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,YAAY,CAAC;AAC3B,cAAc,aAAa,CAAC;AAC5B,cAAc,eAAe,CAAC;AAC9B,cAAc,uBAAuB,CAAC;AACtC,cAAc,uBAAuB,CAAC;AACtC,cAAc,mBAAmB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/hooks/mm/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,YAAY,CAAC;AAC3B,cAAc,aAAa,CAAC;AAC5B,cAAc,eAAe,CAAC;AAC9B,cAAc,uBAAuB,CAAC;AACtC,cAAc,uBAAuB,CAAC;AACtC,cAAc,mBAAmB,CAAC;AAClC,cAAc,kBAAkB,CAAC;AACjC,cAAc,gBAAgB,CAAC"}
@@ -1,5 +1,6 @@
1
1
  import type { XToken } from '@sodax/types';
2
2
  import { type UseMutationResult } from '@tanstack/react-query';
3
+ import type { SpokeProvider } from '@sodax/sdk';
3
4
  interface BorrowResponse {
4
5
  ok: true;
5
6
  value: [`0x${string}`, `0x${string}`];
@@ -11,6 +12,14 @@ interface BorrowResponse {
11
12
  * handling the entire borrow process including transaction creation, submission,
12
13
  * and cross-chain communication.
13
14
  *
15
+ * @param {XToken} spokeToken - The token to borrow from the spoke chain. Must be an XToken with valid address and chain information.
16
+ * @param {SpokeProvider} spokeProvider - The spoke provider to use for the borrow transaction. Must be a valid SpokeProvider instance.
17
+ *
18
+ * @returns {UseMutationResult<BorrowResponse, Error, string>} A mutation result object with the following properties:
19
+ * - mutateAsync: Function to execute the borrow transaction
20
+ * - isPending: Boolean indicating if a transaction is in progress
21
+ * - error: Error object if the last transaction failed, null otherwise
22
+ *
14
23
  * @example
15
24
  * ```typescript
16
25
  * const { mutateAsync: borrow, isPending, error } = useBorrow(spokeToken);
@@ -21,6 +30,6 @@ interface BorrowResponse {
21
30
  * - spokeProvider is not available
22
31
  * - Transaction execution fails
23
32
  */
24
- export declare function useBorrow(spokeToken: XToken): UseMutationResult<BorrowResponse, Error, string>;
33
+ export declare function useBorrow(spokeToken: XToken, spokeProvider: SpokeProvider | undefined): UseMutationResult<BorrowResponse, Error, string>;
25
34
  export {};
26
35
  //# sourceMappingURL=useBorrow.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"useBorrow.d.ts","sourceRoot":"","sources":["../../../src/hooks/mm/useBorrow.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAC3C,OAAO,EAAe,KAAK,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAK5E,UAAU,cAAc;IACtB,EAAE,EAAE,IAAI,CAAC;IACT,KAAK,EAAE,CAAC,KAAK,MAAM,EAAE,EAAE,KAAK,MAAM,EAAE,CAAC,CAAC;CACvC;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,SAAS,CAAC,UAAU,EAAE,MAAM,GAAG,iBAAiB,CAAC,cAAc,EAAE,KAAK,EAAE,MAAM,CAAC,CA2B9F"}
1
+ {"version":3,"file":"useBorrow.d.ts","sourceRoot":"","sources":["../../../src/hooks/mm/useBorrow.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAC3C,OAAO,EAAe,KAAK,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAG5E,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAChD,UAAU,cAAc;IACtB,EAAE,EAAE,IAAI,CAAC;IACT,KAAK,EAAE,CAAC,KAAK,MAAM,EAAE,EAAE,KAAK,MAAM,EAAE,CAAC,CAAC;CACvC;AAED;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,wBAAgB,SAAS,CACvB,UAAU,EAAE,MAAM,EAClB,aAAa,EAAE,aAAa,GAAG,SAAS,GACvC,iBAAiB,CAAC,cAAc,EAAE,KAAK,EAAE,MAAM,CAAC,CA0BlD"}
@@ -0,0 +1,26 @@
1
+ import { type UseQueryResult } from '@tanstack/react-query';
2
+ import type { XToken } from '@sodax/types';
3
+ import type { MoneyMarketAction, SpokeProvider } from '@sodax/sdk';
4
+ /**
5
+ * Hook for checking token allowance for money market operations.
6
+ *
7
+ * This hook verifies if the user has approved enough tokens for a specific money market action
8
+ * (borrow/repay). It automatically queries and tracks the allowance status.
9
+ *
10
+ * @param {XToken} token - The token to check allowance for. Must be an XToken with valid address and chain information.
11
+ * @param {string} amount - The amount to check allowance for, as a decimal string
12
+ * @param {MoneyMarketAction} action - The money market action to check allowance for ('borrow' or 'repay')
13
+ * @param {SpokeProvider} spokeProvider - The spoke provider to use for allowance checks
14
+ *
15
+ * @returns {UseQueryResult<boolean, Error>} A React Query result containing:
16
+ * - data: Boolean indicating if allowance is sufficient
17
+ * - isLoading: Loading state indicator
18
+ * - error: Any error that occurred during the check
19
+ *
20
+ * @example
21
+ * ```typescript
22
+ * const { data: hasAllowed, isLoading } = useMMAllowance(token, "100", "repay", provider);
23
+ * ```
24
+ */
25
+ export declare function useMMAllowance(token: XToken, amount: string, action: MoneyMarketAction, spokeProvider: SpokeProvider | undefined): UseQueryResult<boolean, Error>;
26
+ //# sourceMappingURL=useMMAllowance.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useMMAllowance.d.ts","sourceRoot":"","sources":["../../../src/hooks/mm/useMMAllowance.ts"],"names":[],"mappings":"AAAA,OAAO,EAAY,KAAK,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACtE,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAG3C,OAAO,KAAK,EAAE,iBAAiB,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAEnE;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,cAAc,CAC5B,KAAK,EAAE,MAAM,EACb,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,iBAAiB,EACzB,aAAa,EAAE,aAAa,GAAG,SAAS,GACvC,cAAc,CAAC,OAAO,EAAE,KAAK,CAAC,CAsBhC"}
@@ -0,0 +1,27 @@
1
+ import type { XToken } from '@sodax/types';
2
+ import type { MoneyMarketAction, SpokeProvider } from '@sodax/sdk';
3
+ interface UseApproveReturn {
4
+ approve: ({ amount, action }: {
5
+ amount: string;
6
+ action: MoneyMarketAction;
7
+ }) => Promise<boolean>;
8
+ isLoading: boolean;
9
+ error: Error | null;
10
+ resetError: () => void;
11
+ }
12
+ /**
13
+ * Hook for approving token spending for money market actions
14
+ * @param token The token to approve spending for
15
+ * @param spokeProvider The spoke provider instance for the chain
16
+ * @returns Object containing approve function, loading state, error state and reset function
17
+ * @example
18
+ * ```tsx
19
+ * const { approve, isLoading, error } = useMMApprove(token, spokeProvider);
20
+ *
21
+ * // Approve tokens for supply action
22
+ * await approve({ amount: "100", action: "supply" });
23
+ * ```
24
+ */
25
+ export declare function useMMApprove(token: XToken, spokeProvider: SpokeProvider | undefined): UseApproveReturn;
26
+ export {};
27
+ //# sourceMappingURL=useMMApprove.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useMMApprove.d.ts","sourceRoot":"","sources":["../../../src/hooks/mm/useMMApprove.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAG3C,OAAO,KAAK,EAAE,iBAAiB,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAEnE,UAAU,gBAAgB;IACxB,OAAO,EAAE,CAAC,EAAE,MAAM,EAAE,MAAM,EAAE,EAAE;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,iBAAiB,CAAA;KAAE,KAAK,OAAO,CAAC,OAAO,CAAC,CAAC;IACjG,SAAS,EAAE,OAAO,CAAC;IACnB,KAAK,EAAE,KAAK,GAAG,IAAI,CAAC;IACpB,UAAU,EAAE,MAAM,IAAI,CAAC;CACxB;AAED;;;;;;;;;;;;GAYG;AAEH,wBAAgB,YAAY,CAAC,KAAK,EAAE,MAAM,EAAE,aAAa,EAAE,aAAa,GAAG,SAAS,GAAG,gBAAgB,CAuCtG"}
@@ -1,3 +1,4 @@
1
+ import type { SpokeProvider } from '@sodax/sdk';
1
2
  import type { XToken } from '@sodax/types';
2
3
  import { type UseMutationResult } from '@tanstack/react-query';
3
4
  interface RepayResponse {
@@ -11,6 +12,14 @@ interface RepayResponse {
11
12
  * handling the entire repayment process including transaction creation, submission,
12
13
  * and cross-chain communication.
13
14
  *
15
+ * @param {XToken} spokeToken - The token to repay on the spoke chain. Must be an XToken with valid address and chain information.
16
+ * @param {SpokeProvider} spokeProvider - The spoke provider to use for the repay transaction. Must be a valid SpokeProvider instance.
17
+ *
18
+ * @returns {UseMutationResult<RepayResponse, Error, string>} A mutation result object with the following properties:
19
+ * - mutateAsync: Function to execute the repay transaction
20
+ * - isPending: Boolean indicating if a transaction is in progress
21
+ * - error: Error object if the last transaction failed, null otherwise
22
+ *
14
23
  * @example
15
24
  * ```typescript
16
25
  * const { mutateAsync: repay, isPending, error } = useRepay(spokeToken);
@@ -21,6 +30,6 @@ interface RepayResponse {
21
30
  * - spokeProvider is not available
22
31
  * - Transaction execution fails
23
32
  */
24
- export declare function useRepay(spokeToken: XToken): UseMutationResult<RepayResponse, Error, string>;
33
+ export declare function useRepay(spokeToken: XToken, spokeProvider: SpokeProvider | undefined): UseMutationResult<RepayResponse, Error, string>;
25
34
  export {};
26
35
  //# sourceMappingURL=useRepay.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"useRepay.d.ts","sourceRoot":"","sources":["../../../src/hooks/mm/useRepay.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAC3C,OAAO,EAAe,KAAK,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAK5E,UAAU,aAAa;IACrB,EAAE,EAAE,IAAI,CAAC;IACT,KAAK,EAAE,CAAC,KAAK,MAAM,EAAE,EAAE,KAAK,MAAM,EAAE,CAAC,CAAC;CACvC;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,QAAQ,CAAC,UAAU,EAAE,MAAM,GAAG,iBAAiB,CAAC,aAAa,EAAE,KAAK,EAAE,MAAM,CAAC,CA0B5F"}
1
+ {"version":3,"file":"useRepay.d.ts","sourceRoot":"","sources":["../../../src/hooks/mm/useRepay.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAChD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAC3C,OAAO,EAAe,KAAK,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAI5E,UAAU,aAAa;IACrB,EAAE,EAAE,IAAI,CAAC;IACT,KAAK,EAAE,CAAC,KAAK,MAAM,EAAE,EAAE,KAAK,MAAM,EAAE,CAAC,CAAC;CACvC;AAED;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,wBAAgB,QAAQ,CACtB,UAAU,EAAE,MAAM,EAClB,aAAa,EAAE,aAAa,GAAG,SAAS,GACvC,iBAAiB,CAAC,aAAa,EAAE,KAAK,EAAE,MAAM,CAAC,CA0BjD"}
@@ -1,3 +1,4 @@
1
+ import type { SpokeProvider } from '@sodax/sdk';
1
2
  import type { XToken } from '@sodax/types';
2
3
  import { type UseMutationResult } from '@tanstack/react-query';
3
4
  interface SupplyResponse {
@@ -12,6 +13,7 @@ interface SupplyResponse {
12
13
  * and cross-chain communication.
13
14
  *
14
15
  * @param {XToken} spokeToken - The token to supply on the spoke chain. Must be an XToken with valid address and chain information.
16
+ * @param {SpokeProvider} spokeProvider - The spoke provider to use for the supply transaction. Must be a valid SpokeProvider instance.
15
17
  *
16
18
  * @returns {UseMutationResult<SupplyResponse, Error, string>} A mutation result object with the following properties:
17
19
  * - mutateAsync: Function to execute the supply transaction
@@ -27,6 +29,6 @@ interface SupplyResponse {
27
29
  * @throws {Error} When:
28
30
  * - spokeProvider is not available
29
31
  */
30
- export declare function useSupply(spokeToken: XToken): UseMutationResult<SupplyResponse, Error, string>;
32
+ export declare function useSupply(spokeToken: XToken, spokeProvider: SpokeProvider | undefined): UseMutationResult<SupplyResponse, Error, string>;
31
33
  export {};
32
34
  //# sourceMappingURL=useSupply.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"useSupply.d.ts","sourceRoot":"","sources":["../../../src/hooks/mm/useSupply.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAC3C,OAAO,EAAe,KAAK,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAK5E,UAAU,cAAc;IACtB,EAAE,EAAE,IAAI,CAAC;IACT,KAAK,EAAE,CAAC,KAAK,MAAM,EAAE,EAAE,KAAK,MAAM,EAAE,CAAC,CAAC;CACvC;AAED;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAgB,SAAS,CAAC,UAAU,EAAE,MAAM,GAAG,iBAAiB,CAAC,cAAc,EAAE,KAAK,EAAE,MAAM,CAAC,CA0B9F"}
1
+ {"version":3,"file":"useSupply.d.ts","sourceRoot":"","sources":["../../../src/hooks/mm/useSupply.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAChD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAC3C,OAAO,EAAe,KAAK,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAI5E,UAAU,cAAc;IACtB,EAAE,EAAE,IAAI,CAAC;IACT,KAAK,EAAE,CAAC,KAAK,MAAM,EAAE,EAAE,KAAK,MAAM,EAAE,CAAC,CAAC;CACvC;AAED;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,wBAAgB,SAAS,CACvB,UAAU,EAAE,MAAM,EAClB,aAAa,EAAE,aAAa,GAAG,SAAS,GACvC,iBAAiB,CAAC,cAAc,EAAE,KAAK,EAAE,MAAM,CAAC,CA0BlD"}
@@ -1,5 +1,5 @@
1
1
  import type { ChainId } from '@sodax/types';
2
- export declare function useUserReservesData(spokeChainId: ChainId): {
2
+ export declare function useUserReservesData(spokeChainId: ChainId, address: string | undefined): {
3
3
  token: import("@sodax/sdk").XToken | undefined;
4
4
  underlyingAsset: string;
5
5
  scaledATokenBalance: bigint;
@@ -1 +1 @@
1
- {"version":3,"file":"useUserReservesData.d.ts","sourceRoot":"","sources":["../../../src/hooks/mm/useUserReservesData.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAM5C,wBAAgB,mBAAmB,CAAC,YAAY,EAAE,OAAO;;;;;;gBA2CxD"}
1
+ {"version":3,"file":"useUserReservesData.d.ts","sourceRoot":"","sources":["../../../src/hooks/mm/useUserReservesData.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAK5C,wBAAgB,mBAAmB,CAAC,YAAY,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,GAAG,SAAS;;;;;;gBAsCrF"}
@@ -1,3 +1,4 @@
1
+ import type { SpokeProvider } from '@sodax/sdk';
1
2
  import type { XToken } from '@sodax/types';
2
3
  import { type UseMutationResult } from '@tanstack/react-query';
3
4
  interface WithdrawResponse {
@@ -11,6 +12,12 @@ interface WithdrawResponse {
11
12
  * handling the entire withdrawal process including transaction creation, submission,
12
13
  * and cross-chain communication.
13
14
  *
15
+ * @param {XToken} spokeToken - The token to withdraw from the spoke chain. Must be an XToken with valid address and chain information.
16
+ * @param {SpokeProvider} spokeProvider - The spoke provider to use for the withdraw transaction. Must be a valid SpokeProvider instance.
17
+ *
18
+ * @returns {UseMutationResult<WithdrawResponse, Error, string>} A mutation result object with the following properties:
19
+ * - mutateAsync: Function to execute the withdraw transaction
20
+ * - isPending: Boolean indicating if a transaction is in progress
14
21
  * @example
15
22
  * ```typescript
16
23
  * const { mutateAsync: withdraw, isPending, error } = useWithdraw(spokeToken);
@@ -21,6 +28,6 @@ interface WithdrawResponse {
21
28
  * - spokeProvider is not available
22
29
  * - Transaction execution fails
23
30
  */
24
- export declare function useWithdraw(spokeToken: XToken): UseMutationResult<WithdrawResponse, Error, string>;
31
+ export declare function useWithdraw(spokeToken: XToken, spokeProvider: SpokeProvider | undefined): UseMutationResult<WithdrawResponse, Error, string>;
25
32
  export {};
26
33
  //# sourceMappingURL=useWithdraw.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"useWithdraw.d.ts","sourceRoot":"","sources":["../../../src/hooks/mm/useWithdraw.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAC3C,OAAO,EAAe,KAAK,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAK5E,UAAU,gBAAgB;IACxB,EAAE,EAAE,IAAI,CAAC;IACT,KAAK,EAAE,CAAC,KAAK,MAAM,EAAE,EAAE,KAAK,MAAM,EAAE,CAAC,CAAC;CACvC;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,WAAW,CAAC,UAAU,EAAE,MAAM,GAAG,iBAAiB,CAAC,gBAAgB,EAAE,KAAK,EAAE,MAAM,CAAC,CA2BlG"}
1
+ {"version":3,"file":"useWithdraw.d.ts","sourceRoot":"","sources":["../../../src/hooks/mm/useWithdraw.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAChD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAC3C,OAAO,EAAe,KAAK,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAI5E,UAAU,gBAAgB;IACxB,EAAE,EAAE,IAAI,CAAC;IACT,KAAK,EAAE,CAAC,KAAK,MAAM,EAAE,EAAE,KAAK,MAAM,EAAE,CAAC,CAAC;CACvC;AAED;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAgB,WAAW,CACzB,UAAU,EAAE,MAAM,EAClB,aAAa,EAAE,aAAa,GAAG,SAAS,GACvC,iBAAiB,CAAC,gBAAgB,EAAE,KAAK,EAAE,MAAM,CAAC,CA2BpD"}
@@ -1,4 +1,18 @@
1
- import { EvmSpokeProvider, SuiSpokeProvider, IconSpokeProvider, CWSpokeProvider } from '@sodax/sdk';
1
+ import { type SpokeProvider, type IWalletProvider } from '@sodax/sdk';
2
2
  import type { SpokeChainId } from '@sodax/types';
3
- export declare function useSpokeProvider(spokeChainId: SpokeChainId): EvmSpokeProvider | SuiSpokeProvider | IconSpokeProvider | CWSpokeProvider | undefined;
3
+ /**
4
+ * Hook to get the appropriate spoke provider based on the chain type.
5
+ * Supports EVM, SUI, ICON and INJECTIVE chains.
6
+ *
7
+ * @param {SpokeChainId | undefined} spokeChainId - The spoke chain ID to get the provider for
8
+ * @param {IWalletProvider | undefined} walletProvider - The wallet provider to use
9
+ * @returns {SpokeProvider | undefined} The appropriate spoke provider instance for the given chain ID, or undefined if invalid/unsupported
10
+ *
11
+ * @example
12
+ * ```tsx
13
+ * // Using a specific SpokeChainId and wallet provider
14
+ * const spokeProvider = useSpokeProvider(spokeChainId, walletProvider);
15
+ * ```
16
+ */
17
+ export declare function useSpokeProvider(spokeChainId: SpokeChainId | undefined, walletProvider?: IWalletProvider | undefined): SpokeProvider | undefined;
4
18
  //# sourceMappingURL=useSpokeProvider.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"useSpokeProvider.d.ts","sourceRoot":"","sources":["../../../src/hooks/provider/useSpokeProvider.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,gBAAgB,EAGhB,gBAAgB,EAEhB,iBAAiB,EAEjB,eAAe,EAEhB,MAAM,YAAY,CAAC;AACpB,OAAO,KAAK,EAIV,YAAY,EAEb,MAAM,cAAc,CAAC;AAItB,wBAAgB,gBAAgB,CAAC,YAAY,EAAE,YAAY,yFAkC1D"}
1
+ {"version":3,"file":"useSpokeProvider.d.ts","sourceRoot":"","sources":["../../../src/hooks/provider/useSpokeProvider.ts"],"names":[],"mappings":"AAAA,OAAO,EAYL,KAAK,aAAa,EAClB,KAAK,eAAe,EACrB,MAAM,YAAY,CAAC;AACpB,OAAO,KAAK,EAIV,YAAY,EAGb,MAAM,cAAc,CAAC;AAItB;;;;;;;;;;;;;GAaG;AACH,wBAAgB,gBAAgB,CAC9B,YAAY,EAAE,YAAY,GAAG,SAAS,EACtC,cAAc,CAAC,EAAE,eAAe,GAAG,SAAS,GAC3C,aAAa,GAAG,SAAS,CAgD3B"}
@@ -1,4 +1,2 @@
1
1
  export * from './useSodaxContext';
2
- export * from './useAllowance';
3
- export * from './useApprove';
4
2
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/hooks/shared/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC;AAClC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,cAAc,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/hooks/shared/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC"}
@@ -1,4 +1,6 @@
1
1
  export * from './useQuote';
2
2
  export * from './useCreateIntentOrder';
3
3
  export * from './useStatus';
4
+ export * from './useSwapAllowance';
5
+ export * from './useSwapApprove';
4
6
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/hooks/swap/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,cAAc,wBAAwB,CAAC;AACvC,cAAc,aAAa,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/hooks/swap/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,cAAc,wBAAwB,CAAC;AACvC,cAAc,aAAa,CAAC;AAC5B,cAAc,oBAAoB,CAAC;AACnC,cAAc,kBAAkB,CAAC"}
@@ -1,4 +1,4 @@
1
- import type { CreateIntentParams, SpokeChainId, IntentExecutionResponse, Result, IntentSubmitErrorCode, Intent, PacketData, IntentSubmitError } from '@sodax/sdk';
1
+ import type { CreateIntentParams, IntentExecutionResponse, Result, IntentSubmitErrorCode, Intent, PacketData, IntentSubmitError, SpokeProvider } from '@sodax/sdk';
2
2
  import { type UseMutationResult } from '@tanstack/react-query';
3
3
  type CreateIntentResult = Result<[
4
4
  IntentExecutionResponse,
@@ -9,12 +9,12 @@ type CreateIntentResult = Result<[
9
9
  * Hook for creating and submitting an intent order for cross-chain swaps.
10
10
  * Uses React Query's useMutation for better state management and caching.
11
11
  *
12
- * @param {SpokeChainId} chainId - The source chain ID where the swap will originate
12
+ * @param {SpokeProvider} spokeProvider - The spoke provider to use for the swap
13
13
  * @returns {UseMutationResult} Mutation result object containing mutation function and state
14
14
  *
15
15
  * @example
16
16
  * ```typescript
17
- * const { mutateAsync: createIntent, isPending } = useCreateIntentOrder('0xa4b1.arbitrum');
17
+ * const { mutateAsync: createIntent, isPending } = useCreateIntentOrder(spokeProvider);
18
18
  *
19
19
  * const handleSwap = async () => {
20
20
  * const result = await createIntent({
@@ -28,6 +28,6 @@ type CreateIntentResult = Result<[
28
28
  * };
29
29
  * ```
30
30
  */
31
- export declare function useCreateIntentOrder(chainId: SpokeChainId): UseMutationResult<CreateIntentResult, Error, CreateIntentParams>;
31
+ export declare function useCreateIntentOrder(spokeProvider: SpokeProvider | undefined): UseMutationResult<CreateIntentResult, Error, CreateIntentParams>;
32
32
  export {};
33
33
  //# sourceMappingURL=useCreateIntentOrder.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"useCreateIntentOrder.d.ts","sourceRoot":"","sources":["../../../src/hooks/swap/useCreateIntentOrder.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,kBAAkB,EAClB,YAAY,EACZ,uBAAuB,EACvB,MAAM,EACN,qBAAqB,EACrB,MAAM,EACN,UAAU,EACV,iBAAiB,EAClB,MAAM,YAAY,CAAC;AAEpB,OAAO,EAAe,KAAK,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAE5E,KAAK,kBAAkB,GAAG,MAAM,CAC9B;IAAC,uBAAuB;IAAE,MAAM;IAAE,UAAU;CAAC,EAC7C,iBAAiB,CAAC,qBAAqB,CAAC,CACzC,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAgB,oBAAoB,CAClC,OAAO,EAAE,YAAY,GACpB,iBAAiB,CAAC,kBAAkB,EAAE,KAAK,EAAE,kBAAkB,CAAC,CAYlE"}
1
+ {"version":3,"file":"useCreateIntentOrder.d.ts","sourceRoot":"","sources":["../../../src/hooks/swap/useCreateIntentOrder.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,kBAAkB,EAClB,uBAAuB,EACvB,MAAM,EACN,qBAAqB,EACrB,MAAM,EACN,UAAU,EACV,iBAAiB,EACjB,aAAa,EACd,MAAM,YAAY,CAAC;AACpB,OAAO,EAAe,KAAK,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAE5E,KAAK,kBAAkB,GAAG,MAAM,CAC9B;IAAC,uBAAuB;IAAE,MAAM;IAAE,UAAU;CAAC,EAC7C,iBAAiB,CAAC,qBAAqB,CAAC,CACzC,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAgB,oBAAoB,CAClC,aAAa,EAAE,aAAa,GAAG,SAAS,GACvC,iBAAiB,CAAC,kBAAkB,EAAE,KAAK,EAAE,kBAAkB,CAAC,CAWlE"}
@@ -0,0 +1,23 @@
1
+ import { type UseQueryResult } from '@tanstack/react-query';
2
+ import type { CreateIntentParams, SpokeProvider } from '@sodax/sdk';
3
+ /**
4
+ * Hook for checking token allowance for money market operations.
5
+ *
6
+ * This hook verifies if the user has approved enough tokens for a specific money market action
7
+ * (borrow/repay). It automatically queries and tracks the allowance status.
8
+ *
9
+ * @param {CreateIntentParams} params - The parameters for the intent to check allowance for.
10
+ * @param {SpokeProvider} spokeProvider - The spoke provider to use for allowance checks
11
+ *
12
+ * @returns {UseQueryResult<boolean, Error>} A React Query result containing:
13
+ * - data: Boolean indicating if allowance is sufficient
14
+ * - isLoading: Loading state indicator
15
+ * - error: Any error that occurred during the check
16
+ *
17
+ * @example
18
+ * ```typescript
19
+ * const { data: hasAllowed, isLoading } = useMMAllowance(params, spokeProvider);
20
+ * ```
21
+ */
22
+ export declare function useSwapAllowance(params: CreateIntentParams | undefined, spokeProvider: SpokeProvider | undefined): UseQueryResult<boolean, Error>;
23
+ //# sourceMappingURL=useSwapAllowance.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useSwapAllowance.d.ts","sourceRoot":"","sources":["../../../src/hooks/swap/useSwapAllowance.ts"],"names":[],"mappings":"AAAA,OAAO,EAAY,KAAK,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAEtE,OAAO,KAAK,EAAE,kBAAkB,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAEpE;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,gBAAgB,CAC9B,MAAM,EAAE,kBAAkB,GAAG,SAAS,EACtC,aAAa,EAAE,aAAa,GAAG,SAAS,GACvC,cAAc,CAAC,OAAO,EAAE,KAAK,CAAC,CAiBhC"}
@@ -0,0 +1,26 @@
1
+ import type { Token } from '@sodax/types';
2
+ import type { SpokeProvider } from '@sodax/sdk';
3
+ interface UseApproveReturn {
4
+ approve: ({ amount }: {
5
+ amount: string;
6
+ }) => Promise<boolean>;
7
+ isLoading: boolean;
8
+ error: Error | null;
9
+ resetError: () => void;
10
+ }
11
+ /**
12
+ * Hook for approving token spending for money market actions
13
+ * @param token The token to approve spending for
14
+ * @param spokeProvider The spoke provider instance for the chain
15
+ * @returns Object containing approve function, loading state, error state and reset function
16
+ * @example
17
+ * ```tsx
18
+ * const { approve, isLoading, error } = useApprove(token, spokeProvider);
19
+ *
20
+ * // Approve tokens for supply action
21
+ * await approve({ amount: "100", action: "supply" });
22
+ * ```
23
+ */
24
+ export declare function useSwapApprove(token: Token | undefined, spokeProvider: SpokeProvider | undefined): UseApproveReturn;
25
+ export {};
26
+ //# sourceMappingURL=useSwapApprove.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useSwapApprove.d.ts","sourceRoot":"","sources":["../../../src/hooks/swap/useSwapApprove.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,cAAc,CAAC;AAG1C,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAEhD,UAAU,gBAAgB;IACxB,OAAO,EAAE,CAAC,EAAE,MAAM,EAAE,EAAE;QAAE,MAAM,EAAE,MAAM,CAAA;KAAE,KAAK,OAAO,CAAC,OAAO,CAAC,CAAC;IAC9D,SAAS,EAAE,OAAO,CAAC;IACnB,KAAK,EAAE,KAAK,GAAG,IAAI,CAAC;IACpB,UAAU,EAAE,MAAM,IAAI,CAAC;CACxB;AAED;;;;;;;;;;;;GAYG;AAEH,wBAAgB,cAAc,CAAC,KAAK,EAAE,KAAK,GAAG,SAAS,EAAE,aAAa,EAAE,aAAa,GAAG,SAAS,GAAG,gBAAgB,CAwCnH"}