@sodax/dapp-kit 0.0.1-rc.25 → 0.0.1-rc.27
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 +5 -5
- package/dist/index.js.map +1 -1
- package/dist/index.mjs.map +1 -1
- package/package.json +5 -5
package/README.md
CHANGED
|
@@ -57,14 +57,14 @@ pnpm add @sodax/dapp-kit
|
|
|
57
57
|
1. First, install the required dependencies:
|
|
58
58
|
|
|
59
59
|
```bash
|
|
60
|
-
pnpm install @sodax/dapp-kit @tanstack/react-query @sodax/wallet-sdk
|
|
60
|
+
pnpm install @sodax/dapp-kit @tanstack/react-query @sodax/wallet-sdk-react
|
|
61
61
|
```
|
|
62
62
|
|
|
63
63
|
2. Set up the providers in your app:
|
|
64
64
|
|
|
65
65
|
```typescript
|
|
66
66
|
import { QueryClient, QueryClientProvider } from '@tanstack/react-query';
|
|
67
|
-
import {
|
|
67
|
+
import { SodaxWalletProvider } from '@sodax/wallet-sdk-react';
|
|
68
68
|
import { SodaxProvider } from '@sodax/dapp-kit';
|
|
69
69
|
|
|
70
70
|
const queryClient = new QueryClient();
|
|
@@ -77,7 +77,7 @@ function App() {
|
|
|
77
77
|
return (
|
|
78
78
|
<SodaxProvider testnet={false} rpcConfig={rpcConfig}>
|
|
79
79
|
<QueryClientProvider client={queryClient}>
|
|
80
|
-
<
|
|
80
|
+
<SodaxWalletProvider
|
|
81
81
|
config={{
|
|
82
82
|
EVM: {
|
|
83
83
|
wagmiConfig: wagmiConfig,
|
|
@@ -91,7 +91,7 @@ function App() {
|
|
|
91
91
|
}}
|
|
92
92
|
>
|
|
93
93
|
<YourApp />
|
|
94
|
-
</
|
|
94
|
+
</SodaxWalletProvider>
|
|
95
95
|
</QueryClientProvider>
|
|
96
96
|
</SodaxProvider>
|
|
97
97
|
);
|
|
@@ -102,7 +102,7 @@ function App() {
|
|
|
102
102
|
|
|
103
103
|
```typescript
|
|
104
104
|
// Connect Wallet Operations
|
|
105
|
-
import { useXConnectors, useXConnect, useXAccount } from '@sodax/wallet-sdk';
|
|
105
|
+
import { useXConnectors, useXConnect, useXAccount } from '@sodax/wallet-sdk-react';
|
|
106
106
|
const evmConnectors = useXConnectors('EVM');
|
|
107
107
|
const { mutateAsync: connect, isPending } = useXConnect();
|
|
108
108
|
const account = useXAccount('EVM');
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/contexts/index.ts","../src/hooks/shared/useSodaxContext.ts","../src/hooks/shared/useEstimateGas.ts","../src/hooks/shared/useDeriveUserWalletAddress.ts","../src/hooks/provider/useHubProvider.ts","../src/hooks/provider/useSpokeProvider.ts","../src/hooks/mm/useBorrow.ts","../src/hooks/mm/useRepay.ts","../src/hooks/mm/useSupply.ts","../src/hooks/mm/useWithdraw.ts","../src/hooks/mm/useUserReservesData.ts","../src/hooks/mm/useReservesData.ts","../src/hooks/mm/useMMAllowance.ts","../src/hooks/mm/useMMApprove.ts","../src/hooks/swap/useQuote.ts","../src/hooks/swap/useSwap.ts","../src/hooks/swap/useStatus.ts","../src/hooks/swap/useSwapAllowance.ts","../src/hooks/swap/useSwapApprove.ts","../src/hooks/swap/useCancelSwap.ts","../src/hooks/backend/useBackendIntentByTxHash.ts","../src/hooks/backend/useBackendIntentByHash.ts","../src/hooks/backend/useBackendOrderbook.ts","../src/hooks/backend/useBackendMoneyMarketPosition.ts","../src/hooks/backend/useBackendAllMoneyMarketAssets.ts","../src/hooks/backend/useBackendMoneyMarketAsset.ts","../src/hooks/backend/useBackendMoneyMarketAssetBorrowers.ts","../src/hooks/backend/useBackendMoneyMarketAssetSuppliers.ts","../src/hooks/backend/useBackendAllMoneyMarketBorrowers.ts","../src/hooks/bridge/useBridgeAllowance.ts","../src/hooks/bridge/useBridgeApprove.ts","../src/hooks/bridge/useBridge.ts","../src/hooks/bridge/useGetBridgeableAmount.ts","../src/hooks/bridge/useGetBridgeableTokens.ts","../src/providers/SodaxProvider.tsx","../src/core/index.ts"],"names":["createContext","useContext","useMutation","SpokeService","useQuery","deriveUserWalletAddress","spokeChainConfig","useMemo","SONIC_MAINNET_CHAIN_ID","SonicSpokeProvider","EvmSpokeProvider","SuiSpokeProvider","IconSpokeProvider","InjectiveSpokeProvider","StellarSpokeProvider","SolanaSpokeProvider","parseUnits","useQueryClient","params","Sodax","React","hubAssets"],"mappings":";;;;;;;;;;;;AAUO,IAAM,YAAA,GAAeA,oBAAuC,IAAI,CAAA;ACDhE,IAAM,kBAAkB,MAAwB;AACrD,EAAM,MAAA,OAAA,GAAUC,iBAAW,YAAY,CAAA;AACvC,EAAA,IAAI,CAAC,OAAS,EAAA;AACZ,IAAM,MAAA,IAAI,MAAM,qDAAqD,CAAA;AAAA;AAEvE,EAAO,OAAA,OAAA;AACT;ACZO,SAAS,eACd,aAC8E,EAAA;AAC9E,EAAA,OAAOC,sBAAuE,CAAA;AAAA,IAC5E,UAAA,EAAY,OAAO,KAAiC,KAAA;AAClD,MAAA,IAAI,CAAC,aAAe,EAAA;AAClB,QAAM,MAAA,IAAI,MAAM,4BAA4B,CAAA;AAAA;AAG9C,MAAA,MAAM,QAAW,GAAA,MAAMC,gBAAa,CAAA,WAAA,CAAY,OAAO,aAAa,CAAA;AAEpE,MAAO,OAAA,QAAA;AAAA;AACT,GACD,CAAA;AACH;ACQO,SAAS,0BAAA,CACd,eACA,aACgC,EAAA;AAChC,EAAM,MAAA,EAAE,KAAM,EAAA,GAAI,eAAgB,EAAA;AAElC,EAAA,OAAOC,mBAAS,CAAA;AAAA,IACd,UAAU,CAAC,yBAAA,EAA2B,eAAe,WAAY,CAAA,KAAA,CAAM,IAAI,aAAa,CAAA;AAAA,IACxF,SAAS,YAA8B;AACrC,MAAA,IAAI,CAAC,aAAe,EAAA;AAClB,QAAM,MAAA,IAAI,MAAM,4BAA4B,CAAA;AAAA;AAG9C,MAAA,OAAO,MAAMC,2BAAA,CAAwB,aAAe,EAAA,KAAA,CAAM,aAAa,aAAa,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OAAA;AACT","file":"index.js","sourcesContent":["import { createContext } from 'react';\nimport type { Sodax } from '@sodax/sdk';\nimport type { RpcConfig } from '@/types';\n\nexport interface SodaxContextType {\n sodax: Sodax;\n testnet: boolean;\n rpcConfig: RpcConfig;\n}\n\nexport const SodaxContext = createContext<SodaxContextType | null>(null);\n","import { SodaxContext, type SodaxContextType } from '@/contexts';\nimport { useContext } from 'react';\n\n/**\n * Hook to access the Sodax context which provides access to the Sodax SDK instance and chain configuration\n * @throws {Error} If used outside of a SodaxProvider\n * @returns {SodaxContextType} The Sodax context containing SDK instance and configuration\n */\n\nexport const useSodaxContext = (): SodaxContextType => {\n const context = useContext(SodaxContext);\n if (!context) {\n throw new Error('useSodaxContext must be used within a SodaxProvider');\n }\n return context;\n};\n","import { type GetEstimateGasReturnType, type SpokeProvider, SpokeService, type TxReturnType } from '@sodax/sdk';\nimport { useMutation, type UseMutationResult } from '@tanstack/react-query';\n\nexport function useEstimateGas<T extends SpokeProvider = SpokeProvider>(\n spokeProvider: T | undefined,\n): UseMutationResult<GetEstimateGasReturnType<T>, Error, TxReturnType<T, true>> {\n return useMutation<GetEstimateGasReturnType<T>, Error, TxReturnType<T, true>>({\n mutationFn: async (rawTx: TxReturnType<T, true>) => {\n if (!spokeProvider) {\n throw new Error('spokeProvider is not found');\n }\n\n const response = await SpokeService.estimateGas(rawTx, spokeProvider);\n\n return response;\n },\n });\n}\n","// packages/dapp-kit/src/hooks/shared/useDeriveUserWalletAddress.ts\nimport { deriveUserWalletAddress, type SpokeProvider, type EvmHubProvider } from '@sodax/sdk';\nimport { useQuery, type UseQueryResult } from '@tanstack/react-query';\nimport { useSodaxContext } from './useSodaxContext';\nimport type { Address } from 'viem';\n\n/**\n * Hook for deriving user wallet address for hub abstraction.\n *\n * This hook derives the user's abstracted wallet address for the hub chain.\n * If the spoke chain is the same as the hub chain, it returns the original wallet address.\n * Otherwise, it returns the abstracted wallet address for cross-chain operations.\n *\n * @param spokeProvider - The spoke provider instance for the origin chain\n * @param walletAddress - Optional user wallet address on spoke chain. If not provided, will fetch from spokeProvider\n * @returns A React Query result object containing:\n * - data: The derived user wallet address when available\n * - isLoading: Loading state indicator\n * - error: Any error that occurred during derivation\n *\n * @example\n * ```typescript\n * const { data: derivedAddress, isLoading, error } = useDeriveUserWalletAddress(spokeProvider, userAddress);\n * ```\n */\nexport function useDeriveUserWalletAddress(\n spokeProvider: SpokeProvider | undefined,\n walletAddress?: string | undefined,\n): UseQueryResult<Address, Error> {\n const { sodax } = useSodaxContext();\n\n return useQuery({\n queryKey: ['deriveUserWalletAddress', spokeProvider?.chainConfig.chain.id, walletAddress],\n queryFn: async (): Promise<Address> => {\n if (!spokeProvider) {\n throw new Error('Spoke provider is required');\n }\n\n return await deriveUserWalletAddress(spokeProvider, sodax.hubProvider, walletAddress);\n },\n enabled: !!spokeProvider,\n refetchInterval: false, // This is a deterministic operation, no need to refetch\n });\n}\n","import type { EvmHubProvider } from '@sodax/sdk';\nimport { useSodaxContext } from '../shared/useSodaxContext';\n\nexport function useHubProvider(): EvmHubProvider {\n const { sodax } = useSodaxContext();\n\n return sodax.hubProvider;\n}\n","import { useSodaxContext } from '@/index';\nimport {\n EvmSpokeProvider,\n spokeChainConfig,\n type SuiSpokeChainConfig,\n SuiSpokeProvider,\n type EvmSpokeChainConfig,\n IconSpokeProvider,\n type IconSpokeChainConfig,\n InjectiveSpokeProvider,\n type InjectiveSpokeChainConfig,\n StellarSpokeProvider,\n type StellarSpokeChainConfig,\n type SpokeProvider,\n type IWalletProvider,\n SolanaSpokeProvider,\n type SolanaChainConfig,\n SONIC_MAINNET_CHAIN_ID,\n SonicSpokeProvider,\n type SonicSpokeChainConfig,\n} from '@sodax/sdk';\nimport type {\n IEvmWalletProvider,\n IIconWalletProvider,\n ISuiWalletProvider,\n SpokeChainId,\n IInjectiveWalletProvider,\n IStellarWalletProvider,\n ISolanaWalletProvider,\n} from '@sodax/types';\nimport { useMemo } from 'react';\n\n/**\n * Hook to get the appropriate spoke provider based on the chain type.\n * Supports EVM, SUI, ICON and INJECTIVE chains.\n *\n * @param {SpokeChainId | undefined} spokeChainId - The spoke chain ID to get the provider for\n * @param {IWalletProvider | undefined} walletProvider - The wallet provider to use\n * @returns {SpokeProvider | undefined} The appropriate spoke provider instance for the given chain ID, or undefined if invalid/unsupported\n *\n * @example\n * ```tsx\n * // Using a specific SpokeChainId and wallet provider\n * const spokeProvider = useSpokeProvider(spokeChainId, walletProvider);\n * ```\n */\nexport function useSpokeProvider(\n spokeChainId: SpokeChainId | undefined,\n walletProvider?: IWalletProvider | undefined,\n): SpokeProvider | undefined {\n const { rpcConfig } = useSodaxContext();\n const xChainType = spokeChainId ? spokeChainConfig[spokeChainId]?.chain.type : undefined;\n\n const spokeProvider = useMemo(() => {\n if (!walletProvider) return undefined;\n if (!spokeChainId) return undefined;\n if (!xChainType) return undefined;\n if (!rpcConfig) return undefined;\n\n if (xChainType === 'EVM') {\n if (spokeChainId === SONIC_MAINNET_CHAIN_ID) {\n return new SonicSpokeProvider(\n walletProvider as IEvmWalletProvider,\n spokeChainConfig[spokeChainId] as SonicSpokeChainConfig,\n );\n }\n return new EvmSpokeProvider(\n walletProvider as IEvmWalletProvider,\n spokeChainConfig[spokeChainId] as EvmSpokeChainConfig,\n );\n }\n\n if (xChainType === 'SUI') {\n return new SuiSpokeProvider(\n spokeChainConfig[spokeChainId] as SuiSpokeChainConfig,\n walletProvider as ISuiWalletProvider,\n );\n }\n\n if (xChainType === 'ICON') {\n return new IconSpokeProvider(\n walletProvider as IIconWalletProvider,\n spokeChainConfig[spokeChainId] as IconSpokeChainConfig,\n );\n }\n\n if (xChainType === 'INJECTIVE') {\n return new InjectiveSpokeProvider(\n spokeChainConfig[spokeChainId] as InjectiveSpokeChainConfig,\n walletProvider as IInjectiveWalletProvider,\n );\n }\n\n if (xChainType === 'STELLAR') {\n const stellarConfig = spokeChainConfig[spokeChainId] as StellarSpokeChainConfig;\n return new StellarSpokeProvider(\n walletProvider as IStellarWalletProvider,\n stellarConfig,\n rpcConfig.stellar\n ? rpcConfig.stellar\n : {\n horizonRpcUrl: stellarConfig.horizonRpcUrl,\n sorobanRpcUrl: stellarConfig.sorobanRpcUrl,\n },\n );\n }\n\n if (xChainType === 'SOLANA') {\n return new SolanaSpokeProvider(\n walletProvider as ISolanaWalletProvider,\n rpcConfig.solana\n ? ({\n ...spokeChainConfig[spokeChainId],\n rpcUrl: rpcConfig.solana,\n } as SolanaChainConfig)\n : (spokeChainConfig[spokeChainId] as SolanaChainConfig),\n );\n }\n\n return undefined;\n }, [spokeChainId, xChainType, walletProvider, rpcConfig]);\n\n return spokeProvider;\n}\n","import type { XToken } from '@sodax/types';\nimport { useMutation, type UseMutationResult } from '@tanstack/react-query';\nimport { parseUnits } from 'viem';\nimport { useSodaxContext } from '../shared/useSodaxContext';\nimport type { SpokeProvider } from '@sodax/sdk';\ninterface BorrowResponse {\n ok: true;\n value: [string, string];\n}\n\n/**\n * Hook for borrowing tokens from the Sodax money market.\n *\n * This hook provides functionality to borrow tokens from the money market protocol,\n * handling the entire borrow process including transaction creation, submission,\n * and cross-chain communication.\n *\n * @param {XToken} spokeToken - The token to borrow from the spoke chain. Must be an XToken with valid address and chain information.\n * @param {SpokeProvider} spokeProvider - The spoke provider to use for the borrow transaction. Must be a valid SpokeProvider instance.\n *\n * @returns {UseMutationResult<BorrowResponse, Error, string>} A mutation result object with the following properties:\n * - mutateAsync: Function to execute the borrow transaction\n * - isPending: Boolean indicating if a transaction is in progress\n * - error: Error object if the last transaction failed, null otherwise\n *\n * @example\n * ```typescript\n * const { mutateAsync: borrow, isPending, error } = useBorrow(spokeToken);\n * await borrow('100');\n * ```\n *\n * @throws {Error} When:\n * - spokeProvider is not available\n * - Transaction execution fails\n */\nexport function useBorrow(\n spokeToken: XToken,\n spokeProvider: SpokeProvider | undefined,\n): UseMutationResult<BorrowResponse, Error, string> {\n const { sodax } = useSodaxContext();\n\n return useMutation<BorrowResponse, Error, string>({\n mutationFn: async (amount: string) => {\n if (!spokeProvider) {\n throw new Error('spokeProvider is not found');\n }\n\n const response = await sodax.moneyMarket.borrow(\n {\n token: spokeToken.address,\n amount: parseUnits(amount, 18),\n action: 'borrow',\n },\n spokeProvider,\n );\n\n if (!response.ok) {\n throw new Error('Failed to borrow tokens');\n }\n\n console.log('Borrow transaction submitted:', response);\n return response;\n },\n });\n}\n","import type { SpokeProvider } from '@sodax/sdk';\nimport type { XToken } from '@sodax/types';\nimport { useMutation, type UseMutationResult } from '@tanstack/react-query';\nimport { parseUnits } from 'viem';\nimport { useSodaxContext } from '../shared/useSodaxContext';\n\ninterface RepayResponse {\n ok: true;\n value: [string, string];\n}\n\n/**\n * Hook for repaying borrowed tokens to the Sodax money market.\n *\n * This hook provides functionality to repay borrowed tokens back to the money market protocol,\n * handling the entire repayment process including transaction creation, submission,\n * and cross-chain communication.\n *\n * @param {XToken} spokeToken - The token to repay on the spoke chain. Must be an XToken with valid address and chain information.\n * @param {SpokeProvider} spokeProvider - The spoke provider to use for the repay transaction. Must be a valid SpokeProvider instance.\n *\n * @returns {UseMutationResult<RepayResponse, Error, string>} A mutation result object with the following properties:\n * - mutateAsync: Function to execute the repay transaction\n * - isPending: Boolean indicating if a transaction is in progress\n * - error: Error object if the last transaction failed, null otherwise\n *\n * @example\n * ```typescript\n * const { mutateAsync: repay, isPending, error } = useRepay(spokeToken);\n * await repay('100');\n * ```\n *\n * @throws {Error} When:\n * - spokeProvider is not available\n * - Transaction execution fails\n */\nexport function useRepay(\n spokeToken: XToken,\n spokeProvider: SpokeProvider | undefined,\n): UseMutationResult<RepayResponse, Error, string> {\n const { sodax } = useSodaxContext();\n\n return useMutation<RepayResponse, Error, string>({\n mutationFn: async (amount: string) => {\n if (!spokeProvider) {\n throw new Error('spokeProvider is not found');\n }\n\n const response = await sodax.moneyMarket.repay(\n {\n token: spokeToken.address,\n amount: parseUnits(amount, spokeToken.decimals),\n action: 'repay',\n },\n spokeProvider,\n );\n\n if (!response.ok) {\n throw new Error('Failed to repay tokens');\n }\n\n console.log('Repay transaction submitted:', response);\n return response;\n },\n });\n}\n","import type { SpokeProvider } from '@sodax/sdk';\nimport type { XToken } from '@sodax/types';\nimport { useMutation, type UseMutationResult } from '@tanstack/react-query';\nimport { parseUnits } from 'viem';\nimport { useSodaxContext } from '../shared/useSodaxContext';\n\ninterface SupplyResponse {\n ok: true;\n value: [string, string];\n}\n\n/**\n * Hook for supplying tokens to the Sodax money market.\n *\n * This hook provides functionality to supply tokens to the money market protocol,\n * handling the entire supply process including transaction creation, submission,\n * and cross-chain communication.\n *\n * @param {XToken} spokeToken - The token to supply on the spoke chain. Must be an XToken with valid address and chain information.\n * @param {SpokeProvider} spokeProvider - The spoke provider to use for the supply transaction. Must be a valid SpokeProvider instance.\n *\n * @returns {UseMutationResult<SupplyResponse, Error, string>} A mutation result object with the following properties:\n * - mutateAsync: Function to execute the supply transaction\n * - isPending: Boolean indicating if a transaction is in progress\n * - error: Error object if the last transaction failed, null otherwise\n *\n * @example\n * ```typescript\n * const { mutateAsync: supply, isPending, error } = useSupply(spokeToken);\n * await supply('100');\n * ```\n *\n * @throws {Error} When:\n * - spokeProvider is not available\n */\nexport function useSupply(\n spokeToken: XToken,\n spokeProvider: SpokeProvider | undefined,\n): UseMutationResult<SupplyResponse, Error, string> {\n const { sodax } = useSodaxContext();\n\n return useMutation<SupplyResponse, Error, string>({\n mutationFn: async (amount: string) => {\n if (!spokeProvider) {\n throw new Error('spokeProvider is not found');\n }\n\n const response = await sodax.moneyMarket.supply(\n {\n token: spokeToken.address,\n amount: parseUnits(amount, spokeToken.decimals),\n action: 'supply',\n },\n spokeProvider,\n );\n\n if (!response.ok) {\n throw new Error('Failed to supply tokens');\n }\n\n console.log('Supply transaction submitted:', response);\n return response;\n },\n });\n}\n","import type { SpokeProvider } from '@sodax/sdk';\nimport type { XToken } from '@sodax/types';\nimport { useMutation, type UseMutationResult } from '@tanstack/react-query';\nimport { parseUnits } from 'viem';\nimport { useSodaxContext } from '../shared/useSodaxContext';\n\ninterface WithdrawResponse {\n ok: true;\n value: [string, string];\n}\n\n/**\n * Hook for withdrawing supplied tokens from the Sodax money market.\n *\n * This hook provides functionality to withdraw previously supplied tokens from the money market protocol,\n * handling the entire withdrawal process including transaction creation, submission,\n * and cross-chain communication.\n *\n * @param {XToken} spokeToken - The token to withdraw from the spoke chain. Must be an XToken with valid address and chain information.\n * @param {SpokeProvider} spokeProvider - The spoke provider to use for the withdraw transaction. Must be a valid SpokeProvider instance.\n *\n * @returns {UseMutationResult<WithdrawResponse, Error, string>} A mutation result object with the following properties:\n * - mutateAsync: Function to execute the withdraw transaction\n * - isPending: Boolean indicating if a transaction is in progress\n * @example\n * ```typescript\n * const { mutateAsync: withdraw, isPending, error } = useWithdraw(spokeToken);\n * await withdraw('100');\n * ```\n *\n * @throws {Error} When:\n * - spokeProvider is not available\n * - Transaction execution fails\n */\nexport function useWithdraw(\n spokeToken: XToken,\n spokeProvider: SpokeProvider | undefined,\n): UseMutationResult<WithdrawResponse, Error, string> {\n const { sodax } = useSodaxContext();\n\n return useMutation<WithdrawResponse, Error, string>({\n mutationFn: async (amount: string) => {\n if (!spokeProvider) {\n throw new Error('spokeProvider is not found');\n }\n\n const response = await sodax.moneyMarket.withdraw(\n {\n token: spokeToken.address,\n // vault token on hub chain decimals is 18\n amount: parseUnits(amount, 18),\n action: 'withdraw',\n },\n spokeProvider,\n );\n\n if (!response.ok) {\n throw new Error('Failed to withdraw tokens');\n }\n\n console.log('Withdraw transaction submitted:', response);\n return response;\n },\n });\n}\n","import type { SpokeProvider, UserReserveData } from '@sodax/sdk';\nimport { useQuery, type UseQueryResult } from '@tanstack/react-query';\nimport { useSodaxContext } from '../shared/useSodaxContext';\n\n/**\n * Hook for fetching user reserves data from the Sodax money market.\n *\n * This hook provides access to the current state of user reserves in the money market protocol.\n * The data is automatically fetched and cached using React Query.\n *\n * @example\n * ```typescript\n * const { data: userReservesData, isLoading, error } = useUserReservesData(spokeProvider, address);\n * ```\n *\n * @returns A React Query result object containing:\n * - data: The user reserves data when available\n * - isLoading: Loading state indicator\n * - error: Any error that occurred during data fetching\n */\nexport function useUserReservesData(\n spokeProvider: SpokeProvider | undefined,\n address: string | undefined,\n refetchInterval = 5000,\n): UseQueryResult<readonly [readonly UserReserveData[], number], Error> {\n const { sodax } = useSodaxContext();\n\n return useQuery({\n queryKey: ['userReserves', spokeProvider?.chainConfig.chain.id, address],\n queryFn: async () => {\n if (!spokeProvider) {\n throw new Error('Spoke provider or address is not defined');\n }\n\n return await sodax.moneyMarket.data.getUserReservesData(spokeProvider);\n },\n enabled: !!spokeProvider && !!address,\n refetchInterval,\n });\n}\n","import { useQuery } from '@tanstack/react-query';\nimport { useSodaxContext } from '../shared/useSodaxContext';\n/**\n * Hook for fetching reserves data from the Sodax money market.\n *\n * This hook provides access to the current state of all reserves in the money market protocol,\n * including liquidity, interest rates, and other key metrics. The data is automatically\n * fetched and cached using React Query.\n *\n * @example\n * ```typescript\n * const { data: reservesData, isLoading, error } = useReservesData();\n * ```\n *\n * @returns A React Query result object containing:\n * - data: The reserves data when available\n * - isLoading: Loading state indicator\n * - error: Any error that occurred during data fetching\n */\n\nexport function useReservesData() {\n const { sodax } = useSodaxContext();\n\n return useQuery({\n queryKey: ['reservesData'],\n queryFn: async () => {\n return await sodax.moneyMarket.data.getReservesData();\n },\n });\n}\n","import { useQuery, type UseQueryResult } from '@tanstack/react-query';\nimport type { XToken } from '@sodax/types';\nimport { useSodaxContext } from '../shared/useSodaxContext';\nimport { parseUnits } from 'viem';\nimport type { MoneyMarketAction, SpokeProvider } from '@sodax/sdk';\n\n/**\n * Hook for checking token allowance for money market operations.\n *\n * This hook verifies if the user has approved enough tokens for a specific money market action\n * (borrow/repay). It automatically queries and tracks the allowance status.\n *\n * @param {XToken} token - The token to check allowance for. Must be an XToken with valid address and chain information.\n * @param {string} amount - The amount to check allowance for, as a decimal string\n * @param {MoneyMarketAction} action - The money market action to check allowance for ('borrow' or 'repay')\n * @param {SpokeProvider} spokeProvider - The spoke provider to use for allowance checks\n *\n * @returns {UseQueryResult<boolean, Error>} A React Query result containing:\n * - data: Boolean indicating if allowance is sufficient\n * - isLoading: Loading state indicator\n * - error: Any error that occurred during the check\n *\n * @example\n * ```typescript\n * const { data: hasAllowed, isLoading } = useMMAllowance(token, \"100\", \"repay\", provider);\n * ```\n */\nexport function useMMAllowance(\n token: XToken,\n amount: string,\n action: MoneyMarketAction,\n spokeProvider: SpokeProvider | undefined,\n): UseQueryResult<boolean, Error> {\n const { sodax } = useSodaxContext();\n\n return useQuery({\n queryKey: ['allowance', token.address, amount, action],\n queryFn: async () => {\n if (!spokeProvider) throw new Error('Spoke provider is required');\n const allowance = await sodax.moneyMarket.isAllowanceValid(\n {\n token: token.address,\n amount: parseUnits(amount, token.decimals),\n action,\n },\n spokeProvider,\n );\n if (allowance.ok) {\n return allowance.value;\n }\n return false;\n },\n enabled: !!spokeProvider,\n });\n}\n","import { useSodaxContext } from '../shared/useSodaxContext';\nimport type { XToken } from '@sodax/types';\nimport { parseUnits } from 'viem';\nimport { useMutation, useQueryClient } from '@tanstack/react-query';\nimport type { MoneyMarketAction, SpokeProvider } from '@sodax/sdk';\n\ninterface UseApproveReturn {\n approve: ({ amount, action }: { amount: string; action: MoneyMarketAction }) => Promise<boolean>;\n isLoading: boolean;\n error: Error | null;\n resetError: () => void;\n}\n\n/**\n * Hook for approving token spending for money market actions\n * @param token The token to approve spending for\n * @param spokeProvider The spoke provider instance for the chain\n * @returns Object containing approve function, loading state, error state and reset function\n * @example\n * ```tsx\n * const { approve, isLoading, error } = useMMApprove(token, spokeProvider);\n *\n * // Approve tokens for supply action\n * await approve({ amount: \"100\", action: \"supply\" });\n * ```\n */\n\nexport function useMMApprove(token: XToken, spokeProvider: SpokeProvider | undefined): UseApproveReturn {\n const { sodax } = useSodaxContext();\n const queryClient = useQueryClient();\n\n const {\n mutateAsync: approve,\n isPending,\n error,\n reset: resetError,\n } = useMutation({\n mutationFn: async ({ amount, action }: { amount: string; action: MoneyMarketAction }) => {\n if (!spokeProvider) {\n throw new Error('Spoke provider not found');\n }\n const allowance = await sodax.moneyMarket.approve(\n {\n token: token.address,\n amount: parseUnits(amount, token.decimals),\n action,\n },\n spokeProvider,\n );\n if (!allowance.ok) {\n throw new Error('Failed to approve tokens');\n }\n return allowance.ok;\n },\n onSuccess: () => {\n // Invalidate allowance query to refetch the new allowance\n queryClient.invalidateQueries({ queryKey: ['allowance', token.address] });\n },\n });\n\n return {\n approve,\n isLoading: isPending,\n error: error,\n resetError,\n };\n}\n","import type { SolverErrorResponse, SolverIntentQuoteRequest, SolverIntentQuoteResponse, Result } from '@sodax/sdk';\nimport { useSodaxContext } from '../shared/useSodaxContext';\nimport { useQuery, type UseQueryResult } from '@tanstack/react-query';\n\n/**\n * Hook for fetching a quote for an intent-based swap.\n *\n * This hook provides real-time quote data for an intent-based swap.\n *\n * @param {SolverIntentQuoteRequest | undefined} payload - The intent quote request parameters. If undefined, the query will be disabled.\n *\n * @returns {UseQueryResult<Result<SolverIntentQuoteResponse, SolverErrorResponse> | undefined>} A query result object containing:\n * - data: The quote result from the solver\n * - isLoading: Boolean indicating if the quote is being fetched\n * - error: Error object if the quote request failed\n * - refetch: Function to manually trigger a quote refresh\n *\n * @example\n * ```typescript\n * const { data: quote, isLoading } = useQuote({\n * token_src: '0x...',\n * token_src_blockchain_id: '1',\n * token_dst: '0x...',\n * token_dst_blockchain_id: '2',\n * amount: '1000000000000000000',\n * quote_type: 'exact_input',\n * });\n *\n * if (isLoading) return <div>Loading quote...</div>;\n * if (quote) {\n * console.log('Quote received:', quote);\n * }\n * ```\n *\n * @remarks\n * - The quote is automatically refreshed every 3 seconds\n * - The query is disabled when payload is undefined\n * - Uses React Query for efficient caching and state management\n */\nexport const useQuote = (\n payload: SolverIntentQuoteRequest | undefined,\n): UseQueryResult<Result<SolverIntentQuoteResponse, SolverErrorResponse> | undefined> => {\n const { sodax } = useSodaxContext();\n return useQuery({\n queryKey: [payload],\n queryFn: async () => {\n if (!payload) {\n return undefined;\n }\n return sodax.solver.getQuote(payload);\n },\n enabled: !!payload,\n refetchInterval: 3000,\n });\n};\n","import { useSodaxContext } from '../shared/useSodaxContext';\nimport type {\n CreateIntentParams,\n SolverExecutionResponse,\n Result,\n IntentErrorCode,\n Intent,\n IntentError,\n SpokeProvider,\n IntentDeliveryInfo,\n} from '@sodax/sdk';\nimport { useMutation, type UseMutationResult } from '@tanstack/react-query';\n\ntype CreateIntentResult = Result<[SolverExecutionResponse, Intent, IntentDeliveryInfo], IntentError<IntentErrorCode>>;\n\n/**\n * Hook for creating and submitting an swap intent order for cross-chain swaps.\n * Uses React Query's useMutation for better state management and caching.\n *\n * @param {SpokeProvider} spokeProvider - The spoke provider to use for the swap\n * @returns {UseMutationResult} Mutation result object containing mutation function and state\n *\n * @example\n * ```typescript\n * const { mutateAsync: swap, isPending } = useSwap(spokeProvider);\n *\n * const handleSwap = async () => {\n * const result = await swap({\n * token_src: '0x...',\n * token_src_blockchain_id: 'arbitrum',\n * token_dst: '0x...',\n * token_dst_blockchain_id: 'polygon',\n * amount: '1000000000000000000',\n * min_output_amount: '900000000000000000'\n * });\n * };\n * ```\n */\nexport function useSwap(\n spokeProvider: SpokeProvider | undefined,\n): UseMutationResult<CreateIntentResult, Error, CreateIntentParams> {\n const { sodax } = useSodaxContext();\n\n return useMutation<CreateIntentResult, Error, CreateIntentParams>({\n mutationFn: async (params: CreateIntentParams) => {\n if (!spokeProvider) {\n throw new Error('Spoke provider not found');\n }\n return sodax.solver.swap({\n intentParams: params,\n spokeProvider,\n });\n },\n });\n}\n","import type { Hex, SolverErrorResponse, SolverIntentStatusResponse, Result } from '@sodax/sdk';\nimport { useQuery, type UseQueryResult } from '@tanstack/react-query';\nimport { useSodaxContext } from '../shared/useSodaxContext';\n\n/**\n * Hook for monitoring the status of an intent-based swap.\n *\n * This hook provides real-time status updates for an intent-based swap transaction.\n *\n * @param {Hex} intent_tx_hash - The transaction hash of the intent order on the hub chain\n *\n * @returns {UseQueryResult<Result<SolverIntentStatusResponse, SolverErrorResponse> | undefined>} A query result object containing:\n * - data: The status result from the solver\n * - isLoading: Boolean indicating if the status is being fetched\n * - error: Error object if the status request failed\n * - refetch: Function to manually trigger a status refresh\n *\n * @example\n * ```typescript\n * const { data: status, isLoading } = useStatus('0x...');\n *\n * if (isLoading) return <div>Loading status...</div>;\n * if (status?.ok) {\n * console.log('Status:', status.value);\n * }\n * ```\n *\n * @remarks\n * - The status is automatically refreshed every 3 seconds\n * - Uses React Query for efficient caching and state management\n */\n\nexport const useStatus = (\n intent_tx_hash: Hex,\n): UseQueryResult<Result<SolverIntentStatusResponse, SolverErrorResponse> | undefined> => {\n const { sodax } = useSodaxContext();\n return useQuery({\n queryKey: [intent_tx_hash],\n queryFn: async () => {\n return sodax.solver.getStatus({ intent_tx_hash });\n },\n refetchInterval: 3000, // 3s\n });\n};\n","import { useQuery, type UseQueryResult } from '@tanstack/react-query';\nimport { useSodaxContext } from '../shared/useSodaxContext';\nimport type { CreateIntentParams, SpokeProvider } from '@sodax/sdk';\n\n/**\n * Hook for checking token allowance for money market operations.\n *\n * This hook verifies if the user has approved enough tokens for a specific money market action\n * (borrow/repay). It automatically queries and tracks the allowance status.\n *\n * @param {CreateIntentParams} params - The parameters for the intent to check allowance for.\n * @param {SpokeProvider} spokeProvider - The spoke provider to use for allowance checks\n *\n * @returns {UseQueryResult<boolean, Error>} A React Query result containing:\n * - data: Boolean indicating if allowance is sufficient\n * - isLoading: Loading state indicator\n * - error: Any error that occurred during the check\n *\n * @example\n * ```typescript\n * const { data: hasAllowed, isLoading } = useMMAllowance(params, spokeProvider);\n * ```\n */\nexport function useSwapAllowance(\n params: CreateIntentParams | undefined,\n spokeProvider: SpokeProvider | undefined,\n): UseQueryResult<boolean, Error> {\n const { sodax } = useSodaxContext();\n\n return useQuery({\n queryKey: ['allowance', params],\n queryFn: async () => {\n if (!spokeProvider || !params) {\n return false;\n }\n const allowance = await sodax.solver.isAllowanceValid({\n intentParams: params,\n spokeProvider,\n });\n if (allowance.ok) {\n return allowance.value;\n }\n return false;\n },\n enabled: !!spokeProvider && !!params,\n });\n}\n","import { useSodaxContext } from '../shared/useSodaxContext';\nimport { useMutation, useQueryClient } from '@tanstack/react-query';\nimport type { CreateIntentParams, SpokeProvider } from '@sodax/sdk';\n\ninterface UseApproveReturn {\n approve: ({ params }: { params: CreateIntentParams }) => Promise<boolean>;\n isLoading: boolean;\n error: Error | null;\n resetError: () => void;\n}\n\n/**\n * Hook for approving token spending for money market actions\n * @param token The token to approve spending for\n * @param spokeProvider The spoke provider instance for the chain\n * @returns Object containing approve function, loading state, error state and reset function\n * @example\n * ```tsx\n * const { approve, isLoading, error } = useApprove(token, spokeProvider);\n *\n * // Approve tokens for supply action\n * await approve({ amount: \"100\", action: \"supply\" });\n * ```\n */\n\nexport function useSwapApprove(\n params: CreateIntentParams | undefined,\n spokeProvider: SpokeProvider | undefined,\n): UseApproveReturn {\n const { sodax } = useSodaxContext();\n const queryClient = useQueryClient();\n\n const {\n mutateAsync: approve,\n isPending,\n error,\n reset: resetError,\n } = useMutation({\n mutationFn: async ({ params }: { params: CreateIntentParams | undefined }) => {\n if (!spokeProvider) {\n throw new Error('Spoke provider not found');\n }\n if (!params) {\n throw new Error('Swap Params not found');\n }\n\n const allowance = await sodax.solver.approve({\n intentParams: params,\n spokeProvider,\n });\n if (!allowance.ok) {\n throw new Error('Failed to approve input token');\n }\n return allowance.ok;\n },\n onSuccess: () => {\n // Invalidate allowance query to refetch the new allowance\n queryClient.invalidateQueries({ queryKey: ['allowance', params?.inputToken] });\n },\n });\n\n return {\n approve,\n isLoading: isPending,\n error: error,\n resetError,\n };\n}\n","import { useSodaxContext } from '../shared/useSodaxContext';\nimport type { Intent, Result, SpokeProvider, TxReturnType } from '@sodax/sdk';\nimport { useMutation, type UseMutationResult } from '@tanstack/react-query';\n\ntype CancelIntentParams = {\n intent: Intent;\n raw?: boolean;\n};\n\ntype CancelIntentResult = Result<TxReturnType<SpokeProvider, boolean>>;\n\n/**\n * Hook for canceling a swap intent order.\n * Uses React Query's useMutation for better state management and caching.\n *\n * @param {SpokeProvider} spokeProvider - The spoke provider to use for canceling the intent\n * @returns {UseMutationResult} Mutation result object containing mutation function and state\n *\n * @example\n * ```typescript\n * const { mutateAsync: cancelSwap, isPending } = useCancelSwap(spokeProvider);\n *\n * const handleCancelSwap = async () => {\n * const result = await cancelSwap({\n * intent: intentObject,\n * raw: false // optional, defaults to false\n * });\n * };\n * ```\n */\nexport function useCancelSwap(\n spokeProvider: SpokeProvider | undefined,\n): UseMutationResult<CancelIntentResult, Error, CancelIntentParams> {\n const { sodax } = useSodaxContext();\n\n return useMutation<CancelIntentResult, Error, CancelIntentParams>({\n mutationFn: async ({ intent, raw = false }: CancelIntentParams) => {\n if (!spokeProvider) {\n throw new Error('Spoke provider not found');\n }\n return sodax.solver.cancelIntent(intent, spokeProvider, raw);\n },\n });\n}\n","// packages/dapp-kit/src/hooks/backend/useIntentByTxHash.ts\nimport { useQuery, type UseQueryResult } from '@tanstack/react-query';\nimport type { IntentResponse } from '@sodax/sdk';\nimport { useSodaxContext } from '../shared/useSodaxContext';\n\n/**\n * Hook for fetching intent details by transaction hash from the backend API.\n *\n * This hook provides access to intent data associated with a specific transaction hash,\n * including intent details, events, and transaction information. The data is automatically\n * fetched and cached using React Query.\n *\n * @param {string | undefined} txHash - The transaction hash to fetch intent for. If undefined, the query will be disabled.\n *\n * @returns {UseQueryResult<IntentResponse | undefined>} A query result object containing:\n * - data: The intent response data when available\n * - isLoading: Boolean indicating if the request is in progress\n * - error: Error object if the request failed\n * - refetch: Function to manually trigger a data refresh\n *\n * @example\n * ```typescript\n * const { data: intent, isLoading, error } = useIntentByTxHash('0x123...');\n *\n * if (isLoading) return <div>Loading intent...</div>;\n * if (error) return <div>Error: {error.message}</div>;\n * if (intent) {\n * console.log('Intent found:', intent.intentHash);\n * }\n * ```\n *\n * @remarks\n * - The query is disabled when txHash is undefined or empty\n * - Uses React Query for efficient caching and state management\n * - Automatically handles error states and loading indicators\n */\nexport const useBackendIntentByTxHash = (txHash: string | undefined): UseQueryResult<IntentResponse | undefined> => {\n const { sodax } = useSodaxContext();\n\n return useQuery({\n queryKey: ['backend', 'intent', 'txHash', txHash],\n queryFn: async (): Promise<IntentResponse | undefined> => {\n if (!txHash) {\n return undefined;\n }\n\n return sodax.backendApiService.getIntentByTxHash(txHash);\n },\n enabled: !!txHash && txHash.length > 0,\n retry: 3,\n });\n};\n","// packages/dapp-kit/src/hooks/backend/useIntentByHash.ts\nimport { useQuery, type UseQueryResult } from '@tanstack/react-query';\nimport type { IntentResponse } from '@sodax/sdk';\nimport { useSodaxContext } from '../shared/useSodaxContext';\n\n/**\n * Hook for fetching intent details by intent hash from the backend API.\n *\n * This hook provides access to intent data using the intent hash directly,\n * including intent details, events, and transaction information. The data is automatically\n * fetched and cached using React Query.\n *\n * @param {string | undefined} intentHash - The intent hash to fetch intent for. If undefined, the query will be disabled.\n *\n * @returns {UseQueryResult<IntentResponse | undefined>} A query result object containing:\n * - data: The intent response data when available\n * - isLoading: Boolean indicating if the request is in progress\n * - error: Error object if the request failed\n * - refetch: Function to manually trigger a data refresh\n *\n * @example\n * ```typescript\n * const { data: intent, isLoading, error } = useIntentByHash('0xabc...');\n *\n * if (isLoading) return <div>Loading intent...</div>;\n * if (error) return <div>Error: {error.message}</div>;\n * if (intent) {\n * console.log('Intent found:', intent.intentHash);\n * console.log('Open status:', intent.open);\n * }\n * ```\n *\n * @remarks\n * - The query is disabled when intentHash is undefined or empty\n * - Uses React Query for efficient caching and state management\n * - Automatically handles error states and loading indicators\n */\nexport const useBackendIntentByHash = (intentHash: string | undefined): UseQueryResult<IntentResponse | undefined> => {\n const { sodax } = useSodaxContext();\n\n return useQuery({\n queryKey: ['backend', 'intent', 'hash', intentHash],\n queryFn: async (): Promise<IntentResponse | undefined> => {\n if (!intentHash) {\n return undefined;\n }\n\n return sodax.backendApiService.getIntentByHash(intentHash);\n },\n enabled: !!intentHash && intentHash.length > 0,\n retry: 3,\n });\n};\n","// packages/dapp-kit/src/hooks/backend/useOrderbook.ts\nimport { useQuery, type UseQueryResult } from '@tanstack/react-query';\nimport type { OrderbookResponse } from '@sodax/sdk';\nimport { useSodaxContext } from '../shared/useSodaxContext';\n\n/**\n * Hook for fetching the solver orderbook from the backend API.\n *\n * This hook provides access to the solver orderbook data, including intent states\n * and intent data for all available intents. The data is automatically fetched\n * and cached using React Query with pagination support.\n *\n * @param {Object} params - Pagination parameters for the orderbook\n * @param {string} params.offset - The offset for pagination (number as string)\n * @param {string} params.limit - The limit for pagination (number as string)\n *\n * @returns {UseQueryResult<OrderbookResponse | undefined>} A query result object containing:\n * - data: The orderbook response data when available\n * - isLoading: Boolean indicating if the request is in progress\n * - error: Error object if the request failed\n * - refetch: Function to manually trigger a data refresh\n *\n * @example\n * ```typescript\n * const { data: orderbook, isLoading, error } = useOrderbook({\n * offset: '0',\n * limit: '10'\n * });\n *\n * if (isLoading) return <div>Loading orderbook...</div>;\n * if (error) return <div>Error: {error.message}</div>;\n * if (orderbook) {\n * console.log('Total intents:', orderbook.total);\n * console.log('Intents:', orderbook.data);\n * }\n * ```\n *\n * @remarks\n * - The query is disabled when params are undefined or invalid\n * - Uses React Query for efficient caching and state management\n * - Automatically handles error states and loading indicators\n * - Stale time of 30 seconds for real-time orderbook data\n * - Supports pagination through offset and limit parameters\n */\nexport const useBackendOrderbook = (\n params: { offset: string; limit: string } | undefined,\n): UseQueryResult<OrderbookResponse | undefined> => {\n const { sodax } = useSodaxContext();\n\n return useQuery({\n queryKey: ['backend', 'solver', 'orderbook', params],\n queryFn: async (): Promise<OrderbookResponse | undefined> => {\n if (!params || !params.offset || !params.limit) {\n return undefined;\n }\n\n return sodax.backendApiService.getOrderbook(params);\n },\n enabled: !!params && !!params.offset && !!params.limit,\n staleTime: 30 * 1000, // 30 seconds for real-time data\n retry: 3,\n });\n};\n","// packages/dapp-kit/src/hooks/backend/useMoneyMarketPosition.ts\nimport { useQuery, type UseQueryResult } from '@tanstack/react-query';\nimport type { MoneyMarketPosition } from '@sodax/sdk';\nimport { useSodaxContext } from '../shared/useSodaxContext';\n\n/**\n * Hook for fetching money market position for a specific user from the backend API.\n *\n * This hook provides access to a user's money market positions, including their\n * aToken balances, variable debt token balances, and associated reserve information.\n * The data is automatically fetched and cached using React Query.\n *\n * @param {string | undefined} userAddress - The user's wallet address. If undefined, the query will be disabled.\n *\n * @returns {UseQueryResult<MoneyMarketPosition | undefined>} A query result object containing:\n * - data: The money market position data when available\n * - isLoading: Boolean indicating if the request is in progress\n * - error: Error object if the request failed\n * - refetch: Function to manually trigger a data refresh\n *\n * @example\n * ```typescript\n * const { data: position, isLoading, error } = useMoneyMarketPosition('0x123...');\n *\n * if (isLoading) return <div>Loading position...</div>;\n * if (error) return <div>Error: {error.message}</div>;\n * if (position) {\n * console.log('User address:', position.userAddress);\n * console.log('Positions:', position.positions);\n * }\n * ```\n *\n * @remarks\n * - The query is disabled when userAddress is undefined or empty\n * - Uses React Query for efficient caching and state management\n * - Automatically handles error states and loading indicators\n * - Includes user's aToken and debt token balances across all reserves\n */\nexport const useBackendMoneyMarketPosition = (\n userAddress: string | undefined,\n): UseQueryResult<MoneyMarketPosition | undefined> => {\n const { sodax } = useSodaxContext();\n\n return useQuery({\n queryKey: ['backend', 'moneymarket', 'position', userAddress],\n queryFn: async (): Promise<MoneyMarketPosition | undefined> => {\n if (!userAddress) {\n return undefined;\n }\n\n return sodax.backendApiService.getMoneyMarketPosition(userAddress);\n },\n enabled: !!userAddress && userAddress.length > 0,\n retry: 3,\n });\n};\n","// packages/dapp-kit/src/hooks/backend/useAllMoneyMarketAssets.ts\nimport { useQuery, type UseQueryResult } from '@tanstack/react-query';\nimport type { MoneyMarketAsset } from '@sodax/sdk';\nimport { useSodaxContext } from '../shared/useSodaxContext';\n\n/**\n * Hook for fetching all money market assets from the backend API.\n *\n * This hook provides access to all available money market assets, including\n * their reserve information, liquidity rates, borrow rates, and market statistics.\n * The data is automatically fetched and cached using React Query.\n *\n * @returns {UseQueryResult<MoneyMarketAsset[]>} A query result object containing:\n * - data: Array of money market asset data when available\n * - isLoading: Boolean indicating if the request is in progress\n * - error: Error object if the request failed\n * - refetch: Function to manually trigger a data refresh\n *\n * @example\n * ```typescript\n * const { data: assets, isLoading, error } = useAllMoneyMarketAssets();\n *\n * if (isLoading) return <div>Loading assets...</div>;\n * if (error) return <div>Error: {error.message}</div>;\n * if (assets) {\n * console.log('Total assets:', assets.length);\n * assets.forEach(asset => {\n * console.log(`${asset.symbol}: ${asset.liquidityRate} liquidity rate`);\n * });\n * }\n * ```\n *\n * @remarks\n * - Uses React Query for efficient caching and state management\n * - Automatically handles error states and loading indicators\n * - Returns comprehensive asset information including rates and statistics\n * - No parameters required - fetches all available assets\n */\nexport const useBackendAllMoneyMarketAssets = (): UseQueryResult<MoneyMarketAsset[]> => {\n const { sodax } = useSodaxContext();\n\n return useQuery({\n queryKey: ['backend', 'moneymarket', 'assets', 'all'],\n queryFn: async (): Promise<MoneyMarketAsset[]> => {\n return sodax.backendApiService.getAllMoneyMarketAssets();\n },\n retry: 3,\n });\n};\n","// packages/dapp-kit/src/hooks/backend/useMoneyMarketAsset.ts\nimport { useQuery, type UseQueryResult } from '@tanstack/react-query';\nimport type { MoneyMarketAsset } from '@sodax/sdk';\nimport { useSodaxContext } from '../shared/useSodaxContext';\n\n/**\n * Hook for fetching specific money market asset details from the backend API.\n *\n * This hook provides access to detailed information for a specific money market asset,\n * including reserve information, liquidity rates, borrow rates, and market statistics.\n * The data is automatically fetched and cached using React Query.\n *\n * @param {string | undefined} reserveAddress - The reserve contract address. If undefined, the query will be disabled.\n *\n * @returns {UseQueryResult<MoneyMarketAsset | undefined>} A query result object containing:\n * - data: The money market asset data when available\n * - isLoading: Boolean indicating if the request is in progress\n * - error: Error object if the request failed\n * - refetch: Function to manually trigger a data refresh\n *\n * @example\n * ```typescript\n * const { data: asset, isLoading, error } = useMoneyMarketAsset('0xabc...');\n *\n * if (isLoading) return <div>Loading asset...</div>;\n * if (error) return <div>Error: {error.message}</div>;\n * if (asset) {\n * console.log('Asset symbol:', asset.symbol);\n * console.log('Liquidity rate:', asset.liquidityRate);\n * console.log('Variable borrow rate:', asset.variableBorrowRate);\n * }\n * ```\n *\n * @remarks\n * - The query is disabled when reserveAddress is undefined or empty\n * - Uses React Query for efficient caching and state management\n * - Automatically handles error states and loading indicators\n * - Returns comprehensive asset information for the specified reserve\n */\nexport const useBackendMoneyMarketAsset = (\n reserveAddress: string | undefined,\n): UseQueryResult<MoneyMarketAsset | undefined> => {\n const { sodax } = useSodaxContext();\n\n return useQuery({\n queryKey: ['backend', 'moneymarket', 'asset', reserveAddress],\n queryFn: async (): Promise<MoneyMarketAsset | undefined> => {\n if (!reserveAddress) {\n return undefined;\n }\n\n return sodax.backendApiService.getMoneyMarketAsset(reserveAddress);\n },\n enabled: !!reserveAddress && reserveAddress.length > 0,\n retry: 3,\n });\n};\n","// packages/dapp-kit/src/hooks/backend/useMoneyMarketAssetBorrowers.ts\nimport { useQuery, type UseQueryResult } from '@tanstack/react-query';\nimport type { MoneyMarketAssetBorrowers } from '@sodax/sdk';\nimport { useSodaxContext } from '../shared/useSodaxContext';\n\n/**\n * Hook for fetching borrowers for a specific money market asset from the backend API.\n *\n * This hook provides access to the list of borrowers for a specific money market asset,\n * with pagination support. The data is automatically fetched and cached using React Query.\n *\n * @param {Object} params - Parameters for fetching asset borrowers\n * @param {string | undefined} params.reserveAddress - The reserve contract address. If undefined, the query will be disabled.\n * @param {string} params.offset - The offset for pagination (number as string)\n * @param {string} params.limit - The limit for pagination (number as string)\n *\n * @returns {UseQueryResult<MoneyMarketAssetBorrowers | undefined>} A query result object containing:\n * - data: The asset borrowers data when available\n * - isLoading: Boolean indicating if the request is in progress\n * - error: Error object if the request failed\n * - refetch: Function to manually trigger a data refresh\n *\n * @example\n * ```typescript\n * const { data: borrowers, isLoading, error } = useMoneyMarketAssetBorrowers({\n * reserveAddress: '0xabc...',\n * offset: '0',\n * limit: '20'\n * });\n *\n * if (isLoading) return <div>Loading borrowers...</div>;\n * if (error) return <div>Error: {error.message}</div>;\n * if (borrowers) {\n * console.log('Total borrowers:', borrowers.total);\n * console.log('Borrowers:', borrowers.borrowers);\n * }\n * ```\n *\n * @remarks\n * - The query is disabled when reserveAddress is undefined or empty\n * - Uses React Query for efficient caching and state management\n * - Automatically handles error states and loading indicators\n * - Supports pagination through offset and limit parameters\n */\nexport const useBackendMoneyMarketAssetBorrowers = (params: {\n reserveAddress: string | undefined;\n offset: string;\n limit: string;\n}): UseQueryResult<MoneyMarketAssetBorrowers | undefined> => {\n const { sodax } = useSodaxContext();\n\n return useQuery({\n queryKey: ['backend', 'moneymarket', 'asset', 'borrowers', params],\n queryFn: async (): Promise<MoneyMarketAssetBorrowers | undefined> => {\n if (!params.reserveAddress || !params.offset || !params.limit) {\n return undefined;\n }\n\n return sodax.backendApiService.getMoneyMarketAssetBorrowers(params.reserveAddress, {\n offset: params.offset,\n limit: params.limit,\n });\n },\n enabled: !!params.reserveAddress && !!params.offset && !!params.limit,\n retry: 3,\n });\n};\n","// packages/dapp-kit/src/hooks/backend/useMoneyMarketAssetSuppliers.ts\nimport { useQuery, type UseQueryResult } from '@tanstack/react-query';\nimport type { MoneyMarketAssetSuppliers } from '@sodax/sdk';\nimport { useSodaxContext } from '../shared/useSodaxContext';\n\n/**\n * Hook for fetching suppliers for a specific money market asset from the backend API.\n *\n * This hook provides access to the list of suppliers for a specific money market asset,\n * with pagination support. The data is automatically fetched and cached using React Query.\n *\n * @param {Object} params - Parameters for fetching asset suppliers\n * @param {string | undefined} params.reserveAddress - The reserve contract address. If undefined, the query will be disabled.\n * @param {string} params.offset - The offset for pagination (number as string)\n * @param {string} params.limit - The limit for pagination (number as string)\n *\n * @returns {UseQueryResult<MoneyMarketAssetSuppliers | undefined>} A query result object containing:\n * - data: The asset suppliers data when available\n * - isLoading: Boolean indicating if the request is in progress\n * - error: Error object if the request failed\n * - refetch: Function to manually trigger a data refresh\n *\n * @example\n * ```typescript\n * const { data: suppliers, isLoading, error } = useMoneyMarketAssetSuppliers({\n * reserveAddress: '0xabc...',\n * offset: '0',\n * limit: '20'\n * });\n *\n * if (isLoading) return <div>Loading suppliers...</div>;\n * if (error) return <div>Error: {error.message}</div>;\n * if (suppliers) {\n * console.log('Total suppliers:', suppliers.total);\n * console.log('Suppliers:', suppliers.suppliers);\n * }\n * ```\n *\n * @remarks\n * - The query is disabled when reserveAddress is undefined or empty\n * - Uses React Query for efficient caching and state management\n * - Automatically handles error states and loading indicators\n * - Supports pagination through offset and limit parameters\n */\nexport const useBackendMoneyMarketAssetSuppliers = (params: {\n reserveAddress: string | undefined;\n offset: string;\n limit: string;\n}): UseQueryResult<MoneyMarketAssetSuppliers | undefined> => {\n const { sodax } = useSodaxContext();\n\n return useQuery({\n queryKey: ['backend', 'moneymarket', 'asset', 'suppliers', params],\n queryFn: async (): Promise<MoneyMarketAssetSuppliers | undefined> => {\n if (!params.reserveAddress || !params.offset || !params.limit) {\n return undefined;\n }\n\n return sodax.backendApiService.getMoneyMarketAssetSuppliers(params.reserveAddress, {\n offset: params.offset,\n limit: params.limit,\n });\n },\n enabled: !!params.reserveAddress && !!params.offset && !!params.limit,\n retry: 3,\n });\n};\n","// packages/dapp-kit/src/hooks/backend/useAllMoneyMarketBorrowers.ts\nimport { useQuery, type UseQueryResult } from '@tanstack/react-query';\nimport type { MoneyMarketBorrowers } from '@sodax/sdk';\nimport { useSodaxContext } from '../shared/useSodaxContext';\n\n/**\n * Hook for fetching all money market borrowers from the backend API.\n *\n * This hook provides access to the list of all borrowers across all money market assets,\n * with pagination support. The data is automatically fetched and cached using React Query.\n *\n * @param {Object} params - Pagination parameters for fetching all borrowers\n * @param {string} params.offset - The offset for pagination (number as string)\n * @param {string} params.limit - The limit for pagination (number as string)\n *\n * @returns {UseQueryResult<MoneyMarketBorrowers | undefined>} A query result object containing:\n * - data: The all borrowers data when available\n * - isLoading: Boolean indicating if the request is in progress\n * - error: Error object if the request failed\n * - refetch: Function to manually trigger a data refresh\n *\n * @example\n * ```typescript\n * const { data: borrowers, isLoading, error } = useAllMoneyMarketBorrowers({\n * offset: '0',\n * limit: '50'\n * });\n *\n * if (isLoading) return <div>Loading borrowers...</div>;\n * if (error) return <div>Error: {error.message}</div>;\n * if (borrowers) {\n * console.log('Total borrowers:', borrowers.total);\n * console.log('Borrowers:', borrowers.borrowers);\n * }\n * ```\n *\n * @remarks\n * - The query is disabled when params are undefined or invalid\n * - Uses React Query for efficient caching and state management\n * - Automatically handles error states and loading indicators\n * - Supports pagination through offset and limit parameters\n * - Returns borrowers across all money market assets\n */\nexport const useBackendAllMoneyMarketBorrowers = (\n params: { offset: string; limit: string } | undefined,\n): UseQueryResult<MoneyMarketBorrowers | undefined> => {\n const { sodax } = useSodaxContext();\n\n return useQuery({\n queryKey: ['backend', 'moneymarket', 'borrowers', 'all', params],\n queryFn: async (): Promise<MoneyMarketBorrowers | undefined> => {\n if (!params || !params.offset || !params.limit) {\n return undefined;\n }\n\n return sodax.backendApiService.getAllMoneyMarketBorrowers(params);\n },\n enabled: !!params && !!params.offset && !!params.limit,\n retry: 3,\n });\n};\n","import { useQuery, type UseQueryResult } from '@tanstack/react-query';\nimport { useSodaxContext } from '../shared/useSodaxContext';\nimport type { SpokeProvider, CreateBridgeIntentParams } from '@sodax/sdk';\n\n/**\n * Hook for checking token allowance for bridge operations.\n *\n * This hook verifies if the user has approved enough tokens for a specific bridge action.\n * It automatically queries and tracks the allowance status.\n *\n * @param {BridgeParams} params - The parameters for the bridge to check allowance for.\n * @param {SpokeProvider} spokeProvider - The spoke provider to use for allowance checks\n *\n * @returns {UseQueryResult<boolean, Error>} A React Query result containing:\n * - data: Boolean indicating if allowance is sufficient\n * - isLoading: Loading state indicator\n * - error: Any error that occurred during the check\n *\n * @example\n * ```typescript\n * const { data: hasAllowed, isLoading } = useBridgeAllowance(params, spokeProvider);\n * ```\n */\nexport function useBridgeAllowance(\n params: CreateBridgeIntentParams | undefined,\n spokeProvider: SpokeProvider | undefined,\n): UseQueryResult<boolean, Error> {\n const { sodax } = useSodaxContext();\n\n return useQuery({\n queryKey: ['bridge-allowance', params],\n queryFn: async () => {\n if (!spokeProvider || !params) {\n return false;\n }\n\n const allowance = await sodax.bridge.isAllowanceValid({\n params,\n spokeProvider,\n });\n\n if (allowance.ok) {\n return allowance.value;\n }\n return false;\n },\n enabled: !!spokeProvider && !!params,\n });\n}\n","import { useSodaxContext } from '../shared/useSodaxContext';\nimport type { CreateBridgeIntentParams, SpokeProvider } from '@sodax/sdk';\nimport { useMutation, useQueryClient } from '@tanstack/react-query';\n\ninterface UseBridgeApproveReturn {\n approve: (params: CreateBridgeIntentParams) => Promise<boolean>;\n isLoading: boolean;\n error: Error | null;\n resetError: () => void;\n}\n\n/**\n * Hook for approving token spending for bridge actions\n * @param spokeProvider The spoke provider instance for the chain\n * @returns Object containing approve function, loading state, error state and reset function\n * @example\n * ```tsx\n * const { approve, isLoading, error } = useBridgeApprove(spokeProvider);\n *\n * // Approve tokens for bridge action\n * await approve({\n * srcChainId: '0x2105.base',\n * srcAsset: '0x...',\n * amount: 1000n,\n * dstChainId: '0x89.polygon',\n * dstAsset: '0x...',\n * recipient: '0x...'\n * });\n * ```\n */\nexport function useBridgeApprove(spokeProvider: SpokeProvider | undefined): UseBridgeApproveReturn {\n const { sodax } = useSodaxContext();\n const queryClient = useQueryClient();\n\n const {\n mutateAsync: approve,\n isPending,\n error,\n reset: resetError,\n } = useMutation({\n mutationFn: async (params: CreateBridgeIntentParams) => {\n if (!spokeProvider) {\n throw new Error('Spoke provider not found');\n }\n\n const allowance = await sodax.bridge.approve({\n params,\n spokeProvider,\n });\n\n if (!allowance.ok) {\n throw new Error('Failed to approve tokens for bridge');\n }\n return true;\n },\n onSuccess: (_, params) => {\n // Invalidate allowance query to refetch the new allowance\n queryClient.invalidateQueries({ queryKey: ['bridge-allowance', params] });\n },\n });\n\n return {\n approve,\n isLoading: isPending,\n error: error,\n resetError,\n };\n}\n","import { useSodaxContext } from '../shared/useSodaxContext';\nimport type { BridgeError, BridgeErrorCode, SpokeTxHash, HubTxHash, Result, CreateBridgeIntentParams } from '@sodax/sdk';\nimport { useMutation, type UseMutationResult } from '@tanstack/react-query';\nimport type { SpokeProvider } from '@sodax/sdk';\n\n/**\n * Hook for executing bridge transactions to transfer tokens between chains.\n * Uses React Query's useMutation for better state management and caching.\n *\n * @param {SpokeProvider} spokeProvider - The spoke provider to use for the bridge\n * @returns {UseMutationResult} Mutation result object containing mutation function and state\n *\n * @example\n * ```typescript\n * const { mutateAsync: bridge, isPending } = useBridge(spokeProvider);\n *\n * const handleBridge = async () => {\n * const result = await bridge({\n * srcChainId: '0x2105.base',\n * srcAsset: '0x...',\n * amount: 1000n,\n * dstChainId: '0x89.polygon',\n * dstAsset: '0x...',\n * recipient: '0x...'\n * });\n *\n * console.log('Bridge transaction hashes:', {\n * spokeTxHash: result.spokeTxHash,\n * hubTxHash: result.hubTxHash\n * });\n * };\n * ```\n */\nexport function useBridge(\n spokeProvider: SpokeProvider | undefined,\n): UseMutationResult<Result<[SpokeTxHash, HubTxHash], BridgeError<BridgeErrorCode>>, Error, CreateBridgeIntentParams> {\n const { sodax } = useSodaxContext();\n\n return useMutation<Result<[SpokeTxHash, HubTxHash], BridgeError<BridgeErrorCode>>, Error, CreateBridgeIntentParams>({\n mutationFn: async (params: CreateBridgeIntentParams) => {\n if (!spokeProvider) {\n throw new Error('Spoke provider not found');\n }\n\n const result = await sodax.bridge.bridge({\n params,\n spokeProvider,\n });\n\n if (!result.ok) {\n throw new Error(`Bridge failed: ${result.error.code}`);\n }\n\n return result;\n },\n });\n}\n","import { useQuery, type UseQueryResult } from '@tanstack/react-query';\nimport { useSodaxContext } from '../shared/useSodaxContext';\nimport type { Result, SpokeChainId, XToken } from '@sodax/sdk';\n\n/**\n * Hook for getting the amount available to be bridged.\n *\n * This hook is used to check if a target chain has enough balance to bridge when bridging.\n * It automatically queries and tracks the available amount to be bridged.\n *\n * @param {SpokeChainId | undefined} chainId - The chain ID to get the balance for\n * @param {string | undefined} token - The token address to get the balance for\n *\n * @returns {UseQueryResult<bigint, Error>} A React Query result containing:\n * - data: The available amount to be bridged (bigint)\n * - error: Any error that occurred during the check\n *\n * @example\n * ```typescript\n * const { data: balance, isLoading } = useSpokeAssetManagerTokenBalance(chainId, tokenAddress);\n *\n * if (balance) {\n * console.log('Asset manager token balance:', balance.toString());\n * }\n * ```\n */\nexport function useGetBridgeableAmount(\n from: XToken | undefined,\n to: XToken | undefined,\n): UseQueryResult<bigint, Error> {\n const { sodax } = useSodaxContext();\n\n return useQuery({\n queryKey: ['spoke-asset-manager-token-balance', from, to],\n queryFn: async () => {\n if (!from || !to) {\n return 0n;\n }\n\n const result = await sodax.bridge.getBridgeableAmount(from, to);\n if (result.ok) {\n return result.value;\n }\n\n console.error('Error getting bridgeable amount:', result.error);\n return 0n;\n },\n enabled: !!from && !!to,\n });\n}\n","import { useQuery, type UseQueryResult } from '@tanstack/react-query';\nimport type { XToken, SpokeChainId } from '@sodax/sdk';\nimport { useSodaxContext } from '../shared';\n\n/**\n/**\n * Hook for retrieving all bridgeable tokens from a source token on one chain to a destination chain.\n *\n * This hook queries and tracks the set of tokens on the destination chain that can be bridged to,\n * given a source chain, destination chain, and source token address.\n *\n * @param {SpokeChainId | undefined} from - The source chain ID\n * @param {SpokeChainId | undefined} to - The destination chain ID\n * @param {string | undefined} token - The source token address\n *\n * @returns {UseQueryResult<XToken[], Error>} A React Query result containing:\n * - data: Array of bridgeable tokens (XToken[]) on the destination chain\n * - error: Any error that occurred during the query\n *\n *\n * @example\n * ```typescript\n * const { data: bridgeableTokens, isLoading } = useGetBridgeableTokens(\n * fromChainId,\n * toChainId,\n * fromTokenAddress\n * );\n *\n * if (bridgeableTokens && bridgeableTokens.length > 0) {\n * bridgeableTokens.forEach(token => {\n * console.log(`Bridgeable token: ${token.symbol} (${token.address}) on chain ${token.xChainId}`);\n * });\n * } else {\n * console.log('No bridgeable tokens found for the selected route.');\n * }\n * ```\n */\nexport function useGetBridgeableTokens(\n from: SpokeChainId | undefined,\n to: SpokeChainId | undefined,\n token: string | undefined,\n): UseQueryResult<XToken[], Error> {\n const { sodax } = useSodaxContext();\n\n return useQuery({\n queryKey: ['bridgeable-tokens', from, to, token],\n queryFn: async () => {\n if (!from || !to || !token) {\n return [];\n }\n\n const result = sodax.bridge.getBridgeableTokens(from, to, token);\n if (result.ok) {\n return result.value;\n }\n\n console.error('Error getting bridgeable tokens:', result.error);\n return [];\n },\n enabled: !!from && !!to && !!token,\n });\n}\n","import type { ReactNode, ReactElement } from 'react';\nimport React from 'react';\n\nimport { Sodax, type SodaxConfig } from '@sodax/sdk';\nimport { SodaxContext } from '@/contexts';\nimport type { RpcConfig } from '@/types';\n\ninterface SodaxProviderProps {\n children: ReactNode;\n testnet?: boolean;\n config?: SodaxConfig;\n rpcConfig: RpcConfig;\n}\n\nexport const SodaxProvider = ({ children, testnet = false, config, rpcConfig }: SodaxProviderProps): ReactElement => {\n const sodax = new Sodax(config);\n\n return <SodaxContext.Provider value={{ sodax, testnet, rpcConfig }}>{children}</SodaxContext.Provider>;\n};\n","import type { ChainId } from '@sodax/types';\n\nimport { hubAssets } from '@sodax/sdk';\n\nexport const getSpokeTokenAddressByVault = (spokeChainId: ChainId, vault: string) => {\n const tokens = hubAssets[spokeChainId];\n const address = Object.keys(tokens).find(\n tokenAddress => tokens[tokenAddress].vault.toLowerCase() === vault.toLowerCase(),\n );\n\n return address;\n};\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/contexts/index.ts","../src/hooks/shared/useSodaxContext.ts","../src/hooks/shared/useEstimateGas.ts","../src/hooks/shared/useDeriveUserWalletAddress.ts","../src/hooks/provider/useHubProvider.ts","../src/hooks/provider/useSpokeProvider.ts","../src/hooks/mm/useBorrow.ts","../src/hooks/mm/useRepay.ts","../src/hooks/mm/useSupply.ts","../src/hooks/mm/useWithdraw.ts","../src/hooks/mm/useUserReservesData.ts","../src/hooks/mm/useReservesData.ts","../src/hooks/mm/useMMAllowance.ts","../src/hooks/mm/useMMApprove.ts","../src/hooks/swap/useQuote.ts","../src/hooks/swap/useSwap.ts","../src/hooks/swap/useStatus.ts","../src/hooks/swap/useSwapAllowance.ts","../src/hooks/swap/useSwapApprove.ts","../src/hooks/swap/useCancelSwap.ts","../src/hooks/backend/useBackendIntentByTxHash.ts","../src/hooks/backend/useBackendIntentByHash.ts","../src/hooks/backend/useBackendOrderbook.ts","../src/hooks/backend/useBackendMoneyMarketPosition.ts","../src/hooks/backend/useBackendAllMoneyMarketAssets.ts","../src/hooks/backend/useBackendMoneyMarketAsset.ts","../src/hooks/backend/useBackendMoneyMarketAssetBorrowers.ts","../src/hooks/backend/useBackendMoneyMarketAssetSuppliers.ts","../src/hooks/backend/useBackendAllMoneyMarketBorrowers.ts","../src/hooks/bridge/useBridgeAllowance.ts","../src/hooks/bridge/useBridgeApprove.ts","../src/hooks/bridge/useBridge.ts","../src/hooks/bridge/useGetBridgeableAmount.ts","../src/hooks/bridge/useGetBridgeableTokens.ts","../src/providers/SodaxProvider.tsx","../src/core/index.ts"],"names":["createContext","useContext","useMutation","SpokeService","useQuery","deriveUserWalletAddress","spokeChainConfig","useMemo","SONIC_MAINNET_CHAIN_ID","SonicSpokeProvider","EvmSpokeProvider","SuiSpokeProvider","IconSpokeProvider","InjectiveSpokeProvider","StellarSpokeProvider","SolanaSpokeProvider","parseUnits","useQueryClient","params","Sodax","React","hubAssets"],"mappings":";;;;;;;;;;;;AAUO,IAAM,YAAA,GAAeA,oBAAuC,IAAI,CAAA;ACDhE,IAAM,kBAAkB,MAAwB;AACrD,EAAA,MAAM,OAAA,GAAUC,iBAAW,YAAY,CAAA;AACvC,EAAA,IAAI,CAAC,OAAA,EAAS;AACZ,IAAA,MAAM,IAAI,MAAM,qDAAqD,CAAA;AAAA,EACvE;AACA,EAAA,OAAO,OAAA;AACT;ACZO,SAAS,eACd,aAAA,EAC8E;AAC9E,EAAA,OAAOC,sBAAA,CAAu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nB,MAAA,IAAI,CAAC,IAAA,IAAQ,CAAC,EAAA,IAAM,CAAC,KAAA,EAAO;AAC1B,QAAA,OAAO,EAAC;AAAA,MACV;AAEA,MAAA,MAAM,SAAS,KAAA,CAAM,MAAA,CAAO,mBAAA,CAAoB,IAAA,EAAM,IAAI,KAAK,CAAA;AAC/D,MAAA,IAAI,OAAO,EAAA,EAAI;AACb,QAAA,OAAO,MAAA,CAAO,KAAA;AAAA,MAChB;AAEA,MAAA,OAAA,CAAQ,KAAA,CAAM,kCAAA,EAAoC,MAAA,CAAO,KAAK,CAAA;AAC9D,MAAA,OAAO,EAAC;AAAA,IACV,CAAA;AAAA,IACA,OAAA,EAAS,CAAC,CAAC,IAAA,IAAQ,CAAC,CAAC,EAAA,IAAM,CAAC,CAAC;AAAA,GAC9B,CAAA;AACH;AC/CO,IAAM,aAAA,GAAgB,CAAC,EAAE,QAAA,EAAU,UAAU,KAAA,EAAO,MAAA,EAAQ,WAAU,KAAwC;AACnH,EAAA,MAAM,KAAA,GAAQ,IAAIe,SAAA,CAAM,MAAM,CAAA;AAE9B,EAAA,uBAAOC,sBAAA,CAAA,aAAA,CAAC,YAAA,CAAa,QAAA,EAAb,EAAsB,KAAA,EAAO,EAAE,KAAA,EAAO,OAAA,EAAS,SAAA,EAAU,EAAA,EAAI,QAAS,CAAA;AAChF;ACdO,IAAM,2BAAA,GAA8B,CAAC,YAAA,EAAuB,KAAA,KAAkB;AACnF,EAAA,MAAM,MAAA,GAASC,cAAU,YAAY,CAAA;AACrC,EAAA,MAAM,OAAA,GAAU,MAAA,CAAO,IAAA,CAAK,MAAM,CAAA,CAAE,IAAA;AAAA,IAClC,CAAA,YAAA,KAAgB,OAAO,YAAY,CAAA,CAAE,MAAM,WAAA,EAAY,KAAM,MAAM,WAAA;AAAY,GACjF;AAEA,EAAA,OAAO,OAAA;AACT","file":"index.js","sourcesContent":["import { createContext } from 'react';\nimport type { Sodax } from '@sodax/sdk';\nimport type { RpcConfig } from '@/types';\n\nexport interface SodaxContextType {\n sodax: Sodax;\n testnet: boolean;\n rpcConfig: RpcConfig;\n}\n\nexport const SodaxContext = createContext<SodaxContextType | null>(null);\n","import { SodaxContext, type SodaxContextType } from '@/contexts';\nimport { useContext } from 'react';\n\n/**\n * Hook to access the Sodax context which provides access to the Sodax SDK instance and chain configuration\n * @throws {Error} If used outside of a SodaxProvider\n * @returns {SodaxContextType} The Sodax context containing SDK instance and configuration\n */\n\nexport const useSodaxContext = (): SodaxContextType => {\n const context = useContext(SodaxContext);\n if (!context) {\n throw new Error('useSodaxContext must be used within a SodaxProvider');\n }\n return context;\n};\n","import { type GetEstimateGasReturnType, type SpokeProvider, SpokeService, type TxReturnType } from '@sodax/sdk';\nimport { useMutation, type UseMutationResult } from '@tanstack/react-query';\n\nexport function useEstimateGas<T extends SpokeProvider = SpokeProvider>(\n spokeProvider: T | undefined,\n): UseMutationResult<GetEstimateGasReturnType<T>, Error, TxReturnType<T, true>> {\n return useMutation<GetEstimateGasReturnType<T>, Error, TxReturnType<T, true>>({\n mutationFn: async (rawTx: TxReturnType<T, true>) => {\n if (!spokeProvider) {\n throw new Error('spokeProvider is not found');\n }\n\n const response = await SpokeService.estimateGas(rawTx, spokeProvider);\n\n return response;\n },\n });\n}\n","// packages/dapp-kit/src/hooks/shared/useDeriveUserWalletAddress.ts\nimport { deriveUserWalletAddress, type SpokeProvider, type EvmHubProvider } from '@sodax/sdk';\nimport { useQuery, type UseQueryResult } from '@tanstack/react-query';\nimport { useSodaxContext } from './useSodaxContext';\nimport type { Address } from 'viem';\n\n/**\n * Hook for deriving user wallet address for hub abstraction.\n *\n * This hook derives the user's abstracted wallet address for the hub chain.\n * If the spoke chain is the same as the hub chain, it returns the original wallet address.\n * Otherwise, it returns the abstracted wallet address for cross-chain operations.\n *\n * @param spokeProvider - The spoke provider instance for the origin chain\n * @param walletAddress - Optional user wallet address on spoke chain. If not provided, will fetch from spokeProvider\n * @returns A React Query result object containing:\n * - data: The derived user wallet address when available\n * - isLoading: Loading state indicator\n * - error: Any error that occurred during derivation\n *\n * @example\n * ```typescript\n * const { data: derivedAddress, isLoading, error } = useDeriveUserWalletAddress(spokeProvider, userAddress);\n * ```\n */\nexport function useDeriveUserWalletAddress(\n spokeProvider: SpokeProvider | undefined,\n walletAddress?: string | undefined,\n): UseQueryResult<Address, Error> {\n const { sodax } = useSodaxContext();\n\n return useQuery({\n queryKey: ['deriveUserWalletAddress', spokeProvider?.chainConfig.chain.id, walletAddress],\n queryFn: async (): Promise<Address> => {\n if (!spokeProvider) {\n throw new Error('Spoke provider is required');\n }\n\n return await deriveUserWalletAddress(spokeProvider, sodax.hubProvider, walletAddress);\n },\n enabled: !!spokeProvider,\n refetchInterval: false, // This is a deterministic operation, no need to refetch\n });\n}\n","import type { EvmHubProvider } from '@sodax/sdk';\nimport { useSodaxContext } from '../shared/useSodaxContext';\n\nexport function useHubProvider(): EvmHubProvider {\n const { sodax } = useSodaxContext();\n\n return sodax.hubProvider;\n}\n","import { useSodaxContext } from '@/index';\nimport {\n EvmSpokeProvider,\n spokeChainConfig,\n type SuiSpokeChainConfig,\n SuiSpokeProvider,\n type EvmSpokeChainConfig,\n IconSpokeProvider,\n type IconSpokeChainConfig,\n InjectiveSpokeProvider,\n type InjectiveSpokeChainConfig,\n StellarSpokeProvider,\n type StellarSpokeChainConfig,\n type SpokeProvider,\n type IWalletProvider,\n SolanaSpokeProvider,\n type SolanaChainConfig,\n SONIC_MAINNET_CHAIN_ID,\n SonicSpokeProvider,\n type SonicSpokeChainConfig,\n} from '@sodax/sdk';\nimport type {\n IEvmWalletProvider,\n IIconWalletProvider,\n ISuiWalletProvider,\n SpokeChainId,\n IInjectiveWalletProvider,\n IStellarWalletProvider,\n ISolanaWalletProvider,\n} from '@sodax/types';\nimport { useMemo } from 'react';\n\n/**\n * Hook to get the appropriate spoke provider based on the chain type.\n * Supports EVM, SUI, ICON and INJECTIVE chains.\n *\n * @param {SpokeChainId | undefined} spokeChainId - The spoke chain ID to get the provider for\n * @param {IWalletProvider | undefined} walletProvider - The wallet provider to use\n * @returns {SpokeProvider | undefined} The appropriate spoke provider instance for the given chain ID, or undefined if invalid/unsupported\n *\n * @example\n * ```tsx\n * // Using a specific SpokeChainId and wallet provider\n * const spokeProvider = useSpokeProvider(spokeChainId, walletProvider);\n * ```\n */\nexport function useSpokeProvider(\n spokeChainId: SpokeChainId | undefined,\n walletProvider?: IWalletProvider | undefined,\n): SpokeProvider | undefined {\n const { rpcConfig } = useSodaxContext();\n const xChainType = spokeChainId ? spokeChainConfig[spokeChainId]?.chain.type : undefined;\n\n const spokeProvider = useMemo(() => {\n if (!walletProvider) return undefined;\n if (!spokeChainId) return undefined;\n if (!xChainType) return undefined;\n if (!rpcConfig) return undefined;\n\n if (xChainType === 'EVM') {\n if (spokeChainId === SONIC_MAINNET_CHAIN_ID) {\n return new SonicSpokeProvider(\n walletProvider as IEvmWalletProvider,\n spokeChainConfig[spokeChainId] as SonicSpokeChainConfig,\n );\n }\n return new EvmSpokeProvider(\n walletProvider as IEvmWalletProvider,\n spokeChainConfig[spokeChainId] as EvmSpokeChainConfig,\n );\n }\n\n if (xChainType === 'SUI') {\n return new SuiSpokeProvider(\n spokeChainConfig[spokeChainId] as SuiSpokeChainConfig,\n walletProvider as ISuiWalletProvider,\n );\n }\n\n if (xChainType === 'ICON') {\n return new IconSpokeProvider(\n walletProvider as IIconWalletProvider,\n spokeChainConfig[spokeChainId] as IconSpokeChainConfig,\n );\n }\n\n if (xChainType === 'INJECTIVE') {\n return new InjectiveSpokeProvider(\n spokeChainConfig[spokeChainId] as InjectiveSpokeChainConfig,\n walletProvider as IInjectiveWalletProvider,\n );\n }\n\n if (xChainType === 'STELLAR') {\n const stellarConfig = spokeChainConfig[spokeChainId] as StellarSpokeChainConfig;\n return new StellarSpokeProvider(\n walletProvider as IStellarWalletProvider,\n stellarConfig,\n rpcConfig.stellar\n ? rpcConfig.stellar\n : {\n horizonRpcUrl: stellarConfig.horizonRpcUrl,\n sorobanRpcUrl: stellarConfig.sorobanRpcUrl,\n },\n );\n }\n\n if (xChainType === 'SOLANA') {\n return new SolanaSpokeProvider(\n walletProvider as ISolanaWalletProvider,\n rpcConfig.solana\n ? ({\n ...spokeChainConfig[spokeChainId],\n rpcUrl: rpcConfig.solana,\n } as SolanaChainConfig)\n : (spokeChainConfig[spokeChainId] as SolanaChainConfig),\n );\n }\n\n return undefined;\n }, [spokeChainId, xChainType, walletProvider, rpcConfig]);\n\n return spokeProvider;\n}\n","import type { XToken } from '@sodax/types';\nimport { useMutation, type UseMutationResult } from '@tanstack/react-query';\nimport { parseUnits } from 'viem';\nimport { useSodaxContext } from '../shared/useSodaxContext';\nimport type { SpokeProvider } from '@sodax/sdk';\ninterface BorrowResponse {\n ok: true;\n value: [string, string];\n}\n\n/**\n * Hook for borrowing tokens from the Sodax money market.\n *\n * This hook provides functionality to borrow tokens from the money market protocol,\n * handling the entire borrow process including transaction creation, submission,\n * and cross-chain communication.\n *\n * @param {XToken} spokeToken - The token to borrow from the spoke chain. Must be an XToken with valid address and chain information.\n * @param {SpokeProvider} spokeProvider - The spoke provider to use for the borrow transaction. Must be a valid SpokeProvider instance.\n *\n * @returns {UseMutationResult<BorrowResponse, Error, string>} A mutation result object with the following properties:\n * - mutateAsync: Function to execute the borrow transaction\n * - isPending: Boolean indicating if a transaction is in progress\n * - error: Error object if the last transaction failed, null otherwise\n *\n * @example\n * ```typescript\n * const { mutateAsync: borrow, isPending, error } = useBorrow(spokeToken);\n * await borrow('100');\n * ```\n *\n * @throws {Error} When:\n * - spokeProvider is not available\n * - Transaction execution fails\n */\nexport function useBorrow(\n spokeToken: XToken,\n spokeProvider: SpokeProvider | undefined,\n): UseMutationResult<BorrowResponse, Error, string> {\n const { sodax } = useSodaxContext();\n\n return useMutation<BorrowResponse, Error, string>({\n mutationFn: async (amount: string) => {\n if (!spokeProvider) {\n throw new Error('spokeProvider is not found');\n }\n\n const response = await sodax.moneyMarket.borrow(\n {\n token: spokeToken.address,\n amount: parseUnits(amount, 18),\n action: 'borrow',\n },\n spokeProvider,\n );\n\n if (!response.ok) {\n throw new Error('Failed to borrow tokens');\n }\n\n console.log('Borrow transaction submitted:', response);\n return response;\n },\n });\n}\n","import type { SpokeProvider } from '@sodax/sdk';\nimport type { XToken } from '@sodax/types';\nimport { useMutation, type UseMutationResult } from '@tanstack/react-query';\nimport { parseUnits } from 'viem';\nimport { useSodaxContext } from '../shared/useSodaxContext';\n\ninterface RepayResponse {\n ok: true;\n value: [string, string];\n}\n\n/**\n * Hook for repaying borrowed tokens to the Sodax money market.\n *\n * This hook provides functionality to repay borrowed tokens back to the money market protocol,\n * handling the entire repayment process including transaction creation, submission,\n * and cross-chain communication.\n *\n * @param {XToken} spokeToken - The token to repay on the spoke chain. Must be an XToken with valid address and chain information.\n * @param {SpokeProvider} spokeProvider - The spoke provider to use for the repay transaction. Must be a valid SpokeProvider instance.\n *\n * @returns {UseMutationResult<RepayResponse, Error, string>} A mutation result object with the following properties:\n * - mutateAsync: Function to execute the repay transaction\n * - isPending: Boolean indicating if a transaction is in progress\n * - error: Error object if the last transaction failed, null otherwise\n *\n * @example\n * ```typescript\n * const { mutateAsync: repay, isPending, error } = useRepay(spokeToken);\n * await repay('100');\n * ```\n *\n * @throws {Error} When:\n * - spokeProvider is not available\n * - Transaction execution fails\n */\nexport function useRepay(\n spokeToken: XToken,\n spokeProvider: SpokeProvider | undefined,\n): UseMutationResult<RepayResponse, Error, string> {\n const { sodax } = useSodaxContext();\n\n return useMutation<RepayResponse, Error, string>({\n mutationFn: async (amount: string) => {\n if (!spokeProvider) {\n throw new Error('spokeProvider is not found');\n }\n\n const response = await sodax.moneyMarket.repay(\n {\n token: spokeToken.address,\n amount: parseUnits(amount, spokeToken.decimals),\n action: 'repay',\n },\n spokeProvider,\n );\n\n if (!response.ok) {\n throw new Error('Failed to repay tokens');\n }\n\n console.log('Repay transaction submitted:', response);\n return response;\n },\n });\n}\n","import type { SpokeProvider } from '@sodax/sdk';\nimport type { XToken } from '@sodax/types';\nimport { useMutation, type UseMutationResult } from '@tanstack/react-query';\nimport { parseUnits } from 'viem';\nimport { useSodaxContext } from '../shared/useSodaxContext';\n\ninterface SupplyResponse {\n ok: true;\n value: [string, string];\n}\n\n/**\n * Hook for supplying tokens to the Sodax money market.\n *\n * This hook provides functionality to supply tokens to the money market protocol,\n * handling the entire supply process including transaction creation, submission,\n * and cross-chain communication.\n *\n * @param {XToken} spokeToken - The token to supply on the spoke chain. Must be an XToken with valid address and chain information.\n * @param {SpokeProvider} spokeProvider - The spoke provider to use for the supply transaction. Must be a valid SpokeProvider instance.\n *\n * @returns {UseMutationResult<SupplyResponse, Error, string>} A mutation result object with the following properties:\n * - mutateAsync: Function to execute the supply transaction\n * - isPending: Boolean indicating if a transaction is in progress\n * - error: Error object if the last transaction failed, null otherwise\n *\n * @example\n * ```typescript\n * const { mutateAsync: supply, isPending, error } = useSupply(spokeToken);\n * await supply('100');\n * ```\n *\n * @throws {Error} When:\n * - spokeProvider is not available\n */\nexport function useSupply(\n spokeToken: XToken,\n spokeProvider: SpokeProvider | undefined,\n): UseMutationResult<SupplyResponse, Error, string> {\n const { sodax } = useSodaxContext();\n\n return useMutation<SupplyResponse, Error, string>({\n mutationFn: async (amount: string) => {\n if (!spokeProvider) {\n throw new Error('spokeProvider is not found');\n }\n\n const response = await sodax.moneyMarket.supply(\n {\n token: spokeToken.address,\n amount: parseUnits(amount, spokeToken.decimals),\n action: 'supply',\n },\n spokeProvider,\n );\n\n if (!response.ok) {\n throw new Error('Failed to supply tokens');\n }\n\n console.log('Supply transaction submitted:', response);\n return response;\n },\n });\n}\n","import type { SpokeProvider } from '@sodax/sdk';\nimport type { XToken } from '@sodax/types';\nimport { useMutation, type UseMutationResult } from '@tanstack/react-query';\nimport { parseUnits } from 'viem';\nimport { useSodaxContext } from '../shared/useSodaxContext';\n\ninterface WithdrawResponse {\n ok: true;\n value: [string, string];\n}\n\n/**\n * Hook for withdrawing supplied tokens from the Sodax money market.\n *\n * This hook provides functionality to withdraw previously supplied tokens from the money market protocol,\n * handling the entire withdrawal process including transaction creation, submission,\n * and cross-chain communication.\n *\n * @param {XToken} spokeToken - The token to withdraw from the spoke chain. Must be an XToken with valid address and chain information.\n * @param {SpokeProvider} spokeProvider - The spoke provider to use for the withdraw transaction. Must be a valid SpokeProvider instance.\n *\n * @returns {UseMutationResult<WithdrawResponse, Error, string>} A mutation result object with the following properties:\n * - mutateAsync: Function to execute the withdraw transaction\n * - isPending: Boolean indicating if a transaction is in progress\n * @example\n * ```typescript\n * const { mutateAsync: withdraw, isPending, error } = useWithdraw(spokeToken);\n * await withdraw('100');\n * ```\n *\n * @throws {Error} When:\n * - spokeProvider is not available\n * - Transaction execution fails\n */\nexport function useWithdraw(\n spokeToken: XToken,\n spokeProvider: SpokeProvider | undefined,\n): UseMutationResult<WithdrawResponse, Error, string> {\n const { sodax } = useSodaxContext();\n\n return useMutation<WithdrawResponse, Error, string>({\n mutationFn: async (amount: string) => {\n if (!spokeProvider) {\n throw new Error('spokeProvider is not found');\n }\n\n const response = await sodax.moneyMarket.withdraw(\n {\n token: spokeToken.address,\n // vault token on hub chain decimals is 18\n amount: parseUnits(amount, 18),\n action: 'withdraw',\n },\n spokeProvider,\n );\n\n if (!response.ok) {\n throw new Error('Failed to withdraw tokens');\n }\n\n console.log('Withdraw transaction submitted:', response);\n return response;\n },\n });\n}\n","import type { SpokeProvider, UserReserveData } from '@sodax/sdk';\nimport { useQuery, type UseQueryResult } from '@tanstack/react-query';\nimport { useSodaxContext } from '../shared/useSodaxContext';\n\n/**\n * Hook for fetching user reserves data from the Sodax money market.\n *\n * This hook provides access to the current state of user reserves in the money market protocol.\n * The data is automatically fetched and cached using React Query.\n *\n * @example\n * ```typescript\n * const { data: userReservesData, isLoading, error } = useUserReservesData(spokeProvider, address);\n * ```\n *\n * @returns A React Query result object containing:\n * - data: The user reserves data when available\n * - isLoading: Loading state indicator\n * - error: Any error that occurred during data fetching\n */\nexport function useUserReservesData(\n spokeProvider: SpokeProvider | undefined,\n address: string | undefined,\n refetchInterval = 5000,\n): UseQueryResult<readonly [readonly UserReserveData[], number], Error> {\n const { sodax } = useSodaxContext();\n\n return useQuery({\n queryKey: ['userReserves', spokeProvider?.chainConfig.chain.id, address],\n queryFn: async () => {\n if (!spokeProvider) {\n throw new Error('Spoke provider or address is not defined');\n }\n\n return await sodax.moneyMarket.data.getUserReservesData(spokeProvider);\n },\n enabled: !!spokeProvider && !!address,\n refetchInterval,\n });\n}\n","import { useQuery } from '@tanstack/react-query';\nimport { useSodaxContext } from '../shared/useSodaxContext';\n/**\n * Hook for fetching reserves data from the Sodax money market.\n *\n * This hook provides access to the current state of all reserves in the money market protocol,\n * including liquidity, interest rates, and other key metrics. The data is automatically\n * fetched and cached using React Query.\n *\n * @example\n * ```typescript\n * const { data: reservesData, isLoading, error } = useReservesData();\n * ```\n *\n * @returns A React Query result object containing:\n * - data: The reserves data when available\n * - isLoading: Loading state indicator\n * - error: Any error that occurred during data fetching\n */\n\nexport function useReservesData() {\n const { sodax } = useSodaxContext();\n\n return useQuery({\n queryKey: ['reservesData'],\n queryFn: async () => {\n return await sodax.moneyMarket.data.getReservesData();\n },\n });\n}\n","import { useQuery, type UseQueryResult } from '@tanstack/react-query';\nimport type { XToken } from '@sodax/types';\nimport { useSodaxContext } from '../shared/useSodaxContext';\nimport { parseUnits } from 'viem';\nimport type { MoneyMarketAction, SpokeProvider } from '@sodax/sdk';\n\n/**\n * Hook for checking token allowance for money market operations.\n *\n * This hook verifies if the user has approved enough tokens for a specific money market action\n * (borrow/repay). It automatically queries and tracks the allowance status.\n *\n * @param {XToken} token - The token to check allowance for. Must be an XToken with valid address and chain information.\n * @param {string} amount - The amount to check allowance for, as a decimal string\n * @param {MoneyMarketAction} action - The money market action to check allowance for ('borrow' or 'repay')\n * @param {SpokeProvider} spokeProvider - The spoke provider to use for allowance checks\n *\n * @returns {UseQueryResult<boolean, Error>} A React Query result containing:\n * - data: Boolean indicating if allowance is sufficient\n * - isLoading: Loading state indicator\n * - error: Any error that occurred during the check\n *\n * @example\n * ```typescript\n * const { data: hasAllowed, isLoading } = useMMAllowance(token, \"100\", \"repay\", provider);\n * ```\n */\nexport function useMMAllowance(\n token: XToken,\n amount: string,\n action: MoneyMarketAction,\n spokeProvider: SpokeProvider | undefined,\n): UseQueryResult<boolean, Error> {\n const { sodax } = useSodaxContext();\n\n return useQuery({\n queryKey: ['allowance', token.address, amount, action],\n queryFn: async () => {\n if (!spokeProvider) throw new Error('Spoke provider is required');\n const allowance = await sodax.moneyMarket.isAllowanceValid(\n {\n token: token.address,\n amount: parseUnits(amount, token.decimals),\n action,\n },\n spokeProvider,\n );\n if (allowance.ok) {\n return allowance.value;\n }\n return false;\n },\n enabled: !!spokeProvider,\n });\n}\n","import { useSodaxContext } from '../shared/useSodaxContext';\nimport type { XToken } from '@sodax/types';\nimport { parseUnits } from 'viem';\nimport { useMutation, useQueryClient } from '@tanstack/react-query';\nimport type { MoneyMarketAction, SpokeProvider } from '@sodax/sdk';\n\ninterface UseApproveReturn {\n approve: ({ amount, action }: { amount: string; action: MoneyMarketAction }) => Promise<boolean>;\n isLoading: boolean;\n error: Error | null;\n resetError: () => void;\n}\n\n/**\n * Hook for approving token spending for money market actions\n * @param token The token to approve spending for\n * @param spokeProvider The spoke provider instance for the chain\n * @returns Object containing approve function, loading state, error state and reset function\n * @example\n * ```tsx\n * const { approve, isLoading, error } = useMMApprove(token, spokeProvider);\n *\n * // Approve tokens for supply action\n * await approve({ amount: \"100\", action: \"supply\" });\n * ```\n */\n\nexport function useMMApprove(token: XToken, spokeProvider: SpokeProvider | undefined): UseApproveReturn {\n const { sodax } = useSodaxContext();\n const queryClient = useQueryClient();\n\n const {\n mutateAsync: approve,\n isPending,\n error,\n reset: resetError,\n } = useMutation({\n mutationFn: async ({ amount, action }: { amount: string; action: MoneyMarketAction }) => {\n if (!spokeProvider) {\n throw new Error('Spoke provider not found');\n }\n const allowance = await sodax.moneyMarket.approve(\n {\n token: token.address,\n amount: parseUnits(amount, token.decimals),\n action,\n },\n spokeProvider,\n );\n if (!allowance.ok) {\n throw new Error('Failed to approve tokens');\n }\n return allowance.ok;\n },\n onSuccess: () => {\n // Invalidate allowance query to refetch the new allowance\n queryClient.invalidateQueries({ queryKey: ['allowance', token.address] });\n },\n });\n\n return {\n approve,\n isLoading: isPending,\n error: error,\n resetError,\n };\n}\n","import type { SolverErrorResponse, SolverIntentQuoteRequest, SolverIntentQuoteResponse, Result } from '@sodax/sdk';\nimport { useSodaxContext } from '../shared/useSodaxContext';\nimport { useQuery, type UseQueryResult } from '@tanstack/react-query';\n\n/**\n * Hook for fetching a quote for an intent-based swap.\n *\n * This hook provides real-time quote data for an intent-based swap.\n *\n * @param {SolverIntentQuoteRequest | undefined} payload - The intent quote request parameters. If undefined, the query will be disabled.\n *\n * @returns {UseQueryResult<Result<SolverIntentQuoteResponse, SolverErrorResponse> | undefined>} A query result object containing:\n * - data: The quote result from the solver\n * - isLoading: Boolean indicating if the quote is being fetched\n * - error: Error object if the quote request failed\n * - refetch: Function to manually trigger a quote refresh\n *\n * @example\n * ```typescript\n * const { data: quote, isLoading } = useQuote({\n * token_src: '0x...',\n * token_src_blockchain_id: '1',\n * token_dst: '0x...',\n * token_dst_blockchain_id: '2',\n * amount: '1000000000000000000',\n * quote_type: 'exact_input',\n * });\n *\n * if (isLoading) return <div>Loading quote...</div>;\n * if (quote) {\n * console.log('Quote received:', quote);\n * }\n * ```\n *\n * @remarks\n * - The quote is automatically refreshed every 3 seconds\n * - The query is disabled when payload is undefined\n * - Uses React Query for efficient caching and state management\n */\nexport const useQuote = (\n payload: SolverIntentQuoteRequest | undefined,\n): UseQueryResult<Result<SolverIntentQuoteResponse, SolverErrorResponse> | undefined> => {\n const { sodax } = useSodaxContext();\n return useQuery({\n queryKey: [payload],\n queryFn: async () => {\n if (!payload) {\n return undefined;\n }\n return sodax.solver.getQuote(payload);\n },\n enabled: !!payload,\n refetchInterval: 3000,\n });\n};\n","import { useSodaxContext } from '../shared/useSodaxContext';\nimport type {\n CreateIntentParams,\n SolverExecutionResponse,\n Result,\n IntentErrorCode,\n Intent,\n IntentError,\n SpokeProvider,\n IntentDeliveryInfo,\n} from '@sodax/sdk';\nimport { useMutation, type UseMutationResult } from '@tanstack/react-query';\n\ntype CreateIntentResult = Result<[SolverExecutionResponse, Intent, IntentDeliveryInfo], IntentError<IntentErrorCode>>;\n\n/**\n * Hook for creating and submitting an swap intent order for cross-chain swaps.\n * Uses React Query's useMutation for better state management and caching.\n *\n * @param {SpokeProvider} spokeProvider - The spoke provider to use for the swap\n * @returns {UseMutationResult} Mutation result object containing mutation function and state\n *\n * @example\n * ```typescript\n * const { mutateAsync: swap, isPending } = useSwap(spokeProvider);\n *\n * const handleSwap = async () => {\n * const result = await swap({\n * token_src: '0x...',\n * token_src_blockchain_id: 'arbitrum',\n * token_dst: '0x...',\n * token_dst_blockchain_id: 'polygon',\n * amount: '1000000000000000000',\n * min_output_amount: '900000000000000000'\n * });\n * };\n * ```\n */\nexport function useSwap(\n spokeProvider: SpokeProvider | undefined,\n): UseMutationResult<CreateIntentResult, Error, CreateIntentParams> {\n const { sodax } = useSodaxContext();\n\n return useMutation<CreateIntentResult, Error, CreateIntentParams>({\n mutationFn: async (params: CreateIntentParams) => {\n if (!spokeProvider) {\n throw new Error('Spoke provider not found');\n }\n return sodax.solver.swap({\n intentParams: params,\n spokeProvider,\n });\n },\n });\n}\n","import type { Hex, SolverErrorResponse, SolverIntentStatusResponse, Result } from '@sodax/sdk';\nimport { useQuery, type UseQueryResult } from '@tanstack/react-query';\nimport { useSodaxContext } from '../shared/useSodaxContext';\n\n/**\n * Hook for monitoring the status of an intent-based swap.\n *\n * This hook provides real-time status updates for an intent-based swap transaction.\n *\n * @param {Hex} intent_tx_hash - The transaction hash of the intent order on the hub chain\n *\n * @returns {UseQueryResult<Result<SolverIntentStatusResponse, SolverErrorResponse> | undefined>} A query result object containing:\n * - data: The status result from the solver\n * - isLoading: Boolean indicating if the status is being fetched\n * - error: Error object if the status request failed\n * - refetch: Function to manually trigger a status refresh\n *\n * @example\n * ```typescript\n * const { data: status, isLoading } = useStatus('0x...');\n *\n * if (isLoading) return <div>Loading status...</div>;\n * if (status?.ok) {\n * console.log('Status:', status.value);\n * }\n * ```\n *\n * @remarks\n * - The status is automatically refreshed every 3 seconds\n * - Uses React Query for efficient caching and state management\n */\n\nexport const useStatus = (\n intent_tx_hash: Hex,\n): UseQueryResult<Result<SolverIntentStatusResponse, SolverErrorResponse> | undefined> => {\n const { sodax } = useSodaxContext();\n return useQuery({\n queryKey: [intent_tx_hash],\n queryFn: async () => {\n return sodax.solver.getStatus({ intent_tx_hash });\n },\n refetchInterval: 3000, // 3s\n });\n};\n","import { useQuery, type UseQueryResult } from '@tanstack/react-query';\nimport { useSodaxContext } from '../shared/useSodaxContext';\nimport type { CreateIntentParams, SpokeProvider } from '@sodax/sdk';\n\n/**\n * Hook for checking token allowance for money market operations.\n *\n * This hook verifies if the user has approved enough tokens for a specific money market action\n * (borrow/repay). It automatically queries and tracks the allowance status.\n *\n * @param {CreateIntentParams} params - The parameters for the intent to check allowance for.\n * @param {SpokeProvider} spokeProvider - The spoke provider to use for allowance checks\n *\n * @returns {UseQueryResult<boolean, Error>} A React Query result containing:\n * - data: Boolean indicating if allowance is sufficient\n * - isLoading: Loading state indicator\n * - error: Any error that occurred during the check\n *\n * @example\n * ```typescript\n * const { data: hasAllowed, isLoading } = useMMAllowance(params, spokeProvider);\n * ```\n */\nexport function useSwapAllowance(\n params: CreateIntentParams | undefined,\n spokeProvider: SpokeProvider | undefined,\n): UseQueryResult<boolean, Error> {\n const { sodax } = useSodaxContext();\n\n return useQuery({\n queryKey: ['allowance', params],\n queryFn: async () => {\n if (!spokeProvider || !params) {\n return false;\n }\n const allowance = await sodax.solver.isAllowanceValid({\n intentParams: params,\n spokeProvider,\n });\n if (allowance.ok) {\n return allowance.value;\n }\n return false;\n },\n enabled: !!spokeProvider && !!params,\n });\n}\n","import { useSodaxContext } from '../shared/useSodaxContext';\nimport { useMutation, useQueryClient } from '@tanstack/react-query';\nimport type { CreateIntentParams, SpokeProvider } from '@sodax/sdk';\n\ninterface UseApproveReturn {\n approve: ({ params }: { params: CreateIntentParams }) => Promise<boolean>;\n isLoading: boolean;\n error: Error | null;\n resetError: () => void;\n}\n\n/**\n * Hook for approving token spending for money market actions\n * @param token The token to approve spending for\n * @param spokeProvider The spoke provider instance for the chain\n * @returns Object containing approve function, loading state, error state and reset function\n * @example\n * ```tsx\n * const { approve, isLoading, error } = useApprove(token, spokeProvider);\n *\n * // Approve tokens for supply action\n * await approve({ amount: \"100\", action: \"supply\" });\n * ```\n */\n\nexport function useSwapApprove(\n params: CreateIntentParams | undefined,\n spokeProvider: SpokeProvider | undefined,\n): UseApproveReturn {\n const { sodax } = useSodaxContext();\n const queryClient = useQueryClient();\n\n const {\n mutateAsync: approve,\n isPending,\n error,\n reset: resetError,\n } = useMutation({\n mutationFn: async ({ params }: { params: CreateIntentParams | undefined }) => {\n if (!spokeProvider) {\n throw new Error('Spoke provider not found');\n }\n if (!params) {\n throw new Error('Swap Params not found');\n }\n\n const allowance = await sodax.solver.approve({\n intentParams: params,\n spokeProvider,\n });\n if (!allowance.ok) {\n throw new Error('Failed to approve input token');\n }\n return allowance.ok;\n },\n onSuccess: () => {\n // Invalidate allowance query to refetch the new allowance\n queryClient.invalidateQueries({ queryKey: ['allowance', params?.inputToken] });\n },\n });\n\n return {\n approve,\n isLoading: isPending,\n error: error,\n resetError,\n };\n}\n","import { useSodaxContext } from '../shared/useSodaxContext';\nimport type { Intent, Result, SpokeProvider, TxReturnType } from '@sodax/sdk';\nimport { useMutation, type UseMutationResult } from '@tanstack/react-query';\n\ntype CancelIntentParams = {\n intent: Intent;\n raw?: boolean;\n};\n\ntype CancelIntentResult = Result<TxReturnType<SpokeProvider, boolean>>;\n\n/**\n * Hook for canceling a swap intent order.\n * Uses React Query's useMutation for better state management and caching.\n *\n * @param {SpokeProvider} spokeProvider - The spoke provider to use for canceling the intent\n * @returns {UseMutationResult} Mutation result object containing mutation function and state\n *\n * @example\n * ```typescript\n * const { mutateAsync: cancelSwap, isPending } = useCancelSwap(spokeProvider);\n *\n * const handleCancelSwap = async () => {\n * const result = await cancelSwap({\n * intent: intentObject,\n * raw: false // optional, defaults to false\n * });\n * };\n * ```\n */\nexport function useCancelSwap(\n spokeProvider: SpokeProvider | undefined,\n): UseMutationResult<CancelIntentResult, Error, CancelIntentParams> {\n const { sodax } = useSodaxContext();\n\n return useMutation<CancelIntentResult, Error, CancelIntentParams>({\n mutationFn: async ({ intent, raw = false }: CancelIntentParams) => {\n if (!spokeProvider) {\n throw new Error('Spoke provider not found');\n }\n return sodax.solver.cancelIntent(intent, spokeProvider, raw);\n },\n });\n}\n","// packages/dapp-kit/src/hooks/backend/useIntentByTxHash.ts\nimport { useQuery, type UseQueryResult } from '@tanstack/react-query';\nimport type { IntentResponse } from '@sodax/sdk';\nimport { useSodaxContext } from '../shared/useSodaxContext';\n\n/**\n * Hook for fetching intent details by transaction hash from the backend API.\n *\n * This hook provides access to intent data associated with a specific transaction hash,\n * including intent details, events, and transaction information. The data is automatically\n * fetched and cached using React Query.\n *\n * @param {string | undefined} txHash - The transaction hash to fetch intent for. If undefined, the query will be disabled.\n *\n * @returns {UseQueryResult<IntentResponse | undefined>} A query result object containing:\n * - data: The intent response data when available\n * - isLoading: Boolean indicating if the request is in progress\n * - error: Error object if the request failed\n * - refetch: Function to manually trigger a data refresh\n *\n * @example\n * ```typescript\n * const { data: intent, isLoading, error } = useIntentByTxHash('0x123...');\n *\n * if (isLoading) return <div>Loading intent...</div>;\n * if (error) return <div>Error: {error.message}</div>;\n * if (intent) {\n * console.log('Intent found:', intent.intentHash);\n * }\n * ```\n *\n * @remarks\n * - The query is disabled when txHash is undefined or empty\n * - Uses React Query for efficient caching and state management\n * - Automatically handles error states and loading indicators\n */\nexport const useBackendIntentByTxHash = (txHash: string | undefined): UseQueryResult<IntentResponse | undefined> => {\n const { sodax } = useSodaxContext();\n\n return useQuery({\n queryKey: ['backend', 'intent', 'txHash', txHash],\n queryFn: async (): Promise<IntentResponse | undefined> => {\n if (!txHash) {\n return undefined;\n }\n\n return sodax.backendApiService.getIntentByTxHash(txHash);\n },\n enabled: !!txHash && txHash.length > 0,\n retry: 3,\n });\n};\n","// packages/dapp-kit/src/hooks/backend/useIntentByHash.ts\nimport { useQuery, type UseQueryResult } from '@tanstack/react-query';\nimport type { IntentResponse } from '@sodax/sdk';\nimport { useSodaxContext } from '../shared/useSodaxContext';\n\n/**\n * Hook for fetching intent details by intent hash from the backend API.\n *\n * This hook provides access to intent data using the intent hash directly,\n * including intent details, events, and transaction information. The data is automatically\n * fetched and cached using React Query.\n *\n * @param {string | undefined} intentHash - The intent hash to fetch intent for. If undefined, the query will be disabled.\n *\n * @returns {UseQueryResult<IntentResponse | undefined>} A query result object containing:\n * - data: The intent response data when available\n * - isLoading: Boolean indicating if the request is in progress\n * - error: Error object if the request failed\n * - refetch: Function to manually trigger a data refresh\n *\n * @example\n * ```typescript\n * const { data: intent, isLoading, error } = useIntentByHash('0xabc...');\n *\n * if (isLoading) return <div>Loading intent...</div>;\n * if (error) return <div>Error: {error.message}</div>;\n * if (intent) {\n * console.log('Intent found:', intent.intentHash);\n * console.log('Open status:', intent.open);\n * }\n * ```\n *\n * @remarks\n * - The query is disabled when intentHash is undefined or empty\n * - Uses React Query for efficient caching and state management\n * - Automatically handles error states and loading indicators\n */\nexport const useBackendIntentByHash = (intentHash: string | undefined): UseQueryResult<IntentResponse | undefined> => {\n const { sodax } = useSodaxContext();\n\n return useQuery({\n queryKey: ['backend', 'intent', 'hash', intentHash],\n queryFn: async (): Promise<IntentResponse | undefined> => {\n if (!intentHash) {\n return undefined;\n }\n\n return sodax.backendApiService.getIntentByHash(intentHash);\n },\n enabled: !!intentHash && intentHash.length > 0,\n retry: 3,\n });\n};\n","// packages/dapp-kit/src/hooks/backend/useOrderbook.ts\nimport { useQuery, type UseQueryResult } from '@tanstack/react-query';\nimport type { OrderbookResponse } from '@sodax/sdk';\nimport { useSodaxContext } from '../shared/useSodaxContext';\n\n/**\n * Hook for fetching the solver orderbook from the backend API.\n *\n * This hook provides access to the solver orderbook data, including intent states\n * and intent data for all available intents. The data is automatically fetched\n * and cached using React Query with pagination support.\n *\n * @param {Object} params - Pagination parameters for the orderbook\n * @param {string} params.offset - The offset for pagination (number as string)\n * @param {string} params.limit - The limit for pagination (number as string)\n *\n * @returns {UseQueryResult<OrderbookResponse | undefined>} A query result object containing:\n * - data: The orderbook response data when available\n * - isLoading: Boolean indicating if the request is in progress\n * - error: Error object if the request failed\n * - refetch: Function to manually trigger a data refresh\n *\n * @example\n * ```typescript\n * const { data: orderbook, isLoading, error } = useOrderbook({\n * offset: '0',\n * limit: '10'\n * });\n *\n * if (isLoading) return <div>Loading orderbook...</div>;\n * if (error) return <div>Error: {error.message}</div>;\n * if (orderbook) {\n * console.log('Total intents:', orderbook.total);\n * console.log('Intents:', orderbook.data);\n * }\n * ```\n *\n * @remarks\n * - The query is disabled when params are undefined or invalid\n * - Uses React Query for efficient caching and state management\n * - Automatically handles error states and loading indicators\n * - Stale time of 30 seconds for real-time orderbook data\n * - Supports pagination through offset and limit parameters\n */\nexport const useBackendOrderbook = (\n params: { offset: string; limit: string } | undefined,\n): UseQueryResult<OrderbookResponse | undefined> => {\n const { sodax } = useSodaxContext();\n\n return useQuery({\n queryKey: ['backend', 'solver', 'orderbook', params],\n queryFn: async (): Promise<OrderbookResponse | undefined> => {\n if (!params || !params.offset || !params.limit) {\n return undefined;\n }\n\n return sodax.backendApiService.getOrderbook(params);\n },\n enabled: !!params && !!params.offset && !!params.limit,\n staleTime: 30 * 1000, // 30 seconds for real-time data\n retry: 3,\n });\n};\n","// packages/dapp-kit/src/hooks/backend/useMoneyMarketPosition.ts\nimport { useQuery, type UseQueryResult } from '@tanstack/react-query';\nimport type { MoneyMarketPosition } from '@sodax/sdk';\nimport { useSodaxContext } from '../shared/useSodaxContext';\n\n/**\n * Hook for fetching money market position for a specific user from the backend API.\n *\n * This hook provides access to a user's money market positions, including their\n * aToken balances, variable debt token balances, and associated reserve information.\n * The data is automatically fetched and cached using React Query.\n *\n * @param {string | undefined} userAddress - The user's wallet address. If undefined, the query will be disabled.\n *\n * @returns {UseQueryResult<MoneyMarketPosition | undefined>} A query result object containing:\n * - data: The money market position data when available\n * - isLoading: Boolean indicating if the request is in progress\n * - error: Error object if the request failed\n * - refetch: Function to manually trigger a data refresh\n *\n * @example\n * ```typescript\n * const { data: position, isLoading, error } = useMoneyMarketPosition('0x123...');\n *\n * if (isLoading) return <div>Loading position...</div>;\n * if (error) return <div>Error: {error.message}</div>;\n * if (position) {\n * console.log('User address:', position.userAddress);\n * console.log('Positions:', position.positions);\n * }\n * ```\n *\n * @remarks\n * - The query is disabled when userAddress is undefined or empty\n * - Uses React Query for efficient caching and state management\n * - Automatically handles error states and loading indicators\n * - Includes user's aToken and debt token balances across all reserves\n */\nexport const useBackendMoneyMarketPosition = (\n userAddress: string | undefined,\n): UseQueryResult<MoneyMarketPosition | undefined> => {\n const { sodax } = useSodaxContext();\n\n return useQuery({\n queryKey: ['backend', 'moneymarket', 'position', userAddress],\n queryFn: async (): Promise<MoneyMarketPosition | undefined> => {\n if (!userAddress) {\n return undefined;\n }\n\n return sodax.backendApiService.getMoneyMarketPosition(userAddress);\n },\n enabled: !!userAddress && userAddress.length > 0,\n retry: 3,\n });\n};\n","// packages/dapp-kit/src/hooks/backend/useAllMoneyMarketAssets.ts\nimport { useQuery, type UseQueryResult } from '@tanstack/react-query';\nimport type { MoneyMarketAsset } from '@sodax/sdk';\nimport { useSodaxContext } from '../shared/useSodaxContext';\n\n/**\n * Hook for fetching all money market assets from the backend API.\n *\n * This hook provides access to all available money market assets, including\n * their reserve information, liquidity rates, borrow rates, and market statistics.\n * The data is automatically fetched and cached using React Query.\n *\n * @returns {UseQueryResult<MoneyMarketAsset[]>} A query result object containing:\n * - data: Array of money market asset data when available\n * - isLoading: Boolean indicating if the request is in progress\n * - error: Error object if the request failed\n * - refetch: Function to manually trigger a data refresh\n *\n * @example\n * ```typescript\n * const { data: assets, isLoading, error } = useAllMoneyMarketAssets();\n *\n * if (isLoading) return <div>Loading assets...</div>;\n * if (error) return <div>Error: {error.message}</div>;\n * if (assets) {\n * console.log('Total assets:', assets.length);\n * assets.forEach(asset => {\n * console.log(`${asset.symbol}: ${asset.liquidityRate} liquidity rate`);\n * });\n * }\n * ```\n *\n * @remarks\n * - Uses React Query for efficient caching and state management\n * - Automatically handles error states and loading indicators\n * - Returns comprehensive asset information including rates and statistics\n * - No parameters required - fetches all available assets\n */\nexport const useBackendAllMoneyMarketAssets = (): UseQueryResult<MoneyMarketAsset[]> => {\n const { sodax } = useSodaxContext();\n\n return useQuery({\n queryKey: ['backend', 'moneymarket', 'assets', 'all'],\n queryFn: async (): Promise<MoneyMarketAsset[]> => {\n return sodax.backendApiService.getAllMoneyMarketAssets();\n },\n retry: 3,\n });\n};\n","// packages/dapp-kit/src/hooks/backend/useMoneyMarketAsset.ts\nimport { useQuery, type UseQueryResult } from '@tanstack/react-query';\nimport type { MoneyMarketAsset } from '@sodax/sdk';\nimport { useSodaxContext } from '../shared/useSodaxContext';\n\n/**\n * Hook for fetching specific money market asset details from the backend API.\n *\n * This hook provides access to detailed information for a specific money market asset,\n * including reserve information, liquidity rates, borrow rates, and market statistics.\n * The data is automatically fetched and cached using React Query.\n *\n * @param {string | undefined} reserveAddress - The reserve contract address. If undefined, the query will be disabled.\n *\n * @returns {UseQueryResult<MoneyMarketAsset | undefined>} A query result object containing:\n * - data: The money market asset data when available\n * - isLoading: Boolean indicating if the request is in progress\n * - error: Error object if the request failed\n * - refetch: Function to manually trigger a data refresh\n *\n * @example\n * ```typescript\n * const { data: asset, isLoading, error } = useMoneyMarketAsset('0xabc...');\n *\n * if (isLoading) return <div>Loading asset...</div>;\n * if (error) return <div>Error: {error.message}</div>;\n * if (asset) {\n * console.log('Asset symbol:', asset.symbol);\n * console.log('Liquidity rate:', asset.liquidityRate);\n * console.log('Variable borrow rate:', asset.variableBorrowRate);\n * }\n * ```\n *\n * @remarks\n * - The query is disabled when reserveAddress is undefined or empty\n * - Uses React Query for efficient caching and state management\n * - Automatically handles error states and loading indicators\n * - Returns comprehensive asset information for the specified reserve\n */\nexport const useBackendMoneyMarketAsset = (\n reserveAddress: string | undefined,\n): UseQueryResult<MoneyMarketAsset | undefined> => {\n const { sodax } = useSodaxContext();\n\n return useQuery({\n queryKey: ['backend', 'moneymarket', 'asset', reserveAddress],\n queryFn: async (): Promise<MoneyMarketAsset | undefined> => {\n if (!reserveAddress) {\n return undefined;\n }\n\n return sodax.backendApiService.getMoneyMarketAsset(reserveAddress);\n },\n enabled: !!reserveAddress && reserveAddress.length > 0,\n retry: 3,\n });\n};\n","// packages/dapp-kit/src/hooks/backend/useMoneyMarketAssetBorrowers.ts\nimport { useQuery, type UseQueryResult } from '@tanstack/react-query';\nimport type { MoneyMarketAssetBorrowers } from '@sodax/sdk';\nimport { useSodaxContext } from '../shared/useSodaxContext';\n\n/**\n * Hook for fetching borrowers for a specific money market asset from the backend API.\n *\n * This hook provides access to the list of borrowers for a specific money market asset,\n * with pagination support. The data is automatically fetched and cached using React Query.\n *\n * @param {Object} params - Parameters for fetching asset borrowers\n * @param {string | undefined} params.reserveAddress - The reserve contract address. If undefined, the query will be disabled.\n * @param {string} params.offset - The offset for pagination (number as string)\n * @param {string} params.limit - The limit for pagination (number as string)\n *\n * @returns {UseQueryResult<MoneyMarketAssetBorrowers | undefined>} A query result object containing:\n * - data: The asset borrowers data when available\n * - isLoading: Boolean indicating if the request is in progress\n * - error: Error object if the request failed\n * - refetch: Function to manually trigger a data refresh\n *\n * @example\n * ```typescript\n * const { data: borrowers, isLoading, error } = useMoneyMarketAssetBorrowers({\n * reserveAddress: '0xabc...',\n * offset: '0',\n * limit: '20'\n * });\n *\n * if (isLoading) return <div>Loading borrowers...</div>;\n * if (error) return <div>Error: {error.message}</div>;\n * if (borrowers) {\n * console.log('Total borrowers:', borrowers.total);\n * console.log('Borrowers:', borrowers.borrowers);\n * }\n * ```\n *\n * @remarks\n * - The query is disabled when reserveAddress is undefined or empty\n * - Uses React Query for efficient caching and state management\n * - Automatically handles error states and loading indicators\n * - Supports pagination through offset and limit parameters\n */\nexport const useBackendMoneyMarketAssetBorrowers = (params: {\n reserveAddress: string | undefined;\n offset: string;\n limit: string;\n}): UseQueryResult<MoneyMarketAssetBorrowers | undefined> => {\n const { sodax } = useSodaxContext();\n\n return useQuery({\n queryKey: ['backend', 'moneymarket', 'asset', 'borrowers', params],\n queryFn: async (): Promise<MoneyMarketAssetBorrowers | undefined> => {\n if (!params.reserveAddress || !params.offset || !params.limit) {\n return undefined;\n }\n\n return sodax.backendApiService.getMoneyMarketAssetBorrowers(params.reserveAddress, {\n offset: params.offset,\n limit: params.limit,\n });\n },\n enabled: !!params.reserveAddress && !!params.offset && !!params.limit,\n retry: 3,\n });\n};\n","// packages/dapp-kit/src/hooks/backend/useMoneyMarketAssetSuppliers.ts\nimport { useQuery, type UseQueryResult } from '@tanstack/react-query';\nimport type { MoneyMarketAssetSuppliers } from '@sodax/sdk';\nimport { useSodaxContext } from '../shared/useSodaxContext';\n\n/**\n * Hook for fetching suppliers for a specific money market asset from the backend API.\n *\n * This hook provides access to the list of suppliers for a specific money market asset,\n * with pagination support. The data is automatically fetched and cached using React Query.\n *\n * @param {Object} params - Parameters for fetching asset suppliers\n * @param {string | undefined} params.reserveAddress - The reserve contract address. If undefined, the query will be disabled.\n * @param {string} params.offset - The offset for pagination (number as string)\n * @param {string} params.limit - The limit for pagination (number as string)\n *\n * @returns {UseQueryResult<MoneyMarketAssetSuppliers | undefined>} A query result object containing:\n * - data: The asset suppliers data when available\n * - isLoading: Boolean indicating if the request is in progress\n * - error: Error object if the request failed\n * - refetch: Function to manually trigger a data refresh\n *\n * @example\n * ```typescript\n * const { data: suppliers, isLoading, error } = useMoneyMarketAssetSuppliers({\n * reserveAddress: '0xabc...',\n * offset: '0',\n * limit: '20'\n * });\n *\n * if (isLoading) return <div>Loading suppliers...</div>;\n * if (error) return <div>Error: {error.message}</div>;\n * if (suppliers) {\n * console.log('Total suppliers:', suppliers.total);\n * console.log('Suppliers:', suppliers.suppliers);\n * }\n * ```\n *\n * @remarks\n * - The query is disabled when reserveAddress is undefined or empty\n * - Uses React Query for efficient caching and state management\n * - Automatically handles error states and loading indicators\n * - Supports pagination through offset and limit parameters\n */\nexport const useBackendMoneyMarketAssetSuppliers = (params: {\n reserveAddress: string | undefined;\n offset: string;\n limit: string;\n}): UseQueryResult<MoneyMarketAssetSuppliers | undefined> => {\n const { sodax } = useSodaxContext();\n\n return useQuery({\n queryKey: ['backend', 'moneymarket', 'asset', 'suppliers', params],\n queryFn: async (): Promise<MoneyMarketAssetSuppliers | undefined> => {\n if (!params.reserveAddress || !params.offset || !params.limit) {\n return undefined;\n }\n\n return sodax.backendApiService.getMoneyMarketAssetSuppliers(params.reserveAddress, {\n offset: params.offset,\n limit: params.limit,\n });\n },\n enabled: !!params.reserveAddress && !!params.offset && !!params.limit,\n retry: 3,\n });\n};\n","// packages/dapp-kit/src/hooks/backend/useAllMoneyMarketBorrowers.ts\nimport { useQuery, type UseQueryResult } from '@tanstack/react-query';\nimport type { MoneyMarketBorrowers } from '@sodax/sdk';\nimport { useSodaxContext } from '../shared/useSodaxContext';\n\n/**\n * Hook for fetching all money market borrowers from the backend API.\n *\n * This hook provides access to the list of all borrowers across all money market assets,\n * with pagination support. The data is automatically fetched and cached using React Query.\n *\n * @param {Object} params - Pagination parameters for fetching all borrowers\n * @param {string} params.offset - The offset for pagination (number as string)\n * @param {string} params.limit - The limit for pagination (number as string)\n *\n * @returns {UseQueryResult<MoneyMarketBorrowers | undefined>} A query result object containing:\n * - data: The all borrowers data when available\n * - isLoading: Boolean indicating if the request is in progress\n * - error: Error object if the request failed\n * - refetch: Function to manually trigger a data refresh\n *\n * @example\n * ```typescript\n * const { data: borrowers, isLoading, error } = useAllMoneyMarketBorrowers({\n * offset: '0',\n * limit: '50'\n * });\n *\n * if (isLoading) return <div>Loading borrowers...</div>;\n * if (error) return <div>Error: {error.message}</div>;\n * if (borrowers) {\n * console.log('Total borrowers:', borrowers.total);\n * console.log('Borrowers:', borrowers.borrowers);\n * }\n * ```\n *\n * @remarks\n * - The query is disabled when params are undefined or invalid\n * - Uses React Query for efficient caching and state management\n * - Automatically handles error states and loading indicators\n * - Supports pagination through offset and limit parameters\n * - Returns borrowers across all money market assets\n */\nexport const useBackendAllMoneyMarketBorrowers = (\n params: { offset: string; limit: string } | undefined,\n): UseQueryResult<MoneyMarketBorrowers | undefined> => {\n const { sodax } = useSodaxContext();\n\n return useQuery({\n queryKey: ['backend', 'moneymarket', 'borrowers', 'all', params],\n queryFn: async (): Promise<MoneyMarketBorrowers | undefined> => {\n if (!params || !params.offset || !params.limit) {\n return undefined;\n }\n\n return sodax.backendApiService.getAllMoneyMarketBorrowers(params);\n },\n enabled: !!params && !!params.offset && !!params.limit,\n retry: 3,\n });\n};\n","import { useQuery, type UseQueryResult } from '@tanstack/react-query';\nimport { useSodaxContext } from '../shared/useSodaxContext';\nimport type { SpokeProvider, CreateBridgeIntentParams } from '@sodax/sdk';\n\n/**\n * Hook for checking token allowance for bridge operations.\n *\n * This hook verifies if the user has approved enough tokens for a specific bridge action.\n * It automatically queries and tracks the allowance status.\n *\n * @param {BridgeParams} params - The parameters for the bridge to check allowance for.\n * @param {SpokeProvider} spokeProvider - The spoke provider to use for allowance checks\n *\n * @returns {UseQueryResult<boolean, Error>} A React Query result containing:\n * - data: Boolean indicating if allowance is sufficient\n * - isLoading: Loading state indicator\n * - error: Any error that occurred during the check\n *\n * @example\n * ```typescript\n * const { data: hasAllowed, isLoading } = useBridgeAllowance(params, spokeProvider);\n * ```\n */\nexport function useBridgeAllowance(\n params: CreateBridgeIntentParams | undefined,\n spokeProvider: SpokeProvider | undefined,\n): UseQueryResult<boolean, Error> {\n const { sodax } = useSodaxContext();\n\n return useQuery({\n queryKey: ['bridge-allowance', params],\n queryFn: async () => {\n if (!spokeProvider || !params) {\n return false;\n }\n\n const allowance = await sodax.bridge.isAllowanceValid({\n params,\n spokeProvider,\n });\n\n if (allowance.ok) {\n return allowance.value;\n }\n return false;\n },\n enabled: !!spokeProvider && !!params,\n });\n}\n","import { useSodaxContext } from '../shared/useSodaxContext';\nimport type { CreateBridgeIntentParams, SpokeProvider } from '@sodax/sdk';\nimport { useMutation, useQueryClient } from '@tanstack/react-query';\n\ninterface UseBridgeApproveReturn {\n approve: (params: CreateBridgeIntentParams) => Promise<boolean>;\n isLoading: boolean;\n error: Error | null;\n resetError: () => void;\n}\n\n/**\n * Hook for approving token spending for bridge actions\n * @param spokeProvider The spoke provider instance for the chain\n * @returns Object containing approve function, loading state, error state and reset function\n * @example\n * ```tsx\n * const { approve, isLoading, error } = useBridgeApprove(spokeProvider);\n *\n * // Approve tokens for bridge action\n * await approve({\n * srcChainId: '0x2105.base',\n * srcAsset: '0x...',\n * amount: 1000n,\n * dstChainId: '0x89.polygon',\n * dstAsset: '0x...',\n * recipient: '0x...'\n * });\n * ```\n */\nexport function useBridgeApprove(spokeProvider: SpokeProvider | undefined): UseBridgeApproveReturn {\n const { sodax } = useSodaxContext();\n const queryClient = useQueryClient();\n\n const {\n mutateAsync: approve,\n isPending,\n error,\n reset: resetError,\n } = useMutation({\n mutationFn: async (params: CreateBridgeIntentParams) => {\n if (!spokeProvider) {\n throw new Error('Spoke provider not found');\n }\n\n const allowance = await sodax.bridge.approve({\n params,\n spokeProvider,\n });\n\n if (!allowance.ok) {\n throw new Error('Failed to approve tokens for bridge');\n }\n return true;\n },\n onSuccess: (_, params) => {\n // Invalidate allowance query to refetch the new allowance\n queryClient.invalidateQueries({ queryKey: ['bridge-allowance', params] });\n },\n });\n\n return {\n approve,\n isLoading: isPending,\n error: error,\n resetError,\n };\n}\n","import { useSodaxContext } from '../shared/useSodaxContext';\nimport type { BridgeError, BridgeErrorCode, SpokeTxHash, HubTxHash, Result, CreateBridgeIntentParams } from '@sodax/sdk';\nimport { useMutation, type UseMutationResult } from '@tanstack/react-query';\nimport type { SpokeProvider } from '@sodax/sdk';\n\n/**\n * Hook for executing bridge transactions to transfer tokens between chains.\n * Uses React Query's useMutation for better state management and caching.\n *\n * @param {SpokeProvider} spokeProvider - The spoke provider to use for the bridge\n * @returns {UseMutationResult} Mutation result object containing mutation function and state\n *\n * @example\n * ```typescript\n * const { mutateAsync: bridge, isPending } = useBridge(spokeProvider);\n *\n * const handleBridge = async () => {\n * const result = await bridge({\n * srcChainId: '0x2105.base',\n * srcAsset: '0x...',\n * amount: 1000n,\n * dstChainId: '0x89.polygon',\n * dstAsset: '0x...',\n * recipient: '0x...'\n * });\n *\n * console.log('Bridge transaction hashes:', {\n * spokeTxHash: result.spokeTxHash,\n * hubTxHash: result.hubTxHash\n * });\n * };\n * ```\n */\nexport function useBridge(\n spokeProvider: SpokeProvider | undefined,\n): UseMutationResult<Result<[SpokeTxHash, HubTxHash], BridgeError<BridgeErrorCode>>, Error, CreateBridgeIntentParams> {\n const { sodax } = useSodaxContext();\n\n return useMutation<Result<[SpokeTxHash, HubTxHash], BridgeError<BridgeErrorCode>>, Error, CreateBridgeIntentParams>({\n mutationFn: async (params: CreateBridgeIntentParams) => {\n if (!spokeProvider) {\n throw new Error('Spoke provider not found');\n }\n\n const result = await sodax.bridge.bridge({\n params,\n spokeProvider,\n });\n\n if (!result.ok) {\n throw new Error(`Bridge failed: ${result.error.code}`);\n }\n\n return result;\n },\n });\n}\n","import { useQuery, type UseQueryResult } from '@tanstack/react-query';\nimport { useSodaxContext } from '../shared/useSodaxContext';\nimport type { Result, SpokeChainId, XToken } from '@sodax/sdk';\n\n/**\n * Hook for getting the amount available to be bridged.\n *\n * This hook is used to check if a target chain has enough balance to bridge when bridging.\n * It automatically queries and tracks the available amount to be bridged.\n *\n * @param {SpokeChainId | undefined} chainId - The chain ID to get the balance for\n * @param {string | undefined} token - The token address to get the balance for\n *\n * @returns {UseQueryResult<bigint, Error>} A React Query result containing:\n * - data: The available amount to be bridged (bigint)\n * - error: Any error that occurred during the check\n *\n * @example\n * ```typescript\n * const { data: balance, isLoading } = useSpokeAssetManagerTokenBalance(chainId, tokenAddress);\n *\n * if (balance) {\n * console.log('Asset manager token balance:', balance.toString());\n * }\n * ```\n */\nexport function useGetBridgeableAmount(\n from: XToken | undefined,\n to: XToken | undefined,\n): UseQueryResult<bigint, Error> {\n const { sodax } = useSodaxContext();\n\n return useQuery({\n queryKey: ['spoke-asset-manager-token-balance', from, to],\n queryFn: async () => {\n if (!from || !to) {\n return 0n;\n }\n\n const result = await sodax.bridge.getBridgeableAmount(from, to);\n if (result.ok) {\n return result.value;\n }\n\n console.error('Error getting bridgeable amount:', result.error);\n return 0n;\n },\n enabled: !!from && !!to,\n });\n}\n","import { useQuery, type UseQueryResult } from '@tanstack/react-query';\nimport type { XToken, SpokeChainId } from '@sodax/sdk';\nimport { useSodaxContext } from '../shared';\n\n/**\n/**\n * Hook for retrieving all bridgeable tokens from a source token on one chain to a destination chain.\n *\n * This hook queries and tracks the set of tokens on the destination chain that can be bridged to,\n * given a source chain, destination chain, and source token address.\n *\n * @param {SpokeChainId | undefined} from - The source chain ID\n * @param {SpokeChainId | undefined} to - The destination chain ID\n * @param {string | undefined} token - The source token address\n *\n * @returns {UseQueryResult<XToken[], Error>} A React Query result containing:\n * - data: Array of bridgeable tokens (XToken[]) on the destination chain\n * - error: Any error that occurred during the query\n *\n *\n * @example\n * ```typescript\n * const { data: bridgeableTokens, isLoading } = useGetBridgeableTokens(\n * fromChainId,\n * toChainId,\n * fromTokenAddress\n * );\n *\n * if (bridgeableTokens && bridgeableTokens.length > 0) {\n * bridgeableTokens.forEach(token => {\n * console.log(`Bridgeable token: ${token.symbol} (${token.address}) on chain ${token.xChainId}`);\n * });\n * } else {\n * console.log('No bridgeable tokens found for the selected route.');\n * }\n * ```\n */\nexport function useGetBridgeableTokens(\n from: SpokeChainId | undefined,\n to: SpokeChainId | undefined,\n token: string | undefined,\n): UseQueryResult<XToken[], Error> {\n const { sodax } = useSodaxContext();\n\n return useQuery({\n queryKey: ['bridgeable-tokens', from, to, token],\n queryFn: async () => {\n if (!from || !to || !token) {\n return [];\n }\n\n const result = sodax.bridge.getBridgeableTokens(from, to, token);\n if (result.ok) {\n return result.value;\n }\n\n console.error('Error getting bridgeable tokens:', result.error);\n return [];\n },\n enabled: !!from && !!to && !!token,\n });\n}\n","import type { ReactNode, ReactElement } from 'react';\nimport React from 'react';\n\nimport { Sodax, type SodaxConfig } from '@sodax/sdk';\nimport { SodaxContext } from '@/contexts';\nimport type { RpcConfig } from '@/types';\n\ninterface SodaxProviderProps {\n children: ReactNode;\n testnet?: boolean;\n config?: SodaxConfig;\n rpcConfig: RpcConfig;\n}\n\nexport const SodaxProvider = ({ children, testnet = false, config, rpcConfig }: SodaxProviderProps): ReactElement => {\n const sodax = new Sodax(config);\n\n return <SodaxContext.Provider value={{ sodax, testnet, rpcConfig }}>{children}</SodaxContext.Provider>;\n};\n","import type { ChainId } from '@sodax/types';\n\nimport { hubAssets } from '@sodax/sdk';\n\nexport const getSpokeTokenAddressByVault = (spokeChainId: ChainId, vault: string) => {\n const tokens = hubAssets[spokeChainId];\n const address = Object.keys(tokens).find(\n tokenAddress => tokens[tokenAddress].vault.toLowerCase() === vault.toLowerCase(),\n );\n\n return address;\n};\n"]}
|
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/contexts/index.ts","../src/hooks/shared/useSodaxContext.ts","../src/hooks/shared/useEstimateGas.ts","../src/hooks/shared/useDeriveUserWalletAddress.ts","../src/hooks/provider/useHubProvider.ts","../src/hooks/provider/useSpokeProvider.ts","../src/hooks/mm/useBorrow.ts","../src/hooks/mm/useRepay.ts","../src/hooks/mm/useSupply.ts","../src/hooks/mm/useWithdraw.ts","../src/hooks/mm/useUserReservesData.ts","../src/hooks/mm/useReservesData.ts","../src/hooks/mm/useMMAllowance.ts","../src/hooks/mm/useMMApprove.ts","../src/hooks/swap/useQuote.ts","../src/hooks/swap/useSwap.ts","../src/hooks/swap/useStatus.ts","../src/hooks/swap/useSwapAllowance.ts","../src/hooks/swap/useSwapApprove.ts","../src/hooks/swap/useCancelSwap.ts","../src/hooks/backend/useBackendIntentByTxHash.ts","../src/hooks/backend/useBackendIntentByHash.ts","../src/hooks/backend/useBackendOrderbook.ts","../src/hooks/backend/useBackendMoneyMarketPosition.ts","../src/hooks/backend/useBackendAllMoneyMarketAssets.ts","../src/hooks/backend/useBackendMoneyMarketAsset.ts","../src/hooks/backend/useBackendMoneyMarketAssetBorrowers.ts","../src/hooks/backend/useBackendMoneyMarketAssetSuppliers.ts","../src/hooks/backend/useBackendAllMoneyMarketBorrowers.ts","../src/hooks/bridge/useBridgeAllowance.ts","../src/hooks/bridge/useBridgeApprove.ts","../src/hooks/bridge/useBridge.ts","../src/hooks/bridge/useGetBridgeableAmount.ts","../src/hooks/bridge/useGetBridgeableTokens.ts","../src/providers/SodaxProvider.tsx","../src/core/index.ts"],"names":["useMutation","parseUnits","useQuery","useQueryClient","params"],"mappings":";;;;;;AAUO,IAAM,YAAA,GAAe,cAAuC,IAAI,CAAA;ACDhE,IAAM,kBAAkB,MAAwB;AACrD,EAAM,MAAA,OAAA,GAAU,WAAW,YAAY,CAAA;AACvC,EAAA,IAAI,CAAC,OAAS,EAAA;AACZ,IAAM,MAAA,IAAI,MAAM,qDAAqD,CAAA;AAAA;AAEvE,EAAO,OAAA,OAAA;AACT;ACZO,SAAS,eACd,aAC8E,EAAA;AAC9E,EAAA,OAAO,WAAuE,CAAA;AAAA,IAC5E,UAAA,EAAY,OAAO,KAAiC,KAAA;AAClD,MAAA,IAAI,CAAC,aAAe,EAAA;AAClB,QAAM,MAAA,IAAI,MAAM,4BAA4B,CAAA;AAAA;AAG9C,MAAA,MAAM,QAAW,GAAA,MAAM,YAAa,CAAA,WAAA,CAAY,OAAO,aAAa,CAAA;AAEpE,MAAO,OAAA,QAAA;AAAA;AACT,GAC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AU,EAAA,EAAA,EAAI,QAAS,CAAA;AAChF;ACda,IAAA,2BAAA,GAA8B,CAAC,YAAA,EAAuB,KAAkB,KAAA;AACnF,EAAM,MAAA,MAAA,GAAS,UAAU,YAAY,CAAA;AACrC,EAAA,MAAM,OAAU,GAAA,MAAA,CAAO,IAAK,CAAA,MAAM,CAAE,CAAA,IAAA;AAAA,IAClC,CAAA,YAAA,KAAgB,OAAO,YAAY,CAAA,CAAE,MAAM,WAAY,EAAA,KAAM,MAAM,WAAY;AAAA,GACjF;AAEA,EAAO,OAAA,OAAA;AACT","file":"index.mjs","sourcesContent":["import { createContext } from 'react';\nimport type { Sodax } from '@sodax/sdk';\nimport type { RpcConfig } from '@/types';\n\nexport interface SodaxContextType {\n sodax: Sodax;\n testnet: boolean;\n rpcConfig: RpcConfig;\n}\n\nexport const SodaxContext = createContext<SodaxContextType | null>(null);\n","import { SodaxContext, type SodaxContextType } from '@/contexts';\nimport { useContext } from 'react';\n\n/**\n * Hook to access the Sodax context which provides access to the Sodax SDK instance and chain configuration\n * @throws {Error} If used outside of a SodaxProvider\n * @returns {SodaxContextType} The Sodax context containing SDK instance and configuration\n */\n\nexport const useSodaxContext = (): SodaxContextType => {\n const context = useContext(SodaxContext);\n if (!context) {\n throw new Error('useSodaxContext must be used within a SodaxProvider');\n }\n return context;\n};\n","import { type GetEstimateGasReturnType, type SpokeProvider, SpokeService, type TxReturnType } from '@sodax/sdk';\nimport { useMutation, type UseMutationResult } from '@tanstack/react-query';\n\nexport function useEstimateGas<T extends SpokeProvider = SpokeProvider>(\n spokeProvider: T | undefined,\n): UseMutationResult<GetEstimateGasReturnType<T>, Error, TxReturnType<T, true>> {\n return useMutation<GetEstimateGasReturnType<T>, Error, TxReturnType<T, true>>({\n mutationFn: async (rawTx: TxReturnType<T, true>) => {\n if (!spokeProvider) {\n throw new Error('spokeProvider is not found');\n }\n\n const response = await SpokeService.estimateGas(rawTx, spokeProvider);\n\n return response;\n },\n });\n}\n","// packages/dapp-kit/src/hooks/shared/useDeriveUserWalletAddress.ts\nimport { deriveUserWalletAddress, type SpokeProvider, type EvmHubProvider } from '@sodax/sdk';\nimport { useQuery, type UseQueryResult } from '@tanstack/react-query';\nimport { useSodaxContext } from './useSodaxContext';\nimport type { Address } from 'viem';\n\n/**\n * Hook for deriving user wallet address for hub abstraction.\n *\n * This hook derives the user's abstracted wallet address for the hub chain.\n * If the spoke chain is the same as the hub chain, it returns the original wallet address.\n * Otherwise, it returns the abstracted wallet address for cross-chain operations.\n *\n * @param spokeProvider - The spoke provider instance for the origin chain\n * @param walletAddress - Optional user wallet address on spoke chain. If not provided, will fetch from spokeProvider\n * @returns A React Query result object containing:\n * - data: The derived user wallet address when available\n * - isLoading: Loading state indicator\n * - error: Any error that occurred during derivation\n *\n * @example\n * ```typescript\n * const { data: derivedAddress, isLoading, error } = useDeriveUserWalletAddress(spokeProvider, userAddress);\n * ```\n */\nexport function useDeriveUserWalletAddress(\n spokeProvider: SpokeProvider | undefined,\n walletAddress?: string | undefined,\n): UseQueryResult<Address, Error> {\n const { sodax } = useSodaxContext();\n\n return useQuery({\n queryKey: ['deriveUserWalletAddress', spokeProvider?.chainConfig.chain.id, walletAddress],\n queryFn: async (): Promise<Address> => {\n if (!spokeProvider) {\n throw new Error('Spoke provider is required');\n }\n\n return await deriveUserWalletAddress(spokeProvider, sodax.hubProvider, walletAddress);\n },\n enabled: !!spokeProvider,\n refetchInterval: false, // This is a deterministic operation, no need to refetch\n });\n}\n","import type { EvmHubProvider } from '@sodax/sdk';\nimport { useSodaxContext } from '../shared/useSodaxContext';\n\nexport function useHubProvider(): EvmHubProvider {\n const { sodax } = useSodaxContext();\n\n return sodax.hubProvider;\n}\n","import { useSodaxContext } from '@/index';\nimport {\n EvmSpokeProvider,\n spokeChainConfig,\n type SuiSpokeChainConfig,\n SuiSpokeProvider,\n type EvmSpokeChainConfig,\n IconSpokeProvider,\n type IconSpokeChainConfig,\n InjectiveSpokeProvider,\n type InjectiveSpokeChainConfig,\n StellarSpokeProvider,\n type StellarSpokeChainConfig,\n type SpokeProvider,\n type IWalletProvider,\n SolanaSpokeProvider,\n type SolanaChainConfig,\n SONIC_MAINNET_CHAIN_ID,\n SonicSpokeProvider,\n type SonicSpokeChainConfig,\n} from '@sodax/sdk';\nimport type {\n IEvmWalletProvider,\n IIconWalletProvider,\n ISuiWalletProvider,\n SpokeChainId,\n IInjectiveWalletProvider,\n IStellarWalletProvider,\n ISolanaWalletProvider,\n} from '@sodax/types';\nimport { useMemo } from 'react';\n\n/**\n * Hook to get the appropriate spoke provider based on the chain type.\n * Supports EVM, SUI, ICON and INJECTIVE chains.\n *\n * @param {SpokeChainId | undefined} spokeChainId - The spoke chain ID to get the provider for\n * @param {IWalletProvider | undefined} walletProvider - The wallet provider to use\n * @returns {SpokeProvider | undefined} The appropriate spoke provider instance for the given chain ID, or undefined if invalid/unsupported\n *\n * @example\n * ```tsx\n * // Using a specific SpokeChainId and wallet provider\n * const spokeProvider = useSpokeProvider(spokeChainId, walletProvider);\n * ```\n */\nexport function useSpokeProvider(\n spokeChainId: SpokeChainId | undefined,\n walletProvider?: IWalletProvider | undefined,\n): SpokeProvider | undefined {\n const { rpcConfig } = useSodaxContext();\n const xChainType = spokeChainId ? spokeChainConfig[spokeChainId]?.chain.type : undefined;\n\n const spokeProvider = useMemo(() => {\n if (!walletProvider) return undefined;\n if (!spokeChainId) return undefined;\n if (!xChainType) return undefined;\n if (!rpcConfig) return undefined;\n\n if (xChainType === 'EVM') {\n if (spokeChainId === SONIC_MAINNET_CHAIN_ID) {\n return new SonicSpokeProvider(\n walletProvider as IEvmWalletProvider,\n spokeChainConfig[spokeChainId] as SonicSpokeChainConfig,\n );\n }\n return new EvmSpokeProvider(\n walletProvider as IEvmWalletProvider,\n spokeChainConfig[spokeChainId] as EvmSpokeChainConfig,\n );\n }\n\n if (xChainType === 'SUI') {\n return new SuiSpokeProvider(\n spokeChainConfig[spokeChainId] as SuiSpokeChainConfig,\n walletProvider as ISuiWalletProvider,\n );\n }\n\n if (xChainType === 'ICON') {\n return new IconSpokeProvider(\n walletProvider as IIconWalletProvider,\n spokeChainConfig[spokeChainId] as IconSpokeChainConfig,\n );\n }\n\n if (xChainType === 'INJECTIVE') {\n return new InjectiveSpokeProvider(\n spokeChainConfig[spokeChainId] as InjectiveSpokeChainConfig,\n walletProvider as IInjectiveWalletProvider,\n );\n }\n\n if (xChainType === 'STELLAR') {\n const stellarConfig = spokeChainConfig[spokeChainId] as StellarSpokeChainConfig;\n return new StellarSpokeProvider(\n walletProvider as IStellarWalletProvider,\n stellarConfig,\n rpcConfig.stellar\n ? rpcConfig.stellar\n : {\n horizonRpcUrl: stellarConfig.horizonRpcUrl,\n sorobanRpcUrl: stellarConfig.sorobanRpcUrl,\n },\n );\n }\n\n if (xChainType === 'SOLANA') {\n return new SolanaSpokeProvider(\n walletProvider as ISolanaWalletProvider,\n rpcConfig.solana\n ? ({\n ...spokeChainConfig[spokeChainId],\n rpcUrl: rpcConfig.solana,\n } as SolanaChainConfig)\n : (spokeChainConfig[spokeChainId] as SolanaChainConfig),\n );\n }\n\n return undefined;\n }, [spokeChainId, xChainType, walletProvider, rpcConfig]);\n\n return spokeProvider;\n}\n","import type { XToken } from '@sodax/types';\nimport { useMutation, type UseMutationResult } from '@tanstack/react-query';\nimport { parseUnits } from 'viem';\nimport { useSodaxContext } from '../shared/useSodaxContext';\nimport type { SpokeProvider } from '@sodax/sdk';\ninterface BorrowResponse {\n ok: true;\n value: [string, string];\n}\n\n/**\n * Hook for borrowing tokens from the Sodax money market.\n *\n * This hook provides functionality to borrow tokens from the money market protocol,\n * handling the entire borrow process including transaction creation, submission,\n * and cross-chain communication.\n *\n * @param {XToken} spokeToken - The token to borrow from the spoke chain. Must be an XToken with valid address and chain information.\n * @param {SpokeProvider} spokeProvider - The spoke provider to use for the borrow transaction. Must be a valid SpokeProvider instance.\n *\n * @returns {UseMutationResult<BorrowResponse, Error, string>} A mutation result object with the following properties:\n * - mutateAsync: Function to execute the borrow transaction\n * - isPending: Boolean indicating if a transaction is in progress\n * - error: Error object if the last transaction failed, null otherwise\n *\n * @example\n * ```typescript\n * const { mutateAsync: borrow, isPending, error } = useBorrow(spokeToken);\n * await borrow('100');\n * ```\n *\n * @throws {Error} When:\n * - spokeProvider is not available\n * - Transaction execution fails\n */\nexport function useBorrow(\n spokeToken: XToken,\n spokeProvider: SpokeProvider | undefined,\n): UseMutationResult<BorrowResponse, Error, string> {\n const { sodax } = useSodaxContext();\n\n return useMutation<BorrowResponse, Error, string>({\n mutationFn: async (amount: string) => {\n if (!spokeProvider) {\n throw new Error('spokeProvider is not found');\n }\n\n const response = await sodax.moneyMarket.borrow(\n {\n token: spokeToken.address,\n amount: parseUnits(amount, 18),\n action: 'borrow',\n },\n spokeProvider,\n );\n\n if (!response.ok) {\n throw new Error('Failed to borrow tokens');\n }\n\n console.log('Borrow transaction submitted:', response);\n return response;\n },\n });\n}\n","import type { SpokeProvider } from '@sodax/sdk';\nimport type { XToken } from '@sodax/types';\nimport { useMutation, type UseMutationResult } from '@tanstack/react-query';\nimport { parseUnits } from 'viem';\nimport { useSodaxContext } from '../shared/useSodaxContext';\n\ninterface RepayResponse {\n ok: true;\n value: [string, string];\n}\n\n/**\n * Hook for repaying borrowed tokens to the Sodax money market.\n *\n * This hook provides functionality to repay borrowed tokens back to the money market protocol,\n * handling the entire repayment process including transaction creation, submission,\n * and cross-chain communication.\n *\n * @param {XToken} spokeToken - The token to repay on the spoke chain. Must be an XToken with valid address and chain information.\n * @param {SpokeProvider} spokeProvider - The spoke provider to use for the repay transaction. Must be a valid SpokeProvider instance.\n *\n * @returns {UseMutationResult<RepayResponse, Error, string>} A mutation result object with the following properties:\n * - mutateAsync: Function to execute the repay transaction\n * - isPending: Boolean indicating if a transaction is in progress\n * - error: Error object if the last transaction failed, null otherwise\n *\n * @example\n * ```typescript\n * const { mutateAsync: repay, isPending, error } = useRepay(spokeToken);\n * await repay('100');\n * ```\n *\n * @throws {Error} When:\n * - spokeProvider is not available\n * - Transaction execution fails\n */\nexport function useRepay(\n spokeToken: XToken,\n spokeProvider: SpokeProvider | undefined,\n): UseMutationResult<RepayResponse, Error, string> {\n const { sodax } = useSodaxContext();\n\n return useMutation<RepayResponse, Error, string>({\n mutationFn: async (amount: string) => {\n if (!spokeProvider) {\n throw new Error('spokeProvider is not found');\n }\n\n const response = await sodax.moneyMarket.repay(\n {\n token: spokeToken.address,\n amount: parseUnits(amount, spokeToken.decimals),\n action: 'repay',\n },\n spokeProvider,\n );\n\n if (!response.ok) {\n throw new Error('Failed to repay tokens');\n }\n\n console.log('Repay transaction submitted:', response);\n return response;\n },\n });\n}\n","import type { SpokeProvider } from '@sodax/sdk';\nimport type { XToken } from '@sodax/types';\nimport { useMutation, type UseMutationResult } from '@tanstack/react-query';\nimport { parseUnits } from 'viem';\nimport { useSodaxContext } from '../shared/useSodaxContext';\n\ninterface SupplyResponse {\n ok: true;\n value: [string, string];\n}\n\n/**\n * Hook for supplying tokens to the Sodax money market.\n *\n * This hook provides functionality to supply tokens to the money market protocol,\n * handling the entire supply process including transaction creation, submission,\n * and cross-chain communication.\n *\n * @param {XToken} spokeToken - The token to supply on the spoke chain. Must be an XToken with valid address and chain information.\n * @param {SpokeProvider} spokeProvider - The spoke provider to use for the supply transaction. Must be a valid SpokeProvider instance.\n *\n * @returns {UseMutationResult<SupplyResponse, Error, string>} A mutation result object with the following properties:\n * - mutateAsync: Function to execute the supply transaction\n * - isPending: Boolean indicating if a transaction is in progress\n * - error: Error object if the last transaction failed, null otherwise\n *\n * @example\n * ```typescript\n * const { mutateAsync: supply, isPending, error } = useSupply(spokeToken);\n * await supply('100');\n * ```\n *\n * @throws {Error} When:\n * - spokeProvider is not available\n */\nexport function useSupply(\n spokeToken: XToken,\n spokeProvider: SpokeProvider | undefined,\n): UseMutationResult<SupplyResponse, Error, string> {\n const { sodax } = useSodaxContext();\n\n return useMutation<SupplyResponse, Error, string>({\n mutationFn: async (amount: string) => {\n if (!spokeProvider) {\n throw new Error('spokeProvider is not found');\n }\n\n const response = await sodax.moneyMarket.supply(\n {\n token: spokeToken.address,\n amount: parseUnits(amount, spokeToken.decimals),\n action: 'supply',\n },\n spokeProvider,\n );\n\n if (!response.ok) {\n throw new Error('Failed to supply tokens');\n }\n\n console.log('Supply transaction submitted:', response);\n return response;\n },\n });\n}\n","import type { SpokeProvider } from '@sodax/sdk';\nimport type { XToken } from '@sodax/types';\nimport { useMutation, type UseMutationResult } from '@tanstack/react-query';\nimport { parseUnits } from 'viem';\nimport { useSodaxContext } from '../shared/useSodaxContext';\n\ninterface WithdrawResponse {\n ok: true;\n value: [string, string];\n}\n\n/**\n * Hook for withdrawing supplied tokens from the Sodax money market.\n *\n * This hook provides functionality to withdraw previously supplied tokens from the money market protocol,\n * handling the entire withdrawal process including transaction creation, submission,\n * and cross-chain communication.\n *\n * @param {XToken} spokeToken - The token to withdraw from the spoke chain. Must be an XToken with valid address and chain information.\n * @param {SpokeProvider} spokeProvider - The spoke provider to use for the withdraw transaction. Must be a valid SpokeProvider instance.\n *\n * @returns {UseMutationResult<WithdrawResponse, Error, string>} A mutation result object with the following properties:\n * - mutateAsync: Function to execute the withdraw transaction\n * - isPending: Boolean indicating if a transaction is in progress\n * @example\n * ```typescript\n * const { mutateAsync: withdraw, isPending, error } = useWithdraw(spokeToken);\n * await withdraw('100');\n * ```\n *\n * @throws {Error} When:\n * - spokeProvider is not available\n * - Transaction execution fails\n */\nexport function useWithdraw(\n spokeToken: XToken,\n spokeProvider: SpokeProvider | undefined,\n): UseMutationResult<WithdrawResponse, Error, string> {\n const { sodax } = useSodaxContext();\n\n return useMutation<WithdrawResponse, Error, string>({\n mutationFn: async (amount: string) => {\n if (!spokeProvider) {\n throw new Error('spokeProvider is not found');\n }\n\n const response = await sodax.moneyMarket.withdraw(\n {\n token: spokeToken.address,\n // vault token on hub chain decimals is 18\n amount: parseUnits(amount, 18),\n action: 'withdraw',\n },\n spokeProvider,\n );\n\n if (!response.ok) {\n throw new Error('Failed to withdraw tokens');\n }\n\n console.log('Withdraw transaction submitted:', response);\n return response;\n },\n });\n}\n","import type { SpokeProvider, UserReserveData } from '@sodax/sdk';\nimport { useQuery, type UseQueryResult } from '@tanstack/react-query';\nimport { useSodaxContext } from '../shared/useSodaxContext';\n\n/**\n * Hook for fetching user reserves data from the Sodax money market.\n *\n * This hook provides access to the current state of user reserves in the money market protocol.\n * The data is automatically fetched and cached using React Query.\n *\n * @example\n * ```typescript\n * const { data: userReservesData, isLoading, error } = useUserReservesData(spokeProvider, address);\n * ```\n *\n * @returns A React Query result object containing:\n * - data: The user reserves data when available\n * - isLoading: Loading state indicator\n * - error: Any error that occurred during data fetching\n */\nexport function useUserReservesData(\n spokeProvider: SpokeProvider | undefined,\n address: string | undefined,\n refetchInterval = 5000,\n): UseQueryResult<readonly [readonly UserReserveData[], number], Error> {\n const { sodax } = useSodaxContext();\n\n return useQuery({\n queryKey: ['userReserves', spokeProvider?.chainConfig.chain.id, address],\n queryFn: async () => {\n if (!spokeProvider) {\n throw new Error('Spoke provider or address is not defined');\n }\n\n return await sodax.moneyMarket.data.getUserReservesData(spokeProvider);\n },\n enabled: !!spokeProvider && !!address,\n refetchInterval,\n });\n}\n","import { useQuery } from '@tanstack/react-query';\nimport { useSodaxContext } from '../shared/useSodaxContext';\n/**\n * Hook for fetching reserves data from the Sodax money market.\n *\n * This hook provides access to the current state of all reserves in the money market protocol,\n * including liquidity, interest rates, and other key metrics. The data is automatically\n * fetched and cached using React Query.\n *\n * @example\n * ```typescript\n * const { data: reservesData, isLoading, error } = useReservesData();\n * ```\n *\n * @returns A React Query result object containing:\n * - data: The reserves data when available\n * - isLoading: Loading state indicator\n * - error: Any error that occurred during data fetching\n */\n\nexport function useReservesData() {\n const { sodax } = useSodaxContext();\n\n return useQuery({\n queryKey: ['reservesData'],\n queryFn: async () => {\n return await sodax.moneyMarket.data.getReservesData();\n },\n });\n}\n","import { useQuery, type UseQueryResult } from '@tanstack/react-query';\nimport type { XToken } from '@sodax/types';\nimport { useSodaxContext } from '../shared/useSodaxContext';\nimport { parseUnits } from 'viem';\nimport type { MoneyMarketAction, SpokeProvider } from '@sodax/sdk';\n\n/**\n * Hook for checking token allowance for money market operations.\n *\n * This hook verifies if the user has approved enough tokens for a specific money market action\n * (borrow/repay). It automatically queries and tracks the allowance status.\n *\n * @param {XToken} token - The token to check allowance for. Must be an XToken with valid address and chain information.\n * @param {string} amount - The amount to check allowance for, as a decimal string\n * @param {MoneyMarketAction} action - The money market action to check allowance for ('borrow' or 'repay')\n * @param {SpokeProvider} spokeProvider - The spoke provider to use for allowance checks\n *\n * @returns {UseQueryResult<boolean, Error>} A React Query result containing:\n * - data: Boolean indicating if allowance is sufficient\n * - isLoading: Loading state indicator\n * - error: Any error that occurred during the check\n *\n * @example\n * ```typescript\n * const { data: hasAllowed, isLoading } = useMMAllowance(token, \"100\", \"repay\", provider);\n * ```\n */\nexport function useMMAllowance(\n token: XToken,\n amount: string,\n action: MoneyMarketAction,\n spokeProvider: SpokeProvider | undefined,\n): UseQueryResult<boolean, Error> {\n const { sodax } = useSodaxContext();\n\n return useQuery({\n queryKey: ['allowance', token.address, amount, action],\n queryFn: async () => {\n if (!spokeProvider) throw new Error('Spoke provider is required');\n const allowance = await sodax.moneyMarket.isAllowanceValid(\n {\n token: token.address,\n amount: parseUnits(amount, token.decimals),\n action,\n },\n spokeProvider,\n );\n if (allowance.ok) {\n return allowance.value;\n }\n return false;\n },\n enabled: !!spokeProvider,\n });\n}\n","import { useSodaxContext } from '../shared/useSodaxContext';\nimport type { XToken } from '@sodax/types';\nimport { parseUnits } from 'viem';\nimport { useMutation, useQueryClient } from '@tanstack/react-query';\nimport type { MoneyMarketAction, SpokeProvider } from '@sodax/sdk';\n\ninterface UseApproveReturn {\n approve: ({ amount, action }: { amount: string; action: MoneyMarketAction }) => Promise<boolean>;\n isLoading: boolean;\n error: Error | null;\n resetError: () => void;\n}\n\n/**\n * Hook for approving token spending for money market actions\n * @param token The token to approve spending for\n * @param spokeProvider The spoke provider instance for the chain\n * @returns Object containing approve function, loading state, error state and reset function\n * @example\n * ```tsx\n * const { approve, isLoading, error } = useMMApprove(token, spokeProvider);\n *\n * // Approve tokens for supply action\n * await approve({ amount: \"100\", action: \"supply\" });\n * ```\n */\n\nexport function useMMApprove(token: XToken, spokeProvider: SpokeProvider | undefined): UseApproveReturn {\n const { sodax } = useSodaxContext();\n const queryClient = useQueryClient();\n\n const {\n mutateAsync: approve,\n isPending,\n error,\n reset: resetError,\n } = useMutation({\n mutationFn: async ({ amount, action }: { amount: string; action: MoneyMarketAction }) => {\n if (!spokeProvider) {\n throw new Error('Spoke provider not found');\n }\n const allowance = await sodax.moneyMarket.approve(\n {\n token: token.address,\n amount: parseUnits(amount, token.decimals),\n action,\n },\n spokeProvider,\n );\n if (!allowance.ok) {\n throw new Error('Failed to approve tokens');\n }\n return allowance.ok;\n },\n onSuccess: () => {\n // Invalidate allowance query to refetch the new allowance\n queryClient.invalidateQueries({ queryKey: ['allowance', token.address] });\n },\n });\n\n return {\n approve,\n isLoading: isPending,\n error: error,\n resetError,\n };\n}\n","import type { SolverErrorResponse, SolverIntentQuoteRequest, SolverIntentQuoteResponse, Result } from '@sodax/sdk';\nimport { useSodaxContext } from '../shared/useSodaxContext';\nimport { useQuery, type UseQueryResult } from '@tanstack/react-query';\n\n/**\n * Hook for fetching a quote for an intent-based swap.\n *\n * This hook provides real-time quote data for an intent-based swap.\n *\n * @param {SolverIntentQuoteRequest | undefined} payload - The intent quote request parameters. If undefined, the query will be disabled.\n *\n * @returns {UseQueryResult<Result<SolverIntentQuoteResponse, SolverErrorResponse> | undefined>} A query result object containing:\n * - data: The quote result from the solver\n * - isLoading: Boolean indicating if the quote is being fetched\n * - error: Error object if the quote request failed\n * - refetch: Function to manually trigger a quote refresh\n *\n * @example\n * ```typescript\n * const { data: quote, isLoading } = useQuote({\n * token_src: '0x...',\n * token_src_blockchain_id: '1',\n * token_dst: '0x...',\n * token_dst_blockchain_id: '2',\n * amount: '1000000000000000000',\n * quote_type: 'exact_input',\n * });\n *\n * if (isLoading) return <div>Loading quote...</div>;\n * if (quote) {\n * console.log('Quote received:', quote);\n * }\n * ```\n *\n * @remarks\n * - The quote is automatically refreshed every 3 seconds\n * - The query is disabled when payload is undefined\n * - Uses React Query for efficient caching and state management\n */\nexport const useQuote = (\n payload: SolverIntentQuoteRequest | undefined,\n): UseQueryResult<Result<SolverIntentQuoteResponse, SolverErrorResponse> | undefined> => {\n const { sodax } = useSodaxContext();\n return useQuery({\n queryKey: [payload],\n queryFn: async () => {\n if (!payload) {\n return undefined;\n }\n return sodax.solver.getQuote(payload);\n },\n enabled: !!payload,\n refetchInterval: 3000,\n });\n};\n","import { useSodaxContext } from '../shared/useSodaxContext';\nimport type {\n CreateIntentParams,\n SolverExecutionResponse,\n Result,\n IntentErrorCode,\n Intent,\n IntentError,\n SpokeProvider,\n IntentDeliveryInfo,\n} from '@sodax/sdk';\nimport { useMutation, type UseMutationResult } from '@tanstack/react-query';\n\ntype CreateIntentResult = Result<[SolverExecutionResponse, Intent, IntentDeliveryInfo], IntentError<IntentErrorCode>>;\n\n/**\n * Hook for creating and submitting an swap intent order for cross-chain swaps.\n * Uses React Query's useMutation for better state management and caching.\n *\n * @param {SpokeProvider} spokeProvider - The spoke provider to use for the swap\n * @returns {UseMutationResult} Mutation result object containing mutation function and state\n *\n * @example\n * ```typescript\n * const { mutateAsync: swap, isPending } = useSwap(spokeProvider);\n *\n * const handleSwap = async () => {\n * const result = await swap({\n * token_src: '0x...',\n * token_src_blockchain_id: 'arbitrum',\n * token_dst: '0x...',\n * token_dst_blockchain_id: 'polygon',\n * amount: '1000000000000000000',\n * min_output_amount: '900000000000000000'\n * });\n * };\n * ```\n */\nexport function useSwap(\n spokeProvider: SpokeProvider | undefined,\n): UseMutationResult<CreateIntentResult, Error, CreateIntentParams> {\n const { sodax } = useSodaxContext();\n\n return useMutation<CreateIntentResult, Error, CreateIntentParams>({\n mutationFn: async (params: CreateIntentParams) => {\n if (!spokeProvider) {\n throw new Error('Spoke provider not found');\n }\n return sodax.solver.swap({\n intentParams: params,\n spokeProvider,\n });\n },\n });\n}\n","import type { Hex, SolverErrorResponse, SolverIntentStatusResponse, Result } from '@sodax/sdk';\nimport { useQuery, type UseQueryResult } from '@tanstack/react-query';\nimport { useSodaxContext } from '../shared/useSodaxContext';\n\n/**\n * Hook for monitoring the status of an intent-based swap.\n *\n * This hook provides real-time status updates for an intent-based swap transaction.\n *\n * @param {Hex} intent_tx_hash - The transaction hash of the intent order on the hub chain\n *\n * @returns {UseQueryResult<Result<SolverIntentStatusResponse, SolverErrorResponse> | undefined>} A query result object containing:\n * - data: The status result from the solver\n * - isLoading: Boolean indicating if the status is being fetched\n * - error: Error object if the status request failed\n * - refetch: Function to manually trigger a status refresh\n *\n * @example\n * ```typescript\n * const { data: status, isLoading } = useStatus('0x...');\n *\n * if (isLoading) return <div>Loading status...</div>;\n * if (status?.ok) {\n * console.log('Status:', status.value);\n * }\n * ```\n *\n * @remarks\n * - The status is automatically refreshed every 3 seconds\n * - Uses React Query for efficient caching and state management\n */\n\nexport const useStatus = (\n intent_tx_hash: Hex,\n): UseQueryResult<Result<SolverIntentStatusResponse, SolverErrorResponse> | undefined> => {\n const { sodax } = useSodaxContext();\n return useQuery({\n queryKey: [intent_tx_hash],\n queryFn: async () => {\n return sodax.solver.getStatus({ intent_tx_hash });\n },\n refetchInterval: 3000, // 3s\n });\n};\n","import { useQuery, type UseQueryResult } from '@tanstack/react-query';\nimport { useSodaxContext } from '../shared/useSodaxContext';\nimport type { CreateIntentParams, SpokeProvider } from '@sodax/sdk';\n\n/**\n * Hook for checking token allowance for money market operations.\n *\n * This hook verifies if the user has approved enough tokens for a specific money market action\n * (borrow/repay). It automatically queries and tracks the allowance status.\n *\n * @param {CreateIntentParams} params - The parameters for the intent to check allowance for.\n * @param {SpokeProvider} spokeProvider - The spoke provider to use for allowance checks\n *\n * @returns {UseQueryResult<boolean, Error>} A React Query result containing:\n * - data: Boolean indicating if allowance is sufficient\n * - isLoading: Loading state indicator\n * - error: Any error that occurred during the check\n *\n * @example\n * ```typescript\n * const { data: hasAllowed, isLoading } = useMMAllowance(params, spokeProvider);\n * ```\n */\nexport function useSwapAllowance(\n params: CreateIntentParams | undefined,\n spokeProvider: SpokeProvider | undefined,\n): UseQueryResult<boolean, Error> {\n const { sodax } = useSodaxContext();\n\n return useQuery({\n queryKey: ['allowance', params],\n queryFn: async () => {\n if (!spokeProvider || !params) {\n return false;\n }\n const allowance = await sodax.solver.isAllowanceValid({\n intentParams: params,\n spokeProvider,\n });\n if (allowance.ok) {\n return allowance.value;\n }\n return false;\n },\n enabled: !!spokeProvider && !!params,\n });\n}\n","import { useSodaxContext } from '../shared/useSodaxContext';\nimport { useMutation, useQueryClient } from '@tanstack/react-query';\nimport type { CreateIntentParams, SpokeProvider } from '@sodax/sdk';\n\ninterface UseApproveReturn {\n approve: ({ params }: { params: CreateIntentParams }) => Promise<boolean>;\n isLoading: boolean;\n error: Error | null;\n resetError: () => void;\n}\n\n/**\n * Hook for approving token spending for money market actions\n * @param token The token to approve spending for\n * @param spokeProvider The spoke provider instance for the chain\n * @returns Object containing approve function, loading state, error state and reset function\n * @example\n * ```tsx\n * const { approve, isLoading, error } = useApprove(token, spokeProvider);\n *\n * // Approve tokens for supply action\n * await approve({ amount: \"100\", action: \"supply\" });\n * ```\n */\n\nexport function useSwapApprove(\n params: CreateIntentParams | undefined,\n spokeProvider: SpokeProvider | undefined,\n): UseApproveReturn {\n const { sodax } = useSodaxContext();\n const queryClient = useQueryClient();\n\n const {\n mutateAsync: approve,\n isPending,\n error,\n reset: resetError,\n } = useMutation({\n mutationFn: async ({ params }: { params: CreateIntentParams | undefined }) => {\n if (!spokeProvider) {\n throw new Error('Spoke provider not found');\n }\n if (!params) {\n throw new Error('Swap Params not found');\n }\n\n const allowance = await sodax.solver.approve({\n intentParams: params,\n spokeProvider,\n });\n if (!allowance.ok) {\n throw new Error('Failed to approve input token');\n }\n return allowance.ok;\n },\n onSuccess: () => {\n // Invalidate allowance query to refetch the new allowance\n queryClient.invalidateQueries({ queryKey: ['allowance', params?.inputToken] });\n },\n });\n\n return {\n approve,\n isLoading: isPending,\n error: error,\n resetError,\n };\n}\n","import { useSodaxContext } from '../shared/useSodaxContext';\nimport type { Intent, Result, SpokeProvider, TxReturnType } from '@sodax/sdk';\nimport { useMutation, type UseMutationResult } from '@tanstack/react-query';\n\ntype CancelIntentParams = {\n intent: Intent;\n raw?: boolean;\n};\n\ntype CancelIntentResult = Result<TxReturnType<SpokeProvider, boolean>>;\n\n/**\n * Hook for canceling a swap intent order.\n * Uses React Query's useMutation for better state management and caching.\n *\n * @param {SpokeProvider} spokeProvider - The spoke provider to use for canceling the intent\n * @returns {UseMutationResult} Mutation result object containing mutation function and state\n *\n * @example\n * ```typescript\n * const { mutateAsync: cancelSwap, isPending } = useCancelSwap(spokeProvider);\n *\n * const handleCancelSwap = async () => {\n * const result = await cancelSwap({\n * intent: intentObject,\n * raw: false // optional, defaults to false\n * });\n * };\n * ```\n */\nexport function useCancelSwap(\n spokeProvider: SpokeProvider | undefined,\n): UseMutationResult<CancelIntentResult, Error, CancelIntentParams> {\n const { sodax } = useSodaxContext();\n\n return useMutation<CancelIntentResult, Error, CancelIntentParams>({\n mutationFn: async ({ intent, raw = false }: CancelIntentParams) => {\n if (!spokeProvider) {\n throw new Error('Spoke provider not found');\n }\n return sodax.solver.cancelIntent(intent, spokeProvider, raw);\n },\n });\n}\n","// packages/dapp-kit/src/hooks/backend/useIntentByTxHash.ts\nimport { useQuery, type UseQueryResult } from '@tanstack/react-query';\nimport type { IntentResponse } from '@sodax/sdk';\nimport { useSodaxContext } from '../shared/useSodaxContext';\n\n/**\n * Hook for fetching intent details by transaction hash from the backend API.\n *\n * This hook provides access to intent data associated with a specific transaction hash,\n * including intent details, events, and transaction information. The data is automatically\n * fetched and cached using React Query.\n *\n * @param {string | undefined} txHash - The transaction hash to fetch intent for. If undefined, the query will be disabled.\n *\n * @returns {UseQueryResult<IntentResponse | undefined>} A query result object containing:\n * - data: The intent response data when available\n * - isLoading: Boolean indicating if the request is in progress\n * - error: Error object if the request failed\n * - refetch: Function to manually trigger a data refresh\n *\n * @example\n * ```typescript\n * const { data: intent, isLoading, error } = useIntentByTxHash('0x123...');\n *\n * if (isLoading) return <div>Loading intent...</div>;\n * if (error) return <div>Error: {error.message}</div>;\n * if (intent) {\n * console.log('Intent found:', intent.intentHash);\n * }\n * ```\n *\n * @remarks\n * - The query is disabled when txHash is undefined or empty\n * - Uses React Query for efficient caching and state management\n * - Automatically handles error states and loading indicators\n */\nexport const useBackendIntentByTxHash = (txHash: string | undefined): UseQueryResult<IntentResponse | undefined> => {\n const { sodax } = useSodaxContext();\n\n return useQuery({\n queryKey: ['backend', 'intent', 'txHash', txHash],\n queryFn: async (): Promise<IntentResponse | undefined> => {\n if (!txHash) {\n return undefined;\n }\n\n return sodax.backendApiService.getIntentByTxHash(txHash);\n },\n enabled: !!txHash && txHash.length > 0,\n retry: 3,\n });\n};\n","// packages/dapp-kit/src/hooks/backend/useIntentByHash.ts\nimport { useQuery, type UseQueryResult } from '@tanstack/react-query';\nimport type { IntentResponse } from '@sodax/sdk';\nimport { useSodaxContext } from '../shared/useSodaxContext';\n\n/**\n * Hook for fetching intent details by intent hash from the backend API.\n *\n * This hook provides access to intent data using the intent hash directly,\n * including intent details, events, and transaction information. The data is automatically\n * fetched and cached using React Query.\n *\n * @param {string | undefined} intentHash - The intent hash to fetch intent for. If undefined, the query will be disabled.\n *\n * @returns {UseQueryResult<IntentResponse | undefined>} A query result object containing:\n * - data: The intent response data when available\n * - isLoading: Boolean indicating if the request is in progress\n * - error: Error object if the request failed\n * - refetch: Function to manually trigger a data refresh\n *\n * @example\n * ```typescript\n * const { data: intent, isLoading, error } = useIntentByHash('0xabc...');\n *\n * if (isLoading) return <div>Loading intent...</div>;\n * if (error) return <div>Error: {error.message}</div>;\n * if (intent) {\n * console.log('Intent found:', intent.intentHash);\n * console.log('Open status:', intent.open);\n * }\n * ```\n *\n * @remarks\n * - The query is disabled when intentHash is undefined or empty\n * - Uses React Query for efficient caching and state management\n * - Automatically handles error states and loading indicators\n */\nexport const useBackendIntentByHash = (intentHash: string | undefined): UseQueryResult<IntentResponse | undefined> => {\n const { sodax } = useSodaxContext();\n\n return useQuery({\n queryKey: ['backend', 'intent', 'hash', intentHash],\n queryFn: async (): Promise<IntentResponse | undefined> => {\n if (!intentHash) {\n return undefined;\n }\n\n return sodax.backendApiService.getIntentByHash(intentHash);\n },\n enabled: !!intentHash && intentHash.length > 0,\n retry: 3,\n });\n};\n","// packages/dapp-kit/src/hooks/backend/useOrderbook.ts\nimport { useQuery, type UseQueryResult } from '@tanstack/react-query';\nimport type { OrderbookResponse } from '@sodax/sdk';\nimport { useSodaxContext } from '../shared/useSodaxContext';\n\n/**\n * Hook for fetching the solver orderbook from the backend API.\n *\n * This hook provides access to the solver orderbook data, including intent states\n * and intent data for all available intents. The data is automatically fetched\n * and cached using React Query with pagination support.\n *\n * @param {Object} params - Pagination parameters for the orderbook\n * @param {string} params.offset - The offset for pagination (number as string)\n * @param {string} params.limit - The limit for pagination (number as string)\n *\n * @returns {UseQueryResult<OrderbookResponse | undefined>} A query result object containing:\n * - data: The orderbook response data when available\n * - isLoading: Boolean indicating if the request is in progress\n * - error: Error object if the request failed\n * - refetch: Function to manually trigger a data refresh\n *\n * @example\n * ```typescript\n * const { data: orderbook, isLoading, error } = useOrderbook({\n * offset: '0',\n * limit: '10'\n * });\n *\n * if (isLoading) return <div>Loading orderbook...</div>;\n * if (error) return <div>Error: {error.message}</div>;\n * if (orderbook) {\n * console.log('Total intents:', orderbook.total);\n * console.log('Intents:', orderbook.data);\n * }\n * ```\n *\n * @remarks\n * - The query is disabled when params are undefined or invalid\n * - Uses React Query for efficient caching and state management\n * - Automatically handles error states and loading indicators\n * - Stale time of 30 seconds for real-time orderbook data\n * - Supports pagination through offset and limit parameters\n */\nexport const useBackendOrderbook = (\n params: { offset: string; limit: string } | undefined,\n): UseQueryResult<OrderbookResponse | undefined> => {\n const { sodax } = useSodaxContext();\n\n return useQuery({\n queryKey: ['backend', 'solver', 'orderbook', params],\n queryFn: async (): Promise<OrderbookResponse | undefined> => {\n if (!params || !params.offset || !params.limit) {\n return undefined;\n }\n\n return sodax.backendApiService.getOrderbook(params);\n },\n enabled: !!params && !!params.offset && !!params.limit,\n staleTime: 30 * 1000, // 30 seconds for real-time data\n retry: 3,\n });\n};\n","// packages/dapp-kit/src/hooks/backend/useMoneyMarketPosition.ts\nimport { useQuery, type UseQueryResult } from '@tanstack/react-query';\nimport type { MoneyMarketPosition } from '@sodax/sdk';\nimport { useSodaxContext } from '../shared/useSodaxContext';\n\n/**\n * Hook for fetching money market position for a specific user from the backend API.\n *\n * This hook provides access to a user's money market positions, including their\n * aToken balances, variable debt token balances, and associated reserve information.\n * The data is automatically fetched and cached using React Query.\n *\n * @param {string | undefined} userAddress - The user's wallet address. If undefined, the query will be disabled.\n *\n * @returns {UseQueryResult<MoneyMarketPosition | undefined>} A query result object containing:\n * - data: The money market position data when available\n * - isLoading: Boolean indicating if the request is in progress\n * - error: Error object if the request failed\n * - refetch: Function to manually trigger a data refresh\n *\n * @example\n * ```typescript\n * const { data: position, isLoading, error } = useMoneyMarketPosition('0x123...');\n *\n * if (isLoading) return <div>Loading position...</div>;\n * if (error) return <div>Error: {error.message}</div>;\n * if (position) {\n * console.log('User address:', position.userAddress);\n * console.log('Positions:', position.positions);\n * }\n * ```\n *\n * @remarks\n * - The query is disabled when userAddress is undefined or empty\n * - Uses React Query for efficient caching and state management\n * - Automatically handles error states and loading indicators\n * - Includes user's aToken and debt token balances across all reserves\n */\nexport const useBackendMoneyMarketPosition = (\n userAddress: string | undefined,\n): UseQueryResult<MoneyMarketPosition | undefined> => {\n const { sodax } = useSodaxContext();\n\n return useQuery({\n queryKey: ['backend', 'moneymarket', 'position', userAddress],\n queryFn: async (): Promise<MoneyMarketPosition | undefined> => {\n if (!userAddress) {\n return undefined;\n }\n\n return sodax.backendApiService.getMoneyMarketPosition(userAddress);\n },\n enabled: !!userAddress && userAddress.length > 0,\n retry: 3,\n });\n};\n","// packages/dapp-kit/src/hooks/backend/useAllMoneyMarketAssets.ts\nimport { useQuery, type UseQueryResult } from '@tanstack/react-query';\nimport type { MoneyMarketAsset } from '@sodax/sdk';\nimport { useSodaxContext } from '../shared/useSodaxContext';\n\n/**\n * Hook for fetching all money market assets from the backend API.\n *\n * This hook provides access to all available money market assets, including\n * their reserve information, liquidity rates, borrow rates, and market statistics.\n * The data is automatically fetched and cached using React Query.\n *\n * @returns {UseQueryResult<MoneyMarketAsset[]>} A query result object containing:\n * - data: Array of money market asset data when available\n * - isLoading: Boolean indicating if the request is in progress\n * - error: Error object if the request failed\n * - refetch: Function to manually trigger a data refresh\n *\n * @example\n * ```typescript\n * const { data: assets, isLoading, error } = useAllMoneyMarketAssets();\n *\n * if (isLoading) return <div>Loading assets...</div>;\n * if (error) return <div>Error: {error.message}</div>;\n * if (assets) {\n * console.log('Total assets:', assets.length);\n * assets.forEach(asset => {\n * console.log(`${asset.symbol}: ${asset.liquidityRate} liquidity rate`);\n * });\n * }\n * ```\n *\n * @remarks\n * - Uses React Query for efficient caching and state management\n * - Automatically handles error states and loading indicators\n * - Returns comprehensive asset information including rates and statistics\n * - No parameters required - fetches all available assets\n */\nexport const useBackendAllMoneyMarketAssets = (): UseQueryResult<MoneyMarketAsset[]> => {\n const { sodax } = useSodaxContext();\n\n return useQuery({\n queryKey: ['backend', 'moneymarket', 'assets', 'all'],\n queryFn: async (): Promise<MoneyMarketAsset[]> => {\n return sodax.backendApiService.getAllMoneyMarketAssets();\n },\n retry: 3,\n });\n};\n","// packages/dapp-kit/src/hooks/backend/useMoneyMarketAsset.ts\nimport { useQuery, type UseQueryResult } from '@tanstack/react-query';\nimport type { MoneyMarketAsset } from '@sodax/sdk';\nimport { useSodaxContext } from '../shared/useSodaxContext';\n\n/**\n * Hook for fetching specific money market asset details from the backend API.\n *\n * This hook provides access to detailed information for a specific money market asset,\n * including reserve information, liquidity rates, borrow rates, and market statistics.\n * The data is automatically fetched and cached using React Query.\n *\n * @param {string | undefined} reserveAddress - The reserve contract address. If undefined, the query will be disabled.\n *\n * @returns {UseQueryResult<MoneyMarketAsset | undefined>} A query result object containing:\n * - data: The money market asset data when available\n * - isLoading: Boolean indicating if the request is in progress\n * - error: Error object if the request failed\n * - refetch: Function to manually trigger a data refresh\n *\n * @example\n * ```typescript\n * const { data: asset, isLoading, error } = useMoneyMarketAsset('0xabc...');\n *\n * if (isLoading) return <div>Loading asset...</div>;\n * if (error) return <div>Error: {error.message}</div>;\n * if (asset) {\n * console.log('Asset symbol:', asset.symbol);\n * console.log('Liquidity rate:', asset.liquidityRate);\n * console.log('Variable borrow rate:', asset.variableBorrowRate);\n * }\n * ```\n *\n * @remarks\n * - The query is disabled when reserveAddress is undefined or empty\n * - Uses React Query for efficient caching and state management\n * - Automatically handles error states and loading indicators\n * - Returns comprehensive asset information for the specified reserve\n */\nexport const useBackendMoneyMarketAsset = (\n reserveAddress: string | undefined,\n): UseQueryResult<MoneyMarketAsset | undefined> => {\n const { sodax } = useSodaxContext();\n\n return useQuery({\n queryKey: ['backend', 'moneymarket', 'asset', reserveAddress],\n queryFn: async (): Promise<MoneyMarketAsset | undefined> => {\n if (!reserveAddress) {\n return undefined;\n }\n\n return sodax.backendApiService.getMoneyMarketAsset(reserveAddress);\n },\n enabled: !!reserveAddress && reserveAddress.length > 0,\n retry: 3,\n });\n};\n","// packages/dapp-kit/src/hooks/backend/useMoneyMarketAssetBorrowers.ts\nimport { useQuery, type UseQueryResult } from '@tanstack/react-query';\nimport type { MoneyMarketAssetBorrowers } from '@sodax/sdk';\nimport { useSodaxContext } from '../shared/useSodaxContext';\n\n/**\n * Hook for fetching borrowers for a specific money market asset from the backend API.\n *\n * This hook provides access to the list of borrowers for a specific money market asset,\n * with pagination support. The data is automatically fetched and cached using React Query.\n *\n * @param {Object} params - Parameters for fetching asset borrowers\n * @param {string | undefined} params.reserveAddress - The reserve contract address. If undefined, the query will be disabled.\n * @param {string} params.offset - The offset for pagination (number as string)\n * @param {string} params.limit - The limit for pagination (number as string)\n *\n * @returns {UseQueryResult<MoneyMarketAssetBorrowers | undefined>} A query result object containing:\n * - data: The asset borrowers data when available\n * - isLoading: Boolean indicating if the request is in progress\n * - error: Error object if the request failed\n * - refetch: Function to manually trigger a data refresh\n *\n * @example\n * ```typescript\n * const { data: borrowers, isLoading, error } = useMoneyMarketAssetBorrowers({\n * reserveAddress: '0xabc...',\n * offset: '0',\n * limit: '20'\n * });\n *\n * if (isLoading) return <div>Loading borrowers...</div>;\n * if (error) return <div>Error: {error.message}</div>;\n * if (borrowers) {\n * console.log('Total borrowers:', borrowers.total);\n * console.log('Borrowers:', borrowers.borrowers);\n * }\n * ```\n *\n * @remarks\n * - The query is disabled when reserveAddress is undefined or empty\n * - Uses React Query for efficient caching and state management\n * - Automatically handles error states and loading indicators\n * - Supports pagination through offset and limit parameters\n */\nexport const useBackendMoneyMarketAssetBorrowers = (params: {\n reserveAddress: string | undefined;\n offset: string;\n limit: string;\n}): UseQueryResult<MoneyMarketAssetBorrowers | undefined> => {\n const { sodax } = useSodaxContext();\n\n return useQuery({\n queryKey: ['backend', 'moneymarket', 'asset', 'borrowers', params],\n queryFn: async (): Promise<MoneyMarketAssetBorrowers | undefined> => {\n if (!params.reserveAddress || !params.offset || !params.limit) {\n return undefined;\n }\n\n return sodax.backendApiService.getMoneyMarketAssetBorrowers(params.reserveAddress, {\n offset: params.offset,\n limit: params.limit,\n });\n },\n enabled: !!params.reserveAddress && !!params.offset && !!params.limit,\n retry: 3,\n });\n};\n","// packages/dapp-kit/src/hooks/backend/useMoneyMarketAssetSuppliers.ts\nimport { useQuery, type UseQueryResult } from '@tanstack/react-query';\nimport type { MoneyMarketAssetSuppliers } from '@sodax/sdk';\nimport { useSodaxContext } from '../shared/useSodaxContext';\n\n/**\n * Hook for fetching suppliers for a specific money market asset from the backend API.\n *\n * This hook provides access to the list of suppliers for a specific money market asset,\n * with pagination support. The data is automatically fetched and cached using React Query.\n *\n * @param {Object} params - Parameters for fetching asset suppliers\n * @param {string | undefined} params.reserveAddress - The reserve contract address. If undefined, the query will be disabled.\n * @param {string} params.offset - The offset for pagination (number as string)\n * @param {string} params.limit - The limit for pagination (number as string)\n *\n * @returns {UseQueryResult<MoneyMarketAssetSuppliers | undefined>} A query result object containing:\n * - data: The asset suppliers data when available\n * - isLoading: Boolean indicating if the request is in progress\n * - error: Error object if the request failed\n * - refetch: Function to manually trigger a data refresh\n *\n * @example\n * ```typescript\n * const { data: suppliers, isLoading, error } = useMoneyMarketAssetSuppliers({\n * reserveAddress: '0xabc...',\n * offset: '0',\n * limit: '20'\n * });\n *\n * if (isLoading) return <div>Loading suppliers...</div>;\n * if (error) return <div>Error: {error.message}</div>;\n * if (suppliers) {\n * console.log('Total suppliers:', suppliers.total);\n * console.log('Suppliers:', suppliers.suppliers);\n * }\n * ```\n *\n * @remarks\n * - The query is disabled when reserveAddress is undefined or empty\n * - Uses React Query for efficient caching and state management\n * - Automatically handles error states and loading indicators\n * - Supports pagination through offset and limit parameters\n */\nexport const useBackendMoneyMarketAssetSuppliers = (params: {\n reserveAddress: string | undefined;\n offset: string;\n limit: string;\n}): UseQueryResult<MoneyMarketAssetSuppliers | undefined> => {\n const { sodax } = useSodaxContext();\n\n return useQuery({\n queryKey: ['backend', 'moneymarket', 'asset', 'suppliers', params],\n queryFn: async (): Promise<MoneyMarketAssetSuppliers | undefined> => {\n if (!params.reserveAddress || !params.offset || !params.limit) {\n return undefined;\n }\n\n return sodax.backendApiService.getMoneyMarketAssetSuppliers(params.reserveAddress, {\n offset: params.offset,\n limit: params.limit,\n });\n },\n enabled: !!params.reserveAddress && !!params.offset && !!params.limit,\n retry: 3,\n });\n};\n","// packages/dapp-kit/src/hooks/backend/useAllMoneyMarketBorrowers.ts\nimport { useQuery, type UseQueryResult } from '@tanstack/react-query';\nimport type { MoneyMarketBorrowers } from '@sodax/sdk';\nimport { useSodaxContext } from '../shared/useSodaxContext';\n\n/**\n * Hook for fetching all money market borrowers from the backend API.\n *\n * This hook provides access to the list of all borrowers across all money market assets,\n * with pagination support. The data is automatically fetched and cached using React Query.\n *\n * @param {Object} params - Pagination parameters for fetching all borrowers\n * @param {string} params.offset - The offset for pagination (number as string)\n * @param {string} params.limit - The limit for pagination (number as string)\n *\n * @returns {UseQueryResult<MoneyMarketBorrowers | undefined>} A query result object containing:\n * - data: The all borrowers data when available\n * - isLoading: Boolean indicating if the request is in progress\n * - error: Error object if the request failed\n * - refetch: Function to manually trigger a data refresh\n *\n * @example\n * ```typescript\n * const { data: borrowers, isLoading, error } = useAllMoneyMarketBorrowers({\n * offset: '0',\n * limit: '50'\n * });\n *\n * if (isLoading) return <div>Loading borrowers...</div>;\n * if (error) return <div>Error: {error.message}</div>;\n * if (borrowers) {\n * console.log('Total borrowers:', borrowers.total);\n * console.log('Borrowers:', borrowers.borrowers);\n * }\n * ```\n *\n * @remarks\n * - The query is disabled when params are undefined or invalid\n * - Uses React Query for efficient caching and state management\n * - Automatically handles error states and loading indicators\n * - Supports pagination through offset and limit parameters\n * - Returns borrowers across all money market assets\n */\nexport const useBackendAllMoneyMarketBorrowers = (\n params: { offset: string; limit: string } | undefined,\n): UseQueryResult<MoneyMarketBorrowers | undefined> => {\n const { sodax } = useSodaxContext();\n\n return useQuery({\n queryKey: ['backend', 'moneymarket', 'borrowers', 'all', params],\n queryFn: async (): Promise<MoneyMarketBorrowers | undefined> => {\n if (!params || !params.offset || !params.limit) {\n return undefined;\n }\n\n return sodax.backendApiService.getAllMoneyMarketBorrowers(params);\n },\n enabled: !!params && !!params.offset && !!params.limit,\n retry: 3,\n });\n};\n","import { useQuery, type UseQueryResult } from '@tanstack/react-query';\nimport { useSodaxContext } from '../shared/useSodaxContext';\nimport type { SpokeProvider, CreateBridgeIntentParams } from '@sodax/sdk';\n\n/**\n * Hook for checking token allowance for bridge operations.\n *\n * This hook verifies if the user has approved enough tokens for a specific bridge action.\n * It automatically queries and tracks the allowance status.\n *\n * @param {BridgeParams} params - The parameters for the bridge to check allowance for.\n * @param {SpokeProvider} spokeProvider - The spoke provider to use for allowance checks\n *\n * @returns {UseQueryResult<boolean, Error>} A React Query result containing:\n * - data: Boolean indicating if allowance is sufficient\n * - isLoading: Loading state indicator\n * - error: Any error that occurred during the check\n *\n * @example\n * ```typescript\n * const { data: hasAllowed, isLoading } = useBridgeAllowance(params, spokeProvider);\n * ```\n */\nexport function useBridgeAllowance(\n params: CreateBridgeIntentParams | undefined,\n spokeProvider: SpokeProvider | undefined,\n): UseQueryResult<boolean, Error> {\n const { sodax } = useSodaxContext();\n\n return useQuery({\n queryKey: ['bridge-allowance', params],\n queryFn: async () => {\n if (!spokeProvider || !params) {\n return false;\n }\n\n const allowance = await sodax.bridge.isAllowanceValid({\n params,\n spokeProvider,\n });\n\n if (allowance.ok) {\n return allowance.value;\n }\n return false;\n },\n enabled: !!spokeProvider && !!params,\n });\n}\n","import { useSodaxContext } from '../shared/useSodaxContext';\nimport type { CreateBridgeIntentParams, SpokeProvider } from '@sodax/sdk';\nimport { useMutation, useQueryClient } from '@tanstack/react-query';\n\ninterface UseBridgeApproveReturn {\n approve: (params: CreateBridgeIntentParams) => Promise<boolean>;\n isLoading: boolean;\n error: Error | null;\n resetError: () => void;\n}\n\n/**\n * Hook for approving token spending for bridge actions\n * @param spokeProvider The spoke provider instance for the chain\n * @returns Object containing approve function, loading state, error state and reset function\n * @example\n * ```tsx\n * const { approve, isLoading, error } = useBridgeApprove(spokeProvider);\n *\n * // Approve tokens for bridge action\n * await approve({\n * srcChainId: '0x2105.base',\n * srcAsset: '0x...',\n * amount: 1000n,\n * dstChainId: '0x89.polygon',\n * dstAsset: '0x...',\n * recipient: '0x...'\n * });\n * ```\n */\nexport function useBridgeApprove(spokeProvider: SpokeProvider | undefined): UseBridgeApproveReturn {\n const { sodax } = useSodaxContext();\n const queryClient = useQueryClient();\n\n const {\n mutateAsync: approve,\n isPending,\n error,\n reset: resetError,\n } = useMutation({\n mutationFn: async (params: CreateBridgeIntentParams) => {\n if (!spokeProvider) {\n throw new Error('Spoke provider not found');\n }\n\n const allowance = await sodax.bridge.approve({\n params,\n spokeProvider,\n });\n\n if (!allowance.ok) {\n throw new Error('Failed to approve tokens for bridge');\n }\n return true;\n },\n onSuccess: (_, params) => {\n // Invalidate allowance query to refetch the new allowance\n queryClient.invalidateQueries({ queryKey: ['bridge-allowance', params] });\n },\n });\n\n return {\n approve,\n isLoading: isPending,\n error: error,\n resetError,\n };\n}\n","import { useSodaxContext } from '../shared/useSodaxContext';\nimport type { BridgeError, BridgeErrorCode, SpokeTxHash, HubTxHash, Result, CreateBridgeIntentParams } from '@sodax/sdk';\nimport { useMutation, type UseMutationResult } from '@tanstack/react-query';\nimport type { SpokeProvider } from '@sodax/sdk';\n\n/**\n * Hook for executing bridge transactions to transfer tokens between chains.\n * Uses React Query's useMutation for better state management and caching.\n *\n * @param {SpokeProvider} spokeProvider - The spoke provider to use for the bridge\n * @returns {UseMutationResult} Mutation result object containing mutation function and state\n *\n * @example\n * ```typescript\n * const { mutateAsync: bridge, isPending } = useBridge(spokeProvider);\n *\n * const handleBridge = async () => {\n * const result = await bridge({\n * srcChainId: '0x2105.base',\n * srcAsset: '0x...',\n * amount: 1000n,\n * dstChainId: '0x89.polygon',\n * dstAsset: '0x...',\n * recipient: '0x...'\n * });\n *\n * console.log('Bridge transaction hashes:', {\n * spokeTxHash: result.spokeTxHash,\n * hubTxHash: result.hubTxHash\n * });\n * };\n * ```\n */\nexport function useBridge(\n spokeProvider: SpokeProvider | undefined,\n): UseMutationResult<Result<[SpokeTxHash, HubTxHash], BridgeError<BridgeErrorCode>>, Error, CreateBridgeIntentParams> {\n const { sodax } = useSodaxContext();\n\n return useMutation<Result<[SpokeTxHash, HubTxHash], BridgeError<BridgeErrorCode>>, Error, CreateBridgeIntentParams>({\n mutationFn: async (params: CreateBridgeIntentParams) => {\n if (!spokeProvider) {\n throw new Error('Spoke provider not found');\n }\n\n const result = await sodax.bridge.bridge({\n params,\n spokeProvider,\n });\n\n if (!result.ok) {\n throw new Error(`Bridge failed: ${result.error.code}`);\n }\n\n return result;\n },\n });\n}\n","import { useQuery, type UseQueryResult } from '@tanstack/react-query';\nimport { useSodaxContext } from '../shared/useSodaxContext';\nimport type { Result, SpokeChainId, XToken } from '@sodax/sdk';\n\n/**\n * Hook for getting the amount available to be bridged.\n *\n * This hook is used to check if a target chain has enough balance to bridge when bridging.\n * It automatically queries and tracks the available amount to be bridged.\n *\n * @param {SpokeChainId | undefined} chainId - The chain ID to get the balance for\n * @param {string | undefined} token - The token address to get the balance for\n *\n * @returns {UseQueryResult<bigint, Error>} A React Query result containing:\n * - data: The available amount to be bridged (bigint)\n * - error: Any error that occurred during the check\n *\n * @example\n * ```typescript\n * const { data: balance, isLoading } = useSpokeAssetManagerTokenBalance(chainId, tokenAddress);\n *\n * if (balance) {\n * console.log('Asset manager token balance:', balance.toString());\n * }\n * ```\n */\nexport function useGetBridgeableAmount(\n from: XToken | undefined,\n to: XToken | undefined,\n): UseQueryResult<bigint, Error> {\n const { sodax } = useSodaxContext();\n\n return useQuery({\n queryKey: ['spoke-asset-manager-token-balance', from, to],\n queryFn: async () => {\n if (!from || !to) {\n return 0n;\n }\n\n const result = await sodax.bridge.getBridgeableAmount(from, to);\n if (result.ok) {\n return result.value;\n }\n\n console.error('Error getting bridgeable amount:', result.error);\n return 0n;\n },\n enabled: !!from && !!to,\n });\n}\n","import { useQuery, type UseQueryResult } from '@tanstack/react-query';\nimport type { XToken, SpokeChainId } from '@sodax/sdk';\nimport { useSodaxContext } from '../shared';\n\n/**\n/**\n * Hook for retrieving all bridgeable tokens from a source token on one chain to a destination chain.\n *\n * This hook queries and tracks the set of tokens on the destination chain that can be bridged to,\n * given a source chain, destination chain, and source token address.\n *\n * @param {SpokeChainId | undefined} from - The source chain ID\n * @param {SpokeChainId | undefined} to - The destination chain ID\n * @param {string | undefined} token - The source token address\n *\n * @returns {UseQueryResult<XToken[], Error>} A React Query result containing:\n * - data: Array of bridgeable tokens (XToken[]) on the destination chain\n * - error: Any error that occurred during the query\n *\n *\n * @example\n * ```typescript\n * const { data: bridgeableTokens, isLoading } = useGetBridgeableTokens(\n * fromChainId,\n * toChainId,\n * fromTokenAddress\n * );\n *\n * if (bridgeableTokens && bridgeableTokens.length > 0) {\n * bridgeableTokens.forEach(token => {\n * console.log(`Bridgeable token: ${token.symbol} (${token.address}) on chain ${token.xChainId}`);\n * });\n * } else {\n * console.log('No bridgeable tokens found for the selected route.');\n * }\n * ```\n */\nexport function useGetBridgeableTokens(\n from: SpokeChainId | undefined,\n to: SpokeChainId | undefined,\n token: string | undefined,\n): UseQueryResult<XToken[], Error> {\n const { sodax } = useSodaxContext();\n\n return useQuery({\n queryKey: ['bridgeable-tokens', from, to, token],\n queryFn: async () => {\n if (!from || !to || !token) {\n return [];\n }\n\n const result = sodax.bridge.getBridgeableTokens(from, to, token);\n if (result.ok) {\n return result.value;\n }\n\n console.error('Error getting bridgeable tokens:', result.error);\n return [];\n },\n enabled: !!from && !!to && !!token,\n });\n}\n","import type { ReactNode, ReactElement } from 'react';\nimport React from 'react';\n\nimport { Sodax, type SodaxConfig } from '@sodax/sdk';\nimport { SodaxContext } from '@/contexts';\nimport type { RpcConfig } from '@/types';\n\ninterface SodaxProviderProps {\n children: ReactNode;\n testnet?: boolean;\n config?: SodaxConfig;\n rpcConfig: RpcConfig;\n}\n\nexport const SodaxProvider = ({ children, testnet = false, config, rpcConfig }: SodaxProviderProps): ReactElement => {\n const sodax = new Sodax(config);\n\n return <SodaxContext.Provider value={{ sodax, testnet, rpcConfig }}>{children}</SodaxContext.Provider>;\n};\n","import type { ChainId } from '@sodax/types';\n\nimport { hubAssets } from '@sodax/sdk';\n\nexport const getSpokeTokenAddressByVault = (spokeChainId: ChainId, vault: string) => {\n const tokens = hubAssets[spokeChainId];\n const address = Object.keys(tokens).find(\n tokenAddress => tokens[tokenAddress].vault.toLowerCase() === vault.toLowerCase(),\n );\n\n return address;\n};\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/contexts/index.ts","../src/hooks/shared/useSodaxContext.ts","../src/hooks/shared/useEstimateGas.ts","../src/hooks/shared/useDeriveUserWalletAddress.ts","../src/hooks/provider/useHubProvider.ts","../src/hooks/provider/useSpokeProvider.ts","../src/hooks/mm/useBorrow.ts","../src/hooks/mm/useRepay.ts","../src/hooks/mm/useSupply.ts","../src/hooks/mm/useWithdraw.ts","../src/hooks/mm/useUserReservesData.ts","../src/hooks/mm/useReservesData.ts","../src/hooks/mm/useMMAllowance.ts","../src/hooks/mm/useMMApprove.ts","../src/hooks/swap/useQuote.ts","../src/hooks/swap/useSwap.ts","../src/hooks/swap/useStatus.ts","../src/hooks/swap/useSwapAllowance.ts","../src/hooks/swap/useSwapApprove.ts","../src/hooks/swap/useCancelSwap.ts","../src/hooks/backend/useBackendIntentByTxHash.ts","../src/hooks/backend/useBackendIntentByHash.ts","../src/hooks/backend/useBackendOrderbook.ts","../src/hooks/backend/useBackendMoneyMarketPosition.ts","../src/hooks/backend/useBackendAllMoneyMarketAssets.ts","../src/hooks/backend/useBackendMoneyMarketAsset.ts","../src/hooks/backend/useBackendMoneyMarketAssetBorrowers.ts","../src/hooks/backend/useBackendMoneyMarketAssetSuppliers.ts","../src/hooks/backend/useBackendAllMoneyMarketBorrowers.ts","../src/hooks/bridge/useBridgeAllowance.ts","../src/hooks/bridge/useBridgeApprove.ts","../src/hooks/bridge/useBridge.ts","../src/hooks/bridge/useGetBridgeableAmount.ts","../src/hooks/bridge/useGetBridgeableTokens.ts","../src/providers/SodaxProvider.tsx","../src/core/index.ts"],"names":["useMutation","parseUnits","useQuery","useQueryClient","params"],"mappings":";;;;;;AAUO,IAAM,YAAA,GAAe,cAAuC,IAAI,CAAA;ACDhE,IAAM,kBAAkB,MAAwB;AACrD,EAAA,MAAM,OAAA,GAAU,WAAW,YAAY,CAAA;AACvC,EAAA,IAAI,CAAC,OAAA,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js","sourcesContent":["import { createContext } from 'react';\nimport type { Sodax } from '@sodax/sdk';\nimport type { RpcConfig } from '@/types';\n\nexport interface SodaxContextType {\n sodax: Sodax;\n testnet: boolean;\n rpcConfig: RpcConfig;\n}\n\nexport const SodaxContext = createContext<SodaxContextType | null>(null);\n","import { SodaxContext, type SodaxContextType } from '@/contexts';\nimport { useContext } from 'react';\n\n/**\n * Hook to access the Sodax context which provides access to the Sodax SDK instance and chain configuration\n * @throws {Error} If used outside of a SodaxProvider\n * @returns {SodaxContextType} The Sodax context containing SDK instance and configuration\n */\n\nexport const useSodaxContext = (): SodaxContextType => {\n const context = useContext(SodaxContext);\n if (!context) {\n throw new Error('useSodaxContext must be used within a SodaxProvider');\n }\n return context;\n};\n","import { type GetEstimateGasReturnType, type SpokeProvider, SpokeService, type TxReturnType } from '@sodax/sdk';\nimport { useMutation, type UseMutationResult } from '@tanstack/react-query';\n\nexport function useEstimateGas<T extends SpokeProvider = SpokeProvider>(\n spokeProvider: T | undefined,\n): UseMutationResult<GetEstimateGasReturnType<T>, Error, TxReturnType<T, true>> {\n return useMutation<GetEstimateGasReturnType<T>, Error, TxReturnType<T, true>>({\n mutationFn: async (rawTx: TxReturnType<T, true>) => {\n if (!spokeProvider) {\n throw new Error('spokeProvider is not found');\n }\n\n const response = await SpokeService.estimateGas(rawTx, spokeProvider);\n\n return response;\n },\n });\n}\n","// packages/dapp-kit/src/hooks/shared/useDeriveUserWalletAddress.ts\nimport { deriveUserWalletAddress, type SpokeProvider, type EvmHubProvider } from '@sodax/sdk';\nimport { useQuery, type UseQueryResult } from '@tanstack/react-query';\nimport { useSodaxContext } from './useSodaxContext';\nimport type { Address } from 'viem';\n\n/**\n * Hook for deriving user wallet address for hub abstraction.\n *\n * This hook derives the user's abstracted wallet address for the hub chain.\n * If the spoke chain is the same as the hub chain, it returns the original wallet address.\n * Otherwise, it returns the abstracted wallet address for cross-chain operations.\n *\n * @param spokeProvider - The spoke provider instance for the origin chain\n * @param walletAddress - Optional user wallet address on spoke chain. If not provided, will fetch from spokeProvider\n * @returns A React Query result object containing:\n * - data: The derived user wallet address when available\n * - isLoading: Loading state indicator\n * - error: Any error that occurred during derivation\n *\n * @example\n * ```typescript\n * const { data: derivedAddress, isLoading, error } = useDeriveUserWalletAddress(spokeProvider, userAddress);\n * ```\n */\nexport function useDeriveUserWalletAddress(\n spokeProvider: SpokeProvider | undefined,\n walletAddress?: string | undefined,\n): UseQueryResult<Address, Error> {\n const { sodax } = useSodaxContext();\n\n return useQuery({\n queryKey: ['deriveUserWalletAddress', spokeProvider?.chainConfig.chain.id, walletAddress],\n queryFn: async (): Promise<Address> => {\n if (!spokeProvider) {\n throw new Error('Spoke provider is required');\n }\n\n return await deriveUserWalletAddress(spokeProvider, sodax.hubProvider, walletAddress);\n },\n enabled: !!spokeProvider,\n refetchInterval: false, // This is a deterministic operation, no need to refetch\n });\n}\n","import type { EvmHubProvider } from '@sodax/sdk';\nimport { useSodaxContext } from '../shared/useSodaxContext';\n\nexport function useHubProvider(): EvmHubProvider {\n const { sodax } = useSodaxContext();\n\n return sodax.hubProvider;\n}\n","import { useSodaxContext } from '@/index';\nimport {\n EvmSpokeProvider,\n spokeChainConfig,\n type SuiSpokeChainConfig,\n SuiSpokeProvider,\n type EvmSpokeChainConfig,\n IconSpokeProvider,\n type IconSpokeChainConfig,\n InjectiveSpokeProvider,\n type InjectiveSpokeChainConfig,\n StellarSpokeProvider,\n type StellarSpokeChainConfig,\n type SpokeProvider,\n type IWalletProvider,\n SolanaSpokeProvider,\n type SolanaChainConfig,\n SONIC_MAINNET_CHAIN_ID,\n SonicSpokeProvider,\n type SonicSpokeChainConfig,\n} from '@sodax/sdk';\nimport type {\n IEvmWalletProvider,\n IIconWalletProvider,\n ISuiWalletProvider,\n SpokeChainId,\n IInjectiveWalletProvider,\n IStellarWalletProvider,\n ISolanaWalletProvider,\n} from '@sodax/types';\nimport { useMemo } from 'react';\n\n/**\n * Hook to get the appropriate spoke provider based on the chain type.\n * Supports EVM, SUI, ICON and INJECTIVE chains.\n *\n * @param {SpokeChainId | undefined} spokeChainId - The spoke chain ID to get the provider for\n * @param {IWalletProvider | undefined} walletProvider - The wallet provider to use\n * @returns {SpokeProvider | undefined} The appropriate spoke provider instance for the given chain ID, or undefined if invalid/unsupported\n *\n * @example\n * ```tsx\n * // Using a specific SpokeChainId and wallet provider\n * const spokeProvider = useSpokeProvider(spokeChainId, walletProvider);\n * ```\n */\nexport function useSpokeProvider(\n spokeChainId: SpokeChainId | undefined,\n walletProvider?: IWalletProvider | undefined,\n): SpokeProvider | undefined {\n const { rpcConfig } = useSodaxContext();\n const xChainType = spokeChainId ? spokeChainConfig[spokeChainId]?.chain.type : undefined;\n\n const spokeProvider = useMemo(() => {\n if (!walletProvider) return undefined;\n if (!spokeChainId) return undefined;\n if (!xChainType) return undefined;\n if (!rpcConfig) return undefined;\n\n if (xChainType === 'EVM') {\n if (spokeChainId === SONIC_MAINNET_CHAIN_ID) {\n return new SonicSpokeProvider(\n walletProvider as IEvmWalletProvider,\n spokeChainConfig[spokeChainId] as SonicSpokeChainConfig,\n );\n }\n return new EvmSpokeProvider(\n walletProvider as IEvmWalletProvider,\n spokeChainConfig[spokeChainId] as EvmSpokeChainConfig,\n );\n }\n\n if (xChainType === 'SUI') {\n return new SuiSpokeProvider(\n spokeChainConfig[spokeChainId] as SuiSpokeChainConfig,\n walletProvider as ISuiWalletProvider,\n );\n }\n\n if (xChainType === 'ICON') {\n return new IconSpokeProvider(\n walletProvider as IIconWalletProvider,\n spokeChainConfig[spokeChainId] as IconSpokeChainConfig,\n );\n }\n\n if (xChainType === 'INJECTIVE') {\n return new InjectiveSpokeProvider(\n spokeChainConfig[spokeChainId] as InjectiveSpokeChainConfig,\n walletProvider as IInjectiveWalletProvider,\n );\n }\n\n if (xChainType === 'STELLAR') {\n const stellarConfig = spokeChainConfig[spokeChainId] as StellarSpokeChainConfig;\n return new StellarSpokeProvider(\n walletProvider as IStellarWalletProvider,\n stellarConfig,\n rpcConfig.stellar\n ? rpcConfig.stellar\n : {\n horizonRpcUrl: stellarConfig.horizonRpcUrl,\n sorobanRpcUrl: stellarConfig.sorobanRpcUrl,\n },\n );\n }\n\n if (xChainType === 'SOLANA') {\n return new SolanaSpokeProvider(\n walletProvider as ISolanaWalletProvider,\n rpcConfig.solana\n ? ({\n ...spokeChainConfig[spokeChainId],\n rpcUrl: rpcConfig.solana,\n } as SolanaChainConfig)\n : (spokeChainConfig[spokeChainId] as SolanaChainConfig),\n );\n }\n\n return undefined;\n }, [spokeChainId, xChainType, walletProvider, rpcConfig]);\n\n return spokeProvider;\n}\n","import type { XToken } from '@sodax/types';\nimport { useMutation, type UseMutationResult } from '@tanstack/react-query';\nimport { parseUnits } from 'viem';\nimport { useSodaxContext } from '../shared/useSodaxContext';\nimport type { SpokeProvider } from '@sodax/sdk';\ninterface BorrowResponse {\n ok: true;\n value: [string, string];\n}\n\n/**\n * Hook for borrowing tokens from the Sodax money market.\n *\n * This hook provides functionality to borrow tokens from the money market protocol,\n * handling the entire borrow process including transaction creation, submission,\n * and cross-chain communication.\n *\n * @param {XToken} spokeToken - The token to borrow from the spoke chain. Must be an XToken with valid address and chain information.\n * @param {SpokeProvider} spokeProvider - The spoke provider to use for the borrow transaction. Must be a valid SpokeProvider instance.\n *\n * @returns {UseMutationResult<BorrowResponse, Error, string>} A mutation result object with the following properties:\n * - mutateAsync: Function to execute the borrow transaction\n * - isPending: Boolean indicating if a transaction is in progress\n * - error: Error object if the last transaction failed, null otherwise\n *\n * @example\n * ```typescript\n * const { mutateAsync: borrow, isPending, error } = useBorrow(spokeToken);\n * await borrow('100');\n * ```\n *\n * @throws {Error} When:\n * - spokeProvider is not available\n * - Transaction execution fails\n */\nexport function useBorrow(\n spokeToken: XToken,\n spokeProvider: SpokeProvider | undefined,\n): UseMutationResult<BorrowResponse, Error, string> {\n const { sodax } = useSodaxContext();\n\n return useMutation<BorrowResponse, Error, string>({\n mutationFn: async (amount: string) => {\n if (!spokeProvider) {\n throw new Error('spokeProvider is not found');\n }\n\n const response = await sodax.moneyMarket.borrow(\n {\n token: spokeToken.address,\n amount: parseUnits(amount, 18),\n action: 'borrow',\n },\n spokeProvider,\n );\n\n if (!response.ok) {\n throw new Error('Failed to borrow tokens');\n }\n\n console.log('Borrow transaction submitted:', response);\n return response;\n },\n });\n}\n","import type { SpokeProvider } from '@sodax/sdk';\nimport type { XToken } from '@sodax/types';\nimport { useMutation, type UseMutationResult } from '@tanstack/react-query';\nimport { parseUnits } from 'viem';\nimport { useSodaxContext } from '../shared/useSodaxContext';\n\ninterface RepayResponse {\n ok: true;\n value: [string, string];\n}\n\n/**\n * Hook for repaying borrowed tokens to the Sodax money market.\n *\n * This hook provides functionality to repay borrowed tokens back to the money market protocol,\n * handling the entire repayment process including transaction creation, submission,\n * and cross-chain communication.\n *\n * @param {XToken} spokeToken - The token to repay on the spoke chain. Must be an XToken with valid address and chain information.\n * @param {SpokeProvider} spokeProvider - The spoke provider to use for the repay transaction. Must be a valid SpokeProvider instance.\n *\n * @returns {UseMutationResult<RepayResponse, Error, string>} A mutation result object with the following properties:\n * - mutateAsync: Function to execute the repay transaction\n * - isPending: Boolean indicating if a transaction is in progress\n * - error: Error object if the last transaction failed, null otherwise\n *\n * @example\n * ```typescript\n * const { mutateAsync: repay, isPending, error } = useRepay(spokeToken);\n * await repay('100');\n * ```\n *\n * @throws {Error} When:\n * - spokeProvider is not available\n * - Transaction execution fails\n */\nexport function useRepay(\n spokeToken: XToken,\n spokeProvider: SpokeProvider | undefined,\n): UseMutationResult<RepayResponse, Error, string> {\n const { sodax } = useSodaxContext();\n\n return useMutation<RepayResponse, Error, string>({\n mutationFn: async (amount: string) => {\n if (!spokeProvider) {\n throw new Error('spokeProvider is not found');\n }\n\n const response = await sodax.moneyMarket.repay(\n {\n token: spokeToken.address,\n amount: parseUnits(amount, spokeToken.decimals),\n action: 'repay',\n },\n spokeProvider,\n );\n\n if (!response.ok) {\n throw new Error('Failed to repay tokens');\n }\n\n console.log('Repay transaction submitted:', response);\n return response;\n },\n });\n}\n","import type { SpokeProvider } from '@sodax/sdk';\nimport type { XToken } from '@sodax/types';\nimport { useMutation, type UseMutationResult } from '@tanstack/react-query';\nimport { parseUnits } from 'viem';\nimport { useSodaxContext } from '../shared/useSodaxContext';\n\ninterface SupplyResponse {\n ok: true;\n value: [string, string];\n}\n\n/**\n * Hook for supplying tokens to the Sodax money market.\n *\n * This hook provides functionality to supply tokens to the money market protocol,\n * handling the entire supply process including transaction creation, submission,\n * and cross-chain communication.\n *\n * @param {XToken} spokeToken - The token to supply on the spoke chain. Must be an XToken with valid address and chain information.\n * @param {SpokeProvider} spokeProvider - The spoke provider to use for the supply transaction. Must be a valid SpokeProvider instance.\n *\n * @returns {UseMutationResult<SupplyResponse, Error, string>} A mutation result object with the following properties:\n * - mutateAsync: Function to execute the supply transaction\n * - isPending: Boolean indicating if a transaction is in progress\n * - error: Error object if the last transaction failed, null otherwise\n *\n * @example\n * ```typescript\n * const { mutateAsync: supply, isPending, error } = useSupply(spokeToken);\n * await supply('100');\n * ```\n *\n * @throws {Error} When:\n * - spokeProvider is not available\n */\nexport function useSupply(\n spokeToken: XToken,\n spokeProvider: SpokeProvider | undefined,\n): UseMutationResult<SupplyResponse, Error, string> {\n const { sodax } = useSodaxContext();\n\n return useMutation<SupplyResponse, Error, string>({\n mutationFn: async (amount: string) => {\n if (!spokeProvider) {\n throw new Error('spokeProvider is not found');\n }\n\n const response = await sodax.moneyMarket.supply(\n {\n token: spokeToken.address,\n amount: parseUnits(amount, spokeToken.decimals),\n action: 'supply',\n },\n spokeProvider,\n );\n\n if (!response.ok) {\n throw new Error('Failed to supply tokens');\n }\n\n console.log('Supply transaction submitted:', response);\n return response;\n },\n });\n}\n","import type { SpokeProvider } from '@sodax/sdk';\nimport type { XToken } from '@sodax/types';\nimport { useMutation, type UseMutationResult } from '@tanstack/react-query';\nimport { parseUnits } from 'viem';\nimport { useSodaxContext } from '../shared/useSodaxContext';\n\ninterface WithdrawResponse {\n ok: true;\n value: [string, string];\n}\n\n/**\n * Hook for withdrawing supplied tokens from the Sodax money market.\n *\n * This hook provides functionality to withdraw previously supplied tokens from the money market protocol,\n * handling the entire withdrawal process including transaction creation, submission,\n * and cross-chain communication.\n *\n * @param {XToken} spokeToken - The token to withdraw from the spoke chain. Must be an XToken with valid address and chain information.\n * @param {SpokeProvider} spokeProvider - The spoke provider to use for the withdraw transaction. Must be a valid SpokeProvider instance.\n *\n * @returns {UseMutationResult<WithdrawResponse, Error, string>} A mutation result object with the following properties:\n * - mutateAsync: Function to execute the withdraw transaction\n * - isPending: Boolean indicating if a transaction is in progress\n * @example\n * ```typescript\n * const { mutateAsync: withdraw, isPending, error } = useWithdraw(spokeToken);\n * await withdraw('100');\n * ```\n *\n * @throws {Error} When:\n * - spokeProvider is not available\n * - Transaction execution fails\n */\nexport function useWithdraw(\n spokeToken: XToken,\n spokeProvider: SpokeProvider | undefined,\n): UseMutationResult<WithdrawResponse, Error, string> {\n const { sodax } = useSodaxContext();\n\n return useMutation<WithdrawResponse, Error, string>({\n mutationFn: async (amount: string) => {\n if (!spokeProvider) {\n throw new Error('spokeProvider is not found');\n }\n\n const response = await sodax.moneyMarket.withdraw(\n {\n token: spokeToken.address,\n // vault token on hub chain decimals is 18\n amount: parseUnits(amount, 18),\n action: 'withdraw',\n },\n spokeProvider,\n );\n\n if (!response.ok) {\n throw new Error('Failed to withdraw tokens');\n }\n\n console.log('Withdraw transaction submitted:', response);\n return response;\n },\n });\n}\n","import type { SpokeProvider, UserReserveData } from '@sodax/sdk';\nimport { useQuery, type UseQueryResult } from '@tanstack/react-query';\nimport { useSodaxContext } from '../shared/useSodaxContext';\n\n/**\n * Hook for fetching user reserves data from the Sodax money market.\n *\n * This hook provides access to the current state of user reserves in the money market protocol.\n * The data is automatically fetched and cached using React Query.\n *\n * @example\n * ```typescript\n * const { data: userReservesData, isLoading, error } = useUserReservesData(spokeProvider, address);\n * ```\n *\n * @returns A React Query result object containing:\n * - data: The user reserves data when available\n * - isLoading: Loading state indicator\n * - error: Any error that occurred during data fetching\n */\nexport function useUserReservesData(\n spokeProvider: SpokeProvider | undefined,\n address: string | undefined,\n refetchInterval = 5000,\n): UseQueryResult<readonly [readonly UserReserveData[], number], Error> {\n const { sodax } = useSodaxContext();\n\n return useQuery({\n queryKey: ['userReserves', spokeProvider?.chainConfig.chain.id, address],\n queryFn: async () => {\n if (!spokeProvider) {\n throw new Error('Spoke provider or address is not defined');\n }\n\n return await sodax.moneyMarket.data.getUserReservesData(spokeProvider);\n },\n enabled: !!spokeProvider && !!address,\n refetchInterval,\n });\n}\n","import { useQuery } from '@tanstack/react-query';\nimport { useSodaxContext } from '../shared/useSodaxContext';\n/**\n * Hook for fetching reserves data from the Sodax money market.\n *\n * This hook provides access to the current state of all reserves in the money market protocol,\n * including liquidity, interest rates, and other key metrics. The data is automatically\n * fetched and cached using React Query.\n *\n * @example\n * ```typescript\n * const { data: reservesData, isLoading, error } = useReservesData();\n * ```\n *\n * @returns A React Query result object containing:\n * - data: The reserves data when available\n * - isLoading: Loading state indicator\n * - error: Any error that occurred during data fetching\n */\n\nexport function useReservesData() {\n const { sodax } = useSodaxContext();\n\n return useQuery({\n queryKey: ['reservesData'],\n queryFn: async () => {\n return await sodax.moneyMarket.data.getReservesData();\n },\n });\n}\n","import { useQuery, type UseQueryResult } from '@tanstack/react-query';\nimport type { XToken } from '@sodax/types';\nimport { useSodaxContext } from '../shared/useSodaxContext';\nimport { parseUnits } from 'viem';\nimport type { MoneyMarketAction, SpokeProvider } from '@sodax/sdk';\n\n/**\n * Hook for checking token allowance for money market operations.\n *\n * This hook verifies if the user has approved enough tokens for a specific money market action\n * (borrow/repay). It automatically queries and tracks the allowance status.\n *\n * @param {XToken} token - The token to check allowance for. Must be an XToken with valid address and chain information.\n * @param {string} amount - The amount to check allowance for, as a decimal string\n * @param {MoneyMarketAction} action - The money market action to check allowance for ('borrow' or 'repay')\n * @param {SpokeProvider} spokeProvider - The spoke provider to use for allowance checks\n *\n * @returns {UseQueryResult<boolean, Error>} A React Query result containing:\n * - data: Boolean indicating if allowance is sufficient\n * - isLoading: Loading state indicator\n * - error: Any error that occurred during the check\n *\n * @example\n * ```typescript\n * const { data: hasAllowed, isLoading } = useMMAllowance(token, \"100\", \"repay\", provider);\n * ```\n */\nexport function useMMAllowance(\n token: XToken,\n amount: string,\n action: MoneyMarketAction,\n spokeProvider: SpokeProvider | undefined,\n): UseQueryResult<boolean, Error> {\n const { sodax } = useSodaxContext();\n\n return useQuery({\n queryKey: ['allowance', token.address, amount, action],\n queryFn: async () => {\n if (!spokeProvider) throw new Error('Spoke provider is required');\n const allowance = await sodax.moneyMarket.isAllowanceValid(\n {\n token: token.address,\n amount: parseUnits(amount, token.decimals),\n action,\n },\n spokeProvider,\n );\n if (allowance.ok) {\n return allowance.value;\n }\n return false;\n },\n enabled: !!spokeProvider,\n });\n}\n","import { useSodaxContext } from '../shared/useSodaxContext';\nimport type { XToken } from '@sodax/types';\nimport { parseUnits } from 'viem';\nimport { useMutation, useQueryClient } from '@tanstack/react-query';\nimport type { MoneyMarketAction, SpokeProvider } from '@sodax/sdk';\n\ninterface UseApproveReturn {\n approve: ({ amount, action }: { amount: string; action: MoneyMarketAction }) => Promise<boolean>;\n isLoading: boolean;\n error: Error | null;\n resetError: () => void;\n}\n\n/**\n * Hook for approving token spending for money market actions\n * @param token The token to approve spending for\n * @param spokeProvider The spoke provider instance for the chain\n * @returns Object containing approve function, loading state, error state and reset function\n * @example\n * ```tsx\n * const { approve, isLoading, error } = useMMApprove(token, spokeProvider);\n *\n * // Approve tokens for supply action\n * await approve({ amount: \"100\", action: \"supply\" });\n * ```\n */\n\nexport function useMMApprove(token: XToken, spokeProvider: SpokeProvider | undefined): UseApproveReturn {\n const { sodax } = useSodaxContext();\n const queryClient = useQueryClient();\n\n const {\n mutateAsync: approve,\n isPending,\n error,\n reset: resetError,\n } = useMutation({\n mutationFn: async ({ amount, action }: { amount: string; action: MoneyMarketAction }) => {\n if (!spokeProvider) {\n throw new Error('Spoke provider not found');\n }\n const allowance = await sodax.moneyMarket.approve(\n {\n token: token.address,\n amount: parseUnits(amount, token.decimals),\n action,\n },\n spokeProvider,\n );\n if (!allowance.ok) {\n throw new Error('Failed to approve tokens');\n }\n return allowance.ok;\n },\n onSuccess: () => {\n // Invalidate allowance query to refetch the new allowance\n queryClient.invalidateQueries({ queryKey: ['allowance', token.address] });\n },\n });\n\n return {\n approve,\n isLoading: isPending,\n error: error,\n resetError,\n };\n}\n","import type { SolverErrorResponse, SolverIntentQuoteRequest, SolverIntentQuoteResponse, Result } from '@sodax/sdk';\nimport { useSodaxContext } from '../shared/useSodaxContext';\nimport { useQuery, type UseQueryResult } from '@tanstack/react-query';\n\n/**\n * Hook for fetching a quote for an intent-based swap.\n *\n * This hook provides real-time quote data for an intent-based swap.\n *\n * @param {SolverIntentQuoteRequest | undefined} payload - The intent quote request parameters. If undefined, the query will be disabled.\n *\n * @returns {UseQueryResult<Result<SolverIntentQuoteResponse, SolverErrorResponse> | undefined>} A query result object containing:\n * - data: The quote result from the solver\n * - isLoading: Boolean indicating if the quote is being fetched\n * - error: Error object if the quote request failed\n * - refetch: Function to manually trigger a quote refresh\n *\n * @example\n * ```typescript\n * const { data: quote, isLoading } = useQuote({\n * token_src: '0x...',\n * token_src_blockchain_id: '1',\n * token_dst: '0x...',\n * token_dst_blockchain_id: '2',\n * amount: '1000000000000000000',\n * quote_type: 'exact_input',\n * });\n *\n * if (isLoading) return <div>Loading quote...</div>;\n * if (quote) {\n * console.log('Quote received:', quote);\n * }\n * ```\n *\n * @remarks\n * - The quote is automatically refreshed every 3 seconds\n * - The query is disabled when payload is undefined\n * - Uses React Query for efficient caching and state management\n */\nexport const useQuote = (\n payload: SolverIntentQuoteRequest | undefined,\n): UseQueryResult<Result<SolverIntentQuoteResponse, SolverErrorResponse> | undefined> => {\n const { sodax } = useSodaxContext();\n return useQuery({\n queryKey: [payload],\n queryFn: async () => {\n if (!payload) {\n return undefined;\n }\n return sodax.solver.getQuote(payload);\n },\n enabled: !!payload,\n refetchInterval: 3000,\n });\n};\n","import { useSodaxContext } from '../shared/useSodaxContext';\nimport type {\n CreateIntentParams,\n SolverExecutionResponse,\n Result,\n IntentErrorCode,\n Intent,\n IntentError,\n SpokeProvider,\n IntentDeliveryInfo,\n} from '@sodax/sdk';\nimport { useMutation, type UseMutationResult } from '@tanstack/react-query';\n\ntype CreateIntentResult = Result<[SolverExecutionResponse, Intent, IntentDeliveryInfo], IntentError<IntentErrorCode>>;\n\n/**\n * Hook for creating and submitting an swap intent order for cross-chain swaps.\n * Uses React Query's useMutation for better state management and caching.\n *\n * @param {SpokeProvider} spokeProvider - The spoke provider to use for the swap\n * @returns {UseMutationResult} Mutation result object containing mutation function and state\n *\n * @example\n * ```typescript\n * const { mutateAsync: swap, isPending } = useSwap(spokeProvider);\n *\n * const handleSwap = async () => {\n * const result = await swap({\n * token_src: '0x...',\n * token_src_blockchain_id: 'arbitrum',\n * token_dst: '0x...',\n * token_dst_blockchain_id: 'polygon',\n * amount: '1000000000000000000',\n * min_output_amount: '900000000000000000'\n * });\n * };\n * ```\n */\nexport function useSwap(\n spokeProvider: SpokeProvider | undefined,\n): UseMutationResult<CreateIntentResult, Error, CreateIntentParams> {\n const { sodax } = useSodaxContext();\n\n return useMutation<CreateIntentResult, Error, CreateIntentParams>({\n mutationFn: async (params: CreateIntentParams) => {\n if (!spokeProvider) {\n throw new Error('Spoke provider not found');\n }\n return sodax.solver.swap({\n intentParams: params,\n spokeProvider,\n });\n },\n });\n}\n","import type { Hex, SolverErrorResponse, SolverIntentStatusResponse, Result } from '@sodax/sdk';\nimport { useQuery, type UseQueryResult } from '@tanstack/react-query';\nimport { useSodaxContext } from '../shared/useSodaxContext';\n\n/**\n * Hook for monitoring the status of an intent-based swap.\n *\n * This hook provides real-time status updates for an intent-based swap transaction.\n *\n * @param {Hex} intent_tx_hash - The transaction hash of the intent order on the hub chain\n *\n * @returns {UseQueryResult<Result<SolverIntentStatusResponse, SolverErrorResponse> | undefined>} A query result object containing:\n * - data: The status result from the solver\n * - isLoading: Boolean indicating if the status is being fetched\n * - error: Error object if the status request failed\n * - refetch: Function to manually trigger a status refresh\n *\n * @example\n * ```typescript\n * const { data: status, isLoading } = useStatus('0x...');\n *\n * if (isLoading) return <div>Loading status...</div>;\n * if (status?.ok) {\n * console.log('Status:', status.value);\n * }\n * ```\n *\n * @remarks\n * - The status is automatically refreshed every 3 seconds\n * - Uses React Query for efficient caching and state management\n */\n\nexport const useStatus = (\n intent_tx_hash: Hex,\n): UseQueryResult<Result<SolverIntentStatusResponse, SolverErrorResponse> | undefined> => {\n const { sodax } = useSodaxContext();\n return useQuery({\n queryKey: [intent_tx_hash],\n queryFn: async () => {\n return sodax.solver.getStatus({ intent_tx_hash });\n },\n refetchInterval: 3000, // 3s\n });\n};\n","import { useQuery, type UseQueryResult } from '@tanstack/react-query';\nimport { useSodaxContext } from '../shared/useSodaxContext';\nimport type { CreateIntentParams, SpokeProvider } from '@sodax/sdk';\n\n/**\n * Hook for checking token allowance for money market operations.\n *\n * This hook verifies if the user has approved enough tokens for a specific money market action\n * (borrow/repay). It automatically queries and tracks the allowance status.\n *\n * @param {CreateIntentParams} params - The parameters for the intent to check allowance for.\n * @param {SpokeProvider} spokeProvider - The spoke provider to use for allowance checks\n *\n * @returns {UseQueryResult<boolean, Error>} A React Query result containing:\n * - data: Boolean indicating if allowance is sufficient\n * - isLoading: Loading state indicator\n * - error: Any error that occurred during the check\n *\n * @example\n * ```typescript\n * const { data: hasAllowed, isLoading } = useMMAllowance(params, spokeProvider);\n * ```\n */\nexport function useSwapAllowance(\n params: CreateIntentParams | undefined,\n spokeProvider: SpokeProvider | undefined,\n): UseQueryResult<boolean, Error> {\n const { sodax } = useSodaxContext();\n\n return useQuery({\n queryKey: ['allowance', params],\n queryFn: async () => {\n if (!spokeProvider || !params) {\n return false;\n }\n const allowance = await sodax.solver.isAllowanceValid({\n intentParams: params,\n spokeProvider,\n });\n if (allowance.ok) {\n return allowance.value;\n }\n return false;\n },\n enabled: !!spokeProvider && !!params,\n });\n}\n","import { useSodaxContext } from '../shared/useSodaxContext';\nimport { useMutation, useQueryClient } from '@tanstack/react-query';\nimport type { CreateIntentParams, SpokeProvider } from '@sodax/sdk';\n\ninterface UseApproveReturn {\n approve: ({ params }: { params: CreateIntentParams }) => Promise<boolean>;\n isLoading: boolean;\n error: Error | null;\n resetError: () => void;\n}\n\n/**\n * Hook for approving token spending for money market actions\n * @param token The token to approve spending for\n * @param spokeProvider The spoke provider instance for the chain\n * @returns Object containing approve function, loading state, error state and reset function\n * @example\n * ```tsx\n * const { approve, isLoading, error } = useApprove(token, spokeProvider);\n *\n * // Approve tokens for supply action\n * await approve({ amount: \"100\", action: \"supply\" });\n * ```\n */\n\nexport function useSwapApprove(\n params: CreateIntentParams | undefined,\n spokeProvider: SpokeProvider | undefined,\n): UseApproveReturn {\n const { sodax } = useSodaxContext();\n const queryClient = useQueryClient();\n\n const {\n mutateAsync: approve,\n isPending,\n error,\n reset: resetError,\n } = useMutation({\n mutationFn: async ({ params }: { params: CreateIntentParams | undefined }) => {\n if (!spokeProvider) {\n throw new Error('Spoke provider not found');\n }\n if (!params) {\n throw new Error('Swap Params not found');\n }\n\n const allowance = await sodax.solver.approve({\n intentParams: params,\n spokeProvider,\n });\n if (!allowance.ok) {\n throw new Error('Failed to approve input token');\n }\n return allowance.ok;\n },\n onSuccess: () => {\n // Invalidate allowance query to refetch the new allowance\n queryClient.invalidateQueries({ queryKey: ['allowance', params?.inputToken] });\n },\n });\n\n return {\n approve,\n isLoading: isPending,\n error: error,\n resetError,\n };\n}\n","import { useSodaxContext } from '../shared/useSodaxContext';\nimport type { Intent, Result, SpokeProvider, TxReturnType } from '@sodax/sdk';\nimport { useMutation, type UseMutationResult } from '@tanstack/react-query';\n\ntype CancelIntentParams = {\n intent: Intent;\n raw?: boolean;\n};\n\ntype CancelIntentResult = Result<TxReturnType<SpokeProvider, boolean>>;\n\n/**\n * Hook for canceling a swap intent order.\n * Uses React Query's useMutation for better state management and caching.\n *\n * @param {SpokeProvider} spokeProvider - The spoke provider to use for canceling the intent\n * @returns {UseMutationResult} Mutation result object containing mutation function and state\n *\n * @example\n * ```typescript\n * const { mutateAsync: cancelSwap, isPending } = useCancelSwap(spokeProvider);\n *\n * const handleCancelSwap = async () => {\n * const result = await cancelSwap({\n * intent: intentObject,\n * raw: false // optional, defaults to false\n * });\n * };\n * ```\n */\nexport function useCancelSwap(\n spokeProvider: SpokeProvider | undefined,\n): UseMutationResult<CancelIntentResult, Error, CancelIntentParams> {\n const { sodax } = useSodaxContext();\n\n return useMutation<CancelIntentResult, Error, CancelIntentParams>({\n mutationFn: async ({ intent, raw = false }: CancelIntentParams) => {\n if (!spokeProvider) {\n throw new Error('Spoke provider not found');\n }\n return sodax.solver.cancelIntent(intent, spokeProvider, raw);\n },\n });\n}\n","// packages/dapp-kit/src/hooks/backend/useIntentByTxHash.ts\nimport { useQuery, type UseQueryResult } from '@tanstack/react-query';\nimport type { IntentResponse } from '@sodax/sdk';\nimport { useSodaxContext } from '../shared/useSodaxContext';\n\n/**\n * Hook for fetching intent details by transaction hash from the backend API.\n *\n * This hook provides access to intent data associated with a specific transaction hash,\n * including intent details, events, and transaction information. The data is automatically\n * fetched and cached using React Query.\n *\n * @param {string | undefined} txHash - The transaction hash to fetch intent for. If undefined, the query will be disabled.\n *\n * @returns {UseQueryResult<IntentResponse | undefined>} A query result object containing:\n * - data: The intent response data when available\n * - isLoading: Boolean indicating if the request is in progress\n * - error: Error object if the request failed\n * - refetch: Function to manually trigger a data refresh\n *\n * @example\n * ```typescript\n * const { data: intent, isLoading, error } = useIntentByTxHash('0x123...');\n *\n * if (isLoading) return <div>Loading intent...</div>;\n * if (error) return <div>Error: {error.message}</div>;\n * if (intent) {\n * console.log('Intent found:', intent.intentHash);\n * }\n * ```\n *\n * @remarks\n * - The query is disabled when txHash is undefined or empty\n * - Uses React Query for efficient caching and state management\n * - Automatically handles error states and loading indicators\n */\nexport const useBackendIntentByTxHash = (txHash: string | undefined): UseQueryResult<IntentResponse | undefined> => {\n const { sodax } = useSodaxContext();\n\n return useQuery({\n queryKey: ['backend', 'intent', 'txHash', txHash],\n queryFn: async (): Promise<IntentResponse | undefined> => {\n if (!txHash) {\n return undefined;\n }\n\n return sodax.backendApiService.getIntentByTxHash(txHash);\n },\n enabled: !!txHash && txHash.length > 0,\n retry: 3,\n });\n};\n","// packages/dapp-kit/src/hooks/backend/useIntentByHash.ts\nimport { useQuery, type UseQueryResult } from '@tanstack/react-query';\nimport type { IntentResponse } from '@sodax/sdk';\nimport { useSodaxContext } from '../shared/useSodaxContext';\n\n/**\n * Hook for fetching intent details by intent hash from the backend API.\n *\n * This hook provides access to intent data using the intent hash directly,\n * including intent details, events, and transaction information. The data is automatically\n * fetched and cached using React Query.\n *\n * @param {string | undefined} intentHash - The intent hash to fetch intent for. If undefined, the query will be disabled.\n *\n * @returns {UseQueryResult<IntentResponse | undefined>} A query result object containing:\n * - data: The intent response data when available\n * - isLoading: Boolean indicating if the request is in progress\n * - error: Error object if the request failed\n * - refetch: Function to manually trigger a data refresh\n *\n * @example\n * ```typescript\n * const { data: intent, isLoading, error } = useIntentByHash('0xabc...');\n *\n * if (isLoading) return <div>Loading intent...</div>;\n * if (error) return <div>Error: {error.message}</div>;\n * if (intent) {\n * console.log('Intent found:', intent.intentHash);\n * console.log('Open status:', intent.open);\n * }\n * ```\n *\n * @remarks\n * - The query is disabled when intentHash is undefined or empty\n * - Uses React Query for efficient caching and state management\n * - Automatically handles error states and loading indicators\n */\nexport const useBackendIntentByHash = (intentHash: string | undefined): UseQueryResult<IntentResponse | undefined> => {\n const { sodax } = useSodaxContext();\n\n return useQuery({\n queryKey: ['backend', 'intent', 'hash', intentHash],\n queryFn: async (): Promise<IntentResponse | undefined> => {\n if (!intentHash) {\n return undefined;\n }\n\n return sodax.backendApiService.getIntentByHash(intentHash);\n },\n enabled: !!intentHash && intentHash.length > 0,\n retry: 3,\n });\n};\n","// packages/dapp-kit/src/hooks/backend/useOrderbook.ts\nimport { useQuery, type UseQueryResult } from '@tanstack/react-query';\nimport type { OrderbookResponse } from '@sodax/sdk';\nimport { useSodaxContext } from '../shared/useSodaxContext';\n\n/**\n * Hook for fetching the solver orderbook from the backend API.\n *\n * This hook provides access to the solver orderbook data, including intent states\n * and intent data for all available intents. The data is automatically fetched\n * and cached using React Query with pagination support.\n *\n * @param {Object} params - Pagination parameters for the orderbook\n * @param {string} params.offset - The offset for pagination (number as string)\n * @param {string} params.limit - The limit for pagination (number as string)\n *\n * @returns {UseQueryResult<OrderbookResponse | undefined>} A query result object containing:\n * - data: The orderbook response data when available\n * - isLoading: Boolean indicating if the request is in progress\n * - error: Error object if the request failed\n * - refetch: Function to manually trigger a data refresh\n *\n * @example\n * ```typescript\n * const { data: orderbook, isLoading, error } = useOrderbook({\n * offset: '0',\n * limit: '10'\n * });\n *\n * if (isLoading) return <div>Loading orderbook...</div>;\n * if (error) return <div>Error: {error.message}</div>;\n * if (orderbook) {\n * console.log('Total intents:', orderbook.total);\n * console.log('Intents:', orderbook.data);\n * }\n * ```\n *\n * @remarks\n * - The query is disabled when params are undefined or invalid\n * - Uses React Query for efficient caching and state management\n * - Automatically handles error states and loading indicators\n * - Stale time of 30 seconds for real-time orderbook data\n * - Supports pagination through offset and limit parameters\n */\nexport const useBackendOrderbook = (\n params: { offset: string; limit: string } | undefined,\n): UseQueryResult<OrderbookResponse | undefined> => {\n const { sodax } = useSodaxContext();\n\n return useQuery({\n queryKey: ['backend', 'solver', 'orderbook', params],\n queryFn: async (): Promise<OrderbookResponse | undefined> => {\n if (!params || !params.offset || !params.limit) {\n return undefined;\n }\n\n return sodax.backendApiService.getOrderbook(params);\n },\n enabled: !!params && !!params.offset && !!params.limit,\n staleTime: 30 * 1000, // 30 seconds for real-time data\n retry: 3,\n });\n};\n","// packages/dapp-kit/src/hooks/backend/useMoneyMarketPosition.ts\nimport { useQuery, type UseQueryResult } from '@tanstack/react-query';\nimport type { MoneyMarketPosition } from '@sodax/sdk';\nimport { useSodaxContext } from '../shared/useSodaxContext';\n\n/**\n * Hook for fetching money market position for a specific user from the backend API.\n *\n * This hook provides access to a user's money market positions, including their\n * aToken balances, variable debt token balances, and associated reserve information.\n * The data is automatically fetched and cached using React Query.\n *\n * @param {string | undefined} userAddress - The user's wallet address. If undefined, the query will be disabled.\n *\n * @returns {UseQueryResult<MoneyMarketPosition | undefined>} A query result object containing:\n * - data: The money market position data when available\n * - isLoading: Boolean indicating if the request is in progress\n * - error: Error object if the request failed\n * - refetch: Function to manually trigger a data refresh\n *\n * @example\n * ```typescript\n * const { data: position, isLoading, error } = useMoneyMarketPosition('0x123...');\n *\n * if (isLoading) return <div>Loading position...</div>;\n * if (error) return <div>Error: {error.message}</div>;\n * if (position) {\n * console.log('User address:', position.userAddress);\n * console.log('Positions:', position.positions);\n * }\n * ```\n *\n * @remarks\n * - The query is disabled when userAddress is undefined or empty\n * - Uses React Query for efficient caching and state management\n * - Automatically handles error states and loading indicators\n * - Includes user's aToken and debt token balances across all reserves\n */\nexport const useBackendMoneyMarketPosition = (\n userAddress: string | undefined,\n): UseQueryResult<MoneyMarketPosition | undefined> => {\n const { sodax } = useSodaxContext();\n\n return useQuery({\n queryKey: ['backend', 'moneymarket', 'position', userAddress],\n queryFn: async (): Promise<MoneyMarketPosition | undefined> => {\n if (!userAddress) {\n return undefined;\n }\n\n return sodax.backendApiService.getMoneyMarketPosition(userAddress);\n },\n enabled: !!userAddress && userAddress.length > 0,\n retry: 3,\n });\n};\n","// packages/dapp-kit/src/hooks/backend/useAllMoneyMarketAssets.ts\nimport { useQuery, type UseQueryResult } from '@tanstack/react-query';\nimport type { MoneyMarketAsset } from '@sodax/sdk';\nimport { useSodaxContext } from '../shared/useSodaxContext';\n\n/**\n * Hook for fetching all money market assets from the backend API.\n *\n * This hook provides access to all available money market assets, including\n * their reserve information, liquidity rates, borrow rates, and market statistics.\n * The data is automatically fetched and cached using React Query.\n *\n * @returns {UseQueryResult<MoneyMarketAsset[]>} A query result object containing:\n * - data: Array of money market asset data when available\n * - isLoading: Boolean indicating if the request is in progress\n * - error: Error object if the request failed\n * - refetch: Function to manually trigger a data refresh\n *\n * @example\n * ```typescript\n * const { data: assets, isLoading, error } = useAllMoneyMarketAssets();\n *\n * if (isLoading) return <div>Loading assets...</div>;\n * if (error) return <div>Error: {error.message}</div>;\n * if (assets) {\n * console.log('Total assets:', assets.length);\n * assets.forEach(asset => {\n * console.log(`${asset.symbol}: ${asset.liquidityRate} liquidity rate`);\n * });\n * }\n * ```\n *\n * @remarks\n * - Uses React Query for efficient caching and state management\n * - Automatically handles error states and loading indicators\n * - Returns comprehensive asset information including rates and statistics\n * - No parameters required - fetches all available assets\n */\nexport const useBackendAllMoneyMarketAssets = (): UseQueryResult<MoneyMarketAsset[]> => {\n const { sodax } = useSodaxContext();\n\n return useQuery({\n queryKey: ['backend', 'moneymarket', 'assets', 'all'],\n queryFn: async (): Promise<MoneyMarketAsset[]> => {\n return sodax.backendApiService.getAllMoneyMarketAssets();\n },\n retry: 3,\n });\n};\n","// packages/dapp-kit/src/hooks/backend/useMoneyMarketAsset.ts\nimport { useQuery, type UseQueryResult } from '@tanstack/react-query';\nimport type { MoneyMarketAsset } from '@sodax/sdk';\nimport { useSodaxContext } from '../shared/useSodaxContext';\n\n/**\n * Hook for fetching specific money market asset details from the backend API.\n *\n * This hook provides access to detailed information for a specific money market asset,\n * including reserve information, liquidity rates, borrow rates, and market statistics.\n * The data is automatically fetched and cached using React Query.\n *\n * @param {string | undefined} reserveAddress - The reserve contract address. If undefined, the query will be disabled.\n *\n * @returns {UseQueryResult<MoneyMarketAsset | undefined>} A query result object containing:\n * - data: The money market asset data when available\n * - isLoading: Boolean indicating if the request is in progress\n * - error: Error object if the request failed\n * - refetch: Function to manually trigger a data refresh\n *\n * @example\n * ```typescript\n * const { data: asset, isLoading, error } = useMoneyMarketAsset('0xabc...');\n *\n * if (isLoading) return <div>Loading asset...</div>;\n * if (error) return <div>Error: {error.message}</div>;\n * if (asset) {\n * console.log('Asset symbol:', asset.symbol);\n * console.log('Liquidity rate:', asset.liquidityRate);\n * console.log('Variable borrow rate:', asset.variableBorrowRate);\n * }\n * ```\n *\n * @remarks\n * - The query is disabled when reserveAddress is undefined or empty\n * - Uses React Query for efficient caching and state management\n * - Automatically handles error states and loading indicators\n * - Returns comprehensive asset information for the specified reserve\n */\nexport const useBackendMoneyMarketAsset = (\n reserveAddress: string | undefined,\n): UseQueryResult<MoneyMarketAsset | undefined> => {\n const { sodax } = useSodaxContext();\n\n return useQuery({\n queryKey: ['backend', 'moneymarket', 'asset', reserveAddress],\n queryFn: async (): Promise<MoneyMarketAsset | undefined> => {\n if (!reserveAddress) {\n return undefined;\n }\n\n return sodax.backendApiService.getMoneyMarketAsset(reserveAddress);\n },\n enabled: !!reserveAddress && reserveAddress.length > 0,\n retry: 3,\n });\n};\n","// packages/dapp-kit/src/hooks/backend/useMoneyMarketAssetBorrowers.ts\nimport { useQuery, type UseQueryResult } from '@tanstack/react-query';\nimport type { MoneyMarketAssetBorrowers } from '@sodax/sdk';\nimport { useSodaxContext } from '../shared/useSodaxContext';\n\n/**\n * Hook for fetching borrowers for a specific money market asset from the backend API.\n *\n * This hook provides access to the list of borrowers for a specific money market asset,\n * with pagination support. The data is automatically fetched and cached using React Query.\n *\n * @param {Object} params - Parameters for fetching asset borrowers\n * @param {string | undefined} params.reserveAddress - The reserve contract address. If undefined, the query will be disabled.\n * @param {string} params.offset - The offset for pagination (number as string)\n * @param {string} params.limit - The limit for pagination (number as string)\n *\n * @returns {UseQueryResult<MoneyMarketAssetBorrowers | undefined>} A query result object containing:\n * - data: The asset borrowers data when available\n * - isLoading: Boolean indicating if the request is in progress\n * - error: Error object if the request failed\n * - refetch: Function to manually trigger a data refresh\n *\n * @example\n * ```typescript\n * const { data: borrowers, isLoading, error } = useMoneyMarketAssetBorrowers({\n * reserveAddress: '0xabc...',\n * offset: '0',\n * limit: '20'\n * });\n *\n * if (isLoading) return <div>Loading borrowers...</div>;\n * if (error) return <div>Error: {error.message}</div>;\n * if (borrowers) {\n * console.log('Total borrowers:', borrowers.total);\n * console.log('Borrowers:', borrowers.borrowers);\n * }\n * ```\n *\n * @remarks\n * - The query is disabled when reserveAddress is undefined or empty\n * - Uses React Query for efficient caching and state management\n * - Automatically handles error states and loading indicators\n * - Supports pagination through offset and limit parameters\n */\nexport const useBackendMoneyMarketAssetBorrowers = (params: {\n reserveAddress: string | undefined;\n offset: string;\n limit: string;\n}): UseQueryResult<MoneyMarketAssetBorrowers | undefined> => {\n const { sodax } = useSodaxContext();\n\n return useQuery({\n queryKey: ['backend', 'moneymarket', 'asset', 'borrowers', params],\n queryFn: async (): Promise<MoneyMarketAssetBorrowers | undefined> => {\n if (!params.reserveAddress || !params.offset || !params.limit) {\n return undefined;\n }\n\n return sodax.backendApiService.getMoneyMarketAssetBorrowers(params.reserveAddress, {\n offset: params.offset,\n limit: params.limit,\n });\n },\n enabled: !!params.reserveAddress && !!params.offset && !!params.limit,\n retry: 3,\n });\n};\n","// packages/dapp-kit/src/hooks/backend/useMoneyMarketAssetSuppliers.ts\nimport { useQuery, type UseQueryResult } from '@tanstack/react-query';\nimport type { MoneyMarketAssetSuppliers } from '@sodax/sdk';\nimport { useSodaxContext } from '../shared/useSodaxContext';\n\n/**\n * Hook for fetching suppliers for a specific money market asset from the backend API.\n *\n * This hook provides access to the list of suppliers for a specific money market asset,\n * with pagination support. The data is automatically fetched and cached using React Query.\n *\n * @param {Object} params - Parameters for fetching asset suppliers\n * @param {string | undefined} params.reserveAddress - The reserve contract address. If undefined, the query will be disabled.\n * @param {string} params.offset - The offset for pagination (number as string)\n * @param {string} params.limit - The limit for pagination (number as string)\n *\n * @returns {UseQueryResult<MoneyMarketAssetSuppliers | undefined>} A query result object containing:\n * - data: The asset suppliers data when available\n * - isLoading: Boolean indicating if the request is in progress\n * - error: Error object if the request failed\n * - refetch: Function to manually trigger a data refresh\n *\n * @example\n * ```typescript\n * const { data: suppliers, isLoading, error } = useMoneyMarketAssetSuppliers({\n * reserveAddress: '0xabc...',\n * offset: '0',\n * limit: '20'\n * });\n *\n * if (isLoading) return <div>Loading suppliers...</div>;\n * if (error) return <div>Error: {error.message}</div>;\n * if (suppliers) {\n * console.log('Total suppliers:', suppliers.total);\n * console.log('Suppliers:', suppliers.suppliers);\n * }\n * ```\n *\n * @remarks\n * - The query is disabled when reserveAddress is undefined or empty\n * - Uses React Query for efficient caching and state management\n * - Automatically handles error states and loading indicators\n * - Supports pagination through offset and limit parameters\n */\nexport const useBackendMoneyMarketAssetSuppliers = (params: {\n reserveAddress: string | undefined;\n offset: string;\n limit: string;\n}): UseQueryResult<MoneyMarketAssetSuppliers | undefined> => {\n const { sodax } = useSodaxContext();\n\n return useQuery({\n queryKey: ['backend', 'moneymarket', 'asset', 'suppliers', params],\n queryFn: async (): Promise<MoneyMarketAssetSuppliers | undefined> => {\n if (!params.reserveAddress || !params.offset || !params.limit) {\n return undefined;\n }\n\n return sodax.backendApiService.getMoneyMarketAssetSuppliers(params.reserveAddress, {\n offset: params.offset,\n limit: params.limit,\n });\n },\n enabled: !!params.reserveAddress && !!params.offset && !!params.limit,\n retry: 3,\n });\n};\n","// packages/dapp-kit/src/hooks/backend/useAllMoneyMarketBorrowers.ts\nimport { useQuery, type UseQueryResult } from '@tanstack/react-query';\nimport type { MoneyMarketBorrowers } from '@sodax/sdk';\nimport { useSodaxContext } from '../shared/useSodaxContext';\n\n/**\n * Hook for fetching all money market borrowers from the backend API.\n *\n * This hook provides access to the list of all borrowers across all money market assets,\n * with pagination support. The data is automatically fetched and cached using React Query.\n *\n * @param {Object} params - Pagination parameters for fetching all borrowers\n * @param {string} params.offset - The offset for pagination (number as string)\n * @param {string} params.limit - The limit for pagination (number as string)\n *\n * @returns {UseQueryResult<MoneyMarketBorrowers | undefined>} A query result object containing:\n * - data: The all borrowers data when available\n * - isLoading: Boolean indicating if the request is in progress\n * - error: Error object if the request failed\n * - refetch: Function to manually trigger a data refresh\n *\n * @example\n * ```typescript\n * const { data: borrowers, isLoading, error } = useAllMoneyMarketBorrowers({\n * offset: '0',\n * limit: '50'\n * });\n *\n * if (isLoading) return <div>Loading borrowers...</div>;\n * if (error) return <div>Error: {error.message}</div>;\n * if (borrowers) {\n * console.log('Total borrowers:', borrowers.total);\n * console.log('Borrowers:', borrowers.borrowers);\n * }\n * ```\n *\n * @remarks\n * - The query is disabled when params are undefined or invalid\n * - Uses React Query for efficient caching and state management\n * - Automatically handles error states and loading indicators\n * - Supports pagination through offset and limit parameters\n * - Returns borrowers across all money market assets\n */\nexport const useBackendAllMoneyMarketBorrowers = (\n params: { offset: string; limit: string } | undefined,\n): UseQueryResult<MoneyMarketBorrowers | undefined> => {\n const { sodax } = useSodaxContext();\n\n return useQuery({\n queryKey: ['backend', 'moneymarket', 'borrowers', 'all', params],\n queryFn: async (): Promise<MoneyMarketBorrowers | undefined> => {\n if (!params || !params.offset || !params.limit) {\n return undefined;\n }\n\n return sodax.backendApiService.getAllMoneyMarketBorrowers(params);\n },\n enabled: !!params && !!params.offset && !!params.limit,\n retry: 3,\n });\n};\n","import { useQuery, type UseQueryResult } from '@tanstack/react-query';\nimport { useSodaxContext } from '../shared/useSodaxContext';\nimport type { SpokeProvider, CreateBridgeIntentParams } from '@sodax/sdk';\n\n/**\n * Hook for checking token allowance for bridge operations.\n *\n * This hook verifies if the user has approved enough tokens for a specific bridge action.\n * It automatically queries and tracks the allowance status.\n *\n * @param {BridgeParams} params - The parameters for the bridge to check allowance for.\n * @param {SpokeProvider} spokeProvider - The spoke provider to use for allowance checks\n *\n * @returns {UseQueryResult<boolean, Error>} A React Query result containing:\n * - data: Boolean indicating if allowance is sufficient\n * - isLoading: Loading state indicator\n * - error: Any error that occurred during the check\n *\n * @example\n * ```typescript\n * const { data: hasAllowed, isLoading } = useBridgeAllowance(params, spokeProvider);\n * ```\n */\nexport function useBridgeAllowance(\n params: CreateBridgeIntentParams | undefined,\n spokeProvider: SpokeProvider | undefined,\n): UseQueryResult<boolean, Error> {\n const { sodax } = useSodaxContext();\n\n return useQuery({\n queryKey: ['bridge-allowance', params],\n queryFn: async () => {\n if (!spokeProvider || !params) {\n return false;\n }\n\n const allowance = await sodax.bridge.isAllowanceValid({\n params,\n spokeProvider,\n });\n\n if (allowance.ok) {\n return allowance.value;\n }\n return false;\n },\n enabled: !!spokeProvider && !!params,\n });\n}\n","import { useSodaxContext } from '../shared/useSodaxContext';\nimport type { CreateBridgeIntentParams, SpokeProvider } from '@sodax/sdk';\nimport { useMutation, useQueryClient } from '@tanstack/react-query';\n\ninterface UseBridgeApproveReturn {\n approve: (params: CreateBridgeIntentParams) => Promise<boolean>;\n isLoading: boolean;\n error: Error | null;\n resetError: () => void;\n}\n\n/**\n * Hook for approving token spending for bridge actions\n * @param spokeProvider The spoke provider instance for the chain\n * @returns Object containing approve function, loading state, error state and reset function\n * @example\n * ```tsx\n * const { approve, isLoading, error } = useBridgeApprove(spokeProvider);\n *\n * // Approve tokens for bridge action\n * await approve({\n * srcChainId: '0x2105.base',\n * srcAsset: '0x...',\n * amount: 1000n,\n * dstChainId: '0x89.polygon',\n * dstAsset: '0x...',\n * recipient: '0x...'\n * });\n * ```\n */\nexport function useBridgeApprove(spokeProvider: SpokeProvider | undefined): UseBridgeApproveReturn {\n const { sodax } = useSodaxContext();\n const queryClient = useQueryClient();\n\n const {\n mutateAsync: approve,\n isPending,\n error,\n reset: resetError,\n } = useMutation({\n mutationFn: async (params: CreateBridgeIntentParams) => {\n if (!spokeProvider) {\n throw new Error('Spoke provider not found');\n }\n\n const allowance = await sodax.bridge.approve({\n params,\n spokeProvider,\n });\n\n if (!allowance.ok) {\n throw new Error('Failed to approve tokens for bridge');\n }\n return true;\n },\n onSuccess: (_, params) => {\n // Invalidate allowance query to refetch the new allowance\n queryClient.invalidateQueries({ queryKey: ['bridge-allowance', params] });\n },\n });\n\n return {\n approve,\n isLoading: isPending,\n error: error,\n resetError,\n };\n}\n","import { useSodaxContext } from '../shared/useSodaxContext';\nimport type { BridgeError, BridgeErrorCode, SpokeTxHash, HubTxHash, Result, CreateBridgeIntentParams } from '@sodax/sdk';\nimport { useMutation, type UseMutationResult } from '@tanstack/react-query';\nimport type { SpokeProvider } from '@sodax/sdk';\n\n/**\n * Hook for executing bridge transactions to transfer tokens between chains.\n * Uses React Query's useMutation for better state management and caching.\n *\n * @param {SpokeProvider} spokeProvider - The spoke provider to use for the bridge\n * @returns {UseMutationResult} Mutation result object containing mutation function and state\n *\n * @example\n * ```typescript\n * const { mutateAsync: bridge, isPending } = useBridge(spokeProvider);\n *\n * const handleBridge = async () => {\n * const result = await bridge({\n * srcChainId: '0x2105.base',\n * srcAsset: '0x...',\n * amount: 1000n,\n * dstChainId: '0x89.polygon',\n * dstAsset: '0x...',\n * recipient: '0x...'\n * });\n *\n * console.log('Bridge transaction hashes:', {\n * spokeTxHash: result.spokeTxHash,\n * hubTxHash: result.hubTxHash\n * });\n * };\n * ```\n */\nexport function useBridge(\n spokeProvider: SpokeProvider | undefined,\n): UseMutationResult<Result<[SpokeTxHash, HubTxHash], BridgeError<BridgeErrorCode>>, Error, CreateBridgeIntentParams> {\n const { sodax } = useSodaxContext();\n\n return useMutation<Result<[SpokeTxHash, HubTxHash], BridgeError<BridgeErrorCode>>, Error, CreateBridgeIntentParams>({\n mutationFn: async (params: CreateBridgeIntentParams) => {\n if (!spokeProvider) {\n throw new Error('Spoke provider not found');\n }\n\n const result = await sodax.bridge.bridge({\n params,\n spokeProvider,\n });\n\n if (!result.ok) {\n throw new Error(`Bridge failed: ${result.error.code}`);\n }\n\n return result;\n },\n });\n}\n","import { useQuery, type UseQueryResult } from '@tanstack/react-query';\nimport { useSodaxContext } from '../shared/useSodaxContext';\nimport type { Result, SpokeChainId, XToken } from '@sodax/sdk';\n\n/**\n * Hook for getting the amount available to be bridged.\n *\n * This hook is used to check if a target chain has enough balance to bridge when bridging.\n * It automatically queries and tracks the available amount to be bridged.\n *\n * @param {SpokeChainId | undefined} chainId - The chain ID to get the balance for\n * @param {string | undefined} token - The token address to get the balance for\n *\n * @returns {UseQueryResult<bigint, Error>} A React Query result containing:\n * - data: The available amount to be bridged (bigint)\n * - error: Any error that occurred during the check\n *\n * @example\n * ```typescript\n * const { data: balance, isLoading } = useSpokeAssetManagerTokenBalance(chainId, tokenAddress);\n *\n * if (balance) {\n * console.log('Asset manager token balance:', balance.toString());\n * }\n * ```\n */\nexport function useGetBridgeableAmount(\n from: XToken | undefined,\n to: XToken | undefined,\n): UseQueryResult<bigint, Error> {\n const { sodax } = useSodaxContext();\n\n return useQuery({\n queryKey: ['spoke-asset-manager-token-balance', from, to],\n queryFn: async () => {\n if (!from || !to) {\n return 0n;\n }\n\n const result = await sodax.bridge.getBridgeableAmount(from, to);\n if (result.ok) {\n return result.value;\n }\n\n console.error('Error getting bridgeable amount:', result.error);\n return 0n;\n },\n enabled: !!from && !!to,\n });\n}\n","import { useQuery, type UseQueryResult } from '@tanstack/react-query';\nimport type { XToken, SpokeChainId } from '@sodax/sdk';\nimport { useSodaxContext } from '../shared';\n\n/**\n/**\n * Hook for retrieving all bridgeable tokens from a source token on one chain to a destination chain.\n *\n * This hook queries and tracks the set of tokens on the destination chain that can be bridged to,\n * given a source chain, destination chain, and source token address.\n *\n * @param {SpokeChainId | undefined} from - The source chain ID\n * @param {SpokeChainId | undefined} to - The destination chain ID\n * @param {string | undefined} token - The source token address\n *\n * @returns {UseQueryResult<XToken[], Error>} A React Query result containing:\n * - data: Array of bridgeable tokens (XToken[]) on the destination chain\n * - error: Any error that occurred during the query\n *\n *\n * @example\n * ```typescript\n * const { data: bridgeableTokens, isLoading } = useGetBridgeableTokens(\n * fromChainId,\n * toChainId,\n * fromTokenAddress\n * );\n *\n * if (bridgeableTokens && bridgeableTokens.length > 0) {\n * bridgeableTokens.forEach(token => {\n * console.log(`Bridgeable token: ${token.symbol} (${token.address}) on chain ${token.xChainId}`);\n * });\n * } else {\n * console.log('No bridgeable tokens found for the selected route.');\n * }\n * ```\n */\nexport function useGetBridgeableTokens(\n from: SpokeChainId | undefined,\n to: SpokeChainId | undefined,\n token: string | undefined,\n): UseQueryResult<XToken[], Error> {\n const { sodax } = useSodaxContext();\n\n return useQuery({\n queryKey: ['bridgeable-tokens', from, to, token],\n queryFn: async () => {\n if (!from || !to || !token) {\n return [];\n }\n\n const result = sodax.bridge.getBridgeableTokens(from, to, token);\n if (result.ok) {\n return result.value;\n }\n\n console.error('Error getting bridgeable tokens:', result.error);\n return [];\n },\n enabled: !!from && !!to && !!token,\n });\n}\n","import type { ReactNode, ReactElement } from 'react';\nimport React from 'react';\n\nimport { Sodax, type SodaxConfig } from '@sodax/sdk';\nimport { SodaxContext } from '@/contexts';\nimport type { RpcConfig } from '@/types';\n\ninterface SodaxProviderProps {\n children: ReactNode;\n testnet?: boolean;\n config?: SodaxConfig;\n rpcConfig: RpcConfig;\n}\n\nexport const SodaxProvider = ({ children, testnet = false, config, rpcConfig }: SodaxProviderProps): ReactElement => {\n const sodax = new Sodax(config);\n\n return <SodaxContext.Provider value={{ sodax, testnet, rpcConfig }}>{children}</SodaxContext.Provider>;\n};\n","import type { ChainId } from '@sodax/types';\n\nimport { hubAssets } from '@sodax/sdk';\n\nexport const getSpokeTokenAddressByVault = (spokeChainId: ChainId, vault: string) => {\n const tokens = hubAssets[spokeChainId];\n const address = Object.keys(tokens).find(\n tokenAddress => tokens[tokenAddress].vault.toLowerCase() === vault.toLowerCase(),\n );\n\n return address;\n};\n"]}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sodax/dapp-kit",
|
|
3
3
|
"license": "MIT",
|
|
4
|
-
"version": "0.0.1-rc.
|
|
4
|
+
"version": "0.0.1-rc.27",
|
|
5
5
|
"description": "dapp-kit of New World",
|
|
6
6
|
"main": "dist/index.js",
|
|
7
7
|
"types": "dist/index.d.ts",
|
|
@@ -15,12 +15,12 @@
|
|
|
15
15
|
"url": "https://github.com/icon-project/sodax-frontend"
|
|
16
16
|
},
|
|
17
17
|
"dependencies": {
|
|
18
|
-
"viem": "
|
|
19
|
-
"@sodax/sdk": "0.0.1-rc.
|
|
20
|
-
"@sodax/types": "0.0.1-rc.
|
|
18
|
+
"viem": "2.29.2",
|
|
19
|
+
"@sodax/sdk": "0.0.1-rc.37",
|
|
20
|
+
"@sodax/types": "0.0.1-rc.16"
|
|
21
21
|
},
|
|
22
22
|
"devDependencies": {
|
|
23
|
-
"@types/react": "
|
|
23
|
+
"@types/react": "18.3.1",
|
|
24
24
|
"knip": "5.30.5",
|
|
25
25
|
"tsup": "^8.4.0",
|
|
26
26
|
"typescript": "5.5.4"
|