@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.
- package/README.md +130 -39
- package/dist/index.d.mts +576 -346
- package/dist/index.d.ts +576 -346
- package/dist/index.js +357 -176
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +354 -178
- package/dist/index.mjs.map +1 -1
- package/package.json +3 -3
- package/src/hooks/backend/README.md +148 -49
- package/src/hooks/backend/index.ts +2 -0
- package/src/hooks/backend/types.ts +4 -0
- package/src/hooks/backend/useBackendAllMoneyMarketAssets.ts +31 -20
- package/src/hooks/backend/useBackendAllMoneyMarketBorrowers.ts +25 -7
- package/src/hooks/backend/useBackendIntentByHash.ts +36 -26
- package/src/hooks/backend/useBackendIntentByTxHash.ts +41 -29
- package/src/hooks/backend/useBackendMoneyMarketAsset.ts +40 -27
- package/src/hooks/backend/useBackendMoneyMarketAssetBorrowers.ts +45 -36
- package/src/hooks/backend/useBackendMoneyMarketAssetSuppliers.ts +45 -36
- package/src/hooks/backend/useBackendMoneyMarketPosition.ts +34 -37
- package/src/hooks/backend/useBackendOrderbook.ts +38 -38
- package/src/hooks/backend/useBackendUserIntents.ts +81 -0
- package/src/hooks/mm/index.ts +2 -0
- package/src/hooks/mm/useAToken.ts +37 -20
- package/src/hooks/mm/useATokensBalances.ts +87 -0
- package/src/hooks/mm/useBorrow.ts +36 -36
- package/src/hooks/mm/useMMAllowance.ts +33 -24
- package/src/hooks/mm/useMMApprove.ts +43 -48
- package/src/hooks/mm/useRepay.ts +32 -36
- package/src/hooks/mm/useReservesData.ts +35 -16
- package/src/hooks/mm/useReservesHumanized.ts +15 -3
- package/src/hooks/mm/useReservesList.ts +28 -15
- package/src/hooks/mm/useReservesUsdFormat.ts +30 -21
- package/src/hooks/mm/useSupply.ts +34 -36
- package/src/hooks/mm/useUserFormattedSummary.ts +42 -20
- package/src/hooks/mm/useUserReservesData.ts +34 -19
- package/src/hooks/mm/useWithdraw.ts +33 -35
- package/src/hooks/swap/index.ts +2 -0
- package/src/hooks/swap/useCancelLimitOrder.ts +53 -0
- package/src/hooks/swap/useCreateLimitOrder.ts +72 -0
- package/src/hooks/swap/useSwapAllowance.ts +7 -7
- 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
|
|
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
|
|
9
|
-
*
|
|
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 } =
|
|
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
|
|
14
|
-
* @param
|
|
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
|
}
|