{"version":3,"sources":["../src/hooks/shared/unwrapResult.ts","../src/hooks/shared/useSafeMutation.ts","../src/contexts/index.ts","../src/hooks/shared/useSodaxContext.ts","../src/hooks/shared/useEstimateGas.ts","../src/hooks/shared/useDeriveUserWalletAddress.ts","../src/hooks/shared/useStellarTrustlineCheck.ts","../src/hooks/shared/useRequestTrustline.ts","../src/hooks/shared/useGetUserHubWalletAddress.ts","../src/hooks/shared/useXBalances.ts","../src/hooks/provider/useHubProvider.ts","../src/hooks/bitcoin/useRadfiAuth.ts","../src/hooks/bitcoin/useRadfiSession.ts","../src/hooks/bitcoin/useFundTradingWallet.ts","../src/hooks/bitcoin/useBitcoinBalance.ts","../src/hooks/bitcoin/useTradingWallet.ts","../src/hooks/bitcoin/useTradingWalletBalance.ts","../src/hooks/bitcoin/useExpiredUtxos.ts","../src/hooks/bitcoin/useRenewUtxos.ts","../src/hooks/bitcoin/useRadfiWithdraw.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/useReservesHumanized.ts","../src/hooks/mm/useReservesList.ts","../src/hooks/mm/useMMAllowance.ts","../src/hooks/mm/useMMApprove.ts","../src/hooks/mm/useAToken.ts","../src/hooks/mm/useATokensBalances.ts","../src/hooks/mm/useReservesUsdFormat.ts","../src/hooks/mm/useUserFormattedSummary.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/swap/useCreateLimitOrder.ts","../src/hooks/swap/useCancelLimitOrder.ts","../src/hooks/backend/useBackendIntentByTxHash.ts","../src/hooks/backend/useBackendIntentByHash.ts","../src/hooks/backend/useBackendUserIntents.ts","../src/hooks/backend/useBackendSubmitSwapTx.ts","../src/hooks/backend/useBackendSubmitSwapTxStatus.ts","../src/hooks/backend/useBackendOrderbook.ts","../src/hooks/backend/useBackendMoneyMarketPosition.ts","../src/hooks/backend/useBackendAllMoneyMarketAssets.ts","../src/hooks/backend/useBackendMoneyMarketAsset.ts","../src/hooks/backend/useBackendMoneyMarketAssetBorrowers.ts","../src/hooks/backend/useBackendMoneyMarketAssetSuppliers.ts","../src/hooks/backend/useBackendAllMoneyMarketBorrowers.ts","../src/hooks/bridge/useBridge.ts","../src/hooks/bridge/useBridgeAllowance.ts","../src/hooks/bridge/useBridgeApprove.ts","../src/hooks/bridge/useGetBridgeableAmount.ts","../src/hooks/bridge/useGetBridgeableTokens.ts","../src/hooks/staking/useStake.ts","../src/hooks/staking/useStakeApprove.ts","../src/hooks/staking/useStakeAllowance.ts","../src/hooks/staking/useUnstake.ts","../src/hooks/staking/useClaim.ts","../src/hooks/staking/useCancelUnstake.ts","../src/hooks/staking/useStakingInfo.ts","../src/hooks/staking/useUnstakingInfoWithPenalty.ts","../src/hooks/staking/useStakingConfig.ts","../src/hooks/staking/useStakeRatio.ts","../src/hooks/staking/useInstantUnstakeRatio.ts","../src/hooks/staking/useConvertedAssets.ts","../src/hooks/staking/useInstantUnstake.ts","../src/hooks/staking/useUnstakeAllowance.ts","../src/hooks/staking/useUnstakeApprove.ts","../src/hooks/staking/useUnstakingInfo.ts","../src/hooks/staking/useInstantUnstakeApprove.ts","../src/hooks/staking/useInstantUnstakeAllowance.ts","../src/hooks/partner/useFetchAssetsBalances.ts","../src/hooks/partner/useGetAutoSwapPreferences.ts","../src/hooks/partner/useIsTokenApproved.ts","../src/hooks/partner/useApproveToken.ts","../src/hooks/partner/useSetSwapPreference.ts","../src/hooks/partner/useFeeClaimSwap.ts","../src/hooks/recovery/useHubAssetBalances.ts","../src/hooks/recovery/useWithdrawHubAsset.ts","../src/hooks/migrate/useMigrateIcxToSoda.ts","../src/hooks/migrate/useRevertMigrateSodaToIcx.ts","../src/hooks/migrate/useMigratebnUSD.ts","../src/hooks/migrate/useMigrateBaln.ts","../src/hooks/migrate/useMigrationApprove.ts","../src/hooks/migrate/useMigrationAllowance.ts","../src/hooks/dex/usePools.ts","../src/hooks/dex/usePoolData.ts","../src/hooks/dex/usePoolBalances.ts","../src/hooks/dex/usePositionInfo.ts","../src/hooks/dex/useDexDeposit.ts","../src/hooks/dex/useDexWithdraw.ts","../src/hooks/dex/useDexAllowance.ts","../src/hooks/dex/useDexApprove.ts","../src/hooks/dex/useLiquidityAmounts.ts","../src/hooks/dex/useSupplyLiquidity.ts","../src/hooks/dex/useDecreaseLiquidity.ts","../src/utils/dex-utils.ts","../src/hooks/dex/useCreateDepositParams.ts","../src/hooks/dex/useCreateSupplyLiquidityParams.ts","../src/hooks/dex/useCreateDecreaseLiquidityParams.ts","../src/hooks/dex/useCreateWithdrawParams.ts","../src/hooks/dex/useClaimRewards.ts","../src/providers/SodaxProvider.tsx","../src/providers/createSodaxQueryClient.ts"],"names":["useMutation","useCallback","createContext","useContext","useQuery","ChainKeys","useQueryClient","useState","token","error","RadfiApiError","useRef","useEffect","normalizePsbtToBase64","isAddress","REFETCH_INTERVAL_MS","erc20Abi","useMemo","ClService","parseUnits","Sodax","jsx","QueryClient","MutationCache"],"mappings":";;;;;;;;;AAUO,SAAS,aAAgB,MAAA,EAAsB;AACpD,EAAA,IAAI,CAAC,OAAO,EAAA,EAAI;AACd,IAAA,IAAI,MAAA,CAAO,KAAA,YAAiB,KAAA,EAAO,MAAM,MAAA,CAAO,KAAA;AAChD,IAAA,MAAM,IAAI,MAAA,CAAO,KAAA;AACjB,IAAA,MAAM,GAAA,GAAM,GAAG,MAAA,EAAQ,IAAA,IAAQ,GAAG,MAAA,EAAQ,OAAA,IAAW,GAAG,OAAA,IAAW,iBAAA;AACnE,IAAA,MAAM,IAAI,KAAA,CAAM,GAAA,EAAK,EAAE,KAAA,EAAO,MAAA,CAAO,OAAO,CAAA;AAAA,EAC9C;AACA,EAAA,OAAO,MAAA,CAAO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EAAS,CAAC,KAAA,EAAO,KAAA,EAAO,MAAM,QAAA,KAAa;AACzC,QAAA,IAAI,QAAA,CAAS,OAAA,CAAQ,IAAA,EAAM,MAAA,KAAW,IAAA,EAAM;AAC5C,QAAA,eAAA,CAAgB,KAAK,CAAA;AAAA,MACvB;AAAA,KACD;AAAA,GACF,CAAA;AACH","file":"index.cjs","sourcesContent":["import type { Result } from '@sodax/sdk';\n\n/**\n * Translates the SDK's `Result<T>` contract into the React Query contract: returns `value` on\n * success, throws `error` on failure. Non-`Error` throwables are wrapped so consumers always get\n * an `Error` in `mutation.error` / catch blocks.\n *\n * Used by every dapp-kit mutation hook so the React Query error model (`isError`, `error`,\n * `onError`, `retry`, `throwOnError`, devtools) engages uniformly.\n */\nexport function unwrapResult<T>(result: Result<T>): T {\n  if (!result.ok) {\n    if (result.error instanceof Error) throw result.error;\n    const e = result.error as { message?: string; detail?: { code?: string; message?: string } };\n    const msg = e?.detail?.code ?? e?.detail?.message ?? e?.message ?? 'SDK call failed';\n    throw new Error(msg, { cause: result.error });\n  }\n  return result.value;\n}\n","// packages/dapp-kit/src/hooks/shared/useSafeMutation.ts\nimport type { Result } from '@sodax/sdk';\nimport {\n  useMutation,\n  type MutateOptions,\n  type UseMutationOptions,\n  type UseMutationResult,\n} from '@tanstack/react-query';\nimport { useCallback } from 'react';\n\n/**\n * Return shape of every dapp-kit mutation hook. Extends `UseMutationResult` with one extra\n * method, `mutateAsyncSafe`, that never rejects — it returns the SDK's `Result<T>` shape so\n * callers can branch on `.ok` without `try/catch`.\n *\n * The underlying `mutationFn` still throws on SDK failure, so React Query's native error model\n * (`isError`, `error`, `onError`, `retry`, `throwOnError`, devtools) keeps working as documented.\n */\nexport type SafeUseMutationResult<TData, TError, TVars, TContext = unknown> = UseMutationResult<\n  TData,\n  TError,\n  TVars,\n  TContext\n> & {\n  /**\n   * Like `mutateAsync` but never rejects. Returns `Result<TData>` so callers can branch\n   * on `.ok` without `try/catch`.\n   *\n   * Use this for imperative flows where rejection-style errors are awkward — e.g. sequential\n   * `if (!hasAllowance) await approve(...); await action(...)` chains where the user-reject\n   * case is the modal failure mode, not an exceptional one.\n   */\n  mutateAsyncSafe: (\n    vars: TVars,\n    options?: MutateOptions<TData, TError, TVars, TContext>,\n  ) => Promise<Result<TData>>;\n};\n\n/**\n * Wraps a `Promise<T>` (typically `mutateAsync(vars)`) into a `Promise<Result<T>>` that never\n * rejects. Pure, side-effect-free — extracted for unit testing.\n */\nexport async function toResult<T>(promise: Promise<T>): Promise<Result<T>> {\n  try {\n    const value = await promise;\n    return { ok: true, value };\n  } catch (error) {\n    return { ok: false, error };\n  }\n}\n\n/**\n * Drop-in replacement for `useMutation` that augments the result with `mutateAsyncSafe`. Used\n * by every dapp-kit mutation hook so consumers can pick rejection-style (`mutateAsync`) or\n * Result-style (`mutateAsyncSafe`) ergonomics without the hook author having to think about it.\n */\nexport function useSafeMutation<TData, TError, TVars, TContext = unknown>(\n  options: UseMutationOptions<TData, TError, TVars, TContext>,\n): SafeUseMutationResult<TData, TError, TVars, TContext> {\n  const mutation = useMutation<TData, TError, TVars, TContext>(options);\n  const { mutateAsync } = mutation;\n  const mutateAsyncSafe = useCallback(\n    (vars: TVars, opts?: MutateOptions<TData, TError, TVars, TContext>): Promise<Result<TData>> =>\n      toResult(mutateAsync(vars, opts)),\n    [mutateAsync],\n  );\n  return { ...mutation, mutateAsyncSafe };\n}\n","import { createContext } from 'react';\nimport type { Sodax } from '@sodax/sdk';\n\nexport interface SodaxContextType {\n  sodax: Sodax;\n}\n\nexport const SodaxContext = createContext<SodaxContextType | null>(null);\n","import { SodaxContext, type SodaxContextType } from '@/contexts/index.js';\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","// packages/dapp-kit/src/hooks/shared/useEstimateGas.ts\nimport type { EstimateGasParams, GetEstimateGasReturnType, SpokeChainKey } from '@sodax/sdk';\nimport { useSodaxContext } from './useSodaxContext.js';\nimport type { MutationHookParams } from './types.js';\nimport { useSafeMutation, type SafeUseMutationResult } from './useSafeMutation.js';\nimport { unwrapResult } from './unwrapResult.js';\n\nexport function useEstimateGas<C extends SpokeChainKey>({\n  mutationOptions,\n}: MutationHookParams<GetEstimateGasReturnType<C>, EstimateGasParams<C>> = {}): SafeUseMutationResult<\n  GetEstimateGasReturnType<C>,\n  Error,\n  EstimateGasParams<C>\n> {\n  const { sodax } = useSodaxContext();\n  return useSafeMutation<GetEstimateGasReturnType<C>, Error, EstimateGasParams<C>>({\n    mutationKey: ['shared', 'estimateGas'],\n    ...mutationOptions,\n    mutationFn: async params => unwrapResult(await sodax.spoke.estimateGas<C>(params)),\n  });\n}\n","import type { SpokeChainKey } from '@sodax/sdk';\nimport { useQuery, type UseQueryResult } from '@tanstack/react-query';\nimport { useSodaxContext } from './useSodaxContext.js';\nimport type { Address } from 'viem';\nimport type { ReadHookParams } from './types.js';\n\nexport type UseDeriveUserWalletAddressParams = ReadHookParams<\n  Address,\n  {\n    spokeChainId?: SpokeChainKey;\n    spokeAddress?: string;\n  }\n>;\n\nexport function useDeriveUserWalletAddress({\n  params,\n  queryOptions,\n}: UseDeriveUserWalletAddressParams = {}): UseQueryResult<Address, Error> {\n  const { sodax } = useSodaxContext();\n  const spokeChainId = params?.spokeChainId;\n  const spokeAddress = params?.spokeAddress;\n\n  return useQuery<Address, Error>({\n    queryKey: ['shared', 'deriveUserWalletAddress', spokeChainId, spokeAddress],\n    queryFn: async (): Promise<Address> => {\n      if (!spokeChainId || !spokeAddress) {\n        throw new Error('Spoke chain id and address are required');\n      }\n      return await sodax.hubProvider.getUserHubWalletAddress(spokeAddress, spokeChainId);\n    },\n    enabled: !!spokeChainId && !!spokeAddress,\n    refetchInterval: false,\n    ...queryOptions,\n  });\n}\n","import { ChainKeys, type IStellarWalletProvider, type SpokeChainKey } from '@sodax/sdk';\nimport { useQuery, type UseQueryResult } from '@tanstack/react-query';\nimport { useSodaxContext } from './useSodaxContext.js';\nimport type { ReadHookParams } from './types.js';\n\nexport type UseStellarTrustlineCheckParams = ReadHookParams<\n  boolean,\n  {\n    token: string | undefined;\n    amount: bigint | undefined;\n    chainId: SpokeChainKey | undefined;\n    walletProvider: IStellarWalletProvider | undefined;\n  }\n>;\n\nexport function useStellarTrustlineCheck({\n  params,\n  queryOptions,\n}: UseStellarTrustlineCheckParams = {}): UseQueryResult<boolean, Error> {\n  const { sodax } = useSodaxContext();\n  const token = params?.token;\n  const amount = params?.amount;\n  const chainId = params?.chainId;\n  const walletProvider = params?.walletProvider;\n\n  return useQuery<boolean, Error>({\n    queryKey: ['shared', 'stellarTrustlineCheck', token],\n    queryFn: async () => {\n      if (chainId !== ChainKeys.STELLAR_MAINNET) return true;\n      if (!walletProvider || !token || !amount) return false;\n      const walletAddress = await walletProvider.getWalletAddress();\n      return sodax.spoke.stellar.hasSufficientTrustline(token, amount, walletAddress);\n    },\n    enabled: !!walletProvider && !!token && !!amount,\n    ...queryOptions,\n  });\n}\n","import { useQueryClient } from '@tanstack/react-query';\nimport { useCallback, useState } from 'react';\nimport type { IStellarWalletProvider, StellarChainKey } from '@sodax/sdk';\nimport { useSodaxContext } from './useSodaxContext.js';\n\nexport function useRequestTrustline(token: string | undefined): {\n  requestTrustline: (params: {\n    token: string;\n    amount: bigint;\n    srcChainKey: StellarChainKey;\n    walletProvider: IStellarWalletProvider;\n  }) => Promise<string>;\n  isLoading: boolean;\n  isRequested: boolean;\n  error: Error | null;\n  data: string | null;\n} {\n  const { sodax } = useSodaxContext();\n  const queryClient = useQueryClient();\n  const [isLoading, setIsLoading] = useState<boolean>(false);\n  const [isRequested, setIsRequested] = useState<boolean>(false);\n  const [error, setError] = useState<Error | null>(null);\n  const [data, setData] = useState<string | null>(null);\n\n  const requestTrustline = useCallback(\n    async ({\n      token,\n      amount,\n      srcChainKey,\n      walletProvider,\n    }: {\n      token: string;\n      amount: bigint;\n      srcChainKey: StellarChainKey;\n      walletProvider: IStellarWalletProvider;\n    }): Promise<string> => {\n      if (!token || !amount) {\n        const error = new Error('Token and amount are required');\n        setError(error);\n        throw error;\n      }\n      setIsLoading(true);\n      setError(null);\n      try {\n        const srcAddress = await walletProvider.getWalletAddress();\n        const result = await sodax.spoke.stellar.requestTrustline<false>({\n          raw: false,\n          srcChainKey,\n          srcAddress,\n          token,\n          amount,\n          walletProvider,\n        });\n        setData(result);\n        setIsRequested(true);\n        queryClient.invalidateQueries({ queryKey: ['shared', 'stellarTrustlineCheck', token] });\n        return result;\n      } catch (err) {\n        const error = err instanceof Error ? err : new Error('Unknown error occurred');\n        setError(error);\n        throw error;\n      } finally {\n        setIsLoading(false);\n      }\n    },\n    [queryClient, sodax],\n  );\n\n  return { requestTrustline, isLoading, isRequested, error, data };\n}\n","import type { SpokeChainKey } from '@sodax/sdk';\nimport { useQuery, type UseQueryResult } from '@tanstack/react-query';\nimport { useSodaxContext } from './useSodaxContext.js';\nimport type { Address } from 'viem';\nimport type { ReadHookParams } from './types.js';\n\nexport type UseGetUserHubWalletAddressParams = ReadHookParams<\n  Address,\n  {\n    spokeChainId?: SpokeChainKey;\n    spokeAddress?: string;\n  }\n>;\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 based on the spoke chain ID and address.\n * If the spoke chain is the same as the hub chain, it returns the encoded spoke address.\n * Otherwise, it derives and returns the abstracted wallet address for cross-chain operations.\n * NOTE: This hook is different from useDeriveUserWalletAddress because it uses wallet router address instead of CREATE3 address for Sonic (hub).\n *\n * The query is automatically enabled when both `spokeChainId` and `spokeAddress` are provided.\n * This is a deterministic operation, so the result is cached and not refetched automatically.\n *\n * @example\n * ```typescript\n * const { data: derivedAddress, isLoading, error } = useGetUserHubWalletAddress({\n *   params: { spokeChainId, spokeAddress: userAddress },\n * });\n * ```\n */\nexport function useGetUserHubWalletAddress({\n  params,\n  queryOptions,\n}: UseGetUserHubWalletAddressParams = {}): UseQueryResult<Address, Error> {\n  const { sodax } = useSodaxContext();\n  const spokeChainId = params?.spokeChainId;\n  const spokeAddress = params?.spokeAddress;\n\n  return useQuery<Address, Error>({\n    queryKey: ['shared', 'userHubWalletAddress', spokeChainId, spokeAddress],\n    queryFn: async (): Promise<Address> => {\n      if (!spokeChainId || !spokeAddress) {\n        throw new Error('Spoke chain id and address are required');\n      }\n      return await sodax.hubProvider.getUserHubWalletAddress(spokeAddress, spokeChainId);\n    },\n    enabled: !!spokeChainId && !!spokeAddress,\n    refetchInterval: false,\n    ...queryOptions,\n  });\n}\n","import { type UseQueryResult, useQuery } from '@tanstack/react-query';\nimport type { SpokeChainKey, IXServiceBase, XToken } from '@sodax/sdk';\nimport type { ReadHookParams } from './types.js';\n\n/**\n * Domain inputs for {@link useXBalances}. `xChainId` is optional so the hook can be mounted\n * before a chain is selected; `enabled` gates execution on every required field being present.\n */\nexport interface XBalancesInputs {\n  xService: IXServiceBase | undefined;\n  xChainId: SpokeChainKey | undefined;\n  xTokens: readonly XToken[];\n  address: string | undefined;\n}\n\nexport type UseXBalancesParams = ReadHookParams<Record<string, bigint>, XBalancesInputs>;\n\nconst REFETCH_INTERVAL_MS = 5_000;\n\n/**\n * Pure builder for {@link useXBalances} query options. Exported for unit\n * tests and for advanced callers that compose their own `useQuery` wrapper.\n */\nexport function getXBalancesQueryOptions({ xService, xChainId, xTokens, address }: XBalancesInputs) {\n  return {\n    // Pair symbol + address: readable in devtools, unique on-chain (symbol alone\n    // can collide — e.g. scam tokens copying legitimate ticker).\n    queryKey: ['shared', 'xBalances', xChainId, xTokens.map(x => [x.symbol, x.address] as const), address] as const,\n    queryFn: async (): Promise<Record<string, bigint>> => {\n      if (!xService) return {};\n      return xService.getBalances(address, xTokens);\n    },\n    enabled: !!xService && !!address && xTokens.length > 0,\n    refetchInterval: REFETCH_INTERVAL_MS,\n  };\n}\n\n/**\n * Fetch token balances for multiple tokens on a specific chain. Returns an\n * object mapping each token's address to its balance in smallest unit.\n *\n * @example\n * ```tsx\n * const xService = useXService({ xChainType: getXChainType(xChainId) });\n * const { data: balances } = useXBalances({ params: { xService, xChainId, xTokens, address } });\n * ```\n */\nexport function useXBalances({\n  params,\n  queryOptions,\n}: UseXBalancesParams = {}): UseQueryResult<Record<string, bigint>> {\n  return useQuery({\n    ...getXBalancesQueryOptions({\n      xService: params?.xService,\n      xChainId: params?.xChainId,\n      xTokens: params?.xTokens ?? [],\n      address: params?.address,\n    }),\n    ...queryOptions,\n  });\n}\n","import type { EvmHubProvider } from '@sodax/sdk';\nimport { useSodaxContext } from '../shared/useSodaxContext.js';\n\nexport function useHubProvider(): EvmHubProvider {\n  const { sodax } = useSodaxContext();\n\n  return sodax.hubProvider;\n}\n","// packages/dapp-kit/src/hooks/bitcoin/useRadfiAuth.ts\nimport { RadfiApiError, type IBitcoinWalletProvider } from '@sodax/sdk';\nimport { useSodaxContext } from '../shared/useSodaxContext.js';\nimport type { MutationHookParams } from '../shared/types.js';\nimport { useSafeMutation, type SafeUseMutationResult } from '../shared/useSafeMutation.js';\n\nexport type RadfiSession = {\n  accessToken: string;\n  refreshToken: string;\n  tradingAddress: string;\n  publicKey: string;\n};\n\nexport type UseRadfiAuthVars = {\n  walletProvider: IBitcoinWalletProvider;\n};\n\ntype RadfiAuthResult = {\n  accessToken: string;\n  refreshToken: string;\n  tradingAddress: string;\n};\n\nconst SESSION_KEY = (address: string): string => `radfi_session_${address}`;\n\nexport function saveRadfiSession(address: string, session: RadfiSession): void {\n  try {\n    localStorage.setItem(SESSION_KEY(address), JSON.stringify(session));\n  } catch {}\n}\n\nexport function loadRadfiSession(address: string): RadfiSession | null {\n  try {\n    const raw = localStorage.getItem(SESSION_KEY(address));\n    return raw ? (JSON.parse(raw) as RadfiSession) : null;\n  } catch {\n    return null;\n  }\n}\n\nexport function clearRadfiSession(address: string): void {\n  try {\n    localStorage.removeItem(SESSION_KEY(address));\n  } catch {}\n}\n\n/**\n * React hook for authenticating with Radfi via BIP322-signed message. Pure mutation: pass\n * `{ walletProvider }` to `mutate({...})`. The hook itself takes no arguments other than the\n * structural `mutationOptions` slot.\n */\nexport function useRadfiAuth({\n  mutationOptions,\n}: MutationHookParams<RadfiAuthResult, UseRadfiAuthVars> = {}): SafeUseMutationResult<\n  RadfiAuthResult,\n  Error,\n  UseRadfiAuthVars\n> {\n  const { sodax } = useSodaxContext();\n  return useSafeMutation<RadfiAuthResult, Error, UseRadfiAuthVars>({\n    mutationKey: ['bitcoin', 'radfiAuth'],\n    ...mutationOptions,\n    mutationFn: async ({ walletProvider }) => {\n      const radfi = sodax.spoke.bitcoin.radfi;\n      const walletAddress = await walletProvider.getWalletAddress();\n      const existingSession = loadRadfiSession(walletAddress);\n      const cachedPublicKey = existingSession?.publicKey;\n\n      try {\n        const { accessToken, refreshToken, tradingAddress, publicKey } = await radfi.authenticateWithWallet(\n          walletProvider,\n          cachedPublicKey,\n        );\n        saveRadfiSession(walletAddress, { accessToken, refreshToken, tradingAddress, publicKey });\n        return { accessToken, refreshToken, tradingAddress };\n      } catch (err: unknown) {\n        const isAlreadyRegistered = err instanceof RadfiApiError && err.code === '4008';\n\n        if (isAlreadyRegistered && existingSession?.refreshToken) {\n          try {\n            const refreshed = await radfi.refreshAccessToken(existingSession.refreshToken);\n            radfi.setRadfiAccessToken(refreshed.accessToken, refreshed.refreshToken);\n            saveRadfiSession(walletAddress, {\n              ...existingSession,\n              accessToken: refreshed.accessToken,\n              refreshToken: refreshed.refreshToken,\n            });\n            return {\n              accessToken: refreshed.accessToken,\n              refreshToken: refreshed.refreshToken,\n              tradingAddress: existingSession.tradingAddress,\n            };\n          } catch {\n            clearRadfiSession(walletAddress);\n          }\n\n          throw new Error(\n            'This wallet is already registered with Radfi from another session. ' +\n              'Please clear your browser storage for this site and try again, ' +\n              'or wait for the previous session to expire.',\n          );\n        }\n\n        throw err;\n      }\n    },\n  });\n}\n","// packages/dapp-kit/src/hooks/bitcoin/useRadfiSession.ts\nimport { useState, useEffect, useRef, useCallback } from 'react';\nimport type { IBitcoinWalletProvider } from '@sodax/sdk';\nimport {\n  useRadfiAuth,\n  loadRadfiSession,\n  saveRadfiSession,\n  clearRadfiSession,\n  type RadfiSession,\n} from './useRadfiAuth.js';\nimport { useSodaxContext } from '../shared/useSodaxContext.js';\n\nconst REFRESH_INTERVAL = 5 * 60 * 1000;\n\nexport type UseRadfiSessionReturn = {\n  walletAddress: string | undefined;\n  isAuthed: boolean;\n  tradingAddress: string | undefined;\n  login: () => Promise<void>;\n  isLoginPending: boolean;\n};\n\nexport function useRadfiSession(walletProvider: IBitcoinWalletProvider | undefined): UseRadfiSessionReturn {\n  const { sodax } = useSodaxContext();\n  const [walletAddress, setWalletAddress] = useState<string | undefined>();\n  const [isAuthed, setIsAuthed] = useState(false);\n  const [tradingAddress, setTradingAddress] = useState<string | undefined>();\n  const isRefreshingRef = useRef(false);\n\n  const silentRefresh = useCallback(\n    async (address: string) => {\n      if (!walletProvider || isRefreshingRef.current) return;\n      isRefreshingRef.current = true;\n\n      try {\n        const session = loadRadfiSession(address);\n        if (!session?.refreshToken) {\n          setIsAuthed(false);\n          return;\n        }\n\n        const radfi = sodax.spoke.bitcoin.radfi;\n        const { accessToken, refreshToken } = await radfi.refreshAccessToken(session.refreshToken);\n        const updated: RadfiSession = { ...session, accessToken, refreshToken };\n\n        saveRadfiSession(address, updated);\n        radfi.setRadfiAccessToken(accessToken, refreshToken);\n        setIsAuthed(true);\n        setTradingAddress(updated.tradingAddress || undefined);\n      } catch {\n        clearRadfiSession(address);\n        sodax.spoke.bitcoin.radfi.setRadfiAccessToken('', '');\n        setIsAuthed(false);\n        setTradingAddress(undefined);\n      } finally {\n        isRefreshingRef.current = false;\n      }\n    },\n    [walletProvider, sodax],\n  );\n\n  useEffect(() => {\n    if (!walletProvider) return;\n\n    setIsAuthed(false);\n    setTradingAddress(undefined);\n    setWalletAddress(undefined);\n\n    walletProvider\n      .getWalletAddress()\n      .then((addr: string) => {\n        setWalletAddress(addr);\n        const session = loadRadfiSession(addr);\n        if (!session?.refreshToken) return;\n        silentRefresh(addr);\n      })\n      .catch(() => {});\n  }, [walletProvider, silentRefresh]);\n\n  useEffect(() => {\n    if (!walletAddress || !walletProvider) return;\n\n    const id = setInterval(() => {\n      silentRefresh(walletAddress);\n    }, REFRESH_INTERVAL);\n\n    return () => clearInterval(id);\n  }, [walletAddress, walletProvider, silentRefresh]);\n\n  const { mutateAsyncSafe: loginMutateSafe, isPending: isLoginPending } = useRadfiAuth();\n\n  const login = useCallback(async () => {\n    if (!walletProvider) {\n      return;\n    }\n    const result = await loginMutateSafe({ walletProvider });\n    if (!result.ok) {\n      return;\n    }\n    setIsAuthed(true);\n    setTradingAddress(result.value.tradingAddress || undefined);\n  }, [loginMutateSafe, walletProvider]);\n\n  return { walletAddress, isAuthed, tradingAddress, login, isLoginPending };\n}\n","// packages/dapp-kit/src/hooks/bitcoin/useFundTradingWallet.ts\nimport { useQueryClient } from '@tanstack/react-query';\nimport { ChainKeys, type IBitcoinWalletProvider } from '@sodax/sdk';\nimport { useSodaxContext } from '../shared/useSodaxContext.js';\nimport type { MutationHookParams } from '../shared/types.js';\nimport { useSafeMutation, type SafeUseMutationResult } from '../shared/useSafeMutation.js';\n\nexport type UseFundTradingWalletVars = {\n  amount: bigint;\n  walletProvider: IBitcoinWalletProvider;\n};\n\n/**\n * React hook for funding the user's Radfi trading wallet from their personal Bitcoin wallet.\n * Pure mutation: pass `{ amount, walletProvider }` to `mutate({...})`. Returns the broadcast tx\n * id on success.\n */\nexport function useFundTradingWallet({\n  mutationOptions,\n}: MutationHookParams<string, UseFundTradingWalletVars> = {}): SafeUseMutationResult<\n  string,\n  Error,\n  UseFundTradingWalletVars\n> {\n  const { sodax } = useSodaxContext();\n  const queryClient = useQueryClient();\n\n  return useSafeMutation<string, Error, UseFundTradingWalletVars>({\n    mutationKey: ['bitcoin', 'fundTradingWallet'],\n    ...mutationOptions,\n    mutationFn: async ({ amount, walletProvider }) => {\n      const walletAddress = await walletProvider.getWalletAddress();\n      return sodax.spoke.bitcoin.fundTradingWallet(amount, walletAddress, walletProvider);\n    },\n    onSuccess: async (data, vars, ctx) => {\n      queryClient.invalidateQueries({ queryKey: ['bitcoin', 'balance'] });\n      queryClient.invalidateQueries({ queryKey: ['bitcoin', 'tradingWalletBalance'] });\n      queryClient.invalidateQueries({ queryKey: ['shared', 'xBalances', ChainKeys.BITCOIN_MAINNET] });\n      await mutationOptions?.onSuccess?.(data, vars, ctx);\n    },\n  });\n}\n","import { useQuery, type UseQueryResult } from '@tanstack/react-query';\nimport type { ReadHookParams } from '../shared/types.js';\n\nexport type UseBitcoinBalanceParams = ReadHookParams<\n  bigint,\n  {\n    address: string | undefined;\n    rpcUrl?: string;\n  }\n>;\n\nconst DEFAULT_RPC_URL = 'https://mempool.space/api';\n\n/**\n * Hook to fetch BTC balance for any Bitcoin address.\n * Sums all UTXOs (confirmed + unconfirmed) from mempool.space API.\n *\n * The UTXO set already excludes spent outputs (even from unconfirmed txs),\n * so the total is always the correct spendable balance.\n */\nexport function useBitcoinBalance({\n  params,\n  queryOptions,\n}: UseBitcoinBalanceParams = {}): UseQueryResult<bigint, Error> {\n  const address = params?.address;\n  const rpcUrl = params?.rpcUrl ?? DEFAULT_RPC_URL;\n\n  return useQuery<bigint, Error>({\n    queryKey: ['bitcoin', 'balance', address],\n    queryFn: async () => {\n      if (!address) return 0n;\n\n      const response = await fetch(`${rpcUrl}/address/${address}/utxo`);\n      if (!response.ok) return 0n;\n\n      const utxos: Array<{ value: number }> = await response.json();\n      return BigInt(utxos.reduce((sum, utxo) => sum + utxo.value, 0));\n    },\n    enabled: !!address,\n    ...queryOptions,\n  });\n}\n","import { loadRadfiSession } from './useRadfiAuth.js';\n\ntype UseTradingWalletReturn = {\n  tradingAddress: string | undefined;\n};\n\n/**\n * Returns the Radfi trading wallet address from the persisted session.\n * Trading wallet is created automatically during authentication — no API call needed.\n */\nexport function useTradingWallet(walletAddress: string | undefined): UseTradingWalletReturn {\n  if (!walletAddress) return { tradingAddress: undefined };\n  const session = loadRadfiSession(walletAddress);\n  return { tradingAddress: session?.tradingAddress || undefined };\n}\n","import { useQuery, type UseQueryResult } from '@tanstack/react-query';\nimport type { RadfiWalletBalance, IBitcoinWalletProvider } from '@sodax/sdk';\nimport { useSodaxContext } from '../shared/useSodaxContext.js';\nimport type { ReadHookParams } from '../shared/types.js';\n\nexport type UseTradingWalletBalanceParams = ReadHookParams<\n  RadfiWalletBalance,\n  {\n    walletProvider: IBitcoinWalletProvider | undefined;\n    tradingAddress: string | undefined;\n  }\n>;\n\nexport function useTradingWalletBalance({\n  params,\n  queryOptions,\n}: UseTradingWalletBalanceParams = {}): UseQueryResult<RadfiWalletBalance, Error> {\n  const { sodax } = useSodaxContext();\n  const walletProvider = params?.walletProvider;\n  const tradingAddress = params?.tradingAddress;\n\n  return useQuery<RadfiWalletBalance, Error>({\n    queryKey: ['bitcoin', 'tradingWalletBalance', tradingAddress],\n    queryFn: () => {\n      if (!walletProvider || !tradingAddress) {\n        throw new Error('walletProvider and tradingAddress are required');\n      }\n      return sodax.spoke.bitcoin.radfi.getBalance(tradingAddress);\n    },\n    enabled: !!walletProvider && !!tradingAddress,\n    ...queryOptions,\n  });\n}\n","import { useQuery, type UseQueryResult } from '@tanstack/react-query';\nimport type { RadfiUtxo, IBitcoinWalletProvider } from '@sodax/sdk';\nimport { useSodaxContext } from '../shared/useSodaxContext.js';\nimport type { ReadHookParams } from '../shared/types.js';\n\nexport type UseExpiredUtxosParams = ReadHookParams<\n  RadfiUtxo[],\n  {\n    walletProvider: IBitcoinWalletProvider | undefined;\n    tradingAddress: string | undefined;\n  }\n>;\n\nexport function useExpiredUtxos({\n  params,\n  queryOptions,\n}: UseExpiredUtxosParams = {}): UseQueryResult<RadfiUtxo[], Error> {\n  const { sodax } = useSodaxContext();\n  const walletProvider = params?.walletProvider;\n  const tradingAddress = params?.tradingAddress;\n\n  return useQuery<RadfiUtxo[], Error>({\n    queryKey: ['bitcoin', 'expiredUtxos', tradingAddress],\n    queryFn: async () => {\n      if (!walletProvider || !tradingAddress) {\n        throw new Error('walletProvider and tradingAddress are required');\n      }\n      const result = await sodax.spoke.bitcoin.radfi.getExpiredUtxos(tradingAddress);\n      return result.data;\n    },\n    enabled: !!walletProvider && !!tradingAddress,\n    refetchInterval: 60_000,\n    ...queryOptions,\n  });\n}\n","// packages/dapp-kit/src/hooks/bitcoin/useRenewUtxos.ts\nimport { normalizePsbtToBase64, type IBitcoinWalletProvider } from '@sodax/sdk';\nimport { useQueryClient } from '@tanstack/react-query';\nimport { loadRadfiSession } from './useRadfiAuth.js';\nimport { useSodaxContext } from '../shared/useSodaxContext.js';\nimport type { MutationHookParams } from '../shared/types.js';\nimport { useSafeMutation, type SafeUseMutationResult } from '../shared/useSafeMutation.js';\n\nexport type UseRenewUtxosVars = {\n  txIdVouts: string[];\n  walletProvider: IBitcoinWalletProvider;\n};\n\n/**\n * React hook for renewing expired UTXOs in the user's Radfi trading wallet. Pure mutation: pass\n * `{ txIdVouts, walletProvider }` to `mutate({...})`.\n */\nexport function useRenewUtxos({\n  mutationOptions,\n}: MutationHookParams<string, UseRenewUtxosVars> = {}): SafeUseMutationResult<string, Error, UseRenewUtxosVars> {\n  const { sodax } = useSodaxContext();\n  const queryClient = useQueryClient();\n\n  return useSafeMutation<string, Error, UseRenewUtxosVars>({\n    mutationKey: ['bitcoin', 'renewUtxos'],\n    ...mutationOptions,\n    mutationFn: async ({ txIdVouts, walletProvider }) => {\n      const radfi = sodax.spoke.bitcoin.radfi;\n\n      const userAddress = await walletProvider.getWalletAddress();\n      const session = loadRadfiSession(userAddress);\n      const accessToken = session?.accessToken || radfi.accessToken;\n\n      if (!accessToken) {\n        throw new Error('Radfi authentication required. Please login first.');\n      }\n\n      const buildResult = await radfi.buildRenewUtxoTransaction({ userAddress, txIdVouts }, accessToken);\n\n      const signedTx = await walletProvider.signTransaction(buildResult.base64Psbt, false);\n\n      const signedBase64Tx = normalizePsbtToBase64(signedTx);\n\n      return radfi.signAndBroadcastRenewUtxo({ userAddress, signedBase64Tx }, accessToken);\n    },\n    onSuccess: async (data, vars, ctx) => {\n      queryClient.invalidateQueries({ queryKey: ['bitcoin', 'expiredUtxos'] });\n      queryClient.invalidateQueries({ queryKey: ['bitcoin', 'tradingWalletBalance'] });\n      await mutationOptions?.onSuccess?.(data, vars, ctx);\n    },\n  });\n}\n","// packages/dapp-kit/src/hooks/bitcoin/useRadfiWithdraw.ts\nimport { normalizePsbtToBase64, ChainKeys, type IBitcoinWalletProvider } from '@sodax/sdk';\nimport { useQueryClient } from '@tanstack/react-query';\nimport { loadRadfiSession } from './useRadfiAuth.js';\nimport { useSodaxContext } from '../shared/useSodaxContext.js';\nimport type { MutationHookParams } from '../shared/types.js';\nimport { useSafeMutation, type SafeUseMutationResult } from '../shared/useSafeMutation.js';\n\nexport type UseRadfiWithdrawVars = {\n  amount: string;\n  tokenId: string;\n  withdrawTo: string;\n  walletProvider: IBitcoinWalletProvider;\n};\n\ntype WithdrawResult = {\n  txId: string;\n  fee: number;\n};\n\n/**\n * React hook for withdrawing BTC from the user's Radfi trading wallet back to their personal\n * Bitcoin wallet. Pure mutation: pass all inputs (including the wallet provider) to\n * `mutate({...})`.\n */\nexport function useRadfiWithdraw({\n  mutationOptions,\n}: MutationHookParams<WithdrawResult, UseRadfiWithdrawVars> = {}): SafeUseMutationResult<\n  WithdrawResult,\n  Error,\n  UseRadfiWithdrawVars\n> {\n  const { sodax } = useSodaxContext();\n  const queryClient = useQueryClient();\n\n  return useSafeMutation<WithdrawResult, Error, UseRadfiWithdrawVars>({\n    mutationKey: ['bitcoin', 'radfiWithdraw'],\n    ...mutationOptions,\n    mutationFn: async ({ amount, tokenId, withdrawTo, walletProvider }) => {\n      const radfi = sodax.spoke.bitcoin.radfi;\n\n      const userAddress = await walletProvider.getWalletAddress();\n      const session = loadRadfiSession(userAddress);\n      const accessToken = session?.accessToken || radfi.accessToken;\n\n      if (!accessToken) {\n        throw new Error('Radfi authentication required. Please login first.');\n      }\n\n      const buildResult = await radfi.withdrawToUser({ userAddress, amount, tokenId, withdrawTo }, accessToken);\n\n      const signedTx = await walletProvider.signTransaction(buildResult.base64Psbt, false);\n\n      const signedBase64Tx = normalizePsbtToBase64(signedTx);\n\n      const txId = await radfi.signAndBroadcastWithdraw({ userAddress, signedBase64Tx }, accessToken);\n\n      return { txId, fee: buildResult.fee.totalFee };\n    },\n    onSuccess: async (data, vars, ctx) => {\n      queryClient.invalidateQueries({ queryKey: ['bitcoin', 'tradingWalletBalance'] });\n      queryClient.invalidateQueries({ queryKey: ['bitcoin', 'balance'] });\n      queryClient.invalidateQueries({ queryKey: ['shared', 'xBalances', ChainKeys.BITCOIN_MAINNET] });\n      await mutationOptions?.onSuccess?.(data, vars, ctx);\n    },\n  });\n}\n","// packages/dapp-kit/src/hooks/mm/useBorrow.ts\nimport type { MoneyMarketBorrowActionParams, SpokeChainKey, TxHashPair } from '@sodax/sdk';\nimport { useQueryClient } from '@tanstack/react-query';\nimport { useSodaxContext } from '../shared/useSodaxContext.js';\nimport type { MutationHookParams } from '../shared/types.js';\nimport { useSafeMutation, type SafeUseMutationResult } from '../shared/useSafeMutation.js';\nimport { unwrapResult } from '../shared/unwrapResult.js';\n\n/**\n * Mutation variables for {@link useBorrow}. Generic over `K extends SpokeChainKey` (defaults to\n * the full union). Sophisticated callers can lock K at the hook call site to narrow the\n * `walletProvider` and `params.srcChainKey` types.\n */\nexport type UseBorrowVars<K extends SpokeChainKey = SpokeChainKey> = Omit<\n  MoneyMarketBorrowActionParams<K, false>,\n  'raw'\n>;\n\n/**\n * React hook for borrowing tokens from the Sodax money market protocol.\n *\n * Throws on SDK failure so React Query's native error model engages (`isError`, `error`,\n * `onError`, `retry`). Returns the unwrapped `TxHashPair` on success.\n */\nexport function useBorrow<K extends SpokeChainKey = SpokeChainKey>({\n  mutationOptions,\n}: MutationHookParams<TxHashPair, UseBorrowVars<K>> = {}): SafeUseMutationResult<TxHashPair, Error, UseBorrowVars<K>> {\n  const { sodax } = useSodaxContext();\n  const queryClient = useQueryClient();\n\n  return useSafeMutation<TxHashPair, Error, UseBorrowVars<K>>({\n    mutationKey: ['mm', 'borrow'],\n    ...mutationOptions,\n    mutationFn: async vars => unwrapResult(await sodax.moneyMarket.borrow({ ...vars, raw: false })),\n    onSuccess: async (data, vars, ctx) => {\n      const { params } = vars;\n      queryClient.invalidateQueries({ queryKey: ['mm', 'userReservesData', params.srcChainKey, params.srcAddress] });\n      queryClient.invalidateQueries({\n        queryKey: ['mm', 'userFormattedSummary', params.srcChainKey, params.srcAddress],\n      });\n      queryClient.invalidateQueries({ queryKey: ['mm', 'aTokensBalances'] });\n      const balanceChains = new Set([params.srcChainKey, params.dstChainKey ?? params.srcChainKey]);\n      for (const chainKey of balanceChains) {\n        queryClient.invalidateQueries({ queryKey: ['shared', 'xBalances', chainKey] });\n      }\n      await mutationOptions?.onSuccess?.(data, vars, ctx);\n    },\n  });\n}\n","// packages/dapp-kit/src/hooks/mm/useRepay.ts\nimport type { MoneyMarketRepayActionParams, SpokeChainKey, TxHashPair } from '@sodax/sdk';\nimport { useQueryClient } from '@tanstack/react-query';\nimport { useSodaxContext } from '../shared/useSodaxContext.js';\nimport type { MutationHookParams } from '../shared/types.js';\nimport { useSafeMutation, type SafeUseMutationResult } from '../shared/useSafeMutation.js';\nimport { unwrapResult } from '../shared/unwrapResult.js';\n\n/**\n * Mutation variables for {@link useRepay}. Generic over `K extends SpokeChainKey` (defaults to\n * the full union). Sophisticated callers can lock K at the hook call site to narrow the\n * `walletProvider` and `params.srcChainKey` types.\n */\nexport type UseRepayVars<K extends SpokeChainKey = SpokeChainKey> = Omit<MoneyMarketRepayActionParams<K, false>, 'raw'>;\n\n/**\n * React hook for repaying a borrow in the Sodax money market protocol.\n *\n * Throws on SDK failure so React Query's native error model engages (`isError`, `error`,\n * `onError`, `retry`). Returns the unwrapped `TxHashPair` on success.\n */\nexport function useRepay<K extends SpokeChainKey = SpokeChainKey>({\n  mutationOptions,\n}: MutationHookParams<TxHashPair, UseRepayVars<K>> = {}): SafeUseMutationResult<TxHashPair, Error, UseRepayVars<K>> {\n  const { sodax } = useSodaxContext();\n  const queryClient = useQueryClient();\n\n  return useSafeMutation<TxHashPair, Error, UseRepayVars<K>>({\n    mutationKey: ['mm', 'repay'],\n    ...mutationOptions,\n    mutationFn: async vars => unwrapResult(await sodax.moneyMarket.repay({ ...vars, raw: false })),\n    onSuccess: async (data, vars, ctx) => {\n      const { params } = vars;\n      queryClient.invalidateQueries({ queryKey: ['mm', 'userReservesData', params.srcChainKey, params.srcAddress] });\n      queryClient.invalidateQueries({\n        queryKey: ['mm', 'userFormattedSummary', params.srcChainKey, params.srcAddress],\n      });\n      queryClient.invalidateQueries({ queryKey: ['mm', 'aTokensBalances'] });\n      queryClient.invalidateQueries({ queryKey: ['mm', 'allowance', params.srcChainKey, params.token, params.action] });\n      queryClient.invalidateQueries({ queryKey: ['shared', 'xBalances', params.srcChainKey] });\n      await mutationOptions?.onSuccess?.(data, vars, ctx);\n    },\n  });\n}\n","// packages/dapp-kit/src/hooks/mm/useSupply.ts\nimport type { MoneyMarketSupplyActionParams, SpokeChainKey, TxHashPair } from '@sodax/sdk';\nimport { useQueryClient } from '@tanstack/react-query';\nimport { useSodaxContext } from '../shared/useSodaxContext.js';\nimport type { MutationHookParams } from '../shared/types.js';\nimport { useSafeMutation, type SafeUseMutationResult } from '../shared/useSafeMutation.js';\nimport { unwrapResult } from '../shared/unwrapResult.js';\n\n/**\n * Mutation variables for {@link useSupply}. Generic over `K extends SpokeChainKey` (defaults to\n * the full union). Sophisticated callers can lock K at the hook call site to narrow the\n * `walletProvider` and `params.srcChainKey` types.\n */\nexport type UseSupplyVars<K extends SpokeChainKey = SpokeChainKey> = Omit<\n  MoneyMarketSupplyActionParams<K, false>,\n  'raw'\n>;\n\n/**\n * React hook for supplying tokens to the Sodax money market protocol.\n *\n * Throws on SDK failure so React Query's native error model engages (`isError`, `error`,\n * `onError`, `retry`). Returns the unwrapped `TxHashPair` on success.\n *\n * @example\n * ```tsx\n * const walletProvider = useWalletProvider({ xChainId: chainKey });\n * const { mutateAsync: supply, isError, error } = useSupply();\n * if (!walletProvider) return;\n * try {\n *   const { spokeTxHash, hubTxHash } = await supply({ params: supplyParams, walletProvider });\n * } catch (e) {\n *   // surfaced via mutation.error / onError\n * }\n * ```\n */\nexport function useSupply<K extends SpokeChainKey = SpokeChainKey>({\n  mutationOptions,\n}: MutationHookParams<TxHashPair, UseSupplyVars<K>> = {}): SafeUseMutationResult<TxHashPair, Error, UseSupplyVars<K>> {\n  const { sodax } = useSodaxContext();\n  const queryClient = useQueryClient();\n\n  return useSafeMutation<TxHashPair, Error, UseSupplyVars<K>>({\n    mutationKey: ['mm', 'supply'],\n    ...mutationOptions,\n    mutationFn: async vars => unwrapResult(await sodax.moneyMarket.supply({ ...vars, raw: false })),\n    onSuccess: async (data, vars, ctx) => {\n      const { params } = vars;\n      queryClient.invalidateQueries({ queryKey: ['mm', 'userReservesData', params.srcChainKey, params.srcAddress] });\n      queryClient.invalidateQueries({\n        queryKey: ['mm', 'userFormattedSummary', params.srcChainKey, params.srcAddress],\n      });\n      queryClient.invalidateQueries({ queryKey: ['mm', 'aTokensBalances'] });\n      queryClient.invalidateQueries({ queryKey: ['mm', 'allowance', params.srcChainKey, params.token, params.action] });\n      queryClient.invalidateQueries({ queryKey: ['shared', 'xBalances', params.srcChainKey] });\n      await mutationOptions?.onSuccess?.(data, vars, ctx);\n    },\n  });\n}\n","// packages/dapp-kit/src/hooks/mm/useWithdraw.ts\nimport type { MoneyMarketWithdrawActionParams, SpokeChainKey, TxHashPair } from '@sodax/sdk';\nimport { useQueryClient } from '@tanstack/react-query';\nimport { useSodaxContext } from '../shared/useSodaxContext.js';\nimport type { MutationHookParams } from '../shared/types.js';\nimport { useSafeMutation, type SafeUseMutationResult } from '../shared/useSafeMutation.js';\nimport { unwrapResult } from '../shared/unwrapResult.js';\n\n/**\n * Mutation variables for {@link useWithdraw}. Generic over `K extends SpokeChainKey` (defaults to\n * the full union). Sophisticated callers can lock K at the hook call site to narrow the\n * `walletProvider` and `params.srcChainKey` types.\n */\nexport type UseWithdrawVars<K extends SpokeChainKey = SpokeChainKey> = Omit<\n  MoneyMarketWithdrawActionParams<K, false>,\n  'raw'\n>;\n\n/**\n * React hook for withdrawing supplied tokens from the Sodax money market protocol.\n *\n * Throws on SDK failure so React Query's native error model engages (`isError`, `error`,\n * `onError`, `retry`). Returns the unwrapped `TxHashPair` on success.\n */\nexport function useWithdraw<K extends SpokeChainKey = SpokeChainKey>({\n  mutationOptions,\n}: MutationHookParams<TxHashPair, UseWithdrawVars<K>> = {}): SafeUseMutationResult<TxHashPair, Error, UseWithdrawVars<K>> {\n  const { sodax } = useSodaxContext();\n  const queryClient = useQueryClient();\n\n  return useSafeMutation<TxHashPair, Error, UseWithdrawVars<K>>({\n    mutationKey: ['mm', 'withdraw'],\n    ...mutationOptions,\n    mutationFn: async vars => unwrapResult(await sodax.moneyMarket.withdraw({ ...vars, raw: false })),\n    onSuccess: async (data, vars, ctx) => {\n      const { params } = vars;\n      queryClient.invalidateQueries({ queryKey: ['mm', 'userReservesData', params.srcChainKey, params.srcAddress] });\n      queryClient.invalidateQueries({\n        queryKey: ['mm', 'userFormattedSummary', params.srcChainKey, params.srcAddress],\n      });\n      queryClient.invalidateQueries({ queryKey: ['mm', 'aTokensBalances'] });\n      const balanceChains = new Set([params.srcChainKey, params.dstChainKey ?? params.srcChainKey]);\n      for (const chainKey of balanceChains) {\n        queryClient.invalidateQueries({ queryKey: ['shared', 'xBalances', chainKey] });\n      }\n      await mutationOptions?.onSuccess?.(data, vars, ctx);\n    },\n  });\n}\n","import type { UserReserveData } from '@sodax/sdk';\nimport type { SpokeChainKey } from '@sodax/sdk';\nimport { useQuery, type UseQueryResult } from '@tanstack/react-query';\nimport { useSodaxContext } from '../shared/useSodaxContext.js';\nimport type { ReadHookParams } from '../shared/types.js';\n\nexport type UseUserReservesDataParams = ReadHookParams<\n  readonly [readonly UserReserveData[], number],\n  {\n    spokeChainKey: SpokeChainKey | undefined;\n    userAddress: string | undefined;\n  }\n>;\n\n/**\n * React hook for fetching the raw user reserves data (positions on the hub) for a given spoke\n * chain and user address.\n */\nexport function useUserReservesData({\n  params,\n  queryOptions,\n}: UseUserReservesDataParams = {}): UseQueryResult<readonly [readonly UserReserveData[], number], Error> {\n  const { sodax } = useSodaxContext();\n  const spokeChainKey = params?.spokeChainKey;\n  const userAddress = params?.userAddress;\n\n  return useQuery({\n    queryKey: ['mm', 'userReservesData', spokeChainKey, userAddress],\n    queryFn: async () => {\n      if (!spokeChainKey || !userAddress) {\n        throw new Error('spokeChainKey and userAddress are required');\n      }\n      return sodax.moneyMarket.data.getUserReservesData(spokeChainKey, userAddress);\n    },\n    enabled: !!spokeChainKey && !!userAddress,\n    refetchInterval: 5000,\n    ...queryOptions,\n  });\n}\n","import type { AggregatedReserveData, BaseCurrencyInfo } from '@sodax/sdk';\nimport { useQuery, type UseQueryResult } from '@tanstack/react-query';\nimport { useSodaxContext } from '../shared/useSodaxContext.js';\nimport type { ReadHookParams } from '../shared/types.js';\n\nexport type UseReservesDataParams = ReadHookParams<readonly [readonly AggregatedReserveData[], BaseCurrencyInfo]>;\n\n/**\n * React hook for fetching the latest aggregated reserves data and base-currency info from the\n * Sodax money market.\n */\nexport function useReservesData({\n  queryOptions,\n}: UseReservesDataParams = {}): UseQueryResult<readonly [readonly AggregatedReserveData[], BaseCurrencyInfo], Error> {\n  const { sodax } = useSodaxContext();\n\n  return useQuery({\n    queryKey: ['mm', 'reservesData'],\n    queryFn: async () => sodax.moneyMarket.data.getReservesData(),\n    refetchInterval: 5000,\n    ...queryOptions,\n  });\n}\n","import type { ReservesDataHumanized } from '@sodax/sdk';\nimport { useQuery, type UseQueryResult } from '@tanstack/react-query';\nimport { useSodaxContext } from '../shared/useSodaxContext.js';\nimport type { ReadHookParams } from '../shared/types.js';\n\nexport type UseReservesHumanizedParams = ReadHookParams<ReservesDataHumanized>;\n\n/**\n * React hook for fetching the human-readable (decimal-normalized, string-formatted) reserves\n * snapshot from the Sodax money market.\n */\nexport function useReservesHumanized({\n  queryOptions,\n}: UseReservesHumanizedParams = {}): UseQueryResult<ReservesDataHumanized, Error> {\n  const { sodax } = useSodaxContext();\n\n  return useQuery({\n    queryKey: ['mm', 'reservesHumanized'],\n    queryFn: async () => sodax.moneyMarket.data.getReservesHumanized(),\n    refetchInterval: 5000,\n    ...queryOptions,\n  });\n}\n","import type { Address } from '@sodax/sdk';\nimport { useQuery, type UseQueryResult } from '@tanstack/react-query';\nimport { useSodaxContext } from '../shared/useSodaxContext.js';\nimport type { ReadHookParams } from '../shared/types.js';\n\nexport type UseReservesListParams = ReadHookParams<readonly Address[]>;\n\n/**\n * React hook for fetching the list of reserve asset addresses currently registered in the\n * Sodax money market.\n */\nexport function useReservesList({\n  queryOptions,\n}: UseReservesListParams = {}): UseQueryResult<readonly Address[], Error> {\n  const { sodax } = useSodaxContext();\n\n  return useQuery<readonly Address[], Error>({\n    queryKey: ['mm', 'reservesList'],\n    queryFn: async () => sodax.moneyMarket.data.getReservesList(),\n    ...queryOptions,\n  });\n}\n","import type { MoneyMarketParams } from '@sodax/sdk';\nimport type { SpokeChainKey } from '@sodax/sdk';\nimport { useQuery, type UseQueryResult } from '@tanstack/react-query';\nimport { useSodaxContext } from '../shared/useSodaxContext.js';\nimport type { ReadHookParams } from '../shared/types.js';\n\nexport type UseMMAllowanceParams<K extends SpokeChainKey> = ReadHookParams<\n  boolean,\n  {\n    payload: MoneyMarketParams<K> | undefined;\n  }\n>;\n\n/**\n * Hook for checking token allowance / trustline sufficiency for money market operations.\n *\n * Skips the on-chain check entirely for `borrow` and `withdraw` actions — those don't require\n * approval, and the SDK already short-circuits to `true` for them. The early `enabled: false`\n * here additionally avoids a render flash with `isLoading: true`.\n *\n * The query key matches the invalidation keys emitted by `useMMApprove` and the four mutation\n * hooks: `['mm', 'allowance', srcChainKey, token, action]`.\n *\n * @example\n * ```tsx\n * const { data: hasAllowance } = useMMAllowance({ params: { payload: supplyParams } });\n * ```\n */\nexport function useMMAllowance<K extends SpokeChainKey>({\n  params,\n  queryOptions,\n}: UseMMAllowanceParams<K> = {}): UseQueryResult<boolean, Error> {\n  const { sodax } = useSodaxContext();\n  const payload = params?.payload;\n\n  return useQuery<boolean, Error>({\n    queryKey: ['mm', 'allowance', payload?.srcChainKey, payload?.token, payload?.action],\n    queryFn: async () => {\n      if (!payload) {\n        throw new Error('Params are required');\n      }\n\n      // Borrow and withdraw don't require approval; SDK returns true instantly anyway.\n      if (payload.action === 'borrow' || payload.action === 'withdraw') {\n        return true;\n      }\n\n      const result = await sodax.moneyMarket.isAllowanceValid({ params: payload });\n      if (!result.ok) throw result.error;\n      return result.value;\n    },\n    enabled: !!payload && payload.action !== 'borrow' && payload.action !== 'withdraw',\n    refetchInterval: 5000,\n    gcTime: 0,\n    ...queryOptions,\n  });\n}\n","// packages/dapp-kit/src/hooks/mm/useMMApprove.ts\nimport type { MoneyMarketApproveActionParams, SpokeChainKey, TxReturnType } from '@sodax/sdk';\nimport { useQueryClient } from '@tanstack/react-query';\nimport { useSodaxContext } from '../shared/useSodaxContext.js';\nimport type { MutationHookParams } from '../shared/types.js';\nimport { useSafeMutation, type SafeUseMutationResult } from '../shared/useSafeMutation.js';\nimport { unwrapResult } from '../shared/unwrapResult.js';\n\n/**\n * Mutation variables for {@link useMMApprove}. Generic over `K extends SpokeChainKey` (defaults\n * to the full union). Sophisticated callers can lock K at the hook call site to narrow the\n * `walletProvider` and `params.srcChainKey` types.\n */\nexport type UseMMApproveVars<K extends SpokeChainKey = SpokeChainKey> = Omit<\n  MoneyMarketApproveActionParams<K, false>,\n  'raw'\n>;\n\n/**\n * React hook for approving ERC-20 token spending (or trustline establishment) for a Sodax money\n * market action.\n *\n * Throws on SDK failure so React Query's native error model engages (`isError`, `error`,\n * `onError`, `retry`). Returns the unwrapped tx return value on success. Invalidates the matching\n * `['mm', 'allowance', srcChainKey, token, action]` query on confirmed success.\n */\nexport function useMMApprove<K extends SpokeChainKey = SpokeChainKey>({\n  mutationOptions,\n}: MutationHookParams<TxReturnType<K, false>, UseMMApproveVars<K>> = {}): SafeUseMutationResult<\n  TxReturnType<K, false>,\n  Error,\n  UseMMApproveVars<K>\n> {\n  const { sodax } = useSodaxContext();\n  const queryClient = useQueryClient();\n\n  return useSafeMutation<TxReturnType<K, false>, Error, UseMMApproveVars<K>>({\n    mutationKey: ['mm', 'approve'],\n    ...mutationOptions,\n    mutationFn: async vars => unwrapResult(await sodax.moneyMarket.approve({ ...vars, raw: false })),\n    onSuccess: async (data, vars, ctx) => {\n      const { params } = vars;\n      queryClient.invalidateQueries({\n        queryKey: ['mm', 'allowance', params.srcChainKey, params.token, params.action],\n      });\n      await mutationOptions?.onSuccess?.(data, vars, ctx);\n    },\n  });\n}\n","import type { Erc20Token } from '@sodax/sdk';\nimport type { ChainKey } from '@sodax/sdk';\nimport { useQuery, type UseQueryResult } from '@tanstack/react-query';\nimport { type Address, isAddress } from 'viem';\nimport { useSodaxContext } from '../shared/useSodaxContext.js';\nimport type { ReadHookParams } from '../shared/types.js';\n\nexport type ATokenData = Erc20Token & { chainKey: ChainKey };\n\nexport type UseATokenParams = ReadHookParams<\n  ATokenData,\n  {\n    aToken: Address | string | undefined;\n  }\n>;\n\n/**\n * React hook to fetch ERC-20 metadata for a given aToken address on the hub chain.\n * Returns `Erc20Token` (`name`, `symbol`, `decimals`, `address`) augmented with the hub\n * `chainKey`. Note: the returned shape is a subset of `XToken` — `hubAsset` and `vault` fields\n * must be resolved separately if needed.\n */\nexport function useAToken({ params, queryOptions }: UseATokenParams = {}): UseQueryResult<ATokenData, Error> {\n  const { sodax } = useSodaxContext();\n  const aToken = params?.aToken;\n\n  return useQuery({\n    queryKey: ['mm', 'aToken', aToken],\n    queryFn: async () => {\n      if (!aToken) {\n        throw new Error('aToken address is required');\n      }\n      if (!isAddress(aToken)) {\n        throw new Error('aToken address is not a valid address');\n      }\n\n      const aTokenData = await sodax.moneyMarket.data.getATokenData(aToken);\n      return {\n        ...aTokenData,\n        chainKey: sodax.hubProvider.chainConfig.chain.key,\n      };\n    },\n    enabled: !!aToken && isAddress(aToken ?? ''),\n    ...queryOptions,\n  });\n}\n","import type { SpokeChainKey } from '@sodax/sdk';\nimport { useQuery, type UseQueryResult } from '@tanstack/react-query';\nimport { type Address, isAddress } from 'viem';\nimport { useSodaxContext } from '../shared/useSodaxContext.js';\nimport type { ReadHookParams } from '../shared/types.js';\n\nexport type UseATokensBalancesParams = ReadHookParams<\n  Map<Address, bigint>,\n  {\n    aTokens: readonly Address[];\n    spokeChainKey: SpokeChainKey | undefined;\n    userAddress: string | undefined;\n  }\n>;\n\n/**\n * React hook to fetch aToken balances for a list of addresses in a single multicall.\n * Derives the user's hub wallet via `EvmHubProvider.getUserHubWalletAddress` from the\n * spoke `chainKey` + spoke wallet `userAddress`.\n */\nexport function useATokensBalances({\n  params,\n  queryOptions,\n}: UseATokensBalancesParams = {}): UseQueryResult<Map<Address, bigint>, Error> {\n  const { sodax } = useSodaxContext();\n  const aTokens = params?.aTokens ?? [];\n  const spokeChainKey = params?.spokeChainKey;\n  const userAddress = params?.userAddress;\n\n  return useQuery({\n    queryKey: ['mm', 'aTokensBalances', aTokens, spokeChainKey, userAddress],\n    queryFn: async () => {\n      if (aTokens.length === 0) {\n        return new Map<Address, bigint>();\n      }\n      if (!spokeChainKey || !userAddress) {\n        throw new Error('spokeChainKey and userAddress are required');\n      }\n      for (const aToken of aTokens) {\n        if (!isAddress(aToken)) {\n          throw new Error(`Invalid aToken address: ${aToken}`);\n        }\n      }\n\n      const hubWalletAddress = await sodax.hubProvider.getUserHubWalletAddress(userAddress, spokeChainKey);\n      return sodax.moneyMarket.data.getATokensBalances(aTokens, hubWalletAddress);\n    },\n    enabled: aTokens.length > 0 && !!spokeChainKey && !!userAddress,\n    ...queryOptions,\n  });\n}\n","import type { FormatReserveUSDResponse, ReserveDataHumanized } from '@sodax/sdk';\nimport { useQuery, type UseQueryResult } from '@tanstack/react-query';\nimport { useSodaxContext } from '../shared/useSodaxContext.js';\nimport type { ReadHookParams } from '../shared/types.js';\n\nexport type ReserveUsdFormat = ReserveDataHumanized & FormatReserveUSDResponse;\n\nexport type UseReservesUsdFormatParams = ReadHookParams<ReserveUsdFormat[]>;\n\n/**\n * React hook returning reserves with USD-formatted values for the Sodax money market.\n * Chains `getReservesHumanized` → `buildReserveDataWithPrice` → `formatReservesUSD`.\n */\nexport function useReservesUsdFormat({\n  queryOptions,\n}: UseReservesUsdFormatParams = {}): UseQueryResult<ReserveUsdFormat[], Error> {\n  const { sodax } = useSodaxContext();\n\n  return useQuery<ReserveUsdFormat[], Error>({\n    queryKey: ['mm', 'reservesUsdFormat'],\n    queryFn: async () => {\n      const reserves = await sodax.moneyMarket.data.getReservesHumanized();\n      return sodax.moneyMarket.data.formatReservesUSD(sodax.moneyMarket.data.buildReserveDataWithPrice(reserves));\n    },\n    ...queryOptions,\n  });\n}\n","import type { FormatReserveUSDResponse, FormatUserSummaryResponse } from '@sodax/sdk';\nimport type { SpokeChainKey } from '@sodax/sdk';\nimport { useQuery, type UseQueryResult } from '@tanstack/react-query';\nimport { useSodaxContext } from '../shared/useSodaxContext.js';\nimport type { ReadHookParams } from '../shared/types.js';\n\nexport type UseUserFormattedSummaryParams = ReadHookParams<\n  FormatUserSummaryResponse<FormatReserveUSDResponse>,\n  {\n    spokeChainKey: SpokeChainKey | undefined;\n    userAddress: string | undefined;\n  }\n>;\n\n/**\n * React hook returning the user's formatted money market portfolio summary (collateral, borrows,\n * health factor, available borrow power, etc.) for the given spoke chain.\n *\n * Internally chains `getReservesHumanized` → `formatReservesUSD` → `getUserReservesHumanized`\n * → `formatUserSummary`.\n */\nexport function useUserFormattedSummary({\n  params,\n  queryOptions,\n}: UseUserFormattedSummaryParams = {}): UseQueryResult<FormatUserSummaryResponse<FormatReserveUSDResponse>, Error> {\n  const { sodax } = useSodaxContext();\n  const spokeChainKey = params?.spokeChainKey;\n  const userAddress = params?.userAddress;\n\n  return useQuery({\n    queryKey: ['mm', 'userFormattedSummary', spokeChainKey, userAddress],\n    queryFn: async () => {\n      if (!spokeChainKey || !userAddress) {\n        throw new Error('spokeChainKey and userAddress are required');\n      }\n\n      const [reserves, userReserves] = await Promise.all([\n        sodax.moneyMarket.data.getReservesHumanized(),\n        sodax.moneyMarket.data.getUserReservesHumanized(spokeChainKey, userAddress),\n      ]);\n      const formattedReserves = sodax.moneyMarket.data.formatReservesUSD(\n        sodax.moneyMarket.data.buildReserveDataWithPrice(reserves),\n      );\n\n      return sodax.moneyMarket.data.formatUserSummary(\n        sodax.moneyMarket.data.buildUserSummaryRequest(reserves, formattedReserves, userReserves),\n      );\n    },\n    enabled: !!spokeChainKey && !!userAddress,\n    refetchInterval: 5000,\n    ...queryOptions,\n  });\n}\n","import type { SolverErrorResponse, SolverIntentQuoteRequest, SolverIntentQuoteResponse } from '@sodax/sdk';\nimport type { Result } from '@sodax/sdk';\nimport { useSodaxContext } from '../shared/useSodaxContext.js';\nimport { useQuery, type UseQueryResult } from '@tanstack/react-query';\nimport type { ReadHookParams } from '../shared/types.js';\n\nexport type UseQuoteParams = ReadHookParams<\n  Result<SolverIntentQuoteResponse, SolverErrorResponse> | undefined,\n  { payload: SolverIntentQuoteRequest | undefined }\n>;\n\n/**\n * Hook for fetching a quote for an intent-based swap.\n *\n * @example\n * ```typescript\n * const { data: quote, isLoading } = useQuote({ params: { payload } });\n * ```\n *\n * @remarks\n * - The quote is automatically refreshed every 3 seconds\n * - The query is disabled when payload is undefined\n */\nexport const useQuote = ({\n  params,\n  queryOptions,\n}: UseQuoteParams = {}): UseQueryResult<Result<SolverIntentQuoteResponse, SolverErrorResponse> | undefined> => {\n  const { sodax } = useSodaxContext();\n  const payload = params?.payload;\n\n  return useQuery({\n    queryKey: ['swap', 'quote', payload && { ...payload, amount: payload.amount.toString() }],\n    queryFn: async () => {\n      if (!payload) {\n        return undefined;\n      }\n      return sodax.swaps.getQuote(payload);\n    },\n    enabled: !!payload,\n    refetchInterval: 3000,\n    ...queryOptions,\n  });\n};\n","// packages/dapp-kit/src/hooks/swap/useSwap.ts\nimport { useSodaxContext } from '../shared/useSodaxContext.js';\nimport type { SpokeChainKey, SwapActionParams, SwapResponse } from '@sodax/sdk';\nimport { useQueryClient } from '@tanstack/react-query';\nimport type { MutationHookParams } from '../shared/types.js';\nimport { useSafeMutation, type SafeUseMutationResult } from '../shared/useSafeMutation.js';\nimport { unwrapResult } from '../shared/unwrapResult.js';\n\n/**\n * Mutation variables for {@link useSwap}. Generic over `K extends SpokeChainKey` (defaults to the\n * full union). Sophisticated callers can lock K at the hook call site to narrow the\n * `walletProvider` and `params.srcChainKey` types.\n */\nexport type UseSwapVars<K extends SpokeChainKey = SpokeChainKey> = Omit<SwapActionParams<K, false>, 'raw'>;\n\n/**\n * React hook for executing an intent-based cross-chain swap.\n *\n * Throws on SDK failure so React Query's native error model engages (`isError`, `error`,\n * `onError`, `retry`). Returns the unwrapped `SwapResponse` on success.\n */\nexport function useSwap<K extends SpokeChainKey = SpokeChainKey>({\n  mutationOptions,\n}: MutationHookParams<SwapResponse, UseSwapVars<K>> = {}): SafeUseMutationResult<\n  SwapResponse,\n  Error,\n  UseSwapVars<K>\n> {\n  const { sodax } = useSodaxContext();\n  const queryClient = useQueryClient();\n\n  return useSafeMutation<SwapResponse, Error, UseSwapVars<K>>({\n    mutationKey: ['swap'],\n    ...mutationOptions,\n    mutationFn: async vars => unwrapResult(await sodax.swaps.swap({ ...vars, raw: false })),\n    onSuccess: async (data, vars, ctx) => {\n      queryClient.invalidateQueries({ queryKey: ['shared', 'xBalances', vars.params.srcChainKey] });\n      queryClient.invalidateQueries({ queryKey: ['shared', 'xBalances', vars.params.dstChainKey] });\n      await mutationOptions?.onSuccess?.(data, vars, ctx);\n    },\n  });\n}\n","import type { Hex, SolverErrorResponse, SolverIntentStatusResponse } from '@sodax/sdk';\nimport type { Result } from '@sodax/sdk';\nimport { useQuery, type UseQueryResult } from '@tanstack/react-query';\nimport { useSodaxContext } from '../shared/useSodaxContext.js';\nimport type { ReadHookParams } from '../shared/types.js';\n\nexport type UseStatusParams = ReadHookParams<\n  Result<SolverIntentStatusResponse, SolverErrorResponse> | undefined,\n  { intentTxHash: Hex | undefined }\n>;\n\n/**\n * Hook for monitoring the status of an intent-based swap.\n *\n * @example\n * ```typescript\n * const { data: status, isLoading } = useStatus({ params: { intentTxHash } });\n * ```\n */\nexport const useStatus = ({\n  params,\n  queryOptions,\n}: UseStatusParams = {}): UseQueryResult<Result<SolverIntentStatusResponse, SolverErrorResponse> | undefined> => {\n  const { sodax } = useSodaxContext();\n  const intentTxHash = params?.intentTxHash;\n\n  return useQuery({\n    queryKey: ['swap', 'status', intentTxHash],\n    queryFn: async () => {\n      if (!intentTxHash) return undefined;\n      return sodax.swaps.getStatus({ intent_tx_hash: intentTxHash });\n    },\n    enabled: !!intentTxHash,\n    refetchInterval: 3000,\n    ...queryOptions,\n  });\n};\n","import { useQuery, type UseQueryResult } from '@tanstack/react-query';\nimport { useSodaxContext } from '../shared/useSodaxContext.js';\nimport type { CreateIntentParams, CreateLimitOrderParams } from '@sodax/sdk';\nimport type { GetWalletProviderType, SpokeChainKey } from '@sodax/sdk';\nimport type { ReadHookParams } from '../shared/types.js';\n\nexport type UseSwapAllowanceParams<K extends SpokeChainKey> = ReadHookParams<\n  boolean,\n  {\n    payload: CreateIntentParams | CreateLimitOrderParams | undefined;\n    srcChainKey: K | undefined;\n    walletProvider: GetWalletProviderType<K> | undefined;\n  }\n>;\n\nexport function useSwapAllowance<K extends SpokeChainKey>({\n  params,\n  queryOptions,\n}: UseSwapAllowanceParams<K> = {}): UseQueryResult<boolean, Error> {\n  const { sodax } = useSodaxContext();\n  const payload = params?.payload;\n  const srcChainKey = params?.srcChainKey;\n  const walletProvider = params?.walletProvider;\n\n  return useQuery<boolean, Error>({\n    // Extract the (chain, owner, token, amount) tuple that actually scopes the allowance —\n    // raw-object keys break per Rule 4 (bigints) and churn on every render.\n    queryKey: [\n      'swap',\n      'allowance',\n      payload?.srcChainKey,\n      payload?.srcAddress,\n      payload?.inputToken,\n      payload?.inputAmount?.toString(),\n    ],\n    queryFn: async () => {\n      if (!srcChainKey || !walletProvider || !payload) {\n        return false;\n      }\n      const allowance = await sodax.swaps.isAllowanceValid({\n        params: payload as CreateIntentParams,\n        raw: false,\n        walletProvider,\n      });\n      return allowance.ok ? allowance.value : false;\n    },\n    enabled: !!srcChainKey && !!walletProvider && !!payload,\n    refetchInterval: 2000,\n    ...queryOptions,\n  });\n}\n","// packages/dapp-kit/src/hooks/swap/useSwapApprove.ts\nimport { useSodaxContext } from '../shared/useSodaxContext.js';\nimport { useQueryClient } from '@tanstack/react-query';\nimport type {\n  CreateIntentParams,\n  CreateLimitOrderParams,\n  GetWalletProviderType,\n  SpokeChainKey,\n  TxReturnType,\n} from '@sodax/sdk';\nimport type { MutationHookParams } from '../shared/types.js';\nimport { useSafeMutation, type SafeUseMutationResult } from '../shared/useSafeMutation.js';\nimport { unwrapResult } from '../shared/unwrapResult.js';\n\n/**\n * Mutation variables for {@link useSwapApprove}. Generic over `K extends SpokeChainKey` (defaults\n * to the full union). Sophisticated callers can lock K at the call site to narrow the\n * `walletProvider` and `params.srcChainKey` types.\n */\nexport type UseSwapApproveVars<K extends SpokeChainKey = SpokeChainKey> = {\n  params: CreateIntentParams<K> | CreateLimitOrderParams<K>;\n  walletProvider: GetWalletProviderType<K>;\n};\n\n/**\n * React hook for approving ERC-20 token spending (or trustline establishment) for a swap or\n * limit-order intent.\n *\n * Throws on SDK failure so React Query's native error model engages (`isError`, `error`,\n * `onError`, `retry`). Returns the unwrapped tx return value on success. Invalidates all\n * `['swap', 'allowance', ...]` queries so any pending allowance check refreshes.\n */\nexport function useSwapApprove<K extends SpokeChainKey = SpokeChainKey>({\n  mutationOptions,\n}: MutationHookParams<TxReturnType<K, false>, UseSwapApproveVars<K>> = {}): SafeUseMutationResult<\n  TxReturnType<K, false>,\n  Error,\n  UseSwapApproveVars<K>\n> {\n  const { sodax } = useSodaxContext();\n  const queryClient = useQueryClient();\n\n  return useSafeMutation<TxReturnType<K, false>, Error, UseSwapApproveVars<K>>({\n    mutationKey: ['swap', 'approve'],\n    ...mutationOptions,\n    mutationFn: async ({ params, walletProvider }) =>\n      unwrapResult(\n        await sodax.swaps.approve<K, false>({\n          params: params as CreateIntentParams<K>,\n          raw: false,\n          walletProvider,\n        }),\n      ),\n    onSuccess: async (data, vars, ctx) => {\n      queryClient.invalidateQueries({ queryKey: ['swap', 'allowance'] });\n      await mutationOptions?.onSuccess?.(data, vars, ctx);\n    },\n  });\n}\n","// packages/dapp-kit/src/hooks/swap/useCancelSwap.ts\nimport { useSodaxContext } from '../shared/useSodaxContext.js';\nimport type { GetWalletProviderType, Intent, SpokeChainKey, TxHashPair } from '@sodax/sdk';\nimport type { MutationHookParams } from '../shared/types.js';\nimport { useSafeMutation, type SafeUseMutationResult } from '../shared/useSafeMutation.js';\nimport { unwrapResult } from '../shared/unwrapResult.js';\n\ntype CancelIntentParams<K extends SpokeChainKey = SpokeChainKey> = {\n  srcChainKey: K;\n  walletProvider: GetWalletProviderType<K>;\n  intent: Intent;\n};\n\n/**\n * React hook for cancelling an in-flight swap intent.\n *\n * Throws on SDK failure so React Query's native error model engages (`isError`, `error`,\n * `onError`, `retry`). Returns the unwrapped `TxHashPair` on success.\n */\nexport function useCancelSwap({\n  mutationOptions,\n}: MutationHookParams<TxHashPair, CancelIntentParams> = {}): SafeUseMutationResult<\n  TxHashPair,\n  Error,\n  CancelIntentParams\n> {\n  const { sodax } = useSodaxContext();\n\n  return useSafeMutation<TxHashPair, Error, CancelIntentParams>({\n    mutationKey: ['swap', 'cancel'],\n    ...mutationOptions,\n    mutationFn: async ({ srcChainKey, walletProvider, intent }) =>\n      unwrapResult(await sodax.swaps.cancelIntent({ params: { srcChainKey, intent }, walletProvider })),\n  });\n}\n","// packages/dapp-kit/src/hooks/swap/useCreateLimitOrder.ts\nimport { useSodaxContext } from '../shared/useSodaxContext.js';\nimport type { LimitOrderActionParams, SpokeChainKey, SwapResponse } from '@sodax/sdk';\nimport type { MutationHookParams } from '../shared/types.js';\nimport { useSafeMutation, type SafeUseMutationResult } from '../shared/useSafeMutation.js';\nimport { unwrapResult } from '../shared/unwrapResult.js';\n\n/**\n * Mutation variables for {@link useCreateLimitOrder}. Generic over `K extends SpokeChainKey`\n * (defaults to the full union). Sophisticated callers can lock K at the call site to narrow the\n * `walletProvider` and `params.srcChainKey` types.\n */\nexport type UseCreateLimitOrderVars<K extends SpokeChainKey = SpokeChainKey> = Omit<\n  LimitOrderActionParams<K, false>,\n  'raw'\n>;\n\n/**\n * React hook for creating a limit-order intent (no deadline).\n *\n * Throws on SDK failure so React Query's native error model engages (`isError`, `error`,\n * `onError`, `retry`). Returns the unwrapped `SwapResponse` on success.\n */\nexport function useCreateLimitOrder<K extends SpokeChainKey = SpokeChainKey>({\n  mutationOptions,\n}: MutationHookParams<SwapResponse, UseCreateLimitOrderVars<K>> = {}): SafeUseMutationResult<\n  SwapResponse,\n  Error,\n  UseCreateLimitOrderVars<K>\n> {\n  const { sodax } = useSodaxContext();\n\n  return useSafeMutation<SwapResponse, Error, UseCreateLimitOrderVars<K>>({\n    mutationKey: ['swap', 'limitOrder', 'create'],\n    ...mutationOptions,\n    mutationFn: async vars =>\n      unwrapResult(await sodax.swaps.createLimitOrder({ ...vars, raw: false })),\n  });\n}\n","// packages/dapp-kit/src/hooks/swap/useCancelLimitOrder.ts\nimport { useSodaxContext } from '../shared/useSodaxContext.js';\nimport type { GetWalletProviderType, Intent, SpokeChainKey, TxHashPair } from '@sodax/sdk';\nimport type { MutationHookParams } from '../shared/types.js';\nimport { useSafeMutation, type SafeUseMutationResult } from '../shared/useSafeMutation.js';\nimport { unwrapResult } from '../shared/unwrapResult.js';\n\ntype CancelLimitOrderParams<K extends SpokeChainKey = SpokeChainKey> = {\n  srcChainKey: K;\n  walletProvider: GetWalletProviderType<K>;\n  intent: Intent;\n  timeout?: number;\n};\n\n/**\n * React hook for cancelling a limit-order intent.\n *\n * Throws on SDK failure so React Query's native error model engages (`isError`, `error`,\n * `onError`, `retry`). Returns the unwrapped `TxHashPair` on success.\n */\nexport function useCancelLimitOrder({\n  mutationOptions,\n}: MutationHookParams<TxHashPair, CancelLimitOrderParams> = {}): SafeUseMutationResult<\n  TxHashPair,\n  Error,\n  CancelLimitOrderParams\n> {\n  const { sodax } = useSodaxContext();\n\n  return useSafeMutation<TxHashPair, Error, CancelLimitOrderParams>({\n    mutationKey: ['swap', 'limitOrder', 'cancel'],\n    ...mutationOptions,\n    mutationFn: async ({ srcChainKey, walletProvider, intent, timeout }) =>\n      unwrapResult(await sodax.swaps.cancelLimitOrder({ params: { srcChainKey, intent }, walletProvider, timeout })),\n  });\n}\n","import { useQuery, type UseQueryResult } from '@tanstack/react-query';\nimport type { IntentResponse } from '@sodax/sdk';\nimport { useSodaxContext } from '../shared/useSodaxContext.js';\nimport type { ReadHookParams } from '../shared/types.js';\n\nexport type UseBackendIntentByTxHashParams = ReadHookParams<\n  IntentResponse | undefined,\n  {\n    txHash: string | undefined;\n  }\n>;\n\n/**\n * React hook for fetching intent details from the backend API using a transaction hash.\n *\n * @example\n * const { data: intent } = useBackendIntentByTxHash({ params: { txHash: '0x123...' } });\n *\n * @remarks\n * - Intents are only created on the hub chain, so `txHash` must originate from there.\n * - Default refetch interval is 1 second.\n */\nexport const useBackendIntentByTxHash = ({\n  params,\n  queryOptions,\n}: UseBackendIntentByTxHashParams = {}): UseQueryResult<IntentResponse | undefined, Error> => {\n  const { sodax } = useSodaxContext();\n  const txHash = params?.txHash;\n\n  return useQuery({\n    queryKey: ['backend', 'intent', 'txHash', txHash],\n    queryFn: async (): Promise<IntentResponse | undefined> => {\n      if (!txHash) return undefined;\n      const result = await sodax.backendApi.getIntentByTxHash(txHash);\n      return result.ok ? result.value : undefined;\n    },\n    enabled: !!txHash && txHash.length > 0,\n    retry: 3,\n    refetchInterval: 1000,\n    ...queryOptions,\n  });\n};\n","import { useQuery, type UseQueryResult } from '@tanstack/react-query';\nimport type { IntentResponse } from '@sodax/sdk';\nimport { useSodaxContext } from '../shared/useSodaxContext.js';\nimport type { ReadHookParams } from '../shared/types.js';\n\nexport type UseBackendIntentByHashParams = ReadHookParams<\n  IntentResponse | undefined,\n  {\n    intentHash: string | undefined;\n  }\n>;\n\n/**\n * React hook to fetch intent details from the backend API using an intent hash.\n *\n * @example\n * const { data: intent } = useBackendIntentByHash({ params: { intentHash: '0xabc...' } });\n */\nexport const useBackendIntentByHash = ({\n  params,\n  queryOptions,\n}: UseBackendIntentByHashParams = {}): UseQueryResult<IntentResponse | undefined, Error> => {\n  const { sodax } = useSodaxContext();\n  const intentHash = params?.intentHash;\n\n  return useQuery({\n    queryKey: ['backend', 'intent', 'hash', intentHash],\n    queryFn: async (): Promise<IntentResponse | undefined> => {\n      if (!intentHash) return undefined;\n      const result = await sodax.backendApi.getIntentByHash(intentHash);\n      return result.ok ? result.value : undefined;\n    },\n    enabled: !!intentHash && intentHash.length > 0,\n    retry: 3,\n    ...queryOptions,\n  });\n};\n","import type { UserIntentsResponse, Address } from '@sodax/sdk';\nimport { useQuery, type UseQueryResult } from '@tanstack/react-query';\nimport { useSodaxContext } from '../shared/useSodaxContext.js';\nimport { unwrapResult } from './unwrapResult.js';\nimport type { ReadHookParams } from '../shared/types.js';\n\nexport type UseBackendUserIntentsParams = ReadHookParams<\n  UserIntentsResponse | undefined,\n  {\n    userAddress: Address | undefined;\n    startDate?: number;\n    endDate?: number;\n  }\n>;\n\n/**\n * React hook for fetching user-created intents from the backend API for a given user address.\n *\n * @example\n * const { data: userIntents } = useBackendUserIntents({\n *   params: { userAddress: '0x123...' },\n * });\n */\nexport const useBackendUserIntents = ({\n  params,\n  queryOptions,\n}: UseBackendUserIntentsParams = {}): UseQueryResult<UserIntentsResponse | undefined, Error> => {\n  const { sodax } = useSodaxContext();\n  const userAddress = params?.userAddress;\n  const startDate = params?.startDate;\n  const endDate = params?.endDate;\n\n  return useQuery({\n    queryKey: ['backend', 'intent', 'user', userAddress, startDate, endDate],\n    queryFn: async (): Promise<UserIntentsResponse | undefined> => {\n      if (!userAddress) return undefined;\n      return unwrapResult(await sodax.backendApi.getUserIntents({ userAddress, startDate, endDate }));\n    },\n    enabled: !!userAddress && userAddress.length > 0,\n    retry: 3,\n    ...queryOptions,\n  });\n};\n","// packages/dapp-kit/src/hooks/backend/useBackendSubmitSwapTx.ts\nimport type { RequestOverrideConfig, SubmitSwapTxRequest, SubmitSwapTxResponse } from '@sodax/sdk';\nimport { useSodaxContext } from '../shared/useSodaxContext.js';\nimport { unwrapResult } from './unwrapResult.js';\nimport type { MutationHookParams } from '../shared/types.js';\nimport { useSafeMutation, type SafeUseMutationResult } from '../shared/useSafeMutation.js';\n\n/**\n * Mutation variables for {@link useBackendSubmitSwapTx}. The per-request `apiConfig` override\n * (e.g. base URL) belongs here rather than at the hook level — different submissions in the same\n * component can target different endpoints without re-rendering.\n */\nexport type UseBackendSubmitSwapTxVars = {\n  request: SubmitSwapTxRequest;\n  apiConfig?: RequestOverrideConfig;\n};\n\n/**\n * React hook for submitting a swap transaction to be processed by the backend (relay, post\n * execution to solver, etc.).\n *\n * Pure mutation: pass `{ request, apiConfig? }` to `mutate({...})`. Default `retry: 3` is applied\n * at the hook level — consumers can override via `mutationOptions.retry`.\n *\n * @example\n * const { mutateAsync: submitSwapTx, isPending, error } = useBackendSubmitSwapTx();\n *\n * const result = await submitSwapTx({\n *   request: { txHash: '0x123...', srcChainKey: 'sonic', walletAddress: '0xabc...', intent: { ... }, relayData: '0x...' },\n *   apiConfig: { baseURL: 'https://...' },\n * });\n */\nexport const useBackendSubmitSwapTx = ({\n  mutationOptions,\n}: MutationHookParams<SubmitSwapTxResponse, UseBackendSubmitSwapTxVars> = {}): SafeUseMutationResult<\n  SubmitSwapTxResponse,\n  Error,\n  UseBackendSubmitSwapTxVars\n> => {\n  const { sodax } = useSodaxContext();\n\n  return useSafeMutation<SubmitSwapTxResponse, Error, UseBackendSubmitSwapTxVars>({\n    mutationKey: ['backend', 'submitSwapTx'],\n    retry: 3,\n    ...mutationOptions,\n    mutationFn: async ({ request, apiConfig }): Promise<SubmitSwapTxResponse> =>\n      unwrapResult(await sodax.backendApi.submitSwapTx(request, apiConfig)),\n  });\n};\n","import { useQuery, type UseQueryResult } from '@tanstack/react-query';\nimport type { RequestOverrideConfig, SubmitSwapTxStatusResponse } from '@sodax/sdk';\nimport { useSodaxContext } from '../shared/useSodaxContext.js';\nimport { unwrapResult } from './unwrapResult.js';\nimport type { ReadHookParams } from '../shared/types.js';\n\nexport type UseBackendSubmitSwapTxStatusParams = ReadHookParams<\n  SubmitSwapTxStatusResponse | undefined,\n  {\n    txHash: string | undefined;\n    srcChainKey?: string;\n    apiConfig?: RequestOverrideConfig;\n  }\n>;\n\n/**\n * React hook for polling the processing status of a submitted swap transaction.\n *\n * @example\n * const { data: status } = useBackendSubmitSwapTxStatus({\n *   params: { txHash: '0x123...', srcChainKey: 'sonic' },\n * });\n *\n * @remarks\n * - Default refetch interval is 1 second; stops on 'executed' or 'failed' status.\n */\nexport const useBackendSubmitSwapTxStatus = ({\n  params,\n  queryOptions,\n}: UseBackendSubmitSwapTxStatusParams = {}): UseQueryResult<SubmitSwapTxStatusResponse | undefined, Error> => {\n  const { sodax } = useSodaxContext();\n  const txHash = params?.txHash;\n  const srcChainKey = params?.srcChainKey;\n  const apiConfig = params?.apiConfig;\n\n  return useQuery({\n    queryKey: ['backend', 'submitSwapTx', 'status', txHash, srcChainKey],\n    queryFn: async (): Promise<SubmitSwapTxStatusResponse | undefined> => {\n      if (!txHash) return undefined;\n      return unwrapResult(\n        await sodax.backendApi.getSubmitSwapTxStatus(\n          {\n            txHash,\n            srcChainKey,\n          },\n          apiConfig,\n        ),\n      );\n    },\n    enabled: !!txHash && txHash.length > 0,\n    retry: 3,\n    refetchInterval: query => {\n      const status = query.state.data?.data?.status;\n      if (status === 'executed' || status === 'failed') return false;\n      return 1000;\n    },\n    ...queryOptions,\n  });\n};\n","import { useQuery, type UseQueryResult } from '@tanstack/react-query';\nimport type { OrderbookResponse } from '@sodax/sdk';\nimport { useSodaxContext } from '../shared/useSodaxContext.js';\nimport { unwrapResult } from './unwrapResult.js';\nimport type { BackendPaginationParams } from './types.js';\nimport type { ReadHookParams } from '../shared/types.js';\n\nexport type UseBackendOrderbookParams = ReadHookParams<\n  OrderbookResponse,\n  {\n    pagination: BackendPaginationParams;\n  }\n>;\n\n/**\n * Hook for fetching the solver orderbook from the backend API.\n *\n * @example\n * const { data } = useBackendOrderbook({ params: { pagination: { offset: '0', limit: '10' } } });\n */\nexport const useBackendOrderbook = ({\n  params,\n  queryOptions,\n}: UseBackendOrderbookParams = {}): UseQueryResult<OrderbookResponse> => {\n  const { sodax } = useSodaxContext();\n  const pagination = params?.pagination;\n\n  return useQuery<OrderbookResponse, Error>({\n    queryKey: ['backend', 'orderbook', pagination?.offset, pagination?.limit],\n    queryFn: async (): Promise<OrderbookResponse> => {\n      if (!pagination?.offset || !pagination?.limit) {\n        throw new Error('Pagination offset and limit are required');\n      }\n      return unwrapResult(await sodax.backendApi.getOrderbook(pagination));\n    },\n    enabled: !!pagination?.offset && !!pagination?.limit,\n    staleTime: 30 * 1000,\n    retry: 3,\n    ...queryOptions,\n  });\n};\n","import { useQuery, type UseQueryResult } from '@tanstack/react-query';\nimport type { MoneyMarketPosition } from '@sodax/sdk';\nimport { useSodaxContext } from '../shared/useSodaxContext.js';\nimport { unwrapResult } from './unwrapResult.js';\nimport type { ReadHookParams } from '../shared/types.js';\n\nexport type UseBackendMoneyMarketPositionParams = ReadHookParams<\n  MoneyMarketPosition | undefined,\n  {\n    userAddress: string | undefined;\n  }\n>;\n\n/**\n * React hook for fetching a user's money market position from the backend API.\n *\n * @example\n * const { data } = useBackendMoneyMarketPosition({ params: { userAddress: '0xabc...' } });\n */\nexport const useBackendMoneyMarketPosition = ({\n  params,\n  queryOptions,\n}: UseBackendMoneyMarketPositionParams = {}): UseQueryResult<MoneyMarketPosition | undefined, Error> => {\n  const { sodax } = useSodaxContext();\n  const userAddress = params?.userAddress;\n\n  return useQuery({\n    queryKey: ['backend', 'mm', 'position', userAddress],\n    queryFn: async (): Promise<MoneyMarketPosition | undefined> => {\n      if (!userAddress) return undefined;\n      return unwrapResult(await sodax.backendApi.getMoneyMarketPosition(userAddress));\n    },\n    enabled: !!userAddress && userAddress.length > 0,\n    retry: 3,\n    ...queryOptions,\n  });\n};\n","import { useQuery, type UseQueryResult } from '@tanstack/react-query';\nimport type { MoneyMarketAsset } from '@sodax/sdk';\nimport { useSodaxContext } from '../shared/useSodaxContext.js';\nimport { unwrapResult } from './unwrapResult.js';\nimport type { ReadHookParams } from '../shared/types.js';\n\nexport type UseBackendAllMoneyMarketAssetsParams = ReadHookParams<MoneyMarketAsset[]>;\n\n/**\n * React hook to fetch all money market assets from the backend API.\n *\n * @example\n * const { data: assets, isLoading, error } = useBackendAllMoneyMarketAssets();\n */\nexport const useBackendAllMoneyMarketAssets = ({\n  queryOptions,\n}: UseBackendAllMoneyMarketAssetsParams = {}): UseQueryResult<MoneyMarketAsset[], Error> => {\n  const { sodax } = useSodaxContext();\n\n  return useQuery<MoneyMarketAsset[], Error>({\n    queryKey: ['backend', 'mm', 'assets', 'all'],\n    queryFn: async (): Promise<MoneyMarketAsset[]> => {\n      return unwrapResult(await sodax.backendApi.getAllMoneyMarketAssets());\n    },\n    retry: 3,\n    ...queryOptions,\n  });\n};\n","import { useQuery, type UseQueryResult } from '@tanstack/react-query';\nimport type { MoneyMarketAsset } from '@sodax/sdk';\nimport { useSodaxContext } from '../shared/useSodaxContext.js';\nimport { unwrapResult } from './unwrapResult.js';\nimport type { ReadHookParams } from '../shared/types.js';\n\nexport type UseBackendMoneyMarketAssetParams = ReadHookParams<\n  MoneyMarketAsset | undefined,\n  {\n    reserveAddress: string | undefined;\n  }\n>;\n\n/**\n * React hook to fetch a specific money market asset from the backend API.\n *\n * @example\n * const { data: asset } = useBackendMoneyMarketAsset({ params: { reserveAddress: '0xabc...' } });\n */\nexport const useBackendMoneyMarketAsset = ({\n  params,\n  queryOptions,\n}: UseBackendMoneyMarketAssetParams = {}): UseQueryResult<MoneyMarketAsset | undefined, Error> => {\n  const { sodax } = useSodaxContext();\n  const reserveAddress = params?.reserveAddress;\n\n  return useQuery({\n    queryKey: ['backend', 'mm', 'asset', reserveAddress],\n    queryFn: async (): Promise<MoneyMarketAsset | undefined> => {\n      if (!reserveAddress) return undefined;\n      return unwrapResult(await sodax.backendApi.getMoneyMarketAsset(reserveAddress));\n    },\n    enabled: !!reserveAddress && reserveAddress.length > 0,\n    retry: 3,\n    ...queryOptions,\n  });\n};\n","import { useQuery, type UseQueryResult } from '@tanstack/react-query';\nimport type { MoneyMarketAssetBorrowers } from '@sodax/sdk';\nimport { useSodaxContext } from '../shared/useSodaxContext.js';\nimport { unwrapResult } from './unwrapResult.js';\nimport type { BackendPaginationParams } from './types.js';\nimport type { ReadHookParams } from '../shared/types.js';\n\nexport type UseBackendMoneyMarketAssetBorrowersParams = ReadHookParams<\n  MoneyMarketAssetBorrowers | undefined,\n  {\n    reserveAddress: string | undefined;\n    pagination: BackendPaginationParams;\n  }\n>;\n\n/**\n * React hook for fetching borrowers for a specific money market asset from the backend API with pagination.\n *\n * @example\n * const { data: borrowers } = useBackendMoneyMarketAssetBorrowers({\n *   params: { reserveAddress: '0xabc...', pagination: { offset: '0', limit: '20' } },\n * });\n */\nexport const useBackendMoneyMarketAssetBorrowers = ({\n  params,\n  queryOptions,\n}: UseBackendMoneyMarketAssetBorrowersParams = {}): UseQueryResult<MoneyMarketAssetBorrowers | undefined, Error> => {\n  const { sodax } = useSodaxContext();\n  const reserveAddress = params?.reserveAddress;\n  const pagination = params?.pagination;\n\n  return useQuery({\n    queryKey: ['backend', 'mm', 'asset', 'borrowers', reserveAddress, pagination],\n    queryFn: async (): Promise<MoneyMarketAssetBorrowers | undefined> => {\n      if (!reserveAddress || !pagination?.offset || !pagination?.limit) {\n        return undefined;\n      }\n      return unwrapResult(\n        await sodax.backendApi.getMoneyMarketAssetBorrowers(reserveAddress, {\n          offset: pagination.offset,\n          limit: pagination.limit,\n        }),\n      );\n    },\n    enabled: !!reserveAddress && !!pagination?.offset && !!pagination?.limit,\n    retry: 3,\n    ...queryOptions,\n  });\n};\n","import { useQuery, type UseQueryResult } from '@tanstack/react-query';\nimport type { MoneyMarketAssetSuppliers } from '@sodax/sdk';\nimport { useSodaxContext } from '../shared/useSodaxContext.js';\nimport { unwrapResult } from './unwrapResult.js';\nimport type { BackendPaginationParams } from './types.js';\nimport type { ReadHookParams } from '../shared/types.js';\n\nexport type UseBackendMoneyMarketAssetSuppliersParams = ReadHookParams<\n  MoneyMarketAssetSuppliers | undefined,\n  {\n    reserveAddress: string | undefined;\n    pagination: BackendPaginationParams;\n  }\n>;\n\n/**\n * React hook for fetching suppliers for a specific money market asset from the backend API.\n *\n * @example\n * const { data: suppliers } = useBackendMoneyMarketAssetSuppliers({\n *   params: { reserveAddress: '0xabc...', pagination: { offset: '0', limit: '20' } },\n * });\n */\nexport const useBackendMoneyMarketAssetSuppliers = ({\n  params,\n  queryOptions,\n}: UseBackendMoneyMarketAssetSuppliersParams = {}): UseQueryResult<MoneyMarketAssetSuppliers | undefined, Error> => {\n  const { sodax } = useSodaxContext();\n  const reserveAddress = params?.reserveAddress;\n  const pagination = params?.pagination;\n\n  return useQuery({\n    queryKey: ['backend', 'mm', 'asset', 'suppliers', reserveAddress, pagination],\n    queryFn: async (): Promise<MoneyMarketAssetSuppliers | undefined> => {\n      if (!reserveAddress || !pagination?.offset || !pagination?.limit) {\n        return undefined;\n      }\n      return unwrapResult(\n        await sodax.backendApi.getMoneyMarketAssetSuppliers(reserveAddress, {\n          offset: pagination.offset,\n          limit: pagination.limit,\n        }),\n      );\n    },\n    enabled: !!reserveAddress && !!pagination?.offset && !!pagination?.limit,\n    retry: 3,\n    ...queryOptions,\n  });\n};\n","import { useQuery, type UseQueryResult } from '@tanstack/react-query';\nimport type { MoneyMarketBorrowers } from '@sodax/sdk';\nimport { useSodaxContext } from '../shared/useSodaxContext.js';\nimport { unwrapResult } from './unwrapResult.js';\nimport type { BackendPaginationParams } from './types.js';\nimport type { ReadHookParams } from '../shared/types.js';\n\nexport type UseBackendAllMoneyMarketBorrowersParams = ReadHookParams<\n  MoneyMarketBorrowers | undefined,\n  {\n    pagination: BackendPaginationParams;\n  }\n>;\n\n/**\n * Hook for fetching all money market borrowers from the backend API.\n *\n * @example\n * ```typescript\n * const { data, isLoading, error } = useBackendAllMoneyMarketBorrowers({\n *   params: { pagination: { offset: '0', limit: '50' } },\n * });\n * ```\n */\nexport const useBackendAllMoneyMarketBorrowers = ({\n  params,\n  queryOptions,\n}: UseBackendAllMoneyMarketBorrowersParams = {}): UseQueryResult<MoneyMarketBorrowers | undefined> => {\n  const { sodax } = useSodaxContext();\n  const pagination = params?.pagination;\n\n  return useQuery({\n    queryKey: ['backend', 'mm', 'borrowers', 'all', pagination],\n    queryFn: async (): Promise<MoneyMarketBorrowers | undefined> => {\n      if (!pagination?.offset || !pagination?.limit) {\n        return undefined;\n      }\n      return unwrapResult(\n        await sodax.backendApi.getAllMoneyMarketBorrowers({\n          offset: pagination.offset,\n          limit: pagination.limit,\n        }),\n      );\n    },\n    enabled: !!pagination?.offset && !!pagination?.limit,\n    retry: 3,\n    ...queryOptions,\n  });\n};\n","// packages/dapp-kit/src/hooks/bridge/useBridge.ts\nimport { useSodaxContext } from '../shared/useSodaxContext.js';\nimport type { BridgeParams, SpokeChainKey, TxHashPair } from '@sodax/sdk';\nimport { useQueryClient } from '@tanstack/react-query';\nimport type { MutationHookParams } from '../shared/types.js';\nimport { useSafeMutation, type SafeUseMutationResult } from '../shared/useSafeMutation.js';\nimport { unwrapResult } from '../shared/unwrapResult.js';\n\n/**\n * Mutation variables for {@link useBridge}. Generic over `K extends SpokeChainKey` (defaults to\n * the full union). Sophisticated callers can lock K at the hook call site to narrow the\n * `walletProvider` and `params.srcChainKey` types.\n */\nexport type UseBridgeVars<K extends SpokeChainKey = SpokeChainKey> = Omit<BridgeParams<K, false>, 'raw'>;\n\n/**\n * React hook for executing a cross-chain bridge transfer.\n *\n * Throws on SDK failure so React Query's native error model engages (`isError`, `error`,\n * `onError`, `retry`). Returns the unwrapped `TxHashPair` on success.\n */\nexport function useBridge<K extends SpokeChainKey = SpokeChainKey>({\n  mutationOptions,\n}: MutationHookParams<TxHashPair, UseBridgeVars<K>> = {}): SafeUseMutationResult<TxHashPair, Error, UseBridgeVars<K>> {\n  const { sodax } = useSodaxContext();\n  const queryClient = useQueryClient();\n\n  return useSafeMutation<TxHashPair, Error, UseBridgeVars<K>>({\n    mutationKey: ['bridge'],\n    ...mutationOptions,\n    mutationFn: async vars => unwrapResult(await sodax.bridge.bridge({ ...vars, raw: false })),\n    onSuccess: async (data, vars, ctx) => {\n      queryClient.invalidateQueries({ queryKey: ['shared', 'xBalances', vars.params.srcChainKey] });\n      queryClient.invalidateQueries({ queryKey: ['shared', 'xBalances', vars.params.dstChainKey] });\n      await mutationOptions?.onSuccess?.(data, vars, ctx);\n    },\n  });\n}\n","import { useQuery, type UseQueryResult } from '@tanstack/react-query';\nimport { useSodaxContext } from '../shared/useSodaxContext.js';\nimport type { CreateBridgeIntentParams, GetWalletProviderType, SpokeChainKey } from '@sodax/sdk';\nimport type { ReadHookParams } from '../shared/types.js';\n\nexport type UseBridgeAllowanceParams<K extends SpokeChainKey> = ReadHookParams<\n  boolean,\n  {\n    payload: CreateBridgeIntentParams<K> | undefined;\n    walletProvider: GetWalletProviderType<K> | undefined;\n  }\n>;\n\nexport function useBridgeAllowance<K extends SpokeChainKey>({\n  params,\n  queryOptions,\n}: UseBridgeAllowanceParams<K> = {}): UseQueryResult<boolean, Error> {\n  const { sodax } = useSodaxContext();\n  const payload = params?.payload;\n  const walletProvider = params?.walletProvider;\n\n  return useQuery<boolean, Error>({\n    // Extract the (chain, owner, token, amount) tuple that actually scopes the allowance —\n    // raw-object keys break per Rule 4 (bigints) and churn on every render.\n    queryKey: [\n      'bridge',\n      'allowance',\n      payload?.srcChainKey,\n      payload?.srcAddress,\n      payload?.srcToken,\n      payload?.amount?.toString(),\n    ],\n    queryFn: async () => {\n      if (!payload || !walletProvider) {\n        return false;\n      }\n      const result = await sodax.bridge.isAllowanceValid({\n        params: payload,\n        raw: false,\n        walletProvider,\n      });\n      return result.ok ? result.value : false;\n    },\n    enabled: !!payload && !!walletProvider,\n    refetchInterval: 2000,\n    gcTime: 0,\n    ...queryOptions,\n  });\n}\n","// packages/dapp-kit/src/hooks/bridge/useBridgeApprove.ts\nimport type { BridgeParams, SpokeChainKey, TxReturnType } from '@sodax/sdk';\nimport { useQueryClient } from '@tanstack/react-query';\nimport { useSodaxContext } from '../shared/useSodaxContext.js';\nimport type { MutationHookParams } from '../shared/types.js';\nimport { useSafeMutation, type SafeUseMutationResult } from '../shared/useSafeMutation.js';\nimport { unwrapResult } from '../shared/unwrapResult.js';\n\n/**\n * Mutation variables for {@link useBridgeApprove}. Generic over `K extends SpokeChainKey`\n * (defaults to the full union). Sophisticated callers can lock K at the hook call site to narrow\n * the `walletProvider` and `params.srcChainKey` types.\n */\nexport type UseBridgeApproveVars<K extends SpokeChainKey = SpokeChainKey> = Omit<BridgeParams<K, false>, 'raw'>;\n\n/**\n * React hook for approving ERC-20 token spending (or trustline establishment) for a bridge\n * action.\n *\n * Throws on SDK failure so React Query's native error model engages (`isError`, `error`,\n * `onError`, `retry`). Returns the unwrapped tx return value on success. Invalidates all\n * `['bridge', 'allowance', ...]` queries so any pending allowance check refreshes.\n */\nexport function useBridgeApprove<K extends SpokeChainKey = SpokeChainKey>({\n  mutationOptions,\n}: MutationHookParams<TxReturnType<K, false>, UseBridgeApproveVars<K>> = {}): SafeUseMutationResult<\n  TxReturnType<K, false>,\n  Error,\n  UseBridgeApproveVars<K>\n> {\n  const { sodax } = useSodaxContext();\n  const queryClient = useQueryClient();\n\n  return useSafeMutation<TxReturnType<K, false>, Error, UseBridgeApproveVars<K>>({\n    mutationKey: ['bridge', 'approve'],\n    ...mutationOptions,\n    mutationFn: async vars => unwrapResult(await sodax.bridge.approve({ ...vars, raw: false } as BridgeParams<K, false>)),\n    onSuccess: async (data, vars, ctx) => {\n      queryClient.invalidateQueries({ queryKey: ['bridge', 'allowance'] });\n      await mutationOptions?.onSuccess?.(data, vars, ctx);\n    },\n  });\n}\n","import { useQuery, type UseQueryResult } from '@tanstack/react-query';\nimport { useSodaxContext } from '../shared/useSodaxContext.js';\nimport type { BridgeLimit, XToken } from '@sodax/sdk';\nimport type { ReadHookParams } from '../shared/types.js';\n\nexport type UseGetBridgeableAmountParams = ReadHookParams<\n  BridgeLimit,\n  {\n    from: XToken | undefined;\n    to: XToken | undefined;\n  }\n>;\n\nexport function useGetBridgeableAmount({\n  params,\n  queryOptions,\n}: UseGetBridgeableAmountParams = {}): UseQueryResult<BridgeLimit, Error> {\n  const { sodax } = useSodaxContext();\n  const from = params?.from;\n  const to = params?.to;\n\n  return useQuery<BridgeLimit, Error>({\n    queryKey: ['bridge', 'bridgeableAmount', from, to],\n    queryFn: async () => {\n      if (!from || !to) {\n        throw new Error('from and to tokens are required');\n      }\n      const result = await sodax.bridge.getBridgeableAmount(from, to);\n      if (!result.ok) {\n        throw result.error;\n      }\n      return result.value;\n    },\n    enabled: !!from && !!to,\n    ...queryOptions,\n  });\n}\n","import { useQuery, type UseQueryResult } from '@tanstack/react-query';\nimport type { XToken, SpokeChainKey } from '@sodax/sdk';\nimport { useSodaxContext } from '../shared/index.js';\nimport type { ReadHookParams } from '../shared/types.js';\n\nexport type UseGetBridgeableTokensParams = ReadHookParams<\n  XToken[],\n  {\n    from: SpokeChainKey | undefined;\n    to: SpokeChainKey | undefined;\n    token: string | undefined;\n  }\n>;\n\nexport function useGetBridgeableTokens({\n  params,\n  queryOptions,\n}: UseGetBridgeableTokensParams = {}): UseQueryResult<XToken[], Error> {\n  const { sodax } = useSodaxContext();\n  const from = params?.from;\n  const to = params?.to;\n  const token = params?.token;\n\n  return useQuery<XToken[], Error>({\n    queryKey: ['bridge', 'bridgeableTokens', from, to, token],\n    queryFn: () => {\n      if (!from || !to || !token) {\n        throw new Error('from, to and token are required');\n      }\n      const result = sodax.bridge.getBridgeableTokens(from, to, token);\n      if (!result.ok) {\n        throw result.error;\n      }\n      return result.value;\n    },\n    enabled: !!from && !!to && !!token,\n    ...queryOptions,\n  });\n}\n","// packages/dapp-kit/src/hooks/staking/useStake.ts\nimport type { SpokeChainKey, StakeAction, TxHashPair } from '@sodax/sdk';\nimport { useQueryClient } from '@tanstack/react-query';\nimport { useSodaxContext } from '../shared/useSodaxContext.js';\nimport type { MutationHookParams } from '../shared/types.js';\nimport { useSafeMutation, type SafeUseMutationResult } from '../shared/useSafeMutation.js';\nimport { unwrapResult } from '../shared/unwrapResult.js';\n\n/**\n * Mutation variables for {@link useStake}. Generic over `K extends SpokeChainKey` (defaults to\n * the full union). Sophisticated callers can lock K at the hook call site to narrow the\n * `walletProvider` and `params.srcChainKey` types.\n */\nexport type UseStakeVars<K extends SpokeChainKey = SpokeChainKey> = Omit<StakeAction<K, false>, 'raw'>;\n\n/**\n * React hook for staking SODA tokens.\n *\n * Throws on SDK failure so React Query's native error model engages (`isError`, `error`,\n * `onError`, `retry`). Returns the unwrapped `TxHashPair` on success.\n */\nexport function useStake<K extends SpokeChainKey = SpokeChainKey>({\n  mutationOptions,\n}: MutationHookParams<TxHashPair, UseStakeVars<K>> = {}): SafeUseMutationResult<TxHashPair, Error, UseStakeVars<K>> {\n  const { sodax } = useSodaxContext();\n  const queryClient = useQueryClient();\n\n  return useSafeMutation<TxHashPair, Error, UseStakeVars<K>>({\n    mutationKey: ['staking', 'stake'],\n    ...mutationOptions,\n    mutationFn: async vars => unwrapResult(await sodax.staking.stake({ ...vars, raw: false })),\n    onSuccess: async (data, vars, ctx) => {\n      const { params } = vars;\n      queryClient.invalidateQueries({ queryKey: ['staking', 'info', params.srcChainKey, params.srcAddress] });\n      queryClient.invalidateQueries({ queryKey: ['staking', 'allowance', params.srcChainKey, 'stake'] });\n      queryClient.invalidateQueries({ queryKey: ['staking', 'stakeRatio'] });\n      queryClient.invalidateQueries({ queryKey: ['staking', 'convertedAssets'] });\n      queryClient.invalidateQueries({ queryKey: ['shared', 'xBalances', params.srcChainKey] });\n      await mutationOptions?.onSuccess?.(data, vars, ctx);\n    },\n  });\n}\n","// packages/dapp-kit/src/hooks/staking/useStakeApprove.ts\nimport type { GetWalletProviderType, SpokeChainKey, StakeParams, TxReturnType } from '@sodax/sdk';\nimport { useQueryClient } from '@tanstack/react-query';\nimport { useSodaxContext } from '../shared/useSodaxContext.js';\nimport type { MutationHookParams } from '../shared/types.js';\nimport { useSafeMutation, type SafeUseMutationResult } from '../shared/useSafeMutation.js';\nimport { unwrapResult } from '../shared/unwrapResult.js';\n\n/**\n * Mutation variables for {@link useStakeApprove}. The `action` literal is injected by the hook —\n * callers pass the stake-specific fields only.\n */\nexport type UseStakeApproveVars<K extends SpokeChainKey = SpokeChainKey> = {\n  params: Omit<StakeParams<K>, 'action'>;\n  walletProvider: GetWalletProviderType<K>;\n};\n\n/**\n * React hook for approving SODA spending on the stake action.\n *\n * Throws on SDK failure so React Query's native error model engages (`isError`, `error`,\n * `onError`, `retry`). Returns the unwrapped tx return value on success.\n */\nexport function useStakeApprove<K extends SpokeChainKey = SpokeChainKey>({\n  mutationOptions,\n}: MutationHookParams<TxReturnType<K, false>, UseStakeApproveVars<K>> = {}): SafeUseMutationResult<\n  TxReturnType<K, false>,\n  Error,\n  UseStakeApproveVars<K>\n> {\n  const { sodax } = useSodaxContext();\n  const queryClient = useQueryClient();\n\n  return useSafeMutation<TxReturnType<K, false>, Error, UseStakeApproveVars<K>>({\n    mutationKey: ['staking', 'approve', 'stake'],\n    ...mutationOptions,\n    mutationFn: async ({ params, walletProvider }) =>\n      unwrapResult(\n        await sodax.staking.approve({\n          params: { ...params, action: 'stake' },\n          raw: false,\n          walletProvider,\n        }),\n      ),\n    onSuccess: async (data, vars, ctx) => {\n      queryClient.invalidateQueries({ queryKey: ['staking', 'allowance', vars.params.srcChainKey, 'stake'] });\n      await mutationOptions?.onSuccess?.(data, vars, ctx);\n    },\n  });\n}\n","import type { StakeParams } from '@sodax/sdk';\nimport type { SpokeChainKey } from '@sodax/sdk';\nimport { useQuery, type UseQueryResult } from '@tanstack/react-query';\nimport { useSodaxContext } from '../shared/useSodaxContext.js';\nimport type { ReadHookParams } from '../shared/types.js';\n\nexport type UseStakeAllowanceParams<K extends SpokeChainKey = SpokeChainKey> = ReadHookParams<\n  boolean,\n  {\n    payload: Omit<StakeParams<K>, 'action'> | undefined;\n  }\n>;\n\n/**\n * React hook to check whether the user has approved sufficient SODA spending for the stake\n * action. Read-only — calls `staking.isAllowanceValid` with `raw: true` so no `walletProvider`\n * is required.\n */\nexport function useStakeAllowance<K extends SpokeChainKey = SpokeChainKey>({\n  params,\n  queryOptions,\n}: UseStakeAllowanceParams<K> = {}): UseQueryResult<boolean, Error> {\n  const { sodax } = useSodaxContext();\n  const payload = params?.payload;\n\n  return useQuery<boolean, Error>({\n    queryKey: ['staking', 'allowance', payload?.srcChainKey, 'stake', payload?.srcAddress, payload?.amount?.toString()],\n    queryFn: async () => {\n      if (!payload) {\n        throw new Error('Params are required');\n      }\n      const result = await sodax.staking.isAllowanceValid({\n        params: { ...payload, action: 'stake' },\n        raw: true,\n      });\n      if (!result.ok) throw result.error;\n      return result.value;\n    },\n    enabled: !!payload,\n    refetchInterval: 5_000,\n    gcTime: 0,\n    ...queryOptions,\n  });\n}\n","// packages/dapp-kit/src/hooks/staking/useUnstake.ts\nimport type { SpokeChainKey, TxHashPair, UnstakeAction } from '@sodax/sdk';\nimport { useQueryClient } from '@tanstack/react-query';\nimport { useSodaxContext } from '../shared/useSodaxContext.js';\nimport type { MutationHookParams } from '../shared/types.js';\nimport { useSafeMutation, type SafeUseMutationResult } from '../shared/useSafeMutation.js';\nimport { unwrapResult } from '../shared/unwrapResult.js';\n\nexport type UseUnstakeVars<K extends SpokeChainKey = SpokeChainKey> = Omit<UnstakeAction<K, false>, 'raw'>;\n\n/**\n * React hook for initiating an SODA unstake.\n *\n * Throws on SDK failure so React Query's native error model engages (`isError`, `error`,\n * `onError`, `retry`). Returns the unwrapped `TxHashPair` on success.\n */\nexport function useUnstake<K extends SpokeChainKey = SpokeChainKey>({\n  mutationOptions,\n}: MutationHookParams<TxHashPair, UseUnstakeVars<K>> = {}): SafeUseMutationResult<TxHashPair, Error, UseUnstakeVars<K>> {\n  const { sodax } = useSodaxContext();\n  const queryClient = useQueryClient();\n\n  return useSafeMutation<TxHashPair, Error, UseUnstakeVars<K>>({\n    mutationKey: ['staking', 'unstake'],\n    ...mutationOptions,\n    mutationFn: async vars => unwrapResult(await sodax.staking.unstake({ ...vars, raw: false })),\n    onSuccess: async (data, vars, ctx) => {\n      const { params } = vars;\n      queryClient.invalidateQueries({ queryKey: ['staking', 'info', params.srcChainKey, params.srcAddress] });\n      // Scope to (srcChainKey, srcAddress) so a user's unstake doesn't refetch every other user's\n      // staking data. Matches `useUnstakingInfo` / `useUnstakingInfoWithPenalty` query keys.\n      queryClient.invalidateQueries({ queryKey: ['staking', 'unstakingInfo', params.srcChainKey, params.srcAddress] });\n      queryClient.invalidateQueries({\n        queryKey: ['staking', 'unstakingInfoWithPenalty', params.srcChainKey, params.srcAddress],\n      });\n      queryClient.invalidateQueries({ queryKey: ['staking', 'allowance', params.srcChainKey, 'unstake'] });\n      await mutationOptions?.onSuccess?.(data, vars, ctx);\n    },\n  });\n}\n","// packages/dapp-kit/src/hooks/staking/useClaim.ts\nimport type { ClaimAction, SpokeChainKey, TxHashPair } from '@sodax/sdk';\nimport { useQueryClient } from '@tanstack/react-query';\nimport { useSodaxContext } from '../shared/useSodaxContext.js';\nimport type { MutationHookParams } from '../shared/types.js';\nimport { useSafeMutation, type SafeUseMutationResult } from '../shared/useSafeMutation.js';\nimport { unwrapResult } from '../shared/unwrapResult.js';\n\nexport type UseClaimVars<K extends SpokeChainKey = SpokeChainKey> = Omit<ClaimAction<K, false>, 'raw'>;\n\n/**\n * React hook for claiming an unstaked SODA request that has reached the end of its waiting period.\n *\n * Throws on SDK failure so React Query's native error model engages (`isError`, `error`,\n * `onError`, `retry`). Returns the unwrapped `TxHashPair` on success.\n */\nexport function useClaim<K extends SpokeChainKey = SpokeChainKey>({\n  mutationOptions,\n}: MutationHookParams<TxHashPair, UseClaimVars<K>> = {}): SafeUseMutationResult<TxHashPair, Error, UseClaimVars<K>> {\n  const { sodax } = useSodaxContext();\n  const queryClient = useQueryClient();\n\n  return useSafeMutation<TxHashPair, Error, UseClaimVars<K>>({\n    mutationKey: ['staking', 'claim'],\n    ...mutationOptions,\n    mutationFn: async vars => unwrapResult(await sodax.staking.claim({ ...vars, raw: false })),\n    onSuccess: async (data, vars, ctx) => {\n      const { params } = vars;\n      queryClient.invalidateQueries({ queryKey: ['staking', 'unstakingInfo', params.srcChainKey, params.srcAddress] });\n      queryClient.invalidateQueries({\n        queryKey: ['staking', 'unstakingInfoWithPenalty', params.srcChainKey, params.srcAddress],\n      });\n      queryClient.invalidateQueries({ queryKey: ['shared', 'xBalances', params.srcChainKey] });\n      await mutationOptions?.onSuccess?.(data, vars, ctx);\n    },\n  });\n}\n","// packages/dapp-kit/src/hooks/staking/useCancelUnstake.ts\nimport type { CancelUnstakeAction, SpokeChainKey, TxHashPair } from '@sodax/sdk';\nimport { useQueryClient } from '@tanstack/react-query';\nimport { useSodaxContext } from '../shared/useSodaxContext.js';\nimport type { MutationHookParams } from '../shared/types.js';\nimport { useSafeMutation, type SafeUseMutationResult } from '../shared/useSafeMutation.js';\nimport { unwrapResult } from '../shared/unwrapResult.js';\n\nexport type UseCancelUnstakeVars<K extends SpokeChainKey = SpokeChainKey> = Omit<CancelUnstakeAction<K, false>, 'raw'>;\n\n/**\n * React hook for cancelling a pending unstake request.\n *\n * Throws on SDK failure so React Query's native error model engages (`isError`, `error`,\n * `onError`, `retry`). Returns the unwrapped `TxHashPair` on success.\n */\nexport function useCancelUnstake<K extends SpokeChainKey = SpokeChainKey>({\n  mutationOptions,\n}: MutationHookParams<TxHashPair, UseCancelUnstakeVars<K>> = {}): SafeUseMutationResult<\n  TxHashPair,\n  Error,\n  UseCancelUnstakeVars<K>\n> {\n  const { sodax } = useSodaxContext();\n  const queryClient = useQueryClient();\n\n  return useSafeMutation<TxHashPair, Error, UseCancelUnstakeVars<K>>({\n    mutationKey: ['staking', 'cancelUnstake'],\n    ...mutationOptions,\n    mutationFn: async vars => unwrapResult(await sodax.staking.cancelUnstake({ ...vars, raw: false })),\n    onSuccess: async (data, vars, ctx) => {\n      const { params } = vars;\n      queryClient.invalidateQueries({ queryKey: ['staking', 'unstakingInfo', params.srcChainKey, params.srcAddress] });\n      queryClient.invalidateQueries({\n        queryKey: ['staking', 'unstakingInfoWithPenalty', params.srcChainKey, params.srcAddress],\n      });\n      queryClient.invalidateQueries({ queryKey: ['staking', 'info', params.srcChainKey, params.srcAddress] });\n      await mutationOptions?.onSuccess?.(data, vars, ctx);\n    },\n  });\n}\n","import type { StakingInfo } from '@sodax/sdk';\nimport type { SpokeChainKey } from '@sodax/sdk';\nimport { useQuery, type UseQueryResult } from '@tanstack/react-query';\nimport { useSodaxContext } from '../shared/useSodaxContext.js';\nimport type { ReadHookParams } from '../shared/types.js';\n\nexport type UseStakingInfoParams = ReadHookParams<\n  StakingInfo,\n  {\n    srcAddress: `0x${string}` | undefined;\n    srcChainKey: SpokeChainKey | undefined;\n  }\n>;\n\n/**\n * React hook to fetch the user's staking info (xSODA balance, share value, underlying SODA) by\n * deriving the hub wallet from the spoke `srcAddress` + `srcChainKey`. Throws on `!ok` so React\n * Query lands in `error` state.\n */\nexport function useStakingInfo({ params, queryOptions }: UseStakingInfoParams = {}): UseQueryResult<\n  StakingInfo,\n  Error\n> {\n  const { sodax } = useSodaxContext();\n  const srcAddress = params?.srcAddress;\n  const srcChainKey = params?.srcChainKey;\n\n  return useQuery<StakingInfo, Error>({\n    queryKey: ['staking', 'info', srcChainKey, srcAddress],\n    queryFn: async () => {\n      if (!srcAddress || !srcChainKey) {\n        throw new Error('srcAddress and srcChainKey are required');\n      }\n      const result = await sodax.staking.getStakingInfoFromSpoke(srcAddress, srcChainKey);\n      if (!result.ok) throw result.error;\n      return result.value;\n    },\n    enabled: !!srcAddress && !!srcChainKey,\n    refetchInterval: 5_000,\n    ...queryOptions,\n  });\n}\n","import type { UnstakeRequestWithPenalty, UnstakingInfo } from '@sodax/sdk';\nimport type { SpokeChainKey } from '@sodax/sdk';\nimport { useQuery, type UseQueryResult } from '@tanstack/react-query';\nimport { useSodaxContext } from '../shared/useSodaxContext.js';\nimport type { ReadHookParams } from '../shared/types.js';\n\nexport type UnstakingInfoWithPenalty = UnstakingInfo & { requestsWithPenalty: UnstakeRequestWithPenalty[] };\n\nexport type UseUnstakingInfoWithPenaltyParams = ReadHookParams<\n  UnstakingInfoWithPenalty,\n  {\n    srcAddress: `0x${string}` | undefined;\n    srcChainKey: SpokeChainKey | undefined;\n  }\n>;\n\n/**\n * React hook to fetch the user's pending unstake requests **with computed early-exit penalties**\n * by deriving the hub wallet from the spoke `srcAddress` + `srcChainKey`. Throws on `!ok`.\n */\nexport function useUnstakingInfoWithPenalty({\n  params,\n  queryOptions,\n}: UseUnstakingInfoWithPenaltyParams = {}): UseQueryResult<UnstakingInfoWithPenalty, Error> {\n  const { sodax } = useSodaxContext();\n  const srcAddress = params?.srcAddress;\n  const srcChainKey = params?.srcChainKey;\n\n  return useQuery<UnstakingInfoWithPenalty, Error>({\n    queryKey: ['staking', 'unstakingInfoWithPenalty', srcChainKey, srcAddress],\n    queryFn: async () => {\n      if (!srcAddress || !srcChainKey) {\n        throw new Error('srcAddress and srcChainKey are required');\n      }\n      const result = await sodax.staking.getUnstakingInfoWithPenalty(srcAddress, srcChainKey);\n      if (!result.ok) throw result.error;\n      return result.value;\n    },\n    enabled: !!srcAddress && !!srcChainKey,\n    refetchInterval: 5_000,\n    ...queryOptions,\n  });\n}\n","import type { StakingConfig } from '@sodax/sdk';\nimport { useQuery, type UseQueryResult } from '@tanstack/react-query';\nimport { useSodaxContext } from '../shared/useSodaxContext.js';\nimport type { ReadHookParams } from '../shared/types.js';\n\nexport type UseStakingConfigParams = ReadHookParams<StakingConfig>;\n\n/**\n * React hook to fetch the global staking config (unstaking period, min unstaking period, max\n * penalty). Hub-only read; no chain context required. Throws on `!ok`.\n */\nexport function useStakingConfig({\n  queryOptions,\n}: UseStakingConfigParams = {}): UseQueryResult<StakingConfig, Error> {\n  const { sodax } = useSodaxContext();\n\n  return useQuery<StakingConfig, Error>({\n    queryKey: ['staking', 'config'],\n    queryFn: async () => {\n      const result = await sodax.staking.getStakingConfig();\n      if (!result.ok) throw result.error;\n      return result.value;\n    },\n    staleTime: Number.POSITIVE_INFINITY,\n    ...queryOptions,\n  });\n}\n","import { useQuery, type UseQueryResult } from '@tanstack/react-query';\nimport { useSodaxContext } from '../shared/useSodaxContext.js';\nimport type { ReadHookParams } from '../shared/types.js';\n\nexport type UseStakeRatioParams = ReadHookParams<\n  [bigint, bigint],\n  {\n    amount: bigint | undefined;\n  }\n>;\n\n/**\n * React hook to estimate the SODA → xSODA stake ratio for a given amount. Hub-only read. Throws\n * on `!ok`.\n */\nexport function useStakeRatio({\n  params,\n  queryOptions,\n}: UseStakeRatioParams = {}): UseQueryResult<[bigint, bigint], Error> {\n  const { sodax } = useSodaxContext();\n  const amount = params?.amount;\n\n  return useQuery<[bigint, bigint], Error>({\n    queryKey: ['staking', 'stakeRatio', amount?.toString()],\n    queryFn: async () => {\n      if (amount === undefined) {\n        throw new Error('amount is required');\n      }\n      const result = await sodax.staking.getStakeRatio(amount);\n      if (!result.ok) throw result.error;\n      return result.value;\n    },\n    enabled: amount !== undefined,\n    refetchInterval: 10_000,\n    ...queryOptions,\n  });\n}\n","import { useQuery, type UseQueryResult } from '@tanstack/react-query';\nimport { useSodaxContext } from '../shared/useSodaxContext.js';\nimport type { ReadHookParams } from '../shared/types.js';\n\nexport type UseInstantUnstakeRatioParams = ReadHookParams<\n  bigint,\n  {\n    amount: bigint | undefined;\n  }\n>;\n\n/**\n * React hook to estimate the SODA amount received from instant-unstaking a given xSODA amount\n * (after slippage). Hub-only read. Throws on `!ok`.\n */\nexport function useInstantUnstakeRatio({\n  params,\n  queryOptions,\n}: UseInstantUnstakeRatioParams = {}): UseQueryResult<bigint, Error> {\n  const { sodax } = useSodaxContext();\n  const amount = params?.amount;\n\n  return useQuery<bigint, Error>({\n    queryKey: ['staking', 'instantUnstakeRatio', amount?.toString()],\n    queryFn: async () => {\n      if (amount === undefined) {\n        throw new Error('amount is required');\n      }\n      const result = await sodax.staking.getInstantUnstakeRatio(amount);\n      if (!result.ok) throw result.error;\n      return result.value;\n    },\n    enabled: amount !== undefined,\n    refetchInterval: 10_000,\n    ...queryOptions,\n  });\n}\n","import { useQuery, type UseQueryResult } from '@tanstack/react-query';\nimport { useSodaxContext } from '../shared/useSodaxContext.js';\nimport type { ReadHookParams } from '../shared/types.js';\n\nexport type UseConvertedAssetsParams = ReadHookParams<\n  bigint,\n  {\n    amount: bigint | undefined;\n  }\n>;\n\n/**\n * React hook to convert an xSODA share amount to its underlying SODA value via the vault's\n * exchange rate. Hub-only read. Throws on `!ok`.\n */\nexport function useConvertedAssets({\n  params,\n  queryOptions,\n}: UseConvertedAssetsParams = {}): UseQueryResult<bigint, Error> {\n  const { sodax } = useSodaxContext();\n  const amount = params?.amount;\n\n  return useQuery<bigint, Error>({\n    queryKey: ['staking', 'convertedAssets', amount?.toString()],\n    queryFn: async () => {\n      if (amount === undefined) {\n        throw new Error('amount is required');\n      }\n      const result = await sodax.staking.getConvertedAssets(amount);\n      if (!result.ok) throw result.error;\n      return result.value;\n    },\n    enabled: amount !== undefined,\n    refetchInterval: 10_000,\n    ...queryOptions,\n  });\n}\n","// packages/dapp-kit/src/hooks/staking/useInstantUnstake.ts\nimport type { InstantUnstakeAction, SpokeChainKey, TxHashPair } from '@sodax/sdk';\nimport { useQueryClient } from '@tanstack/react-query';\nimport { useSodaxContext } from '../shared/useSodaxContext.js';\nimport type { MutationHookParams } from '../shared/types.js';\nimport { useSafeMutation, type SafeUseMutationResult } from '../shared/useSafeMutation.js';\nimport { unwrapResult } from '../shared/unwrapResult.js';\n\nexport type UseInstantUnstakeVars<K extends SpokeChainKey = SpokeChainKey> = Omit<\n  InstantUnstakeAction<K, false>,\n  'raw'\n>;\n\n/**\n * React hook for instant-unstaking SODA (bypassing the waiting period at a slippage cost).\n *\n * Throws on SDK failure so React Query's native error model engages (`isError`, `error`,\n * `onError`, `retry`). Returns the unwrapped `TxHashPair` on success.\n */\nexport function useInstantUnstake<K extends SpokeChainKey = SpokeChainKey>({\n  mutationOptions,\n}: MutationHookParams<TxHashPair, UseInstantUnstakeVars<K>> = {}): SafeUseMutationResult<\n  TxHashPair,\n  Error,\n  UseInstantUnstakeVars<K>\n> {\n  const { sodax } = useSodaxContext();\n  const queryClient = useQueryClient();\n\n  return useSafeMutation<TxHashPair, Error, UseInstantUnstakeVars<K>>({\n    mutationKey: ['staking', 'instantUnstake'],\n    ...mutationOptions,\n    mutationFn: async vars => unwrapResult(await sodax.staking.instantUnstake({ ...vars, raw: false })),\n    onSuccess: async (data, vars, ctx) => {\n      const { params } = vars;\n      queryClient.invalidateQueries({ queryKey: ['staking', 'info', params.srcChainKey, params.srcAddress] });\n      queryClient.invalidateQueries({ queryKey: ['staking', 'instantUnstakeRatio'] });\n      queryClient.invalidateQueries({ queryKey: ['staking', 'allowance', params.srcChainKey, 'instantUnstake'] });\n      queryClient.invalidateQueries({ queryKey: ['shared', 'xBalances', params.srcChainKey] });\n      await mutationOptions?.onSuccess?.(data, vars, ctx);\n    },\n  });\n}\n","import type { UnstakeParams } from '@sodax/sdk';\nimport type { SpokeChainKey } from '@sodax/sdk';\nimport { useQuery, type UseQueryResult } from '@tanstack/react-query';\nimport { useSodaxContext } from '../shared/useSodaxContext.js';\nimport type { ReadHookParams } from '../shared/types.js';\n\nexport type UseUnstakeAllowanceParams<K extends SpokeChainKey = SpokeChainKey> = ReadHookParams<\n  boolean,\n  {\n    payload: Omit<UnstakeParams<K>, 'action'> | undefined;\n  }\n>;\n\n/**\n * React hook to check whether the user has approved sufficient xSODA spending for the unstake\n * action. Read-only — calls `staking.isAllowanceValid` with `raw: true` so no `walletProvider`\n * is required.\n */\nexport function useUnstakeAllowance<K extends SpokeChainKey = SpokeChainKey>({\n  params,\n  queryOptions,\n}: UseUnstakeAllowanceParams<K> = {}): UseQueryResult<boolean, Error> {\n  const { sodax } = useSodaxContext();\n  const payload = params?.payload;\n\n  return useQuery<boolean, Error>({\n    queryKey: [\n      'staking',\n      'allowance',\n      payload?.srcChainKey,\n      'unstake',\n      payload?.srcAddress,\n      payload?.amount?.toString(),\n    ],\n    queryFn: async () => {\n      if (!payload) {\n        throw new Error('Params are required');\n      }\n      const result = await sodax.staking.isAllowanceValid({\n        params: { ...payload, action: 'unstake' },\n        raw: true,\n      });\n      if (!result.ok) throw result.error;\n      return result.value;\n    },\n    enabled: !!payload,\n    refetchInterval: 5_000,\n    gcTime: 0,\n    ...queryOptions,\n  });\n}\n","// packages/dapp-kit/src/hooks/staking/useUnstakeApprove.ts\nimport type { GetWalletProviderType, SpokeChainKey, TxReturnType, UnstakeParams } from '@sodax/sdk';\nimport { useQueryClient } from '@tanstack/react-query';\nimport { useSodaxContext } from '../shared/useSodaxContext.js';\nimport type { MutationHookParams } from '../shared/types.js';\nimport { useSafeMutation, type SafeUseMutationResult } from '../shared/useSafeMutation.js';\nimport { unwrapResult } from '../shared/unwrapResult.js';\n\n/**\n * Mutation variables for {@link useUnstakeApprove}. The `action` literal is injected by the hook.\n */\nexport type UseUnstakeApproveVars<K extends SpokeChainKey = SpokeChainKey> = {\n  params: Omit<UnstakeParams<K>, 'action'>;\n  walletProvider: GetWalletProviderType<K>;\n};\n\n/**\n * React hook for approving xSODA spending on the unstake action.\n *\n * Throws on SDK failure so React Query's native error model engages (`isError`, `error`,\n * `onError`, `retry`). Returns the unwrapped tx return value on success.\n */\nexport function useUnstakeApprove<K extends SpokeChainKey = SpokeChainKey>({\n  mutationOptions,\n}: MutationHookParams<TxReturnType<K, false>, UseUnstakeApproveVars<K>> = {}): SafeUseMutationResult<\n  TxReturnType<K, false>,\n  Error,\n  UseUnstakeApproveVars<K>\n> {\n  const { sodax } = useSodaxContext();\n  const queryClient = useQueryClient();\n\n  return useSafeMutation<TxReturnType<K, false>, Error, UseUnstakeApproveVars<K>>({\n    mutationKey: ['staking', 'approve', 'unstake'],\n    ...mutationOptions,\n    mutationFn: async ({ params, walletProvider }) =>\n      unwrapResult(\n        await sodax.staking.approve({\n          params: { ...params, action: 'unstake' },\n          raw: false,\n          walletProvider,\n        }),\n      ),\n    onSuccess: async (data, vars, ctx) => {\n      queryClient.invalidateQueries({ queryKey: ['staking', 'allowance', vars.params.srcChainKey, 'unstake'] });\n      await mutationOptions?.onSuccess?.(data, vars, ctx);\n    },\n  });\n}\n","import type { UnstakingInfo } from '@sodax/sdk';\nimport type { SpokeChainKey } from '@sodax/sdk';\nimport { useQuery, type UseQueryResult } from '@tanstack/react-query';\nimport { useSodaxContext } from '../shared/useSodaxContext.js';\nimport type { ReadHookParams } from '../shared/types.js';\n\nexport type UseUnstakingInfoParams = ReadHookParams<\n  UnstakingInfo,\n  {\n    srcAddress: `0x${string}` | undefined;\n    srcChainKey: SpokeChainKey | undefined;\n  }\n>;\n\n/**\n * React hook to fetch the user's pending unstake requests by deriving the hub wallet from the\n * spoke `srcAddress` + `srcChainKey`. Throws on `!ok`.\n */\nexport function useUnstakingInfo({\n  params,\n  queryOptions,\n}: UseUnstakingInfoParams = {}): UseQueryResult<UnstakingInfo, Error> {\n  const { sodax } = useSodaxContext();\n  const srcAddress = params?.srcAddress;\n  const srcChainKey = params?.srcChainKey;\n\n  return useQuery<UnstakingInfo, Error>({\n    queryKey: ['staking', 'unstakingInfo', srcChainKey, srcAddress],\n    queryFn: async () => {\n      if (!srcAddress || !srcChainKey) {\n        throw new Error('srcAddress and srcChainKey are required');\n      }\n      const result = await sodax.staking.getUnstakingInfo(srcAddress, srcChainKey);\n      if (!result.ok) throw result.error;\n      return result.value;\n    },\n    enabled: !!srcAddress && !!srcChainKey,\n    refetchInterval: 5_000,\n    ...queryOptions,\n  });\n}\n","// packages/dapp-kit/src/hooks/staking/useInstantUnstakeApprove.ts\nimport type { GetWalletProviderType, InstantUnstakeParams, SpokeChainKey, TxReturnType } from '@sodax/sdk';\nimport { useQueryClient } from '@tanstack/react-query';\nimport { useSodaxContext } from '../shared/useSodaxContext.js';\nimport type { MutationHookParams } from '../shared/types.js';\nimport { useSafeMutation, type SafeUseMutationResult } from '../shared/useSafeMutation.js';\nimport { unwrapResult } from '../shared/unwrapResult.js';\n\n/**\n * Mutation variables for {@link useInstantUnstakeApprove}. The `action` literal is injected by\n * the hook.\n */\nexport type UseInstantUnstakeApproveVars<K extends SpokeChainKey = SpokeChainKey> = {\n  params: Omit<InstantUnstakeParams<K>, 'action'>;\n  walletProvider: GetWalletProviderType<K>;\n};\n\n/**\n * React hook for approving xSODA spending on the instant-unstake action.\n *\n * Throws on SDK failure so React Query's native error model engages (`isError`, `error`,\n * `onError`, `retry`). Returns the unwrapped tx return value on success.\n */\nexport function useInstantUnstakeApprove<K extends SpokeChainKey = SpokeChainKey>({\n  mutationOptions,\n}: MutationHookParams<TxReturnType<K, false>, UseInstantUnstakeApproveVars<K>> = {}): SafeUseMutationResult<\n  TxReturnType<K, false>,\n  Error,\n  UseInstantUnstakeApproveVars<K>\n> {\n  const { sodax } = useSodaxContext();\n  const queryClient = useQueryClient();\n\n  return useSafeMutation<TxReturnType<K, false>, Error, UseInstantUnstakeApproveVars<K>>({\n    mutationKey: ['staking', 'approve', 'instantUnstake'],\n    ...mutationOptions,\n    mutationFn: async ({ params, walletProvider }) =>\n      unwrapResult(\n        await sodax.staking.approve({\n          params: { ...params, action: 'instantUnstake' },\n          raw: false,\n          walletProvider,\n        }),\n      ),\n    onSuccess: async (data, vars, ctx) => {\n      queryClient.invalidateQueries({\n        queryKey: ['staking', 'allowance', vars.params.srcChainKey, 'instantUnstake'],\n      });\n      await mutationOptions?.onSuccess?.(data, vars, ctx);\n    },\n  });\n}\n","import type { InstantUnstakeParams } from '@sodax/sdk';\nimport type { SpokeChainKey } from '@sodax/sdk';\nimport { useQuery, type UseQueryResult } from '@tanstack/react-query';\nimport { useSodaxContext } from '../shared/useSodaxContext.js';\nimport type { ReadHookParams } from '../shared/types.js';\n\nexport type UseInstantUnstakeAllowanceParams<K extends SpokeChainKey = SpokeChainKey> = ReadHookParams<\n  boolean,\n  {\n    payload: Omit<InstantUnstakeParams<K>, 'action'> | undefined;\n  }\n>;\n\n/**\n * React hook to check whether the user has approved sufficient xSODA spending for the\n * instant-unstake action. Read-only — calls `staking.isAllowanceValid` with `raw: true` so no\n * `walletProvider` is required.\n */\nexport function useInstantUnstakeAllowance<K extends SpokeChainKey = SpokeChainKey>({\n  params,\n  queryOptions,\n}: UseInstantUnstakeAllowanceParams<K> = {}): UseQueryResult<boolean, Error> {\n  const { sodax } = useSodaxContext();\n  const payload = params?.payload;\n\n  return useQuery<boolean, Error>({\n    queryKey: [\n      'staking',\n      'allowance',\n      payload?.srcChainKey,\n      'instantUnstake',\n      payload?.srcAddress,\n      payload?.amount?.toString(),\n    ],\n    queryFn: async () => {\n      if (!payload) {\n        throw new Error('Params are required');\n      }\n      const result = await sodax.staking.isAllowanceValid({\n        params: { ...payload, action: 'instantUnstake' },\n        raw: true,\n      });\n      if (!result.ok) throw result.error;\n      return result.value;\n    },\n    enabled: !!payload,\n    refetchInterval: 5_000,\n    gcTime: 0,\n    ...queryOptions,\n  });\n}\n","import type { PartnerFeeClaimAssetBalance } from '@sodax/sdk';\nimport { useQuery, type UseQueryResult } from '@tanstack/react-query';\nimport { useSodaxContext } from '../shared/useSodaxContext.js';\nimport type { ReadHookParams } from '../shared/types.js';\n\nexport type UseFetchAssetsBalancesParams = ReadHookParams<\n  Map<string, PartnerFeeClaimAssetBalance>,\n  {\n    queryAddress: string | undefined;\n  }\n>;\n\n/**\n * React hook to fetch hub-asset balances on Sonic for a given EVM address. Disabled when\n * `queryAddress` is missing. Throws on `!ok`.\n */\nexport function useFetchAssetsBalances({\n  params,\n  queryOptions,\n}: UseFetchAssetsBalancesParams = {}): UseQueryResult<Map<string, PartnerFeeClaimAssetBalance>, Error> {\n  const { sodax } = useSodaxContext();\n  const queryAddress = params?.queryAddress;\n\n  return useQuery<Map<string, PartnerFeeClaimAssetBalance>, Error>({\n    queryKey: ['partner', 'feeClaim', 'assetsBalances', queryAddress],\n    queryFn: async () => {\n      if (!queryAddress) {\n        throw new Error('queryAddress is required');\n      }\n      const result = await sodax.partners.feeClaim.fetchAssetsBalances(queryAddress);\n      if (!result.ok) throw result.error;\n      return result.value;\n    },\n    enabled: !!queryAddress,\n    ...queryOptions,\n  });\n}\n","import type { AutoSwapPreferences } from '@sodax/sdk';\nimport { useQuery, type UseQueryResult } from '@tanstack/react-query';\nimport { useSodaxContext } from '../shared/useSodaxContext.js';\nimport type { ReadHookParams } from '../shared/types.js';\n\nexport type UseGetAutoSwapPreferencesParams = ReadHookParams<\n  AutoSwapPreferences,\n  {\n    queryAddress: string | undefined;\n  }\n>;\n\n/**\n * React hook to fetch the auto-swap preferences (output token, destination chain, destination\n * address) for a given EVM address. Disabled when `queryAddress` is missing. Throws on `!ok`.\n */\nexport function useGetAutoSwapPreferences({\n  params,\n  queryOptions,\n}: UseGetAutoSwapPreferencesParams = {}): UseQueryResult<AutoSwapPreferences, Error> {\n  const { sodax } = useSodaxContext();\n  const queryAddress = params?.queryAddress;\n\n  return useQuery<AutoSwapPreferences, Error>({\n    queryKey: ['partner', 'feeClaim', 'autoSwapPreferences', queryAddress],\n    queryFn: async () => {\n      if (!queryAddress) {\n        throw new Error('queryAddress is required');\n      }\n      const result = await sodax.partners.feeClaim.getAutoSwapPreferences(queryAddress);\n      if (!result.ok) throw result.error;\n      return result.value;\n    },\n    enabled: !!queryAddress,\n    ...queryOptions,\n  });\n}\n","import type { FeeTokenApproveParams } from '@sodax/sdk';\nimport { useQuery, type UseQueryResult } from '@tanstack/react-query';\nimport { useSodaxContext } from '../shared/useSodaxContext.js';\nimport type { ReadHookParams } from '../shared/types.js';\n\nexport type UseIsTokenApprovedParams = ReadHookParams<\n  boolean,\n  {\n    payload: FeeTokenApproveParams | undefined;\n  }\n>;\n\n/**\n * React hook to check whether a token is approved to the protocol-intents contract on Sonic for\n * a given owner. Read-only; throws on `!ok`.\n */\nexport function useIsTokenApproved({\n  params,\n  queryOptions,\n}: UseIsTokenApprovedParams = {}): UseQueryResult<boolean, Error> {\n  const { sodax } = useSodaxContext();\n  const payload = params?.payload;\n\n  return useQuery<boolean, Error>({\n    queryKey: ['partner', 'feeClaim', 'isTokenApproved', payload?.srcChainKey, payload?.srcAddress, payload?.token],\n    queryFn: async () => {\n      if (!payload) {\n        throw new Error('params are required');\n      }\n      const result = await sodax.partners.feeClaim.isTokenApproved(payload);\n      if (!result.ok) throw result.error;\n      return result.value;\n    },\n    enabled: !!payload,\n    refetchInterval: 5_000,\n    gcTime: 0,\n    ...queryOptions,\n  });\n}\n","// packages/dapp-kit/src/hooks/partner/useApproveToken.ts\nimport type { FeeTokenApproveAction, HubChainKey, TxReturnType } from '@sodax/sdk';\nimport { useQueryClient } from '@tanstack/react-query';\nimport { useSodaxContext } from '../shared/useSodaxContext.js';\nimport type { MutationHookParams } from '../shared/types.js';\nimport { useSafeMutation, type SafeUseMutationResult } from '../shared/useSafeMutation.js';\nimport { unwrapResult } from '../shared/unwrapResult.js';\n\nexport type UseApproveTokenVars = Omit<FeeTokenApproveAction<HubChainKey, false>, 'raw'>;\n\ntype ApproveTokenData = TxReturnType<HubChainKey, false>;\n\n/**\n * React hook to approve a token to the protocol-intents contract on Sonic with max allowance.\n *\n * Throws on SDK failure so React Query's native error model engages (`isError`, `error`,\n * `onError`, `retry`). Returns the unwrapped tx return value on success.\n */\nexport function useApproveToken({\n  mutationOptions,\n}: MutationHookParams<ApproveTokenData, UseApproveTokenVars> = {}): SafeUseMutationResult<\n  ApproveTokenData,\n  Error,\n  UseApproveTokenVars\n> {\n  const { sodax } = useSodaxContext();\n  const queryClient = useQueryClient();\n\n  return useSafeMutation<ApproveTokenData, Error, UseApproveTokenVars>({\n    mutationKey: ['partner', 'approveToken'],\n    ...mutationOptions,\n    mutationFn: async vars =>\n      unwrapResult(await sodax.partners.feeClaim.approveToken<false>({ ...vars, raw: false })),\n    onSuccess: async (data, vars, ctx) => {\n      const { params } = vars;\n      queryClient.invalidateQueries({\n        queryKey: ['partner', 'feeClaim', 'isTokenApproved', params.srcChainKey, params.srcAddress, params.token],\n      });\n      await mutationOptions?.onSuccess?.(data, vars, ctx);\n    },\n  });\n}\n","// packages/dapp-kit/src/hooks/partner/useSetSwapPreference.ts\nimport type { HubChainKey, SetSwapPreferenceAction, SpokeChainKey, TxReturnType } from '@sodax/sdk';\nimport { useQueryClient } from '@tanstack/react-query';\nimport { useSodaxContext } from '../shared/useSodaxContext.js';\nimport type { MutationHookParams } from '../shared/types.js';\nimport { useSafeMutation, type SafeUseMutationResult } from '../shared/useSafeMutation.js';\nimport { unwrapResult } from '../shared/unwrapResult.js';\n\n/**\n * Mutation variables for {@link useSetSwapPreference}. Generic over `K extends SpokeChainKey`\n * for compatibility with the SDK signature; at runtime the SDK enforces hub-only\n * (`isHubChainKeyType(srcChainKey)`).\n */\nexport type UseSetSwapPreferenceVars<K extends SpokeChainKey = SpokeChainKey> = Omit<\n  SetSwapPreferenceAction<K, false>,\n  'raw'\n>;\n\n/**\n * React hook to set the partner's auto-swap preferences (output token + destination chain +\n * destination address) on the protocol-intents contract.\n *\n * Throws on SDK failure so React Query's native error model engages (`isError`, `error`,\n * `onError`, `retry`). Returns the unwrapped tx return value on success.\n */\nexport function useSetSwapPreference<K extends SpokeChainKey = SpokeChainKey>({\n  mutationOptions,\n}: MutationHookParams<TxReturnType<K, false>, UseSetSwapPreferenceVars<K>> = {}): SafeUseMutationResult<\n  TxReturnType<K, false>,\n  Error,\n  UseSetSwapPreferenceVars<K>\n> {\n  const { sodax } = useSodaxContext();\n  const queryClient = useQueryClient();\n\n  return useSafeMutation<TxReturnType<K, false>, Error, UseSetSwapPreferenceVars<K>>({\n    mutationKey: ['partner', 'setSwapPreference'],\n    ...mutationOptions,\n    mutationFn: async vars => unwrapResult(await sodax.partners.feeClaim.setSwapPreference({ ...vars, raw: false })),\n    onSuccess: async (data, vars, ctx) => {\n      queryClient.invalidateQueries({\n        queryKey: ['partner', 'feeClaim', 'autoSwapPreferences', (vars.params as { srcAddress: string }).srcAddress],\n      });\n      await mutationOptions?.onSuccess?.(data, vars, ctx);\n    },\n  });\n}\n\n// Helper alias for the common Sonic-only call shape.\nexport type UseSetSwapPreferenceVarsHub = UseSetSwapPreferenceVars<HubChainKey>;\n","// packages/dapp-kit/src/hooks/partner/useFeeClaimSwap.ts\nimport type { HubChainKey, IntentAutoSwapResult, PartnerFeeClaimSwapAction } from '@sodax/sdk';\nimport { useQueryClient } from '@tanstack/react-query';\nimport { useSodaxContext } from '../shared/useSodaxContext.js';\nimport type { MutationHookParams } from '../shared/types.js';\nimport { useSafeMutation, type SafeUseMutationResult } from '../shared/useSafeMutation.js';\nimport { unwrapResult } from '../shared/unwrapResult.js';\n\nexport type UseFeeClaimSwapVars = Omit<PartnerFeeClaimSwapAction<HubChainKey, false>, 'raw'>;\n\n/**\n * React hook to create a partner-fee auto-swap intent and wait for the solver execution.\n *\n * Throws on SDK failure so React Query's native error model engages (`isError`, `error`,\n * `onError`, `retry`). Returns the unwrapped `IntentAutoSwapResult` on success.\n */\nexport function useFeeClaimSwap({\n  mutationOptions,\n}: MutationHookParams<IntentAutoSwapResult, UseFeeClaimSwapVars> = {}): SafeUseMutationResult<\n  IntentAutoSwapResult,\n  Error,\n  UseFeeClaimSwapVars\n> {\n  const { sodax } = useSodaxContext();\n  const queryClient = useQueryClient();\n\n  return useSafeMutation<IntentAutoSwapResult, Error, UseFeeClaimSwapVars>({\n    mutationKey: ['partner', 'feeClaimSwap'],\n    ...mutationOptions,\n    mutationFn: async vars => unwrapResult(await sodax.partners.feeClaim.swap({ ...vars, raw: false })),\n    onSuccess: async (data, vars, ctx) => {\n      queryClient.invalidateQueries({\n        queryKey: ['partner', 'feeClaim', 'assetsBalances', vars.params.srcAddress],\n      });\n      await mutationOptions?.onSuccess?.(data, vars, ctx);\n    },\n  });\n}\n","import type { HubAssetBalance } from '@sodax/sdk';\nimport type { SpokeChainKey } from '@sodax/sdk';\nimport { useQuery, type UseQueryResult } from '@tanstack/react-query';\nimport { useSodaxContext } from '../shared/useSodaxContext.js';\nimport type { ReadHookParams } from '../shared/types.js';\n\nexport type UseHubAssetBalancesParams = ReadHookParams<\n  HubAssetBalance[],\n  {\n    chainKey: SpokeChainKey | undefined;\n    /** The user's address on the spoke chain. The SDK derives the hub wallet abstraction internally. */\n    srcAddress: string | undefined;\n  }\n>;\n\n/**\n * React hook to fetch the hub-side balances of every supported token on the given spoke chain\n * for the user's hub wallet (derived internally from `srcAddress` + `chainKey`). Disabled when\n * either input is missing. Throws on `!ok`.\n */\nexport function useHubAssetBalances({\n  params,\n  queryOptions,\n}: UseHubAssetBalancesParams = {}): UseQueryResult<HubAssetBalance[], Error> {\n  const { sodax } = useSodaxContext();\n  const chainKey = params?.chainKey;\n  const srcAddress = params?.srcAddress;\n\n  return useQuery<HubAssetBalance[], Error>({\n    queryKey: ['recovery', 'hubAssetBalances', chainKey, srcAddress],\n    queryFn: async () => {\n      if (!chainKey || !srcAddress) {\n        throw new Error('chainKey and srcAddress are required');\n      }\n      const result = await sodax.recovery.fetchHubAssetBalances({ chainKey, srcAddress });\n      if (!result.ok) throw result.error;\n      return result.value;\n    },\n    enabled: !!chainKey && !!srcAddress,\n    staleTime: 10_000,\n    ...queryOptions,\n  });\n}\n","// packages/dapp-kit/src/hooks/recovery/useWithdrawHubAsset.ts\nimport type { SpokeChainKey, TxReturnType, WithdrawHubAssetAction } from '@sodax/sdk';\nimport { useQueryClient } from '@tanstack/react-query';\nimport { useSodaxContext } from '../shared/useSodaxContext.js';\nimport type { MutationHookParams } from '../shared/types.js';\nimport { useSafeMutation, type SafeUseMutationResult } from '../shared/useSafeMutation.js';\nimport { unwrapResult } from '../shared/unwrapResult.js';\n\n/**\n * Mutation variables for {@link useWithdrawHubAsset}. Generic over `K extends SpokeChainKey`\n * (defaults to the full union). Sophisticated callers can lock K at the hook call site to narrow\n * the `walletProvider` and `params.srcChainKey` types.\n */\nexport type UseWithdrawHubAssetVars<K extends SpokeChainKey = SpokeChainKey> = Omit<\n  WithdrawHubAssetAction<K, false>,\n  'raw'\n>;\n\n/**\n * React hook for withdrawing a hub-side asset back to the user's spoke chain wallet.\n *\n * Throws on SDK failure so React Query's native error model engages (`isError`, `error`,\n * `onError`, `retry`). Returns the unwrapped tx return value on success.\n */\nexport function useWithdrawHubAsset<K extends SpokeChainKey = SpokeChainKey>({\n  mutationOptions,\n}: MutationHookParams<TxReturnType<K, false>, UseWithdrawHubAssetVars<K>> = {}): SafeUseMutationResult<\n  TxReturnType<K, false>,\n  Error,\n  UseWithdrawHubAssetVars<K>\n> {\n  const { sodax } = useSodaxContext();\n  const queryClient = useQueryClient();\n\n  return useSafeMutation<TxReturnType<K, false>, Error, UseWithdrawHubAssetVars<K>>({\n    mutationKey: ['recovery', 'withdrawHubAsset'],\n    ...mutationOptions,\n    mutationFn: async vars => unwrapResult(await sodax.recovery.withdrawHubAsset<K, false>({ ...vars, raw: false })),\n    onSuccess: async (data, vars, ctx) => {\n      const { params } = vars;\n      queryClient.invalidateQueries({\n        queryKey: ['recovery', 'hubAssetBalances', params.srcChainKey, params.srcAddress],\n      });\n      queryClient.invalidateQueries({ queryKey: ['shared', 'xBalances', params.srcChainKey] });\n      await mutationOptions?.onSuccess?.(data, vars, ctx);\n    },\n  });\n}\n","// packages/dapp-kit/src/hooks/migrate/useMigrateIcxToSoda.ts\nimport type { IcxMigrateAction, TxHashPair } from '@sodax/sdk';\nimport { ChainKeys } from '@sodax/sdk';\nimport { useQueryClient } from '@tanstack/react-query';\nimport { useSodaxContext } from '../shared/useSodaxContext.js';\nimport type { MutationHookParams } from '../shared/types.js';\nimport { useSafeMutation, type SafeUseMutationResult } from '../shared/useSafeMutation.js';\nimport { unwrapResult } from '../shared/unwrapResult.js';\n\n/**\n * Mutation variables for {@link useMigrateIcxToSoda}. Wraps `IcxMigrateAction<false>` with `raw`\n * stripped — the hook always submits non-raw and unwraps the SDK Result.\n */\nexport type UseMigrateIcxToSodaVars = Omit<IcxMigrateAction<false>, 'raw'>;\n\n/**\n * React hook for migrating ICX/wICX → SODA on the Sonic hub. Forward-only direction; for the\n * reverse (SODA → ICX) use {@link useRevertMigrateSodaToIcx}.\n *\n * Throws on SDK failure so React Query's native error model engages (`isError`, `error`,\n * `onError`, `retry`). Returns the unwrapped `TxHashPair` on success.\n */\nexport function useMigrateIcxToSoda({\n  mutationOptions,\n}: MutationHookParams<TxHashPair, UseMigrateIcxToSodaVars> = {}): SafeUseMutationResult<\n  TxHashPair,\n  Error,\n  UseMigrateIcxToSodaVars\n> {\n  const { sodax } = useSodaxContext();\n  const queryClient = useQueryClient();\n\n  return useSafeMutation<TxHashPair, Error, UseMigrateIcxToSodaVars>({\n    mutationKey: ['migrate', 'icxToSoda'],\n    ...mutationOptions,\n    mutationFn: async vars => unwrapResult(await sodax.migration.migrateIcxToSoda({ ...vars, raw: false })),\n    onSuccess: async (data, vars, ctx) => {\n      queryClient.invalidateQueries({ queryKey: ['migrate', 'allowance'] });\n      queryClient.invalidateQueries({ queryKey: ['shared', 'xBalances', vars.params.srcChainKey] });\n      queryClient.invalidateQueries({ queryKey: ['shared', 'xBalances', ChainKeys.SONIC_MAINNET] });\n      await mutationOptions?.onSuccess?.(data, vars, ctx);\n    },\n  });\n}\n","// packages/dapp-kit/src/hooks/migrate/useRevertMigrateSodaToIcx.ts\nimport type { IcxRevertMigrationAction, TxHashPair } from '@sodax/sdk';\nimport { ChainKeys } from '@sodax/sdk';\nimport { useQueryClient } from '@tanstack/react-query';\nimport { useSodaxContext } from '../shared/useSodaxContext.js';\nimport type { MutationHookParams } from '../shared/types.js';\nimport { useSafeMutation, type SafeUseMutationResult } from '../shared/useSafeMutation.js';\nimport { unwrapResult } from '../shared/unwrapResult.js';\n\nexport type UseRevertMigrateSodaToIcxVars = Omit<IcxRevertMigrationAction<false>, 'raw'>;\n\n/**\n * React hook for reverting SODA → ICX (the inverse of {@link useMigrateIcxToSoda}).\n *\n * Throws on SDK failure so React Query's native error model engages (`isError`, `error`,\n * `onError`, `retry`). Returns the unwrapped `TxHashPair` on success.\n */\nexport function useRevertMigrateSodaToIcx({\n  mutationOptions,\n}: MutationHookParams<TxHashPair, UseRevertMigrateSodaToIcxVars> = {}): SafeUseMutationResult<\n  TxHashPair,\n  Error,\n  UseRevertMigrateSodaToIcxVars\n> {\n  const { sodax } = useSodaxContext();\n  const queryClient = useQueryClient();\n\n  return useSafeMutation<TxHashPair, Error, UseRevertMigrateSodaToIcxVars>({\n    mutationKey: ['migrate', 'revertSodaToIcx'],\n    ...mutationOptions,\n    mutationFn: async vars => unwrapResult(await sodax.migration.revertMigrateSodaToIcx({ ...vars, raw: false })),\n    onSuccess: async (data, vars, ctx) => {\n      queryClient.invalidateQueries({ queryKey: ['migrate', 'allowance'] });\n      queryClient.invalidateQueries({ queryKey: ['shared', 'xBalances', vars.params.srcChainKey] });\n      queryClient.invalidateQueries({ queryKey: ['shared', 'xBalances', ChainKeys.ICON_MAINNET] });\n      await mutationOptions?.onSuccess?.(data, vars, ctx);\n    },\n  });\n}\n","// packages/dapp-kit/src/hooks/migrate/useMigratebnUSD.ts\nimport type { SpokeChainKey, TxHashPair, UnifiedBnUSDMigrateAction } from '@sodax/sdk';\nimport { useQueryClient } from '@tanstack/react-query';\nimport { useSodaxContext } from '../shared/useSodaxContext.js';\nimport type { MutationHookParams } from '../shared/types.js';\nimport { useSafeMutation, type SafeUseMutationResult } from '../shared/useSafeMutation.js';\nimport { unwrapResult } from '../shared/unwrapResult.js';\n\n/**\n * Mutation variables for {@link useMigratebnUSD}. Generic over `K extends SpokeChainKey` (defaults\n * to the full union). Bidirectional — handles both legacy → new and new → legacy bnUSD migration\n * via the same SDK call; the SDK detects direction from the token addresses.\n */\nexport type UseMigratebnUSDVars<K extends SpokeChainKey = SpokeChainKey> = Omit<\n  UnifiedBnUSDMigrateAction<K, false>,\n  'raw'\n>;\n\n/**\n * React hook for migrating bnUSD between legacy and new formats across spoke chains via Sonic.\n *\n * Throws on SDK failure so React Query's native error model engages (`isError`, `error`,\n * `onError`, `retry`). Returns the unwrapped `TxHashPair` on success.\n */\nexport function useMigratebnUSD<K extends SpokeChainKey = SpokeChainKey>({\n  mutationOptions,\n}: MutationHookParams<TxHashPair, UseMigratebnUSDVars<K>> = {}): SafeUseMutationResult<\n  TxHashPair,\n  Error,\n  UseMigratebnUSDVars<K>\n> {\n  const { sodax } = useSodaxContext();\n  const queryClient = useQueryClient();\n\n  return useSafeMutation<TxHashPair, Error, UseMigratebnUSDVars<K>>({\n    mutationKey: ['migrate', 'bnUSD'],\n    ...mutationOptions,\n    mutationFn: async vars => unwrapResult(await sodax.migration.migratebnUSD({ ...vars, raw: false })),\n    onSuccess: async (data, vars, ctx) => {\n      const { params } = vars;\n      queryClient.invalidateQueries({ queryKey: ['migrate', 'allowance'] });\n      queryClient.invalidateQueries({ queryKey: ['shared', 'xBalances', params.srcChainKey] });\n      queryClient.invalidateQueries({ queryKey: ['shared', 'xBalances', params.dstChainKey] });\n      await mutationOptions?.onSuccess?.(data, vars, ctx);\n    },\n  });\n}\n","// packages/dapp-kit/src/hooks/migrate/useMigrateBaln.ts\nimport type { BalnMigrateAction, TxHashPair } from '@sodax/sdk';\nimport { ChainKeys } from '@sodax/sdk';\nimport { useQueryClient } from '@tanstack/react-query';\nimport { useSodaxContext } from '../shared/useSodaxContext.js';\nimport type { MutationHookParams } from '../shared/types.js';\nimport { useSafeMutation, type SafeUseMutationResult } from '../shared/useSafeMutation.js';\nimport { unwrapResult } from '../shared/unwrapResult.js';\n\nexport type UseMigrateBalnVars = Omit<BalnMigrateAction<false>, 'raw'>;\n\n/**\n * React hook for migrating BALN → SODA on the Sonic hub. Source chain is always Icon. Supports\n * lockup periods (0–24 months) which multiply the SODA reward (0.5x–1.5x).\n *\n * Throws on SDK failure so React Query's native error model engages (`isError`, `error`,\n * `onError`, `retry`). Returns the unwrapped `TxHashPair` on success.\n */\nexport function useMigrateBaln({\n  mutationOptions,\n}: MutationHookParams<TxHashPair, UseMigrateBalnVars> = {}): SafeUseMutationResult<\n  TxHashPair,\n  Error,\n  UseMigrateBalnVars\n> {\n  const { sodax } = useSodaxContext();\n  const queryClient = useQueryClient();\n\n  return useSafeMutation<TxHashPair, Error, UseMigrateBalnVars>({\n    mutationKey: ['migrate', 'baln'],\n    ...mutationOptions,\n    mutationFn: async vars => unwrapResult(await sodax.migration.migrateBaln({ ...vars, raw: false })),\n    onSuccess: async (data, vars, ctx) => {\n      queryClient.invalidateQueries({ queryKey: ['migrate', 'allowance'] });\n      queryClient.invalidateQueries({ queryKey: ['shared', 'xBalances', ChainKeys.ICON_MAINNET] });\n      queryClient.invalidateQueries({ queryKey: ['shared', 'xBalances', ChainKeys.SONIC_MAINNET] });\n      // BALN with stake=true affects staking info too; cheap broad invalidation.\n      queryClient.invalidateQueries({ queryKey: ['staking', 'info'] });\n      await mutationOptions?.onSuccess?.(data, vars, ctx);\n    },\n  });\n}\n","// packages/dapp-kit/src/hooks/migrate/useMigrationApprove.ts\nimport type {\n  IcxRevertMigrationAction,\n  MigrationAction,\n  SpokeChainKey,\n  TxReturnType,\n  UnifiedBnUSDMigrateAction,\n} from '@sodax/sdk';\nimport { useQueryClient } from '@tanstack/react-query';\nimport { useSodaxContext } from '../shared/useSodaxContext.js';\nimport type { MutationHookParams } from '../shared/types.js';\nimport { useSafeMutation, type SafeUseMutationResult } from '../shared/useSafeMutation.js';\nimport { unwrapResult } from '../shared/unwrapResult.js';\n\n/**\n * Mutation variables for {@link useMigrationApprove}. The SDK's `approve` accepts a union of\n * action wrappers (Icx-revert OR bnUSD bidirectional) plus a separate `'migrate' | 'revert'`\n * discriminator. Both ride along in `TVars` here so the hook stays a pure pass-through.\n */\nexport type UseMigrationApproveVars<K extends SpokeChainKey = SpokeChainKey> = (\n  | Omit<IcxRevertMigrationAction<false>, 'raw'>\n  | Omit<UnifiedBnUSDMigrateAction<K, false>, 'raw'>\n) & { action: MigrationAction };\n\n/**\n * React hook for approving token spending on a migration intent. Required before:\n * - SODA → ICX revert (consumes SODA on Sonic via the user's hub router)\n * - bnUSD migrations on EVM/Stellar source chains (consumes the source bnUSD via asset manager)\n *\n * NOT required for ICX → SODA forward migrations or BALN migrations (both originate on Icon\n * which doesn't use ERC-20 allowances).\n *\n * Throws on SDK failure so React Query's native error model engages (`isError`, `error`,\n * `onError`, `retry`). Returns the unwrapped tx return value on success.\n */\nexport function useMigrationApprove<K extends SpokeChainKey = SpokeChainKey>({\n  mutationOptions,\n}: MutationHookParams<TxReturnType<K, false>, UseMigrationApproveVars<K>> = {}): SafeUseMutationResult<\n  TxReturnType<K, false>,\n  Error,\n  UseMigrationApproveVars<K>\n> {\n  const { sodax } = useSodaxContext();\n  const queryClient = useQueryClient();\n\n  return useSafeMutation<TxReturnType<K, false>, Error, UseMigrationApproveVars<K>>({\n    mutationKey: ['migrate', 'approve'],\n    ...mutationOptions,\n    mutationFn: async ({ action, ...actionParams }) =>\n      unwrapResult(\n        await sodax.migration.approve(\n          { ...actionParams, raw: false } as\n            | IcxRevertMigrationAction<false>\n            | UnifiedBnUSDMigrateAction<K, false>,\n          action,\n        ),\n      ),\n    onSuccess: async (data, vars, ctx) => {\n      // Broad — wipes all migrate allowance variants. The mutation can't know exactly which\n      // (action, params) tuple the consumer was reading, so refetch all and let the active\n      // queries reconcile.\n      queryClient.invalidateQueries({ queryKey: ['migrate', 'allowance'] });\n      await mutationOptions?.onSuccess?.(data, vars, ctx);\n    },\n  });\n}\n","// packages/dapp-kit/src/hooks/migrate/useMigrationAllowance.ts\nimport type {\n  BalnMigrateParams,\n  IcxCreateRevertMigrationParams,\n  IcxMigrateParams,\n  MigrationAction,\n  SpokeChainKey,\n  UnifiedBnUSDMigrateParams,\n} from '@sodax/sdk';\nimport { useQuery, type UseQueryResult } from '@tanstack/react-query';\nimport { useSodaxContext } from '../shared/useSodaxContext.js';\nimport type { ReadHookParams } from '../shared/types.js';\n\n/**\n * Domain inputs for {@link useMigrationAllowance}. `params` is the underlying migration params\n * (NOT the action wrapper — no `walletProvider`/`raw`); `action` is the `'migrate' | 'revert'`\n * discriminator the SDK uses to pick the right allowance check path.\n *\n * For ICX forward migration (`migrate`, params={IcxMigrateParams}) and BALN migration the SDK\n * always returns `true` (Icon has no ERC-20-style allowance) — but the hook still works there\n * for code-uniformity at the call site.\n */\nexport type UseMigrationAllowanceInputs<K extends SpokeChainKey = SpokeChainKey> = {\n  params:\n    | IcxMigrateParams\n    | IcxCreateRevertMigrationParams\n    | UnifiedBnUSDMigrateParams<K>\n    | BalnMigrateParams\n    | undefined;\n  action: MigrationAction | undefined;\n};\n\nexport type UseMigrationAllowanceParams<K extends SpokeChainKey = SpokeChainKey> = ReadHookParams<\n  boolean,\n  UseMigrationAllowanceInputs<K>\n>;\n\nconst REFETCH_INTERVAL_MS = 2_000;\n\n/**\n * React hook to check if migration spending is approved.\n *\n * Returns `false` when params are missing (so the call site can disable the action button).\n * Hook lifecycle (`enabled`, `queryKey`, `queryFn`) is owned internally; consumers can override\n * other React Query knobs via `queryOptions`.\n */\nexport function useMigrationAllowance<K extends SpokeChainKey = SpokeChainKey>({\n  params,\n  queryOptions,\n}: UseMigrationAllowanceParams<K> = {}): UseQueryResult<boolean, Error> {\n  const { sodax } = useSodaxContext();\n  const migrationParams = params?.params;\n  const action = params?.action;\n\n  return useQuery<boolean, Error>({\n    // Extract the (chain, owner, token, amount) tuple that actually scopes the allowance —\n    // raw-object keys break per Rule 4 (bigints) and churn on every render.\n    queryKey: [\n      'migrate',\n      'allowance',\n      action,\n      migrationParams?.srcChainKey,\n      migrationParams?.srcAddress,\n      migrationParams && 'srcbnUSD' in migrationParams ? migrationParams.srcbnUSD : undefined,\n      migrationParams?.amount?.toString(),\n    ],\n    queryFn: async () => {\n      if (!migrationParams || !action) return false;\n      const result = await sodax.migration.isAllowanceValid<K>(migrationParams, action);\n      return result.ok ? result.value : false;\n    },\n    enabled: !!migrationParams && !!action,\n    refetchInterval: REFETCH_INTERVAL_MS,\n    ...queryOptions,\n  });\n}\n","import type { PoolKey } from '@sodax/sdk';\nimport { useQuery, type UseQueryResult } from '@tanstack/react-query';\nimport { useSodaxContext } from '../shared/useSodaxContext.js';\nimport type { ReadHookParams } from '../shared/types.js';\n\nexport type UsePoolsParams = ReadHookParams<PoolKey[]>;\n\n/**\n * Loads the list of concentrated-liquidity pools known to the SDK config. The SDK's `getPools()`\n * is synchronous in v2 (no network), so this hook caches indefinitely by default.\n */\nexport function usePools({ queryOptions }: UsePoolsParams = {}): UseQueryResult<PoolKey[], Error> {\n  const { sodax } = useSodaxContext();\n\n  return useQuery<PoolKey[], Error>({\n    queryKey: ['dex', 'pools'],\n    queryFn: () => sodax.dex.clService.getPools(),\n    staleTime: Number.POSITIVE_INFINITY,\n    ...queryOptions,\n  });\n}\n","import type { PoolData, PoolKey } from '@sodax/sdk';\nimport { useQuery, type UseQueryResult } from '@tanstack/react-query';\nimport { useSodaxContext } from '../shared/useSodaxContext.js';\nimport type { ReadHookParams } from '../shared/types.js';\n\nexport type UsePoolDataParams = ReadHookParams<PoolData, { poolKey: PoolKey | null }>;\n\n/**\n * React hook to fetch on-chain pool data (sqrt price, tick, fees, token info, etc.) for a given\n * pool key. Reads via the hub `publicClient`. Disabled when `poolKey` is null.\n */\nexport function usePoolData({ params, queryOptions }: UsePoolDataParams = {}): UseQueryResult<PoolData, Error> {\n  const { sodax } = useSodaxContext();\n  const poolKey = params?.poolKey ?? null;\n\n  return useQuery<PoolData, Error>({\n    queryKey: ['dex', 'poolData', poolKey],\n    queryFn: async () => {\n      if (!poolKey) {\n        throw new Error('Pool key is required');\n      }\n      const result = await sodax.dex.clService.getPoolData(poolKey, sodax.hubProvider.publicClient);\n      if (!result.ok) throw result.error;\n      return result.value;\n    },\n    enabled: poolKey !== null,\n    staleTime: 10_000,\n    refetchInterval: 30_000,\n    ...queryOptions,\n  });\n}\n","import type { PoolData, PoolKey } from '@sodax/sdk';\nimport type { SpokeChainKey } from '@sodax/sdk';\nimport { useQuery, type UseQueryResult } from '@tanstack/react-query';\nimport { erc20Abi } from 'viem';\nimport { useSodaxContext } from '../shared/useSodaxContext.js';\nimport type { ReadHookParams } from '../shared/types.js';\n\nexport type UsePoolBalancesResponse = {\n  token0Balance: bigint;\n  token1Balance: bigint;\n};\n\nexport type UsePoolBalancesParams = ReadHookParams<\n  UsePoolBalancesResponse,\n  {\n    poolData: PoolData | null;\n    poolKey: PoolKey | null;\n    spokeChainKey: SpokeChainKey | undefined;\n    userAddress: string | undefined;\n  }\n>;\n\n/**\n * React hook to query the user's hub-side deposit balances for both pool tokens. Derives the hub\n * wallet once and reads both pool-token balances in parallel via the hub `publicClient`.\n */\nexport function usePoolBalances({\n  params,\n  queryOptions,\n}: UsePoolBalancesParams = {}): UseQueryResult<UsePoolBalancesResponse, Error> {\n  const { sodax } = useSodaxContext();\n  const poolData = params?.poolData ?? null;\n  const poolKey = params?.poolKey ?? null;\n  const spokeChainKey = params?.spokeChainKey;\n  const userAddress = params?.userAddress;\n\n  return useQuery<UsePoolBalancesResponse, Error>({\n    queryKey: ['dex', 'poolBalances', poolData?.poolId, spokeChainKey, userAddress],\n    queryFn: async () => {\n      if (!poolData || !poolKey || !spokeChainKey || !userAddress) {\n        throw new Error('poolData, poolKey, spokeChainKey, and userAddress are required');\n      }\n\n      const hubWallet = await sodax.hubProvider.getUserHubWalletAddress(userAddress, spokeChainKey);\n\n      const [token0Balance, token1Balance] = await Promise.all([\n        sodax.hubProvider.publicClient.readContract({\n          address: poolData.token0.address,\n          abi: erc20Abi,\n          functionName: 'balanceOf',\n          args: [hubWallet],\n        }),\n        sodax.hubProvider.publicClient.readContract({\n          address: poolData.token1.address,\n          abi: erc20Abi,\n          functionName: 'balanceOf',\n          args: [hubWallet],\n        }),\n      ]);\n\n      return { token0Balance, token1Balance };\n    },\n    enabled: !!poolData && !!poolKey && !!spokeChainKey && !!userAddress,\n    staleTime: 5_000,\n    refetchInterval: 10_000,\n    ...queryOptions,\n  });\n}\n","import type { ClPositionInfo, PoolKey } from '@sodax/sdk';\nimport { useQuery, type UseQueryResult } from '@tanstack/react-query';\nimport { useSodaxContext } from '../shared/useSodaxContext.js';\nimport type { ReadHookParams } from '../shared/types.js';\n\nexport type UsePositionInfoResponse = {\n  positionInfo: ClPositionInfo;\n  isValid: boolean;\n};\n\nexport type UsePositionInfoParams = ReadHookParams<\n  UsePositionInfoResponse,\n  {\n    tokenId: string | null;\n    poolKey: PoolKey | null;\n  }\n>;\n\n/**\n * React hook to fetch a CL position by NFT token id and validate it against an expected pool key.\n * Reads via the hub `publicClient`. Disabled when `tokenId` or `poolKey` is missing.\n */\nexport function usePositionInfo({\n  params,\n  queryOptions,\n}: UsePositionInfoParams = {}): UseQueryResult<UsePositionInfoResponse, Error> {\n  const { sodax } = useSodaxContext();\n  const tokenId = params?.tokenId ?? null;\n  const poolKey = params?.poolKey ?? null;\n\n  return useQuery<UsePositionInfoResponse, Error>({\n    queryKey: ['dex', 'positionInfo', tokenId, poolKey],\n    queryFn: async () => {\n      if (!tokenId || !poolKey) {\n        throw new Error('Token ID and pool key are required');\n      }\n\n      const infoResult = await sodax.dex.clService.getPositionInfo(BigInt(tokenId), sodax.hubProvider.publicClient);\n      if (!infoResult.ok) throw infoResult.error;\n      const info = infoResult.value;\n\n      const isValid =\n        info.poolKey.currency0.toLowerCase() === poolKey.currency0.toLowerCase() &&\n        info.poolKey.currency1.toLowerCase() === poolKey.currency1.toLowerCase() &&\n        info.poolKey.fee === poolKey.fee;\n\n      return { positionInfo: info, isValid };\n    },\n    enabled: tokenId !== null && tokenId !== '' && poolKey !== null,\n    staleTime: 10_000,\n    ...queryOptions,\n  });\n}\n","// packages/dapp-kit/src/hooks/dex/useDexDeposit.ts\nimport type { AssetDepositAction, SpokeChainKey, TxHashPair } from '@sodax/sdk';\nimport { useQueryClient } from '@tanstack/react-query';\nimport { useSodaxContext } from '../shared/useSodaxContext.js';\nimport type { MutationHookParams } from '../shared/types.js';\nimport { useSafeMutation, type SafeUseMutationResult } from '../shared/useSafeMutation.js';\nimport { unwrapResult } from '../shared/unwrapResult.js';\n\n/**\n * Mutation variables for {@link useDexDeposit}. Generic over `K extends SpokeChainKey` (defaults\n * to the full union). Sophisticated callers can lock K at the hook call site to narrow the\n * `walletProvider` and `params.srcChainKey` types.\n */\nexport type UseDexDepositVars<K extends SpokeChainKey = SpokeChainKey> = Omit<AssetDepositAction<K, false>, 'raw'>;\n\n/**\n * React hook for depositing an asset into a DEX pool.\n *\n * Throws on SDK failure so React Query's native error model engages (`isError`, `error`,\n * `onError`, `retry`). Returns the unwrapped `TxHashPair` on success.\n *\n * @example\n * ```tsx\n * const walletProvider = useWalletProvider({ xChainId: chainKey });\n * const { mutateAsync: deposit } = useDexDeposit();\n * try {\n *   const { spokeTxHash, hubTxHash } = await deposit({ params, walletProvider });\n * } catch (e) {\n *   // surfaced via mutation.error / onError\n * }\n * ```\n */\nexport function useDexDeposit<K extends SpokeChainKey = SpokeChainKey>({\n  mutationOptions,\n}: MutationHookParams<TxHashPair, UseDexDepositVars<K>> = {}): SafeUseMutationResult<\n  TxHashPair,\n  Error,\n  UseDexDepositVars<K>\n> {\n  const { sodax } = useSodaxContext();\n  const queryClient = useQueryClient();\n\n  return useSafeMutation<TxHashPair, Error, UseDexDepositVars<K>>({\n    mutationKey: ['dex', 'deposit'],\n    ...mutationOptions,\n    mutationFn: async vars => unwrapResult(await sodax.dex.assetService.deposit({ ...vars, raw: false })),\n    onSuccess: async (data, vars, ctx) => {\n      const { params } = vars;\n      queryClient.invalidateQueries({ queryKey: ['dex', 'poolBalances', params.srcChainKey, params.srcAddress] });\n      queryClient.invalidateQueries({\n        queryKey: ['dex', 'allowance', params.srcChainKey, params.asset, params.amount.toString()],\n      });\n      queryClient.invalidateQueries({ queryKey: ['shared', 'xBalances', params.srcChainKey] });\n      await mutationOptions?.onSuccess?.(data, vars, ctx);\n    },\n  });\n}\n","// packages/dapp-kit/src/hooks/dex/useDexWithdraw.ts\nimport type { AssetWithdrawAction, SpokeChainKey, TxHashPair } from '@sodax/sdk';\nimport { useQueryClient } from '@tanstack/react-query';\nimport { useSodaxContext } from '../shared/useSodaxContext.js';\nimport type { MutationHookParams } from '../shared/types.js';\nimport { useSafeMutation, type SafeUseMutationResult } from '../shared/useSafeMutation.js';\nimport { unwrapResult } from '../shared/unwrapResult.js';\n\n/**\n * Mutation variables for {@link useDexWithdraw}. Generic over `K extends SpokeChainKey` (defaults\n * to the full union). Sophisticated callers can lock K at the hook call site to narrow the\n * `walletProvider` and `params.srcChainKey` types.\n */\nexport type UseDexWithdrawVars<K extends SpokeChainKey = SpokeChainKey> = Omit<AssetWithdrawAction<K, false>, 'raw'>;\n\n/**\n * React hook for withdrawing an asset from a DEX pool.\n *\n * Throws on SDK failure so React Query's native error model engages (`isError`, `error`,\n * `onError`, `retry`). Returns the unwrapped `TxHashPair` on success.\n */\nexport function useDexWithdraw<K extends SpokeChainKey = SpokeChainKey>({\n  mutationOptions,\n}: MutationHookParams<TxHashPair, UseDexWithdrawVars<K>> = {}): SafeUseMutationResult<\n  TxHashPair,\n  Error,\n  UseDexWithdrawVars<K>\n> {\n  const { sodax } = useSodaxContext();\n  const queryClient = useQueryClient();\n\n  return useSafeMutation<TxHashPair, Error, UseDexWithdrawVars<K>>({\n    mutationKey: ['dex', 'withdraw'],\n    ...mutationOptions,\n    mutationFn: async vars => unwrapResult(await sodax.dex.assetService.withdraw({ ...vars, raw: false })),\n    onSuccess: async (data, vars, ctx) => {\n      const { params } = vars;\n      queryClient.invalidateQueries({ queryKey: ['dex', 'poolBalances', params.srcChainKey, params.srcAddress] });\n      queryClient.invalidateQueries({ queryKey: ['shared', 'xBalances', params.srcChainKey] });\n      await mutationOptions?.onSuccess?.(data, vars, ctx);\n    },\n  });\n}\n","import type { CreateAssetDepositParams } from '@sodax/sdk';\nimport type { SpokeChainKey } from '@sodax/sdk';\nimport { useQuery, type UseQueryResult } from '@tanstack/react-query';\nimport { useSodaxContext } from '../shared/useSodaxContext.js';\nimport type { ReadHookParams } from '../shared/types.js';\n\nexport type UseDexAllowanceParams<K extends SpokeChainKey = SpokeChainKey> = ReadHookParams<\n  boolean,\n  {\n    payload: CreateAssetDepositParams<K> | undefined;\n  }\n>;\n\n/**\n * React hook to check whether the user has approved sufficient token allowance (or established a\n * trustline, on Stellar) for a DEX deposit. Read-only — calls `assetService.isAllowanceValid`\n * with `raw: true` so no `walletProvider` is required.\n */\nexport function useDexAllowance<K extends SpokeChainKey = SpokeChainKey>({\n  params,\n  queryOptions,\n}: UseDexAllowanceParams<K> = {}): UseQueryResult<boolean, Error> {\n  const { sodax } = useSodaxContext();\n  const payload = params?.payload;\n\n  return useQuery<boolean, Error>({\n    queryKey: ['dex', 'allowance', payload?.srcChainKey, payload?.asset, payload?.amount?.toString()],\n    queryFn: async () => {\n      if (!payload) {\n        throw new Error('Params are required');\n      }\n      const result = await sodax.dex.assetService.isAllowanceValid({ params: payload, raw: true });\n      if (!result.ok) throw result.error;\n      return result.value;\n    },\n    enabled: !!payload,\n    refetchInterval: 5_000,\n    gcTime: 0,\n    ...queryOptions,\n  });\n}\n","// packages/dapp-kit/src/hooks/dex/useDexApprove.ts\nimport type { AssetDepositAction, SpokeChainKey, TxReturnType } from '@sodax/sdk';\nimport { useQueryClient } from '@tanstack/react-query';\nimport { useSodaxContext } from '../shared/useSodaxContext.js';\nimport type { MutationHookParams } from '../shared/types.js';\nimport { useSafeMutation, type SafeUseMutationResult } from '../shared/useSafeMutation.js';\nimport { unwrapResult } from '../shared/unwrapResult.js';\n\n/**\n * Mutation variables for {@link useDexApprove}. Generic over `K extends SpokeChainKey` (defaults\n * to the full union). Sophisticated callers can lock K at the hook call site to narrow the\n * `walletProvider` and `params.srcChainKey` types.\n */\nexport type UseDexApproveVars<K extends SpokeChainKey = SpokeChainKey> = Omit<AssetDepositAction<K, false>, 'raw'>;\n\n/**\n * React hook for approving ERC-20 token spending (or trustline establishment) for a DEX deposit.\n *\n * Throws on SDK failure so React Query's native error model engages (`isError`, `error`,\n * `onError`, `retry`). Returns the unwrapped tx return value on success.\n */\nexport function useDexApprove<K extends SpokeChainKey = SpokeChainKey>({\n  mutationOptions,\n}: MutationHookParams<TxReturnType<K, false>, UseDexApproveVars<K>> = {}): SafeUseMutationResult<\n  TxReturnType<K, false>,\n  Error,\n  UseDexApproveVars<K>\n> {\n  const { sodax } = useSodaxContext();\n  const queryClient = useQueryClient();\n\n  return useSafeMutation<TxReturnType<K, false>, Error, UseDexApproveVars<K>>({\n    mutationKey: ['dex', 'approve'],\n    ...mutationOptions,\n    mutationFn: async vars => unwrapResult(await sodax.dex.assetService.approve({ ...vars, raw: false })),\n    onSuccess: async (data, vars, ctx) => {\n      const { params } = vars;\n      queryClient.invalidateQueries({\n        queryKey: ['dex', 'allowance', params.srcChainKey, params.asset, params.amount.toString()],\n      });\n      await mutationOptions?.onSuccess?.(data, vars, ctx);\n    },\n  });\n}\n","import { useState, useEffect, useCallback, useMemo } from 'react';\nimport { ClService, type PoolData } from '@sodax/sdk';\n\nexport type UseLiquidityAmountsResult = {\n  liquidityToken0Amount: string;\n  liquidityToken1Amount: string;\n  lastEditedToken: 'token0' | 'token1' | null;\n  setLiquidityToken0Amount: (value: string) => void;\n  setLiquidityToken1Amount: (value: string) => void;\n  handleToken0AmountChange: (value: string) => void;\n  handleToken1AmountChange: (value: string) => void;\n};\n\n/**\n * Hook for calculating concentrated-liquidity amounts based on the price range. Pure state +\n * math; no SDK calls beyond the static {@link ClService} helpers.\n */\nexport function useLiquidityAmounts(\n  minPrice: string,\n  maxPrice: string,\n  poolData: PoolData | null,\n): UseLiquidityAmountsResult {\n  const [liquidityToken0Amount, setLiquidityToken0Amount] = useState<string>('');\n  const [liquidityToken1Amount, setLiquidityToken1Amount] = useState<string>('');\n  const [lastEditedToken, setLastEditedToken] = useState<'token0' | 'token1' | null>(null);\n\n  const { minPriceNum, maxPriceNum, isValidPriceRange } = useMemo(() => {\n    const parsedMin = Number.parseFloat(minPrice);\n    const parsedMax = Number.parseFloat(maxPrice);\n    const isValid = parsedMin > 0 && parsedMax > 0 && parsedMin < parsedMax;\n    return { minPriceNum: parsedMin, maxPriceNum: parsedMax, isValidPriceRange: isValid };\n  }, [minPrice, maxPrice]);\n\n  const { tickLower, tickUpper, currentTick } = useMemo(() => {\n    if (!poolData || !isValidPriceRange) {\n      return { tickLower: null, tickUpper: null, currentTick: null };\n    }\n    try {\n      const lower = ClService.priceToTick(minPriceNum, poolData.token0, poolData.token1, poolData.tickSpacing);\n      const upper = ClService.priceToTick(maxPriceNum, poolData.token0, poolData.token1, poolData.tickSpacing);\n      return { tickLower: lower, tickUpper: upper, currentTick: BigInt(poolData.currentTick) };\n    } catch (err) {\n      console.error('Failed to calculate ticks:', err);\n      return { tickLower: null, tickUpper: null, currentTick: null };\n    }\n  }, [minPriceNum, maxPriceNum, poolData, isValidPriceRange]);\n\n  const handleToken0AmountChange = useCallback(\n    (value: string): void => {\n      setLiquidityToken0Amount(value);\n      setLastEditedToken('token0');\n\n      if (!value || !poolData || !tickLower || !tickUpper || !currentTick) return;\n      const amount0 = Number.parseFloat(value);\n      if (amount0 <= 0 || !isValidPriceRange) return;\n\n      try {\n        const amount0BigInt = BigInt(Math.floor(amount0 * 10 ** poolData.token0.decimals));\n        const amount1BigInt = ClService.calculateAmount1FromAmount0(\n          amount0BigInt,\n          tickLower,\n          tickUpper,\n          currentTick,\n          poolData.sqrtPriceX96,\n        );\n        const amount1 = Number(amount1BigInt) / 10 ** poolData.token1.decimals;\n        setLiquidityToken1Amount(amount1.toFixed(6));\n      } catch (err) {\n        console.error('Failed to calculate token1 amount:', err);\n      }\n    },\n    [poolData, tickLower, tickUpper, currentTick, isValidPriceRange],\n  );\n\n  const handleToken1AmountChange = useCallback(\n    (value: string): void => {\n      setLiquidityToken1Amount(value);\n      setLastEditedToken('token1');\n\n      if (!value || !poolData || !tickLower || !tickUpper || !currentTick) return;\n      const amount1 = Number.parseFloat(value);\n      if (amount1 <= 0 || !isValidPriceRange) return;\n\n      try {\n        const amount1BigInt = BigInt(Math.floor(amount1 * 10 ** poolData.token1.decimals));\n        const amount0BigInt = ClService.calculateAmount0FromAmount1(\n          amount1BigInt,\n          tickLower,\n          tickUpper,\n          currentTick,\n          poolData.sqrtPriceX96,\n        );\n        const amount0 = Number(amount0BigInt) / 10 ** poolData.token0.decimals;\n        setLiquidityToken0Amount(amount0.toFixed(6));\n      } catch (err) {\n        console.error('Failed to calculate token0 amount:', err);\n      }\n    },\n    [poolData, tickLower, tickUpper, currentTick, isValidPriceRange],\n  );\n\n  useEffect(() => {\n    if (!poolData || !tickLower || !tickUpper || !lastEditedToken || !isValidPriceRange) return;\n    if (lastEditedToken === 'token0' && liquidityToken0Amount) {\n      handleToken0AmountChange(liquidityToken0Amount);\n    } else if (lastEditedToken === 'token1' && liquidityToken1Amount) {\n      handleToken1AmountChange(liquidityToken1Amount);\n    }\n  }, [\n    poolData,\n    lastEditedToken,\n    liquidityToken0Amount,\n    liquidityToken1Amount,\n    handleToken0AmountChange,\n    handleToken1AmountChange,\n    tickLower,\n    tickUpper,\n    isValidPriceRange,\n  ]);\n\n  return {\n    liquidityToken0Amount,\n    liquidityToken1Amount,\n    lastEditedToken,\n    setLiquidityToken0Amount,\n    setLiquidityToken1Amount,\n    handleToken0AmountChange,\n    handleToken1AmountChange,\n  };\n}\n","// packages/dapp-kit/src/hooks/dex/useSupplyLiquidity.ts\nimport type {\n  ClIncreaseLiquidityParams,\n  ClSupplyParams,\n  GetWalletProviderType,\n  SpokeChainKey,\n  TxHashPair,\n} from '@sodax/sdk';\nimport { useQueryClient } from '@tanstack/react-query';\nimport { useSodaxContext } from '../shared/useSodaxContext.js';\nimport type { UseCreateSupplyLiquidityParamsResult } from './useCreateSupplyLiquidityParams.js';\nimport type { MutationHookParams } from '../shared/types.js';\nimport { useSafeMutation, type SafeUseMutationResult } from '../shared/useSafeMutation.js';\nimport { unwrapResult } from '../shared/unwrapResult.js';\n\n/**\n * Mutation variables for {@link useSupplyLiquidity}. Generic over `K extends SpokeChainKey`\n * (defaults to the full union). The hook fans out internally to either\n * `clService.increaseLiquidity` (when `params.tokenId` + `params.isValidPosition` are present) or\n * `clService.supplyLiquidity` (mint a new position).\n */\nexport type UseSupplyLiquidityVars<K extends SpokeChainKey = SpokeChainKey> = {\n  params: UseCreateSupplyLiquidityParamsResult & { srcChainKey: K; srcAddress: string };\n  walletProvider: GetWalletProviderType<K>;\n  /** Optional relay timeout in ms (default 60_000) */\n  timeout?: number;\n};\n\n/**\n * React hook for supplying liquidity to a concentrated-liquidity pool. If the input vars include a\n * valid `tokenId` for an existing position, the hook calls `increaseLiquidity`; otherwise it mints\n * a new position via `supplyLiquidity`.\n *\n * Throws on SDK failure so React Query's native error model engages (`isError`, `error`,\n * `onError`, `retry`). Returns the unwrapped `TxHashPair` on success.\n */\nexport function useSupplyLiquidity<K extends SpokeChainKey = SpokeChainKey>({\n  mutationOptions,\n}: MutationHookParams<TxHashPair, UseSupplyLiquidityVars<K>> = {}): SafeUseMutationResult<\n  TxHashPair,\n  Error,\n  UseSupplyLiquidityVars<K>\n> {\n  const { sodax } = useSodaxContext();\n  const queryClient = useQueryClient();\n\n  return useSafeMutation<TxHashPair, Error, UseSupplyLiquidityVars<K>>({\n    mutationKey: ['dex', 'supplyLiquidity'],\n    ...mutationOptions,\n    mutationFn: async ({ params, walletProvider, timeout }) => {\n      const sharedParams = {\n        srcChainKey: params.srcChainKey,\n        srcAddress: params.srcAddress as ClSupplyParams<K>['srcAddress'],\n        poolKey: params.poolKey,\n        tickLower: params.tickLower,\n        tickUpper: params.tickUpper,\n        liquidity: params.liquidity,\n        amount0Max: params.amount0Max,\n        amount1Max: params.amount1Max,\n        sqrtPriceX96: params.sqrtPriceX96,\n      } satisfies ClSupplyParams<K>;\n\n      if (params.tokenId !== undefined && params.isValidPosition) {\n        const increaseParams: ClIncreaseLiquidityParams<K> = {\n          ...sharedParams,\n          tokenId: typeof params.tokenId === 'bigint' ? params.tokenId : BigInt(params.tokenId),\n        };\n        return unwrapResult(\n          await sodax.dex.clService.increaseLiquidity({ params: increaseParams, raw: false, walletProvider, timeout }),\n        );\n      }\n\n      return unwrapResult(\n        await sodax.dex.clService.supplyLiquidity({ params: sharedParams, raw: false, walletProvider, timeout }),\n      );\n    },\n    onSuccess: async (data, vars, ctx) => {\n      const { params } = vars;\n      // Increase-liquidity branch knows the affected position — scope to it. Mint-new-position\n      // branch creates a fresh tokenId that's only known after the tx, so a bare invalidation is\n      // the right fallback (refetches all positions, including the new one once it lands).\n      if (params.tokenId !== undefined && params.isValidPosition) {\n        // `usePositionInfo` keys by string tokenId — coerce here to match its shape regardless of\n        // whether the caller passed bigint or string.\n        const tokenIdStr = String(params.tokenId);\n        queryClient.invalidateQueries({ queryKey: ['dex', 'positionInfo', tokenIdStr, params.poolKey] });\n      } else {\n        queryClient.invalidateQueries({ queryKey: ['dex', 'positionInfo'] });\n      }\n      queryClient.invalidateQueries({ queryKey: ['dex', 'poolData', params.poolKey] });\n      queryClient.invalidateQueries({ queryKey: ['dex', 'poolBalances', params.srcChainKey, params.srcAddress] });\n      queryClient.invalidateQueries({ queryKey: ['shared', 'xBalances', params.srcChainKey] });\n      await mutationOptions?.onSuccess?.(data, vars, ctx);\n    },\n  });\n}\n","// packages/dapp-kit/src/hooks/dex/useDecreaseLiquidity.ts\nimport type { ClLiquidityDecreaseLiquidityAction, SpokeChainKey, TxHashPair } from '@sodax/sdk';\nimport { useQueryClient } from '@tanstack/react-query';\nimport { useSodaxContext } from '../shared/useSodaxContext.js';\nimport type { MutationHookParams } from '../shared/types.js';\nimport { useSafeMutation, type SafeUseMutationResult } from '../shared/useSafeMutation.js';\nimport { unwrapResult } from '../shared/unwrapResult.js';\n\n/**\n * Mutation variables for {@link useDecreaseLiquidity}. Generic over `K extends SpokeChainKey`\n * (defaults to the full union). Sophisticated callers can lock K at the hook call site to narrow\n * the `walletProvider` and `params.srcChainKey` types.\n */\nexport type UseDecreaseLiquidityVars<K extends SpokeChainKey = SpokeChainKey> = Omit<\n  ClLiquidityDecreaseLiquidityAction<K, false>,\n  'raw'\n>;\n\n/**\n * React hook for decreasing liquidity in an existing concentrated-liquidity position.\n *\n * Throws on SDK failure so React Query's native error model engages (`isError`, `error`,\n * `onError`, `retry`). Returns the unwrapped `TxHashPair` on success.\n */\nexport function useDecreaseLiquidity<K extends SpokeChainKey = SpokeChainKey>({\n  mutationOptions,\n}: MutationHookParams<TxHashPair, UseDecreaseLiquidityVars<K>> = {}): SafeUseMutationResult<\n  TxHashPair,\n  Error,\n  UseDecreaseLiquidityVars<K>\n> {\n  const { sodax } = useSodaxContext();\n  const queryClient = useQueryClient();\n\n  return useSafeMutation<TxHashPair, Error, UseDecreaseLiquidityVars<K>>({\n    mutationKey: ['dex', 'decreaseLiquidity'],\n    ...mutationOptions,\n    mutationFn: async vars => unwrapResult(await sodax.dex.clService.decreaseLiquidity({ ...vars, raw: false })),\n    onSuccess: async (data, vars, ctx) => {\n      const { params } = vars;\n      // Decrease always targets a known position — scope invalidation to (tokenId, poolKey) instead\n      // of wiping all positions. `usePositionInfo` keys by string tokenId, so stringify the bigint\n      // here to keep the structural match.\n      queryClient.invalidateQueries({\n        queryKey: ['dex', 'positionInfo', params.tokenId.toString(), params.poolKey],\n      });\n      queryClient.invalidateQueries({ queryKey: ['dex', 'poolData', params.poolKey] });\n      queryClient.invalidateQueries({ queryKey: ['dex', 'poolBalances', params.srcChainKey, params.srcAddress] });\n      await mutationOptions?.onSuccess?.(data, vars, ctx);\n    },\n  });\n}\n","import type {\n  UseCreateDecreaseLiquidityParamsProps,\n  UseCreateDepositParamsProps,\n  UseCreateSupplyLiquidityParamsProps,\n  UseCreateSupplyLiquidityParamsResult,\n  UseCreateWithdrawParamsProps,\n} from '@/hooks/dex/index.js';\nimport {\n  ClService,\n  type CreateAssetWithdrawParams,\n  type ClDecreaseLiquidityParams,\n  type CreateAssetDepositParams,\n} from '@sodax/sdk';\nimport type { SpokeChainKey } from '@sodax/sdk';\nimport { parseUnits } from 'viem';\n\n/**\n * Subset of {@link CreateAssetDepositParams} produced by {@link createDepositParamsProps}.\n * Callers add `srcChainKey` + `srcAddress` at the mutation call site.\n */\nexport type DepositParamsCore = Omit<CreateAssetDepositParams<SpokeChainKey>, 'srcChainKey' | 'srcAddress'>;\n\n/**\n * Subset of {@link CreateAssetWithdrawParams} produced by {@link createWithdrawParamsProps}.\n * Callers add `srcChainKey` + `srcAddress` at the mutation call site.\n */\nexport type WithdrawParamsCore = Omit<CreateAssetWithdrawParams<SpokeChainKey>, 'srcChainKey' | 'srcAddress'>;\n\n/**\n * Subset of {@link ClDecreaseLiquidityParams} produced by {@link createDecreaseLiquidityParamsProps}.\n * Callers add `srcChainKey` + `srcAddress` at the mutation call site.\n */\nexport type DecreaseLiquidityParamsCore = Omit<\n  ClDecreaseLiquidityParams<SpokeChainKey>,\n  'srcChainKey' | 'srcAddress'\n>;\n\nexport function createDecreaseLiquidityParamsProps({\n  poolKey,\n  tokenId,\n  percentage,\n  positionInfo,\n  slippageTolerance,\n}: UseCreateDecreaseLiquidityParamsProps): DecreaseLiquidityParamsCore {\n  const percentageNum = Number.parseFloat(String(percentage));\n  const slippage = Number.parseFloat(String(slippageTolerance));\n\n  if (percentageNum <= 0 || percentageNum > 100) {\n    throw new Error('Percentage must be between 0 and 100');\n  }\n\n  if (slippage <= 0 || slippage > 100) {\n    throw new Error('Slippage must be between 0 and 100');\n  }\n\n  // Calculate liquidity to remove based on percentage\n  const liquidityToRemove =\n    percentageNum === 100\n      ? positionInfo.liquidity\n      : (positionInfo.liquidity * BigInt(Math.floor(percentageNum * 100))) / 10000n;\n\n  // Calculate expected token amounts from this liquidity\n  const expectedAmount0 =\n    percentageNum === 100\n      ? positionInfo.amount0\n      : (positionInfo.amount0 * BigInt(Math.floor(percentageNum * 100))) / 10000n;\n  const expectedAmount1 =\n    percentageNum === 100\n      ? positionInfo.amount1\n      : (positionInfo.amount1 * BigInt(Math.floor(percentageNum * 100))) / 10000n;\n\n  // Apply slippage to minimum amounts\n  const slippageMultiplier = BigInt(Math.floor((100 - slippage) * 100));\n  const amount0Min = (expectedAmount0 * slippageMultiplier) / 10000n;\n  const amount1Min = (expectedAmount1 * slippageMultiplier) / 10000n;\n\n  return {\n    poolKey,\n    tokenId: BigInt(tokenId),\n    liquidity: liquidityToRemove,\n    amount0Min,\n    amount1Min,\n  };\n}\n\nexport function createDepositParamsProps({\n  tokenIndex,\n  amount,\n  poolData,\n  poolSpokeAssets,\n}: UseCreateDepositParamsProps): DepositParamsCore {\n  const amountNum = Number.parseFloat(String(amount));\n\n  if (!amount || amountNum <= 0) {\n    throw new Error('Amount must be greater than 0');\n  }\n\n  const token = tokenIndex === 0 ? poolData.token0 : poolData.token1;\n  const originalAsset = tokenIndex === 0 ? poolSpokeAssets.token0 : poolSpokeAssets.token1;\n\n  return {\n    asset: originalAsset.address,\n    // Use deposit token decimals (original asset) for correct unit parsing\n    amount: parseUnits(String(amount), originalAsset.decimals),\n    poolToken: token.address,\n  };\n}\n\nexport function createSupplyLiquidityParamsProps({\n  poolData,\n  poolKey,\n  minPrice,\n  maxPrice,\n  liquidityToken0Amount,\n  liquidityToken1Amount,\n  slippageTolerance,\n  positionId,\n  isValidPosition,\n}: UseCreateSupplyLiquidityParamsProps): UseCreateSupplyLiquidityParamsResult {\n  const slippage = Number.parseFloat(String(slippageTolerance));\n  if (slippage <= 0 || slippage > 100) {\n    throw new Error('Slippage must be between 0 and 100');\n  }\n\n  const minPriceNum = Number.parseFloat(minPrice);\n  const maxPriceNum = Number.parseFloat(maxPrice);\n  const amount0 = Number.parseFloat(liquidityToken0Amount);\n  const amount1 = Number.parseFloat(liquidityToken1Amount);\n\n  if (minPriceNum <= 0 || maxPriceNum <= 0 || amount0 <= 0 || amount1 <= 0) {\n    throw new Error('All values must be greater than 0');\n  }\n\n  if (minPriceNum >= maxPriceNum) {\n    throw new Error('Min price must be less than max price');\n  }\n\n  const amount0BigInt = parseUnits(liquidityToken0Amount, poolData.token0.decimals);\n  const amount1BigInt = parseUnits(liquidityToken1Amount, poolData.token1.decimals);\n\n  // Convert prices to ticks\n  const token0 = poolData.token0;\n  const token1 = poolData.token1;\n  const tickSpacing = poolData.tickSpacing;\n\n  const tickLower = ClService.priceToTick(minPriceNum, token0, token1, tickSpacing);\n  const tickUpper = ClService.priceToTick(maxPriceNum, token0, token1, tickSpacing);\n\n  // Calculate liquidity from full amounts (the desired deposit)\n  const liquidity = ClService.calculateLiquidityFromAmounts(\n    amount0BigInt,\n    amount1BigInt,\n    tickLower,\n    tickUpper,\n    BigInt(poolData.currentTick),\n  );\n\n  // Apply slippage to get max amounts — the ceiling the contract is allowed to pull.\n  // If price moves unfavorably, the contract may need slightly more tokens than expected.\n  const { amount0Max, amount1Max } = ClService.calculateMaxAmountsForSlippage(\n    liquidity,\n    tickLower,\n    tickUpper,\n    BigInt(poolData.currentTick),\n    poolData.sqrtPriceX96,\n    slippage,\n  );\n\n  const tokenId = positionId ? BigInt(positionId) : undefined;\n\n  return {\n    poolKey,\n    tickLower,\n    tickUpper,\n    liquidity,\n    amount0Max,\n    amount1Max,\n    sqrtPriceX96: poolData.sqrtPriceX96,\n    positionId,\n    isValidPosition,\n    tokenId,\n  };\n}\n\nexport function createWithdrawParamsProps({\n  tokenIndex,\n  amount,\n  poolData,\n  poolSpokeAssets,\n  dst,\n}: UseCreateWithdrawParamsProps): WithdrawParamsCore {\n  const amountNum = Number.parseFloat(String(amount));\n  if (!amount || amountNum <= 0) {\n    throw new Error('Please enter a valid amount');\n  }\n\n  const token = tokenIndex === 0 ? poolData.token0 : poolData.token1;\n  const originalAsset = tokenIndex === 0 ? poolSpokeAssets.token0 : poolSpokeAssets.token1;\n\n  return {\n    asset: originalAsset.address,\n    amount: parseUnits(String(amount), token.decimals),\n    poolToken: token.address,\n    dst,\n  };\n}\n","import { useMemo } from 'react';\nimport type { PoolData, PoolSpokeAssets } from '@sodax/sdk';\nimport { createDepositParamsProps, type DepositParamsCore } from '@/utils/dex-utils.js';\n\nexport type UseCreateDepositParamsProps = {\n  tokenIndex: 0 | 1;\n  amount: string | number;\n  poolData: PoolData;\n  poolSpokeAssets: PoolSpokeAssets;\n};\n\n/**\n * React hook to memoize the deposit-specific subset of {@link CreateAssetDepositParams}\n * (`{ asset, amount, poolToken, dst? }`). Callers add `srcChainKey` + `srcAddress` at the mutation\n * call site.\n */\nexport function useCreateDepositParams({\n  tokenIndex,\n  amount,\n  poolData,\n  poolSpokeAssets,\n}: UseCreateDepositParamsProps): DepositParamsCore | undefined {\n  return useMemo<DepositParamsCore | undefined>(() => {\n    if (!amount || Number.parseFloat(String(amount)) <= 0) {\n      return undefined;\n    }\n    return createDepositParamsProps({ tokenIndex, amount, poolData, poolSpokeAssets });\n  }, [tokenIndex, amount, poolData, poolSpokeAssets]);\n}\n","import { createSupplyLiquidityParamsProps } from '@/utils/dex-utils.js';\nimport type { ClSupplyParams, ClIncreaseLiquidityParams, PoolData, PoolKey } from '@sodax/sdk';\nimport type { SpokeChainKey } from '@sodax/sdk';\nimport { useMemo } from 'react';\n\nexport type UseCreateSupplyLiquidityParamsProps = {\n  poolData: PoolData;\n  poolKey: PoolKey;\n  minPrice: string;\n  maxPrice: string;\n  liquidityToken0Amount: string;\n  liquidityToken1Amount: string;\n  slippageTolerance: string | number;\n  positionId?: string | null;\n  isValidPosition?: boolean;\n};\n\n/**\n * Subset of {@link ClSupplyParams} / {@link ClIncreaseLiquidityParams} produced by\n * {@link useCreateSupplyLiquidityParams}. Callers add `srcChainKey` + `srcAddress` at the mutation\n * call site. `tokenId` and `isValidPosition` distinguish the mint-new vs increase-existing path.\n */\nexport type UseCreateSupplyLiquidityParamsResult = Omit<ClSupplyParams<SpokeChainKey>, 'srcChainKey' | 'srcAddress'> &\n  Omit<ClIncreaseLiquidityParams<SpokeChainKey>, 'srcChainKey' | 'srcAddress' | 'tokenId'> & {\n    tokenId?: string | bigint;\n    positionId?: string | null;\n    isValidPosition?: boolean;\n  };\n\n/**\n * React hook to memoize concentrated-liquidity supply parameters for a given pool. Returns the\n * pool/tick/liquidity/amount fields without `srcChainKey`/`srcAddress` — callers add those at the\n * mutation call site.\n */\nexport function useCreateSupplyLiquidityParams({\n  poolData,\n  poolKey,\n  minPrice,\n  maxPrice,\n  liquidityToken0Amount,\n  liquidityToken1Amount,\n  slippageTolerance,\n  positionId,\n  isValidPosition,\n}: UseCreateSupplyLiquidityParamsProps): UseCreateSupplyLiquidityParamsResult {\n  return useMemo<UseCreateSupplyLiquidityParamsResult>(() => {\n    return createSupplyLiquidityParamsProps({\n      poolData,\n      poolKey,\n      minPrice,\n      maxPrice,\n      liquidityToken0Amount,\n      liquidityToken1Amount,\n      slippageTolerance,\n      positionId,\n      isValidPosition,\n    });\n  }, [\n    minPrice,\n    maxPrice,\n    liquidityToken0Amount,\n    liquidityToken1Amount,\n    slippageTolerance,\n    poolData,\n    poolKey,\n    positionId,\n    isValidPosition,\n  ]);\n}\n","import { createDecreaseLiquidityParamsProps, type DecreaseLiquidityParamsCore } from '@/utils/dex-utils.js';\nimport type { ClPositionInfo, PoolKey } from '@sodax/sdk';\nimport { useMemo } from 'react';\n\nexport type UseCreateDecreaseLiquidityParamsProps = {\n  poolKey: PoolKey;\n  tokenId: string | bigint;\n  percentage: string | number;\n  positionInfo: ClPositionInfo;\n  slippageTolerance: string | number;\n};\n\n/**\n * React hook to memoize the decrease-liquidity-specific subset of {@link ClDecreaseLiquidityParams}\n * (`{ poolKey, tokenId, liquidity, amount0Min, amount1Min }`). Callers add `srcChainKey` +\n * `srcAddress` at the mutation call site.\n */\nexport function useCreateDecreaseLiquidityParams({\n  poolKey,\n  tokenId,\n  percentage,\n  positionInfo,\n  slippageTolerance,\n}: UseCreateDecreaseLiquidityParamsProps): DecreaseLiquidityParamsCore {\n  return useMemo<DecreaseLiquidityParamsCore>(() => {\n    return createDecreaseLiquidityParamsProps({ poolKey, tokenId, percentage, positionInfo, slippageTolerance });\n  }, [poolKey, tokenId, percentage, positionInfo, slippageTolerance]);\n}\n","import type { DestinationParamsType, PoolData, PoolSpokeAssets } from '@sodax/sdk';\nimport { useMemo } from 'react';\nimport { createWithdrawParamsProps, type WithdrawParamsCore } from '@/utils/dex-utils.js';\n\nexport type UseCreateWithdrawParamsProps = {\n  tokenIndex: 0 | 1;\n  amount: string | number;\n  poolData: PoolData;\n  poolSpokeAssets: PoolSpokeAssets;\n  dst?: DestinationParamsType;\n};\n\n/**\n * React hook to memoize the withdraw-specific subset of {@link CreateAssetWithdrawParams}\n * (`{ asset, amount, poolToken, dst? }`). Callers add `srcChainKey` + `srcAddress` at the mutation\n * call site.\n */\nexport function useCreateWithdrawParams({\n  tokenIndex,\n  amount,\n  poolData,\n  poolSpokeAssets,\n  dst,\n}: UseCreateWithdrawParamsProps): WithdrawParamsCore | undefined {\n  return useMemo<WithdrawParamsCore | undefined>(() => {\n    if (!amount || Number.parseFloat(String(amount)) <= 0) {\n      return undefined;\n    }\n    return createWithdrawParamsProps({ tokenIndex, amount, poolData, poolSpokeAssets, dst });\n  }, [tokenIndex, amount, poolData, poolSpokeAssets, dst]);\n}\n","// packages/dapp-kit/src/hooks/dex/useClaimRewards.ts\nimport type { ClLiquidityClaimRewardsAction, SpokeChainKey, TxHashPair } from '@sodax/sdk';\nimport { useQueryClient } from '@tanstack/react-query';\nimport { useSodaxContext } from '../shared/useSodaxContext.js';\nimport type { MutationHookParams } from '../shared/types.js';\nimport { useSafeMutation, type SafeUseMutationResult } from '../shared/useSafeMutation.js';\nimport { unwrapResult } from '../shared/unwrapResult.js';\n\n/**\n * Mutation variables for {@link useClaimRewards}. Generic over `K extends SpokeChainKey` (defaults\n * to the full union). Sophisticated callers can lock K at the hook call site to narrow the\n * `walletProvider` and `params.srcChainKey` types.\n */\nexport type UseClaimRewardsVars<K extends SpokeChainKey = SpokeChainKey> = Omit<\n  ClLiquidityClaimRewardsAction<K, false>,\n  'raw'\n>;\n\n/**\n * React hook for claiming accrued fees on a concentrated-liquidity position.\n *\n * Throws on SDK failure so React Query's native error model engages (`isError`, `error`,\n * `onError`, `retry`). Returns the unwrapped `TxHashPair` on success.\n */\nexport function useClaimRewards<K extends SpokeChainKey = SpokeChainKey>({\n  mutationOptions,\n}: MutationHookParams<TxHashPair, UseClaimRewardsVars<K>> = {}): SafeUseMutationResult<\n  TxHashPair,\n  Error,\n  UseClaimRewardsVars<K>\n> {\n  const { sodax } = useSodaxContext();\n  const queryClient = useQueryClient();\n\n  return useSafeMutation<TxHashPair, Error, UseClaimRewardsVars<K>>({\n    mutationKey: ['dex', 'claimRewards'],\n    ...mutationOptions,\n    mutationFn: async vars => unwrapResult(await sodax.dex.clService.claimRewards({ ...vars, raw: false })),\n    onSuccess: async (data, vars, ctx) => {\n      const { params } = vars;\n      // `usePositionInfo` keys by string tokenId — stringify the bigint to keep the structural match.\n      queryClient.invalidateQueries({\n        queryKey: ['dex', 'positionInfo', params.tokenId.toString(), params.poolKey],\n      });\n      queryClient.invalidateQueries({ queryKey: ['dex', 'poolBalances', params.srcChainKey, params.srcAddress] });\n      await mutationOptions?.onSuccess?.(data, vars, ctx);\n    },\n  });\n}\n","import { useMemo, useRef, type ReactNode, type ReactElement } from 'react';\nimport { Sodax, type SodaxConfig } from '@sodax/sdk';\nimport { SodaxContext } from '@/contexts/index.js';\nimport type { DeepPartial } from '@sodax/sdk';\n\ninterface SodaxProviderProps {\n  children: ReactNode;\n  /**\n   * Sodax config (overrides defaults including rpcUrls). **Read-once at mount** —\n   * changes after first render are ignored to prevent re-instantiating the SDK\n   * from unstable parent references. To switch config (e.g. testnet ↔ mainnet),\n   * unmount/remount the provider.\n   */\n  config?: DeepPartial<SodaxConfig>;\n}\n\nexport const SodaxProvider = ({ children, config }: SodaxProviderProps): ReactElement => {\n  // Freeze config on first render so the SDK instance and consumers share one\n  // snapshot (matches SodaxWalletProvider semantic).\n  const configRef = useRef<DeepPartial<SodaxConfig> | undefined>(config);\n  const frozen = configRef.current;\n  const sodax = useMemo(() => new Sodax(frozen), [frozen]);\n\n  return <SodaxContext.Provider value={{ sodax }}>{children}</SodaxContext.Provider>;\n};\n","// packages/dapp-kit/src/providers/createSodaxQueryClient.ts\nimport { MutationCache, QueryClient, type QueryClientConfig } from '@tanstack/react-query';\n\nexport type CreateSodaxQueryClientOptions = {\n  /**\n   * Called for every mutation failure (i.e. every time `mutationFn` throws) that does NOT opt out\n   * via `meta: { silent: true }` on the mutation. Defaults to `console.error`.\n   *\n   * This is **global observability** — it runs alongside any per-hook `onError` handler the\n   * consumer set, NOT instead of them. In particular, it fires:\n   * - whether or not `mutateAsync` was awaited inside `try/catch`\n   * - whether or not `mutateAsyncSafe` was used (the wrapper packs into `Result<T>` AFTER React\n   *   Query has already entered the error state and dispatched its callbacks)\n   * - whether or not the consumer's `mutationOptions.onError` already toasted/logged\n   *\n   * It is NOT a \"did this rejection escape to the global handler?\" detector — accurate\n   * unhandled-rejection detection lives at `window.onunhandledrejection`, not here.\n   *\n   * To silence the default for a specific mutation that the consumer is handling locally, set\n   * `meta: { silent: true }`:\n   *\n   * ```ts\n   * useSwap({ mutationOptions: { meta: { silent: true }, onError: (e) => toast(e.message) } });\n   * ```\n   *\n   * To disable the default globally (e.g. wire your own error boundary), pass a no-op:\n   *\n   * ```ts\n   * createSodaxQueryClient({ onMutationError: () => {} });\n   * ```\n   */\n  onMutationError?: (error: unknown) => void;\n  /** Pass-through for any other QueryClient config (default queries options, etc.) */\n  config?: QueryClientConfig;\n};\n\nconst defaultOnMutationError = (error: unknown): void => {\n  console.error('[sodax] Mutation error:', error);\n};\n\n/**\n * Creates a `QueryClient` pre-wired with a mutation-error observability hook that gives dapp-kit\n * consumers a single seam for every mutation failure across the app — wire to Sentry/Datadog/console\n * as you like. Optional opt-in: consumers who construct their own `QueryClient` are unaffected.\n *\n * **Composition with a custom `MutationCache`.** If you pass `config.mutationCache`, we keep your\n * cache instance (preserving its own `onError` / `onSuccess` / etc.) and *additionally* subscribe\n * to its event stream to dispatch `onMutationError`. Both your handler and the dapp-kit handler\n * fire — neither replaces the other. If you don't pass one, we install our own.\n *\n * @example default — logs to console\n * const queryClient = createSodaxQueryClient();\n *\n * @example custom — Sentry\n * const queryClient = createSodaxQueryClient({\n *   onMutationError: (e) => Sentry.captureException(e),\n * });\n *\n * @example silent — disable the default\n * const queryClient = createSodaxQueryClient({ onMutationError: () => {} });\n *\n * @example bring-your-own MutationCache\n * const myCache = new MutationCache({ onError: myOwnErrorHandler });\n * const queryClient = createSodaxQueryClient({ config: { mutationCache: myCache } });\n * // myOwnErrorHandler still runs; onMutationError ALSO runs (unless meta.silent).\n */\nexport function createSodaxQueryClient({\n  onMutationError = defaultOnMutationError,\n  config,\n}: CreateSodaxQueryClientOptions = {}): QueryClient {\n  if (config?.mutationCache) {\n    // Compose: keep the consumer's cache, attach our observability as an extra subscriber.\n    // The consumer's own `MutationCache.onError` (if any) still fires — subscribe is additive.\n    config.mutationCache.subscribe(event => {\n      if (\n        event.type === 'updated' &&\n        event.action.type === 'error' &&\n        event.mutation.options.meta?.silent !== true\n      ) {\n        onMutationError(event.action.error);\n      }\n    });\n    return new QueryClient(config);\n  }\n\n  // No consumer cache: install our own with `onError` directly (cheaper than a subscribe loop).\n  return new QueryClient({\n    ...config,\n    mutationCache: new MutationCache({\n      onError: (error, _vars, _ctx, mutation) => {\n        if (mutation.options.meta?.silent === true) return;\n        onMutationError(error);\n      },\n    }),\n  });\n}\n"]}