@sodax/dapp-kit 1.0.0-rc.6 → 1.0.0-rc.8
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/dist/index.d.mts +31 -11
- package/dist/index.d.ts +31 -11
- package/dist/index.js +13 -9
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +14 -10
- package/dist/index.mjs.map +1 -1
- package/package.json +3 -3
- package/src/hooks/backend/useBackendIntentByTxHash.ts +11 -6
- package/src/hooks/mm/index.ts +2 -1
- package/src/index.ts +0 -1
- package/src/core/index.ts +0 -12
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/shared/useStellarTrustlineCheck.ts","../src/hooks/shared/useRequestTrustline.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/mm/useAToken.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/hooks/staking/useStake.ts","../src/hooks/staking/useStakeApprove.ts","../src/hooks/staking/useStakeAllowance.ts","../src/hooks/staking/useUnstake.ts","../src/hooks/staking/useClaim.ts","../src/hooks/staking/useCancelUnstake.ts","../src/hooks/staking/useStakingInfo.ts","../src/hooks/staking/useUnstakingInfoWithPenalty.ts","../src/hooks/staking/useStakingConfig.ts","../src/hooks/staking/useStakeRatio.ts","../src/hooks/staking/useInstantUnstakeRatio.ts","../src/hooks/staking/useConvertedAssets.ts","../src/hooks/staking/useInstantUnstake.ts","../src/hooks/staking/useUnstakeAllowance.ts","../src/hooks/staking/useUnstakeApprove.ts","../src/hooks/staking/useUnstakingInfo.ts","../src/hooks/staking/useInstantUnstakeApprove.ts","../src/hooks/staking/useInstantUnstakeAllowance.ts","../src/hooks/migrate/types.ts","../src/hooks/migrate/useMigrate.tsx","../src/hooks/migrate/useMigrationAllowance.tsx","../src/hooks/migrate/useMigrationApprove.tsx","../src/providers/SodaxProvider.tsx","../src/core/index.ts"],"names":["useQuery","token","StellarSpokeProvider","error","StellarSpokeService","useMutation","parseUnits","useQueryClient","useMemo","params","spokeChainConfig","result","ICON_MAINNET_CHAIN_ID","useState","useCallback"],"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,EAAS;AACZ,IAAA,MAAM,IAAI,MAAM,qDAAqD,CAAA;AAAA,EACvE;AACA,EAAA,OAAO,OAAA;AACT;ACZO,SAAS,eACd,aAAA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,EAAA,MAAM,MAAA,GAAS,UAAU,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.mjs","sourcesContent":["import { createContext } from 'react';\nimport type { Sodax } from '@sodax/sdk';\nimport type { RpcConfig } from '@sodax/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 } 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 { STELLAR_MAINNET_CHAIN_ID, StellarSpokeProvider, StellarSpokeService } from '@sodax/sdk';\nimport type { SpokeChainId, SpokeProvider } from '@sodax/sdk';\nimport { useQuery, type UseQueryResult } from '@tanstack/react-query';\n\n/**\n * React hook to check if a Stellar account has a sufficient trustline for a given token and amount.\n *\n * This hook queries the Stellar network (via the provided SpokeProvider) to determine\n * whether the account has established a trustline for the specified token and if the trustline\n * is sufficient for the intended amount. It is useful for gating UI actions that require\n * a trustline to be present and funded.\n *\n * @template T - The type of SpokeProvider, defaults to SpokeProvider.\n * @param {string | undefined} token - The Stellar asset code or token address to check the trustline for.\n * @param {bigint | undefined} amount - The minimum amount required for the trustline.\n * @param {T | undefined} spokeProvider - The provider instance for interacting with the Stellar network.\n * @param {SpokeChainId | undefined} chainId - The chain ID to determine if the check should be performed (only on Stellar mainnet).\n * @returns {UseQueryResult<boolean, Error>} A React Query result object containing:\n * - `data`: `true` if the trustline exists and is sufficient, `false` otherwise.\n * - `error`: Any error encountered during the check.\n * - `isLoading`: Whether the query is in progress.\n * - Other React Query state.\n *\n * @example\n * ```tsx\n * import { useStellarTrustlineCheck } from '@sodax/dapp-kit';\n *\n * const { data: hasTrustline, isLoading, error } = useStellarTrustlineCheck(\n * 'USDC-G...TOKEN',\n * 10000000n,\n * stellarProvider,\n * 'stellar'\n * );\n *\n * if (isLoading) return <span>Checking trustline...</span>;\n * if (error) return <span>Error: {error.message}</span>;\n * if (!hasTrustline) return <span>Trustline not established or insufficient.</span>;\n * return <span>Trustline is sufficient!</span>;\n * ```\n */\n\nexport function useStellarTrustlineCheck<T extends SpokeProvider = SpokeProvider>(\n token: string | undefined,\n amount: bigint | undefined,\n spokeProvider: T | undefined,\n chainId: SpokeChainId | undefined,\n): UseQueryResult<boolean, Error> {\n return useQuery({\n queryKey: ['stellar-trustline-check', token],\n queryFn: async () => {\n if (chainId !== STELLAR_MAINNET_CHAIN_ID) {\n return true;\n }\n if (!spokeProvider || !token || !amount || !(spokeProvider instanceof StellarSpokeProvider)) {\n console.error(\n 'Spoke provider, token or amount not found. Details: spokeProvider:',\n spokeProvider,\n 'token:',\n token,\n 'amount:',\n amount,\n );\n return false;\n }\n const response = await StellarSpokeService.hasSufficientTrustline(token, amount, spokeProvider);\n\n return response;\n },\n enabled: !!spokeProvider && !!token && !!amount,\n });\n}\n","import { type SpokeProvider, StellarSpokeProvider, StellarSpokeService, type TxReturnType } from '@sodax/sdk';\nimport { useQueryClient } from '@tanstack/react-query';\nimport { useCallback, useState } from 'react';\n\n/**\n * React hook to request a Stellar trustline for a given token and amount.\n *\n * This hook provides a callback function for requesting a trustline on the Stellar network\n * using the provided SpokeProvider. It is intended for use with StellarSpokeProvider\n * and will throw if used with a non-Stellar provider. Upon success, it invalidates\n * the trustline check query to ensure UI reflects the updated trustline state.\n *\n * @template T - The type of SpokeProvider, defaults to SpokeProvider.\n * @param {string | undefined} token - The Stellar asset code or token address for which to request a trustline.\n * @returns {Object} An object containing:\n * - `requestTrustline`: Function to trigger the trustline request.\n * - `isLoading`: Whether the request is in progress.\n * - `isRequested`: Whether a trustline has been successfully requested.\n * - `error`: Any error encountered during the request.\n * - `data`: The transaction result if successful.\n *\n * @example\n * ```tsx\n * import { useRequestTrustline } from '@sodax/dapp-kit';\n *\n * const { requestTrustline, isLoading, isRequested, error, data } = useRequestTrustline('USDC-G...TOKEN');\n *\n * // To request a trustline:\n * await requestTrustline({\n * token: 'USDC-G...TOKEN',\n * amount: 10000000n,\n * spokeProvider: stellarProvider,\n * });\n *\n * if (isLoading) return <span>Requesting trustline...</span>;\n * if (error) return <span>Error: {error.message}</span>;\n * if (isRequested) return <span>Trustline requested! Tx: {data?.txHash}</span>;\n * ```\n */\n\nexport function useRequestTrustline<T extends SpokeProvider = SpokeProvider>(\n token: string | undefined,\n): {\n requestTrustline: (params: {\n token: string;\n amount: bigint;\n spokeProvider: T;\n }) => Promise<TxReturnType<StellarSpokeProvider, false>>;\n isLoading: boolean;\n isRequested: boolean;\n error: Error | null;\n data: TxReturnType<StellarSpokeProvider, false> | null;\n} {\n const queryClient = useQueryClient();\n const [isLoading, setIsLoading] = useState<boolean>(false);\n const [isRequested, setIsRequested] = useState<boolean>(false);\n const [error, setError] = useState<Error | null>(null);\n const [data, setData] = useState<TxReturnType<StellarSpokeProvider, false> | null>(null);\n\n const requestTrustline = useCallback(\n async ({\n token,\n amount,\n spokeProvider,\n }: {\n token: string;\n amount: bigint;\n spokeProvider: T;\n }): Promise<TxReturnType<StellarSpokeProvider, false>> => {\n if (!spokeProvider || !token || !amount || !(spokeProvider instanceof StellarSpokeProvider)) {\n const error = new Error('Spoke provider, token or amount not found');\n setError(error);\n throw error;\n }\n\n setIsLoading(true);\n setError(null);\n\n try {\n const result = await StellarSpokeService.requestTrustline(token, amount, spokeProvider);\n setData(result);\n setIsRequested(true);\n queryClient.invalidateQueries({ queryKey: ['stellar-trustline-check', token] });\n return result;\n } catch (err) {\n const error = err instanceof Error ? err : new Error('Unknown error occurred');\n setError(error);\n throw error;\n } finally {\n setIsLoading(false);\n }\n },\n [queryClient],\n );\n\n return {\n requestTrustline,\n isLoading,\n isRequested,\n error,\n data,\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 actionBasedDecimals = action === 'withdraw' || action === 'borrow' ? 18 : token.decimals; // withdraw and borrow actions are in aToken decimals\n const allowance = await sodax.moneyMarket.isAllowanceValid(\n {\n token: token.address,\n amount: parseUnits(amount, actionBasedDecimals),\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 actionBasedDecimals = action === 'withdraw' || action === 'borrow' ? 18 : token.decimals; // withdraw and borrow actions are in aToken decimals\n const allowance = await sodax.moneyMarket.approve(\n {\n token: token.address,\n amount: parseUnits(amount, actionBasedDecimals),\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 { Address, XToken } from '@sodax/sdk';\nimport { useQuery, type UseQueryResult } from '@tanstack/react-query';\nimport { useSodaxContext } from '../shared/useSodaxContext';\n\n/**\n * React hook for fetching an AToken's ERC20 metadata from the Sodax money market.\n *\n * Fetches and caches the metadata (name, symbol, decimals, address) for a given aToken address and chain using React Query.\n * This metadata is typically required for rendering balances and labels in UI components.\n *\n * @param {Address | undefined} aToken - The aToken contract address to look up. Should be an EVM address.\n * @param {ChainId | undefined} chainId - The EVM chain ID for the aToken.\n *\n * @example\n * ```typescript\n * const { data: aToken, isLoading, error } = useAToken(aTokenAddress, chainId);\n * if (aToken) {\n * console.log(aToken.symbol); // 'aETH'\n * }\n * ```\n *\n * @returns {UseQueryResult<Erc20Token, Error>} A React Query result object containing:\n * - data: The aToken ERC20 metadata when available.\n * - isLoading: Loading state indicator.\n * - error: Any error that occurred during data fetching.\n */\nexport function useAToken(\n aToken: Address | undefined,\n): UseQueryResult<XToken, Error> {\n const { sodax } = useSodaxContext();\n\n return useQuery({\n queryKey: ['aToken', sodax.hubProvider.chainConfig.chain.id, aToken],\n queryFn: async () => {\n if (!aToken) {\n throw new Error('aToken address or hub provider is not defined');\n }\n\n const aTokenData = await sodax.moneyMarket.data.getATokenData(aToken);\n return {\n ...aTokenData,\n xChainId: sodax.hubProvider.chainConfig.chain.id,\n };\n },\n enabled: !!aToken,\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';\nimport { useMemo } from 'react';\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 \n // Create a serializable query key by converting BigInt to string\n const queryKey = useMemo(() => {\n if (!payload) return ['quote', undefined];\n return [\n 'quote',\n {\n ...payload,\n amount: payload.amount.toString(),\n },\n ];\n }, [payload]);\n\n return useQuery({\n queryKey,\n queryFn: async () => {\n if (!payload) {\n return undefined;\n }\n return sodax.swap.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, useQueryClient } 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 const queryClient = useQueryClient();\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.swap.swap({\n intentParams: params,\n spokeProvider,\n });\n },\n onSuccess: () => {\n // Invalidate balance queries to refresh both source and destination token balances\n queryClient.invalidateQueries({ queryKey: ['xBalances'] });\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.swap.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.swap.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 refetchInterval: 2000,\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.swap.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] });\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.swap.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.backendApi.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.backendApi.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.backendApi.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.backendApi.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.backendApi.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.backendApi.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.backendApi.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.backendApi.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.backendApi.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 { 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","// packages/dapp-kit/src/hooks/staking/useStake.ts\nimport { useSodaxContext } from '../shared/useSodaxContext';\nimport type { StakeParams, SpokeTxHash, HubTxHash, SpokeProvider } from '@sodax/sdk';\nimport { useMutation, type UseMutationResult } from '@tanstack/react-query';\n\n/**\n * Hook for executing stake transactions to stake SODA tokens and receive xSODA shares.\n * Uses React Query's useMutation for better state management and caching.\n *\n * @param {SpokeProvider | undefined} spokeProvider - The spoke provider to use for the stake\n * @returns {UseMutationResult<[SpokeTxHash, HubTxHash], Error, StakeParams>} Mutation result object containing mutation function and state\n *\n * @example\n * ```typescript\n * const { mutateAsync: stake, isPending } = useStake(spokeProvider);\n *\n * const handleStake = async () => {\n * const result = await stake({\n * amount: 1000000000000000000n, // 1 SODA\n * account: '0x...'\n * });\n *\n * console.log('Stake successful:', result);\n * };\n * ```\n */\nexport function useStake(\n spokeProvider: SpokeProvider | undefined,\n): UseMutationResult<[SpokeTxHash, HubTxHash], Error, StakeParams> {\n const { sodax } = useSodaxContext();\n\n return useMutation<[SpokeTxHash, HubTxHash], Error, StakeParams>({\n mutationFn: async (params: StakeParams) => {\n if (!spokeProvider) {\n throw new Error('Spoke provider not found');\n }\n\n const result = await sodax.staking.stake(params, spokeProvider);\n\n if (!result.ok) {\n throw new Error(`Stake failed: ${result.error.code}`);\n }\n\n return result.value;\n },\n });\n}\n","// packages/dapp-kit/src/hooks/staking/useStakeApprove.ts\nimport { useSodaxContext } from '../shared/useSodaxContext';\nimport type { StakeParams, TxReturnType, SpokeProvider } from '@sodax/sdk';\nimport { useMutation, type UseMutationResult } from '@tanstack/react-query';\n\n/**\n * Hook for approving SODA token spending for staking operations.\n * Uses React Query's useMutation for better state management and caching.\n *\n * @param {SpokeProvider | undefined} spokeProvider - The spoke provider to use for the approval\n * @returns {UseMutationResult<TxReturnType<SpokeProvider, false>, Error, Omit<StakeParams, 'action'>>} Mutation result object containing mutation function and state\n *\n * @example\n * ```typescript\n * const { mutateAsync: approve, isPending } = useStakeApprove(spokeProvider);\n *\n * const handleApprove = async () => {\n * const result = await approve({\n * amount: 1000000000000000000n, // 1 SODA\n * account: '0x...'\n * });\n *\n * console.log('Approval successful:', result);\n * };\n * ```\n */\nexport function useStakeApprove(\n spokeProvider: SpokeProvider | undefined,\n): UseMutationResult<TxReturnType<SpokeProvider, false>, Error, Omit<StakeParams, 'action'>> {\n const { sodax } = useSodaxContext();\n\n return useMutation<TxReturnType<SpokeProvider, false>, Error, Omit<StakeParams, 'action'>>({\n mutationFn: async (params: Omit<StakeParams, 'action'>) => {\n if (!spokeProvider) {\n throw new Error('Spoke provider not found');\n }\n\n const result = await sodax.staking.approve({\n params: { ...params, action: 'stake' },\n spokeProvider,\n });\n\n if (!result.ok) {\n throw new Error(`Stake approval failed: ${result.error.code}`);\n }\n\n return result.value;\n },\n });\n}\n","// packages/dapp-kit/src/hooks/staking/useStakeAllowance.ts\nimport { useSodaxContext } from '../shared/useSodaxContext';\nimport type { StakeParams, SpokeProvider } from '@sodax/sdk';\nimport { useQuery, type UseQueryResult } from '@tanstack/react-query';\n\n/**\n * Hook for checking SODA token allowance for staking operations.\n * Uses React Query for efficient caching and state management.\n *\n * @param {Omit<StakeParams, 'action'> | undefined} params - The staking parameters. If undefined, the query will be disabled.\n * @param {SpokeProvider | undefined} spokeProvider - The spoke provider to use for the allowance check\n * @returns {UseQueryResult<boolean, Error>} Query result object containing allowance data and state\n *\n * @example\n * ```typescript\n * const { data: hasAllowed, isLoading } = useStakeAllowance(\n * {\n * amount: 1000000000000000000n, // 1 SODA\n * account: '0x...'\n * },\n * spokeProvider\n * );\n *\n * if (isLoading) return <div>Checking allowance...</div>;\n * if (hasAllowed) {\n * console.log('Sufficient allowance for staking');\n * }\n * ```\n */\nexport function useStakeAllowance(\n params: Omit<StakeParams, 'action'> | undefined,\n spokeProvider: SpokeProvider | undefined,\n): UseQueryResult<boolean, Error> {\n const { sodax } = useSodaxContext();\n\n return useQuery({\n queryKey: ['soda', 'stakeAllowance', params, spokeProvider?.chainConfig.chain.id],\n queryFn: async () => {\n if (!params || !spokeProvider) {\n return false;\n }\n\n const result = await sodax.staking.isAllowanceValid({\n params: { ...params, action: 'stake' },\n spokeProvider,\n });\n\n if (!result.ok) {\n throw new Error(`Allowance check failed: ${result.error.code}`);\n }\n\n return result.value;\n },\n enabled: !!params && !!spokeProvider,\n refetchInterval: 5000, // Refetch every 5 seconds\n });\n}\n","// packages/dapp-kit/src/hooks/staking/useUnstake.ts\nimport { useSodaxContext } from '../shared/useSodaxContext';\nimport type { UnstakeParams, SpokeTxHash, HubTxHash, SpokeProvider } from '@sodax/sdk';\nimport { useMutation, useQueryClient, type UseMutationResult } from '@tanstack/react-query';\n\n/**\n * Hook for executing unstake transactions to unstake xSODA shares.\n * Uses React Query's useMutation for better state management and caching.\n *\n * @param {SpokeProvider | undefined} spokeProvider - The spoke provider to use for the unstake\n * @returns {UseMutationResult<[SpokeTxHash, HubTxHash], Error, Omit<UnstakeParams, 'action'>>} Mutation result object containing mutation function and state\n *\n * @example\n * ```typescript\n * const { mutateAsync: unstake, isPending } = useUnstake(spokeProvider);\n *\n * const handleUnstake = async () => {\n * const result = await unstake({\n * amount: 1000000000000000000n, // 1 xSODA\n * account: '0x...'\n * });\n *\n * console.log('Unstake successful:', result);\n * };\n * ```\n */\nexport function useUnstake(\n spokeProvider: SpokeProvider | undefined,\n): UseMutationResult<[SpokeTxHash, HubTxHash], Error, Omit<UnstakeParams, 'action'>> {\n const { sodax } = useSodaxContext();\n const queryClient = useQueryClient();\n\n return useMutation<[SpokeTxHash, HubTxHash], Error, Omit<UnstakeParams, 'action'>>({\n mutationFn: async (params: Omit<UnstakeParams, 'action'>) => {\n if (!spokeProvider) {\n throw new Error('Spoke provider not found');\n }\n\n const result = await sodax.staking.unstake({ ...params, action: 'unstake' }, spokeProvider);\n\n if (!result.ok) {\n throw new Error(`Unstake failed: ${result.error.code}`);\n }\n\n return result.value;\n },\n onSuccess: () => {\n // Invalidate relevant queries to refresh data\n queryClient.invalidateQueries({ queryKey: ['stakingInfo'] });\n queryClient.invalidateQueries({ queryKey: ['unstakingInfo'] });\n queryClient.invalidateQueries({ queryKey: ['unstakingInfoWithPenalty'] });\n },\n });\n}\n","// packages/dapp-kit/src/hooks/staking/useClaim.ts\nimport { useSodaxContext } from '../shared/useSodaxContext';\nimport type { ClaimParams, SpokeTxHash, HubTxHash, SpokeProvider } from '@sodax/sdk';\nimport { useMutation, type UseMutationResult } from '@tanstack/react-query';\n\n/**\n * Hook for executing claim transactions to claim unstaked SODA tokens after the unstaking period.\n * Uses React Query's useMutation for better state management and caching.\n *\n * @param {SpokeProvider | undefined} spokeProvider - The spoke provider to use for the claim\n * @returns {UseMutationResult<[SpokeTxHash, HubTxHash], Error, Omit<ClaimParams, 'action'>>} Mutation result object containing mutation function and state\n *\n * @example\n * ```typescript\n * const { mutateAsync: claim, isPending } = useClaim(spokeProvider);\n *\n * const handleClaim = async () => {\n * const result = await claim({\n * requestId: 1n\n * });\n *\n * console.log('Claim successful:', result);\n * };\n * ```\n */\nexport function useClaim(\n spokeProvider: SpokeProvider | undefined,\n): UseMutationResult<[SpokeTxHash, HubTxHash], Error, Omit<ClaimParams, 'action'>> {\n const { sodax } = useSodaxContext();\n\n return useMutation<[SpokeTxHash, HubTxHash], Error, Omit<ClaimParams, 'action'>>({\n mutationFn: async (params: Omit<ClaimParams, 'action'>) => {\n if (!spokeProvider) {\n throw new Error('Spoke provider not found');\n }\n\n const result = await sodax.staking.claim({ ...params, action: 'claim' }, spokeProvider);\n\n if (!result.ok) {\n throw new Error(`Claim failed: ${result.error.code}`);\n }\n\n return result.value;\n },\n });\n}\n","// packages/dapp-kit/src/hooks/staking/useCancelUnstake.ts\nimport { useMutation, useQueryClient, type UseMutationResult } from '@tanstack/react-query';\nimport { useSodaxContext } from '../shared/useSodaxContext';\nimport type { CancelUnstakeParams, SpokeProvider, SpokeTxHash, HubTxHash } from '@sodax/sdk';\n\n/**\n * Hook for executing cancel unstake transactions to cancel pending unstake requests.\n * Uses React Query's useMutation for better state management and caching.\n *\n * @param {SpokeProvider | undefined} spokeProvider - The spoke provider to use for the cancel unstake\n * @returns {UseMutationResult<[SpokeTxHash, HubTxHash], Error, Omit<CancelUnstakeParams, 'action'>>} Mutation result object containing mutation function and state\n *\n * @example\n * ```typescript\n * const { mutateAsync: cancelUnstake, isPending } = useCancelUnstake(spokeProvider);\n *\n * const handleCancelUnstake = async () => {\n * const result = await cancelUnstake({\n * requestId: 1n\n * });\n *\n * console.log('Cancel unstake successful:', result);\n * };\n * ```\n */\nexport function useCancelUnstake(\n spokeProvider: SpokeProvider | undefined,\n): UseMutationResult<[SpokeTxHash, HubTxHash], Error, Omit<CancelUnstakeParams, 'action'>> {\n const { sodax } = useSodaxContext();\n const queryClient = useQueryClient();\n\n return useMutation({\n mutationFn: async (params: Omit<CancelUnstakeParams, 'action'>) => {\n if (!spokeProvider) {\n throw new Error('Spoke provider not available');\n }\n\n const result = await sodax.staking.cancelUnstake({ ...params, action: 'cancelUnstake' }, spokeProvider);\n if (!result.ok) {\n throw new Error(`Cancel unstake failed: ${result.error.code}`);\n }\n\n return result.value;\n },\n onSuccess: () => {\n // Invalidate relevant queries to refresh data\n queryClient.invalidateQueries({ queryKey: ['stakingInfo'] });\n queryClient.invalidateQueries({ queryKey: ['unstakingInfo'] });\n queryClient.invalidateQueries({ queryKey: ['unstakingInfoWithPenalty'] });\n },\n });\n}\n","// packages/dapp-kit/src/hooks/staking/useStakingInfo.ts\nimport { useSodaxContext } from '../shared/useSodaxContext';\nimport type { StakingInfo, SpokeProvider } from '@sodax/sdk';\nimport { useQuery, type UseQueryResult } from '@tanstack/react-query';\n\n/**\n * Hook for fetching comprehensive staking information for a user.\n * Uses React Query for efficient caching and state management.\n *\n * @param {SpokeProvider | undefined} spokeProvider - The spoke provider to use for the query\n * @param {number} refetchInterval - The interval in milliseconds to refetch data (default: 5000)\n * @returns {UseQueryResult<StakingInfo, Error>} Query result object containing staking info and state\n *\n * @example\n * ```typescript\n * const { data: stakingInfo, isLoading, error } = useStakingInfo(spokeProvider);\n *\n * if (isLoading) return <div>Loading staking info...</div>;\n * if (stakingInfo) {\n * console.log('Total staked:', stakingInfo.totalStaked);\n * console.log('User staked:', stakingInfo.userStaked);\n * console.log('xSODA balance:', stakingInfo.userXSodaBalance);\n * }\n * ```\n */\nexport function useStakingInfo(\n spokeProvider: SpokeProvider | undefined,\n refetchInterval = 5000,\n): UseQueryResult<StakingInfo, Error> {\n const { sodax } = useSodaxContext();\n\n return useQuery({\n queryKey: ['soda', 'stakingInfo', spokeProvider?.chainConfig.chain.id],\n queryFn: async () => {\n if (!spokeProvider) {\n throw new Error('Spoke provider not found');\n }\n\n const result = await sodax.staking.getStakingInfoFromSpoke(spokeProvider);\n\n if (!result.ok) {\n throw new Error(`Failed to fetch staking info: ${result.error.code}`);\n }\n\n return result.value;\n },\n enabled: !!spokeProvider,\n refetchInterval,\n });\n}\n","// packages/dapp-kit/src/hooks/staking/useUnstakingInfoWithPenalty.ts\nimport { useSodaxContext } from '../shared/useSodaxContext';\nimport type { UnstakingInfo, UnstakeRequestWithPenalty, SpokeProvider } from '@sodax/sdk';\nimport { useQuery, type UseQueryResult } from '@tanstack/react-query';\n\nexport type UnstakingInfoWithPenalty = UnstakingInfo & {\n requestsWithPenalty: UnstakeRequestWithPenalty[];\n};\n\n/**\n * Hook for fetching unstaking information with penalty calculations from the stakedSoda contract.\n * Uses React Query for efficient caching and state management.\n *\n * @param {string | undefined} userAddress - The user address to fetch unstaking info for\n * @param {SpokeProvider | undefined} spokeProvider - The spoke provider instance\n * @param {number} refetchInterval - The interval in milliseconds to refetch data (default: 5000)\n * @returns {UseQueryResult<UnstakingInfoWithPenalty, Error>} Query result object containing unstaking info with penalties and state\n *\n * @example\n * ```typescript\n * const { data: unstakingInfo, isLoading, error } = useUnstakingInfoWithPenalty(userAddress, spokeProvider);\n *\n * if (isLoading) return <div>Loading unstaking info...</div>;\n * if (unstakingInfo) {\n * console.log('Total unstaking:', unstakingInfo.totalUnstaking);\n * unstakingInfo.requestsWithPenalty.forEach(request => {\n * console.log('Penalty:', request.penaltyPercentage + '%');\n * console.log('Claimable amount:', request.claimableAmount);\n * });\n * }\n * ```\n */\nexport function useUnstakingInfoWithPenalty(\n userAddress: string | undefined,\n spokeProvider: SpokeProvider | undefined,\n refetchInterval = 5000,\n): UseQueryResult<UnstakingInfoWithPenalty, Error> {\n const { sodax } = useSodaxContext();\n\n return useQuery({\n queryKey: ['soda', 'unstakingInfoWithPenalty', spokeProvider?.chainConfig.chain.id, userAddress],\n queryFn: async () => {\n if (!spokeProvider) {\n throw new Error('Spoke provider not found');\n }\n\n // Get unstaking info with penalty calculations\n const penaltyResult = await sodax.staking.getUnstakingInfoWithPenalty(spokeProvider);\n\n if (!penaltyResult.ok) {\n throw new Error(`Failed to fetch unstaking info with penalty: ${penaltyResult.error.code}`);\n }\n\n return penaltyResult.value;\n },\n enabled: !!spokeProvider && !!userAddress,\n refetchInterval,\n });\n}\n","// packages/dapp-kit/src/hooks/staking/useStakingConfig.ts\nimport { useSodaxContext } from '../shared/useSodaxContext';\nimport type { StakingConfig } from '@sodax/sdk';\nimport { useQuery, type UseQueryResult } from '@tanstack/react-query';\n\n/**\n * Hook for fetching staking configuration from the stakedSoda contract.\n * Uses React Query for efficient caching and state management.\n *\n * @param {number} refetchInterval - The interval in milliseconds to refetch data (default: 30000)\n * @returns {UseQueryResult<StakingConfig, Error>} Query result object containing staking config and state\n *\n * @example\n * ```typescript\n * const { data: stakingConfig, isLoading, error } = useStakingConfig();\n *\n * if (isLoading) return <div>Loading staking config...</div>;\n * if (stakingConfig) {\n * console.log('Unstaking period (days):', stakingConfig.unstakingPeriod / 86400n);\n * console.log('Max penalty (%):', stakingConfig.maxPenalty);\n * }\n * ```\n */\nexport function useStakingConfig(refetchInterval = 30000): UseQueryResult<StakingConfig, Error> {\n const { sodax } = useSodaxContext();\n\n return useQuery({\n queryKey: ['soda', 'stakingConfig'],\n queryFn: async () => {\n const result = await sodax.staking.getStakingConfig();\n\n if (!result.ok) {\n throw new Error(`Failed to fetch staking config: ${result.error.code}`);\n }\n\n return result.value;\n },\n refetchInterval,\n });\n}\n","// packages/dapp-kit/src/hooks/staking/useStakeRatio.ts\nimport { useSodaxContext } from '../shared/useSodaxContext';\nimport { useQuery, type UseQueryResult } from '@tanstack/react-query';\n\n/**\n * Hook for fetching stake ratio estimates (xSoda amount and preview deposit).\n * Uses React Query for efficient caching and state management.\n *\n * @param {bigint | undefined} amount - The amount of SODA to estimate stake for\n * @param {number} refetchInterval - The interval in milliseconds to refetch data (default: 10000)\n * @returns {UseQueryResult<[bigint, bigint], Error>} Query result object containing stake ratio estimates and state\n *\n * @example\n * ```typescript\n * const { data: stakeRatio, isLoading, error } = useStakeRatio(1000000000000000000n); // 1 SODA\n *\n * if (isLoading) return <div>Loading stake ratio...</div>;\n * if (stakeRatio) {\n * const [xSodaAmount, previewDepositAmount] = stakeRatio;\n * console.log('xSoda amount:', xSodaAmount);\n * console.log('Preview deposit:', previewDepositAmount);\n * }\n * ```\n */\nexport function useStakeRatio(\n amount: bigint | undefined,\n refetchInterval = 10000,\n): UseQueryResult<[bigint, bigint], Error> {\n const { sodax } = useSodaxContext();\n\n return useQuery({\n queryKey: ['soda', 'stakeRatio', amount?.toString()],\n queryFn: async () => {\n if (!amount || amount <= 0n) {\n throw new Error('Amount must be greater than 0');\n }\n\n if (!sodax?.staking) {\n throw new Error('Staking service not available');\n }\n\n const result = await sodax.staking.getStakeRatio(amount);\n\n if (!result.ok) {\n throw new Error(`Failed to fetch stake ratio: ${result.error.code}`);\n }\n\n return result.value;\n },\n enabled: !!amount && amount > 0n && !!sodax?.staking,\n refetchInterval,\n });\n}\n","// packages/dapp-kit/src/hooks/staking/useInstantUnstakeRatio.ts\nimport { useSodaxContext } from '../shared/useSodaxContext';\nimport { useQuery, type UseQueryResult } from '@tanstack/react-query';\n\n/**\n * Hook for fetching instant unstake ratio estimates.\n * Uses React Query for efficient caching and state management.\n *\n * @param {bigint | undefined} amount - The amount of xSoda to estimate instant unstake for\n * @param {number} refetchInterval - The interval in milliseconds to refetch data (default: 10000)\n * @returns {UseQueryResult<bigint, Error>} Query result object containing instant unstake ratio and state\n *\n * @example\n * ```typescript\n * const { data: instantUnstakeRatio, isLoading, error } = useInstantUnstakeRatio(1000000000000000000n); // 1 xSoda\n *\n * if (isLoading) return <div>Loading instant unstake ratio...</div>;\n * if (instantUnstakeRatio) {\n * console.log('Instant unstake ratio:', instantUnstakeRatio);\n * }\n * ```\n */\nexport function useInstantUnstakeRatio(\n amount: bigint | undefined,\n refetchInterval = 10000,\n): UseQueryResult<bigint, Error> {\n const { sodax } = useSodaxContext();\n\n console.log('useInstantUnstakeRatio hook called with:', { amount: amount?.toString(), sodax: !!sodax });\n\n return useQuery({\n queryKey: ['soda', 'instantUnstakeRatio', amount?.toString()],\n queryFn: async () => {\n console.log('useInstantUnstakeRatio queryFn called with amount:', amount?.toString());\n if (!amount || amount <= 0n) {\n throw new Error('Amount must be greater than 0');\n }\n\n if (!sodax?.staking) {\n throw new Error('Staking service not available');\n }\n\n const result = await sodax.staking.getInstantUnstakeRatio(amount);\n\n if (!result.ok) {\n throw new Error(`Failed to fetch instant unstake ratio: ${result.error.code}`);\n }\n\n return result.value;\n },\n enabled: !!amount && amount > 0n && !!sodax?.staking,\n refetchInterval,\n });\n}\n","// packages/dapp-kit/src/hooks/staking/useConvertedAssets.ts\nimport { useSodaxContext } from '../shared/useSodaxContext';\nimport { useQuery, type UseQueryResult } from '@tanstack/react-query';\n\n/**\n * Hook for fetching converted assets amount for xSODA shares.\n * Uses React Query for efficient caching and state management.\n *\n * @param {bigint | undefined} amount - The amount of xSODA shares to convert\n * @param {number} refetchInterval - The interval in milliseconds to refetch data (default: 10000)\n * @returns {UseQueryResult<bigint, Error>} Query result object containing converted assets amount and state\n *\n * @example\n * ```typescript\n * const { data: convertedAssets, isLoading, error } = useConvertedAssets(1000000000000000000n); // 1 xSODA\n *\n * if (isLoading) return <div>Loading converted assets...</div>;\n * if (convertedAssets) {\n * console.log('Converted assets:', convertedAssets);\n * }\n * ```\n */\nexport function useConvertedAssets(amount: bigint | undefined, refetchInterval = 10000): UseQueryResult<bigint, Error> {\n const { sodax } = useSodaxContext();\n\n console.log('useConvertedAssets hook called with:', { amount: amount?.toString(), sodax: !!sodax });\n\n return useQuery({\n queryKey: ['soda', 'convertedAssets', amount?.toString()],\n queryFn: async () => {\n console.log('useConvertedAssets queryFn called with amount:', amount?.toString());\n if (!amount || amount <= 0n) {\n throw new Error('Amount must be greater than 0');\n }\n\n const result = await sodax.staking.getConvertedAssets(amount);\n\n if (!result.ok) {\n throw new Error(`Failed to fetch converted assets: ${result.error.code}`);\n }\n\n return result.value;\n },\n enabled: !!amount && amount > 0n && !!sodax?.staking,\n refetchInterval,\n });\n}\n","// packages/dapp-kit/src/hooks/staking/useInstantUnstake.ts\nimport { useSodaxContext } from '../shared/useSodaxContext';\nimport { useMutation, type UseMutationResult } from '@tanstack/react-query';\nimport type { SpokeProvider, InstantUnstakeParams } from '@sodax/sdk';\n\n/**\n * Hook for executing instant unstake operations.\n * Uses React Query for efficient state management and error handling.\n *\n * @param {SpokeProvider | undefined} spokeProvider - The spoke provider for the transaction\n * @returns {UseMutationResult<[string, string], Error, Omit<InstantUnstakeParams, 'action'>>} Mutation result object containing instant unstake state and methods\n *\n * @example\n * ```typescript\n * const { mutateAsync: instantUnstake, isPending } = useInstantUnstake(spokeProvider);\n *\n * const handleInstantUnstake = async () => {\n * const result = await instantUnstake({\n * amount: 1000000000000000000n,\n * minAmount: 950000000000000000n,\n * account: '0x...'\n * });\n * console.log('Instant unstake successful:', result);\n * };\n * ```\n */\nexport function useInstantUnstake(\n spokeProvider: SpokeProvider | undefined,\n): UseMutationResult<[string, string], Error, Omit<InstantUnstakeParams, 'action'>> {\n const { sodax } = useSodaxContext();\n\n return useMutation({\n mutationFn: async (params: Omit<InstantUnstakeParams, 'action'>) => {\n if (!spokeProvider) {\n throw new Error('spokeProvider is not found');\n }\n\n const result = await sodax.staking.instantUnstake({ ...params, action: 'instantUnstake' }, spokeProvider);\n\n if (!result.ok) {\n throw new Error(`Instant unstake failed: ${result.error.code}`);\n }\n\n return result.value;\n },\n onError: error => {\n console.error('Instant unstake error:', error);\n },\n });\n}\n","// packages/dapp-kit/src/hooks/staking/useStakeAllowance.ts\nimport { useSodaxContext } from '../shared/useSodaxContext';\nimport type { UnstakeParams, SpokeProvider } from '@sodax/sdk';\nimport { useQuery, type UseQueryResult } from '@tanstack/react-query';\n\n/**\n * Hook for checking xSODA token allowance for unstaking operations.\n * Uses React Query for efficient caching and state management.\n *\n * @param {Omit<UnstakeParams, 'action'> | undefined} params - The unstaking parameters. If undefined, the query will be disabled.\n * @param {SpokeProvider | undefined} spokeProvider - The spoke provider to use for the allowance check\n * @returns {UseQueryResult<boolean, Error>} Query result object containing allowance data and state\n *\n * @example\n * ```typescript\n * const { data: hasAllowed, isLoading } = useUnstakeAllowance(\n * {\n * amount: 1000000000000000000n, // 1 xSODA\n * account: '0x...'\n * },\n * spokeProvider\n * );\n *\n * if (isLoading) return <div>Checking allowance...</div>;\n * if (hasAllowed) {\n * console.log('Sufficient allowance for unstaking');\n * }\n * ```\n */\nexport function useUnstakeAllowance(\n params: Omit<UnstakeParams, 'action'> | undefined,\n spokeProvider: SpokeProvider | undefined,\n): UseQueryResult<boolean, Error> {\n const { sodax } = useSodaxContext();\n\n return useQuery({\n queryKey: ['soda', 'unstakeAllowance', params, spokeProvider?.chainConfig.chain.id],\n queryFn: async () => {\n if (!params || !spokeProvider) {\n return false;\n }\n\n const result = await sodax.staking.isAllowanceValid({\n params: { ...params, action: 'unstake' },\n spokeProvider,\n });\n\n if (!result.ok) {\n console.error(`Unstake allowance check failed: ${result.error.code}, error: ${result.error.error}`);\n throw new Error(`Unstake allowance check failed: ${result.error.code}`);\n }\n\n return result.value;\n },\n enabled: !!params && !!spokeProvider,\n refetchInterval: 5000, // Refetch every 5 seconds\n });\n}\n","// packages/dapp-kit/src/hooks/staking/useStakeApprove.ts\nimport { useSodaxContext } from '../shared/useSodaxContext';\nimport type { TxReturnType, UnstakeParams } from '@sodax/sdk';\nimport { useMutation, type UseMutationResult } from '@tanstack/react-query';\nimport type { SpokeProvider } from '@sodax/sdk';\n\n/**\n * Hook for approving xSODA token spending for unstaking operations.\n * Uses React Query's useMutation for better state management and caching.\n *\n * @param {SpokeProvider | undefined} spokeProvider - The spoke provider to use for the approval\n * @returns {UseMutationResult<TxReturnType<SpokeProvider, false>, Error, Omit<UnstakeParams, 'action'>>} Mutation result object containing mutation function and state\n *\n * @example\n * ```typescript\n * const { mutateAsync: approve, isPending } = useUnstakeApprove(spokeProvider);\n *\n * const handleApprove = async () => {\n * const result = await approve({\n * amount: 1000000000000000000n, // 1 xSODA\n * account: '0x...'\n * });\n *\n * console.log('Approval successful:', result);\n * };\n * ```\n */\nexport function useUnstakeApprove(\n spokeProvider: SpokeProvider | undefined,\n): UseMutationResult<TxReturnType<SpokeProvider, false>, Error, Omit<UnstakeParams, 'action'>> {\n const { sodax } = useSodaxContext();\n\n return useMutation<TxReturnType<SpokeProvider, false>, Error, Omit<UnstakeParams, 'action'>>({\n mutationFn: async (params: Omit<UnstakeParams, 'action'>) => {\n console.log('useUnstakeApprove called with params:', params);\n if (!spokeProvider) {\n throw new Error('Spoke provider not found');\n }\n\n const result = await sodax.staking.approve({\n params: { ...params, action: 'unstake' },\n spokeProvider,\n });\n\n if (!result.ok) {\n throw new Error(`Unstake approval failed: ${result.error.code}`);\n }\n\n return result.value;\n },\n });\n}\n","// packages/dapp-kit/src/hooks/staking/useUnstakingInfoWithPenalty.ts\nimport { useSodaxContext } from '../shared/useSodaxContext';\nimport type { UnstakingInfo, SpokeProvider } from '@sodax/sdk';\nimport { useQuery, type UseQueryResult } from '@tanstack/react-query';\n\n/**\n * Hook for fetching unstaking information from the stakedSoda contract.\n * Uses React Query for efficient caching and state management.\n *\n * @param {string | undefined} userAddress - The user address to fetch unstaking info for\n * @param {SpokeProvider | undefined} spokeProvider - The spoke provider instance\n * @param {number} refetchInterval - The interval in milliseconds to refetch data (default: 5000)\n * @returns {UseQueryResult<UnstakingInfo, Error>} Query result object containing unstaking info and state\n *\n * @example\n * ```typescript\n * const { data: unstakingInfo, isLoading, error } = useUnstakingInfo(userAddress, spokeProvider);\n *\n * if (isLoading) return <div>Loading unstaking info...</div>;\n * if (unstakingInfo) {\n * console.log('Total unstaking:', unstakingInfo.totalUnstaking);\n * unstakingInfo.userUnstakeSodaRequests.forEach(request => {\n * console.log('Request amount:', request.request.amount);\n * });\n * }\n * ```\n */\nexport function useUnstakingInfo(\n userAddress: string | undefined,\n spokeProvider: SpokeProvider | undefined,\n refetchInterval = 5000,\n): UseQueryResult<UnstakingInfo, Error> {\n const { sodax } = useSodaxContext();\n\n return useQuery({\n queryKey: ['soda', 'unstakingInfoWithPenalty', spokeProvider?.chainConfig.chain.id, userAddress],\n queryFn: async () => {\n if (!spokeProvider || !userAddress) {\n throw new Error('Spoke provider or user address not found');\n }\n\n const result = await sodax.staking.getUnstakingInfo(spokeProvider);\n\n if (!result.ok) {\n throw new Error(`Failed to fetch unstaking info: ${result.error.code}`);\n }\n\n return result.value;\n },\n enabled: !!spokeProvider && !!userAddress,\n refetchInterval,\n });\n}\n","// packages/dapp-kit/src/hooks/staking/useStakeApprove.ts\nimport { useSodaxContext } from '../shared/useSodaxContext';\nimport type { InstantUnstakeParams, TxReturnType, SpokeProvider } from '@sodax/sdk';\nimport { useMutation, type UseMutationResult } from '@tanstack/react-query';\n\n/**\n * Hook for approving xSODA token spending for instant unstaking operations.\n * Uses React Query's useMutation for better state management and caching.\n *\n * @param {SpokeProvider | undefined} spokeProvider - The spoke provider to use for the approval\n * @returns {UseMutationResult<TxReturnType<SpokeProvider, false>, Error, Omit<InstantUnstakeParams, 'action'>>} Mutation result object containing mutation function and state\n *\n * @example\n * ```typescript\n * const { mutateAsync: approve, isPending } = useInstantUnstakeApprove(spokeProvider);\n *\n * const handleApprove = async () => {\n * const result = await approve({\n * amount: 1000000000000000000n, // 1 xSODA\n * minAmount: 950000000000000000n, // 0.95 SODA\n * account: '0x...'\n * });\n *\n * console.log('Approval successful:', result);\n * };\n * ```\n */\nexport function useInstantUnstakeApprove(\n spokeProvider: SpokeProvider | undefined,\n): UseMutationResult<TxReturnType<SpokeProvider, false>, Error, Omit<InstantUnstakeParams, 'action'>> {\n const { sodax } = useSodaxContext();\n\n return useMutation<TxReturnType<SpokeProvider, false>, Error, Omit<InstantUnstakeParams, 'action'>>({\n mutationFn: async (params: Omit<InstantUnstakeParams, 'action'>) => {\n console.log('useInstantUnstakeApprove called with params:', params);\n if (!spokeProvider) {\n throw new Error('Spoke provider not found');\n }\n\n const result = await sodax.staking.approve({\n params: { ...params, action: 'instantUnstake' },\n spokeProvider,\n });\n\n if (!result.ok) {\n throw new Error(`Instant unstake approval failed: ${result.error.code}`);\n }\n\n return result.value;\n },\n });\n}\n","// packages/dapp-kit/src/hooks/staking/useStakeAllowance.ts\nimport { useSodaxContext } from '../shared/useSodaxContext';\nimport type { SpokeProvider, InstantUnstakeParams } from '@sodax/sdk';\nimport { useQuery, type UseQueryResult } from '@tanstack/react-query';\n\n/**\n * Hook for checking xSODA token allowance for instant unstaking operations.\n * Uses React Query for efficient caching and state management.\n *\n * @param {Omit<InstantUnstakeParams, 'action'> | undefined} params - The instant unstaking parameters. If undefined, the query will be disabled.\n * @param {SpokeProvider | undefined} spokeProvider - The spoke provider to use for the allowance check\n * @returns {UseQueryResult<boolean, Error>} Query result object containing allowance data and state\n *\n * @example\n * ```typescript\n * const { data: hasAllowed, isLoading } = useInstantUnstakeAllowance(\n * {\n * amount: 1000000000000000000n, // 1 xSODA\n * minAmount: 950000000000000000n, // 0.95 SODA\n * account: '0x...'\n * },\n * spokeProvider\n * );\n *\n * if (isLoading) return <div>Checking allowance...</div>;\n * if (hasAllowed) {\n * console.log('Sufficient allowance for instant unstaking');\n * }\n * ```\n */\nexport function useInstantUnstakeAllowance(\n params: Omit<InstantUnstakeParams, 'action'> | undefined,\n spokeProvider: SpokeProvider | undefined,\n): UseQueryResult<boolean, Error> {\n const { sodax } = useSodaxContext();\n\n return useQuery({\n queryKey: ['soda', 'instantUnstakeAllowance', params, spokeProvider?.chainConfig.chain.id],\n queryFn: async () => {\n if (!params || !spokeProvider) {\n return false;\n }\n\n const result = await sodax.staking.isAllowanceValid({\n params: { ...params, action: 'instantUnstake' },\n spokeProvider,\n });\n\n if (!result.ok) {\n console.error(`Unstake allowance check failed: ${result.error.code}, error: ${result.error.error}`);\n throw new Error(`Unstake allowance check failed: ${result.error.code}`);\n }\n\n return result.value;\n },\n enabled: !!params && !!spokeProvider,\n refetchInterval: 5000, // Refetch every 5 seconds\n });\n}\n","import type { XToken } from '@sodax/types';\r\n\r\nexport const MIGRATION_MODE_ICX_SODA = 'icxsoda';\r\nexport const MIGRATION_MODE_BNUSD = 'bnusd';\r\n\r\nexport type MigrationMode = typeof MIGRATION_MODE_ICX_SODA | typeof MIGRATION_MODE_BNUSD;\r\n\r\nexport interface MigrationIntentParams {\r\n token: XToken | undefined;\r\n amount: string | undefined;\r\n sourceAddress: string | undefined;\r\n migrationMode?: MigrationMode;\r\n toToken?: XToken;\r\n destinationAddress?: string;\r\n}\r\n","import { parseUnits } from 'viem';\nimport {\n spokeChainConfig,\n type UnifiedBnUSDMigrateParams,\n type IconSpokeProvider,\n type SonicSpokeProvider,\n isLegacybnUSDToken,\n type SpokeProvider,\n} from '@sodax/sdk';\nimport { type ChainId, ICON_MAINNET_CHAIN_ID } from '@sodax/types';\nimport { useSodaxContext } from '../shared/useSodaxContext';\nimport { useMutation, type UseMutationResult } from '@tanstack/react-query';\nimport { MIGRATION_MODE_BNUSD, MIGRATION_MODE_ICX_SODA, type MigrationIntentParams } from './types';\n\n/**\n * Hook for executing migration operations between chains.\n *\n * This hook handles ICX/SODA and bnUSD migrations by accepting a spoke provider\n * and returning a mutation function that accepts migration parameters.\n *\n * @param {SpokeProvider} spokeProvider - The spoke provider to use for the migration\n * @returns {UseMutationResult} Mutation result object containing migration function and state\n *\n * @example\n * ```typescript\n * const { mutateAsync: migrate, isPending } = useMigrate(spokeProvider);\n *\n * const result = await migrate({\n * token: { address: \"0x...\", decimals: 18 },\n * amount: \"100\",\n * migrationMode: MIGRATION_MODE_ICX_SODA,\n * toToken: { address: \"0x...\", decimals: 18 },\n * destinationAddress: \"0x...\"\n * });\n * ```\n */\nexport function useMigrate(\n spokeProvider: SpokeProvider | undefined,\n): UseMutationResult<{ spokeTxHash: string; hubTxHash: `0x${string}` }, Error, MigrationIntentParams> {\n const { sodax } = useSodaxContext();\n\n return useMutation({\n mutationFn: async (params: MigrationIntentParams) => {\n const { token, amount, migrationMode = MIGRATION_MODE_ICX_SODA, toToken, destinationAddress } = params;\n const amountToMigrate = parseUnits(amount ?? '0', token?.decimals ?? 0);\n\n if (!spokeProvider) {\n throw new Error('Spoke provider not found');\n }\n\n if (migrationMode === MIGRATION_MODE_ICX_SODA) {\n // ICX->SODA migration logic\n if (token?.xChainId === ICON_MAINNET_CHAIN_ID) {\n const params = {\n address: spokeChainConfig[ICON_MAINNET_CHAIN_ID].nativeToken,\n amount: amountToMigrate,\n to: destinationAddress as `0x${string}`,\n };\n const result = await sodax.migration.migrateIcxToSoda(params, spokeProvider as IconSpokeProvider, 30000);\n if (result.ok) {\n const [spokeTxHash, hubTxHash] = result.value;\n return { spokeTxHash, hubTxHash };\n }\n throw new Error('ICX to SODA migration failed. Please try again.');\n }\n\n // SODA->ICX migration\n const revertParams = {\n amount: amountToMigrate,\n to: destinationAddress as `hx${string}`,\n };\n const result = await sodax.migration.revertMigrateSodaToIcx(\n revertParams,\n spokeProvider as SonicSpokeProvider,\n 30000,\n );\n if (result.ok) {\n const [hubTxHash, spokeTxHash] = result.value;\n return { spokeTxHash, hubTxHash };\n }\n throw new Error('SODA to ICX migration failed. Please try again.');\n }\n\n if (migrationMode === MIGRATION_MODE_BNUSD) {\n // bnUSD migration logic - handle dynamic source/destination chains\n const params = {\n srcChainId: token?.xChainId as ChainId,\n dstChainId: toToken?.xChainId as ChainId,\n srcbnUSD: token?.address as string,\n dstbnUSD: toToken?.address as string,\n amount: amountToMigrate,\n to: destinationAddress as `hx${string}` | `0x${string}`,\n } satisfies UnifiedBnUSDMigrateParams;\n\n const result = await sodax.migration.migratebnUSD(params, spokeProvider, 30000);\n if (result.ok) {\n const [spokeTxHash, hubTxHash] = result.value;\n return { spokeTxHash, hubTxHash };\n }\n\n const errorMessage = isLegacybnUSDToken(token?.address as string)\n ? 'bnUSD migration failed. Please try again.'\n : 'bnUSD reverse migration failed. Please try again.';\n throw new Error(errorMessage);\n }\n\n throw new Error('Invalid migration mode');\n },\n });\n}\n","import { useQuery, type UseQueryResult } from '@tanstack/react-query';\nimport type { ChainId } from '@sodax/types';\nimport { useSodaxContext } from '../shared/useSodaxContext';\nimport { parseUnits } from 'viem';\nimport type { IcxCreateRevertMigrationParams, UnifiedBnUSDMigrateParams, SpokeProvider } from '@sodax/sdk';\nimport { ICON_MAINNET_CHAIN_ID } from '@sodax/types';\nimport { MIGRATION_MODE_ICX_SODA, type MigrationIntentParams } from './types';\n\n/**\n * Hook for checking token allowance for migration operations.\n *\n * This hook verifies if the user has approved enough tokens for migration operations.\n * It handles both ICX/SODA and bnUSD migration allowance checks.\n *\n * @param {MigrationIntentParams} params - The parameters for the migration allowance check\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 } = useMigrationAllowance(params, spokeProvider);\n * ```\n */\nexport function useMigrationAllowance(\n params: MigrationIntentParams | undefined,\n spokeProvider: SpokeProvider | undefined,\n): UseQueryResult<boolean, Error> {\n const { sodax } = useSodaxContext();\n\n return useQuery({\n queryKey: ['migration-allowance', params],\n queryFn: async () => {\n if (!spokeProvider || !params) {\n return false;\n }\n\n const { token, amount, migrationMode = MIGRATION_MODE_ICX_SODA, toToken, destinationAddress } = params;\n\n // For ICON chain, no allowance is required (forward migrations)\n if (token?.xChainId === ICON_MAINNET_CHAIN_ID) {\n return true;\n }\n\n if (!spokeProvider) throw new Error('Spoke provider is required');\n const amountToMigrate = parseUnits(amount ?? '0', token?.decimals ?? 0);\n\n let migrationParams: IcxCreateRevertMigrationParams | UnifiedBnUSDMigrateParams;\n if (migrationMode === MIGRATION_MODE_ICX_SODA) {\n migrationParams = {\n amount: amountToMigrate,\n to: destinationAddress as `hx${string}`,\n } satisfies IcxCreateRevertMigrationParams;\n } else {\n if (!toToken) throw new Error('Destination token is required for bnUSD migration');\n\n migrationParams = {\n srcChainId: token?.xChainId as ChainId,\n dstChainId: toToken?.xChainId as ChainId,\n srcbnUSD: token?.address as string,\n dstbnUSD: toToken?.address as string,\n amount: amountToMigrate,\n to: destinationAddress as `hx${string}` | `0x${string}`,\n } satisfies UnifiedBnUSDMigrateParams;\n }\n\n const allowance = await sodax.migration.isAllowanceValid(migrationParams, 'revert', spokeProvider);\n if (allowance.ok) {\n return allowance.value;\n }\n return false;\n },\n enabled: !!spokeProvider && !!params,\n refetchInterval: 2000,\n });\n}\n","import { parseUnits } from 'viem';\nimport { useCallback, useState, useRef, useEffect } from 'react';\nimport type {\n IcxCreateRevertMigrationParams,\n UnifiedBnUSDMigrateParams,\n SpokeProvider,\n Result,\n ChainId,\n} from '@sodax/sdk';\nimport { useSodaxContext } from '../shared/useSodaxContext';\nimport { MIGRATION_MODE_BNUSD, MIGRATION_MODE_ICX_SODA, type MigrationIntentParams } from './types';\nimport { useQueryClient } from '@tanstack/react-query';\n\ninterface UseApproveReturn {\n approve: ({ params }: { params: MigrationIntentParams }) => Promise<boolean>;\n isLoading: boolean;\n error: Error | null;\n resetError: () => void;\n isApproved: boolean;\n}\n\n/**\n * Hook for approving token spending for migration actions\n * @param params The parameters for the migration approval\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 } = useMigrationApprove(params, spokeProvider);\n *\n * // Approve tokens for migration\n * await approve({ params });\n * ```\n */\n\nexport function useMigrationApprove(\n params: MigrationIntentParams | undefined,\n spokeProvider: SpokeProvider | undefined,\n): UseApproveReturn {\n const { sodax } = useSodaxContext();\n const [isLoading, setIsLoading] = useState(false);\n const [error, setError] = useState<Error | null>(null);\n const [isApproved, setIsApproved] = useState(false);\n const queryClient = useQueryClient();\n\n // Track previous values to reset approval state when needed\n const prevTokenAddress = useRef<string | undefined>(undefined);\n const prevAmount = useRef<string | undefined>(undefined);\n\n useEffect(() => {\n if (prevTokenAddress.current !== params?.token?.address || prevAmount.current !== params?.amount) {\n setIsApproved(false);\n prevTokenAddress.current = params?.token?.address;\n prevAmount.current = params?.amount;\n }\n }, [params?.token?.address, params?.amount]);\n\n const approve = useCallback(\n async ({ params: approveParams }: { params: MigrationIntentParams }) => {\n try {\n setIsLoading(true);\n setError(null);\n\n if (!spokeProvider) {\n throw new Error('Spoke provider not found');\n }\n if (!approveParams) {\n throw new Error('Migration intent not found');\n }\n\n const { token, amount, migrationMode = MIGRATION_MODE_ICX_SODA, toToken, destinationAddress } = approveParams;\n const amountToMigrate = parseUnits(amount ?? '0', token?.decimals ?? 0);\n\n let result: Result<string, unknown>;\n if (migrationMode === MIGRATION_MODE_ICX_SODA) {\n // ICX/SODA migration approval\n const revertParams = {\n amount: amountToMigrate,\n to: destinationAddress as `hx${string}`,\n } satisfies IcxCreateRevertMigrationParams;\n\n result = await sodax.migration.approve(revertParams, 'revert', spokeProvider, false);\n } else if (migrationMode === MIGRATION_MODE_BNUSD) {\n // bnUSD migration approval\n if (!toToken) throw new Error('Destination token is required for bnUSD migration');\n\n const migrationParams = {\n srcChainId: token?.xChainId as ChainId,\n dstChainId: toToken?.xChainId as ChainId,\n srcbnUSD: token?.address as string,\n dstbnUSD: toToken?.address as string,\n amount: amountToMigrate,\n to: destinationAddress as `hx${string}` | `0x${string}`,\n } satisfies UnifiedBnUSDMigrateParams;\n\n result = await sodax.migration.approve(migrationParams, 'revert', spokeProvider, false);\n } else {\n throw new Error('Invalid migration mode');\n }\n if (!result.ok) {\n throw new Error('Failed to approve tokens');\n }\n\n setIsApproved(true);\n queryClient.invalidateQueries({ queryKey: ['migration-allowance', params] });\n return result.ok;\n } catch (err) {\n const error = err instanceof Error ? err : new Error('An unknown error occurred');\n setError(error);\n throw error;\n } finally {\n setIsLoading(false);\n }\n },\n [spokeProvider, sodax, queryClient, params],\n );\n\n const resetError = useCallback(() => {\n setError(null);\n }, []);\n\n return {\n approve,\n isLoading,\n error,\n resetError,\n isApproved,\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 '@sodax/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/shared/useStellarTrustlineCheck.ts","../src/hooks/shared/useRequestTrustline.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/mm/useAToken.ts","../src/hooks/mm/useReservesUsdFormat.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/hooks/staking/useStake.ts","../src/hooks/staking/useStakeApprove.ts","../src/hooks/staking/useStakeAllowance.ts","../src/hooks/staking/useUnstake.ts","../src/hooks/staking/useClaim.ts","../src/hooks/staking/useCancelUnstake.ts","../src/hooks/staking/useStakingInfo.ts","../src/hooks/staking/useUnstakingInfoWithPenalty.ts","../src/hooks/staking/useStakingConfig.ts","../src/hooks/staking/useStakeRatio.ts","../src/hooks/staking/useInstantUnstakeRatio.ts","../src/hooks/staking/useConvertedAssets.ts","../src/hooks/staking/useInstantUnstake.ts","../src/hooks/staking/useUnstakeAllowance.ts","../src/hooks/staking/useUnstakeApprove.ts","../src/hooks/staking/useUnstakingInfo.ts","../src/hooks/staking/useInstantUnstakeApprove.ts","../src/hooks/staking/useInstantUnstakeAllowance.ts","../src/hooks/migrate/types.ts","../src/hooks/migrate/useMigrate.tsx","../src/hooks/migrate/useMigrationAllowance.tsx","../src/hooks/migrate/useMigrationApprove.tsx","../src/providers/SodaxProvider.tsx"],"names":["useQuery","token","StellarSpokeProvider","error","StellarSpokeService","useMutation","parseUnits","useQueryClient","useMemo","params","spokeChainConfig","result","ICON_MAINNET_CHAIN_ID","useState","useCallback"],"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,EAAS;AACZ,IAAA,MAAM,IAAI,MAAM,qDAAqD,CAAA;AAAA,EACvE;AACA,EAAA,OAAO,OAAA;AACT;ACZO,SAAS,eACd,aAAA,EAC8E;AAC9E,EAAA,OAAO,WAAA,CAAuE;AAAA,IAC5E,UAAA,EAAY,OAAO,KAAA,KAAiC;AAClD,MAAA,IAAI,CAAC,aAAA,EAAe;AAClB,QAAA,MAAM,IAAI,MAAM,4BAA4B,CAAA;AAAA,MAC9C;AAEA,MAAA,MAAM,QAAA,GAAW,MAAM,YAAA,CAAa,WAAA,CAAY,OAAO,aAAa,CAAA;AAEpE,MAAA,OAAO,QAAA;AAAA,IACT;AAAA,GACD,CAAA;AACH;ACQO,SAAS,0BAAA,CACd,eACA,aAAA,EACgC;AAChC,EAAA,MAAM,EAAE,KAAA,EAAM,GAAI,eAAA,EAAgB;AAElC,EAAA,OAAO,QAAA,CAAS;AAAA,IACd,UAAU,CAAC,yBAAA,EAA2B,eAAe,WAAA,CAAY,KAAA,CAAM,IAAI,aAAa,CA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,EAAA,EAAI;AACd,UAAA,MAAM,IAAI,MAAM,0BAA0B,CAAA;AAAA,QAC5C;AAEA,QAAA,aAAA,CAAc,IAAI,CAAA;AAClB,QAAA,WAAA,CAAY,kBAAkB,EAAE,QAAA,EAAU,CAAC,qBAAA,EAAuB,MAAM,GAAG,CAAA;AAC3E,QAAA,OAAO,MAAA,CAAO,EAAA;AAAA,MAChB,SAAS,GAAA,EAAK;AACZ,QAAA,MAAMH,SAAQ,GAAA,YAAe,KAAA,GAAQ,GAAA,GAAM,IAAI,MAAM,2BAA2B,CAAA;AAChF,QAAA,QAAA,CAASA,MAAK,CAAA;AACd,QAAA,MAAMA,MAAAA;AAAA,MACR,CAAA,SAAE;AACA,QAAA,YAAA,CAAa,KAAK,CAAA;AAAA,MACpB;AAAA,IACF,CAAA;AAAA,IACA,CAAC,aAAA,EAAe,KAAA,EAAO,WAAA,EAAa,MAAM;AAAA,GAC5C;AAEA,EAAA,MAAM,UAAA,GAAaW,YAAY,MAAM;AACnC,IAAA,QAAA,CAAS,IAAI,CAAA;AAAA,EACf,CAAA,EAAG,EAAE,CAAA;AAEL,EAAA,OAAO;AAAA,IACL,OAAA;AAAA,IACA,SAAA;AAAA,IACA,KAAA;AAAA,IACA,UAAA;AAAA,IACA;AAAA,GACF;AACF;AClHO,IAAM,aAAA,GAAgB,CAAC,EAAE,QAAA,EAAU,UAAU,KAAA,EAAO,MAAA,EAAQ,WAAU,KAAwC;AACnH,EAAA,MAAM,KAAA,GAAQ,IAAI,KAAA,CAAM,MAAM,CAAA;AAE9B,EAAA,uBAAO,KAAA,CAAA,aAAA,CAAC,YAAA,CAAa,QAAA,EAAb,EAAsB,KAAA,EAAO,EAAE,KAAA,EAAO,OAAA,EAAS,SAAA,EAAU,EAAA,EAAI,QAAS,CAAA;AAChF","file":"index.mjs","sourcesContent":["import { createContext } from 'react';\nimport type { Sodax } from '@sodax/sdk';\nimport type { RpcConfig } from '@sodax/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 } 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 { STELLAR_MAINNET_CHAIN_ID, StellarSpokeProvider, StellarSpokeService } from '@sodax/sdk';\nimport type { SpokeChainId, SpokeProvider } from '@sodax/sdk';\nimport { useQuery, type UseQueryResult } from '@tanstack/react-query';\n\n/**\n * React hook to check if a Stellar account has a sufficient trustline for a given token and amount.\n *\n * This hook queries the Stellar network (via the provided SpokeProvider) to determine\n * whether the account has established a trustline for the specified token and if the trustline\n * is sufficient for the intended amount. It is useful for gating UI actions that require\n * a trustline to be present and funded.\n *\n * @template T - The type of SpokeProvider, defaults to SpokeProvider.\n * @param {string | undefined} token - The Stellar asset code or token address to check the trustline for.\n * @param {bigint | undefined} amount - The minimum amount required for the trustline.\n * @param {T | undefined} spokeProvider - The provider instance for interacting with the Stellar network.\n * @param {SpokeChainId | undefined} chainId - The chain ID to determine if the check should be performed (only on Stellar mainnet).\n * @returns {UseQueryResult<boolean, Error>} A React Query result object containing:\n * - `data`: `true` if the trustline exists and is sufficient, `false` otherwise.\n * - `error`: Any error encountered during the check.\n * - `isLoading`: Whether the query is in progress.\n * - Other React Query state.\n *\n * @example\n * ```tsx\n * import { useStellarTrustlineCheck } from '@sodax/dapp-kit';\n *\n * const { data: hasTrustline, isLoading, error } = useStellarTrustlineCheck(\n * 'USDC-G...TOKEN',\n * 10000000n,\n * stellarProvider,\n * 'stellar'\n * );\n *\n * if (isLoading) return <span>Checking trustline...</span>;\n * if (error) return <span>Error: {error.message}</span>;\n * if (!hasTrustline) return <span>Trustline not established or insufficient.</span>;\n * return <span>Trustline is sufficient!</span>;\n * ```\n */\n\nexport function useStellarTrustlineCheck<T extends SpokeProvider = SpokeProvider>(\n token: string | undefined,\n amount: bigint | undefined,\n spokeProvider: T | undefined,\n chainId: SpokeChainId | undefined,\n): UseQueryResult<boolean, Error> {\n return useQuery({\n queryKey: ['stellar-trustline-check', token],\n queryFn: async () => {\n if (chainId !== STELLAR_MAINNET_CHAIN_ID) {\n return true;\n }\n if (!spokeProvider || !token || !amount || !(spokeProvider instanceof StellarSpokeProvider)) {\n console.error(\n 'Spoke provider, token or amount not found. Details: spokeProvider:',\n spokeProvider,\n 'token:',\n token,\n 'amount:',\n amount,\n );\n return false;\n }\n const response = await StellarSpokeService.hasSufficientTrustline(token, amount, spokeProvider);\n\n return response;\n },\n enabled: !!spokeProvider && !!token && !!amount,\n });\n}\n","import { type SpokeProvider, StellarSpokeProvider, StellarSpokeService, type TxReturnType } from '@sodax/sdk';\nimport { useQueryClient } from '@tanstack/react-query';\nimport { useCallback, useState } from 'react';\n\n/**\n * React hook to request a Stellar trustline for a given token and amount.\n *\n * This hook provides a callback function for requesting a trustline on the Stellar network\n * using the provided SpokeProvider. It is intended for use with StellarSpokeProvider\n * and will throw if used with a non-Stellar provider. Upon success, it invalidates\n * the trustline check query to ensure UI reflects the updated trustline state.\n *\n * @template T - The type of SpokeProvider, defaults to SpokeProvider.\n * @param {string | undefined} token - The Stellar asset code or token address for which to request a trustline.\n * @returns {Object} An object containing:\n * - `requestTrustline`: Function to trigger the trustline request.\n * - `isLoading`: Whether the request is in progress.\n * - `isRequested`: Whether a trustline has been successfully requested.\n * - `error`: Any error encountered during the request.\n * - `data`: The transaction result if successful.\n *\n * @example\n * ```tsx\n * import { useRequestTrustline } from '@sodax/dapp-kit';\n *\n * const { requestTrustline, isLoading, isRequested, error, data } = useRequestTrustline('USDC-G...TOKEN');\n *\n * // To request a trustline:\n * await requestTrustline({\n * token: 'USDC-G...TOKEN',\n * amount: 10000000n,\n * spokeProvider: stellarProvider,\n * });\n *\n * if (isLoading) return <span>Requesting trustline...</span>;\n * if (error) return <span>Error: {error.message}</span>;\n * if (isRequested) return <span>Trustline requested! Tx: {data?.txHash}</span>;\n * ```\n */\n\nexport function useRequestTrustline<T extends SpokeProvider = SpokeProvider>(\n token: string | undefined,\n): {\n requestTrustline: (params: {\n token: string;\n amount: bigint;\n spokeProvider: T;\n }) => Promise<TxReturnType<StellarSpokeProvider, false>>;\n isLoading: boolean;\n isRequested: boolean;\n error: Error | null;\n data: TxReturnType<StellarSpokeProvider, false> | null;\n} {\n const queryClient = useQueryClient();\n const [isLoading, setIsLoading] = useState<boolean>(false);\n const [isRequested, setIsRequested] = useState<boolean>(false);\n const [error, setError] = useState<Error | null>(null);\n const [data, setData] = useState<TxReturnType<StellarSpokeProvider, false> | null>(null);\n\n const requestTrustline = useCallback(\n async ({\n token,\n amount,\n spokeProvider,\n }: {\n token: string;\n amount: bigint;\n spokeProvider: T;\n }): Promise<TxReturnType<StellarSpokeProvider, false>> => {\n if (!spokeProvider || !token || !amount || !(spokeProvider instanceof StellarSpokeProvider)) {\n const error = new Error('Spoke provider, token or amount not found');\n setError(error);\n throw error;\n }\n\n setIsLoading(true);\n setError(null);\n\n try {\n const result = await StellarSpokeService.requestTrustline(token, amount, spokeProvider);\n setData(result);\n setIsRequested(true);\n queryClient.invalidateQueries({ queryKey: ['stellar-trustline-check', token] });\n return result;\n } catch (err) {\n const error = err instanceof Error ? err : new Error('Unknown error occurred');\n setError(error);\n throw error;\n } finally {\n setIsLoading(false);\n }\n },\n [queryClient],\n );\n\n return {\n requestTrustline,\n isLoading,\n isRequested,\n error,\n data,\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 actionBasedDecimals = action === 'withdraw' || action === 'borrow' ? 18 : token.decimals; // withdraw and borrow actions are in aToken decimals\n const allowance = await sodax.moneyMarket.isAllowanceValid(\n {\n token: token.address,\n amount: parseUnits(amount, actionBasedDecimals),\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 actionBasedDecimals = action === 'withdraw' || action === 'borrow' ? 18 : token.decimals; // withdraw and borrow actions are in aToken decimals\n const allowance = await sodax.moneyMarket.approve(\n {\n token: token.address,\n amount: parseUnits(amount, actionBasedDecimals),\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 { Address, XToken } from '@sodax/sdk';\nimport { useQuery, type UseQueryResult } from '@tanstack/react-query';\nimport { useSodaxContext } from '../shared/useSodaxContext';\n\n/**\n * React hook for fetching an AToken's ERC20 metadata from the Sodax money market.\n *\n * Fetches and caches the metadata (name, symbol, decimals, address) for a given aToken address and chain using React Query.\n * This metadata is typically required for rendering balances and labels in UI components.\n *\n * @param {Address | undefined} aToken - The aToken contract address to look up. Should be an EVM address.\n * @param {ChainId | undefined} chainId - The EVM chain ID for the aToken.\n *\n * @example\n * ```typescript\n * const { data: aToken, isLoading, error } = useAToken(aTokenAddress, chainId);\n * if (aToken) {\n * console.log(aToken.symbol); // 'aETH'\n * }\n * ```\n *\n * @returns {UseQueryResult<Erc20Token, Error>} A React Query result object containing:\n * - data: The aToken ERC20 metadata when available.\n * - isLoading: Loading state indicator.\n * - error: Any error that occurred during data fetching.\n */\nexport function useAToken(\n aToken: Address | undefined,\n): UseQueryResult<XToken, Error> {\n const { sodax } = useSodaxContext();\n\n return useQuery({\n queryKey: ['aToken', sodax.hubProvider.chainConfig.chain.id, aToken],\n queryFn: async () => {\n if (!aToken) {\n throw new Error('aToken address or hub provider is not defined');\n }\n\n const aTokenData = await sodax.moneyMarket.data.getATokenData(aToken);\n return {\n ...aTokenData,\n xChainId: sodax.hubProvider.chainConfig.chain.id,\n };\n },\n enabled: !!aToken,\n });\n}\n","import type { FormatReserveUSDResponse, ReserveData } from '@sodax/sdk';\nimport { useQuery, type UseQueryResult } from '@tanstack/react-query';\nimport { useSodaxContext } from '../shared/useSodaxContext';\n\n/**\n * Hook for fetching formatted summary of Sodax user portfolio (holdings, total liquidity,\n * collateral, borrows, liquidation threshold, health factor, available borrowing power, etc..).\n *\n * This hook provides access to the current state of user portfolio in the money market protocol.\n * The data is automatically fetched and cached using React Query.\n *\n * @example\n * ```typescript\n * const { data: userFormattedSummary, isLoading, error } = useUserFormattedSummary();\n * ```\n *\n * @returns A React Query result object containing:\n * - data: The formatted summary of Sodax user portfolio when available\n * - isLoading: Loading state indicator\n * - error: Any error that occurred during data fetching\n */\nexport function useReservesUsdFormat(): UseQueryResult<\n (ReserveData & { priceInMarketReferenceCurrency: string } & FormatReserveUSDResponse)[],\n Error\n> {\n const { sodax } = useSodaxContext();\n\n return useQuery({\n queryKey: ['reservesUsdFormat'],\n queryFn: async () => {\n // fetch reserves and hub wallet address\n const reserves = await sodax.moneyMarket.data.getReservesHumanized();\n\n // format reserves\n return sodax.moneyMarket.data.formatReservesUSD(sodax.moneyMarket.data.buildReserveDataWithPrice(reserves));\n },\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';\nimport { useMemo } from 'react';\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 \n // Create a serializable query key by converting BigInt to string\n const queryKey = useMemo(() => {\n if (!payload) return ['quote', undefined];\n return [\n 'quote',\n {\n ...payload,\n amount: payload.amount.toString(),\n },\n ];\n }, [payload]);\n\n return useQuery({\n queryKey,\n queryFn: async () => {\n if (!payload) {\n return undefined;\n }\n return sodax.swap.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, useQueryClient } 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 const queryClient = useQueryClient();\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.swap.swap({\n intentParams: params,\n spokeProvider,\n });\n },\n onSuccess: () => {\n // Invalidate balance queries to refresh both source and destination token balances\n queryClient.invalidateQueries({ queryKey: ['xBalances'] });\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.swap.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.swap.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 refetchInterval: 2000,\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.swap.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] });\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.swap.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 intent created transaction hash from the backend API.\n *\n * This hook provides access to intent data associated with the transaction hash from when\n * the intent was created on the hub chain, including intent details, events, and transaction\n * information. The data is automatically fetched and cached using React Query.\n *\n * @param {string | undefined} txHash - The intent created transaction hash from the hub chain 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 * - Intents are only created on the hub chain, so the transaction hash must be from the hub chain\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 = (\n txHash: string | undefined,\n refetchInterval = 1000,\n): 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.backendApi.getIntentByTxHash(txHash);\n },\n refetchInterval,\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.backendApi.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.backendApi.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.backendApi.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.backendApi.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.backendApi.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.backendApi.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.backendApi.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.backendApi.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 { 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","// packages/dapp-kit/src/hooks/staking/useStake.ts\nimport { useSodaxContext } from '../shared/useSodaxContext';\nimport type { StakeParams, SpokeTxHash, HubTxHash, SpokeProvider } from '@sodax/sdk';\nimport { useMutation, type UseMutationResult } from '@tanstack/react-query';\n\n/**\n * Hook for executing stake transactions to stake SODA tokens and receive xSODA shares.\n * Uses React Query's useMutation for better state management and caching.\n *\n * @param {SpokeProvider | undefined} spokeProvider - The spoke provider to use for the stake\n * @returns {UseMutationResult<[SpokeTxHash, HubTxHash], Error, StakeParams>} Mutation result object containing mutation function and state\n *\n * @example\n * ```typescript\n * const { mutateAsync: stake, isPending } = useStake(spokeProvider);\n *\n * const handleStake = async () => {\n * const result = await stake({\n * amount: 1000000000000000000n, // 1 SODA\n * account: '0x...'\n * });\n *\n * console.log('Stake successful:', result);\n * };\n * ```\n */\nexport function useStake(\n spokeProvider: SpokeProvider | undefined,\n): UseMutationResult<[SpokeTxHash, HubTxHash], Error, StakeParams> {\n const { sodax } = useSodaxContext();\n\n return useMutation<[SpokeTxHash, HubTxHash], Error, StakeParams>({\n mutationFn: async (params: StakeParams) => {\n if (!spokeProvider) {\n throw new Error('Spoke provider not found');\n }\n\n const result = await sodax.staking.stake(params, spokeProvider);\n\n if (!result.ok) {\n throw new Error(`Stake failed: ${result.error.code}`);\n }\n\n return result.value;\n },\n });\n}\n","// packages/dapp-kit/src/hooks/staking/useStakeApprove.ts\nimport { useSodaxContext } from '../shared/useSodaxContext';\nimport type { StakeParams, TxReturnType, SpokeProvider } from '@sodax/sdk';\nimport { useMutation, type UseMutationResult } from '@tanstack/react-query';\n\n/**\n * Hook for approving SODA token spending for staking operations.\n * Uses React Query's useMutation for better state management and caching.\n *\n * @param {SpokeProvider | undefined} spokeProvider - The spoke provider to use for the approval\n * @returns {UseMutationResult<TxReturnType<SpokeProvider, false>, Error, Omit<StakeParams, 'action'>>} Mutation result object containing mutation function and state\n *\n * @example\n * ```typescript\n * const { mutateAsync: approve, isPending } = useStakeApprove(spokeProvider);\n *\n * const handleApprove = async () => {\n * const result = await approve({\n * amount: 1000000000000000000n, // 1 SODA\n * account: '0x...'\n * });\n *\n * console.log('Approval successful:', result);\n * };\n * ```\n */\nexport function useStakeApprove(\n spokeProvider: SpokeProvider | undefined,\n): UseMutationResult<TxReturnType<SpokeProvider, false>, Error, Omit<StakeParams, 'action'>> {\n const { sodax } = useSodaxContext();\n\n return useMutation<TxReturnType<SpokeProvider, false>, Error, Omit<StakeParams, 'action'>>({\n mutationFn: async (params: Omit<StakeParams, 'action'>) => {\n if (!spokeProvider) {\n throw new Error('Spoke provider not found');\n }\n\n const result = await sodax.staking.approve({\n params: { ...params, action: 'stake' },\n spokeProvider,\n });\n\n if (!result.ok) {\n throw new Error(`Stake approval failed: ${result.error.code}`);\n }\n\n return result.value;\n },\n });\n}\n","// packages/dapp-kit/src/hooks/staking/useStakeAllowance.ts\nimport { useSodaxContext } from '../shared/useSodaxContext';\nimport type { StakeParams, SpokeProvider } from '@sodax/sdk';\nimport { useQuery, type UseQueryResult } from '@tanstack/react-query';\n\n/**\n * Hook for checking SODA token allowance for staking operations.\n * Uses React Query for efficient caching and state management.\n *\n * @param {Omit<StakeParams, 'action'> | undefined} params - The staking parameters. If undefined, the query will be disabled.\n * @param {SpokeProvider | undefined} spokeProvider - The spoke provider to use for the allowance check\n * @returns {UseQueryResult<boolean, Error>} Query result object containing allowance data and state\n *\n * @example\n * ```typescript\n * const { data: hasAllowed, isLoading } = useStakeAllowance(\n * {\n * amount: 1000000000000000000n, // 1 SODA\n * account: '0x...'\n * },\n * spokeProvider\n * );\n *\n * if (isLoading) return <div>Checking allowance...</div>;\n * if (hasAllowed) {\n * console.log('Sufficient allowance for staking');\n * }\n * ```\n */\nexport function useStakeAllowance(\n params: Omit<StakeParams, 'action'> | undefined,\n spokeProvider: SpokeProvider | undefined,\n): UseQueryResult<boolean, Error> {\n const { sodax } = useSodaxContext();\n\n return useQuery({\n queryKey: ['soda', 'stakeAllowance', params, spokeProvider?.chainConfig.chain.id],\n queryFn: async () => {\n if (!params || !spokeProvider) {\n return false;\n }\n\n const result = await sodax.staking.isAllowanceValid({\n params: { ...params, action: 'stake' },\n spokeProvider,\n });\n\n if (!result.ok) {\n throw new Error(`Allowance check failed: ${result.error.code}`);\n }\n\n return result.value;\n },\n enabled: !!params && !!spokeProvider,\n refetchInterval: 5000, // Refetch every 5 seconds\n });\n}\n","// packages/dapp-kit/src/hooks/staking/useUnstake.ts\nimport { useSodaxContext } from '../shared/useSodaxContext';\nimport type { UnstakeParams, SpokeTxHash, HubTxHash, SpokeProvider } from '@sodax/sdk';\nimport { useMutation, useQueryClient, type UseMutationResult } from '@tanstack/react-query';\n\n/**\n * Hook for executing unstake transactions to unstake xSODA shares.\n * Uses React Query's useMutation for better state management and caching.\n *\n * @param {SpokeProvider | undefined} spokeProvider - The spoke provider to use for the unstake\n * @returns {UseMutationResult<[SpokeTxHash, HubTxHash], Error, Omit<UnstakeParams, 'action'>>} Mutation result object containing mutation function and state\n *\n * @example\n * ```typescript\n * const { mutateAsync: unstake, isPending } = useUnstake(spokeProvider);\n *\n * const handleUnstake = async () => {\n * const result = await unstake({\n * amount: 1000000000000000000n, // 1 xSODA\n * account: '0x...'\n * });\n *\n * console.log('Unstake successful:', result);\n * };\n * ```\n */\nexport function useUnstake(\n spokeProvider: SpokeProvider | undefined,\n): UseMutationResult<[SpokeTxHash, HubTxHash], Error, Omit<UnstakeParams, 'action'>> {\n const { sodax } = useSodaxContext();\n const queryClient = useQueryClient();\n\n return useMutation<[SpokeTxHash, HubTxHash], Error, Omit<UnstakeParams, 'action'>>({\n mutationFn: async (params: Omit<UnstakeParams, 'action'>) => {\n if (!spokeProvider) {\n throw new Error('Spoke provider not found');\n }\n\n const result = await sodax.staking.unstake({ ...params, action: 'unstake' }, spokeProvider);\n\n if (!result.ok) {\n throw new Error(`Unstake failed: ${result.error.code}`);\n }\n\n return result.value;\n },\n onSuccess: () => {\n // Invalidate relevant queries to refresh data\n queryClient.invalidateQueries({ queryKey: ['stakingInfo'] });\n queryClient.invalidateQueries({ queryKey: ['unstakingInfo'] });\n queryClient.invalidateQueries({ queryKey: ['unstakingInfoWithPenalty'] });\n },\n });\n}\n","// packages/dapp-kit/src/hooks/staking/useClaim.ts\nimport { useSodaxContext } from '../shared/useSodaxContext';\nimport type { ClaimParams, SpokeTxHash, HubTxHash, SpokeProvider } from '@sodax/sdk';\nimport { useMutation, type UseMutationResult } from '@tanstack/react-query';\n\n/**\n * Hook for executing claim transactions to claim unstaked SODA tokens after the unstaking period.\n * Uses React Query's useMutation for better state management and caching.\n *\n * @param {SpokeProvider | undefined} spokeProvider - The spoke provider to use for the claim\n * @returns {UseMutationResult<[SpokeTxHash, HubTxHash], Error, Omit<ClaimParams, 'action'>>} Mutation result object containing mutation function and state\n *\n * @example\n * ```typescript\n * const { mutateAsync: claim, isPending } = useClaim(spokeProvider);\n *\n * const handleClaim = async () => {\n * const result = await claim({\n * requestId: 1n\n * });\n *\n * console.log('Claim successful:', result);\n * };\n * ```\n */\nexport function useClaim(\n spokeProvider: SpokeProvider | undefined,\n): UseMutationResult<[SpokeTxHash, HubTxHash], Error, Omit<ClaimParams, 'action'>> {\n const { sodax } = useSodaxContext();\n\n return useMutation<[SpokeTxHash, HubTxHash], Error, Omit<ClaimParams, 'action'>>({\n mutationFn: async (params: Omit<ClaimParams, 'action'>) => {\n if (!spokeProvider) {\n throw new Error('Spoke provider not found');\n }\n\n const result = await sodax.staking.claim({ ...params, action: 'claim' }, spokeProvider);\n\n if (!result.ok) {\n throw new Error(`Claim failed: ${result.error.code}`);\n }\n\n return result.value;\n },\n });\n}\n","// packages/dapp-kit/src/hooks/staking/useCancelUnstake.ts\nimport { useMutation, useQueryClient, type UseMutationResult } from '@tanstack/react-query';\nimport { useSodaxContext } from '../shared/useSodaxContext';\nimport type { CancelUnstakeParams, SpokeProvider, SpokeTxHash, HubTxHash } from '@sodax/sdk';\n\n/**\n * Hook for executing cancel unstake transactions to cancel pending unstake requests.\n * Uses React Query's useMutation for better state management and caching.\n *\n * @param {SpokeProvider | undefined} spokeProvider - The spoke provider to use for the cancel unstake\n * @returns {UseMutationResult<[SpokeTxHash, HubTxHash], Error, Omit<CancelUnstakeParams, 'action'>>} Mutation result object containing mutation function and state\n *\n * @example\n * ```typescript\n * const { mutateAsync: cancelUnstake, isPending } = useCancelUnstake(spokeProvider);\n *\n * const handleCancelUnstake = async () => {\n * const result = await cancelUnstake({\n * requestId: 1n\n * });\n *\n * console.log('Cancel unstake successful:', result);\n * };\n * ```\n */\nexport function useCancelUnstake(\n spokeProvider: SpokeProvider | undefined,\n): UseMutationResult<[SpokeTxHash, HubTxHash], Error, Omit<CancelUnstakeParams, 'action'>> {\n const { sodax } = useSodaxContext();\n const queryClient = useQueryClient();\n\n return useMutation({\n mutationFn: async (params: Omit<CancelUnstakeParams, 'action'>) => {\n if (!spokeProvider) {\n throw new Error('Spoke provider not available');\n }\n\n const result = await sodax.staking.cancelUnstake({ ...params, action: 'cancelUnstake' }, spokeProvider);\n if (!result.ok) {\n throw new Error(`Cancel unstake failed: ${result.error.code}`);\n }\n\n return result.value;\n },\n onSuccess: () => {\n // Invalidate relevant queries to refresh data\n queryClient.invalidateQueries({ queryKey: ['stakingInfo'] });\n queryClient.invalidateQueries({ queryKey: ['unstakingInfo'] });\n queryClient.invalidateQueries({ queryKey: ['unstakingInfoWithPenalty'] });\n },\n });\n}\n","// packages/dapp-kit/src/hooks/staking/useStakingInfo.ts\nimport { useSodaxContext } from '../shared/useSodaxContext';\nimport type { StakingInfo, SpokeProvider } from '@sodax/sdk';\nimport { useQuery, type UseQueryResult } from '@tanstack/react-query';\n\n/**\n * Hook for fetching comprehensive staking information for a user.\n * Uses React Query for efficient caching and state management.\n *\n * @param {SpokeProvider | undefined} spokeProvider - The spoke provider to use for the query\n * @param {number} refetchInterval - The interval in milliseconds to refetch data (default: 5000)\n * @returns {UseQueryResult<StakingInfo, Error>} Query result object containing staking info and state\n *\n * @example\n * ```typescript\n * const { data: stakingInfo, isLoading, error } = useStakingInfo(spokeProvider);\n *\n * if (isLoading) return <div>Loading staking info...</div>;\n * if (stakingInfo) {\n * console.log('Total staked:', stakingInfo.totalStaked);\n * console.log('User staked:', stakingInfo.userStaked);\n * console.log('xSODA balance:', stakingInfo.userXSodaBalance);\n * }\n * ```\n */\nexport function useStakingInfo(\n spokeProvider: SpokeProvider | undefined,\n refetchInterval = 5000,\n): UseQueryResult<StakingInfo, Error> {\n const { sodax } = useSodaxContext();\n\n return useQuery({\n queryKey: ['soda', 'stakingInfo', spokeProvider?.chainConfig.chain.id],\n queryFn: async () => {\n if (!spokeProvider) {\n throw new Error('Spoke provider not found');\n }\n\n const result = await sodax.staking.getStakingInfoFromSpoke(spokeProvider);\n\n if (!result.ok) {\n throw new Error(`Failed to fetch staking info: ${result.error.code}`);\n }\n\n return result.value;\n },\n enabled: !!spokeProvider,\n refetchInterval,\n });\n}\n","// packages/dapp-kit/src/hooks/staking/useUnstakingInfoWithPenalty.ts\nimport { useSodaxContext } from '../shared/useSodaxContext';\nimport type { UnstakingInfo, UnstakeRequestWithPenalty, SpokeProvider } from '@sodax/sdk';\nimport { useQuery, type UseQueryResult } from '@tanstack/react-query';\n\nexport type UnstakingInfoWithPenalty = UnstakingInfo & {\n requestsWithPenalty: UnstakeRequestWithPenalty[];\n};\n\n/**\n * Hook for fetching unstaking information with penalty calculations from the stakedSoda contract.\n * Uses React Query for efficient caching and state management.\n *\n * @param {string | undefined} userAddress - The user address to fetch unstaking info for\n * @param {SpokeProvider | undefined} spokeProvider - The spoke provider instance\n * @param {number} refetchInterval - The interval in milliseconds to refetch data (default: 5000)\n * @returns {UseQueryResult<UnstakingInfoWithPenalty, Error>} Query result object containing unstaking info with penalties and state\n *\n * @example\n * ```typescript\n * const { data: unstakingInfo, isLoading, error } = useUnstakingInfoWithPenalty(userAddress, spokeProvider);\n *\n * if (isLoading) return <div>Loading unstaking info...</div>;\n * if (unstakingInfo) {\n * console.log('Total unstaking:', unstakingInfo.totalUnstaking);\n * unstakingInfo.requestsWithPenalty.forEach(request => {\n * console.log('Penalty:', request.penaltyPercentage + '%');\n * console.log('Claimable amount:', request.claimableAmount);\n * });\n * }\n * ```\n */\nexport function useUnstakingInfoWithPenalty(\n userAddress: string | undefined,\n spokeProvider: SpokeProvider | undefined,\n refetchInterval = 5000,\n): UseQueryResult<UnstakingInfoWithPenalty, Error> {\n const { sodax } = useSodaxContext();\n\n return useQuery({\n queryKey: ['soda', 'unstakingInfoWithPenalty', spokeProvider?.chainConfig.chain.id, userAddress],\n queryFn: async () => {\n if (!spokeProvider) {\n throw new Error('Spoke provider not found');\n }\n\n // Get unstaking info with penalty calculations\n const penaltyResult = await sodax.staking.getUnstakingInfoWithPenalty(spokeProvider);\n\n if (!penaltyResult.ok) {\n throw new Error(`Failed to fetch unstaking info with penalty: ${penaltyResult.error.code}`);\n }\n\n return penaltyResult.value;\n },\n enabled: !!spokeProvider && !!userAddress,\n refetchInterval,\n });\n}\n","// packages/dapp-kit/src/hooks/staking/useStakingConfig.ts\nimport { useSodaxContext } from '../shared/useSodaxContext';\nimport type { StakingConfig } from '@sodax/sdk';\nimport { useQuery, type UseQueryResult } from '@tanstack/react-query';\n\n/**\n * Hook for fetching staking configuration from the stakedSoda contract.\n * Uses React Query for efficient caching and state management.\n *\n * @param {number} refetchInterval - The interval in milliseconds to refetch data (default: 30000)\n * @returns {UseQueryResult<StakingConfig, Error>} Query result object containing staking config and state\n *\n * @example\n * ```typescript\n * const { data: stakingConfig, isLoading, error } = useStakingConfig();\n *\n * if (isLoading) return <div>Loading staking config...</div>;\n * if (stakingConfig) {\n * console.log('Unstaking period (days):', stakingConfig.unstakingPeriod / 86400n);\n * console.log('Max penalty (%):', stakingConfig.maxPenalty);\n * }\n * ```\n */\nexport function useStakingConfig(refetchInterval = 30000): UseQueryResult<StakingConfig, Error> {\n const { sodax } = useSodaxContext();\n\n return useQuery({\n queryKey: ['soda', 'stakingConfig'],\n queryFn: async () => {\n const result = await sodax.staking.getStakingConfig();\n\n if (!result.ok) {\n throw new Error(`Failed to fetch staking config: ${result.error.code}`);\n }\n\n return result.value;\n },\n refetchInterval,\n });\n}\n","// packages/dapp-kit/src/hooks/staking/useStakeRatio.ts\nimport { useSodaxContext } from '../shared/useSodaxContext';\nimport { useQuery, type UseQueryResult } from '@tanstack/react-query';\n\n/**\n * Hook for fetching stake ratio estimates (xSoda amount and preview deposit).\n * Uses React Query for efficient caching and state management.\n *\n * @param {bigint | undefined} amount - The amount of SODA to estimate stake for\n * @param {number} refetchInterval - The interval in milliseconds to refetch data (default: 10000)\n * @returns {UseQueryResult<[bigint, bigint], Error>} Query result object containing stake ratio estimates and state\n *\n * @example\n * ```typescript\n * const { data: stakeRatio, isLoading, error } = useStakeRatio(1000000000000000000n); // 1 SODA\n *\n * if (isLoading) return <div>Loading stake ratio...</div>;\n * if (stakeRatio) {\n * const [xSodaAmount, previewDepositAmount] = stakeRatio;\n * console.log('xSoda amount:', xSodaAmount);\n * console.log('Preview deposit:', previewDepositAmount);\n * }\n * ```\n */\nexport function useStakeRatio(\n amount: bigint | undefined,\n refetchInterval = 10000,\n): UseQueryResult<[bigint, bigint], Error> {\n const { sodax } = useSodaxContext();\n\n return useQuery({\n queryKey: ['soda', 'stakeRatio', amount?.toString()],\n queryFn: async () => {\n if (!amount || amount <= 0n) {\n throw new Error('Amount must be greater than 0');\n }\n\n if (!sodax?.staking) {\n throw new Error('Staking service not available');\n }\n\n const result = await sodax.staking.getStakeRatio(amount);\n\n if (!result.ok) {\n throw new Error(`Failed to fetch stake ratio: ${result.error.code}`);\n }\n\n return result.value;\n },\n enabled: !!amount && amount > 0n && !!sodax?.staking,\n refetchInterval,\n });\n}\n","// packages/dapp-kit/src/hooks/staking/useInstantUnstakeRatio.ts\nimport { useSodaxContext } from '../shared/useSodaxContext';\nimport { useQuery, type UseQueryResult } from '@tanstack/react-query';\n\n/**\n * Hook for fetching instant unstake ratio estimates.\n * Uses React Query for efficient caching and state management.\n *\n * @param {bigint | undefined} amount - The amount of xSoda to estimate instant unstake for\n * @param {number} refetchInterval - The interval in milliseconds to refetch data (default: 10000)\n * @returns {UseQueryResult<bigint, Error>} Query result object containing instant unstake ratio and state\n *\n * @example\n * ```typescript\n * const { data: instantUnstakeRatio, isLoading, error } = useInstantUnstakeRatio(1000000000000000000n); // 1 xSoda\n *\n * if (isLoading) return <div>Loading instant unstake ratio...</div>;\n * if (instantUnstakeRatio) {\n * console.log('Instant unstake ratio:', instantUnstakeRatio);\n * }\n * ```\n */\nexport function useInstantUnstakeRatio(\n amount: bigint | undefined,\n refetchInterval = 10000,\n): UseQueryResult<bigint, Error> {\n const { sodax } = useSodaxContext();\n\n console.log('useInstantUnstakeRatio hook called with:', { amount: amount?.toString(), sodax: !!sodax });\n\n return useQuery({\n queryKey: ['soda', 'instantUnstakeRatio', amount?.toString()],\n queryFn: async () => {\n console.log('useInstantUnstakeRatio queryFn called with amount:', amount?.toString());\n if (!amount || amount <= 0n) {\n throw new Error('Amount must be greater than 0');\n }\n\n if (!sodax?.staking) {\n throw new Error('Staking service not available');\n }\n\n const result = await sodax.staking.getInstantUnstakeRatio(amount);\n\n if (!result.ok) {\n throw new Error(`Failed to fetch instant unstake ratio: ${result.error.code}`);\n }\n\n return result.value;\n },\n enabled: !!amount && amount > 0n && !!sodax?.staking,\n refetchInterval,\n });\n}\n","// packages/dapp-kit/src/hooks/staking/useConvertedAssets.ts\nimport { useSodaxContext } from '../shared/useSodaxContext';\nimport { useQuery, type UseQueryResult } from '@tanstack/react-query';\n\n/**\n * Hook for fetching converted assets amount for xSODA shares.\n * Uses React Query for efficient caching and state management.\n *\n * @param {bigint | undefined} amount - The amount of xSODA shares to convert\n * @param {number} refetchInterval - The interval in milliseconds to refetch data (default: 10000)\n * @returns {UseQueryResult<bigint, Error>} Query result object containing converted assets amount and state\n *\n * @example\n * ```typescript\n * const { data: convertedAssets, isLoading, error } = useConvertedAssets(1000000000000000000n); // 1 xSODA\n *\n * if (isLoading) return <div>Loading converted assets...</div>;\n * if (convertedAssets) {\n * console.log('Converted assets:', convertedAssets);\n * }\n * ```\n */\nexport function useConvertedAssets(amount: bigint | undefined, refetchInterval = 10000): UseQueryResult<bigint, Error> {\n const { sodax } = useSodaxContext();\n\n console.log('useConvertedAssets hook called with:', { amount: amount?.toString(), sodax: !!sodax });\n\n return useQuery({\n queryKey: ['soda', 'convertedAssets', amount?.toString()],\n queryFn: async () => {\n console.log('useConvertedAssets queryFn called with amount:', amount?.toString());\n if (!amount || amount <= 0n) {\n throw new Error('Amount must be greater than 0');\n }\n\n const result = await sodax.staking.getConvertedAssets(amount);\n\n if (!result.ok) {\n throw new Error(`Failed to fetch converted assets: ${result.error.code}`);\n }\n\n return result.value;\n },\n enabled: !!amount && amount > 0n && !!sodax?.staking,\n refetchInterval,\n });\n}\n","// packages/dapp-kit/src/hooks/staking/useInstantUnstake.ts\nimport { useSodaxContext } from '../shared/useSodaxContext';\nimport { useMutation, type UseMutationResult } from '@tanstack/react-query';\nimport type { SpokeProvider, InstantUnstakeParams } from '@sodax/sdk';\n\n/**\n * Hook for executing instant unstake operations.\n * Uses React Query for efficient state management and error handling.\n *\n * @param {SpokeProvider | undefined} spokeProvider - The spoke provider for the transaction\n * @returns {UseMutationResult<[string, string], Error, Omit<InstantUnstakeParams, 'action'>>} Mutation result object containing instant unstake state and methods\n *\n * @example\n * ```typescript\n * const { mutateAsync: instantUnstake, isPending } = useInstantUnstake(spokeProvider);\n *\n * const handleInstantUnstake = async () => {\n * const result = await instantUnstake({\n * amount: 1000000000000000000n,\n * minAmount: 950000000000000000n,\n * account: '0x...'\n * });\n * console.log('Instant unstake successful:', result);\n * };\n * ```\n */\nexport function useInstantUnstake(\n spokeProvider: SpokeProvider | undefined,\n): UseMutationResult<[string, string], Error, Omit<InstantUnstakeParams, 'action'>> {\n const { sodax } = useSodaxContext();\n\n return useMutation({\n mutationFn: async (params: Omit<InstantUnstakeParams, 'action'>) => {\n if (!spokeProvider) {\n throw new Error('spokeProvider is not found');\n }\n\n const result = await sodax.staking.instantUnstake({ ...params, action: 'instantUnstake' }, spokeProvider);\n\n if (!result.ok) {\n throw new Error(`Instant unstake failed: ${result.error.code}`);\n }\n\n return result.value;\n },\n onError: error => {\n console.error('Instant unstake error:', error);\n },\n });\n}\n","// packages/dapp-kit/src/hooks/staking/useStakeAllowance.ts\nimport { useSodaxContext } from '../shared/useSodaxContext';\nimport type { UnstakeParams, SpokeProvider } from '@sodax/sdk';\nimport { useQuery, type UseQueryResult } from '@tanstack/react-query';\n\n/**\n * Hook for checking xSODA token allowance for unstaking operations.\n * Uses React Query for efficient caching and state management.\n *\n * @param {Omit<UnstakeParams, 'action'> | undefined} params - The unstaking parameters. If undefined, the query will be disabled.\n * @param {SpokeProvider | undefined} spokeProvider - The spoke provider to use for the allowance check\n * @returns {UseQueryResult<boolean, Error>} Query result object containing allowance data and state\n *\n * @example\n * ```typescript\n * const { data: hasAllowed, isLoading } = useUnstakeAllowance(\n * {\n * amount: 1000000000000000000n, // 1 xSODA\n * account: '0x...'\n * },\n * spokeProvider\n * );\n *\n * if (isLoading) return <div>Checking allowance...</div>;\n * if (hasAllowed) {\n * console.log('Sufficient allowance for unstaking');\n * }\n * ```\n */\nexport function useUnstakeAllowance(\n params: Omit<UnstakeParams, 'action'> | undefined,\n spokeProvider: SpokeProvider | undefined,\n): UseQueryResult<boolean, Error> {\n const { sodax } = useSodaxContext();\n\n return useQuery({\n queryKey: ['soda', 'unstakeAllowance', params, spokeProvider?.chainConfig.chain.id],\n queryFn: async () => {\n if (!params || !spokeProvider) {\n return false;\n }\n\n const result = await sodax.staking.isAllowanceValid({\n params: { ...params, action: 'unstake' },\n spokeProvider,\n });\n\n if (!result.ok) {\n console.error(`Unstake allowance check failed: ${result.error.code}, error: ${result.error.error}`);\n throw new Error(`Unstake allowance check failed: ${result.error.code}`);\n }\n\n return result.value;\n },\n enabled: !!params && !!spokeProvider,\n refetchInterval: 5000, // Refetch every 5 seconds\n });\n}\n","// packages/dapp-kit/src/hooks/staking/useStakeApprove.ts\nimport { useSodaxContext } from '../shared/useSodaxContext';\nimport type { TxReturnType, UnstakeParams } from '@sodax/sdk';\nimport { useMutation, type UseMutationResult } from '@tanstack/react-query';\nimport type { SpokeProvider } from '@sodax/sdk';\n\n/**\n * Hook for approving xSODA token spending for unstaking operations.\n * Uses React Query's useMutation for better state management and caching.\n *\n * @param {SpokeProvider | undefined} spokeProvider - The spoke provider to use for the approval\n * @returns {UseMutationResult<TxReturnType<SpokeProvider, false>, Error, Omit<UnstakeParams, 'action'>>} Mutation result object containing mutation function and state\n *\n * @example\n * ```typescript\n * const { mutateAsync: approve, isPending } = useUnstakeApprove(spokeProvider);\n *\n * const handleApprove = async () => {\n * const result = await approve({\n * amount: 1000000000000000000n, // 1 xSODA\n * account: '0x...'\n * });\n *\n * console.log('Approval successful:', result);\n * };\n * ```\n */\nexport function useUnstakeApprove(\n spokeProvider: SpokeProvider | undefined,\n): UseMutationResult<TxReturnType<SpokeProvider, false>, Error, Omit<UnstakeParams, 'action'>> {\n const { sodax } = useSodaxContext();\n\n return useMutation<TxReturnType<SpokeProvider, false>, Error, Omit<UnstakeParams, 'action'>>({\n mutationFn: async (params: Omit<UnstakeParams, 'action'>) => {\n console.log('useUnstakeApprove called with params:', params);\n if (!spokeProvider) {\n throw new Error('Spoke provider not found');\n }\n\n const result = await sodax.staking.approve({\n params: { ...params, action: 'unstake' },\n spokeProvider,\n });\n\n if (!result.ok) {\n throw new Error(`Unstake approval failed: ${result.error.code}`);\n }\n\n return result.value;\n },\n });\n}\n","// packages/dapp-kit/src/hooks/staking/useUnstakingInfoWithPenalty.ts\nimport { useSodaxContext } from '../shared/useSodaxContext';\nimport type { UnstakingInfo, SpokeProvider } from '@sodax/sdk';\nimport { useQuery, type UseQueryResult } from '@tanstack/react-query';\n\n/**\n * Hook for fetching unstaking information from the stakedSoda contract.\n * Uses React Query for efficient caching and state management.\n *\n * @param {string | undefined} userAddress - The user address to fetch unstaking info for\n * @param {SpokeProvider | undefined} spokeProvider - The spoke provider instance\n * @param {number} refetchInterval - The interval in milliseconds to refetch data (default: 5000)\n * @returns {UseQueryResult<UnstakingInfo, Error>} Query result object containing unstaking info and state\n *\n * @example\n * ```typescript\n * const { data: unstakingInfo, isLoading, error } = useUnstakingInfo(userAddress, spokeProvider);\n *\n * if (isLoading) return <div>Loading unstaking info...</div>;\n * if (unstakingInfo) {\n * console.log('Total unstaking:', unstakingInfo.totalUnstaking);\n * unstakingInfo.userUnstakeSodaRequests.forEach(request => {\n * console.log('Request amount:', request.request.amount);\n * });\n * }\n * ```\n */\nexport function useUnstakingInfo(\n userAddress: string | undefined,\n spokeProvider: SpokeProvider | undefined,\n refetchInterval = 5000,\n): UseQueryResult<UnstakingInfo, Error> {\n const { sodax } = useSodaxContext();\n\n return useQuery({\n queryKey: ['soda', 'unstakingInfoWithPenalty', spokeProvider?.chainConfig.chain.id, userAddress],\n queryFn: async () => {\n if (!spokeProvider || !userAddress) {\n throw new Error('Spoke provider or user address not found');\n }\n\n const result = await sodax.staking.getUnstakingInfo(spokeProvider);\n\n if (!result.ok) {\n throw new Error(`Failed to fetch unstaking info: ${result.error.code}`);\n }\n\n return result.value;\n },\n enabled: !!spokeProvider && !!userAddress,\n refetchInterval,\n });\n}\n","// packages/dapp-kit/src/hooks/staking/useStakeApprove.ts\nimport { useSodaxContext } from '../shared/useSodaxContext';\nimport type { InstantUnstakeParams, TxReturnType, SpokeProvider } from '@sodax/sdk';\nimport { useMutation, type UseMutationResult } from '@tanstack/react-query';\n\n/**\n * Hook for approving xSODA token spending for instant unstaking operations.\n * Uses React Query's useMutation for better state management and caching.\n *\n * @param {SpokeProvider | undefined} spokeProvider - The spoke provider to use for the approval\n * @returns {UseMutationResult<TxReturnType<SpokeProvider, false>, Error, Omit<InstantUnstakeParams, 'action'>>} Mutation result object containing mutation function and state\n *\n * @example\n * ```typescript\n * const { mutateAsync: approve, isPending } = useInstantUnstakeApprove(spokeProvider);\n *\n * const handleApprove = async () => {\n * const result = await approve({\n * amount: 1000000000000000000n, // 1 xSODA\n * minAmount: 950000000000000000n, // 0.95 SODA\n * account: '0x...'\n * });\n *\n * console.log('Approval successful:', result);\n * };\n * ```\n */\nexport function useInstantUnstakeApprove(\n spokeProvider: SpokeProvider | undefined,\n): UseMutationResult<TxReturnType<SpokeProvider, false>, Error, Omit<InstantUnstakeParams, 'action'>> {\n const { sodax } = useSodaxContext();\n\n return useMutation<TxReturnType<SpokeProvider, false>, Error, Omit<InstantUnstakeParams, 'action'>>({\n mutationFn: async (params: Omit<InstantUnstakeParams, 'action'>) => {\n console.log('useInstantUnstakeApprove called with params:', params);\n if (!spokeProvider) {\n throw new Error('Spoke provider not found');\n }\n\n const result = await sodax.staking.approve({\n params: { ...params, action: 'instantUnstake' },\n spokeProvider,\n });\n\n if (!result.ok) {\n throw new Error(`Instant unstake approval failed: ${result.error.code}`);\n }\n\n return result.value;\n },\n });\n}\n","// packages/dapp-kit/src/hooks/staking/useStakeAllowance.ts\nimport { useSodaxContext } from '../shared/useSodaxContext';\nimport type { SpokeProvider, InstantUnstakeParams } from '@sodax/sdk';\nimport { useQuery, type UseQueryResult } from '@tanstack/react-query';\n\n/**\n * Hook for checking xSODA token allowance for instant unstaking operations.\n * Uses React Query for efficient caching and state management.\n *\n * @param {Omit<InstantUnstakeParams, 'action'> | undefined} params - The instant unstaking parameters. If undefined, the query will be disabled.\n * @param {SpokeProvider | undefined} spokeProvider - The spoke provider to use for the allowance check\n * @returns {UseQueryResult<boolean, Error>} Query result object containing allowance data and state\n *\n * @example\n * ```typescript\n * const { data: hasAllowed, isLoading } = useInstantUnstakeAllowance(\n * {\n * amount: 1000000000000000000n, // 1 xSODA\n * minAmount: 950000000000000000n, // 0.95 SODA\n * account: '0x...'\n * },\n * spokeProvider\n * );\n *\n * if (isLoading) return <div>Checking allowance...</div>;\n * if (hasAllowed) {\n * console.log('Sufficient allowance for instant unstaking');\n * }\n * ```\n */\nexport function useInstantUnstakeAllowance(\n params: Omit<InstantUnstakeParams, 'action'> | undefined,\n spokeProvider: SpokeProvider | undefined,\n): UseQueryResult<boolean, Error> {\n const { sodax } = useSodaxContext();\n\n return useQuery({\n queryKey: ['soda', 'instantUnstakeAllowance', params, spokeProvider?.chainConfig.chain.id],\n queryFn: async () => {\n if (!params || !spokeProvider) {\n return false;\n }\n\n const result = await sodax.staking.isAllowanceValid({\n params: { ...params, action: 'instantUnstake' },\n spokeProvider,\n });\n\n if (!result.ok) {\n console.error(`Unstake allowance check failed: ${result.error.code}, error: ${result.error.error}`);\n throw new Error(`Unstake allowance check failed: ${result.error.code}`);\n }\n\n return result.value;\n },\n enabled: !!params && !!spokeProvider,\n refetchInterval: 5000, // Refetch every 5 seconds\n });\n}\n","import type { XToken } from '@sodax/types';\r\n\r\nexport const MIGRATION_MODE_ICX_SODA = 'icxsoda';\r\nexport const MIGRATION_MODE_BNUSD = 'bnusd';\r\n\r\nexport type MigrationMode = typeof MIGRATION_MODE_ICX_SODA | typeof MIGRATION_MODE_BNUSD;\r\n\r\nexport interface MigrationIntentParams {\r\n token: XToken | undefined;\r\n amount: string | undefined;\r\n sourceAddress: string | undefined;\r\n migrationMode?: MigrationMode;\r\n toToken?: XToken;\r\n destinationAddress?: string;\r\n}\r\n","import { parseUnits } from 'viem';\nimport {\n spokeChainConfig,\n type UnifiedBnUSDMigrateParams,\n type IconSpokeProvider,\n type SonicSpokeProvider,\n isLegacybnUSDToken,\n type SpokeProvider,\n} from '@sodax/sdk';\nimport { type ChainId, ICON_MAINNET_CHAIN_ID } from '@sodax/types';\nimport { useSodaxContext } from '../shared/useSodaxContext';\nimport { useMutation, type UseMutationResult } from '@tanstack/react-query';\nimport { MIGRATION_MODE_BNUSD, MIGRATION_MODE_ICX_SODA, type MigrationIntentParams } from './types';\n\n/**\n * Hook for executing migration operations between chains.\n *\n * This hook handles ICX/SODA and bnUSD migrations by accepting a spoke provider\n * and returning a mutation function that accepts migration parameters.\n *\n * @param {SpokeProvider} spokeProvider - The spoke provider to use for the migration\n * @returns {UseMutationResult} Mutation result object containing migration function and state\n *\n * @example\n * ```typescript\n * const { mutateAsync: migrate, isPending } = useMigrate(spokeProvider);\n *\n * const result = await migrate({\n * token: { address: \"0x...\", decimals: 18 },\n * amount: \"100\",\n * migrationMode: MIGRATION_MODE_ICX_SODA,\n * toToken: { address: \"0x...\", decimals: 18 },\n * destinationAddress: \"0x...\"\n * });\n * ```\n */\nexport function useMigrate(\n spokeProvider: SpokeProvider | undefined,\n): UseMutationResult<{ spokeTxHash: string; hubTxHash: `0x${string}` }, Error, MigrationIntentParams> {\n const { sodax } = useSodaxContext();\n\n return useMutation({\n mutationFn: async (params: MigrationIntentParams) => {\n const { token, amount, migrationMode = MIGRATION_MODE_ICX_SODA, toToken, destinationAddress } = params;\n const amountToMigrate = parseUnits(amount ?? '0', token?.decimals ?? 0);\n\n if (!spokeProvider) {\n throw new Error('Spoke provider not found');\n }\n\n if (migrationMode === MIGRATION_MODE_ICX_SODA) {\n // ICX->SODA migration logic\n if (token?.xChainId === ICON_MAINNET_CHAIN_ID) {\n const params = {\n address: spokeChainConfig[ICON_MAINNET_CHAIN_ID].nativeToken,\n amount: amountToMigrate,\n to: destinationAddress as `0x${string}`,\n };\n const result = await sodax.migration.migrateIcxToSoda(params, spokeProvider as IconSpokeProvider, 30000);\n if (result.ok) {\n const [spokeTxHash, hubTxHash] = result.value;\n return { spokeTxHash, hubTxHash };\n }\n throw new Error('ICX to SODA migration failed. Please try again.');\n }\n\n // SODA->ICX migration\n const revertParams = {\n amount: amountToMigrate,\n to: destinationAddress as `hx${string}`,\n };\n const result = await sodax.migration.revertMigrateSodaToIcx(\n revertParams,\n spokeProvider as SonicSpokeProvider,\n 30000,\n );\n if (result.ok) {\n const [hubTxHash, spokeTxHash] = result.value;\n return { spokeTxHash, hubTxHash };\n }\n throw new Error('SODA to ICX migration failed. Please try again.');\n }\n\n if (migrationMode === MIGRATION_MODE_BNUSD) {\n // bnUSD migration logic - handle dynamic source/destination chains\n const params = {\n srcChainId: token?.xChainId as ChainId,\n dstChainId: toToken?.xChainId as ChainId,\n srcbnUSD: token?.address as string,\n dstbnUSD: toToken?.address as string,\n amount: amountToMigrate,\n to: destinationAddress as `hx${string}` | `0x${string}`,\n } satisfies UnifiedBnUSDMigrateParams;\n\n const result = await sodax.migration.migratebnUSD(params, spokeProvider, 30000);\n if (result.ok) {\n const [spokeTxHash, hubTxHash] = result.value;\n return { spokeTxHash, hubTxHash };\n }\n\n const errorMessage = isLegacybnUSDToken(token?.address as string)\n ? 'bnUSD migration failed. Please try again.'\n : 'bnUSD reverse migration failed. Please try again.';\n throw new Error(errorMessage);\n }\n\n throw new Error('Invalid migration mode');\n },\n });\n}\n","import { useQuery, type UseQueryResult } from '@tanstack/react-query';\nimport type { ChainId } from '@sodax/types';\nimport { useSodaxContext } from '../shared/useSodaxContext';\nimport { parseUnits } from 'viem';\nimport type { IcxCreateRevertMigrationParams, UnifiedBnUSDMigrateParams, SpokeProvider } from '@sodax/sdk';\nimport { ICON_MAINNET_CHAIN_ID } from '@sodax/types';\nimport { MIGRATION_MODE_ICX_SODA, type MigrationIntentParams } from './types';\n\n/**\n * Hook for checking token allowance for migration operations.\n *\n * This hook verifies if the user has approved enough tokens for migration operations.\n * It handles both ICX/SODA and bnUSD migration allowance checks.\n *\n * @param {MigrationIntentParams} params - The parameters for the migration allowance check\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 } = useMigrationAllowance(params, spokeProvider);\n * ```\n */\nexport function useMigrationAllowance(\n params: MigrationIntentParams | undefined,\n spokeProvider: SpokeProvider | undefined,\n): UseQueryResult<boolean, Error> {\n const { sodax } = useSodaxContext();\n\n return useQuery({\n queryKey: ['migration-allowance', params],\n queryFn: async () => {\n if (!spokeProvider || !params) {\n return false;\n }\n\n const { token, amount, migrationMode = MIGRATION_MODE_ICX_SODA, toToken, destinationAddress } = params;\n\n // For ICON chain, no allowance is required (forward migrations)\n if (token?.xChainId === ICON_MAINNET_CHAIN_ID) {\n return true;\n }\n\n if (!spokeProvider) throw new Error('Spoke provider is required');\n const amountToMigrate = parseUnits(amount ?? '0', token?.decimals ?? 0);\n\n let migrationParams: IcxCreateRevertMigrationParams | UnifiedBnUSDMigrateParams;\n if (migrationMode === MIGRATION_MODE_ICX_SODA) {\n migrationParams = {\n amount: amountToMigrate,\n to: destinationAddress as `hx${string}`,\n } satisfies IcxCreateRevertMigrationParams;\n } else {\n if (!toToken) throw new Error('Destination token is required for bnUSD migration');\n\n migrationParams = {\n srcChainId: token?.xChainId as ChainId,\n dstChainId: toToken?.xChainId as ChainId,\n srcbnUSD: token?.address as string,\n dstbnUSD: toToken?.address as string,\n amount: amountToMigrate,\n to: destinationAddress as `hx${string}` | `0x${string}`,\n } satisfies UnifiedBnUSDMigrateParams;\n }\n\n const allowance = await sodax.migration.isAllowanceValid(migrationParams, 'revert', spokeProvider);\n if (allowance.ok) {\n return allowance.value;\n }\n return false;\n },\n enabled: !!spokeProvider && !!params,\n refetchInterval: 2000,\n });\n}\n","import { parseUnits } from 'viem';\nimport { useCallback, useState, useRef, useEffect } from 'react';\nimport type {\n IcxCreateRevertMigrationParams,\n UnifiedBnUSDMigrateParams,\n SpokeProvider,\n Result,\n ChainId,\n} from '@sodax/sdk';\nimport { useSodaxContext } from '../shared/useSodaxContext';\nimport { MIGRATION_MODE_BNUSD, MIGRATION_MODE_ICX_SODA, type MigrationIntentParams } from './types';\nimport { useQueryClient } from '@tanstack/react-query';\n\ninterface UseApproveReturn {\n approve: ({ params }: { params: MigrationIntentParams }) => Promise<boolean>;\n isLoading: boolean;\n error: Error | null;\n resetError: () => void;\n isApproved: boolean;\n}\n\n/**\n * Hook for approving token spending for migration actions\n * @param params The parameters for the migration approval\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 } = useMigrationApprove(params, spokeProvider);\n *\n * // Approve tokens for migration\n * await approve({ params });\n * ```\n */\n\nexport function useMigrationApprove(\n params: MigrationIntentParams | undefined,\n spokeProvider: SpokeProvider | undefined,\n): UseApproveReturn {\n const { sodax } = useSodaxContext();\n const [isLoading, setIsLoading] = useState(false);\n const [error, setError] = useState<Error | null>(null);\n const [isApproved, setIsApproved] = useState(false);\n const queryClient = useQueryClient();\n\n // Track previous values to reset approval state when needed\n const prevTokenAddress = useRef<string | undefined>(undefined);\n const prevAmount = useRef<string | undefined>(undefined);\n\n useEffect(() => {\n if (prevTokenAddress.current !== params?.token?.address || prevAmount.current !== params?.amount) {\n setIsApproved(false);\n prevTokenAddress.current = params?.token?.address;\n prevAmount.current = params?.amount;\n }\n }, [params?.token?.address, params?.amount]);\n\n const approve = useCallback(\n async ({ params: approveParams }: { params: MigrationIntentParams }) => {\n try {\n setIsLoading(true);\n setError(null);\n\n if (!spokeProvider) {\n throw new Error('Spoke provider not found');\n }\n if (!approveParams) {\n throw new Error('Migration intent not found');\n }\n\n const { token, amount, migrationMode = MIGRATION_MODE_ICX_SODA, toToken, destinationAddress } = approveParams;\n const amountToMigrate = parseUnits(amount ?? '0', token?.decimals ?? 0);\n\n let result: Result<string, unknown>;\n if (migrationMode === MIGRATION_MODE_ICX_SODA) {\n // ICX/SODA migration approval\n const revertParams = {\n amount: amountToMigrate,\n to: destinationAddress as `hx${string}`,\n } satisfies IcxCreateRevertMigrationParams;\n\n result = await sodax.migration.approve(revertParams, 'revert', spokeProvider, false);\n } else if (migrationMode === MIGRATION_MODE_BNUSD) {\n // bnUSD migration approval\n if (!toToken) throw new Error('Destination token is required for bnUSD migration');\n\n const migrationParams = {\n srcChainId: token?.xChainId as ChainId,\n dstChainId: toToken?.xChainId as ChainId,\n srcbnUSD: token?.address as string,\n dstbnUSD: toToken?.address as string,\n amount: amountToMigrate,\n to: destinationAddress as `hx${string}` | `0x${string}`,\n } satisfies UnifiedBnUSDMigrateParams;\n\n result = await sodax.migration.approve(migrationParams, 'revert', spokeProvider, false);\n } else {\n throw new Error('Invalid migration mode');\n }\n if (!result.ok) {\n throw new Error('Failed to approve tokens');\n }\n\n setIsApproved(true);\n queryClient.invalidateQueries({ queryKey: ['migration-allowance', params] });\n return result.ok;\n } catch (err) {\n const error = err instanceof Error ? err : new Error('An unknown error occurred');\n setError(error);\n throw error;\n } finally {\n setIsLoading(false);\n }\n },\n [spokeProvider, sodax, queryClient, params],\n );\n\n const resetError = useCallback(() => {\n setError(null);\n }, []);\n\n return {\n approve,\n isLoading,\n error,\n resetError,\n isApproved,\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 '@sodax/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"]}
|