@sodax/dapp-kit 0.0.1-rc.6 → 0.0.1-rc.7

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 (41) hide show
  1. package/dist/hooks/mm/index.d.ts +2 -0
  2. package/dist/hooks/mm/index.d.ts.map +1 -1
  3. package/dist/hooks/mm/useAllowance.d.ts +4 -0
  4. package/dist/hooks/mm/useAllowance.d.ts.map +1 -0
  5. package/dist/hooks/{shared → mm}/useApprove.d.ts +5 -1
  6. package/dist/hooks/mm/useApprove.d.ts.map +1 -0
  7. package/dist/hooks/mm/useBorrow.d.ts +10 -1
  8. package/dist/hooks/mm/useBorrow.d.ts.map +1 -1
  9. package/dist/hooks/mm/useRepay.d.ts +10 -1
  10. package/dist/hooks/mm/useRepay.d.ts.map +1 -1
  11. package/dist/hooks/mm/useSupply.d.ts +3 -1
  12. package/dist/hooks/mm/useSupply.d.ts.map +1 -1
  13. package/dist/hooks/mm/useUserReservesData.d.ts +1 -1
  14. package/dist/hooks/mm/useUserReservesData.d.ts.map +1 -1
  15. package/dist/hooks/mm/useWithdraw.d.ts +8 -1
  16. package/dist/hooks/mm/useWithdraw.d.ts.map +1 -1
  17. package/dist/hooks/provider/useSpokeProvider.d.ts +16 -2
  18. package/dist/hooks/provider/useSpokeProvider.d.ts.map +1 -1
  19. package/dist/hooks/shared/index.d.ts +0 -2
  20. package/dist/hooks/shared/index.d.ts.map +1 -1
  21. package/dist/hooks/swap/useCreateIntentOrder.d.ts +4 -4
  22. package/dist/hooks/swap/useCreateIntentOrder.d.ts.map +1 -1
  23. package/dist/index.js +98 -99
  24. package/dist/index.js.map +1 -1
  25. package/dist/index.mjs +99 -100
  26. package/dist/index.mjs.map +1 -1
  27. package/package.json +4 -4
  28. package/src/hooks/mm/index.ts +2 -0
  29. package/src/hooks/{shared → mm}/useAllowance.ts +4 -2
  30. package/src/hooks/{shared → mm}/useApprove.ts +9 -7
  31. package/src/hooks/mm/useBorrow.ts +14 -5
  32. package/src/hooks/mm/useRepay.ts +14 -4
  33. package/src/hooks/mm/useSupply.ts +7 -4
  34. package/src/hooks/mm/useUserReservesData.ts +6 -12
  35. package/src/hooks/mm/useWithdraw.ts +12 -4
  36. package/src/hooks/provider/useSpokeProvider.ts +31 -8
  37. package/src/hooks/shared/index.ts +0 -2
  38. package/src/hooks/swap/useCreateIntentOrder.ts +4 -6
  39. package/dist/hooks/shared/useAllowance.d.ts +0 -3
  40. package/dist/hooks/shared/useAllowance.d.ts.map +0 -1
  41. package/dist/hooks/shared/useApprove.d.ts.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/contexts/index.ts","../src/hooks/shared/useSodaxContext.ts","../src/hooks/provider/useSpokeProvider.ts","../src/hooks/shared/useAllowance.ts","../src/hooks/shared/useApprove.ts","../src/hooks/provider/useHubProvider.ts","../src/hooks/mm/useBorrow.ts","../src/hooks/mm/useRepay.ts","../src/hooks/mm/useSupply.ts","../src/hooks/mm/useWithdraw.ts","../src/core/index.ts","../src/hooks/mm/useUserReservesData.ts","../src/hooks/mm/useHubWalletAddress.ts","../src/hooks/mm/useReservesData.ts","../src/hooks/swap/useQuote.ts","../src/hooks/swap/useCreateIntentOrder.ts","../src/hooks/swap/useStatus.ts","../src/providers/SodaxProvider.tsx"],"names":["parseUnits","useMutation","useQuery","EvmWalletAbstraction","getMoneyMarketConfig","useMemo"],"mappings":";;;;;;;AASO,IAAM,YAAA,GAAe,cAAuC,IAAI,CAAA;ACAhE,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;ACMO,SAAS,iBAAiB,YAA4B,EAAA;AAC3D,EAAM,MAAA,UAAA,GAAa,cAAc,YAAY,CAAA;AAC7C,EAAM,MAAA,cAAA,GAAiB,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{ EvmHubProvider, Sodax } from '@sodax/sdk';\n\nexport interface SodaxContextType {\n sodax: Sodax;\n testnet: boolean;\n hubProvider: EvmHubProvider | undefined;\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 {\n EvmSpokeProvider,\n spokeChainConfig,\n type SuiSpokeChainConfig,\n SuiSpokeProvider,\n type EvmSpokeChainConfig,\n IconSpokeProvider,\n type IconSpokeChainConfig,\n CWSpokeProvider,\n type CosmosSpokeChainConfig,\n} from '@sodax/sdk';\nimport type {\n IEvmWalletProvider,\n IIconWalletProvider,\n ISuiWalletProvider,\n SpokeChainId,\n IInjectiveWalletProvider,\n} from '@sodax/types';\nimport { getXChainType, useWalletProvider } from '@sodax/wallet-sdk';\nimport { useMemo } from 'react';\n\nexport function useSpokeProvider(spokeChainId: SpokeChainId) {\n const xChainType = getXChainType(spokeChainId);\n const walletProvider = useWalletProvider(spokeChainId);\n const spokeProvider = useMemo(() => {\n if (!walletProvider) return undefined;\n if (xChainType === 'EVM') {\n return new EvmSpokeProvider(\n walletProvider as IEvmWalletProvider,\n spokeChainConfig[spokeChainId] as EvmSpokeChainConfig,\n );\n }\n if (xChainType === 'SUI') {\n return new SuiSpokeProvider(\n spokeChainConfig[spokeChainId] as SuiSpokeChainConfig,\n walletProvider as ISuiWalletProvider,\n );\n }\n if (xChainType === 'ICON') {\n return new IconSpokeProvider(\n walletProvider as IIconWalletProvider,\n spokeChainConfig[spokeChainId] as IconSpokeChainConfig,\n );\n }\n if (xChainType === 'INJECTIVE') {\n return new CWSpokeProvider(\n spokeChainConfig[spokeChainId] as CosmosSpokeChainConfig,\n walletProvider as IInjectiveWalletProvider,\n );\n }\n\n return undefined;\n }, [walletProvider, xChainType, spokeChainId]);\n\n return spokeProvider;\n}\n","import { useQuery } from '@tanstack/react-query';\nimport type { SpokeChainId, XToken } from '@sodax/types';\nimport { useSodaxContext } from '../shared/useSodaxContext';\nimport { useSpokeProvider } from '../provider/useSpokeProvider';\nimport { parseUnits } from 'viem';\n\nexport function useAllowance(token: XToken, amount: string) {\n const { sodax } = useSodaxContext();\n const spokeProvider = useSpokeProvider(token.xChainId as SpokeChainId);\n\n return useQuery({\n queryKey: ['allowance', token.address, amount],\n queryFn: async () => {\n if (!spokeProvider) {\n return false;\n }\n const allowance = await sodax.moneyMarket.isAllowanceValid(\n {\n token: token.address,\n amount: parseUnits(amount, token.decimals),\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 { useSpokeProvider } from '../provider/useSpokeProvider';\nimport type { SpokeChainId, XToken } from '@sodax/types';\nimport { parseUnits } from 'viem';\nimport { useMutation, useQueryClient } from '@tanstack/react-query';\nimport type { Address } from '@sodax/sdk';\n\ninterface UseApproveReturn {\n approve: (amount: string) => Promise<boolean>;\n isLoading: boolean;\n error: Error | null;\n resetError: () => void;\n}\n\nexport function useApprove(token: XToken): UseApproveReturn {\n const { sodax } = useSodaxContext();\n const spokeProvider = useSpokeProvider(token.xChainId as SpokeChainId);\n const queryClient = useQueryClient();\n\n const {\n mutateAsync: approve,\n isPending,\n error,\n reset: resetError,\n } = useMutation({\n mutationFn: async (amount: string) => {\n if (!spokeProvider) {\n throw new Error('Spoke provider not found');\n }\n const allowance = await sodax.moneyMarket.approve(\n token.address as Address,\n parseUnits(amount, token.decimals),\n spokeProvider.chainConfig.addresses.assetManager as Address,\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 as Error | null,\n resetError,\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 type { XToken } from '@sodax/types';\nimport { useMutation, type UseMutationResult } from '@tanstack/react-query';\nimport { parseUnits } from 'viem';\nimport { useSpokeProvider } from '../provider/useSpokeProvider';\nimport { useSodaxContext } from '../shared/useSodaxContext';\nimport type { SpokeChainId } from '@sodax/sdk';\ninterface BorrowResponse {\n ok: true;\n value: [`0x${string}`, `0x${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 * @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(spokeToken: XToken): UseMutationResult<BorrowResponse, Error, string> {\n const { sodax } = useSodaxContext();\n const spokeProvider = useSpokeProvider(spokeToken.xChainId as SpokeChainId);\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.borrowAndSubmit(\n {\n token: spokeToken.address,\n amount: parseUnits(amount, 18),\n },\n spokeProvider,\n );\n\n if (!response.ok) {\n console.log('Failed to borrow tokens', response);\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 { SpokeChainId } from '@sodax/sdk';\nimport type { XToken } from '@sodax/types';\nimport { useMutation, type UseMutationResult } from '@tanstack/react-query';\nimport { parseUnits } from 'viem';\nimport { useSpokeProvider } from '../provider/useSpokeProvider';\nimport { useSodaxContext } from '../shared/useSodaxContext';\n\ninterface RepayResponse {\n ok: true;\n value: [`0x${string}`, `0x${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 * @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(spokeToken: XToken): UseMutationResult<RepayResponse, Error, string> {\n const { sodax } = useSodaxContext();\n const spokeProvider = useSpokeProvider(spokeToken.xChainId as SpokeChainId);\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.repayAndSubmit(\n {\n token: spokeToken.address,\n amount: parseUnits(amount, spokeToken.decimals),\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 { SpokeChainId } from '@sodax/sdk';\nimport type { XToken } from '@sodax/types';\nimport { useMutation, type UseMutationResult } from '@tanstack/react-query';\nimport { parseUnits } from 'viem';\nimport { useSpokeProvider } from '../provider/useSpokeProvider';\nimport { useSodaxContext } from '../shared/useSodaxContext';\n\ninterface SupplyResponse {\n ok: true;\n value: [`0x${string}`, `0x${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 *\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(spokeToken: XToken): UseMutationResult<SupplyResponse, Error, string> {\n const { sodax } = useSodaxContext();\n const spokeProvider = useSpokeProvider(spokeToken.xChainId as SpokeChainId);\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.supplyAndSubmit(\n {\n token: spokeToken.address,\n amount: parseUnits(amount, spokeToken.decimals),\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 { SpokeChainId } from '@sodax/sdk';\nimport type { XToken } from '@sodax/types';\nimport { useMutation, type UseMutationResult } from '@tanstack/react-query';\nimport { parseUnits } from 'viem';\nimport { useSpokeProvider } from '../provider/useSpokeProvider';\nimport { useSodaxContext } from '../shared/useSodaxContext';\n\ninterface WithdrawResponse {\n ok: true;\n value: [`0x${string}`, `0x${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 * @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(spokeToken: XToken): UseMutationResult<WithdrawResponse, Error, string> {\n const { sodax } = useSodaxContext();\n const spokeProvider = useSpokeProvider(spokeToken.xChainId as SpokeChainId);\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.withdrawAndSubmit(\n {\n token: spokeToken.address,\n // vault token on hub chain decimals is 18\n amount: parseUnits(amount, 18),\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 { XToken, ChainId } from '@sodax/types';\n\nimport { hubAssets } from '@sodax/sdk';\n\nexport const allXTokens: XToken[] = [];\n\nObject.keys(hubAssets).forEach(xChainId => {\n const tokens = hubAssets[xChainId];\n\n Object.keys(tokens).forEach(tokenAddress => {\n const token = tokens[tokenAddress];\n allXTokens.push({\n xChainId: xChainId as ChainId,\n symbol: token.symbol,\n name: token.name,\n decimals: token.decimal,\n address: tokenAddress,\n });\n\n allXTokens.push({\n xChainId: 'sonic',\n symbol: token.symbol,\n name: token.name,\n decimals: token.decimal,\n address: token.vault,\n });\n });\n});\n\nexport const getSpokeTokenAddressByVault = (spokeChainId: ChainId, vault: string) => {\n const tokens = hubAssets[spokeChainId];\n const address = Object.keys(tokens).find(tokenAddress => tokens[tokenAddress].vault === vault);\n\n return address;\n};\n","import { allXTokens } from '@/core';\nimport { EvmWalletAbstraction, getMoneyMarketConfig, type EvmHubProvider } from '@sodax/sdk';\nimport type { HubChainId, SpokeChainId } from '@sodax/types';\nimport type { ChainId } from '@sodax/types';\nimport { useQuery } from '@tanstack/react-query';\nimport { useHubProvider } from '../provider/useHubProvider';\nimport { useSodaxContext } from '../shared/useSodaxContext';\nimport { useSpokeProvider } from '../provider/useSpokeProvider';\n\nexport function useUserReservesData(spokeChainId: ChainId) {\n const { sodax } = useSodaxContext();\n const hubChainId = (sodax.config?.hubProviderConfig?.chainConfig.chain.id ?? 'sonic') as HubChainId;\n const hubProvider = useHubProvider();\n const spokeProvider = useSpokeProvider(spokeChainId as SpokeChainId);\n\n const { data: userReserves } = useQuery({\n queryKey: ['userReserves', spokeChainId],\n queryFn: async () => {\n if (!hubProvider) {\n return;\n }\n\n if (!spokeProvider) {\n return;\n }\n\n const addressBytes = await spokeProvider.walletProvider.getWalletAddressBytes();\n const hubWalletAddress = await EvmWalletAbstraction.getUserHubWalletAddress(\n spokeChainId as SpokeChainId,\n addressBytes,\n hubProvider as EvmHubProvider,\n );\n\n const moneyMarketConfig = getMoneyMarketConfig(hubChainId);\n const [res] = await sodax.moneyMarket.getUserReservesData(\n hubWalletAddress as `0x${string}`,\n moneyMarketConfig.uiPoolDataProvider,\n moneyMarketConfig.poolAddressesProvider,\n );\n\n return res?.map(r => {\n return {\n ...r,\n token: allXTokens.find(t => t.address === r.underlyingAsset),\n };\n });\n },\n enabled: !!spokeProvider && !!hubProvider,\n refetchInterval: 5000,\n });\n\n return userReserves;\n}\n","import { type EvmHubProvider, EvmWalletAbstraction, type SpokeChainId } from '@sodax/sdk';\nimport { useQuery, type UseQueryResult } from '@tanstack/react-query';\n\n/**\n * Hook for retrieving the hub wallet address for a given spoke chain and address.\n *\n * This hook fetches the hub wallet address associated with a user's address on a specific spoke chain.\n * It uses the EvmWalletAbstraction to query the hub wallet address from the hub provider.\n *\n * @param spokeChainId - The chain ID of the spoke chain\n * @param address - The user's address on the spoke chain\n * @param hubProvider - The hub provider instance\n *\n * @returns {UseQueryResult<string | null>} A query result object containing:\n * - data: The hub wallet address or null if not found\n * - isLoading: Boolean indicating if the query is in progress\n * - error: Error object if the query failed, null otherwise\n *\n * @example\n * ```typescript\n * const { data: hubWalletAddress, isLoading, error } = useHubWalletAddress(spokeChainId, address, hubProvider);\n * ```\n */\n\nexport function useHubWalletAddress(\n spokeChainId: SpokeChainId,\n address: string | undefined,\n hubProvider: EvmHubProvider,\n): UseQueryResult<string | null> {\n return useQuery({\n queryKey: ['hubWallet', spokeChainId, address],\n queryFn: async () => {\n if (!address) return null;\n\n try {\n const hubWalletAddress = await EvmWalletAbstraction.getUserHubWalletAddress(\n spokeChainId,\n address as `0x${string}`,\n hubProvider,\n );\n return hubWalletAddress;\n } catch (error) {\n console.log('error', error);\n return null;\n }\n },\n enabled: !!address && !!hubProvider,\n });\n}\n","import { getMoneyMarketConfig } from '@sodax/sdk';\nimport type { HubChainId } from '@sodax/types';\nimport { 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 const hubChainId = (sodax.config?.hubProviderConfig?.chainConfig.chain.id ?? 'sonic') as HubChainId;\n\n return useQuery({\n queryKey: ['reservesData'],\n queryFn: async () => {\n const moneyMarketConfig = getMoneyMarketConfig(hubChainId);\n return await sodax.moneyMarket.getReservesData(\n moneyMarketConfig.uiPoolDataProvider,\n moneyMarketConfig.poolAddressesProvider,\n );\n },\n });\n}\n","import type { IntentErrorResponse, IntentQuoteRequest, IntentQuoteResponse, 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 {IntentQuoteRequest | undefined} payload - The intent quote request parameters. If undefined, the query will be disabled.\n *\n * @returns {UseQueryResult<Result<IntentQuoteResponse, IntentErrorResponse> | 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: IntentQuoteRequest | undefined,\n): UseQueryResult<Result<IntentQuoteResponse, IntentErrorResponse> | 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 SpokeChainId,\n IntentExecutionResponse,\n Result,\n IntentSubmitErrorCode,\n Intent,\n PacketData,\n IntentSubmitError,\n} from '@sodax/sdk';\nimport { useSpokeProvider } from '../provider/useSpokeProvider';\nimport { useMutation, type UseMutationResult } from '@tanstack/react-query';\n\ntype CreateIntentResult = Result<\n [IntentExecutionResponse, Intent, PacketData],\n IntentSubmitError<IntentSubmitErrorCode>\n>;\n\n/**\n * Hook for creating and submitting an intent order for cross-chain swaps.\n * Uses React Query's useMutation for better state management and caching.\n *\n * @param {SpokeChainId} chainId - The source chain ID where the swap will originate\n * @returns {UseMutationResult} Mutation result object containing mutation function and state\n *\n * @example\n * ```typescript\n * const { mutateAsync: createIntent, isPending } = useCreateIntentOrder('0xa4b1.arbitrum');\n *\n * const handleSwap = async () => {\n * const result = await createIntent({\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 useCreateIntentOrder(\n chainId: SpokeChainId,\n): UseMutationResult<CreateIntentResult, Error, CreateIntentParams> {\n const { sodax } = useSodaxContext();\n const spokeProvider = useSpokeProvider(chainId);\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.createAndSubmitIntent(params, spokeProvider);\n },\n });\n}\n","import type { Hex, IntentErrorResponse, IntentStatusResponse, 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<IntentStatusResponse, IntentErrorResponse> | 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<IntentStatusResponse, IntentErrorResponse> | 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 type { ReactNode, ReactElement } from 'react';\nimport { EvmHubProvider, getHubChainConfig, Sodax, type SodaxConfig } from '@sodax/sdk';\nimport { SodaxContext } from '@/contexts';\nimport React, { useMemo } from 'react';\n\ninterface SodaxProviderProps {\n children: ReactNode;\n testnet?: boolean;\n config: SodaxConfig;\n}\n\nexport const SodaxProvider = ({ children, testnet = false, config }: 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 }}>{children}</SodaxContext.Provider>;\n};\n"]}
1
+ {"version":3,"sources":["../src/contexts/index.ts","../src/hooks/shared/useSodaxContext.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/core/index.ts","../src/hooks/mm/useUserReservesData.ts","../src/hooks/mm/useHubWalletAddress.ts","../src/hooks/mm/useReservesData.ts","../src/hooks/mm/useAllowance.ts","../src/hooks/mm/useApprove.ts","../src/hooks/swap/useQuote.ts","../src/hooks/swap/useCreateIntentOrder.ts","../src/hooks/swap/useStatus.ts","../src/providers/SodaxProvider.tsx"],"names":["useMutation","parseUnits","useQuery","EvmWalletAbstraction","getMoneyMarketConfig","useMemo"],"mappings":";;;;;;;AASO,IAAM,YAAA,GAAe,cAAuC,IAAI,CAAA;ACAhE,IAAM,kBAAkB,MAAwB;AACrD,EAAA,MAAM,OAAA,GAAU,WAAW,YAAY,CAAA;AACvC,EAAA,IAAI,CAAC,OAAA,EAAS;AACZ,IAAA,MAAM,IAAI,MAAM,qDAAqD,CAAA;AAAA;AAEvE,EAAA,OAAO,OAAA;AACT;;;ACZO,SAAS,cAAA,GAA6C;AAC3D,EAAA,MAAM,EAAE,WAAA,EAAY,GAAI,eAAA,EAAgB;AAExC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H;ACtBO,IAAM,SAAA,GAAY,CACvB,cAAA,KACkF;AAClF,EAAA,MAAM,EAAE,KAAA,EAAM,GAAI,eAAA,EAAgB;AAClC,EAAA,OAAOE,QAAAA,CAAS;AAAA,IACd,QAAA,EAAU,CAAC,cAAc,CAAA;AAAA,IACzB,SAAS,YAAY;AACnB,MAAA,OAAO,KAAA,CAAM,MAAA,CAAO,SAAA,CAAU,EAAE,gBAAgB,CAAA;AAAA,KAClD;AAAA,IACA,eAAA,EAAiB;AAAA;AAAA,GAClB,CAAA;AACH;AChCO,IAAM,gBAAgB,CAAC,EAAE,UAAU,OAAA,GAAU,KAAA,EAAO,QAAO,KAAwC;AACxG,EAAA,MAAM,KAAA,GAAQ,IAAI,KAAA,CAAM,MAAM,CAAA;AAE9B,EAAA,MAAM,UAAA,GAAa,MAAA,EAAQ,iBAAA,EAAmB,WAAA,CAAY,KAAA,CAAM,EAAA;AAChE,EAAA,MAAM,SAAA,GAAY,QAAQ,iBAAA,EAAmB,SAAA;AAE7C,EAAA,MAAM,WAAA,GAAcG,QAAQ,MAAM;AAChC,IAAA,IAAI,cAAc,SAAA,EAAW;AAC3B,MAAA,MAAM,WAAA,GAAc,kBAAkB,UAAU,CAAA;AAEhD,MAAA,OAAO,IAAI,cAAA,CAAe;AAAA,QACxB,SAAA;AAAA,QACA,WAAA,EAAa;AAAA,OACd,CAAA;AAAA;AAEH,IAAA,OAAO,MAAA;AAAA,GACT,EAAG,CAAC,UAAA,EAAY,SAAS,CAAC,CAAA;AAE1B,EAAA,uBAAO,KAAA,CAAA,aAAA,CAAC,YAAA,CAAa,QAAA,EAAb,EAAsB,KAAA,EAAO,EAAE,KAAA,EAAO,OAAA,EAAS,WAAA,EAAY,EAAA,EAAI,QAAS,CAAA;AAClF","file":"index.mjs","sourcesContent":["import { createContext } from 'react';\nimport type { EvmHubProvider, Sodax } from '@sodax/sdk';\n\nexport interface SodaxContextType {\n sodax: Sodax;\n testnet: boolean;\n hubProvider: EvmHubProvider | undefined;\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 { 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 {\n EvmSpokeProvider,\n spokeChainConfig,\n type SuiSpokeChainConfig,\n SuiSpokeProvider,\n type EvmSpokeChainConfig,\n IconSpokeProvider,\n type IconSpokeChainConfig,\n CWSpokeProvider,\n type CosmosSpokeChainConfig,\n type SpokeProvider,\n type IWalletProvider,\n} from '@sodax/sdk';\nimport type {\n IEvmWalletProvider,\n IIconWalletProvider,\n ISuiWalletProvider,\n SpokeChainId,\n IInjectiveWalletProvider,\n} from '@sodax/types';\nimport { getXChainType, useWalletProvider } from '@sodax/wallet-sdk';\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 xChainType = getXChainType(spokeChainId);\n const walletProvider_ = useWalletProvider(spokeChainId);\n const _walletProvider = walletProvider ?? walletProvider_;\n\n const spokeProvider = useMemo(() => {\n if (!_walletProvider) return undefined;\n if (!spokeChainId) return undefined;\n\n if (xChainType === 'EVM') {\n return new EvmSpokeProvider(\n _walletProvider as IEvmWalletProvider,\n spokeChainConfig[spokeChainId] as EvmSpokeChainConfig,\n );\n }\n if (xChainType === 'SUI') {\n return new SuiSpokeProvider(\n spokeChainConfig[spokeChainId] as SuiSpokeChainConfig,\n _walletProvider as ISuiWalletProvider,\n );\n }\n if (xChainType === 'ICON') {\n return new IconSpokeProvider(\n _walletProvider as IIconWalletProvider,\n spokeChainConfig[spokeChainId] as IconSpokeChainConfig,\n );\n }\n if (xChainType === 'INJECTIVE') {\n return new CWSpokeProvider(\n spokeChainConfig[spokeChainId] as CosmosSpokeChainConfig,\n _walletProvider as IInjectiveWalletProvider,\n );\n }\n\n return undefined;\n }, [spokeChainId, xChainType, _walletProvider]);\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: [`0x${string}`, `0x${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.borrowAndSubmit(\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: [`0x${string}`, `0x${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.repayAndSubmit(\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: [`0x${string}`, `0x${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.supplyAndSubmit(\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: [`0x${string}`, `0x${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.withdrawAndSubmit(\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 { XToken, ChainId } from '@sodax/types';\n\nimport { hubAssets } from '@sodax/sdk';\n\nexport const allXTokens: XToken[] = [];\n\nObject.keys(hubAssets).forEach(xChainId => {\n const tokens = hubAssets[xChainId];\n\n Object.keys(tokens).forEach(tokenAddress => {\n const token = tokens[tokenAddress];\n allXTokens.push({\n xChainId: xChainId as ChainId,\n symbol: token.symbol,\n name: token.name,\n decimals: token.decimal,\n address: tokenAddress,\n });\n\n allXTokens.push({\n xChainId: 'sonic',\n symbol: token.symbol,\n name: token.name,\n decimals: token.decimal,\n address: token.vault,\n });\n });\n});\n\nexport const getSpokeTokenAddressByVault = (spokeChainId: ChainId, vault: string) => {\n const tokens = hubAssets[spokeChainId];\n const address = Object.keys(tokens).find(tokenAddress => tokens[tokenAddress].vault === vault);\n\n return address;\n};\n","import { allXTokens } from '@/core';\nimport { encodeAddress, EvmWalletAbstraction, getMoneyMarketConfig, type EvmHubProvider } from '@sodax/sdk';\nimport type { HubChainId, SpokeChainId } from '@sodax/types';\nimport type { ChainId } from '@sodax/types';\nimport { useQuery } from '@tanstack/react-query';\nimport { useHubProvider } from '../provider/useHubProvider';\nimport { useSodaxContext } from '../shared/useSodaxContext';\n\nexport function useUserReservesData(spokeChainId: ChainId, address: string | undefined) {\n const { sodax } = useSodaxContext();\n const hubChainId = (sodax.config?.hubProviderConfig?.chainConfig.chain.id ?? 'sonic') as HubChainId;\n const hubProvider = useHubProvider();\n\n const { data: userReserves } = useQuery({\n queryKey: ['userReserves', spokeChainId, address],\n queryFn: async () => {\n if (!hubProvider || !address) {\n return;\n }\n\n const addressBytes = encodeAddress(spokeChainId, address);\n const hubWalletAddress = await EvmWalletAbstraction.getUserHubWalletAddress(\n spokeChainId as SpokeChainId,\n addressBytes,\n hubProvider as EvmHubProvider,\n );\n\n const moneyMarketConfig = getMoneyMarketConfig(hubChainId);\n const [res] = await sodax.moneyMarket.getUserReservesData(\n hubWalletAddress as `0x${string}`,\n moneyMarketConfig.uiPoolDataProvider,\n moneyMarketConfig.poolAddressesProvider,\n );\n\n return res?.map(r => {\n return {\n ...r,\n token: allXTokens.find(t => t.address === r.underlyingAsset),\n };\n });\n },\n enabled: !!spokeChainId && !!hubProvider && !!address,\n refetchInterval: 5000,\n });\n\n return userReserves;\n}\n","import { type EvmHubProvider, EvmWalletAbstraction, type SpokeChainId } from '@sodax/sdk';\nimport { useQuery, type UseQueryResult } from '@tanstack/react-query';\n\n/**\n * Hook for retrieving the hub wallet address for a given spoke chain and address.\n *\n * This hook fetches the hub wallet address associated with a user's address on a specific spoke chain.\n * It uses the EvmWalletAbstraction to query the hub wallet address from the hub provider.\n *\n * @param spokeChainId - The chain ID of the spoke chain\n * @param address - The user's address on the spoke chain\n * @param hubProvider - The hub provider instance\n *\n * @returns {UseQueryResult<string | null>} A query result object containing:\n * - data: The hub wallet address or null if not found\n * - isLoading: Boolean indicating if the query is in progress\n * - error: Error object if the query failed, null otherwise\n *\n * @example\n * ```typescript\n * const { data: hubWalletAddress, isLoading, error } = useHubWalletAddress(spokeChainId, address, hubProvider);\n * ```\n */\n\nexport function useHubWalletAddress(\n spokeChainId: SpokeChainId,\n address: string | undefined,\n hubProvider: EvmHubProvider,\n): UseQueryResult<string | null> {\n return useQuery({\n queryKey: ['hubWallet', spokeChainId, address],\n queryFn: async () => {\n if (!address) return null;\n\n try {\n const hubWalletAddress = await EvmWalletAbstraction.getUserHubWalletAddress(\n spokeChainId,\n address as `0x${string}`,\n hubProvider,\n );\n return hubWalletAddress;\n } catch (error) {\n console.log('error', error);\n return null;\n }\n },\n enabled: !!address && !!hubProvider,\n });\n}\n","import { getMoneyMarketConfig } from '@sodax/sdk';\nimport type { HubChainId } from '@sodax/types';\nimport { 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 const hubChainId = (sodax.config?.hubProviderConfig?.chainConfig.chain.id ?? 'sonic') as HubChainId;\n\n return useQuery({\n queryKey: ['reservesData'],\n queryFn: async () => {\n const moneyMarketConfig = getMoneyMarketConfig(hubChainId);\n return await sodax.moneyMarket.getReservesData(\n moneyMarketConfig.uiPoolDataProvider,\n moneyMarketConfig.poolAddressesProvider,\n );\n },\n });\n}\n","import { useQuery } from '@tanstack/react-query';\nimport type { SpokeChainId, XToken } from '@sodax/types';\nimport { useSodaxContext } from '../shared/useSodaxContext';\nimport { useSpokeProvider } from '../provider/useSpokeProvider';\nimport { parseUnits } from 'viem';\nimport type { MoneyMarketAction } from '@sodax/sdk';\n\nexport function useAllowance(token: XToken, amount: string, action: MoneyMarketAction) {\n const { sodax } = useSodaxContext();\n const spokeProvider = useSpokeProvider(token.xChainId as SpokeChainId);\n\n return useQuery({\n queryKey: ['allowance', token.address, amount, action],\n queryFn: async () => {\n if (!spokeProvider) {\n return false;\n }\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 { useSpokeProvider } from '../provider/useSpokeProvider';\nimport type { SpokeChainId, XToken } from '@sodax/types';\nimport { parseUnits } from 'viem';\nimport { useMutation, useQueryClient } from '@tanstack/react-query';\nimport type { MoneyMarketAction } 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\nexport function useApprove(token: XToken): UseApproveReturn {\n const { sodax } = useSodaxContext();\n const spokeProvider = useSpokeProvider(token.xChainId as SpokeChainId);\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 { IntentErrorResponse, IntentQuoteRequest, IntentQuoteResponse, 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 {IntentQuoteRequest | undefined} payload - The intent quote request parameters. If undefined, the query will be disabled.\n *\n * @returns {UseQueryResult<Result<IntentQuoteResponse, IntentErrorResponse> | 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: IntentQuoteRequest | undefined,\n): UseQueryResult<Result<IntentQuoteResponse, IntentErrorResponse> | 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 IntentExecutionResponse,\n Result,\n IntentSubmitErrorCode,\n Intent,\n PacketData,\n IntentSubmitError,\n SpokeProvider,\n} from '@sodax/sdk';\nimport { useMutation, type UseMutationResult } from '@tanstack/react-query';\n\ntype CreateIntentResult = Result<\n [IntentExecutionResponse, Intent, PacketData],\n IntentSubmitError<IntentSubmitErrorCode>\n>;\n\n/**\n * Hook for creating and submitting an 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: createIntent, isPending } = useCreateIntentOrder(spokeProvider);\n *\n * const handleSwap = async () => {\n * const result = await createIntent({\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 useCreateIntentOrder(\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.createAndSubmitIntent(params, spokeProvider);\n },\n });\n}\n","import type { Hex, IntentErrorResponse, IntentStatusResponse, 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<IntentStatusResponse, IntentErrorResponse> | 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<IntentStatusResponse, IntentErrorResponse> | 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 type { ReactNode, ReactElement } from 'react';\nimport { EvmHubProvider, getHubChainConfig, Sodax, type SodaxConfig } from '@sodax/sdk';\nimport { SodaxContext } from '@/contexts';\nimport React, { useMemo } from 'react';\n\ninterface SodaxProviderProps {\n children: ReactNode;\n testnet?: boolean;\n config: SodaxConfig;\n}\n\nexport const SodaxProvider = ({ children, testnet = false, config }: 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 }}>{children}</SodaxContext.Provider>;\n};\n"]}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@sodax/dapp-kit",
3
3
  "license": "MIT",
4
- "version": "0.0.1-rc.6",
4
+ "version": "0.0.1-rc.7",
5
5
  "description": "dapp-kit of New World",
6
6
  "main": "dist/index.js",
7
7
  "types": "dist/index.d.ts",
@@ -16,9 +16,9 @@
16
16
  },
17
17
  "dependencies": {
18
18
  "viem": "^2.29.2",
19
- "@sodax/sdk": "0.0.1-rc.7",
20
- "@sodax/types": "0.0.1-rc.4",
21
- "@sodax/wallet-sdk": "0.0.1-rc.5"
19
+ "@sodax/sdk": "0.0.1-rc.10",
20
+ "@sodax/wallet-sdk": "0.0.1-rc.6",
21
+ "@sodax/types": "0.0.1-rc.5"
22
22
  },
23
23
  "devDependencies": {
24
24
  "@types/react": "^19.0.8",
@@ -5,3 +5,5 @@ export * from './useWithdraw';
5
5
  export * from './useUserReservesData';
6
6
  export * from './useHubWalletAddress';
7
7
  export * from './useReservesData';
8
+ export * from './useAllowance';
9
+ export * from './useApprove';
@@ -3,13 +3,14 @@ import type { SpokeChainId, XToken } from '@sodax/types';
3
3
  import { useSodaxContext } from '../shared/useSodaxContext';
4
4
  import { useSpokeProvider } from '../provider/useSpokeProvider';
5
5
  import { parseUnits } from 'viem';
6
+ import type { MoneyMarketAction } from '@sodax/sdk';
6
7
 
7
- export function useAllowance(token: XToken, amount: string) {
8
+ export function useAllowance(token: XToken, amount: string, action: MoneyMarketAction) {
8
9
  const { sodax } = useSodaxContext();
9
10
  const spokeProvider = useSpokeProvider(token.xChainId as SpokeChainId);
10
11
 
11
12
  return useQuery({
12
- queryKey: ['allowance', token.address, amount],
13
+ queryKey: ['allowance', token.address, amount, action],
13
14
  queryFn: async () => {
14
15
  if (!spokeProvider) {
15
16
  return false;
@@ -18,6 +19,7 @@ export function useAllowance(token: XToken, amount: string) {
18
19
  {
19
20
  token: token.address,
20
21
  amount: parseUnits(amount, token.decimals),
22
+ action,
21
23
  },
22
24
  spokeProvider,
23
25
  );
@@ -3,10 +3,10 @@ import { useSpokeProvider } from '../provider/useSpokeProvider';
3
3
  import type { SpokeChainId, XToken } from '@sodax/types';
4
4
  import { parseUnits } from 'viem';
5
5
  import { useMutation, useQueryClient } from '@tanstack/react-query';
6
- import type { Address } from '@sodax/sdk';
6
+ import type { MoneyMarketAction } from '@sodax/sdk';
7
7
 
8
8
  interface UseApproveReturn {
9
- approve: (amount: string) => Promise<boolean>;
9
+ approve: ({ amount, action }: { amount: string; action: MoneyMarketAction }) => Promise<boolean>;
10
10
  isLoading: boolean;
11
11
  error: Error | null;
12
12
  resetError: () => void;
@@ -23,14 +23,16 @@ export function useApprove(token: XToken): UseApproveReturn {
23
23
  error,
24
24
  reset: resetError,
25
25
  } = useMutation({
26
- mutationFn: async (amount: string) => {
26
+ mutationFn: async ({ amount, action }: { amount: string; action: MoneyMarketAction }) => {
27
27
  if (!spokeProvider) {
28
28
  throw new Error('Spoke provider not found');
29
29
  }
30
30
  const allowance = await sodax.moneyMarket.approve(
31
- token.address as Address,
32
- parseUnits(amount, token.decimals),
33
- spokeProvider.chainConfig.addresses.assetManager as Address,
31
+ {
32
+ token: token.address,
33
+ amount: parseUnits(amount, token.decimals),
34
+ action,
35
+ },
34
36
  spokeProvider,
35
37
  );
36
38
  if (!allowance.ok) {
@@ -47,7 +49,7 @@ export function useApprove(token: XToken): UseApproveReturn {
47
49
  return {
48
50
  approve,
49
51
  isLoading: isPending,
50
- error: error as Error | null,
52
+ error: error,
51
53
  resetError,
52
54
  };
53
55
  }
@@ -1,9 +1,8 @@
1
1
  import type { XToken } from '@sodax/types';
2
2
  import { useMutation, type UseMutationResult } from '@tanstack/react-query';
3
3
  import { parseUnits } from 'viem';
4
- import { useSpokeProvider } from '../provider/useSpokeProvider';
5
4
  import { useSodaxContext } from '../shared/useSodaxContext';
6
- import type { SpokeChainId } from '@sodax/sdk';
5
+ import type { SpokeProvider } from '@sodax/sdk';
7
6
  interface BorrowResponse {
8
7
  ok: true;
9
8
  value: [`0x${string}`, `0x${string}`];
@@ -16,6 +15,14 @@ interface BorrowResponse {
16
15
  * handling the entire borrow process including transaction creation, submission,
17
16
  * and cross-chain communication.
18
17
  *
18
+ * @param {XToken} spokeToken - The token to borrow from the spoke chain. Must be an XToken with valid address and chain information.
19
+ * @param {SpokeProvider} spokeProvider - The spoke provider to use for the borrow transaction. Must be a valid SpokeProvider instance.
20
+ *
21
+ * @returns {UseMutationResult<BorrowResponse, Error, string>} A mutation result object with the following properties:
22
+ * - mutateAsync: Function to execute the borrow transaction
23
+ * - isPending: Boolean indicating if a transaction is in progress
24
+ * - error: Error object if the last transaction failed, null otherwise
25
+ *
19
26
  * @example
20
27
  * ```typescript
21
28
  * const { mutateAsync: borrow, isPending, error } = useBorrow(spokeToken);
@@ -26,9 +33,11 @@ interface BorrowResponse {
26
33
  * - spokeProvider is not available
27
34
  * - Transaction execution fails
28
35
  */
29
- export function useBorrow(spokeToken: XToken): UseMutationResult<BorrowResponse, Error, string> {
36
+ export function useBorrow(
37
+ spokeToken: XToken,
38
+ spokeProvider: SpokeProvider | undefined,
39
+ ): UseMutationResult<BorrowResponse, Error, string> {
30
40
  const { sodax } = useSodaxContext();
31
- const spokeProvider = useSpokeProvider(spokeToken.xChainId as SpokeChainId);
32
41
 
33
42
  return useMutation<BorrowResponse, Error, string>({
34
43
  mutationFn: async (amount: string) => {
@@ -40,12 +49,12 @@ export function useBorrow(spokeToken: XToken): UseMutationResult<BorrowResponse,
40
49
  {
41
50
  token: spokeToken.address,
42
51
  amount: parseUnits(amount, 18),
52
+ action: 'borrow',
43
53
  },
44
54
  spokeProvider,
45
55
  );
46
56
 
47
57
  if (!response.ok) {
48
- console.log('Failed to borrow tokens', response);
49
58
  throw new Error('Failed to borrow tokens');
50
59
  }
51
60
 
@@ -1,8 +1,7 @@
1
- import type { SpokeChainId } from '@sodax/sdk';
1
+ import type { SpokeProvider } from '@sodax/sdk';
2
2
  import type { XToken } from '@sodax/types';
3
3
  import { useMutation, type UseMutationResult } from '@tanstack/react-query';
4
4
  import { parseUnits } from 'viem';
5
- import { useSpokeProvider } from '../provider/useSpokeProvider';
6
5
  import { useSodaxContext } from '../shared/useSodaxContext';
7
6
 
8
7
  interface RepayResponse {
@@ -17,6 +16,14 @@ interface RepayResponse {
17
16
  * handling the entire repayment process including transaction creation, submission,
18
17
  * and cross-chain communication.
19
18
  *
19
+ * @param {XToken} spokeToken - The token to repay on the spoke chain. Must be an XToken with valid address and chain information.
20
+ * @param {SpokeProvider} spokeProvider - The spoke provider to use for the repay transaction. Must be a valid SpokeProvider instance.
21
+ *
22
+ * @returns {UseMutationResult<RepayResponse, Error, string>} A mutation result object with the following properties:
23
+ * - mutateAsync: Function to execute the repay transaction
24
+ * - isPending: Boolean indicating if a transaction is in progress
25
+ * - error: Error object if the last transaction failed, null otherwise
26
+ *
20
27
  * @example
21
28
  * ```typescript
22
29
  * const { mutateAsync: repay, isPending, error } = useRepay(spokeToken);
@@ -27,9 +34,11 @@ interface RepayResponse {
27
34
  * - spokeProvider is not available
28
35
  * - Transaction execution fails
29
36
  */
30
- export function useRepay(spokeToken: XToken): UseMutationResult<RepayResponse, Error, string> {
37
+ export function useRepay(
38
+ spokeToken: XToken,
39
+ spokeProvider: SpokeProvider | undefined,
40
+ ): UseMutationResult<RepayResponse, Error, string> {
31
41
  const { sodax } = useSodaxContext();
32
- const spokeProvider = useSpokeProvider(spokeToken.xChainId as SpokeChainId);
33
42
 
34
43
  return useMutation<RepayResponse, Error, string>({
35
44
  mutationFn: async (amount: string) => {
@@ -41,6 +50,7 @@ export function useRepay(spokeToken: XToken): UseMutationResult<RepayResponse, E
41
50
  {
42
51
  token: spokeToken.address,
43
52
  amount: parseUnits(amount, spokeToken.decimals),
53
+ action: 'repay',
44
54
  },
45
55
  spokeProvider,
46
56
  );
@@ -1,8 +1,7 @@
1
- import type { SpokeChainId } from '@sodax/sdk';
1
+ import type { SpokeProvider } from '@sodax/sdk';
2
2
  import type { XToken } from '@sodax/types';
3
3
  import { useMutation, type UseMutationResult } from '@tanstack/react-query';
4
4
  import { parseUnits } from 'viem';
5
- import { useSpokeProvider } from '../provider/useSpokeProvider';
6
5
  import { useSodaxContext } from '../shared/useSodaxContext';
7
6
 
8
7
  interface SupplyResponse {
@@ -18,6 +17,7 @@ interface SupplyResponse {
18
17
  * and cross-chain communication.
19
18
  *
20
19
  * @param {XToken} spokeToken - The token to supply on the spoke chain. Must be an XToken with valid address and chain information.
20
+ * @param {SpokeProvider} spokeProvider - The spoke provider to use for the supply transaction. Must be a valid SpokeProvider instance.
21
21
  *
22
22
  * @returns {UseMutationResult<SupplyResponse, Error, string>} A mutation result object with the following properties:
23
23
  * - mutateAsync: Function to execute the supply transaction
@@ -33,9 +33,11 @@ interface SupplyResponse {
33
33
  * @throws {Error} When:
34
34
  * - spokeProvider is not available
35
35
  */
36
- export function useSupply(spokeToken: XToken): UseMutationResult<SupplyResponse, Error, string> {
36
+ export function useSupply(
37
+ spokeToken: XToken,
38
+ spokeProvider: SpokeProvider | undefined,
39
+ ): UseMutationResult<SupplyResponse, Error, string> {
37
40
  const { sodax } = useSodaxContext();
38
- const spokeProvider = useSpokeProvider(spokeToken.xChainId as SpokeChainId);
39
41
 
40
42
  return useMutation<SupplyResponse, Error, string>({
41
43
  mutationFn: async (amount: string) => {
@@ -47,6 +49,7 @@ export function useSupply(spokeToken: XToken): UseMutationResult<SupplyResponse,
47
49
  {
48
50
  token: spokeToken.address,
49
51
  amount: parseUnits(amount, spokeToken.decimals),
52
+ action: 'supply',
50
53
  },
51
54
  spokeProvider,
52
55
  );
@@ -1,30 +1,24 @@
1
1
  import { allXTokens } from '@/core';
2
- import { EvmWalletAbstraction, getMoneyMarketConfig, type EvmHubProvider } from '@sodax/sdk';
2
+ import { encodeAddress, EvmWalletAbstraction, getMoneyMarketConfig, type EvmHubProvider } from '@sodax/sdk';
3
3
  import type { HubChainId, SpokeChainId } from '@sodax/types';
4
4
  import type { ChainId } from '@sodax/types';
5
5
  import { useQuery } from '@tanstack/react-query';
6
6
  import { useHubProvider } from '../provider/useHubProvider';
7
7
  import { useSodaxContext } from '../shared/useSodaxContext';
8
- import { useSpokeProvider } from '../provider/useSpokeProvider';
9
8
 
10
- export function useUserReservesData(spokeChainId: ChainId) {
9
+ export function useUserReservesData(spokeChainId: ChainId, address: string | undefined) {
11
10
  const { sodax } = useSodaxContext();
12
11
  const hubChainId = (sodax.config?.hubProviderConfig?.chainConfig.chain.id ?? 'sonic') as HubChainId;
13
12
  const hubProvider = useHubProvider();
14
- const spokeProvider = useSpokeProvider(spokeChainId as SpokeChainId);
15
13
 
16
14
  const { data: userReserves } = useQuery({
17
- queryKey: ['userReserves', spokeChainId],
15
+ queryKey: ['userReserves', spokeChainId, address],
18
16
  queryFn: async () => {
19
- if (!hubProvider) {
17
+ if (!hubProvider || !address) {
20
18
  return;
21
19
  }
22
20
 
23
- if (!spokeProvider) {
24
- return;
25
- }
26
-
27
- const addressBytes = await spokeProvider.walletProvider.getWalletAddressBytes();
21
+ const addressBytes = encodeAddress(spokeChainId, address);
28
22
  const hubWalletAddress = await EvmWalletAbstraction.getUserHubWalletAddress(
29
23
  spokeChainId as SpokeChainId,
30
24
  addressBytes,
@@ -45,7 +39,7 @@ export function useUserReservesData(spokeChainId: ChainId) {
45
39
  };
46
40
  });
47
41
  },
48
- enabled: !!spokeProvider && !!hubProvider,
42
+ enabled: !!spokeChainId && !!hubProvider && !!address,
49
43
  refetchInterval: 5000,
50
44
  });
51
45
 
@@ -1,8 +1,7 @@
1
- import type { SpokeChainId } from '@sodax/sdk';
1
+ import type { SpokeProvider } from '@sodax/sdk';
2
2
  import type { XToken } from '@sodax/types';
3
3
  import { useMutation, type UseMutationResult } from '@tanstack/react-query';
4
4
  import { parseUnits } from 'viem';
5
- import { useSpokeProvider } from '../provider/useSpokeProvider';
6
5
  import { useSodaxContext } from '../shared/useSodaxContext';
7
6
 
8
7
  interface WithdrawResponse {
@@ -17,6 +16,12 @@ interface WithdrawResponse {
17
16
  * handling the entire withdrawal process including transaction creation, submission,
18
17
  * and cross-chain communication.
19
18
  *
19
+ * @param {XToken} spokeToken - The token to withdraw from the spoke chain. Must be an XToken with valid address and chain information.
20
+ * @param {SpokeProvider} spokeProvider - The spoke provider to use for the withdraw transaction. Must be a valid SpokeProvider instance.
21
+ *
22
+ * @returns {UseMutationResult<WithdrawResponse, Error, string>} A mutation result object with the following properties:
23
+ * - mutateAsync: Function to execute the withdraw transaction
24
+ * - isPending: Boolean indicating if a transaction is in progress
20
25
  * @example
21
26
  * ```typescript
22
27
  * const { mutateAsync: withdraw, isPending, error } = useWithdraw(spokeToken);
@@ -27,9 +32,11 @@ interface WithdrawResponse {
27
32
  * - spokeProvider is not available
28
33
  * - Transaction execution fails
29
34
  */
30
- export function useWithdraw(spokeToken: XToken): UseMutationResult<WithdrawResponse, Error, string> {
35
+ export function useWithdraw(
36
+ spokeToken: XToken,
37
+ spokeProvider: SpokeProvider | undefined,
38
+ ): UseMutationResult<WithdrawResponse, Error, string> {
31
39
  const { sodax } = useSodaxContext();
32
- const spokeProvider = useSpokeProvider(spokeToken.xChainId as SpokeChainId);
33
40
 
34
41
  return useMutation<WithdrawResponse, Error, string>({
35
42
  mutationFn: async (amount: string) => {
@@ -42,6 +49,7 @@ export function useWithdraw(spokeToken: XToken): UseMutationResult<WithdrawRespo
42
49
  token: spokeToken.address,
43
50
  // vault token on hub chain decimals is 18
44
51
  amount: parseUnits(amount, 18),
52
+ action: 'withdraw',
45
53
  },
46
54
  spokeProvider,
47
55
  );
@@ -8,6 +8,8 @@ import {
8
8
  type IconSpokeChainConfig,
9
9
  CWSpokeProvider,
10
10
  type CosmosSpokeChainConfig,
11
+ type SpokeProvider,
12
+ type IWalletProvider,
11
13
  } from '@sodax/sdk';
12
14
  import type {
13
15
  IEvmWalletProvider,
@@ -19,38 +21,59 @@ import type {
19
21
  import { getXChainType, useWalletProvider } from '@sodax/wallet-sdk';
20
22
  import { useMemo } from 'react';
21
23
 
22
- export function useSpokeProvider(spokeChainId: SpokeChainId) {
24
+ /**
25
+ * Hook to get the appropriate spoke provider based on the chain type.
26
+ * Supports EVM, SUI, ICON and INJECTIVE chains.
27
+ *
28
+ * @param {SpokeChainId | undefined} spokeChainId - The spoke chain ID to get the provider for
29
+ * @param {IWalletProvider | undefined} walletProvider - The wallet provider to use
30
+ * @returns {SpokeProvider | undefined} The appropriate spoke provider instance for the given chain ID, or undefined if invalid/unsupported
31
+ *
32
+ * @example
33
+ * ```tsx
34
+ * // Using a specific SpokeChainId and wallet provider
35
+ * const spokeProvider = useSpokeProvider(spokeChainId, walletProvider);
36
+ * ```
37
+ */
38
+ export function useSpokeProvider(
39
+ spokeChainId: SpokeChainId | undefined,
40
+ walletProvider?: IWalletProvider | undefined,
41
+ ): SpokeProvider | undefined {
23
42
  const xChainType = getXChainType(spokeChainId);
24
- const walletProvider = useWalletProvider(spokeChainId);
43
+ const walletProvider_ = useWalletProvider(spokeChainId);
44
+ const _walletProvider = walletProvider ?? walletProvider_;
45
+
25
46
  const spokeProvider = useMemo(() => {
26
- if (!walletProvider) return undefined;
47
+ if (!_walletProvider) return undefined;
48
+ if (!spokeChainId) return undefined;
49
+
27
50
  if (xChainType === 'EVM') {
28
51
  return new EvmSpokeProvider(
29
- walletProvider as IEvmWalletProvider,
52
+ _walletProvider as IEvmWalletProvider,
30
53
  spokeChainConfig[spokeChainId] as EvmSpokeChainConfig,
31
54
  );
32
55
  }
33
56
  if (xChainType === 'SUI') {
34
57
  return new SuiSpokeProvider(
35
58
  spokeChainConfig[spokeChainId] as SuiSpokeChainConfig,
36
- walletProvider as ISuiWalletProvider,
59
+ _walletProvider as ISuiWalletProvider,
37
60
  );
38
61
  }
39
62
  if (xChainType === 'ICON') {
40
63
  return new IconSpokeProvider(
41
- walletProvider as IIconWalletProvider,
64
+ _walletProvider as IIconWalletProvider,
42
65
  spokeChainConfig[spokeChainId] as IconSpokeChainConfig,
43
66
  );
44
67
  }
45
68
  if (xChainType === 'INJECTIVE') {
46
69
  return new CWSpokeProvider(
47
70
  spokeChainConfig[spokeChainId] as CosmosSpokeChainConfig,
48
- walletProvider as IInjectiveWalletProvider,
71
+ _walletProvider as IInjectiveWalletProvider,
49
72
  );
50
73
  }
51
74
 
52
75
  return undefined;
53
- }, [walletProvider, xChainType, spokeChainId]);
76
+ }, [spokeChainId, xChainType, _walletProvider]);
54
77
 
55
78
  return spokeProvider;
56
79
  }
@@ -1,3 +1 @@
1
1
  export * from './useSodaxContext';
2
- export * from './useAllowance';
3
- export * from './useApprove';
@@ -1,15 +1,14 @@
1
1
  import { useSodaxContext } from '../shared/useSodaxContext';
2
2
  import type {
3
3
  CreateIntentParams,
4
- SpokeChainId,
5
4
  IntentExecutionResponse,
6
5
  Result,
7
6
  IntentSubmitErrorCode,
8
7
  Intent,
9
8
  PacketData,
10
9
  IntentSubmitError,
10
+ SpokeProvider,
11
11
  } from '@sodax/sdk';
12
- import { useSpokeProvider } from '../provider/useSpokeProvider';
13
12
  import { useMutation, type UseMutationResult } from '@tanstack/react-query';
14
13
 
15
14
  type CreateIntentResult = Result<
@@ -21,12 +20,12 @@ type CreateIntentResult = Result<
21
20
  * Hook for creating and submitting an intent order for cross-chain swaps.
22
21
  * Uses React Query's useMutation for better state management and caching.
23
22
  *
24
- * @param {SpokeChainId} chainId - The source chain ID where the swap will originate
23
+ * @param {SpokeProvider} spokeProvider - The spoke provider to use for the swap
25
24
  * @returns {UseMutationResult} Mutation result object containing mutation function and state
26
25
  *
27
26
  * @example
28
27
  * ```typescript
29
- * const { mutateAsync: createIntent, isPending } = useCreateIntentOrder('0xa4b1.arbitrum');
28
+ * const { mutateAsync: createIntent, isPending } = useCreateIntentOrder(spokeProvider);
30
29
  *
31
30
  * const handleSwap = async () => {
32
31
  * const result = await createIntent({
@@ -41,10 +40,9 @@ type CreateIntentResult = Result<
41
40
  * ```
42
41
  */
43
42
  export function useCreateIntentOrder(
44
- chainId: SpokeChainId,
43
+ spokeProvider: SpokeProvider | undefined,
45
44
  ): UseMutationResult<CreateIntentResult, Error, CreateIntentParams> {
46
45
  const { sodax } = useSodaxContext();
47
- const spokeProvider = useSpokeProvider(chainId);
48
46
 
49
47
  return useMutation<CreateIntentResult, Error, CreateIntentParams>({
50
48
  mutationFn: async (params: CreateIntentParams) => {