@sodax/dapp-kit 0.0.1-rc.9 → 1.0.0-rc.2
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/LICENSE +21 -0
- package/README.md +142 -44
- package/dist/index.d.mts +1514 -0
- package/dist/index.d.ts +1514 -4
- package/dist/index.js +997 -82
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +957 -84
- package/dist/index.mjs.map +1 -1
- package/package.json +7 -8
- package/src/contexts/index.ts +3 -2
- package/src/hooks/backend/README.md +135 -0
- package/src/hooks/backend/index.ts +23 -0
- package/src/hooks/backend/useBackendAllMoneyMarketAssets.ts +49 -0
- package/src/hooks/backend/useBackendAllMoneyMarketBorrowers.ts +61 -0
- package/src/hooks/backend/useBackendIntentByHash.ts +53 -0
- package/src/hooks/backend/useBackendIntentByTxHash.ts +52 -0
- package/src/hooks/backend/useBackendMoneyMarketAsset.ts +57 -0
- package/src/hooks/backend/useBackendMoneyMarketAssetBorrowers.ts +67 -0
- package/src/hooks/backend/useBackendMoneyMarketAssetSuppliers.ts +67 -0
- package/src/hooks/backend/useBackendMoneyMarketPosition.ts +56 -0
- package/src/hooks/backend/useBackendOrderbook.ts +63 -0
- package/src/hooks/bridge/index.ts +5 -0
- package/src/hooks/bridge/useBridge.ts +57 -0
- package/src/hooks/bridge/useBridgeAllowance.ts +49 -0
- package/src/hooks/bridge/useBridgeApprove.ts +68 -0
- package/src/hooks/bridge/useGetBridgeableAmount.ts +50 -0
- package/src/hooks/bridge/useGetBridgeableTokens.ts +62 -0
- package/src/hooks/index.ts +4 -0
- package/src/hooks/migrate/index.ts +4 -0
- package/src/hooks/migrate/types.ts +15 -0
- package/src/hooks/migrate/useMigrate.tsx +110 -0
- package/src/hooks/migrate/useMigrationAllowance.tsx +79 -0
- package/src/hooks/migrate/useMigrationApprove.tsx +129 -0
- package/src/hooks/mm/useMMAllowance.ts +2 -1
- package/src/hooks/mm/useMMApprove.ts +2 -1
- package/src/hooks/mm/useReservesData.ts +1 -8
- package/src/hooks/mm/useReservesHumanized.ts +30 -0
- package/src/hooks/mm/useReservesList.ts +29 -0
- package/src/hooks/mm/useReservesUsdFormat.ts +38 -0
- package/src/hooks/mm/useUserFormattedSummary.ts +54 -0
- package/src/hooks/mm/useUserReservesData.ts +30 -31
- package/src/hooks/provider/useHubProvider.ts +3 -3
- package/src/hooks/provider/useSpokeProvider.ts +45 -21
- package/src/hooks/shared/index.ts +4 -0
- package/src/hooks/shared/useDeriveUserWalletAddress.ts +44 -0
- package/src/hooks/shared/useEstimateGas.ts +18 -0
- package/src/hooks/shared/useRequestTrustline.ts +103 -0
- package/src/hooks/shared/useStellarTrustlineCheck.ts +71 -0
- 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/hooks/swap/index.ts +2 -1
- package/src/hooks/swap/useCancelSwap.ts +44 -0
- package/src/hooks/swap/useQuote.ts +16 -2
- package/src/hooks/swap/useStatus.ts +1 -1
- package/src/hooks/swap/{useCreateIntentOrder.ts → useSwap.ts} +16 -11
- package/src/hooks/swap/useSwapAllowance.ts +5 -1
- package/src/hooks/swap/useSwapApprove.ts +14 -14
- package/src/providers/SodaxProvider.tsx +8 -20
- package/dist/contexts/index.d.ts +0 -8
- 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/index.d.ts +0 -5
- 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/useSupply.d.ts +0 -34
- package/dist/hooks/mm/useSupply.d.ts.map +0 -1
- package/dist/hooks/mm/useUserReservesData.d.ts +0 -3
- 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 -2
- package/dist/hooks/shared/index.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/swap/index.d.ts +0 -6
- package/dist/hooks/swap/index.d.ts.map +0 -1
- package/dist/hooks/swap/useCreateIntentOrder.d.ts +0 -33
- package/dist/hooks/swap/useCreateIntentOrder.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/useSwapAllowance.d.ts +0 -23
- package/dist/hooks/swap/useSwapAllowance.d.ts.map +0 -1
- package/dist/hooks/swap/useSwapApprove.d.ts +0 -26
- 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 -10
- 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
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
import { useSodaxContext } from '../shared/useSodaxContext';
|
|
2
|
-
import type { Token } from '@sodax/types';
|
|
3
|
-
import { type Address, parseUnits } from 'viem';
|
|
4
2
|
import { useMutation, useQueryClient } from '@tanstack/react-query';
|
|
5
|
-
import type { SpokeProvider } from '@sodax/sdk';
|
|
3
|
+
import type { CreateIntentParams, SpokeProvider } from '@sodax/sdk';
|
|
6
4
|
|
|
7
5
|
interface UseApproveReturn {
|
|
8
|
-
approve: ({
|
|
6
|
+
approve: ({ params }: { params: CreateIntentParams }) => Promise<boolean>;
|
|
9
7
|
isLoading: boolean;
|
|
10
8
|
error: Error | null;
|
|
11
9
|
resetError: () => void;
|
|
@@ -25,7 +23,10 @@ interface UseApproveReturn {
|
|
|
25
23
|
* ```
|
|
26
24
|
*/
|
|
27
25
|
|
|
28
|
-
export function useSwapApprove(
|
|
26
|
+
export function useSwapApprove(
|
|
27
|
+
params: CreateIntentParams | undefined,
|
|
28
|
+
spokeProvider: SpokeProvider | undefined,
|
|
29
|
+
): UseApproveReturn {
|
|
29
30
|
const { sodax } = useSodaxContext();
|
|
30
31
|
const queryClient = useQueryClient();
|
|
31
32
|
|
|
@@ -35,27 +36,26 @@ export function useSwapApprove(token: Token | undefined, spokeProvider: SpokePro
|
|
|
35
36
|
error,
|
|
36
37
|
reset: resetError,
|
|
37
38
|
} = useMutation({
|
|
38
|
-
mutationFn: async ({
|
|
39
|
+
mutationFn: async ({ params }: { params: CreateIntentParams | undefined }) => {
|
|
39
40
|
if (!spokeProvider) {
|
|
40
41
|
throw new Error('Spoke provider not found');
|
|
41
42
|
}
|
|
42
|
-
if (!
|
|
43
|
-
throw new Error('
|
|
43
|
+
if (!params) {
|
|
44
|
+
throw new Error('Swap Params not found');
|
|
44
45
|
}
|
|
45
46
|
|
|
46
|
-
const allowance = await sodax.
|
|
47
|
-
|
|
48
|
-
parseUnits(amount, token.decimals),
|
|
47
|
+
const allowance = await sodax.swap.approve({
|
|
48
|
+
intentParams: params,
|
|
49
49
|
spokeProvider,
|
|
50
|
-
);
|
|
50
|
+
});
|
|
51
51
|
if (!allowance.ok) {
|
|
52
|
-
throw new Error('Failed to approve
|
|
52
|
+
throw new Error('Failed to approve input token');
|
|
53
53
|
}
|
|
54
54
|
return allowance.ok;
|
|
55
55
|
},
|
|
56
56
|
onSuccess: () => {
|
|
57
57
|
// Invalidate allowance query to refetch the new allowance
|
|
58
|
-
queryClient.invalidateQueries({ queryKey: ['allowance',
|
|
58
|
+
queryClient.invalidateQueries({ queryKey: ['allowance', params] });
|
|
59
59
|
},
|
|
60
60
|
});
|
|
61
61
|
|
|
@@ -1,31 +1,19 @@
|
|
|
1
1
|
import type { ReactNode, ReactElement } from 'react';
|
|
2
|
-
import
|
|
2
|
+
import React from 'react';
|
|
3
|
+
|
|
4
|
+
import { Sodax, type SodaxConfig } from '@sodax/sdk';
|
|
3
5
|
import { SodaxContext } from '@/contexts';
|
|
4
|
-
import
|
|
6
|
+
import type { RpcConfig } from '@sodax/types';
|
|
5
7
|
|
|
6
8
|
interface SodaxProviderProps {
|
|
7
9
|
children: ReactNode;
|
|
8
10
|
testnet?: boolean;
|
|
9
|
-
config
|
|
11
|
+
config?: SodaxConfig;
|
|
12
|
+
rpcConfig: RpcConfig;
|
|
10
13
|
}
|
|
11
14
|
|
|
12
|
-
export const SodaxProvider = ({ children, testnet = false, config }: SodaxProviderProps): ReactElement => {
|
|
15
|
+
export const SodaxProvider = ({ children, testnet = false, config, rpcConfig }: SodaxProviderProps): ReactElement => {
|
|
13
16
|
const sodax = new Sodax(config);
|
|
14
17
|
|
|
15
|
-
|
|
16
|
-
const hubRpcUrl = config?.hubProviderConfig?.hubRpcUrl;
|
|
17
|
-
|
|
18
|
-
const hubProvider = useMemo(() => {
|
|
19
|
-
if (hubChainId && hubRpcUrl) {
|
|
20
|
-
const hubChainCfg = getHubChainConfig(hubChainId);
|
|
21
|
-
|
|
22
|
-
return new EvmHubProvider({
|
|
23
|
-
hubRpcUrl: hubRpcUrl,
|
|
24
|
-
chainConfig: hubChainCfg,
|
|
25
|
-
});
|
|
26
|
-
}
|
|
27
|
-
return undefined;
|
|
28
|
-
}, [hubChainId, hubRpcUrl]);
|
|
29
|
-
|
|
30
|
-
return <SodaxContext.Provider value={{ sodax, testnet, hubProvider }}>{children}</SodaxContext.Provider>;
|
|
18
|
+
return <SodaxContext.Provider value={{ sodax, testnet, rpcConfig }}>{children}</SodaxContext.Provider>;
|
|
31
19
|
};
|
package/dist/contexts/index.d.ts
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import type { EvmHubProvider, Sodax } from '@sodax/sdk';
|
|
2
|
-
export interface SodaxContextType {
|
|
3
|
-
sodax: Sodax;
|
|
4
|
-
testnet: boolean;
|
|
5
|
-
hubProvider: EvmHubProvider | undefined;
|
|
6
|
-
}
|
|
7
|
-
export declare const SodaxContext: import("react").Context<SodaxContextType | null>;
|
|
8
|
-
//# 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,cAAc,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AAExD,MAAM,WAAW,gBAAgB;IAC/B,KAAK,EAAE,KAAK,CAAC;IACb,OAAO,EAAE,OAAO,CAAC;IACjB,WAAW,EAAE,cAAc,GAAG,SAAS,CAAC;CACzC;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"}
|
package/dist/hooks/index.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/hooks/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC;AACzB,cAAc,YAAY,CAAC;AAC3B,cAAc,MAAM,CAAC;AACrB,cAAc,QAAQ,CAAC"}
|
package/dist/hooks/mm/index.d.ts
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
export * from './useBorrow';
|
|
2
|
-
export * from './useRepay';
|
|
3
|
-
export * from './useSupply';
|
|
4
|
-
export * from './useWithdraw';
|
|
5
|
-
export * from './useUserReservesData';
|
|
6
|
-
export * from './useReservesData';
|
|
7
|
-
export * from './useMMAllowance';
|
|
8
|
-
export * from './useMMApprove';
|
|
9
|
-
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
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,mBAAmB,CAAC;AAClC,cAAc,kBAAkB,CAAC;AACjC,cAAc,gBAAgB,CAAC"}
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import type { XToken } from '@sodax/types';
|
|
2
|
-
import { type UseMutationResult } from '@tanstack/react-query';
|
|
3
|
-
import type { SpokeProvider } from '@sodax/sdk';
|
|
4
|
-
interface BorrowResponse {
|
|
5
|
-
ok: true;
|
|
6
|
-
value: [string, string];
|
|
7
|
-
}
|
|
8
|
-
/**
|
|
9
|
-
* Hook for borrowing tokens from the Sodax money market.
|
|
10
|
-
*
|
|
11
|
-
* This hook provides functionality to borrow tokens from the money market protocol,
|
|
12
|
-
* handling the entire borrow process including transaction creation, submission,
|
|
13
|
-
* and cross-chain communication.
|
|
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
|
-
*
|
|
23
|
-
* @example
|
|
24
|
-
* ```typescript
|
|
25
|
-
* const { mutateAsync: borrow, isPending, error } = useBorrow(spokeToken);
|
|
26
|
-
* await borrow('100');
|
|
27
|
-
* ```
|
|
28
|
-
*
|
|
29
|
-
* @throws {Error} When:
|
|
30
|
-
* - spokeProvider is not available
|
|
31
|
-
* - Transaction execution fails
|
|
32
|
-
*/
|
|
33
|
-
export declare function useBorrow(spokeToken: XToken, spokeProvider: SpokeProvider | undefined): UseMutationResult<BorrowResponse, Error, string>;
|
|
34
|
-
export {};
|
|
35
|
-
//# sourceMappingURL=useBorrow.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
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,MAAM,EAAE,MAAM,CAAC,CAAC;CACzB;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"}
|
|
@@ -1,26 +0,0 @@
|
|
|
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
|
|
@@ -1 +0,0 @@
|
|
|
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"}
|
|
@@ -1,27 +0,0 @@
|
|
|
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
|
|
@@ -1 +0,0 @@
|
|
|
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,35 +0,0 @@
|
|
|
1
|
-
import type { SpokeProvider } from '@sodax/sdk';
|
|
2
|
-
import type { XToken } from '@sodax/types';
|
|
3
|
-
import { type UseMutationResult } from '@tanstack/react-query';
|
|
4
|
-
interface RepayResponse {
|
|
5
|
-
ok: true;
|
|
6
|
-
value: [string, string];
|
|
7
|
-
}
|
|
8
|
-
/**
|
|
9
|
-
* Hook for repaying borrowed tokens to the Sodax money market.
|
|
10
|
-
*
|
|
11
|
-
* This hook provides functionality to repay borrowed tokens back to the money market protocol,
|
|
12
|
-
* handling the entire repayment process including transaction creation, submission,
|
|
13
|
-
* and cross-chain communication.
|
|
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
|
-
*
|
|
23
|
-
* @example
|
|
24
|
-
* ```typescript
|
|
25
|
-
* const { mutateAsync: repay, isPending, error } = useRepay(spokeToken);
|
|
26
|
-
* await repay('100');
|
|
27
|
-
* ```
|
|
28
|
-
*
|
|
29
|
-
* @throws {Error} When:
|
|
30
|
-
* - spokeProvider is not available
|
|
31
|
-
* - Transaction execution fails
|
|
32
|
-
*/
|
|
33
|
-
export declare function useRepay(spokeToken: XToken, spokeProvider: SpokeProvider | undefined): UseMutationResult<RepayResponse, Error, string>;
|
|
34
|
-
export {};
|
|
35
|
-
//# sourceMappingURL=useRepay.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
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,MAAM,EAAE,MAAM,CAAC,CAAC;CACzB;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,19 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Hook for fetching reserves data from the Sodax money market.
|
|
3
|
-
*
|
|
4
|
-
* This hook provides access to the current state of all reserves in the money market protocol,
|
|
5
|
-
* including liquidity, interest rates, and other key metrics. The data is automatically
|
|
6
|
-
* fetched and cached using React Query.
|
|
7
|
-
*
|
|
8
|
-
* @example
|
|
9
|
-
* ```typescript
|
|
10
|
-
* const { data: reservesData, isLoading, error } = useReservesData();
|
|
11
|
-
* ```
|
|
12
|
-
*
|
|
13
|
-
* @returns A React Query result object containing:
|
|
14
|
-
* - data: The reserves data when available
|
|
15
|
-
* - isLoading: Loading state indicator
|
|
16
|
-
* - error: Any error that occurred during data fetching
|
|
17
|
-
*/
|
|
18
|
-
export declare function useReservesData(): import("@tanstack/react-query").UseQueryResult<readonly [readonly import("@sodax/sdk").AggregatedReserveData[], import("@sodax/sdk").BaseCurrencyInfo], Error>;
|
|
19
|
-
//# sourceMappingURL=useReservesData.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useReservesData.d.ts","sourceRoot":"","sources":["../../../src/hooks/mm/useReservesData.ts"],"names":[],"mappings":"AAIA;;;;;;;;;;;;;;;;GAgBG;AAEH,wBAAgB,eAAe,mKAc9B"}
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import type { SpokeProvider } from '@sodax/sdk';
|
|
2
|
-
import type { XToken } from '@sodax/types';
|
|
3
|
-
import { type UseMutationResult } from '@tanstack/react-query';
|
|
4
|
-
interface SupplyResponse {
|
|
5
|
-
ok: true;
|
|
6
|
-
value: [string, string];
|
|
7
|
-
}
|
|
8
|
-
/**
|
|
9
|
-
* Hook for supplying tokens to the Sodax money market.
|
|
10
|
-
*
|
|
11
|
-
* This hook provides functionality to supply tokens to the money market protocol,
|
|
12
|
-
* handling the entire supply process including transaction creation, submission,
|
|
13
|
-
* and cross-chain communication.
|
|
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.
|
|
17
|
-
*
|
|
18
|
-
* @returns {UseMutationResult<SupplyResponse, Error, string>} A mutation result object with the following properties:
|
|
19
|
-
* - mutateAsync: Function to execute the supply transaction
|
|
20
|
-
* - isPending: Boolean indicating if a transaction is in progress
|
|
21
|
-
* - error: Error object if the last transaction failed, null otherwise
|
|
22
|
-
*
|
|
23
|
-
* @example
|
|
24
|
-
* ```typescript
|
|
25
|
-
* const { mutateAsync: supply, isPending, error } = useSupply(spokeToken);
|
|
26
|
-
* await supply('100');
|
|
27
|
-
* ```
|
|
28
|
-
*
|
|
29
|
-
* @throws {Error} When:
|
|
30
|
-
* - spokeProvider is not available
|
|
31
|
-
*/
|
|
32
|
-
export declare function useSupply(spokeToken: XToken, spokeProvider: SpokeProvider | undefined): UseMutationResult<SupplyResponse, Error, string>;
|
|
33
|
-
export {};
|
|
34
|
-
//# sourceMappingURL=useSupply.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
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,MAAM,EAAE,MAAM,CAAC,CAAC;CACzB;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 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useUserReservesData.d.ts","sourceRoot":"","sources":["../../../src/hooks/mm/useUserReservesData.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAK5C,wBAAgB,mBAAmB,CAAC,YAAY,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,GAAG,SAAS,+DAiCrF"}
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import type { SpokeProvider } from '@sodax/sdk';
|
|
2
|
-
import type { XToken } from '@sodax/types';
|
|
3
|
-
import { type UseMutationResult } from '@tanstack/react-query';
|
|
4
|
-
interface WithdrawResponse {
|
|
5
|
-
ok: true;
|
|
6
|
-
value: [string, string];
|
|
7
|
-
}
|
|
8
|
-
/**
|
|
9
|
-
* Hook for withdrawing supplied tokens from the Sodax money market.
|
|
10
|
-
*
|
|
11
|
-
* This hook provides functionality to withdraw previously supplied tokens from the money market protocol,
|
|
12
|
-
* handling the entire withdrawal process including transaction creation, submission,
|
|
13
|
-
* and cross-chain communication.
|
|
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
|
|
21
|
-
* @example
|
|
22
|
-
* ```typescript
|
|
23
|
-
* const { mutateAsync: withdraw, isPending, error } = useWithdraw(spokeToken);
|
|
24
|
-
* await withdraw('100');
|
|
25
|
-
* ```
|
|
26
|
-
*
|
|
27
|
-
* @throws {Error} When:
|
|
28
|
-
* - spokeProvider is not available
|
|
29
|
-
* - Transaction execution fails
|
|
30
|
-
*/
|
|
31
|
-
export declare function useWithdraw(spokeToken: XToken, spokeProvider: SpokeProvider | undefined): UseMutationResult<WithdrawResponse, Error, string>;
|
|
32
|
-
export {};
|
|
33
|
-
//# sourceMappingURL=useWithdraw.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
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,MAAM,EAAE,MAAM,CAAC,CAAC;CACzB;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 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/hooks/provider/index.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAC;AACjC,cAAc,oBAAoB,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useHubProvider.d.ts","sourceRoot":"","sources":["../../../src/hooks/provider/useHubProvider.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAGjD,wBAAgB,cAAc,IAAI,cAAc,GAAG,SAAS,CAI3D"}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { type SpokeProvider, type IWalletProvider } from '@sodax/sdk';
|
|
2
|
-
import type { SpokeChainId } from '@sodax/types';
|
|
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;
|
|
18
|
-
//# sourceMappingURL=useSpokeProvider.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useSpokeProvider.d.ts","sourceRoot":"","sources":["../../../src/hooks/provider/useSpokeProvider.ts"],"names":[],"mappings":"AAAA,OAAO,EAYL,KAAK,aAAa,EAClB,KAAK,eAAe,EAGrB,MAAM,YAAY,CAAC;AACpB,OAAO,KAAK,EAIV,YAAY,EAIb,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,CAqD3B"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/hooks/shared/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC"}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { type SodaxContextType } from '@/contexts';
|
|
2
|
-
/**
|
|
3
|
-
* Hook to access the Sodax context which provides access to the Sodax SDK instance and chain configuration
|
|
4
|
-
* @throws {Error} If used outside of a SodaxProvider
|
|
5
|
-
* @returns {SodaxContextType} The Sodax context containing SDK instance and configuration
|
|
6
|
-
*/
|
|
7
|
-
export declare const useSodaxContext: () => SodaxContextType;
|
|
8
|
-
//# sourceMappingURL=useSodaxContext.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useSodaxContext.d.ts","sourceRoot":"","sources":["../../../src/hooks/shared/useSodaxContext.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgB,KAAK,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAGjE;;;;GAIG;AAEH,eAAO,MAAM,eAAe,QAAO,gBAMlC,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
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,33 +0,0 @@
|
|
|
1
|
-
import type { CreateIntentParams, SolverExecutionResponse, Result, IntentErrorCode, Intent, PacketData, IntentError, SpokeProvider } from '@sodax/sdk';
|
|
2
|
-
import { type UseMutationResult } from '@tanstack/react-query';
|
|
3
|
-
type CreateIntentResult = Result<[
|
|
4
|
-
SolverExecutionResponse,
|
|
5
|
-
Intent,
|
|
6
|
-
PacketData
|
|
7
|
-
], IntentError<IntentErrorCode>>;
|
|
8
|
-
/**
|
|
9
|
-
* Hook for creating and submitting an intent order for cross-chain swaps.
|
|
10
|
-
* Uses React Query's useMutation for better state management and caching.
|
|
11
|
-
*
|
|
12
|
-
* @param {SpokeProvider} spokeProvider - The spoke provider to use for the swap
|
|
13
|
-
* @returns {UseMutationResult} Mutation result object containing mutation function and state
|
|
14
|
-
*
|
|
15
|
-
* @example
|
|
16
|
-
* ```typescript
|
|
17
|
-
* const { mutateAsync: createIntent, isPending } = useCreateIntentOrder(spokeProvider);
|
|
18
|
-
*
|
|
19
|
-
* const handleSwap = async () => {
|
|
20
|
-
* const result = await createIntent({
|
|
21
|
-
* token_src: '0x...',
|
|
22
|
-
* token_src_blockchain_id: 'arbitrum',
|
|
23
|
-
* token_dst: '0x...',
|
|
24
|
-
* token_dst_blockchain_id: 'polygon',
|
|
25
|
-
* amount: '1000000000000000000',
|
|
26
|
-
* min_output_amount: '900000000000000000'
|
|
27
|
-
* });
|
|
28
|
-
* };
|
|
29
|
-
* ```
|
|
30
|
-
*/
|
|
31
|
-
export declare function useCreateIntentOrder(spokeProvider: SpokeProvider | undefined): UseMutationResult<CreateIntentResult, Error, CreateIntentParams>;
|
|
32
|
-
export {};
|
|
33
|
-
//# sourceMappingURL=useCreateIntentOrder.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
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,eAAe,EACf,MAAM,EACN,UAAU,EACV,WAAW,EACX,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,WAAW,CAAC,eAAe,CAAC,CAC7B,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAgB,oBAAoB,CAClC,aAAa,EAAE,aAAa,GAAG,SAAS,GACvC,iBAAiB,CAAC,kBAAkB,EAAE,KAAK,EAAE,kBAAkB,CAAC,CAWlE"}
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import type { SolverErrorResponse, SolverIntentQuoteRequest, SolverIntentQuoteResponse, Result } from '@sodax/sdk';
|
|
2
|
-
import { type UseQueryResult } from '@tanstack/react-query';
|
|
3
|
-
/**
|
|
4
|
-
* Hook for fetching a quote for an intent-based swap.
|
|
5
|
-
*
|
|
6
|
-
* This hook provides real-time quote data for an intent-based swap.
|
|
7
|
-
*
|
|
8
|
-
* @param {SolverIntentQuoteRequest | undefined} payload - The intent quote request parameters. If undefined, the query will be disabled.
|
|
9
|
-
*
|
|
10
|
-
* @returns {UseQueryResult<Result<SolverIntentQuoteResponse, SolverErrorResponse> | undefined>} A query result object containing:
|
|
11
|
-
* - data: The quote result from the solver
|
|
12
|
-
* - isLoading: Boolean indicating if the quote is being fetched
|
|
13
|
-
* - error: Error object if the quote request failed
|
|
14
|
-
* - refetch: Function to manually trigger a quote refresh
|
|
15
|
-
*
|
|
16
|
-
* @example
|
|
17
|
-
* ```typescript
|
|
18
|
-
* const { data: quote, isLoading } = useQuote({
|
|
19
|
-
* token_src: '0x...',
|
|
20
|
-
* token_src_blockchain_id: '1',
|
|
21
|
-
* token_dst: '0x...',
|
|
22
|
-
* token_dst_blockchain_id: '2',
|
|
23
|
-
* amount: '1000000000000000000',
|
|
24
|
-
* quote_type: 'exact_input',
|
|
25
|
-
* });
|
|
26
|
-
*
|
|
27
|
-
* if (isLoading) return <div>Loading quote...</div>;
|
|
28
|
-
* if (quote) {
|
|
29
|
-
* console.log('Quote received:', quote);
|
|
30
|
-
* }
|
|
31
|
-
* ```
|
|
32
|
-
*
|
|
33
|
-
* @remarks
|
|
34
|
-
* - The quote is automatically refreshed every 3 seconds
|
|
35
|
-
* - The query is disabled when payload is undefined
|
|
36
|
-
* - Uses React Query for efficient caching and state management
|
|
37
|
-
*/
|
|
38
|
-
export declare const useQuote: (payload: SolverIntentQuoteRequest | undefined) => UseQueryResult<Result<SolverIntentQuoteResponse, SolverErrorResponse> | undefined>;
|
|
39
|
-
//# sourceMappingURL=useQuote.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useQuote.d.ts","sourceRoot":"","sources":["../../../src/hooks/swap/useQuote.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,wBAAwB,EAAE,yBAAyB,EAAE,MAAM,EAAE,MAAM,YAAY,CAAC;AAEnH,OAAO,EAAY,KAAK,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAEtE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AACH,eAAO,MAAM,QAAQ,YACV,wBAAwB,GAAG,SAAS,KAC5C,cAAc,CAAC,MAAM,CAAC,yBAAyB,EAAE,mBAAmB,CAAC,GAAG,SAAS,CAanF,CAAC"}
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import type { Hex, SolverErrorResponse, SolverIntentStatusResponse, Result } from '@sodax/sdk';
|
|
2
|
-
import { type UseQueryResult } from '@tanstack/react-query';
|
|
3
|
-
/**
|
|
4
|
-
* Hook for monitoring the status of an intent-based swap.
|
|
5
|
-
*
|
|
6
|
-
* This hook provides real-time status updates for an intent-based swap transaction.
|
|
7
|
-
*
|
|
8
|
-
* @param {Hex} intent_tx_hash - The transaction hash of the intent order on the hub chain
|
|
9
|
-
*
|
|
10
|
-
* @returns {UseQueryResult<Result<SolverIntentStatusResponse, SolverErrorResponse> | undefined>} A query result object containing:
|
|
11
|
-
* - data: The status result from the solver
|
|
12
|
-
* - isLoading: Boolean indicating if the status is being fetched
|
|
13
|
-
* - error: Error object if the status request failed
|
|
14
|
-
* - refetch: Function to manually trigger a status refresh
|
|
15
|
-
*
|
|
16
|
-
* @example
|
|
17
|
-
* ```typescript
|
|
18
|
-
* const { data: status, isLoading } = useStatus('0x...');
|
|
19
|
-
*
|
|
20
|
-
* if (isLoading) return <div>Loading status...</div>;
|
|
21
|
-
* if (status?.ok) {
|
|
22
|
-
* console.log('Status:', status.value);
|
|
23
|
-
* }
|
|
24
|
-
* ```
|
|
25
|
-
*
|
|
26
|
-
* @remarks
|
|
27
|
-
* - The status is automatically refreshed every 3 seconds
|
|
28
|
-
* - Uses React Query for efficient caching and state management
|
|
29
|
-
*/
|
|
30
|
-
export declare const useStatus: (intent_tx_hash: Hex) => UseQueryResult<Result<SolverIntentStatusResponse, SolverErrorResponse> | undefined>;
|
|
31
|
-
//# sourceMappingURL=useStatus.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useStatus.d.ts","sourceRoot":"","sources":["../../../src/hooks/swap/useStatus.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,mBAAmB,EAAE,0BAA0B,EAAE,MAAM,EAAE,MAAM,YAAY,CAAC;AAC/F,OAAO,EAAY,KAAK,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAGtE;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAEH,eAAO,MAAM,SAAS,mBACJ,GAAG,KAClB,cAAc,CAAC,MAAM,CAAC,0BAA0B,EAAE,mBAAmB,CAAC,GAAG,SAAS,CASpF,CAAC"}
|
|
@@ -1,23 +0,0 @@
|
|
|
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
|
|
@@ -1 +0,0 @@
|
|
|
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"}
|