@sodax/dapp-kit 0.0.1-rc.29 → 0.0.1-rc.30
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 +37 -37
- package/dist/index.d.mts +1425 -0
- package/dist/index.d.ts +1425 -5
- package/dist/index.js +364 -0
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +347 -1
- package/dist/index.mjs.map +1 -1
- package/package.json +3 -3
- package/src/contexts/index.ts +1 -1
- package/src/hooks/bridge/useGetBridgeableAmount.ts +1 -1
- package/src/hooks/index.ts +1 -0
- package/src/hooks/shared/useDeriveUserWalletAddress.ts +1 -1
- package/src/hooks/staking/index.ts +19 -0
- package/src/hooks/staking/useCancelUnstake.ts +52 -0
- package/src/hooks/staking/useClaim.ts +46 -0
- package/src/hooks/staking/useConvertedAssets.ts +47 -0
- package/src/hooks/staking/useInstantUnstake.ts +50 -0
- package/src/hooks/staking/useInstantUnstakeAllowance.ts +59 -0
- package/src/hooks/staking/useInstantUnstakeApprove.ts +52 -0
- package/src/hooks/staking/useInstantUnstakeRatio.ts +54 -0
- package/src/hooks/staking/useStake.ts +47 -0
- package/src/hooks/staking/useStakeAllowance.ts +57 -0
- package/src/hooks/staking/useStakeApprove.ts +50 -0
- package/src/hooks/staking/useStakeRatio.ts +53 -0
- package/src/hooks/staking/useStakingConfig.ts +40 -0
- package/src/hooks/staking/useStakingInfo.ts +50 -0
- package/src/hooks/staking/useUnstake.ts +54 -0
- package/src/hooks/staking/useUnstakeAllowance.ts +58 -0
- package/src/hooks/staking/useUnstakeApprove.ts +52 -0
- package/src/hooks/staking/useUnstakingInfo.ts +53 -0
- package/src/hooks/staking/useUnstakingInfoWithPenalty.ts +59 -0
- package/src/index.ts +0 -1
- package/src/providers/SodaxProvider.tsx +1 -1
- package/dist/contexts/index.d.ts +0 -9
- package/dist/contexts/index.d.ts.map +0 -1
- package/dist/core/index.d.ts +0 -3
- package/dist/core/index.d.ts.map +0 -1
- package/dist/hooks/backend/index.d.ts +0 -17
- package/dist/hooks/backend/index.d.ts.map +0 -1
- package/dist/hooks/backend/useBackendAllMoneyMarketAssets.d.ts +0 -37
- package/dist/hooks/backend/useBackendAllMoneyMarketAssets.d.ts.map +0 -1
- package/dist/hooks/backend/useBackendAllMoneyMarketBorrowers.d.ts +0 -45
- package/dist/hooks/backend/useBackendAllMoneyMarketBorrowers.d.ts.map +0 -1
- package/dist/hooks/backend/useBackendIntentByHash.d.ts +0 -36
- package/dist/hooks/backend/useBackendIntentByHash.d.ts.map +0 -1
- package/dist/hooks/backend/useBackendIntentByTxHash.d.ts +0 -35
- package/dist/hooks/backend/useBackendIntentByTxHash.d.ts.map +0 -1
- package/dist/hooks/backend/useBackendMoneyMarketAsset.d.ts +0 -38
- package/dist/hooks/backend/useBackendMoneyMarketAsset.d.ts.map +0 -1
- package/dist/hooks/backend/useBackendMoneyMarketAssetBorrowers.d.ts +0 -47
- package/dist/hooks/backend/useBackendMoneyMarketAssetBorrowers.d.ts.map +0 -1
- package/dist/hooks/backend/useBackendMoneyMarketAssetSuppliers.d.ts +0 -47
- package/dist/hooks/backend/useBackendMoneyMarketAssetSuppliers.d.ts.map +0 -1
- package/dist/hooks/backend/useBackendMoneyMarketPosition.d.ts +0 -37
- package/dist/hooks/backend/useBackendMoneyMarketPosition.d.ts.map +0 -1
- package/dist/hooks/backend/useBackendOrderbook.d.ts +0 -46
- package/dist/hooks/backend/useBackendOrderbook.d.ts.map +0 -1
- package/dist/hooks/bridge/index.d.ts +0 -6
- package/dist/hooks/bridge/index.d.ts.map +0 -1
- package/dist/hooks/bridge/useBridge.d.ts +0 -33
- package/dist/hooks/bridge/useBridge.d.ts.map +0 -1
- package/dist/hooks/bridge/useBridgeAllowance.d.ts +0 -23
- package/dist/hooks/bridge/useBridgeAllowance.d.ts.map +0 -1
- package/dist/hooks/bridge/useBridgeApprove.d.ts +0 -29
- package/dist/hooks/bridge/useBridgeApprove.d.ts.map +0 -1
- package/dist/hooks/bridge/useGetBridgeableAmount.d.ts +0 -26
- package/dist/hooks/bridge/useGetBridgeableAmount.d.ts.map +0 -1
- package/dist/hooks/bridge/useGetBridgeableTokens.d.ts +0 -37
- package/dist/hooks/bridge/useGetBridgeableTokens.d.ts.map +0 -1
- package/dist/hooks/index.d.ts +0 -7
- package/dist/hooks/index.d.ts.map +0 -1
- package/dist/hooks/mm/index.d.ts +0 -9
- package/dist/hooks/mm/index.d.ts.map +0 -1
- package/dist/hooks/mm/useBorrow.d.ts +0 -35
- package/dist/hooks/mm/useBorrow.d.ts.map +0 -1
- package/dist/hooks/mm/useMMAllowance.d.ts +0 -26
- package/dist/hooks/mm/useMMAllowance.d.ts.map +0 -1
- package/dist/hooks/mm/useMMApprove.d.ts +0 -27
- package/dist/hooks/mm/useMMApprove.d.ts.map +0 -1
- package/dist/hooks/mm/useRepay.d.ts +0 -35
- package/dist/hooks/mm/useRepay.d.ts.map +0 -1
- package/dist/hooks/mm/useReservesData.d.ts +0 -19
- package/dist/hooks/mm/useReservesData.d.ts.map +0 -1
- package/dist/hooks/mm/useReservesHumanized.d.ts +0 -21
- package/dist/hooks/mm/useReservesHumanized.d.ts.map +0 -1
- package/dist/hooks/mm/useReservesList.d.ts +0 -18
- package/dist/hooks/mm/useReservesList.d.ts.map +0 -1
- package/dist/hooks/mm/useReservesUsdFormat.d.ts +0 -23
- package/dist/hooks/mm/useReservesUsdFormat.d.ts.map +0 -1
- package/dist/hooks/mm/useSupply.d.ts +0 -34
- package/dist/hooks/mm/useSupply.d.ts.map +0 -1
- package/dist/hooks/mm/useUserFormattedSummary.d.ts +0 -21
- package/dist/hooks/mm/useUserFormattedSummary.d.ts.map +0 -1
- package/dist/hooks/mm/useUserReservesData.d.ts +0 -20
- package/dist/hooks/mm/useUserReservesData.d.ts.map +0 -1
- package/dist/hooks/mm/useWithdraw.d.ts +0 -33
- package/dist/hooks/mm/useWithdraw.d.ts.map +0 -1
- package/dist/hooks/provider/index.d.ts +0 -3
- package/dist/hooks/provider/index.d.ts.map +0 -1
- package/dist/hooks/provider/useHubProvider.d.ts +0 -3
- package/dist/hooks/provider/useHubProvider.d.ts.map +0 -1
- package/dist/hooks/provider/useSpokeProvider.d.ts +0 -18
- package/dist/hooks/provider/useSpokeProvider.d.ts.map +0 -1
- package/dist/hooks/shared/index.d.ts +0 -6
- package/dist/hooks/shared/index.d.ts.map +0 -1
- package/dist/hooks/shared/useDeriveUserWalletAddress.d.ts +0 -24
- package/dist/hooks/shared/useDeriveUserWalletAddress.d.ts.map +0 -1
- package/dist/hooks/shared/useEstimateGas.d.ts +0 -4
- package/dist/hooks/shared/useEstimateGas.d.ts.map +0 -1
- package/dist/hooks/shared/useRequestTrustline.d.ts +0 -44
- package/dist/hooks/shared/useRequestTrustline.d.ts.map +0 -1
- package/dist/hooks/shared/useSodaxContext.d.ts +0 -8
- package/dist/hooks/shared/useSodaxContext.d.ts.map +0 -1
- package/dist/hooks/shared/useStellarTrustlineCheck.d.ts +0 -40
- package/dist/hooks/shared/useStellarTrustlineCheck.d.ts.map +0 -1
- package/dist/hooks/swap/index.d.ts +0 -7
- package/dist/hooks/swap/index.d.ts.map +0 -1
- package/dist/hooks/swap/useCancelSwap.d.ts +0 -29
- package/dist/hooks/swap/useCancelSwap.d.ts.map +0 -1
- package/dist/hooks/swap/useQuote.d.ts +0 -39
- package/dist/hooks/swap/useQuote.d.ts.map +0 -1
- package/dist/hooks/swap/useStatus.d.ts +0 -31
- package/dist/hooks/swap/useStatus.d.ts.map +0 -1
- package/dist/hooks/swap/useSwap.d.ts +0 -29
- package/dist/hooks/swap/useSwap.d.ts.map +0 -1
- package/dist/hooks/swap/useSwapAllowance.d.ts +0 -23
- package/dist/hooks/swap/useSwapAllowance.d.ts.map +0 -1
- package/dist/hooks/swap/useSwapApprove.d.ts +0 -25
- package/dist/hooks/swap/useSwapApprove.d.ts.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/providers/SodaxProvider.d.ts +0 -12
- package/dist/providers/SodaxProvider.d.ts.map +0 -1
- package/dist/providers/index.d.ts +0 -2
- package/dist/providers/index.d.ts.map +0 -1
- package/dist/types.d.ts +0 -17
- package/dist/types.d.ts.map +0 -1
- package/src/types.ts +0 -22
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
// packages/dapp-kit/src/hooks/staking/useStakingConfig.ts
|
|
2
|
+
import { useSodaxContext } from '../shared/useSodaxContext';
|
|
3
|
+
import type { StakingConfig } from '@sodax/sdk';
|
|
4
|
+
import { useQuery, type UseQueryResult } from '@tanstack/react-query';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Hook for fetching staking configuration from the stakedSoda contract.
|
|
8
|
+
* Uses React Query for efficient caching and state management.
|
|
9
|
+
*
|
|
10
|
+
* @param {number} refetchInterval - The interval in milliseconds to refetch data (default: 30000)
|
|
11
|
+
* @returns {UseQueryResult<StakingConfig, Error>} Query result object containing staking config and state
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* ```typescript
|
|
15
|
+
* const { data: stakingConfig, isLoading, error } = useStakingConfig();
|
|
16
|
+
*
|
|
17
|
+
* if (isLoading) return <div>Loading staking config...</div>;
|
|
18
|
+
* if (stakingConfig) {
|
|
19
|
+
* console.log('Unstaking period (days):', stakingConfig.unstakingPeriod / 86400n);
|
|
20
|
+
* console.log('Max penalty (%):', stakingConfig.maxPenalty);
|
|
21
|
+
* }
|
|
22
|
+
* ```
|
|
23
|
+
*/
|
|
24
|
+
export function useStakingConfig(refetchInterval = 30000): UseQueryResult<StakingConfig, Error> {
|
|
25
|
+
const { sodax } = useSodaxContext();
|
|
26
|
+
|
|
27
|
+
return useQuery({
|
|
28
|
+
queryKey: ['soda', 'stakingConfig'],
|
|
29
|
+
queryFn: async () => {
|
|
30
|
+
const result = await sodax.staking.getStakingConfig();
|
|
31
|
+
|
|
32
|
+
if (!result.ok) {
|
|
33
|
+
throw new Error(`Failed to fetch staking config: ${result.error.code}`);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
return result.value;
|
|
37
|
+
},
|
|
38
|
+
refetchInterval,
|
|
39
|
+
});
|
|
40
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
// packages/dapp-kit/src/hooks/staking/useStakingInfo.ts
|
|
2
|
+
import { useSodaxContext } from '../shared/useSodaxContext';
|
|
3
|
+
import type { StakingInfo, SpokeProvider } from '@sodax/sdk';
|
|
4
|
+
import { useQuery, type UseQueryResult } from '@tanstack/react-query';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Hook for fetching comprehensive staking information for a user.
|
|
8
|
+
* Uses React Query for efficient caching and state management.
|
|
9
|
+
*
|
|
10
|
+
* @param {SpokeProvider | undefined} spokeProvider - The spoke provider to use for the query
|
|
11
|
+
* @param {number} refetchInterval - The interval in milliseconds to refetch data (default: 5000)
|
|
12
|
+
* @returns {UseQueryResult<StakingInfo, Error>} Query result object containing staking info and state
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* ```typescript
|
|
16
|
+
* const { data: stakingInfo, isLoading, error } = useStakingInfo(spokeProvider);
|
|
17
|
+
*
|
|
18
|
+
* if (isLoading) return <div>Loading staking info...</div>;
|
|
19
|
+
* if (stakingInfo) {
|
|
20
|
+
* console.log('Total staked:', stakingInfo.totalStaked);
|
|
21
|
+
* console.log('User staked:', stakingInfo.userStaked);
|
|
22
|
+
* console.log('xSODA balance:', stakingInfo.userXSodaBalance);
|
|
23
|
+
* }
|
|
24
|
+
* ```
|
|
25
|
+
*/
|
|
26
|
+
export function useStakingInfo(
|
|
27
|
+
spokeProvider: SpokeProvider | undefined,
|
|
28
|
+
refetchInterval = 5000,
|
|
29
|
+
): UseQueryResult<StakingInfo, Error> {
|
|
30
|
+
const { sodax } = useSodaxContext();
|
|
31
|
+
|
|
32
|
+
return useQuery({
|
|
33
|
+
queryKey: ['soda', 'stakingInfo', spokeProvider?.chainConfig.chain.id],
|
|
34
|
+
queryFn: async () => {
|
|
35
|
+
if (!spokeProvider) {
|
|
36
|
+
throw new Error('Spoke provider not found');
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
const result = await sodax.staking.getStakingInfoFromSpoke(spokeProvider);
|
|
40
|
+
|
|
41
|
+
if (!result.ok) {
|
|
42
|
+
throw new Error(`Failed to fetch staking info: ${result.error.code}`);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
return result.value;
|
|
46
|
+
},
|
|
47
|
+
enabled: !!spokeProvider,
|
|
48
|
+
refetchInterval,
|
|
49
|
+
});
|
|
50
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
// packages/dapp-kit/src/hooks/staking/useUnstake.ts
|
|
2
|
+
import { useSodaxContext } from '../shared/useSodaxContext';
|
|
3
|
+
import type { UnstakeParams, SpokeTxHash, HubTxHash, SpokeProvider } from '@sodax/sdk';
|
|
4
|
+
import { useMutation, useQueryClient, type UseMutationResult } from '@tanstack/react-query';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Hook for executing unstake transactions to unstake xSODA shares.
|
|
8
|
+
* Uses React Query's useMutation for better state management and caching.
|
|
9
|
+
*
|
|
10
|
+
* @param {SpokeProvider | undefined} spokeProvider - The spoke provider to use for the unstake
|
|
11
|
+
* @returns {UseMutationResult<[SpokeTxHash, HubTxHash], Error, Omit<UnstakeParams, 'action'>>} Mutation result object containing mutation function and state
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* ```typescript
|
|
15
|
+
* const { mutateAsync: unstake, isPending } = useUnstake(spokeProvider);
|
|
16
|
+
*
|
|
17
|
+
* const handleUnstake = async () => {
|
|
18
|
+
* const result = await unstake({
|
|
19
|
+
* amount: 1000000000000000000n, // 1 xSODA
|
|
20
|
+
* account: '0x...'
|
|
21
|
+
* });
|
|
22
|
+
*
|
|
23
|
+
* console.log('Unstake successful:', result);
|
|
24
|
+
* };
|
|
25
|
+
* ```
|
|
26
|
+
*/
|
|
27
|
+
export function useUnstake(
|
|
28
|
+
spokeProvider: SpokeProvider | undefined,
|
|
29
|
+
): UseMutationResult<[SpokeTxHash, HubTxHash], Error, Omit<UnstakeParams, 'action'>> {
|
|
30
|
+
const { sodax } = useSodaxContext();
|
|
31
|
+
const queryClient = useQueryClient();
|
|
32
|
+
|
|
33
|
+
return useMutation<[SpokeTxHash, HubTxHash], Error, Omit<UnstakeParams, 'action'>>({
|
|
34
|
+
mutationFn: async (params: Omit<UnstakeParams, 'action'>) => {
|
|
35
|
+
if (!spokeProvider) {
|
|
36
|
+
throw new Error('Spoke provider not found');
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
const result = await sodax.staking.unstake({ ...params, action: 'unstake' }, spokeProvider);
|
|
40
|
+
|
|
41
|
+
if (!result.ok) {
|
|
42
|
+
throw new Error(`Unstake failed: ${result.error.code}`);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
return result.value;
|
|
46
|
+
},
|
|
47
|
+
onSuccess: () => {
|
|
48
|
+
// Invalidate relevant queries to refresh data
|
|
49
|
+
queryClient.invalidateQueries({ queryKey: ['stakingInfo'] });
|
|
50
|
+
queryClient.invalidateQueries({ queryKey: ['unstakingInfo'] });
|
|
51
|
+
queryClient.invalidateQueries({ queryKey: ['unstakingInfoWithPenalty'] });
|
|
52
|
+
},
|
|
53
|
+
});
|
|
54
|
+
}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
// packages/dapp-kit/src/hooks/staking/useStakeAllowance.ts
|
|
2
|
+
import { useSodaxContext } from '../shared/useSodaxContext';
|
|
3
|
+
import type { UnstakeParams, SpokeProvider } from '@sodax/sdk';
|
|
4
|
+
import { useQuery, type UseQueryResult } from '@tanstack/react-query';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Hook for checking xSODA token allowance for unstaking operations.
|
|
8
|
+
* Uses React Query for efficient caching and state management.
|
|
9
|
+
*
|
|
10
|
+
* @param {Omit<UnstakeParams, 'action'> | undefined} params - The unstaking parameters. If undefined, the query will be disabled.
|
|
11
|
+
* @param {SpokeProvider | undefined} spokeProvider - The spoke provider to use for the allowance check
|
|
12
|
+
* @returns {UseQueryResult<boolean, Error>} Query result object containing allowance data and state
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* ```typescript
|
|
16
|
+
* const { data: hasAllowed, isLoading } = useUnstakeAllowance(
|
|
17
|
+
* {
|
|
18
|
+
* amount: 1000000000000000000n, // 1 xSODA
|
|
19
|
+
* account: '0x...'
|
|
20
|
+
* },
|
|
21
|
+
* spokeProvider
|
|
22
|
+
* );
|
|
23
|
+
*
|
|
24
|
+
* if (isLoading) return <div>Checking allowance...</div>;
|
|
25
|
+
* if (hasAllowed) {
|
|
26
|
+
* console.log('Sufficient allowance for unstaking');
|
|
27
|
+
* }
|
|
28
|
+
* ```
|
|
29
|
+
*/
|
|
30
|
+
export function useUnstakeAllowance(
|
|
31
|
+
params: Omit<UnstakeParams, 'action'> | undefined,
|
|
32
|
+
spokeProvider: SpokeProvider | undefined,
|
|
33
|
+
): UseQueryResult<boolean, Error> {
|
|
34
|
+
const { sodax } = useSodaxContext();
|
|
35
|
+
|
|
36
|
+
return useQuery({
|
|
37
|
+
queryKey: ['soda', 'unstakeAllowance', params, spokeProvider?.chainConfig.chain.id],
|
|
38
|
+
queryFn: async () => {
|
|
39
|
+
if (!params || !spokeProvider) {
|
|
40
|
+
return false;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
const result = await sodax.staking.isAllowanceValid({
|
|
44
|
+
params: { ...params, action: 'unstake' },
|
|
45
|
+
spokeProvider,
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
if (!result.ok) {
|
|
49
|
+
console.error(`Unstake allowance check failed: ${result.error.code}, error: ${result.error.error}`);
|
|
50
|
+
throw new Error(`Unstake allowance check failed: ${result.error.code}`);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
return result.value;
|
|
54
|
+
},
|
|
55
|
+
enabled: !!params && !!spokeProvider,
|
|
56
|
+
refetchInterval: 5000, // Refetch every 5 seconds
|
|
57
|
+
});
|
|
58
|
+
}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
// packages/dapp-kit/src/hooks/staking/useStakeApprove.ts
|
|
2
|
+
import { useSodaxContext } from '../shared/useSodaxContext';
|
|
3
|
+
import type { TxReturnType, UnstakeParams } from '@sodax/sdk';
|
|
4
|
+
import { useMutation, type UseMutationResult } from '@tanstack/react-query';
|
|
5
|
+
import type { SpokeProvider } from '@sodax/sdk';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Hook for approving xSODA token spending for unstaking operations.
|
|
9
|
+
* Uses React Query's useMutation for better state management and caching.
|
|
10
|
+
*
|
|
11
|
+
* @param {SpokeProvider | undefined} spokeProvider - The spoke provider to use for the approval
|
|
12
|
+
* @returns {UseMutationResult<TxReturnType<SpokeProvider, false>, Error, Omit<UnstakeParams, 'action'>>} Mutation result object containing mutation function and state
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* ```typescript
|
|
16
|
+
* const { mutateAsync: approve, isPending } = useUnstakeApprove(spokeProvider);
|
|
17
|
+
*
|
|
18
|
+
* const handleApprove = async () => {
|
|
19
|
+
* const result = await approve({
|
|
20
|
+
* amount: 1000000000000000000n, // 1 xSODA
|
|
21
|
+
* account: '0x...'
|
|
22
|
+
* });
|
|
23
|
+
*
|
|
24
|
+
* console.log('Approval successful:', result);
|
|
25
|
+
* };
|
|
26
|
+
* ```
|
|
27
|
+
*/
|
|
28
|
+
export function useUnstakeApprove(
|
|
29
|
+
spokeProvider: SpokeProvider | undefined,
|
|
30
|
+
): UseMutationResult<TxReturnType<SpokeProvider, false>, Error, Omit<UnstakeParams, 'action'>> {
|
|
31
|
+
const { sodax } = useSodaxContext();
|
|
32
|
+
|
|
33
|
+
return useMutation<TxReturnType<SpokeProvider, false>, Error, Omit<UnstakeParams, 'action'>>({
|
|
34
|
+
mutationFn: async (params: Omit<UnstakeParams, 'action'>) => {
|
|
35
|
+
console.log('useUnstakeApprove called with params:', params);
|
|
36
|
+
if (!spokeProvider) {
|
|
37
|
+
throw new Error('Spoke provider not found');
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
const result = await sodax.staking.approve({
|
|
41
|
+
params: { ...params, action: 'unstake' },
|
|
42
|
+
spokeProvider,
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
if (!result.ok) {
|
|
46
|
+
throw new Error(`Unstake approval failed: ${result.error.code}`);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
return result.value;
|
|
50
|
+
},
|
|
51
|
+
});
|
|
52
|
+
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
// packages/dapp-kit/src/hooks/staking/useUnstakingInfoWithPenalty.ts
|
|
2
|
+
import { useSodaxContext } from '../shared/useSodaxContext';
|
|
3
|
+
import type { UnstakingInfo, SpokeProvider } from '@sodax/sdk';
|
|
4
|
+
import { useQuery, type UseQueryResult } from '@tanstack/react-query';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Hook for fetching unstaking information from the stakedSoda contract.
|
|
8
|
+
* Uses React Query for efficient caching and state management.
|
|
9
|
+
*
|
|
10
|
+
* @param {string | undefined} userAddress - The user address to fetch unstaking info for
|
|
11
|
+
* @param {SpokeProvider | undefined} spokeProvider - The spoke provider instance
|
|
12
|
+
* @param {number} refetchInterval - The interval in milliseconds to refetch data (default: 5000)
|
|
13
|
+
* @returns {UseQueryResult<UnstakingInfo, Error>} Query result object containing unstaking info and state
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* ```typescript
|
|
17
|
+
* const { data: unstakingInfo, isLoading, error } = useUnstakingInfo(userAddress, spokeProvider);
|
|
18
|
+
*
|
|
19
|
+
* if (isLoading) return <div>Loading unstaking info...</div>;
|
|
20
|
+
* if (unstakingInfo) {
|
|
21
|
+
* console.log('Total unstaking:', unstakingInfo.totalUnstaking);
|
|
22
|
+
* unstakingInfo.userUnstakeSodaRequests.forEach(request => {
|
|
23
|
+
* console.log('Request amount:', request.request.amount);
|
|
24
|
+
* });
|
|
25
|
+
* }
|
|
26
|
+
* ```
|
|
27
|
+
*/
|
|
28
|
+
export function useUnstakingInfo(
|
|
29
|
+
userAddress: string | undefined,
|
|
30
|
+
spokeProvider: SpokeProvider | undefined,
|
|
31
|
+
refetchInterval = 5000,
|
|
32
|
+
): UseQueryResult<UnstakingInfo, Error> {
|
|
33
|
+
const { sodax } = useSodaxContext();
|
|
34
|
+
|
|
35
|
+
return useQuery({
|
|
36
|
+
queryKey: ['soda', 'unstakingInfoWithPenalty', spokeProvider?.chainConfig.chain.id, userAddress],
|
|
37
|
+
queryFn: async () => {
|
|
38
|
+
if (!spokeProvider || !userAddress) {
|
|
39
|
+
throw new Error('Spoke provider or user address not found');
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
const result = await sodax.staking.getUnstakingInfo(spokeProvider);
|
|
43
|
+
|
|
44
|
+
if (!result.ok) {
|
|
45
|
+
throw new Error(`Failed to fetch unstaking info: ${result.error.code}`);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
return result.value;
|
|
49
|
+
},
|
|
50
|
+
enabled: !!spokeProvider && !!userAddress,
|
|
51
|
+
refetchInterval,
|
|
52
|
+
});
|
|
53
|
+
}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
// packages/dapp-kit/src/hooks/staking/useUnstakingInfoWithPenalty.ts
|
|
2
|
+
import { useSodaxContext } from '../shared/useSodaxContext';
|
|
3
|
+
import type { UnstakingInfo, UnstakeRequestWithPenalty, SpokeProvider } from '@sodax/sdk';
|
|
4
|
+
import { useQuery, type UseQueryResult } from '@tanstack/react-query';
|
|
5
|
+
|
|
6
|
+
export type UnstakingInfoWithPenalty = UnstakingInfo & {
|
|
7
|
+
requestsWithPenalty: UnstakeRequestWithPenalty[];
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Hook for fetching unstaking information with penalty calculations from the stakedSoda contract.
|
|
12
|
+
* Uses React Query for efficient caching and state management.
|
|
13
|
+
*
|
|
14
|
+
* @param {string | undefined} userAddress - The user address to fetch unstaking info for
|
|
15
|
+
* @param {SpokeProvider | undefined} spokeProvider - The spoke provider instance
|
|
16
|
+
* @param {number} refetchInterval - The interval in milliseconds to refetch data (default: 5000)
|
|
17
|
+
* @returns {UseQueryResult<UnstakingInfoWithPenalty, Error>} Query result object containing unstaking info with penalties and state
|
|
18
|
+
*
|
|
19
|
+
* @example
|
|
20
|
+
* ```typescript
|
|
21
|
+
* const { data: unstakingInfo, isLoading, error } = useUnstakingInfoWithPenalty(userAddress, spokeProvider);
|
|
22
|
+
*
|
|
23
|
+
* if (isLoading) return <div>Loading unstaking info...</div>;
|
|
24
|
+
* if (unstakingInfo) {
|
|
25
|
+
* console.log('Total unstaking:', unstakingInfo.totalUnstaking);
|
|
26
|
+
* unstakingInfo.requestsWithPenalty.forEach(request => {
|
|
27
|
+
* console.log('Penalty:', request.penaltyPercentage + '%');
|
|
28
|
+
* console.log('Claimable amount:', request.claimableAmount);
|
|
29
|
+
* });
|
|
30
|
+
* }
|
|
31
|
+
* ```
|
|
32
|
+
*/
|
|
33
|
+
export function useUnstakingInfoWithPenalty(
|
|
34
|
+
userAddress: string | undefined,
|
|
35
|
+
spokeProvider: SpokeProvider | undefined,
|
|
36
|
+
refetchInterval = 5000,
|
|
37
|
+
): UseQueryResult<UnstakingInfoWithPenalty, Error> {
|
|
38
|
+
const { sodax } = useSodaxContext();
|
|
39
|
+
|
|
40
|
+
return useQuery({
|
|
41
|
+
queryKey: ['soda', 'unstakingInfoWithPenalty', spokeProvider?.chainConfig.chain.id, userAddress],
|
|
42
|
+
queryFn: async () => {
|
|
43
|
+
if (!spokeProvider) {
|
|
44
|
+
throw new Error('Spoke provider not found');
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
// Get unstaking info with penalty calculations
|
|
48
|
+
const penaltyResult = await sodax.staking.getUnstakingInfoWithPenalty(spokeProvider);
|
|
49
|
+
|
|
50
|
+
if (!penaltyResult.ok) {
|
|
51
|
+
throw new Error(`Failed to fetch unstaking info with penalty: ${penaltyResult.error.code}`);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
return penaltyResult.value;
|
|
55
|
+
},
|
|
56
|
+
enabled: !!spokeProvider && !!userAddress,
|
|
57
|
+
refetchInterval,
|
|
58
|
+
});
|
|
59
|
+
}
|
package/src/index.ts
CHANGED
|
@@ -3,7 +3,7 @@ import React from 'react';
|
|
|
3
3
|
|
|
4
4
|
import { Sodax, type SodaxConfig } from '@sodax/sdk';
|
|
5
5
|
import { SodaxContext } from '@/contexts';
|
|
6
|
-
import type { RpcConfig } from '
|
|
6
|
+
import type { RpcConfig } from '@sodax/types';
|
|
7
7
|
|
|
8
8
|
interface SodaxProviderProps {
|
|
9
9
|
children: ReactNode;
|
package/dist/contexts/index.d.ts
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import type { Sodax } from '@sodax/sdk';
|
|
2
|
-
import type { RpcConfig } from '@/types';
|
|
3
|
-
export interface SodaxContextType {
|
|
4
|
-
sodax: Sodax;
|
|
5
|
-
testnet: boolean;
|
|
6
|
-
rpcConfig: RpcConfig;
|
|
7
|
-
}
|
|
8
|
-
export declare const SodaxContext: import("react").Context<SodaxContextType | null>;
|
|
9
|
-
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/contexts/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AACxC,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAEzC,MAAM,WAAW,gBAAgB;IAC/B,KAAK,EAAE,KAAK,CAAC;IACb,OAAO,EAAE,OAAO,CAAC;IACjB,SAAS,EAAE,SAAS,CAAC;CACtB;AAED,eAAO,MAAM,YAAY,kDAA+C,CAAC"}
|
package/dist/core/index.d.ts
DELETED
package/dist/core/index.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/core/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAI5C,eAAO,MAAM,2BAA2B,iBAAkB,OAAO,SAAS,MAAM,uBAO/E,CAAC"}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Backend API Hooks
|
|
3
|
-
*
|
|
4
|
-
* This module exports all hooks for interacting with the BackendApiService.
|
|
5
|
-
* These hooks provide a React-friendly interface to the Sodax Backend API,
|
|
6
|
-
* including intent management, solver orderbook, and money market operations.
|
|
7
|
-
*/
|
|
8
|
-
export { useBackendIntentByTxHash } from './useBackendIntentByTxHash';
|
|
9
|
-
export { useBackendIntentByHash } from './useBackendIntentByHash';
|
|
10
|
-
export { useBackendOrderbook } from './useBackendOrderbook';
|
|
11
|
-
export { useBackendMoneyMarketPosition } from './useBackendMoneyMarketPosition';
|
|
12
|
-
export { useBackendAllMoneyMarketAssets } from './useBackendAllMoneyMarketAssets';
|
|
13
|
-
export { useBackendMoneyMarketAsset } from './useBackendMoneyMarketAsset';
|
|
14
|
-
export { useBackendMoneyMarketAssetBorrowers } from './useBackendMoneyMarketAssetBorrowers';
|
|
15
|
-
export { useBackendMoneyMarketAssetSuppliers } from './useBackendMoneyMarketAssetSuppliers';
|
|
16
|
-
export { useBackendAllMoneyMarketBorrowers } from './useBackendAllMoneyMarketBorrowers';
|
|
17
|
-
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/hooks/backend/index.ts"],"names":[],"mappings":"AACA;;;;;;GAMG;AAGH,OAAO,EAAE,wBAAwB,EAAE,MAAM,4BAA4B,CAAC;AACtE,OAAO,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AAGlE,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAG5D,OAAO,EAAE,6BAA6B,EAAE,MAAM,iCAAiC,CAAC;AAChF,OAAO,EAAE,8BAA8B,EAAE,MAAM,kCAAkC,CAAC;AAClF,OAAO,EAAE,0BAA0B,EAAE,MAAM,8BAA8B,CAAC;AAC1E,OAAO,EAAE,mCAAmC,EAAE,MAAM,uCAAuC,CAAC;AAC5F,OAAO,EAAE,mCAAmC,EAAE,MAAM,uCAAuC,CAAC;AAC5F,OAAO,EAAE,iCAAiC,EAAE,MAAM,qCAAqC,CAAC"}
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import { type UseQueryResult } from '@tanstack/react-query';
|
|
2
|
-
import type { MoneyMarketAsset } from '@sodax/sdk';
|
|
3
|
-
/**
|
|
4
|
-
* Hook for fetching all money market assets from the backend API.
|
|
5
|
-
*
|
|
6
|
-
* This hook provides access to all available money market assets, including
|
|
7
|
-
* their reserve information, liquidity rates, borrow rates, and market statistics.
|
|
8
|
-
* The data is automatically fetched and cached using React Query.
|
|
9
|
-
*
|
|
10
|
-
* @returns {UseQueryResult<MoneyMarketAsset[]>} A query result object containing:
|
|
11
|
-
* - data: Array of money market asset data when available
|
|
12
|
-
* - isLoading: Boolean indicating if the request is in progress
|
|
13
|
-
* - error: Error object if the request failed
|
|
14
|
-
* - refetch: Function to manually trigger a data refresh
|
|
15
|
-
*
|
|
16
|
-
* @example
|
|
17
|
-
* ```typescript
|
|
18
|
-
* const { data: assets, isLoading, error } = useAllMoneyMarketAssets();
|
|
19
|
-
*
|
|
20
|
-
* if (isLoading) return <div>Loading assets...</div>;
|
|
21
|
-
* if (error) return <div>Error: {error.message}</div>;
|
|
22
|
-
* if (assets) {
|
|
23
|
-
* console.log('Total assets:', assets.length);
|
|
24
|
-
* assets.forEach(asset => {
|
|
25
|
-
* console.log(`${asset.symbol}: ${asset.liquidityRate} liquidity rate`);
|
|
26
|
-
* });
|
|
27
|
-
* }
|
|
28
|
-
* ```
|
|
29
|
-
*
|
|
30
|
-
* @remarks
|
|
31
|
-
* - Uses React Query for efficient caching and state management
|
|
32
|
-
* - Automatically handles error states and loading indicators
|
|
33
|
-
* - Returns comprehensive asset information including rates and statistics
|
|
34
|
-
* - No parameters required - fetches all available assets
|
|
35
|
-
*/
|
|
36
|
-
export declare const useBackendAllMoneyMarketAssets: () => UseQueryResult<MoneyMarketAsset[]>;
|
|
37
|
-
//# sourceMappingURL=useBackendAllMoneyMarketAssets.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useBackendAllMoneyMarketAssets.d.ts","sourceRoot":"","sources":["../../../src/hooks/backend/useBackendAllMoneyMarketAssets.ts"],"names":[],"mappings":"AACA,OAAO,EAAY,KAAK,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACtE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAGnD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AACH,eAAO,MAAM,8BAA8B,QAAO,cAAc,CAAC,gBAAgB,EAAE,CAUlF,CAAC"}
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
import { type UseQueryResult } from '@tanstack/react-query';
|
|
2
|
-
import type { MoneyMarketBorrowers } from '@sodax/sdk';
|
|
3
|
-
/**
|
|
4
|
-
* Hook for fetching all money market borrowers from the backend API.
|
|
5
|
-
*
|
|
6
|
-
* This hook provides access to the list of all borrowers across all money market assets,
|
|
7
|
-
* with pagination support. The data is automatically fetched and cached using React Query.
|
|
8
|
-
*
|
|
9
|
-
* @param {Object} params - Pagination parameters for fetching all borrowers
|
|
10
|
-
* @param {string} params.offset - The offset for pagination (number as string)
|
|
11
|
-
* @param {string} params.limit - The limit for pagination (number as string)
|
|
12
|
-
*
|
|
13
|
-
* @returns {UseQueryResult<MoneyMarketBorrowers | undefined>} A query result object containing:
|
|
14
|
-
* - data: The all borrowers data when available
|
|
15
|
-
* - isLoading: Boolean indicating if the request is in progress
|
|
16
|
-
* - error: Error object if the request failed
|
|
17
|
-
* - refetch: Function to manually trigger a data refresh
|
|
18
|
-
*
|
|
19
|
-
* @example
|
|
20
|
-
* ```typescript
|
|
21
|
-
* const { data: borrowers, isLoading, error } = useAllMoneyMarketBorrowers({
|
|
22
|
-
* offset: '0',
|
|
23
|
-
* limit: '50'
|
|
24
|
-
* });
|
|
25
|
-
*
|
|
26
|
-
* if (isLoading) return <div>Loading borrowers...</div>;
|
|
27
|
-
* if (error) return <div>Error: {error.message}</div>;
|
|
28
|
-
* if (borrowers) {
|
|
29
|
-
* console.log('Total borrowers:', borrowers.total);
|
|
30
|
-
* console.log('Borrowers:', borrowers.borrowers);
|
|
31
|
-
* }
|
|
32
|
-
* ```
|
|
33
|
-
*
|
|
34
|
-
* @remarks
|
|
35
|
-
* - The query is disabled when params are undefined or invalid
|
|
36
|
-
* - Uses React Query for efficient caching and state management
|
|
37
|
-
* - Automatically handles error states and loading indicators
|
|
38
|
-
* - Supports pagination through offset and limit parameters
|
|
39
|
-
* - Returns borrowers across all money market assets
|
|
40
|
-
*/
|
|
41
|
-
export declare const useBackendAllMoneyMarketBorrowers: (params: {
|
|
42
|
-
offset: string;
|
|
43
|
-
limit: string;
|
|
44
|
-
} | undefined) => UseQueryResult<MoneyMarketBorrowers | undefined>;
|
|
45
|
-
//# sourceMappingURL=useBackendAllMoneyMarketBorrowers.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useBackendAllMoneyMarketBorrowers.d.ts","sourceRoot":"","sources":["../../../src/hooks/backend/useBackendAllMoneyMarketBorrowers.ts"],"names":[],"mappings":"AACA,OAAO,EAAY,KAAK,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACtE,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAC;AAGvD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqCG;AACH,eAAO,MAAM,iCAAiC,WACpC;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,GAAG,SAAS,KACpD,cAAc,CAAC,oBAAoB,GAAG,SAAS,CAejD,CAAC"}
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import { type UseQueryResult } from '@tanstack/react-query';
|
|
2
|
-
import type { IntentResponse } from '@sodax/sdk';
|
|
3
|
-
/**
|
|
4
|
-
* Hook for fetching intent details by intent hash from the backend API.
|
|
5
|
-
*
|
|
6
|
-
* This hook provides access to intent data using the intent hash directly,
|
|
7
|
-
* including intent details, events, and transaction information. The data is automatically
|
|
8
|
-
* fetched and cached using React Query.
|
|
9
|
-
*
|
|
10
|
-
* @param {string | undefined} intentHash - The intent hash to fetch intent for. If undefined, the query will be disabled.
|
|
11
|
-
*
|
|
12
|
-
* @returns {UseQueryResult<IntentResponse | undefined>} A query result object containing:
|
|
13
|
-
* - data: The intent response data when available
|
|
14
|
-
* - isLoading: Boolean indicating if the request is in progress
|
|
15
|
-
* - error: Error object if the request failed
|
|
16
|
-
* - refetch: Function to manually trigger a data refresh
|
|
17
|
-
*
|
|
18
|
-
* @example
|
|
19
|
-
* ```typescript
|
|
20
|
-
* const { data: intent, isLoading, error } = useIntentByHash('0xabc...');
|
|
21
|
-
*
|
|
22
|
-
* if (isLoading) return <div>Loading intent...</div>;
|
|
23
|
-
* if (error) return <div>Error: {error.message}</div>;
|
|
24
|
-
* if (intent) {
|
|
25
|
-
* console.log('Intent found:', intent.intentHash);
|
|
26
|
-
* console.log('Open status:', intent.open);
|
|
27
|
-
* }
|
|
28
|
-
* ```
|
|
29
|
-
*
|
|
30
|
-
* @remarks
|
|
31
|
-
* - The query is disabled when intentHash is undefined or empty
|
|
32
|
-
* - Uses React Query for efficient caching and state management
|
|
33
|
-
* - Automatically handles error states and loading indicators
|
|
34
|
-
*/
|
|
35
|
-
export declare const useBackendIntentByHash: (intentHash: string | undefined) => UseQueryResult<IntentResponse | undefined>;
|
|
36
|
-
//# sourceMappingURL=useBackendIntentByHash.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useBackendIntentByHash.d.ts","sourceRoot":"","sources":["../../../src/hooks/backend/useBackendIntentByHash.ts"],"names":[],"mappings":"AACA,OAAO,EAAY,KAAK,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACtE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAGjD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,eAAO,MAAM,sBAAsB,eAAgB,MAAM,GAAG,SAAS,KAAG,cAAc,CAAC,cAAc,GAAG,SAAS,CAehH,CAAC"}
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import { type UseQueryResult } from '@tanstack/react-query';
|
|
2
|
-
import type { IntentResponse } from '@sodax/sdk';
|
|
3
|
-
/**
|
|
4
|
-
* Hook for fetching intent details by transaction hash from the backend API.
|
|
5
|
-
*
|
|
6
|
-
* This hook provides access to intent data associated with a specific transaction hash,
|
|
7
|
-
* including intent details, events, and transaction information. The data is automatically
|
|
8
|
-
* fetched and cached using React Query.
|
|
9
|
-
*
|
|
10
|
-
* @param {string | undefined} txHash - The transaction hash to fetch intent for. If undefined, the query will be disabled.
|
|
11
|
-
*
|
|
12
|
-
* @returns {UseQueryResult<IntentResponse | undefined>} A query result object containing:
|
|
13
|
-
* - data: The intent response data when available
|
|
14
|
-
* - isLoading: Boolean indicating if the request is in progress
|
|
15
|
-
* - error: Error object if the request failed
|
|
16
|
-
* - refetch: Function to manually trigger a data refresh
|
|
17
|
-
*
|
|
18
|
-
* @example
|
|
19
|
-
* ```typescript
|
|
20
|
-
* const { data: intent, isLoading, error } = useIntentByTxHash('0x123...');
|
|
21
|
-
*
|
|
22
|
-
* if (isLoading) return <div>Loading intent...</div>;
|
|
23
|
-
* if (error) return <div>Error: {error.message}</div>;
|
|
24
|
-
* if (intent) {
|
|
25
|
-
* console.log('Intent found:', intent.intentHash);
|
|
26
|
-
* }
|
|
27
|
-
* ```
|
|
28
|
-
*
|
|
29
|
-
* @remarks
|
|
30
|
-
* - The query is disabled when txHash is undefined or empty
|
|
31
|
-
* - Uses React Query for efficient caching and state management
|
|
32
|
-
* - Automatically handles error states and loading indicators
|
|
33
|
-
*/
|
|
34
|
-
export declare const useBackendIntentByTxHash: (txHash: string | undefined) => UseQueryResult<IntentResponse | undefined>;
|
|
35
|
-
//# sourceMappingURL=useBackendIntentByTxHash.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useBackendIntentByTxHash.d.ts","sourceRoot":"","sources":["../../../src/hooks/backend/useBackendIntentByTxHash.ts"],"names":[],"mappings":"AACA,OAAO,EAAY,KAAK,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACtE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAGjD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,eAAO,MAAM,wBAAwB,WAAY,MAAM,GAAG,SAAS,KAAG,cAAc,CAAC,cAAc,GAAG,SAAS,CAe9G,CAAC"}
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import { type UseQueryResult } from '@tanstack/react-query';
|
|
2
|
-
import type { MoneyMarketAsset } from '@sodax/sdk';
|
|
3
|
-
/**
|
|
4
|
-
* Hook for fetching specific money market asset details from the backend API.
|
|
5
|
-
*
|
|
6
|
-
* This hook provides access to detailed information for a specific money market asset,
|
|
7
|
-
* including reserve information, liquidity rates, borrow rates, and market statistics.
|
|
8
|
-
* The data is automatically fetched and cached using React Query.
|
|
9
|
-
*
|
|
10
|
-
* @param {string | undefined} reserveAddress - The reserve contract address. If undefined, the query will be disabled.
|
|
11
|
-
*
|
|
12
|
-
* @returns {UseQueryResult<MoneyMarketAsset | undefined>} A query result object containing:
|
|
13
|
-
* - data: The money market asset data when available
|
|
14
|
-
* - isLoading: Boolean indicating if the request is in progress
|
|
15
|
-
* - error: Error object if the request failed
|
|
16
|
-
* - refetch: Function to manually trigger a data refresh
|
|
17
|
-
*
|
|
18
|
-
* @example
|
|
19
|
-
* ```typescript
|
|
20
|
-
* const { data: asset, isLoading, error } = useMoneyMarketAsset('0xabc...');
|
|
21
|
-
*
|
|
22
|
-
* if (isLoading) return <div>Loading asset...</div>;
|
|
23
|
-
* if (error) return <div>Error: {error.message}</div>;
|
|
24
|
-
* if (asset) {
|
|
25
|
-
* console.log('Asset symbol:', asset.symbol);
|
|
26
|
-
* console.log('Liquidity rate:', asset.liquidityRate);
|
|
27
|
-
* console.log('Variable borrow rate:', asset.variableBorrowRate);
|
|
28
|
-
* }
|
|
29
|
-
* ```
|
|
30
|
-
*
|
|
31
|
-
* @remarks
|
|
32
|
-
* - The query is disabled when reserveAddress is undefined or empty
|
|
33
|
-
* - Uses React Query for efficient caching and state management
|
|
34
|
-
* - Automatically handles error states and loading indicators
|
|
35
|
-
* - Returns comprehensive asset information for the specified reserve
|
|
36
|
-
*/
|
|
37
|
-
export declare const useBackendMoneyMarketAsset: (reserveAddress: string | undefined) => UseQueryResult<MoneyMarketAsset | undefined>;
|
|
38
|
-
//# sourceMappingURL=useBackendMoneyMarketAsset.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useBackendMoneyMarketAsset.d.ts","sourceRoot":"","sources":["../../../src/hooks/backend/useBackendMoneyMarketAsset.ts"],"names":[],"mappings":"AACA,OAAO,EAAY,KAAK,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACtE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAGnD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AACH,eAAO,MAAM,0BAA0B,mBACrB,MAAM,GAAG,SAAS,KACjC,cAAc,CAAC,gBAAgB,GAAG,SAAS,CAe7C,CAAC"}
|