@sodax/dapp-kit 1.0.1-beta → 1.0.3-beta

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 (41) hide show
  1. package/README.md +130 -39
  2. package/dist/index.d.mts +576 -346
  3. package/dist/index.d.ts +576 -346
  4. package/dist/index.js +357 -176
  5. package/dist/index.js.map +1 -1
  6. package/dist/index.mjs +354 -178
  7. package/dist/index.mjs.map +1 -1
  8. package/package.json +3 -3
  9. package/src/hooks/backend/README.md +148 -49
  10. package/src/hooks/backend/index.ts +2 -0
  11. package/src/hooks/backend/types.ts +4 -0
  12. package/src/hooks/backend/useBackendAllMoneyMarketAssets.ts +31 -20
  13. package/src/hooks/backend/useBackendAllMoneyMarketBorrowers.ts +25 -7
  14. package/src/hooks/backend/useBackendIntentByHash.ts +36 -26
  15. package/src/hooks/backend/useBackendIntentByTxHash.ts +41 -29
  16. package/src/hooks/backend/useBackendMoneyMarketAsset.ts +40 -27
  17. package/src/hooks/backend/useBackendMoneyMarketAssetBorrowers.ts +45 -36
  18. package/src/hooks/backend/useBackendMoneyMarketAssetSuppliers.ts +45 -36
  19. package/src/hooks/backend/useBackendMoneyMarketPosition.ts +34 -37
  20. package/src/hooks/backend/useBackendOrderbook.ts +38 -38
  21. package/src/hooks/backend/useBackendUserIntents.ts +81 -0
  22. package/src/hooks/mm/index.ts +2 -0
  23. package/src/hooks/mm/useAToken.ts +37 -20
  24. package/src/hooks/mm/useATokensBalances.ts +87 -0
  25. package/src/hooks/mm/useBorrow.ts +36 -36
  26. package/src/hooks/mm/useMMAllowance.ts +33 -24
  27. package/src/hooks/mm/useMMApprove.ts +43 -48
  28. package/src/hooks/mm/useRepay.ts +32 -36
  29. package/src/hooks/mm/useReservesData.ts +35 -16
  30. package/src/hooks/mm/useReservesHumanized.ts +15 -3
  31. package/src/hooks/mm/useReservesList.ts +28 -15
  32. package/src/hooks/mm/useReservesUsdFormat.ts +30 -21
  33. package/src/hooks/mm/useSupply.ts +34 -36
  34. package/src/hooks/mm/useUserFormattedSummary.ts +42 -20
  35. package/src/hooks/mm/useUserReservesData.ts +34 -19
  36. package/src/hooks/mm/useWithdraw.ts +33 -35
  37. package/src/hooks/swap/index.ts +2 -0
  38. package/src/hooks/swap/useCancelLimitOrder.ts +53 -0
  39. package/src/hooks/swap/useCreateLimitOrder.ts +72 -0
  40. package/src/hooks/swap/useSwapAllowance.ts +7 -7
  41. package/src/hooks/swap/useSwapApprove.ts +6 -6
@@ -1,14 +1,14 @@
1
1
  import { useQuery, type UseQueryResult } from '@tanstack/react-query';
2
2
  import { useSodaxContext } from '../shared/useSodaxContext';
3
- import type { CreateIntentParams, SpokeProvider } from '@sodax/sdk';
3
+ import type { CreateIntentParams, CreateLimitOrderParams, SpokeProvider } from '@sodax/sdk';
4
4
 
5
5
  /**
6
- * Hook for checking token allowance for money market operations.
6
+ * Hook for checking token allowance for swap operations.
7
7
  *
8
- * This hook verifies if the user has approved enough tokens for a specific money market action
9
- * (borrow/repay). It automatically queries and tracks the allowance status.
8
+ * This hook verifies if the user has approved enough tokens for a specific swap action.
9
+ * It automatically queries and tracks the allowance status.
10
10
  *
11
- * @param {CreateIntentParams} params - The parameters for the intent to check allowance for.
11
+ * @param {CreateIntentParams | CreateLimitOrderParams} params - The parameters for the intent to check allowance for.
12
12
  * @param {SpokeProvider} spokeProvider - The spoke provider to use for allowance checks
13
13
  *
14
14
  * @returns {UseQueryResult<boolean, Error>} A React Query result containing:
@@ -18,11 +18,11 @@ import type { CreateIntentParams, SpokeProvider } from '@sodax/sdk';
18
18
  *
19
19
  * @example
20
20
  * ```typescript
21
- * const { data: hasAllowed, isLoading } = useMMAllowance(params, spokeProvider);
21
+ * const { data: hasAllowed, isLoading } = useSwapAllowance(params, spokeProvider);
22
22
  * ```
23
23
  */
24
24
  export function useSwapAllowance(
25
- params: CreateIntentParams | undefined,
25
+ params: CreateIntentParams | CreateLimitOrderParams | undefined,
26
26
  spokeProvider: SpokeProvider | undefined,
27
27
  ): UseQueryResult<boolean, Error> {
28
28
  const { sodax } = useSodaxContext();
@@ -1,17 +1,17 @@
1
1
  import { useSodaxContext } from '../shared/useSodaxContext';
2
2
  import { useMutation, useQueryClient } from '@tanstack/react-query';
3
- import type { CreateIntentParams, SpokeProvider } from '@sodax/sdk';
3
+ import type { CreateIntentParams, CreateLimitOrderParams, SpokeProvider } from '@sodax/sdk';
4
4
 
5
5
  interface UseApproveReturn {
6
- approve: ({ params }: { params: CreateIntentParams }) => Promise<boolean>;
6
+ approve: ({ params }: { params: CreateIntentParams | CreateLimitOrderParams }) => Promise<boolean>;
7
7
  isLoading: boolean;
8
8
  error: Error | null;
9
9
  resetError: () => void;
10
10
  }
11
11
 
12
12
  /**
13
- * Hook for approving token spending for money market actions
14
- * @param token The token to approve spending for
13
+ * Hook for approving token spending for swap actions
14
+ * @param params The parameters for the intent to approve spending for
15
15
  * @param spokeProvider The spoke provider instance for the chain
16
16
  * @returns Object containing approve function, loading state, error state and reset function
17
17
  * @example
@@ -24,7 +24,7 @@ interface UseApproveReturn {
24
24
  */
25
25
 
26
26
  export function useSwapApprove(
27
- params: CreateIntentParams | undefined,
27
+ params: CreateIntentParams | CreateLimitOrderParams | undefined,
28
28
  spokeProvider: SpokeProvider | undefined,
29
29
  ): UseApproveReturn {
30
30
  const { sodax } = useSodaxContext();
@@ -36,7 +36,7 @@ export function useSwapApprove(
36
36
  error,
37
37
  reset: resetError,
38
38
  } = useMutation({
39
- mutationFn: async ({ params }: { params: CreateIntentParams | undefined }) => {
39
+ mutationFn: async ({ params }: { params: CreateIntentParams | CreateLimitOrderParams | undefined }) => {
40
40
  if (!spokeProvider) {
41
41
  throw new Error('Spoke provider not found');
42
42
  }