@sodax/dapp-kit 0.0.1-rc.20 → 0.0.1-rc.22

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.
Files changed (49) hide show
  1. package/README.md +83 -1
  2. package/dist/contexts/index.d.ts +1 -2
  3. package/dist/contexts/index.d.ts.map +1 -1
  4. package/dist/hooks/bridge/index.d.ts +6 -0
  5. package/dist/hooks/bridge/index.d.ts.map +1 -0
  6. package/dist/hooks/bridge/useBridge.d.ts +33 -0
  7. package/dist/hooks/bridge/useBridge.d.ts.map +1 -0
  8. package/dist/hooks/bridge/useBridgeAllowance.d.ts +23 -0
  9. package/dist/hooks/bridge/useBridgeAllowance.d.ts.map +1 -0
  10. package/dist/hooks/bridge/useBridgeApprove.d.ts +29 -0
  11. package/dist/hooks/bridge/useBridgeApprove.d.ts.map +1 -0
  12. package/dist/hooks/bridge/useGetBridgeableAmount.d.ts +26 -0
  13. package/dist/hooks/bridge/useGetBridgeableAmount.d.ts.map +1 -0
  14. package/dist/hooks/bridge/useGetBridgeableTokens.d.ts +37 -0
  15. package/dist/hooks/bridge/useGetBridgeableTokens.d.ts.map +1 -0
  16. package/dist/hooks/index.d.ts +1 -0
  17. package/dist/hooks/index.d.ts.map +1 -1
  18. package/dist/hooks/mm/useUserFormattedSummary.d.ts +1 -1
  19. package/dist/hooks/mm/useUserFormattedSummary.d.ts.map +1 -1
  20. package/dist/hooks/mm/useUserReservesData.d.ts +1 -1
  21. package/dist/hooks/mm/useUserReservesData.d.ts.map +1 -1
  22. package/dist/hooks/provider/useHubProvider.d.ts +1 -1
  23. package/dist/hooks/provider/useHubProvider.d.ts.map +1 -1
  24. package/dist/hooks/provider/useSpokeProvider.d.ts.map +1 -1
  25. package/dist/hooks/shared/index.d.ts +1 -0
  26. package/dist/hooks/shared/index.d.ts.map +1 -1
  27. package/dist/hooks/shared/useDeriveUserWalletAddress.d.ts +24 -0
  28. package/dist/hooks/shared/useDeriveUserWalletAddress.d.ts.map +1 -0
  29. package/dist/index.js +139 -19
  30. package/dist/index.js.map +1 -1
  31. package/dist/index.mjs +135 -21
  32. package/dist/index.mjs.map +1 -1
  33. package/dist/providers/SodaxProvider.d.ts.map +1 -1
  34. package/package.json +2 -2
  35. package/src/contexts/index.ts +1 -2
  36. package/src/hooks/bridge/index.ts +5 -0
  37. package/src/hooks/bridge/useBridge.ts +57 -0
  38. package/src/hooks/bridge/useBridgeAllowance.ts +49 -0
  39. package/src/hooks/bridge/useBridgeApprove.ts +68 -0
  40. package/src/hooks/bridge/useGetBridgeableAmount.ts +50 -0
  41. package/src/hooks/bridge/useGetBridgeableTokens.ts +62 -0
  42. package/src/hooks/index.ts +1 -0
  43. package/src/hooks/mm/useUserFormattedSummary.ts +1 -1
  44. package/src/hooks/mm/useUserReservesData.ts +1 -1
  45. package/src/hooks/provider/useHubProvider.ts +3 -3
  46. package/src/hooks/provider/useSpokeProvider.ts +10 -4
  47. package/src/hooks/shared/index.ts +1 -0
  48. package/src/hooks/shared/useDeriveUserWalletAddress.ts +44 -0
  49. package/src/providers/SodaxProvider.tsx +4 -18
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/contexts/index.ts","../src/hooks/shared/useSodaxContext.ts","../src/hooks/shared/useEstimateGas.ts","../src/hooks/provider/useHubProvider.ts","../src/hooks/provider/useSpokeProvider.ts","../src/hooks/mm/useBorrow.ts","../src/hooks/mm/useRepay.ts","../src/hooks/mm/useSupply.ts","../src/hooks/mm/useWithdraw.ts","../src/hooks/mm/useUserReservesData.ts","../src/hooks/mm/useReservesData.ts","../src/hooks/mm/useMMAllowance.ts","../src/hooks/mm/useMMApprove.ts","../src/hooks/swap/useQuote.ts","../src/hooks/swap/useSwap.ts","../src/hooks/swap/useStatus.ts","../src/hooks/swap/useSwapAllowance.ts","../src/hooks/swap/useSwapApprove.ts","../src/hooks/swap/useCancelSwap.ts","../src/providers/SodaxProvider.tsx","../src/core/index.ts"],"names":["useMutation","parseUnits","useQuery","useQueryClient","params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M,MAAA,KAAA,GAAQ,IAAI,KAAA,CAAM,MAAM,CAAA;AAE9B,EAAA,MAAM,UAAa,GAAA,MAAA,EAAQ,iBAAmB,EAAA,WAAA,CAAY,KAAM,CAAA,EAAA;AAChE,EAAM,MAAA,SAAA,GAAY,QAAQ,iBAAmB,EAAA,SAAA;AAE7C,EAAM,MAAA,WAAA,GAAcK,QAAQ,MAAM;AAChC,IAAA,IAAI,cAAc,SAAW,EAAA;AAC3B,MAAM,MAAA,WAAA,GAAc,kBAAkB,UAAU,CAAA;AAEhD,MAAA,OAAO,IAAI,cAAe,CAAA;AAAA,QACxB,SAAA;AAAA,QACA,WAAa,EAAA;AAAA,OACd,CAAA;AAAA;AAEH,IAAO,OAAA,MAAA;AAAA,GACN,EAAA,CAAC,UAAY,EAAA,SAAS,CAAC,CAAA;AAE1B,EAAO,uBAAA,KAAA,CAAA,aAAA,CAAC,YAAa,CAAA,QAAA,EAAb,EAAsB,KAAA,EAAO,EAAE,KAAA,EAAO,OAAS,EAAA,WAAA,EAAa,SAAU,EAAA,EAAA,EAAI,QAAS,CAAA;AAC7F;AC5Ba,IAAA,2BAAA,GAA8B,CAAC,YAAA,EAAuB,KAAkB,KAAA;AACnF,EAAM,MAAA,MAAA,GAAS,UAAU,YAAY,CAAA;AACrC,EAAA,MAAM,OAAU,GAAA,MAAA,CAAO,IAAK,CAAA,MAAM,CAAE,CAAA,IAAA;AAAA,IAClC,CAAA,YAAA,KAAgB,OAAO,YAAY,CAAA,CAAE,MAAM,WAAY,EAAA,KAAM,MAAM,WAAY;AAAA,GACjF;AAEA,EAAO,OAAA,OAAA;AACT","file":"index.mjs","sourcesContent":["import { createContext } from 'react';\nimport type { EvmHubProvider, Sodax } from '@sodax/sdk';\nimport type { RpcConfig } from '@/types';\n\nexport interface SodaxContextType {\n sodax: Sodax;\n testnet: boolean;\n hubProvider: EvmHubProvider | undefined;\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","import type { EvmHubProvider } from '@sodax/sdk';\nimport { useSodaxContext } from '../shared/useSodaxContext';\n\nexport function useHubProvider(): EvmHubProvider | undefined {\n const { hubProvider } = useSodaxContext();\n\n return 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(walletProvider as IStellarWalletProvider, stellarConfig, {\n horizonRpcUrl: stellarConfig.horizonRpcUrl,\n sorobanRpcUrl: stellarConfig.sorobanRpcUrl,\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 { SpokeProvider, type UserReserveData } from '@sodax/sdk';\nimport { useQuery, type UseQueryResult } from '@tanstack/react-query';\nimport { useSodaxContext } from '../shared/useSodaxContext';\n\n/**\n * Hook for fetching user reserves data from the Sodax money market.\n *\n * This hook provides access to the current state of user reserves in the money market protocol.\n * The data is automatically fetched and cached using React Query.\n *\n * @example\n * ```typescript\n * const { data: userReservesData, isLoading, error } = useUserReservesData(spokeProvider, address);\n * ```\n *\n * @returns A React Query result object containing:\n * - data: The user reserves data when available\n * - isLoading: Loading state indicator\n * - error: Any error that occurred during data fetching\n */\nexport function useUserReservesData(\n spokeProvider: SpokeProvider | undefined,\n address: string | undefined,\n refetchInterval = 5000,\n): UseQueryResult<readonly [readonly UserReserveData[], number], Error> {\n const { sodax } = useSodaxContext();\n\n return useQuery({\n queryKey: ['userReserves', spokeProvider?.chainConfig.chain.id, address],\n queryFn: async () => {\n if (!spokeProvider) {\n throw new Error('Spoke provider or address is not defined');\n }\n\n return await sodax.moneyMarket.data.getUserReservesData(spokeProvider);\n },\n enabled: !!spokeProvider && !!address,\n refetchInterval,\n });\n}\n","import { useQuery } from '@tanstack/react-query';\nimport { useSodaxContext } from '../shared/useSodaxContext';\n/**\n * Hook for fetching reserves data from the Sodax money market.\n *\n * This hook provides access to the current state of all reserves in the money market protocol,\n * including liquidity, interest rates, and other key metrics. The data is automatically\n * fetched and cached using React Query.\n *\n * @example\n * ```typescript\n * const { data: reservesData, isLoading, error } = useReservesData();\n * ```\n *\n * @returns A React Query result object containing:\n * - data: The reserves data when available\n * - isLoading: Loading state indicator\n * - error: Any error that occurred during data fetching\n */\n\nexport function useReservesData() {\n const { sodax } = useSodaxContext();\n\n return useQuery({\n queryKey: ['reservesData'],\n queryFn: async () => {\n return await sodax.moneyMarket.data.getReservesData();\n },\n });\n}\n","import { useQuery, type UseQueryResult } from '@tanstack/react-query';\nimport type { XToken } from '@sodax/types';\nimport { useSodaxContext } from '../shared/useSodaxContext';\nimport { parseUnits } from 'viem';\nimport type { MoneyMarketAction, SpokeProvider } from '@sodax/sdk';\n\n/**\n * Hook for checking token allowance for money market operations.\n *\n * This hook verifies if the user has approved enough tokens for a specific money market action\n * (borrow/repay). It automatically queries and tracks the allowance status.\n *\n * @param {XToken} token - The token to check allowance for. Must be an XToken with valid address and chain information.\n * @param {string} amount - The amount to check allowance for, as a decimal string\n * @param {MoneyMarketAction} action - The money market action to check allowance for ('borrow' or 'repay')\n * @param {SpokeProvider} spokeProvider - The spoke provider to use for allowance checks\n *\n * @returns {UseQueryResult<boolean, Error>} A React Query result containing:\n * - data: Boolean indicating if allowance is sufficient\n * - isLoading: Loading state indicator\n * - error: Any error that occurred during the check\n *\n * @example\n * ```typescript\n * const { data: hasAllowed, isLoading } = useMMAllowance(token, \"100\", \"repay\", provider);\n * ```\n */\nexport function useMMAllowance(\n token: XToken,\n amount: string,\n action: MoneyMarketAction,\n spokeProvider: SpokeProvider | undefined,\n): UseQueryResult<boolean, Error> {\n const { sodax } = useSodaxContext();\n\n return useQuery({\n queryKey: ['allowance', token.address, amount, action],\n queryFn: async () => {\n if (!spokeProvider) throw new Error('Spoke provider is required');\n const allowance = await sodax.moneyMarket.isAllowanceValid(\n {\n token: token.address,\n amount: parseUnits(amount, token.decimals),\n action,\n },\n spokeProvider,\n );\n if (allowance.ok) {\n return allowance.value;\n }\n return false;\n },\n enabled: !!spokeProvider,\n });\n}\n","import { useSodaxContext } from '../shared/useSodaxContext';\nimport type { XToken } from '@sodax/types';\nimport { parseUnits } from 'viem';\nimport { useMutation, useQueryClient } from '@tanstack/react-query';\nimport type { MoneyMarketAction, SpokeProvider } from '@sodax/sdk';\n\ninterface UseApproveReturn {\n approve: ({ amount, action }: { amount: string; action: MoneyMarketAction }) => Promise<boolean>;\n isLoading: boolean;\n error: Error | null;\n resetError: () => void;\n}\n\n/**\n * Hook for approving token spending for money market actions\n * @param token The token to approve spending for\n * @param spokeProvider The spoke provider instance for the chain\n * @returns Object containing approve function, loading state, error state and reset function\n * @example\n * ```tsx\n * const { approve, isLoading, error } = useMMApprove(token, spokeProvider);\n *\n * // Approve tokens for supply action\n * await approve({ amount: \"100\", action: \"supply\" });\n * ```\n */\n\nexport function useMMApprove(token: XToken, spokeProvider: SpokeProvider | undefined): UseApproveReturn {\n const { sodax } = useSodaxContext();\n const queryClient = useQueryClient();\n\n const {\n mutateAsync: approve,\n isPending,\n error,\n reset: resetError,\n } = useMutation({\n mutationFn: async ({ amount, action }: { amount: string; action: MoneyMarketAction }) => {\n if (!spokeProvider) {\n throw new Error('Spoke provider not found');\n }\n const allowance = await sodax.moneyMarket.approve(\n {\n token: token.address,\n amount: parseUnits(amount, token.decimals),\n action,\n },\n spokeProvider,\n );\n if (!allowance.ok) {\n throw new Error('Failed to approve tokens');\n }\n return allowance.ok;\n },\n onSuccess: () => {\n // Invalidate allowance query to refetch the new allowance\n queryClient.invalidateQueries({ queryKey: ['allowance', token.address] });\n },\n });\n\n return {\n approve,\n isLoading: isPending,\n error: error,\n resetError,\n };\n}\n","import type { SolverErrorResponse, SolverIntentQuoteRequest, SolverIntentQuoteResponse, Result } from '@sodax/sdk';\nimport { useSodaxContext } from '../shared/useSodaxContext';\nimport { useQuery, type UseQueryResult } from '@tanstack/react-query';\n\n/**\n * Hook for fetching a quote for an intent-based swap.\n *\n * This hook provides real-time quote data for an intent-based swap.\n *\n * @param {SolverIntentQuoteRequest | undefined} payload - The intent quote request parameters. If undefined, the query will be disabled.\n *\n * @returns {UseQueryResult<Result<SolverIntentQuoteResponse, SolverErrorResponse> | undefined>} A query result object containing:\n * - data: The quote result from the solver\n * - isLoading: Boolean indicating if the quote is being fetched\n * - error: Error object if the quote request failed\n * - refetch: Function to manually trigger a quote refresh\n *\n * @example\n * ```typescript\n * const { data: quote, isLoading } = useQuote({\n * token_src: '0x...',\n * token_src_blockchain_id: '1',\n * token_dst: '0x...',\n * token_dst_blockchain_id: '2',\n * amount: '1000000000000000000',\n * quote_type: 'exact_input',\n * });\n *\n * if (isLoading) return <div>Loading quote...</div>;\n * if (quote) {\n * console.log('Quote received:', quote);\n * }\n * ```\n *\n * @remarks\n * - The quote is automatically refreshed every 3 seconds\n * - The query is disabled when payload is undefined\n * - Uses React Query for efficient caching and state management\n */\nexport const useQuote = (\n payload: SolverIntentQuoteRequest | undefined,\n): UseQueryResult<Result<SolverIntentQuoteResponse, SolverErrorResponse> | undefined> => {\n const { sodax } = useSodaxContext();\n return useQuery({\n queryKey: [payload],\n queryFn: async () => {\n if (!payload) {\n return undefined;\n }\n return sodax.solver.getQuote(payload);\n },\n enabled: !!payload,\n refetchInterval: 3000,\n });\n};\n","import { useSodaxContext } from '../shared/useSodaxContext';\nimport type {\n CreateIntentParams,\n SolverExecutionResponse,\n Result,\n IntentErrorCode,\n Intent,\n IntentError,\n SpokeProvider,\n IntentDeliveryInfo,\n} from '@sodax/sdk';\nimport { useMutation, type UseMutationResult } from '@tanstack/react-query';\n\ntype CreateIntentResult = Result<[SolverExecutionResponse, Intent, IntentDeliveryInfo], IntentError<IntentErrorCode>>;\n\n/**\n * Hook for creating and submitting an swap intent order for cross-chain swaps.\n * Uses React Query's useMutation for better state management and caching.\n *\n * @param {SpokeProvider} spokeProvider - The spoke provider to use for the swap\n * @returns {UseMutationResult} Mutation result object containing mutation function and state\n *\n * @example\n * ```typescript\n * const { mutateAsync: swap, isPending } = useSwap(spokeProvider);\n *\n * const handleSwap = async () => {\n * const result = await swap({\n * token_src: '0x...',\n * token_src_blockchain_id: 'arbitrum',\n * token_dst: '0x...',\n * token_dst_blockchain_id: 'polygon',\n * amount: '1000000000000000000',\n * min_output_amount: '900000000000000000'\n * });\n * };\n * ```\n */\nexport function useSwap(\n spokeProvider: SpokeProvider | undefined,\n): UseMutationResult<CreateIntentResult, Error, CreateIntentParams> {\n const { sodax } = useSodaxContext();\n\n return useMutation<CreateIntentResult, Error, CreateIntentParams>({\n mutationFn: async (params: CreateIntentParams) => {\n if (!spokeProvider) {\n throw new Error('Spoke provider not found');\n }\n return sodax.solver.swap({\n intentParams: params,\n spokeProvider,\n });\n },\n });\n}\n","import type { Hex, SolverErrorResponse, SolverIntentStatusResponse, Result } from '@sodax/sdk';\nimport { useQuery, type UseQueryResult } from '@tanstack/react-query';\nimport { useSodaxContext } from '../shared/useSodaxContext';\n\n/**\n * Hook for monitoring the status of an intent-based swap.\n *\n * This hook provides real-time status updates for an intent-based swap transaction.\n *\n * @param {Hex} intent_tx_hash - The transaction hash of the intent order on the hub chain\n *\n * @returns {UseQueryResult<Result<SolverIntentStatusResponse, SolverErrorResponse> | undefined>} A query result object containing:\n * - data: The status result from the solver\n * - isLoading: Boolean indicating if the status is being fetched\n * - error: Error object if the status request failed\n * - refetch: Function to manually trigger a status refresh\n *\n * @example\n * ```typescript\n * const { data: status, isLoading } = useStatus('0x...');\n *\n * if (isLoading) return <div>Loading status...</div>;\n * if (status?.ok) {\n * console.log('Status:', status.value);\n * }\n * ```\n *\n * @remarks\n * - The status is automatically refreshed every 3 seconds\n * - Uses React Query for efficient caching and state management\n */\n\nexport const useStatus = (\n intent_tx_hash: Hex,\n): UseQueryResult<Result<SolverIntentStatusResponse, SolverErrorResponse> | undefined> => {\n const { sodax } = useSodaxContext();\n return useQuery({\n queryKey: [intent_tx_hash],\n queryFn: async () => {\n return sodax.solver.getStatus({ intent_tx_hash });\n },\n refetchInterval: 3000, // 3s\n });\n};\n","import { useQuery, type UseQueryResult } from '@tanstack/react-query';\nimport { useSodaxContext } from '../shared/useSodaxContext';\nimport type { CreateIntentParams, SpokeProvider } from '@sodax/sdk';\n\n/**\n * Hook for checking token allowance for money market operations.\n *\n * This hook verifies if the user has approved enough tokens for a specific money market action\n * (borrow/repay). It automatically queries and tracks the allowance status.\n *\n * @param {CreateIntentParams} params - The parameters for the intent to check allowance for.\n * @param {SpokeProvider} spokeProvider - The spoke provider to use for allowance checks\n *\n * @returns {UseQueryResult<boolean, Error>} A React Query result containing:\n * - data: Boolean indicating if allowance is sufficient\n * - isLoading: Loading state indicator\n * - error: Any error that occurred during the check\n *\n * @example\n * ```typescript\n * const { data: hasAllowed, isLoading } = useMMAllowance(params, spokeProvider);\n * ```\n */\nexport function useSwapAllowance(\n params: CreateIntentParams | undefined,\n spokeProvider: SpokeProvider | undefined,\n): UseQueryResult<boolean, Error> {\n const { sodax } = useSodaxContext();\n\n return useQuery({\n queryKey: ['allowance', params],\n queryFn: async () => {\n if (!spokeProvider || !params) {\n return false;\n }\n const allowance = await sodax.solver.isAllowanceValid({\n intentParams: params,\n spokeProvider,\n });\n if (allowance.ok) {\n return allowance.value;\n }\n return false;\n },\n enabled: !!spokeProvider && !!params,\n });\n}\n","import { useSodaxContext } from '../shared/useSodaxContext';\nimport { useMutation, useQueryClient } from '@tanstack/react-query';\nimport type { CreateIntentParams, SpokeProvider } from '@sodax/sdk';\n\ninterface UseApproveReturn {\n approve: ({ params }: { params: CreateIntentParams }) => Promise<boolean>;\n isLoading: boolean;\n error: Error | null;\n resetError: () => void;\n}\n\n/**\n * Hook for approving token spending for money market actions\n * @param token The token to approve spending for\n * @param spokeProvider The spoke provider instance for the chain\n * @returns Object containing approve function, loading state, error state and reset function\n * @example\n * ```tsx\n * const { approve, isLoading, error } = useApprove(token, spokeProvider);\n *\n * // Approve tokens for supply action\n * await approve({ amount: \"100\", action: \"supply\" });\n * ```\n */\n\nexport function useSwapApprove(\n params: CreateIntentParams | undefined,\n spokeProvider: SpokeProvider | undefined,\n): UseApproveReturn {\n const { sodax } = useSodaxContext();\n const queryClient = useQueryClient();\n\n const {\n mutateAsync: approve,\n isPending,\n error,\n reset: resetError,\n } = useMutation({\n mutationFn: async ({ params }: { params: CreateIntentParams | undefined }) => {\n if (!spokeProvider) {\n throw new Error('Spoke provider not found');\n }\n if (!params) {\n throw new Error('Swap Params not found');\n }\n\n const allowance = await sodax.solver.approve({\n intentParams: params,\n spokeProvider,\n });\n if (!allowance.ok) {\n throw new Error('Failed to approve input token');\n }\n return allowance.ok;\n },\n onSuccess: () => {\n // Invalidate allowance query to refetch the new allowance\n queryClient.invalidateQueries({ queryKey: ['allowance', params?.inputToken] });\n },\n });\n\n return {\n approve,\n isLoading: isPending,\n error: error,\n resetError,\n };\n}\n","import { useSodaxContext } from '../shared/useSodaxContext';\nimport type { Intent, Result, SpokeProvider, TxReturnType } from '@sodax/sdk';\nimport { useMutation, type UseMutationResult } from '@tanstack/react-query';\n\ntype CancelIntentParams = {\n intent: Intent;\n raw?: boolean;\n};\n\ntype CancelIntentResult = Result<TxReturnType<SpokeProvider, boolean>>;\n\n/**\n * Hook for canceling a swap intent order.\n * Uses React Query's useMutation for better state management and caching.\n *\n * @param {SpokeProvider} spokeProvider - The spoke provider to use for canceling the intent\n * @returns {UseMutationResult} Mutation result object containing mutation function and state\n *\n * @example\n * ```typescript\n * const { mutateAsync: cancelSwap, isPending } = useCancelSwap(spokeProvider);\n *\n * const handleCancelSwap = async () => {\n * const result = await cancelSwap({\n * intent: intentObject,\n * raw: false // optional, defaults to false\n * });\n * };\n * ```\n */\nexport function useCancelSwap(\n spokeProvider: SpokeProvider | undefined,\n): UseMutationResult<CancelIntentResult, Error, CancelIntentParams> {\n const { sodax } = useSodaxContext();\n\n return useMutation<CancelIntentResult, Error, CancelIntentParams>({\n mutationFn: async ({ intent, raw = false }: CancelIntentParams) => {\n if (!spokeProvider) {\n throw new Error('Spoke provider not found');\n }\n return sodax.solver.cancelIntent(intent, spokeProvider, raw);\n },\n });\n}\n","import type { ReactNode, ReactElement } from 'react';\nimport { EvmHubProvider, getHubChainConfig, Sodax, type SodaxConfig } from '@sodax/sdk';\nimport { SodaxContext } from '@/contexts';\nimport React, { useMemo } from 'react';\nimport type { RpcConfig } from '@/types';\n\ninterface SodaxProviderProps {\n children: ReactNode;\n testnet?: boolean;\n config?: SodaxConfig;\n rpcConfig: RpcConfig;\n}\n\nexport const SodaxProvider = ({ children, testnet = false, config, rpcConfig }: SodaxProviderProps): ReactElement => {\n const sodax = new Sodax(config);\n\n const hubChainId = config?.hubProviderConfig?.chainConfig.chain.id;\n const hubRpcUrl = config?.hubProviderConfig?.hubRpcUrl;\n\n const hubProvider = useMemo(() => {\n if (hubChainId && hubRpcUrl) {\n const hubChainCfg = getHubChainConfig(hubChainId);\n\n return new EvmHubProvider({\n hubRpcUrl: hubRpcUrl,\n chainConfig: hubChainCfg,\n });\n }\n return undefined;\n }, [hubChainId, hubRpcUrl]);\n\n return <SodaxContext.Provider value={{ sodax, testnet, hubProvider, rpcConfig }}>{children}</SodaxContext.Provider>;\n};\n","import type { ChainId } from '@sodax/types';\n\nimport { hubAssets } from '@sodax/sdk';\n\nexport const getSpokeTokenAddressByVault = (spokeChainId: ChainId, vault: string) => {\n const tokens = hubAssets[spokeChainId];\n const address = Object.keys(tokens).find(\n tokenAddress => tokens[tokenAddress].vault.toLowerCase() === vault.toLowerCase(),\n );\n\n return address;\n};\n"]}
1
+ {"version":3,"sources":["../src/contexts/index.ts","../src/hooks/shared/useSodaxContext.ts","../src/hooks/shared/useEstimateGas.ts","../src/hooks/shared/useDeriveUserWalletAddress.ts","../src/hooks/provider/useHubProvider.ts","../src/hooks/provider/useSpokeProvider.ts","../src/hooks/mm/useBorrow.ts","../src/hooks/mm/useRepay.ts","../src/hooks/mm/useSupply.ts","../src/hooks/mm/useWithdraw.ts","../src/hooks/mm/useUserReservesData.ts","../src/hooks/mm/useReservesData.ts","../src/hooks/mm/useMMAllowance.ts","../src/hooks/mm/useMMApprove.ts","../src/hooks/swap/useQuote.ts","../src/hooks/swap/useSwap.ts","../src/hooks/swap/useStatus.ts","../src/hooks/swap/useSwapAllowance.ts","../src/hooks/swap/useSwapApprove.ts","../src/hooks/swap/useCancelSwap.ts","../src/hooks/bridge/useBridgeAllowance.ts","../src/hooks/bridge/useBridgeApprove.ts","../src/hooks/bridge/useBridge.ts","../src/hooks/bridge/useGetBridgeableAmount.ts","../src/hooks/bridge/useGetBridgeableTokens.ts","../src/providers/SodaxProvider.tsx","../src/core/index.ts"],"names":["useMutation","parseUnits","useQuery","useQueryClient","params"],"mappings":";;;;;;AAUO,IAAM,YAAA,GAAe,cAAuC,IAAI,CAAA;ACDhE,IAAM,kBAAkB,MAAwB;AACrD,EAAM,MAAA,OAAA,GAAU,WAAW,YAAY,CAAA;AACvC,EAAA,IAAI,CAAC,OAAS,EAAA;AACZ,IAAM,MAAA,IAAI,MAAM,qDAAqD,CAAA;AAAA;AAEvE,EAAO,OAAA,OAAA;AACT;AC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9B,CAAA;AACH;AC/Ca,IAAA,aAAA,GAAgB,CAAC,EAAE,QAAA,EAAU,UAAU,KAAO,EAAA,MAAA,EAAQ,WAAkD,KAAA;AACnH,EAAM,MAAA,KAAA,GAAQ,IAAI,KAAA,CAAM,MAAM,CAAA;AAE9B,EAAO,uBAAA,KAAA,CAAA,aAAA,CAAC,YAAa,CAAA,QAAA,EAAb,EAAsB,KAAA,EAAO,EAAE,KAAO,EAAA,OAAA,EAAS,SAAU,EAAA,EAAA,EAAI,QAAS,CAAA;AAChF;ACda,IAAA,2BAAA,GAA8B,CAAC,YAAA,EAAuB,KAAkB,KAAA;AACnF,EAAM,MAAA,MAAA,GAAS,UAAU,YAAY,CAAA;AACrC,EAAA,MAAM,OAAU,GAAA,MAAA,CAAO,IAAK,CAAA,MAAM,CAAE,CAAA,IAAA;AAAA,IAClC,CAAA,YAAA,KAAgB,OAAO,YAAY,CAAA,CAAE,MAAM,WAAY,EAAA,KAAM,MAAM,WAAY;AAAA,GACjF;AAEA,EAAO,OAAA,OAAA;AACT","file":"index.mjs","sourcesContent":["import { createContext } from 'react';\nimport type { Sodax } from '@sodax/sdk';\nimport type { RpcConfig } from '@/types';\n\nexport interface SodaxContextType {\n sodax: Sodax;\n testnet: boolean;\n rpcConfig: RpcConfig;\n}\n\nexport const SodaxContext = createContext<SodaxContextType | null>(null);\n","import { SodaxContext, type SodaxContextType } from '@/contexts';\nimport { useContext } from 'react';\n\n/**\n * Hook to access the Sodax context which provides access to the Sodax SDK instance and chain configuration\n * @throws {Error} If used outside of a SodaxProvider\n * @returns {SodaxContextType} The Sodax context containing SDK instance and configuration\n */\n\nexport const useSodaxContext = (): SodaxContextType => {\n const context = useContext(SodaxContext);\n if (!context) {\n throw new Error('useSodaxContext must be used within a SodaxProvider');\n }\n return context;\n};\n","import { type GetEstimateGasReturnType, type SpokeProvider, SpokeService, type TxReturnType } from '@sodax/sdk';\nimport { useMutation, type UseMutationResult } from '@tanstack/react-query';\n\nexport function useEstimateGas<T extends SpokeProvider = SpokeProvider>(\n spokeProvider: T | undefined,\n): UseMutationResult<GetEstimateGasReturnType<T>, Error, TxReturnType<T, true>> {\n return useMutation<GetEstimateGasReturnType<T>, Error, TxReturnType<T, true>>({\n mutationFn: async (rawTx: TxReturnType<T, true>) => {\n if (!spokeProvider) {\n throw new Error('spokeProvider is not found');\n }\n\n const response = await SpokeService.estimateGas(rawTx, spokeProvider);\n\n return response;\n },\n });\n}\n","// packages/dapp-kit/src/hooks/shared/useDeriveUserWalletAddress.ts\nimport { deriveUserWalletAddress, type SpokeProvider, type EvmHubProvider } from '@sodax/sdk';\nimport { useQuery, type UseQueryResult } from '@tanstack/react-query';\nimport { useSodaxContext } from './useSodaxContext';\nimport type { Address } from 'viem';\n\n/**\n * Hook for deriving user wallet address for hub abstraction.\n *\n * This hook derives the user's abstracted wallet address for the hub chain.\n * If the spoke chain is the same as the hub chain, it returns the original wallet address.\n * Otherwise, it returns the abstracted wallet address for cross-chain operations.\n *\n * @param spokeProvider - The spoke provider instance for the origin chain\n * @param walletAddress - Optional user wallet address on spoke chain. If not provided, will fetch from spokeProvider\n * @returns A React Query result object containing:\n * - data: The derived user wallet address when available\n * - isLoading: Loading state indicator\n * - error: Any error that occurred during derivation\n *\n * @example\n * ```typescript\n * const { data: derivedAddress, isLoading, error } = useDeriveUserWalletAddress(spokeProvider, userAddress);\n * ```\n */\nexport function useDeriveUserWalletAddress(\n spokeProvider: SpokeProvider | undefined,\n walletAddress?: string | undefined,\n): UseQueryResult<Address, Error> {\n const { sodax } = useSodaxContext();\n\n return useQuery({\n queryKey: ['deriveUserWalletAddress', spokeProvider?.chainConfig.chain.id, walletAddress],\n queryFn: async (): Promise<Address> => {\n if (!spokeProvider) {\n throw new Error('Spoke provider is required');\n }\n\n return await deriveUserWalletAddress(spokeProvider, sodax.hubProvider, walletAddress);\n },\n enabled: !!spokeProvider,\n refetchInterval: false, // This is a deterministic operation, no need to refetch\n });\n}\n","import type { EvmHubProvider } from '@sodax/sdk';\nimport { useSodaxContext } from '../shared/useSodaxContext';\n\nexport function useHubProvider(): EvmHubProvider {\n const { sodax } = useSodaxContext();\n\n return sodax.hubProvider;\n}\n","import { useSodaxContext } from '@/index';\nimport {\n EvmSpokeProvider,\n spokeChainConfig,\n type SuiSpokeChainConfig,\n SuiSpokeProvider,\n type EvmSpokeChainConfig,\n IconSpokeProvider,\n type IconSpokeChainConfig,\n InjectiveSpokeProvider,\n type InjectiveSpokeChainConfig,\n StellarSpokeProvider,\n type StellarSpokeChainConfig,\n type SpokeProvider,\n type IWalletProvider,\n SolanaSpokeProvider,\n type SolanaChainConfig,\n SONIC_MAINNET_CHAIN_ID,\n SonicSpokeProvider,\n type SonicSpokeChainConfig,\n} from '@sodax/sdk';\nimport type {\n IEvmWalletProvider,\n IIconWalletProvider,\n ISuiWalletProvider,\n SpokeChainId,\n IInjectiveWalletProvider,\n IStellarWalletProvider,\n ISolanaWalletProvider,\n} from '@sodax/types';\nimport { useMemo } from 'react';\n\n/**\n * Hook to get the appropriate spoke provider based on the chain type.\n * Supports EVM, SUI, ICON and INJECTIVE chains.\n *\n * @param {SpokeChainId | undefined} spokeChainId - The spoke chain ID to get the provider for\n * @param {IWalletProvider | undefined} walletProvider - The wallet provider to use\n * @returns {SpokeProvider | undefined} The appropriate spoke provider instance for the given chain ID, or undefined if invalid/unsupported\n *\n * @example\n * ```tsx\n * // Using a specific SpokeChainId and wallet provider\n * const spokeProvider = useSpokeProvider(spokeChainId, walletProvider);\n * ```\n */\nexport function useSpokeProvider(\n spokeChainId: SpokeChainId | undefined,\n walletProvider?: IWalletProvider | undefined,\n): SpokeProvider | undefined {\n const { rpcConfig } = useSodaxContext();\n const xChainType = spokeChainId ? spokeChainConfig[spokeChainId]?.chain.type : undefined;\n\n const spokeProvider = useMemo(() => {\n if (!walletProvider) return undefined;\n if (!spokeChainId) return undefined;\n if (!xChainType) return undefined;\n if (!rpcConfig) return undefined;\n\n if (xChainType === 'EVM') {\n if (spokeChainId === SONIC_MAINNET_CHAIN_ID) {\n return new SonicSpokeProvider(\n walletProvider as IEvmWalletProvider,\n spokeChainConfig[spokeChainId] as SonicSpokeChainConfig,\n );\n }\n return new EvmSpokeProvider(\n walletProvider as IEvmWalletProvider,\n spokeChainConfig[spokeChainId] as EvmSpokeChainConfig,\n );\n }\n\n if (xChainType === 'SUI') {\n return new SuiSpokeProvider(\n spokeChainConfig[spokeChainId] as SuiSpokeChainConfig,\n walletProvider as ISuiWalletProvider,\n );\n }\n\n if (xChainType === 'ICON') {\n return new IconSpokeProvider(\n walletProvider as IIconWalletProvider,\n spokeChainConfig[spokeChainId] as IconSpokeChainConfig,\n );\n }\n\n if (xChainType === 'INJECTIVE') {\n return new InjectiveSpokeProvider(\n spokeChainConfig[spokeChainId] as InjectiveSpokeChainConfig,\n walletProvider as IInjectiveWalletProvider,\n );\n }\n\n if (xChainType === 'STELLAR') {\n const stellarConfig = spokeChainConfig[spokeChainId] as StellarSpokeChainConfig;\n return new StellarSpokeProvider(\n walletProvider as IStellarWalletProvider,\n stellarConfig,\n rpcConfig.stellar\n ? rpcConfig.stellar\n : {\n horizonRpcUrl: stellarConfig.horizonRpcUrl,\n sorobanRpcUrl: stellarConfig.sorobanRpcUrl,\n },\n );\n }\n\n if (xChainType === 'SOLANA') {\n return new SolanaSpokeProvider(\n walletProvider as ISolanaWalletProvider,\n rpcConfig.solana\n ? ({\n ...spokeChainConfig[spokeChainId],\n rpcUrl: rpcConfig.solana,\n } as SolanaChainConfig)\n : (spokeChainConfig[spokeChainId] as SolanaChainConfig),\n );\n }\n\n return undefined;\n }, [spokeChainId, xChainType, walletProvider, rpcConfig]);\n\n return spokeProvider;\n}\n","import type { XToken } from '@sodax/types';\nimport { useMutation, type UseMutationResult } from '@tanstack/react-query';\nimport { parseUnits } from 'viem';\nimport { useSodaxContext } from '../shared/useSodaxContext';\nimport type { SpokeProvider } from '@sodax/sdk';\ninterface BorrowResponse {\n ok: true;\n value: [string, string];\n}\n\n/**\n * Hook for borrowing tokens from the Sodax money market.\n *\n * This hook provides functionality to borrow tokens from the money market protocol,\n * handling the entire borrow process including transaction creation, submission,\n * and cross-chain communication.\n *\n * @param {XToken} spokeToken - The token to borrow from the spoke chain. Must be an XToken with valid address and chain information.\n * @param {SpokeProvider} spokeProvider - The spoke provider to use for the borrow transaction. Must be a valid SpokeProvider instance.\n *\n * @returns {UseMutationResult<BorrowResponse, Error, string>} A mutation result object with the following properties:\n * - mutateAsync: Function to execute the borrow transaction\n * - isPending: Boolean indicating if a transaction is in progress\n * - error: Error object if the last transaction failed, null otherwise\n *\n * @example\n * ```typescript\n * const { mutateAsync: borrow, isPending, error } = useBorrow(spokeToken);\n * await borrow('100');\n * ```\n *\n * @throws {Error} When:\n * - spokeProvider is not available\n * - Transaction execution fails\n */\nexport function useBorrow(\n spokeToken: XToken,\n spokeProvider: SpokeProvider | undefined,\n): UseMutationResult<BorrowResponse, Error, string> {\n const { sodax } = useSodaxContext();\n\n return useMutation<BorrowResponse, Error, string>({\n mutationFn: async (amount: string) => {\n if (!spokeProvider) {\n throw new Error('spokeProvider is not found');\n }\n\n const response = await sodax.moneyMarket.borrow(\n {\n token: spokeToken.address,\n amount: parseUnits(amount, 18),\n action: 'borrow',\n },\n spokeProvider,\n );\n\n if (!response.ok) {\n throw new Error('Failed to borrow tokens');\n }\n\n console.log('Borrow transaction submitted:', response);\n return response;\n },\n });\n}\n","import type { SpokeProvider } from '@sodax/sdk';\nimport type { XToken } from '@sodax/types';\nimport { useMutation, type UseMutationResult } from '@tanstack/react-query';\nimport { parseUnits } from 'viem';\nimport { useSodaxContext } from '../shared/useSodaxContext';\n\ninterface RepayResponse {\n ok: true;\n value: [string, string];\n}\n\n/**\n * Hook for repaying borrowed tokens to the Sodax money market.\n *\n * This hook provides functionality to repay borrowed tokens back to the money market protocol,\n * handling the entire repayment process including transaction creation, submission,\n * and cross-chain communication.\n *\n * @param {XToken} spokeToken - The token to repay on the spoke chain. Must be an XToken with valid address and chain information.\n * @param {SpokeProvider} spokeProvider - The spoke provider to use for the repay transaction. Must be a valid SpokeProvider instance.\n *\n * @returns {UseMutationResult<RepayResponse, Error, string>} A mutation result object with the following properties:\n * - mutateAsync: Function to execute the repay transaction\n * - isPending: Boolean indicating if a transaction is in progress\n * - error: Error object if the last transaction failed, null otherwise\n *\n * @example\n * ```typescript\n * const { mutateAsync: repay, isPending, error } = useRepay(spokeToken);\n * await repay('100');\n * ```\n *\n * @throws {Error} When:\n * - spokeProvider is not available\n * - Transaction execution fails\n */\nexport function useRepay(\n spokeToken: XToken,\n spokeProvider: SpokeProvider | undefined,\n): UseMutationResult<RepayResponse, Error, string> {\n const { sodax } = useSodaxContext();\n\n return useMutation<RepayResponse, Error, string>({\n mutationFn: async (amount: string) => {\n if (!spokeProvider) {\n throw new Error('spokeProvider is not found');\n }\n\n const response = await sodax.moneyMarket.repay(\n {\n token: spokeToken.address,\n amount: parseUnits(amount, spokeToken.decimals),\n action: 'repay',\n },\n spokeProvider,\n );\n\n if (!response.ok) {\n throw new Error('Failed to repay tokens');\n }\n\n console.log('Repay transaction submitted:', response);\n return response;\n },\n });\n}\n","import type { SpokeProvider } from '@sodax/sdk';\nimport type { XToken } from '@sodax/types';\nimport { useMutation, type UseMutationResult } from '@tanstack/react-query';\nimport { parseUnits } from 'viem';\nimport { useSodaxContext } from '../shared/useSodaxContext';\n\ninterface SupplyResponse {\n ok: true;\n value: [string, string];\n}\n\n/**\n * Hook for supplying tokens to the Sodax money market.\n *\n * This hook provides functionality to supply tokens to the money market protocol,\n * handling the entire supply process including transaction creation, submission,\n * and cross-chain communication.\n *\n * @param {XToken} spokeToken - The token to supply on the spoke chain. Must be an XToken with valid address and chain information.\n * @param {SpokeProvider} spokeProvider - The spoke provider to use for the supply transaction. Must be a valid SpokeProvider instance.\n *\n * @returns {UseMutationResult<SupplyResponse, Error, string>} A mutation result object with the following properties:\n * - mutateAsync: Function to execute the supply transaction\n * - isPending: Boolean indicating if a transaction is in progress\n * - error: Error object if the last transaction failed, null otherwise\n *\n * @example\n * ```typescript\n * const { mutateAsync: supply, isPending, error } = useSupply(spokeToken);\n * await supply('100');\n * ```\n *\n * @throws {Error} When:\n * - spokeProvider is not available\n */\nexport function useSupply(\n spokeToken: XToken,\n spokeProvider: SpokeProvider | undefined,\n): UseMutationResult<SupplyResponse, Error, string> {\n const { sodax } = useSodaxContext();\n\n return useMutation<SupplyResponse, Error, string>({\n mutationFn: async (amount: string) => {\n if (!spokeProvider) {\n throw new Error('spokeProvider is not found');\n }\n\n const response = await sodax.moneyMarket.supply(\n {\n token: spokeToken.address,\n amount: parseUnits(amount, spokeToken.decimals),\n action: 'supply',\n },\n spokeProvider,\n );\n\n if (!response.ok) {\n throw new Error('Failed to supply tokens');\n }\n\n console.log('Supply transaction submitted:', response);\n return response;\n },\n });\n}\n","import type { SpokeProvider } from '@sodax/sdk';\nimport type { XToken } from '@sodax/types';\nimport { useMutation, type UseMutationResult } from '@tanstack/react-query';\nimport { parseUnits } from 'viem';\nimport { useSodaxContext } from '../shared/useSodaxContext';\n\ninterface WithdrawResponse {\n ok: true;\n value: [string, string];\n}\n\n/**\n * Hook for withdrawing supplied tokens from the Sodax money market.\n *\n * This hook provides functionality to withdraw previously supplied tokens from the money market protocol,\n * handling the entire withdrawal process including transaction creation, submission,\n * and cross-chain communication.\n *\n * @param {XToken} spokeToken - The token to withdraw from the spoke chain. Must be an XToken with valid address and chain information.\n * @param {SpokeProvider} spokeProvider - The spoke provider to use for the withdraw transaction. Must be a valid SpokeProvider instance.\n *\n * @returns {UseMutationResult<WithdrawResponse, Error, string>} A mutation result object with the following properties:\n * - mutateAsync: Function to execute the withdraw transaction\n * - isPending: Boolean indicating if a transaction is in progress\n * @example\n * ```typescript\n * const { mutateAsync: withdraw, isPending, error } = useWithdraw(spokeToken);\n * await withdraw('100');\n * ```\n *\n * @throws {Error} When:\n * - spokeProvider is not available\n * - Transaction execution fails\n */\nexport function useWithdraw(\n spokeToken: XToken,\n spokeProvider: SpokeProvider | undefined,\n): UseMutationResult<WithdrawResponse, Error, string> {\n const { sodax } = useSodaxContext();\n\n return useMutation<WithdrawResponse, Error, string>({\n mutationFn: async (amount: string) => {\n if (!spokeProvider) {\n throw new Error('spokeProvider is not found');\n }\n\n const response = await sodax.moneyMarket.withdraw(\n {\n token: spokeToken.address,\n // vault token on hub chain decimals is 18\n amount: parseUnits(amount, 18),\n action: 'withdraw',\n },\n spokeProvider,\n );\n\n if (!response.ok) {\n throw new Error('Failed to withdraw tokens');\n }\n\n console.log('Withdraw transaction submitted:', response);\n return response;\n },\n });\n}\n","import type { SpokeProvider, UserReserveData } from '@sodax/sdk';\nimport { useQuery, type UseQueryResult } from '@tanstack/react-query';\nimport { useSodaxContext } from '../shared/useSodaxContext';\n\n/**\n * Hook for fetching user reserves data from the Sodax money market.\n *\n * This hook provides access to the current state of user reserves in the money market protocol.\n * The data is automatically fetched and cached using React Query.\n *\n * @example\n * ```typescript\n * const { data: userReservesData, isLoading, error } = useUserReservesData(spokeProvider, address);\n * ```\n *\n * @returns A React Query result object containing:\n * - data: The user reserves data when available\n * - isLoading: Loading state indicator\n * - error: Any error that occurred during data fetching\n */\nexport function useUserReservesData(\n spokeProvider: SpokeProvider | undefined,\n address: string | undefined,\n refetchInterval = 5000,\n): UseQueryResult<readonly [readonly UserReserveData[], number], Error> {\n const { sodax } = useSodaxContext();\n\n return useQuery({\n queryKey: ['userReserves', spokeProvider?.chainConfig.chain.id, address],\n queryFn: async () => {\n if (!spokeProvider) {\n throw new Error('Spoke provider or address is not defined');\n }\n\n return await sodax.moneyMarket.data.getUserReservesData(spokeProvider);\n },\n enabled: !!spokeProvider && !!address,\n refetchInterval,\n });\n}\n","import { useQuery } from '@tanstack/react-query';\nimport { useSodaxContext } from '../shared/useSodaxContext';\n/**\n * Hook for fetching reserves data from the Sodax money market.\n *\n * This hook provides access to the current state of all reserves in the money market protocol,\n * including liquidity, interest rates, and other key metrics. The data is automatically\n * fetched and cached using React Query.\n *\n * @example\n * ```typescript\n * const { data: reservesData, isLoading, error } = useReservesData();\n * ```\n *\n * @returns A React Query result object containing:\n * - data: The reserves data when available\n * - isLoading: Loading state indicator\n * - error: Any error that occurred during data fetching\n */\n\nexport function useReservesData() {\n const { sodax } = useSodaxContext();\n\n return useQuery({\n queryKey: ['reservesData'],\n queryFn: async () => {\n return await sodax.moneyMarket.data.getReservesData();\n },\n });\n}\n","import { useQuery, type UseQueryResult } from '@tanstack/react-query';\nimport type { XToken } from '@sodax/types';\nimport { useSodaxContext } from '../shared/useSodaxContext';\nimport { parseUnits } from 'viem';\nimport type { MoneyMarketAction, SpokeProvider } from '@sodax/sdk';\n\n/**\n * Hook for checking token allowance for money market operations.\n *\n * This hook verifies if the user has approved enough tokens for a specific money market action\n * (borrow/repay). It automatically queries and tracks the allowance status.\n *\n * @param {XToken} token - The token to check allowance for. Must be an XToken with valid address and chain information.\n * @param {string} amount - The amount to check allowance for, as a decimal string\n * @param {MoneyMarketAction} action - The money market action to check allowance for ('borrow' or 'repay')\n * @param {SpokeProvider} spokeProvider - The spoke provider to use for allowance checks\n *\n * @returns {UseQueryResult<boolean, Error>} A React Query result containing:\n * - data: Boolean indicating if allowance is sufficient\n * - isLoading: Loading state indicator\n * - error: Any error that occurred during the check\n *\n * @example\n * ```typescript\n * const { data: hasAllowed, isLoading } = useMMAllowance(token, \"100\", \"repay\", provider);\n * ```\n */\nexport function useMMAllowance(\n token: XToken,\n amount: string,\n action: MoneyMarketAction,\n spokeProvider: SpokeProvider | undefined,\n): UseQueryResult<boolean, Error> {\n const { sodax } = useSodaxContext();\n\n return useQuery({\n queryKey: ['allowance', token.address, amount, action],\n queryFn: async () => {\n if (!spokeProvider) throw new Error('Spoke provider is required');\n const allowance = await sodax.moneyMarket.isAllowanceValid(\n {\n token: token.address,\n amount: parseUnits(amount, token.decimals),\n action,\n },\n spokeProvider,\n );\n if (allowance.ok) {\n return allowance.value;\n }\n return false;\n },\n enabled: !!spokeProvider,\n });\n}\n","import { useSodaxContext } from '../shared/useSodaxContext';\nimport type { XToken } from '@sodax/types';\nimport { parseUnits } from 'viem';\nimport { useMutation, useQueryClient } from '@tanstack/react-query';\nimport type { MoneyMarketAction, SpokeProvider } from '@sodax/sdk';\n\ninterface UseApproveReturn {\n approve: ({ amount, action }: { amount: string; action: MoneyMarketAction }) => Promise<boolean>;\n isLoading: boolean;\n error: Error | null;\n resetError: () => void;\n}\n\n/**\n * Hook for approving token spending for money market actions\n * @param token The token to approve spending for\n * @param spokeProvider The spoke provider instance for the chain\n * @returns Object containing approve function, loading state, error state and reset function\n * @example\n * ```tsx\n * const { approve, isLoading, error } = useMMApprove(token, spokeProvider);\n *\n * // Approve tokens for supply action\n * await approve({ amount: \"100\", action: \"supply\" });\n * ```\n */\n\nexport function useMMApprove(token: XToken, spokeProvider: SpokeProvider | undefined): UseApproveReturn {\n const { sodax } = useSodaxContext();\n const queryClient = useQueryClient();\n\n const {\n mutateAsync: approve,\n isPending,\n error,\n reset: resetError,\n } = useMutation({\n mutationFn: async ({ amount, action }: { amount: string; action: MoneyMarketAction }) => {\n if (!spokeProvider) {\n throw new Error('Spoke provider not found');\n }\n const allowance = await sodax.moneyMarket.approve(\n {\n token: token.address,\n amount: parseUnits(amount, token.decimals),\n action,\n },\n spokeProvider,\n );\n if (!allowance.ok) {\n throw new Error('Failed to approve tokens');\n }\n return allowance.ok;\n },\n onSuccess: () => {\n // Invalidate allowance query to refetch the new allowance\n queryClient.invalidateQueries({ queryKey: ['allowance', token.address] });\n },\n });\n\n return {\n approve,\n isLoading: isPending,\n error: error,\n resetError,\n };\n}\n","import type { SolverErrorResponse, SolverIntentQuoteRequest, SolverIntentQuoteResponse, Result } from '@sodax/sdk';\nimport { useSodaxContext } from '../shared/useSodaxContext';\nimport { useQuery, type UseQueryResult } from '@tanstack/react-query';\n\n/**\n * Hook for fetching a quote for an intent-based swap.\n *\n * This hook provides real-time quote data for an intent-based swap.\n *\n * @param {SolverIntentQuoteRequest | undefined} payload - The intent quote request parameters. If undefined, the query will be disabled.\n *\n * @returns {UseQueryResult<Result<SolverIntentQuoteResponse, SolverErrorResponse> | undefined>} A query result object containing:\n * - data: The quote result from the solver\n * - isLoading: Boolean indicating if the quote is being fetched\n * - error: Error object if the quote request failed\n * - refetch: Function to manually trigger a quote refresh\n *\n * @example\n * ```typescript\n * const { data: quote, isLoading } = useQuote({\n * token_src: '0x...',\n * token_src_blockchain_id: '1',\n * token_dst: '0x...',\n * token_dst_blockchain_id: '2',\n * amount: '1000000000000000000',\n * quote_type: 'exact_input',\n * });\n *\n * if (isLoading) return <div>Loading quote...</div>;\n * if (quote) {\n * console.log('Quote received:', quote);\n * }\n * ```\n *\n * @remarks\n * - The quote is automatically refreshed every 3 seconds\n * - The query is disabled when payload is undefined\n * - Uses React Query for efficient caching and state management\n */\nexport const useQuote = (\n payload: SolverIntentQuoteRequest | undefined,\n): UseQueryResult<Result<SolverIntentQuoteResponse, SolverErrorResponse> | undefined> => {\n const { sodax } = useSodaxContext();\n return useQuery({\n queryKey: [payload],\n queryFn: async () => {\n if (!payload) {\n return undefined;\n }\n return sodax.solver.getQuote(payload);\n },\n enabled: !!payload,\n refetchInterval: 3000,\n });\n};\n","import { useSodaxContext } from '../shared/useSodaxContext';\nimport type {\n CreateIntentParams,\n SolverExecutionResponse,\n Result,\n IntentErrorCode,\n Intent,\n IntentError,\n SpokeProvider,\n IntentDeliveryInfo,\n} from '@sodax/sdk';\nimport { useMutation, type UseMutationResult } from '@tanstack/react-query';\n\ntype CreateIntentResult = Result<[SolverExecutionResponse, Intent, IntentDeliveryInfo], IntentError<IntentErrorCode>>;\n\n/**\n * Hook for creating and submitting an swap intent order for cross-chain swaps.\n * Uses React Query's useMutation for better state management and caching.\n *\n * @param {SpokeProvider} spokeProvider - The spoke provider to use for the swap\n * @returns {UseMutationResult} Mutation result object containing mutation function and state\n *\n * @example\n * ```typescript\n * const { mutateAsync: swap, isPending } = useSwap(spokeProvider);\n *\n * const handleSwap = async () => {\n * const result = await swap({\n * token_src: '0x...',\n * token_src_blockchain_id: 'arbitrum',\n * token_dst: '0x...',\n * token_dst_blockchain_id: 'polygon',\n * amount: '1000000000000000000',\n * min_output_amount: '900000000000000000'\n * });\n * };\n * ```\n */\nexport function useSwap(\n spokeProvider: SpokeProvider | undefined,\n): UseMutationResult<CreateIntentResult, Error, CreateIntentParams> {\n const { sodax } = useSodaxContext();\n\n return useMutation<CreateIntentResult, Error, CreateIntentParams>({\n mutationFn: async (params: CreateIntentParams) => {\n if (!spokeProvider) {\n throw new Error('Spoke provider not found');\n }\n return sodax.solver.swap({\n intentParams: params,\n spokeProvider,\n });\n },\n });\n}\n","import type { Hex, SolverErrorResponse, SolverIntentStatusResponse, Result } from '@sodax/sdk';\nimport { useQuery, type UseQueryResult } from '@tanstack/react-query';\nimport { useSodaxContext } from '../shared/useSodaxContext';\n\n/**\n * Hook for monitoring the status of an intent-based swap.\n *\n * This hook provides real-time status updates for an intent-based swap transaction.\n *\n * @param {Hex} intent_tx_hash - The transaction hash of the intent order on the hub chain\n *\n * @returns {UseQueryResult<Result<SolverIntentStatusResponse, SolverErrorResponse> | undefined>} A query result object containing:\n * - data: The status result from the solver\n * - isLoading: Boolean indicating if the status is being fetched\n * - error: Error object if the status request failed\n * - refetch: Function to manually trigger a status refresh\n *\n * @example\n * ```typescript\n * const { data: status, isLoading } = useStatus('0x...');\n *\n * if (isLoading) return <div>Loading status...</div>;\n * if (status?.ok) {\n * console.log('Status:', status.value);\n * }\n * ```\n *\n * @remarks\n * - The status is automatically refreshed every 3 seconds\n * - Uses React Query for efficient caching and state management\n */\n\nexport const useStatus = (\n intent_tx_hash: Hex,\n): UseQueryResult<Result<SolverIntentStatusResponse, SolverErrorResponse> | undefined> => {\n const { sodax } = useSodaxContext();\n return useQuery({\n queryKey: [intent_tx_hash],\n queryFn: async () => {\n return sodax.solver.getStatus({ intent_tx_hash });\n },\n refetchInterval: 3000, // 3s\n });\n};\n","import { useQuery, type UseQueryResult } from '@tanstack/react-query';\nimport { useSodaxContext } from '../shared/useSodaxContext';\nimport type { CreateIntentParams, SpokeProvider } from '@sodax/sdk';\n\n/**\n * Hook for checking token allowance for money market operations.\n *\n * This hook verifies if the user has approved enough tokens for a specific money market action\n * (borrow/repay). It automatically queries and tracks the allowance status.\n *\n * @param {CreateIntentParams} params - The parameters for the intent to check allowance for.\n * @param {SpokeProvider} spokeProvider - The spoke provider to use for allowance checks\n *\n * @returns {UseQueryResult<boolean, Error>} A React Query result containing:\n * - data: Boolean indicating if allowance is sufficient\n * - isLoading: Loading state indicator\n * - error: Any error that occurred during the check\n *\n * @example\n * ```typescript\n * const { data: hasAllowed, isLoading } = useMMAllowance(params, spokeProvider);\n * ```\n */\nexport function useSwapAllowance(\n params: CreateIntentParams | undefined,\n spokeProvider: SpokeProvider | undefined,\n): UseQueryResult<boolean, Error> {\n const { sodax } = useSodaxContext();\n\n return useQuery({\n queryKey: ['allowance', params],\n queryFn: async () => {\n if (!spokeProvider || !params) {\n return false;\n }\n const allowance = await sodax.solver.isAllowanceValid({\n intentParams: params,\n spokeProvider,\n });\n if (allowance.ok) {\n return allowance.value;\n }\n return false;\n },\n enabled: !!spokeProvider && !!params,\n });\n}\n","import { useSodaxContext } from '../shared/useSodaxContext';\nimport { useMutation, useQueryClient } from '@tanstack/react-query';\nimport type { CreateIntentParams, SpokeProvider } from '@sodax/sdk';\n\ninterface UseApproveReturn {\n approve: ({ params }: { params: CreateIntentParams }) => Promise<boolean>;\n isLoading: boolean;\n error: Error | null;\n resetError: () => void;\n}\n\n/**\n * Hook for approving token spending for money market actions\n * @param token The token to approve spending for\n * @param spokeProvider The spoke provider instance for the chain\n * @returns Object containing approve function, loading state, error state and reset function\n * @example\n * ```tsx\n * const { approve, isLoading, error } = useApprove(token, spokeProvider);\n *\n * // Approve tokens for supply action\n * await approve({ amount: \"100\", action: \"supply\" });\n * ```\n */\n\nexport function useSwapApprove(\n params: CreateIntentParams | undefined,\n spokeProvider: SpokeProvider | undefined,\n): UseApproveReturn {\n const { sodax } = useSodaxContext();\n const queryClient = useQueryClient();\n\n const {\n mutateAsync: approve,\n isPending,\n error,\n reset: resetError,\n } = useMutation({\n mutationFn: async ({ params }: { params: CreateIntentParams | undefined }) => {\n if (!spokeProvider) {\n throw new Error('Spoke provider not found');\n }\n if (!params) {\n throw new Error('Swap Params not found');\n }\n\n const allowance = await sodax.solver.approve({\n intentParams: params,\n spokeProvider,\n });\n if (!allowance.ok) {\n throw new Error('Failed to approve input token');\n }\n return allowance.ok;\n },\n onSuccess: () => {\n // Invalidate allowance query to refetch the new allowance\n queryClient.invalidateQueries({ queryKey: ['allowance', params?.inputToken] });\n },\n });\n\n return {\n approve,\n isLoading: isPending,\n error: error,\n resetError,\n };\n}\n","import { useSodaxContext } from '../shared/useSodaxContext';\nimport type { Intent, Result, SpokeProvider, TxReturnType } from '@sodax/sdk';\nimport { useMutation, type UseMutationResult } from '@tanstack/react-query';\n\ntype CancelIntentParams = {\n intent: Intent;\n raw?: boolean;\n};\n\ntype CancelIntentResult = Result<TxReturnType<SpokeProvider, boolean>>;\n\n/**\n * Hook for canceling a swap intent order.\n * Uses React Query's useMutation for better state management and caching.\n *\n * @param {SpokeProvider} spokeProvider - The spoke provider to use for canceling the intent\n * @returns {UseMutationResult} Mutation result object containing mutation function and state\n *\n * @example\n * ```typescript\n * const { mutateAsync: cancelSwap, isPending } = useCancelSwap(spokeProvider);\n *\n * const handleCancelSwap = async () => {\n * const result = await cancelSwap({\n * intent: intentObject,\n * raw: false // optional, defaults to false\n * });\n * };\n * ```\n */\nexport function useCancelSwap(\n spokeProvider: SpokeProvider | undefined,\n): UseMutationResult<CancelIntentResult, Error, CancelIntentParams> {\n const { sodax } = useSodaxContext();\n\n return useMutation<CancelIntentResult, Error, CancelIntentParams>({\n mutationFn: async ({ intent, raw = false }: CancelIntentParams) => {\n if (!spokeProvider) {\n throw new Error('Spoke provider not found');\n }\n return sodax.solver.cancelIntent(intent, spokeProvider, raw);\n },\n });\n}\n","import { useQuery, type UseQueryResult } from '@tanstack/react-query';\nimport { useSodaxContext } from '../shared/useSodaxContext';\nimport type { SpokeProvider, CreateBridgeIntentParams } from '@sodax/sdk';\n\n/**\n * Hook for checking token allowance for bridge operations.\n *\n * This hook verifies if the user has approved enough tokens for a specific bridge action.\n * It automatically queries and tracks the allowance status.\n *\n * @param {BridgeParams} params - The parameters for the bridge to check allowance for.\n * @param {SpokeProvider} spokeProvider - The spoke provider to use for allowance checks\n *\n * @returns {UseQueryResult<boolean, Error>} A React Query result containing:\n * - data: Boolean indicating if allowance is sufficient\n * - isLoading: Loading state indicator\n * - error: Any error that occurred during the check\n *\n * @example\n * ```typescript\n * const { data: hasAllowed, isLoading } = useBridgeAllowance(params, spokeProvider);\n * ```\n */\nexport function useBridgeAllowance(\n params: CreateBridgeIntentParams | undefined,\n spokeProvider: SpokeProvider | undefined,\n): UseQueryResult<boolean, Error> {\n const { sodax } = useSodaxContext();\n\n return useQuery({\n queryKey: ['bridge-allowance', params],\n queryFn: async () => {\n if (!spokeProvider || !params) {\n return false;\n }\n\n const allowance = await sodax.bridge.isAllowanceValid({\n params,\n spokeProvider,\n });\n\n if (allowance.ok) {\n return allowance.value;\n }\n return false;\n },\n enabled: !!spokeProvider && !!params,\n });\n}\n","import { useSodaxContext } from '../shared/useSodaxContext';\nimport type { CreateBridgeIntentParams, SpokeProvider } from '@sodax/sdk';\nimport { useMutation, useQueryClient } from '@tanstack/react-query';\n\ninterface UseBridgeApproveReturn {\n approve: (params: CreateBridgeIntentParams) => Promise<boolean>;\n isLoading: boolean;\n error: Error | null;\n resetError: () => void;\n}\n\n/**\n * Hook for approving token spending for bridge actions\n * @param spokeProvider The spoke provider instance for the chain\n * @returns Object containing approve function, loading state, error state and reset function\n * @example\n * ```tsx\n * const { approve, isLoading, error } = useBridgeApprove(spokeProvider);\n *\n * // Approve tokens for bridge action\n * await approve({\n * srcChainId: '0x2105.base',\n * srcAsset: '0x...',\n * amount: 1000n,\n * dstChainId: '0x89.polygon',\n * dstAsset: '0x...',\n * recipient: '0x...'\n * });\n * ```\n */\nexport function useBridgeApprove(spokeProvider: SpokeProvider | undefined): UseBridgeApproveReturn {\n const { sodax } = useSodaxContext();\n const queryClient = useQueryClient();\n\n const {\n mutateAsync: approve,\n isPending,\n error,\n reset: resetError,\n } = useMutation({\n mutationFn: async (params: CreateBridgeIntentParams) => {\n if (!spokeProvider) {\n throw new Error('Spoke provider not found');\n }\n\n const allowance = await sodax.bridge.approve({\n params,\n spokeProvider,\n });\n\n if (!allowance.ok) {\n throw new Error('Failed to approve tokens for bridge');\n }\n return true;\n },\n onSuccess: (_, params) => {\n // Invalidate allowance query to refetch the new allowance\n queryClient.invalidateQueries({ queryKey: ['bridge-allowance', params] });\n },\n });\n\n return {\n approve,\n isLoading: isPending,\n error: error,\n resetError,\n };\n}\n","import { useSodaxContext } from '../shared/useSodaxContext';\nimport type { BridgeError, BridgeErrorCode, SpokeTxHash, HubTxHash, Result, CreateBridgeIntentParams } from '@sodax/sdk';\nimport { useMutation, type UseMutationResult } from '@tanstack/react-query';\nimport type { SpokeProvider } from '@sodax/sdk';\n\n/**\n * Hook for executing bridge transactions to transfer tokens between chains.\n * Uses React Query's useMutation for better state management and caching.\n *\n * @param {SpokeProvider} spokeProvider - The spoke provider to use for the bridge\n * @returns {UseMutationResult} Mutation result object containing mutation function and state\n *\n * @example\n * ```typescript\n * const { mutateAsync: bridge, isPending } = useBridge(spokeProvider);\n *\n * const handleBridge = async () => {\n * const result = await bridge({\n * srcChainId: '0x2105.base',\n * srcAsset: '0x...',\n * amount: 1000n,\n * dstChainId: '0x89.polygon',\n * dstAsset: '0x...',\n * recipient: '0x...'\n * });\n *\n * console.log('Bridge transaction hashes:', {\n * spokeTxHash: result.spokeTxHash,\n * hubTxHash: result.hubTxHash\n * });\n * };\n * ```\n */\nexport function useBridge(\n spokeProvider: SpokeProvider | undefined,\n): UseMutationResult<Result<[SpokeTxHash, HubTxHash], BridgeError<BridgeErrorCode>>, Error, CreateBridgeIntentParams> {\n const { sodax } = useSodaxContext();\n\n return useMutation<Result<[SpokeTxHash, HubTxHash], BridgeError<BridgeErrorCode>>, Error, CreateBridgeIntentParams>({\n mutationFn: async (params: CreateBridgeIntentParams) => {\n if (!spokeProvider) {\n throw new Error('Spoke provider not found');\n }\n\n const result = await sodax.bridge.bridge({\n params,\n spokeProvider,\n });\n\n if (!result.ok) {\n throw new Error(`Bridge failed: ${result.error.code}`);\n }\n\n return result;\n },\n });\n}\n","import { useQuery, type UseQueryResult } from '@tanstack/react-query';\nimport { useSodaxContext } from '../shared/useSodaxContext';\nimport type { Result, SpokeChainId, XToken } from '@sodax/sdk';\n\n/**\n * Hook for getting the amount available to be bridged.\n *\n * This hook is used to check if a target chain has enough balance to bridge when bridging.\n * It automatically queries and tracks the available amount to be bridged.\n *\n * @param {SpokeChainId | undefined} chainId - The chain ID to get the balance for\n * @param {string | undefined} token - The token address to get the balance for\n *\n * @returns {UseQueryResult<bigint, Error>} A React Query result containing:\n * - data: The available amount to be bridged (bigint)\n * - error: Any error that occurred during the check\n *\n * @example\n * ```typescript\n * const { data: balance, isLoading } = useSpokeAssetManagerTokenBalance(chainId, tokenAddress);\n *\n * if (balance) {\n * console.log('Asset manager token balance:', balance.toString());\n * }\n * ```\n */\nexport function useGetBridgeableAmount(\n from: XToken | undefined,\n to: XToken | undefined,\n): UseQueryResult<bigint, Error> {\n const { sodax } = useSodaxContext();\n\n return useQuery({\n queryKey: ['spoke-asset-manager-token-balance', from, to],\n queryFn: async () => {\n if (!from || !to) {\n return 0n;\n }\n\n const result = await sodax.bridge.getBridgeableAmount(from, to);\n if (result.ok) {\n return result.value;\n }\n\n console.error('Error getting bridgeable amount:', result.error);\n return 0n;\n },\n enabled: !!from && !!to,\n });\n}\n","import { useQuery, type UseQueryResult } from '@tanstack/react-query';\nimport { type XToken, type SpokeChainId } from '@sodax/sdk';\nimport { useSodaxContext } from '../shared';\n\n/**\n/**\n * Hook for retrieving all bridgeable tokens from a source token on one chain to a destination chain.\n *\n * This hook queries and tracks the set of tokens on the destination chain that can be bridged to,\n * given a source chain, destination chain, and source token address.\n *\n * @param {SpokeChainId | undefined} from - The source chain ID\n * @param {SpokeChainId | undefined} to - The destination chain ID\n * @param {string | undefined} token - The source token address\n *\n * @returns {UseQueryResult<XToken[], Error>} A React Query result containing:\n * - data: Array of bridgeable tokens (XToken[]) on the destination chain\n * - error: Any error that occurred during the query\n *\n *\n * @example\n * ```typescript\n * const { data: bridgeableTokens, isLoading } = useGetBridgeableTokens(\n * fromChainId,\n * toChainId,\n * fromTokenAddress\n * );\n *\n * if (bridgeableTokens && bridgeableTokens.length > 0) {\n * bridgeableTokens.forEach(token => {\n * console.log(`Bridgeable token: ${token.symbol} (${token.address}) on chain ${token.xChainId}`);\n * });\n * } else {\n * console.log('No bridgeable tokens found for the selected route.');\n * }\n * ```\n */\nexport function useGetBridgeableTokens(\n from: SpokeChainId | undefined,\n to: SpokeChainId | undefined,\n token: string | undefined,\n): UseQueryResult<XToken[], Error> {\n const { sodax } = useSodaxContext();\n\n return useQuery({\n queryKey: ['bridgeable-tokens', from, to, token],\n queryFn: async () => {\n if (!from || !to || !token) {\n return [];\n }\n\n const result = sodax.bridge.getBridgeableTokens(from, to, token);\n if (result.ok) {\n return result.value;\n }\n\n console.error('Error getting bridgeable tokens:', result.error);\n return [];\n },\n enabled: !!from && !!to && !!token,\n });\n}\n","import type { ReactNode, ReactElement } from 'react';\nimport React from 'react';\n\nimport { Sodax, type SodaxConfig } from '@sodax/sdk';\nimport { SodaxContext } from '@/contexts';\nimport type { RpcConfig } from '@/types';\n\ninterface SodaxProviderProps {\n children: ReactNode;\n testnet?: boolean;\n config?: SodaxConfig;\n rpcConfig: RpcConfig;\n}\n\nexport const SodaxProvider = ({ children, testnet = false, config, rpcConfig }: SodaxProviderProps): ReactElement => {\n const sodax = new Sodax(config);\n\n return <SodaxContext.Provider value={{ sodax, testnet, rpcConfig }}>{children}</SodaxContext.Provider>;\n};\n","import type { ChainId } from '@sodax/types';\n\nimport { hubAssets } from '@sodax/sdk';\n\nexport const getSpokeTokenAddressByVault = (spokeChainId: ChainId, vault: string) => {\n const tokens = hubAssets[spokeChainId];\n const address = Object.keys(tokens).find(\n tokenAddress => tokens[tokenAddress].vault.toLowerCase() === vault.toLowerCase(),\n );\n\n return address;\n};\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"SodaxProvider.d.ts","sourceRoot":"","sources":["../../src/providers/SodaxProvider.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,OAAO,CAAC;AACrD,OAAO,EAA4C,KAAK,WAAW,EAAE,MAAM,YAAY,CAAC;AAGxF,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAEzC,UAAU,kBAAkB;IAC1B,QAAQ,EAAE,SAAS,CAAC;IACpB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,MAAM,CAAC,EAAE,WAAW,CAAC;IACrB,SAAS,EAAE,SAAS,CAAC;CACtB;AAED,eAAO,MAAM,aAAa,6CAAsD,kBAAkB,KAAG,YAmBpG,CAAC"}
1
+ {"version":3,"file":"SodaxProvider.d.ts","sourceRoot":"","sources":["../../src/providers/SodaxProvider.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,OAAO,CAAC;AAGrD,OAAO,EAAS,KAAK,WAAW,EAAE,MAAM,YAAY,CAAC;AAErD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAEzC,UAAU,kBAAkB;IAC1B,QAAQ,EAAE,SAAS,CAAC;IACpB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,MAAM,CAAC,EAAE,WAAW,CAAC;IACrB,SAAS,EAAE,SAAS,CAAC;CACtB;AAED,eAAO,MAAM,aAAa,6CAAsD,kBAAkB,KAAG,YAIpG,CAAC"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@sodax/dapp-kit",
3
3
  "license": "MIT",
4
- "version": "0.0.1-rc.20",
4
+ "version": "0.0.1-rc.22",
5
5
  "description": "dapp-kit of New World",
6
6
  "main": "dist/index.js",
7
7
  "types": "dist/index.d.ts",
@@ -16,7 +16,7 @@
16
16
  },
17
17
  "dependencies": {
18
18
  "viem": "^2.29.2",
19
- "@sodax/sdk": "0.0.1-rc.24",
19
+ "@sodax/sdk": "0.0.1-rc.32",
20
20
  "@sodax/types": "0.0.1-rc.15"
21
21
  },
22
22
  "devDependencies": {
@@ -1,11 +1,10 @@
1
1
  import { createContext } from 'react';
2
- import type { EvmHubProvider, Sodax } from '@sodax/sdk';
2
+ import type { Sodax } from '@sodax/sdk';
3
3
  import type { RpcConfig } from '@/types';
4
4
 
5
5
  export interface SodaxContextType {
6
6
  sodax: Sodax;
7
7
  testnet: boolean;
8
- hubProvider: EvmHubProvider | undefined;
9
8
  rpcConfig: RpcConfig;
10
9
  }
11
10
 
@@ -0,0 +1,5 @@
1
+ export * from './useBridgeAllowance';
2
+ export * from './useBridgeApprove';
3
+ export * from './useBridge';
4
+ export * from './useGetBridgeableAmount';
5
+ export * from './useGetBridgeableTokens';
@@ -0,0 +1,57 @@
1
+ import { useSodaxContext } from '../shared/useSodaxContext';
2
+ import type { BridgeError, BridgeErrorCode, SpokeTxHash, HubTxHash, Result, CreateBridgeIntentParams } from '@sodax/sdk';
3
+ import { useMutation, type UseMutationResult } from '@tanstack/react-query';
4
+ import type { SpokeProvider } from '@sodax/sdk';
5
+
6
+ /**
7
+ * Hook for executing bridge transactions to transfer tokens between chains.
8
+ * Uses React Query's useMutation for better state management and caching.
9
+ *
10
+ * @param {SpokeProvider} spokeProvider - The spoke provider to use for the bridge
11
+ * @returns {UseMutationResult} Mutation result object containing mutation function and state
12
+ *
13
+ * @example
14
+ * ```typescript
15
+ * const { mutateAsync: bridge, isPending } = useBridge(spokeProvider);
16
+ *
17
+ * const handleBridge = async () => {
18
+ * const result = await bridge({
19
+ * srcChainId: '0x2105.base',
20
+ * srcAsset: '0x...',
21
+ * amount: 1000n,
22
+ * dstChainId: '0x89.polygon',
23
+ * dstAsset: '0x...',
24
+ * recipient: '0x...'
25
+ * });
26
+ *
27
+ * console.log('Bridge transaction hashes:', {
28
+ * spokeTxHash: result.spokeTxHash,
29
+ * hubTxHash: result.hubTxHash
30
+ * });
31
+ * };
32
+ * ```
33
+ */
34
+ export function useBridge(
35
+ spokeProvider: SpokeProvider | undefined,
36
+ ): UseMutationResult<Result<[SpokeTxHash, HubTxHash], BridgeError<BridgeErrorCode>>, Error, CreateBridgeIntentParams> {
37
+ const { sodax } = useSodaxContext();
38
+
39
+ return useMutation<Result<[SpokeTxHash, HubTxHash], BridgeError<BridgeErrorCode>>, Error, CreateBridgeIntentParams>({
40
+ mutationFn: async (params: CreateBridgeIntentParams) => {
41
+ if (!spokeProvider) {
42
+ throw new Error('Spoke provider not found');
43
+ }
44
+
45
+ const result = await sodax.bridge.bridge({
46
+ params,
47
+ spokeProvider,
48
+ });
49
+
50
+ if (!result.ok) {
51
+ throw new Error(`Bridge failed: ${result.error.code}`);
52
+ }
53
+
54
+ return result;
55
+ },
56
+ });
57
+ }
@@ -0,0 +1,49 @@
1
+ import { useQuery, type UseQueryResult } from '@tanstack/react-query';
2
+ import { useSodaxContext } from '../shared/useSodaxContext';
3
+ import type { SpokeProvider, CreateBridgeIntentParams } from '@sodax/sdk';
4
+
5
+ /**
6
+ * Hook for checking token allowance for bridge operations.
7
+ *
8
+ * This hook verifies if the user has approved enough tokens for a specific bridge action.
9
+ * It automatically queries and tracks the allowance status.
10
+ *
11
+ * @param {BridgeParams} params - The parameters for the bridge to check allowance for.
12
+ * @param {SpokeProvider} spokeProvider - The spoke provider to use for allowance checks
13
+ *
14
+ * @returns {UseQueryResult<boolean, Error>} A React Query result containing:
15
+ * - data: Boolean indicating if allowance is sufficient
16
+ * - isLoading: Loading state indicator
17
+ * - error: Any error that occurred during the check
18
+ *
19
+ * @example
20
+ * ```typescript
21
+ * const { data: hasAllowed, isLoading } = useBridgeAllowance(params, spokeProvider);
22
+ * ```
23
+ */
24
+ export function useBridgeAllowance(
25
+ params: CreateBridgeIntentParams | undefined,
26
+ spokeProvider: SpokeProvider | undefined,
27
+ ): UseQueryResult<boolean, Error> {
28
+ const { sodax } = useSodaxContext();
29
+
30
+ return useQuery({
31
+ queryKey: ['bridge-allowance', params],
32
+ queryFn: async () => {
33
+ if (!spokeProvider || !params) {
34
+ return false;
35
+ }
36
+
37
+ const allowance = await sodax.bridge.isAllowanceValid({
38
+ params,
39
+ spokeProvider,
40
+ });
41
+
42
+ if (allowance.ok) {
43
+ return allowance.value;
44
+ }
45
+ return false;
46
+ },
47
+ enabled: !!spokeProvider && !!params,
48
+ });
49
+ }
@@ -0,0 +1,68 @@
1
+ import { useSodaxContext } from '../shared/useSodaxContext';
2
+ import type { CreateBridgeIntentParams, SpokeProvider } from '@sodax/sdk';
3
+ import { useMutation, useQueryClient } from '@tanstack/react-query';
4
+
5
+ interface UseBridgeApproveReturn {
6
+ approve: (params: CreateBridgeIntentParams) => Promise<boolean>;
7
+ isLoading: boolean;
8
+ error: Error | null;
9
+ resetError: () => void;
10
+ }
11
+
12
+ /**
13
+ * Hook for approving token spending for bridge actions
14
+ * @param spokeProvider The spoke provider instance for the chain
15
+ * @returns Object containing approve function, loading state, error state and reset function
16
+ * @example
17
+ * ```tsx
18
+ * const { approve, isLoading, error } = useBridgeApprove(spokeProvider);
19
+ *
20
+ * // Approve tokens for bridge action
21
+ * await approve({
22
+ * srcChainId: '0x2105.base',
23
+ * srcAsset: '0x...',
24
+ * amount: 1000n,
25
+ * dstChainId: '0x89.polygon',
26
+ * dstAsset: '0x...',
27
+ * recipient: '0x...'
28
+ * });
29
+ * ```
30
+ */
31
+ export function useBridgeApprove(spokeProvider: SpokeProvider | undefined): UseBridgeApproveReturn {
32
+ const { sodax } = useSodaxContext();
33
+ const queryClient = useQueryClient();
34
+
35
+ const {
36
+ mutateAsync: approve,
37
+ isPending,
38
+ error,
39
+ reset: resetError,
40
+ } = useMutation({
41
+ mutationFn: async (params: CreateBridgeIntentParams) => {
42
+ if (!spokeProvider) {
43
+ throw new Error('Spoke provider not found');
44
+ }
45
+
46
+ const allowance = await sodax.bridge.approve({
47
+ params,
48
+ spokeProvider,
49
+ });
50
+
51
+ if (!allowance.ok) {
52
+ throw new Error('Failed to approve tokens for bridge');
53
+ }
54
+ return true;
55
+ },
56
+ onSuccess: (_, params) => {
57
+ // Invalidate allowance query to refetch the new allowance
58
+ queryClient.invalidateQueries({ queryKey: ['bridge-allowance', params] });
59
+ },
60
+ });
61
+
62
+ return {
63
+ approve,
64
+ isLoading: isPending,
65
+ error: error,
66
+ resetError,
67
+ };
68
+ }
@@ -0,0 +1,50 @@
1
+ import { useQuery, type UseQueryResult } from '@tanstack/react-query';
2
+ import { useSodaxContext } from '../shared/useSodaxContext';
3
+ import type { Result, SpokeChainId, XToken } from '@sodax/sdk';
4
+
5
+ /**
6
+ * Hook for getting the amount available to be bridged.
7
+ *
8
+ * This hook is used to check if a target chain has enough balance to bridge when bridging.
9
+ * It automatically queries and tracks the available amount to be bridged.
10
+ *
11
+ * @param {SpokeChainId | undefined} chainId - The chain ID to get the balance for
12
+ * @param {string | undefined} token - The token address to get the balance for
13
+ *
14
+ * @returns {UseQueryResult<bigint, Error>} A React Query result containing:
15
+ * - data: The available amount to be bridged (bigint)
16
+ * - error: Any error that occurred during the check
17
+ *
18
+ * @example
19
+ * ```typescript
20
+ * const { data: balance, isLoading } = useSpokeAssetManagerTokenBalance(chainId, tokenAddress);
21
+ *
22
+ * if (balance) {
23
+ * console.log('Asset manager token balance:', balance.toString());
24
+ * }
25
+ * ```
26
+ */
27
+ export function useGetBridgeableAmount(
28
+ from: XToken | undefined,
29
+ to: XToken | undefined,
30
+ ): UseQueryResult<bigint, Error> {
31
+ const { sodax } = useSodaxContext();
32
+
33
+ return useQuery({
34
+ queryKey: ['spoke-asset-manager-token-balance', from, to],
35
+ queryFn: async () => {
36
+ if (!from || !to) {
37
+ return 0n;
38
+ }
39
+
40
+ const result = await sodax.bridge.getBridgeableAmount(from, to);
41
+ if (result.ok) {
42
+ return result.value;
43
+ }
44
+
45
+ console.error('Error getting bridgeable amount:', result.error);
46
+ return 0n;
47
+ },
48
+ enabled: !!from && !!to,
49
+ });
50
+ }
@@ -0,0 +1,62 @@
1
+ import { useQuery, type UseQueryResult } from '@tanstack/react-query';
2
+ import { type XToken, type SpokeChainId } from '@sodax/sdk';
3
+ import { useSodaxContext } from '../shared';
4
+
5
+ /**
6
+ /**
7
+ * Hook for retrieving all bridgeable tokens from a source token on one chain to a destination chain.
8
+ *
9
+ * This hook queries and tracks the set of tokens on the destination chain that can be bridged to,
10
+ * given a source chain, destination chain, and source token address.
11
+ *
12
+ * @param {SpokeChainId | undefined} from - The source chain ID
13
+ * @param {SpokeChainId | undefined} to - The destination chain ID
14
+ * @param {string | undefined} token - The source token address
15
+ *
16
+ * @returns {UseQueryResult<XToken[], Error>} A React Query result containing:
17
+ * - data: Array of bridgeable tokens (XToken[]) on the destination chain
18
+ * - error: Any error that occurred during the query
19
+ *
20
+ *
21
+ * @example
22
+ * ```typescript
23
+ * const { data: bridgeableTokens, isLoading } = useGetBridgeableTokens(
24
+ * fromChainId,
25
+ * toChainId,
26
+ * fromTokenAddress
27
+ * );
28
+ *
29
+ * if (bridgeableTokens && bridgeableTokens.length > 0) {
30
+ * bridgeableTokens.forEach(token => {
31
+ * console.log(`Bridgeable token: ${token.symbol} (${token.address}) on chain ${token.xChainId}`);
32
+ * });
33
+ * } else {
34
+ * console.log('No bridgeable tokens found for the selected route.');
35
+ * }
36
+ * ```
37
+ */
38
+ export function useGetBridgeableTokens(
39
+ from: SpokeChainId | undefined,
40
+ to: SpokeChainId | undefined,
41
+ token: string | undefined,
42
+ ): UseQueryResult<XToken[], Error> {
43
+ const { sodax } = useSodaxContext();
44
+
45
+ return useQuery({
46
+ queryKey: ['bridgeable-tokens', from, to, token],
47
+ queryFn: async () => {
48
+ if (!from || !to || !token) {
49
+ return [];
50
+ }
51
+
52
+ const result = sodax.bridge.getBridgeableTokens(from, to, token);
53
+ if (result.ok) {
54
+ return result.value;
55
+ }
56
+
57
+ console.error('Error getting bridgeable tokens:', result.error);
58
+ return [];
59
+ },
60
+ enabled: !!from && !!to && !!token,
61
+ });
62
+ }
@@ -2,3 +2,4 @@ export * from './shared';
2
2
  export * from './provider';
3
3
  export * from './mm';
4
4
  export * from './swap';
5
+ export * from './bridge';
@@ -1,4 +1,4 @@
1
- import { type FormatUserSummaryResponse, type FormatReserveUSDResponse, SpokeProvider } from '@sodax/sdk';
1
+ import type { FormatUserSummaryResponse, FormatReserveUSDResponse, SpokeProvider } from '@sodax/sdk';
2
2
  import { useQuery, type UseQueryResult } from '@tanstack/react-query';
3
3
  import { useSodaxContext } from '../shared/useSodaxContext';
4
4
 
@@ -1,4 +1,4 @@
1
- import { SpokeProvider, type UserReserveData } from '@sodax/sdk';
1
+ import type { SpokeProvider, UserReserveData } from '@sodax/sdk';
2
2
  import { useQuery, type UseQueryResult } from '@tanstack/react-query';
3
3
  import { useSodaxContext } from '../shared/useSodaxContext';
4
4
 
@@ -1,8 +1,8 @@
1
1
  import type { EvmHubProvider } from '@sodax/sdk';
2
2
  import { useSodaxContext } from '../shared/useSodaxContext';
3
3
 
4
- export function useHubProvider(): EvmHubProvider | undefined {
5
- const { hubProvider } = useSodaxContext();
4
+ export function useHubProvider(): EvmHubProvider {
5
+ const { sodax } = useSodaxContext();
6
6
 
7
- return hubProvider;
7
+ return sodax.hubProvider;
8
8
  }