@panoptic-eng/sdk 1.0.36 → 1.0.38

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (85) hide show
  1. package/dist/cow/index.d.ts +4 -5
  2. package/dist/cow/index.js +3 -3
  3. package/dist/cow/types.d.ts +3 -2
  4. package/dist/{cow-aX6of9TS.js → cow-DB8siv6M.js} +2 -2
  5. package/dist/{cow-aX6of9TS.js.map → cow-DB8siv6M.js.map} +1 -1
  6. package/dist/deployments.d.ts +3 -2
  7. package/dist/deployments.d.ts.map +1 -1
  8. package/dist/deployments.js +4 -0
  9. package/dist/deployments.js.map +1 -1
  10. package/dist/{position-C8rkkKhi.js → getTrackedPositionIds-zYPIs5dt.js} +1086 -34
  11. package/dist/getTrackedPositionIds-zYPIs5dt.js.map +1 -0
  12. package/dist/hypoVault/vaultDisplayNames.d.ts +2 -0
  13. package/dist/hypoVault/vaultDisplayNames.js +4 -0
  14. package/dist/{index-CURXeKNy.d.ts → index-BhEBx83X.d.ts} +405 -351
  15. package/dist/index-BhEBx83X.d.ts.map +1 -0
  16. package/dist/index-Bo9tHtD7.d.ts +1901 -0
  17. package/dist/index-Bo9tHtD7.d.ts.map +1 -0
  18. package/dist/{index-Cp-nCeV2.d.ts → index-CttjEZ-S.d.ts} +3 -4
  19. package/dist/index-CttjEZ-S.d.ts.map +1 -0
  20. package/dist/{index-Zvu-rJpV.d.ts → index-DktZq9Kb.d.ts} +2 -2
  21. package/dist/{index-Zvu-rJpV.d.ts.map → index-DktZq9Kb.d.ts.map} +1 -1
  22. package/dist/index.d.ts +159 -39
  23. package/dist/index.d.ts.map +1 -1
  24. package/dist/index.js +323 -70
  25. package/dist/index.js.map +1 -1
  26. package/dist/{irm-DnM96-X4.js → irm-ChkvYphK.js} +3 -318
  27. package/dist/irm-ChkvYphK.js.map +1 -0
  28. package/dist/{irm-CmgC1Mqi.d.ts → irm-D2WTHtuo.d.ts} +3 -30
  29. package/dist/{irm-CmgC1Mqi.d.ts.map → irm-D2WTHtuo.d.ts.map} +1 -1
  30. package/dist/irm-D5plRhpB.d.ts +32 -0
  31. package/dist/irm-D5plRhpB.d.ts.map +1 -0
  32. package/dist/panoptic/v2/greeks/index.d.ts +3 -2
  33. package/dist/panoptic/v2/index.d.ts +7 -8
  34. package/dist/panoptic/v2/index.js +7 -6
  35. package/dist/panoptic/v2/react-public.d.ts +29 -13
  36. package/dist/panoptic/v2/react-public.d.ts.map +1 -1
  37. package/dist/panoptic/v2/react-public.js +48 -8
  38. package/dist/panoptic/v2/react-public.js.map +1 -1
  39. package/dist/panoptic/v2/types/index.d.ts +3 -0
  40. package/dist/panoptic/v2/types/index.js +0 -0
  41. package/dist/quote-DeHNUR0Z.d.ts +52 -0
  42. package/dist/quote-DeHNUR0Z.d.ts.map +1 -0
  43. package/dist/{router-CS86ptMu.js → router-BCUJkY8j.js} +3 -3
  44. package/dist/{router-CS86ptMu.js.map → router-BCUJkY8j.js.map} +1 -1
  45. package/dist/{router-DcoU2KmV.js → router-tCRa0ekE.js} +2 -2
  46. package/dist/{router-DcoU2KmV.js.map → router-tCRa0ekE.js.map} +1 -1
  47. package/dist/src-CRAtPwWk.js +321 -0
  48. package/dist/src-CRAtPwWk.js.map +1 -0
  49. package/dist/test/index.d.ts +2 -2
  50. package/dist/test/index.d.ts.map +1 -1
  51. package/dist/transactionFees-CVi2TrJh.js +175 -0
  52. package/dist/transactionFees-CVi2TrJh.js.map +1 -0
  53. package/dist/transactionFees-DzDyt50k.d.ts +63 -0
  54. package/dist/transactionFees-DzDyt50k.d.ts.map +1 -0
  55. package/dist/{types-D_jcYss-.d.ts → types-Cad5m4Td.d.ts} +3 -5
  56. package/dist/types-Cad5m4Td.d.ts.map +1 -0
  57. package/dist/{types-BHdnurYr.d.ts → types-DM0nxlZr.d.ts} +2 -2
  58. package/dist/{types-BHdnurYr.d.ts.map → types-DM0nxlZr.d.ts.map} +1 -1
  59. package/dist/uniswap/index.d.ts +4 -5
  60. package/dist/uniswap/index.d.ts.map +1 -1
  61. package/dist/uniswap/index.js +4 -4
  62. package/dist/{v2-D0dEatKb.js → v2-BxtzpUnV.js} +3267 -2675
  63. package/dist/v2-BxtzpUnV.js.map +1 -0
  64. package/dist/vault-transaction-fees.d.ts +2 -0
  65. package/dist/vault-transaction-fees.js +3 -0
  66. package/dist/vaultDisplayNames-CKpz51Hu.js +0 -0
  67. package/dist/vaultDisplayNames-Q6htUcch.d.ts +2 -0
  68. package/dist/{writes-AupZCK4M.js → writes-D3bj1wth.js} +326 -1292
  69. package/dist/writes-D3bj1wth.js.map +1 -0
  70. package/package.json +5 -1
  71. package/dist/index-CURXeKNy.d.ts.map +0 -1
  72. package/dist/index-Cp-nCeV2.d.ts.map +0 -1
  73. package/dist/irm-DnM96-X4.js.map +0 -1
  74. package/dist/position-BqIgubs5.d.ts +0 -199
  75. package/dist/position-BqIgubs5.d.ts.map +0 -1
  76. package/dist/position-C8rkkKhi.js.map +0 -1
  77. package/dist/quote-BxQkPBRg.d.ts +0 -718
  78. package/dist/quote-BxQkPBRg.d.ts.map +0 -1
  79. package/dist/simulation-zM6-YUaw.d.ts +0 -258
  80. package/dist/simulation-zM6-YUaw.d.ts.map +0 -1
  81. package/dist/tx-CbDQ58Io.d.ts +0 -367
  82. package/dist/tx-CbDQ58Io.d.ts.map +0 -1
  83. package/dist/types-D_jcYss-.d.ts.map +0 -1
  84. package/dist/v2-D0dEatKb.js.map +0 -1
  85. package/dist/writes-AupZCK4M.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"react-public.js","names":["scope?: string","client: unknown","storage: unknown","atTick?: bigint","chainId: bigint","poolAddress: Address","tokenId: bigint","account: Address","atTick: bigint","collateralTrackerAddress: Address","positionIdList: bigint[]","totalAssets: bigint","token: Address","owner: Address","spender: Address","tracker: Address","operation: string","amount: bigint","poolAddress: string","timestampsHash: string","rangeHash: string","poolAddress: Address","options?: QueryOptions","tokenIndex: 0 | 1","params: { queryAddress: Address; startTick: bigint; nTicks: bigint }","params: { sfpmAddress: Address }","owner: Address","tokenId: bigint","tokenIds: bigint[]","owner?: Address","account?: Address","queryAddress: Address","options?: QueryOptions & { atTick?: bigint; includePendingPremium?: boolean }","options?: QueryOptions & { atTick?: bigint }","atTicks: bigint[]","amount: bigint","positionSize: bigint","options?: QueryOptions & {\n existingPositionIds?: bigint[]\n neutralizeITM?: boolean\n swapAtMint?: boolean\n /** Size to measure the base flow at (defaults to positionSize). See SDK param. */\n referenceSize?: bigint\n /** PanopticQuery address — gates OTM on true intrinsic. See SDK param. */\n queryAddress?: Address\n }","options?: QueryOptions & {\n existingPositionIds?: bigint[]\n swapAtMint?: boolean\n precisionPct?: number\n usePremiaAsCollateral?: boolean\n }","atTick?: bigint","collateralTrackerAddress: Address","positionIdList: bigint[]","totalAssets: bigint","options?: QueryOptions & { client?: PublicClient }","account: Address | undefined","existingPositionIds: bigint[]","tickLimitLow: bigint","tickLimitHigh: bigint","options?: QueryOptions & {\n spreadLimit?: bigint\n swapAtMint?: boolean\n usePremiaAsCollateral?: boolean\n blockNumber?: bigint\n }","params?: OmitFactoryClient<GetPanopticPoolAddressParams>","params?: OmitFactoryClient<GetFactoryTokenURIParams>","params?: OmitFactoryClient<GetFactoryOwnerOfParams>","params: MinePoolAddressLocalParams","params?: OmitFactoryClient<GetFactoryConstructMetadataParams>","params?: OmitMineClient<SimulateDeployNewPoolParams>","timeRange: PriceHistoryTimeRange","client: PublicClient","poolConfig: PoolVersionConfig","panopticPoolAddress: Address","account: Address","legs: StreamiaLeg[]","options?: QueryOptions & {\n includeUniswapFees?: boolean\n settledEvents?: Array<{ blockNumber: bigint; settled0: bigint; settled1: bigint }>\n }","poolAddress: Address | undefined","queryAddress: Address | undefined","args: { startTick: number; nTicks: bigint } | undefined","poolManager: Address | undefined","poolId: `0x${string}` | undefined","args?: { fromBlock?: bigint; chunkSize?: bigint }","stateViewAddress: Address | undefined","poolKey: UniswapV4PoolKey | undefined","args: { tickSpacing: number; startTick: number; nTicks: bigint } | undefined","panopticPoolAddress: Address | undefined","token0Decimals: bigint","token1Decimals: bigint","nativeIsToken0: boolean","params?: {\n account: Address\n token: Address\n amount: bigint\n slippageBps: bigint\n existingPositionIds: bigint[]\n }","builderCode: bigint | undefined","params: MutationEffectParams","keys: (readonly string[])[]","chainId: bigint","token: Address","owner: Address","spender: Address","params: Pick<MutationEffectParams, 'chainId' | 'poolAddress'>","requireWallet","inputs: WalletInputs","queryClient: QueryClient","keysToInvalidate: readonly (readonly string[])[]","params: OmitInjected<ApproveParams>","poolAddress: Address","params: OmitInjectedWithPool<ApprovePoolParams>","params: OmitInjected<DepositParams>","params: OmitInjected<WithdrawParams>","params: OmitInjected<WrapXstockParams>","params: OmitInjected<UnwrapXstockParams>","params: OmitInjected<WrapEthParams>","params: OmitInjected<UnwrapWethParams>","params: OmitInjected<MintParams>","params: OmitInjected<RedeemParams>","params: OmitInjected<WithdrawWithPositionsParams>","params: OmitInjectedWithPool<OpenPositionParams>","params: OmitInjectedWithPool<ClosePositionParams>","params: OmitInjectedWithPool<RollPositionParams>","params: OmitInjectedWithPool<LiquidateParams>","params: Omit<\n ForceExerciseParams,\n 'client' | 'walletClient' | 'account' | 'poolAddress' | 'chainId' | 'storage'\n >","params: OmitInjectedWithPool<SettleParams>","params?: OmitInjectedWithPool<PokeOracleParams>","params: OmitInjectedWithPool<DispatchParams>","params: OmitInjectedWithPool<ExecuteBatchDispatchParams>","params: OmitInjected<DeployNewPoolParams>","params: OmitInjectedWithPoolAndChain<SwapExactOutParams>","params: OmitInjectedWithPoolAndChain<SupplyParams>","params: OmitInjectedWithPoolAndChain<UnsupplyParams>","params: OmitInjectedWithPoolAndChain<BorrowParams>","params: OmitInjectedWithPoolAndChain<RepayParams>","params: OmitInjectedWithPoolAndChain<SmartRepayParams>","params: OmitInjectedWithPoolAndChain<SwapExactInParams>","poolAddress: Address","params?: OmitClientAndPool<SimulateOpenPositionParams>","params?: OmitClientAndPool<SimulateClosePositionParams>","params?: OmitClient<SimulateDepositParams>","params?: OmitClient<SimulateWithdrawParams>","params?: OmitClientAndPool<SimulateLiquidateParams>","params?: OmitClientAndPool<SimulateForceExerciseParams>","params?: OmitClientAndPool<SimulateSettleParams>","params?: OmitClientAndPool<SimulateBatchDispatchParams>","params?: OmitClientAndPool<SimulateDispatchParams>","params?: OmitClient<SimulateSFPMParams>","params?: OmitClientAndPool<SimulateSwapExactOutParams>","params?: OmitClientAndPool<SimulateSwapExactInParams>","requireWallet","walletClient?: WalletClient","account?: Address","poolAddress: Address","params?: OmitClientPoolAndChain<QuoteSwapExactInViaRouterParams>","params?: OmitClientPoolAndChain<QuoteSwapExactOutViaRouterParams>","params?: OmitInjectedWithChain<CheckRouterApprovalParams>","params: OmitInjectedWithPoolAndChain<SwapExactInViaRouterParams>","params: OmitInjectedWithPoolAndChain<SwapExactOutViaRouterParams>","params: OmitInjectedWithChain<ApproveErc20ForPermit2Params>","params: OmitInjectedWithChain<ApproveRouterViaPermit2Params>","walletClient?: WalletClient","account?: Address","params?: OmitChainAndFrom<QuoteCowSwapParams>","params?: OmitClientOnly<CheckCowApprovalParams>","params: OmitInjectedWithChain<ApproveErc20ForCowParams>","params: Omit<SignAndSubmitCowOrderParams, 'walletClient' | 'account' | 'chainId'>","orderUid?: Hex","params: Omit<CancelCowOrderParams, 'walletClient' | 'account' | 'chainId'>","poolAddress: Address","params?: { fromBlock?: bigint; toBlock?: bigint }","position: PendingPosition","tokenId: bigint","txHash: Hash","poolAddress: Address","eventTypes: PanopticEventType[] | undefined","onEvent: (events: PanopticEvent[]) => void","options?: {\n enabled?: boolean\n collateralTracker0?: Address\n collateralTracker1?: Address\n riskEngineAddress?: Address\n sfpmAddress?: Address\n poolManagerAddress?: Address\n onError?: (error: Error) => void\n }","options?: {\n enabled?: boolean\n collateralTracker0?: Address\n collateralTracker1?: Address\n riskEngineAddress?: Address\n sfpmAddress?: Address\n poolManagerAddress?: Address\n onError?: (error: Error) => void\n onReconnect?: (attempt: bigint, nextDelayMs: bigint) => void\n onConnected?: () => void\n }","handle: EventSubscriptionHandle","options?: {\n enabled?: boolean\n intervalMs?: bigint\n collateralTracker0?: Address\n collateralTracker1?: Address\n riskEngineAddress?: Address\n sfpmAddress?: Address\n poolManagerAddress?: Address\n onError?: (error: Error) => void\n }","poller: EventPoller"],"sources":["../../../src/panoptic/v2/react/cacheScopes.ts","../../../src/panoptic/v2/react/provider.tsx","../../../src/panoptic/v2/react/queryKeys.ts","../../../src/panoptic/v2/react/hooks/reads.ts","../../../src/panoptic/v2/react/mutationEffects.ts","../../../src/panoptic/v2/react/hooks/writes.ts","../../../src/panoptic/v2/react/hooks/simulations.ts","../../../src/panoptic/v2/react/hooks/uniswapRouter.ts","../../../src/panoptic/v2/react/hooks/cowSwap.ts","../../../src/panoptic/v2/react/hooks/sync.ts","../../../src/panoptic/v2/react/hooks/events.ts"],"sourcesContent":["/**\n * Stable cache-scope helpers for React query keys.\n * @module v2/react/cacheScopes\n */\n\nconst DEFAULT_CLIENT_CACHE_SCOPE = 'default-client'\nconst DEFAULT_STORAGE_CACHE_SCOPE = 'default-storage'\n\nexport function getClientCacheScope(scope?: string): string {\n return scope ?? DEFAULT_CLIENT_CACHE_SCOPE\n}\n\nexport function getStorageCacheScope(scope?: string): string {\n return scope ?? DEFAULT_STORAGE_CACHE_SCOPE\n}\n\nexport function getClientCacheScopeKey(client: unknown, scope?: string): string {\n // Keep client in the queryKey expression for exhaustive-deps while keying by stable scope.\n void client\n return getClientCacheScope(scope)\n}\n\nexport function getStorageCacheScopeKey(storage: unknown, scope?: string): string {\n // Keep storage in the queryKey expression for exhaustive-deps while keying by stable scope.\n void storage\n return getStorageCacheScope(scope)\n}\n\nexport function getAtTickCacheKey(atTick?: bigint): string {\n return atTick === undefined ? 'latest' : atTick.toString()\n}\n","/**\n * React context provider for the Panoptic v2 SDK.\n * @module v2/react/provider\n */\n\nimport { type ReactNode, createContext, useContext } from 'react'\nimport type { Address, PublicClient, WalletClient } from 'viem'\n\nimport type { StorageAdapter } from '../storage'\n\n/**\n * Panoptic SDK context value.\n */\nexport interface PanopticContextValue {\n /** viem PublicClient for reading chain state */\n publicClient: PublicClient\n /**\n * Optional cache scope for read/simulation query keys.\n * Use this when multiple environments share the same QueryClient.\n */\n clientScope?: string\n /** Optional viem WalletClient for write operations */\n walletClient?: WalletClient\n /** Optional account address for write operations */\n account?: Address\n /** Chain ID */\n chainId: bigint\n /** Optional StateView address for V4 Uniswap pool reads (per-chain singleton) */\n stateViewAddress?: Address\n /** Optional storage adapter for position tracking */\n storage?: StorageAdapter\n /**\n * Optional cache scope for storage-backed query keys.\n * Set this when swapping storage adapters at runtime.\n */\n storageScope?: string\n}\n\nconst PanopticContext = createContext<PanopticContextValue | null>(null)\n\n/**\n * Props for PanopticProvider.\n */\nexport interface PanopticProviderProps extends PanopticContextValue {\n children: ReactNode\n}\n\n/**\n * Context provider for Panoptic v2 SDK hooks.\n *\n * Wraps children with shared publicClient, walletClient, account, chainId, and storage.\n * Does NOT include QueryClientProvider — you must provide your own.\n *\n * @example\n * ```tsx\n * <QueryClientProvider client={queryClient}>\n * <PanopticProvider\n * publicClient={publicClient}\n * walletClient={walletClient}\n * account={address}\n * chainId={1n}\n * >\n * <App />\n * </PanopticProvider>\n * </QueryClientProvider>\n * ```\n */\nexport function PanopticProvider({ children, ...value }: PanopticProviderProps) {\n return <PanopticContext.Provider value={value}>{children}</PanopticContext.Provider>\n}\n\n/**\n * Access the Panoptic SDK context.\n *\n * @throws Error if used outside PanopticProvider\n * @returns PanopticContextValue\n */\nexport function usePanopticContext(): PanopticContextValue {\n const ctx = useContext(PanopticContext)\n if (!ctx) {\n throw new Error('usePanopticContext must be used within a PanopticProvider')\n }\n return ctx\n}\n\n/**\n * Internal hook that requires walletClient and account.\n *\n * @throws Error if walletClient or account not provided in context\n * @returns { walletClient, account } guaranteed non-undefined\n */\nexport function useRequireWallet(): { walletClient: WalletClient; account: Address } {\n const { walletClient, account } = usePanopticContext()\n if (!walletClient || !account) {\n throw new Error('walletClient and account are required. Provide them via PanopticProvider.')\n }\n return { walletClient, account }\n}\n\n/**\n * Internal hook that requires storage adapter.\n *\n * @throws Error if storage not provided in context\n * @returns StorageAdapter guaranteed non-undefined\n */\nexport function useRequireStorage(): StorageAdapter {\n const { storage } = usePanopticContext()\n if (!storage) {\n throw new Error('storage is required. Provide a StorageAdapter via PanopticProvider.')\n }\n return storage\n}\n","/**\n * Query key factory for TanStack Query / SWR integration.\n * @module v2/react/queryKeys\n */\n\nimport type { Address } from 'viem'\n\n/**\n * Query key factory for Panoptic v2 SDK data.\n *\n * Use with TanStack Query or SWR for cache key consistency.\n * All keys are arrays for proper cache matching and invalidation.\n *\n * @example\n * ```typescript\n * import { useQuery } from '@tanstack/react-query'\n * import { queryKeys, getPool } from 'panoptic-v2-sdk'\n *\n * function usePool(config: PanopticConfig) {\n * return useQuery({\n * queryKey: queryKeys.pool(config.chainId, config.poolAddress),\n * queryFn: () => getPool(config),\n * })\n * }\n * ```\n */\nexport const queryKeys = {\n /**\n * Base key for all Panoptic v2 queries.\n */\n all: ['panoptic-v2'] as const,\n\n /**\n * Key for pool data.\n */\n pool: (chainId: bigint, poolAddress: Address) =>\n [...queryKeys.all, 'pool', chainId.toString(), poolAddress] as const,\n\n /**\n * Key for pool utilization.\n */\n utilization: (chainId: bigint, poolAddress: Address) =>\n [...queryKeys.all, 'utilization', chainId.toString(), poolAddress] as const,\n\n /**\n * Key for oracle state.\n */\n oracle: (chainId: bigint, poolAddress: Address) =>\n [...queryKeys.all, 'oracle', chainId.toString(), poolAddress] as const,\n\n /**\n * Key for safe mode state.\n */\n safeMode: (chainId: bigint, poolAddress: Address) =>\n [...queryKeys.all, 'safeMode', chainId.toString(), poolAddress] as const,\n\n /**\n * Key for Guardian pool-unlock state.\n */\n guardianUnlock: (chainId: bigint, poolAddress: Address) =>\n [...queryKeys.all, 'guardianUnlock', chainId.toString(), poolAddress] as const,\n\n /**\n * Key for risk parameters.\n */\n riskParameters: (chainId: bigint, poolAddress: Address) =>\n [...queryKeys.all, 'riskParameters', chainId.toString(), poolAddress] as const,\n\n /**\n * Key for current rates.\n */\n rates: (chainId: bigint, poolAddress: Address) =>\n [...queryKeys.all, 'rates', chainId.toString(), poolAddress] as const,\n\n /**\n * Key for a single position.\n */\n position: (chainId: bigint, poolAddress: Address, tokenId: bigint) =>\n [...queryKeys.all, 'position', chainId.toString(), poolAddress, tokenId.toString()] as const,\n\n /**\n * Key for all positions of an account.\n */\n positions: (chainId: bigint, poolAddress: Address, account: Address) =>\n [...queryKeys.all, 'positions', chainId.toString(), poolAddress, account] as const,\n\n /**\n * Key for tracked position IDs.\n */\n trackedPositionIds: (chainId: bigint, poolAddress: Address, account: Address) =>\n [...queryKeys.all, 'trackedPositionIds', chainId.toString(), poolAddress, account] as const,\n\n /**\n * Key for sync status.\n */\n syncStatus: (chainId: bigint, poolAddress: Address, account: Address) =>\n [...queryKeys.all, 'syncStatus', chainId.toString(), poolAddress, account] as const,\n\n /**\n * Key for account collateral.\n */\n accountCollateral: (chainId: bigint, poolAddress: Address, account: Address) =>\n [...queryKeys.all, 'accountCollateral', chainId.toString(), poolAddress, account] as const,\n\n /**\n * Key for base account summary (aggregate dashboard data).\n */\n accountSummaryBasic: (chainId: bigint, poolAddress: Address, account: Address) =>\n [...queryKeys.all, 'accountSummaryBasic', chainId.toString(), poolAddress, account] as const,\n\n /**\n * Key for risk-focused account summary.\n */\n accountSummaryRisk: (chainId: bigint, poolAddress: Address, account: Address) =>\n [...queryKeys.all, 'accountSummaryRisk', chainId.toString(), poolAddress, account] as const,\n\n /**\n * Key for liquidation check.\n */\n isLiquidatable: (chainId: bigint, poolAddress: Address, account: Address) =>\n [...queryKeys.all, 'isLiquidatable', chainId.toString(), poolAddress, account] as const,\n\n /**\n * Key for liquidation prices.\n */\n liquidationPrices: (chainId: bigint, poolAddress: Address, account: Address) =>\n [...queryKeys.all, 'liquidationPrices', chainId.toString(), poolAddress, account] as const,\n\n /**\n * Key for net liquidation value.\n */\n netLiquidationValue: (chainId: bigint, poolAddress: Address, account: Address, atTick: bigint) =>\n [\n ...queryKeys.all,\n 'netLiquidationValue',\n chainId.toString(),\n poolAddress,\n account,\n atTick.toString(),\n ] as const,\n\n /**\n * Key for chunk spreads.\n */\n chunkSpreads: (chainId: bigint, poolAddress: Address) =>\n [...queryKeys.all, 'chunkSpreads', chainId.toString(), poolAddress] as const,\n\n /**\n * Key for closed positions.\n */\n closedPositions: (chainId: bigint, poolAddress: Address, account: Address) =>\n [...queryKeys.all, 'closedPositions', chainId.toString(), poolAddress, account] as const,\n\n /**\n * Key for trade history.\n */\n tradeHistory: (chainId: bigint, poolAddress: Address, account: Address) =>\n [...queryKeys.all, 'tradeHistory', chainId.toString(), poolAddress, account] as const,\n\n /**\n * Key for realized PnL.\n */\n realizedPnL: (chainId: bigint, poolAddress: Address, account: Address) =>\n [...queryKeys.all, 'realizedPnL', chainId.toString(), poolAddress, account] as const,\n\n /**\n * Key for position greeks.\n */\n positionGreeks: (chainId: bigint, poolAddress: Address, tokenId: bigint) =>\n [\n ...queryKeys.all,\n 'positionGreeks',\n chainId.toString(),\n poolAddress,\n tokenId.toString(),\n ] as const,\n\n /**\n * Key for account greeks.\n */\n accountGreeks: (chainId: bigint, poolAddress: Address, account: Address) =>\n [...queryKeys.all, 'accountGreeks', chainId.toString(), poolAddress, account] as const,\n\n /**\n * Key for collateral estimate.\n */\n collateralEstimate: (chainId: bigint, poolAddress: Address, account: Address, tokenId: bigint) =>\n [\n ...queryKeys.all,\n 'collateralEstimate',\n chainId.toString(),\n poolAddress,\n account,\n tokenId.toString(),\n ] as const,\n\n /**\n * Key for max position size.\n */\n maxPositionSize: (chainId: bigint, poolAddress: Address, account: Address, tokenId: bigint) =>\n [\n ...queryKeys.all,\n 'maxPositionSize',\n chainId.toString(),\n poolAddress,\n account,\n tokenId.toString(),\n ] as const,\n\n /**\n * Key for max withdrawable assets from a collateral tracker.\n */\n maxWithdrawable: (\n chainId: bigint,\n collateralTrackerAddress: Address,\n positionIdList: bigint[],\n totalAssets: bigint,\n account: Address,\n ) =>\n [\n ...queryKeys.all,\n chainId.toString(),\n 'maxWithdrawable',\n collateralTrackerAddress,\n positionIdList.map(String).join(','),\n totalAssets.toString(),\n account,\n ] as const,\n\n /**\n * Key for max redeemable shares from a collateral tracker.\n */\n maxRedeem: (chainId: bigint, collateralTrackerAddress: Address, account: Address) =>\n [...queryKeys.all, chainId.toString(), 'maxRedeem', collateralTrackerAddress, account] as const,\n\n /**\n * Key for approval check.\n */\n approval: (chainId: bigint, token: Address, owner: Address, spender: Address) =>\n [...queryKeys.all, 'approval', chainId.toString(), token, owner, spender] as const,\n\n /**\n * Key for ERC4626 preview operations.\n */\n erc4626Preview: (chainId: bigint, tracker: Address, operation: string, amount: bigint) =>\n [\n ...queryKeys.all,\n 'erc4626Preview',\n chainId.toString(),\n tracker,\n operation,\n amount.toString(),\n ] as const,\n\n /**\n * Key for margin buffer.\n */\n marginBuffer: (chainId: bigint, poolAddress: Address, account: Address) =>\n [...queryKeys.all, 'marginBuffer', chainId.toString(), poolAddress, account] as const,\n\n /**\n * Key for account premia.\n */\n accountPremia: (chainId: bigint, poolAddress: Address, account: Address) =>\n [...queryKeys.all, 'accountPremia', chainId.toString(), poolAddress, account] as const,\n\n /**\n * Key for positions with premia.\n */\n positionsWithPremia: (chainId: bigint, poolAddress: Address, account: Address) =>\n [...queryKeys.all, 'positionsWithPremia', chainId.toString(), poolAddress, account] as const,\n\n /**\n * Key for collateral data.\n */\n collateralData: (chainId: bigint, poolAddress: Address) =>\n [...queryKeys.all, 'collateralData', chainId.toString(), poolAddress] as const,\n\n /**\n * Key for pool liquidities.\n */\n poolLiquidities: (chainId: bigint, poolAddress: Address) =>\n [...queryKeys.all, 'poolLiquidities', chainId.toString(), poolAddress] as const,\n\n /**\n * Key for optimized risk partners.\n */\n optimizeRiskPartners: (chainId: bigint, poolAddress: Address, tokenId: bigint) =>\n [\n ...queryKeys.all,\n 'optimizeRiskPartners',\n chainId.toString(),\n poolAddress,\n tokenId.toString(),\n ] as const,\n /**\n * Key for price history.\n * Uses a hash of timestamps for cache busting when the time range changes.\n */\n priceHistory: (chainId: bigint, poolAddress: string, timestampsHash: string) =>\n [...queryKeys.all, 'priceHistory', chainId.toString(), poolAddress, timestampsHash] as const,\n\n /**\n * Key for streamia history.\n */\n streamiaHistory: (chainId: bigint, poolAddress: string, rangeHash: string) =>\n [...queryKeys.all, 'streamiaHistory', chainId.toString(), poolAddress, rangeHash] as const,\n\n /**\n * Key for Uniswap fee history.\n */\n uniswapFeeHistory: (chainId: bigint, poolAddress: string, rangeHash: string) =>\n [...queryKeys.all, 'uniswapFeeHistory', chainId.toString(), poolAddress, rangeHash] as const,\n\n /**\n * Key for required credit for ITM position.\n */\n requiredCreditForITM: (\n chainId: bigint,\n poolAddress: Address,\n account: Address,\n tokenId: bigint,\n ) =>\n [\n ...queryKeys.all,\n 'requiredCreditForITM',\n chainId.toString(),\n poolAddress,\n account,\n tokenId.toString(),\n ] as const,\n /**\n * Key for flow-neutral tokenId (ITM-neutralizing legs). Account-independent —\n * itmAmounts is a pure projection of the tokenId + size.\n */\n flowNeutralTokenId: (chainId: bigint, poolAddress: Address, tokenId: bigint) =>\n [\n ...queryKeys.all,\n 'flowNeutralTokenId',\n chainId.toString(),\n poolAddress,\n tokenId.toString(),\n ] as const,\n /**\n * Key for interest state (per-user borrows).\n */\n interestState: (chainId: bigint, poolAddress: Address, account: Address) =>\n [...queryKeys.all, 'interestState', chainId.toString(), poolAddress, account] as const,\n} as const\n","/**\n * TanStack Query v5 read hooks for the Panoptic v2 SDK.\n * @module v2/react/hooks/reads\n */\n\nimport { keepPreviousData, useMutation, useQuery } from '@tanstack/react-query'\nimport type { Address, PublicClient } from 'viem'\nimport { zeroAddress } from 'viem'\n\nimport { estimateBlockNumbers, resolveBlockNumbers } from '../../clients/blocksByTimestamp'\nimport { PanopticValidationError } from '../../errors'\nimport {\n type GetEnforcedTickLimitsParams,\n type GetFactoryConstructMetadataParams,\n type GetFactoryOwnerOfParams,\n type GetFactoryTokenURIParams,\n type GetPanopticPoolAddressParams,\n type GetPanopticPoolFromPoolIdParams,\n type GetUniswapV3PoolFromIdParams,\n type GetUniswapV4PoolKeyFromIdParams,\n type MinePoolAddressLocalParams,\n type ResolvePanopticPoolFromPoolIdParams,\n type SimulateDeployNewPoolParams,\n type UniswapV4PoolKey,\n createFlowNeutralTokenId,\n estimateCollateralRequired,\n getAccountCollateral,\n getAccountGreeks,\n getAccountPremia,\n getAccountSummaryBasic,\n getAccountSummaryRisk,\n getCollateralData,\n getCurrentRates,\n getEnforcedTickLimits,\n getFactoryConstructMetadata,\n getFactoryOwnerOf,\n getFactoryTokenURI,\n getGuardianUnlockState,\n getInterestState,\n getLiquidationPrices,\n getMarginBuffer,\n getMaxPositionSize,\n getMaxRedeem,\n getMaxWithdrawable,\n getNativeTokenPrice,\n getNetLiquidationValue,\n getNetLiquidationValues,\n getOpenPositionPreview,\n getOracleState,\n getPanopticPoolAddress,\n getPanopticPoolFromPoolId,\n getPool,\n getPoolLiquidities,\n getPosition,\n getPositionGreeks,\n getPositions,\n getPositionsWithPremia,\n getRequiredCreditForITM,\n getRiskParameters,\n getSafeMode,\n getUniswapV3PoolFromId,\n getUniswapV3PoolInfo,\n getUniswapV3PoolLiquidities,\n getUniswapV4PoolBasicState,\n getUniswapV4PoolInfo,\n getUniswapV4PoolKeyFromId,\n getUniswapV4PoolLiquidities,\n getUtilization,\n isLiquidatable,\n minePoolAddressLocalAsync,\n previewDeposit,\n previewMint,\n previewRedeem,\n previewWithdraw,\n resolvePanopticPoolFromPoolId,\n resolveUniswapV4PoolKey,\n simulateDeployNewPool,\n validateBuilderCode,\n} from '../../reads'\nimport { getPriceHistory } from '../../reads/priceHistory'\nimport { optimizeTokenIdRiskPartners } from '../../reads/queryUtils'\nimport type { StreamiaLeg } from '../../reads/streamiaHistory'\nimport { getStreamiaHistory } from '../../reads/streamiaHistory'\nimport { getUniswapFeeHistory } from '../../reads/uniswapFeeHistory'\nimport {\n getChunkSpreads,\n getClosedPositions,\n getRealizedPnL,\n getSyncStatus,\n getTrackedPositionIds,\n getTradeHistory,\n scanChunks,\n} from '../../sync'\nimport type { PoolVersionConfig } from '../../types/poolConfig'\nimport { interpolateBlocks } from '../../utils/interpolateBlocks'\nimport { previewBorrow } from '../../writes/lending'\nimport { getAtTickCacheKey, getClientCacheScopeKey, getStorageCacheScopeKey } from '../cacheScopes'\nimport { usePanopticContext, useRequireStorage } from '../provider'\nimport { queryKeys } from '../queryKeys'\n\n/**\n * Common query options exposed to consumers.\n */\nexport interface QueryOptions {\n /** Whether the query is enabled */\n enabled?: boolean\n /** Refetch interval in milliseconds */\n refetchInterval?: number | false\n /** Time in milliseconds that data is considered fresh */\n staleTime?: number\n /** Time in milliseconds that unused data is kept in cache */\n gcTime?: number\n}\n\n// --- Pool reads ---\n\nexport function usePool(poolAddress: Address, options?: QueryOptions) {\n const { publicClient, chainId, clientScope, stateViewAddress } = usePanopticContext()\n return useQuery({\n queryKey: [\n ...queryKeys.pool(chainId, poolAddress),\n getClientCacheScopeKey(publicClient, clientScope),\n stateViewAddress,\n ],\n queryFn: () => getPool({ client: publicClient, poolAddress, chainId, stateViewAddress }),\n enabled: options?.enabled,\n refetchInterval: options?.refetchInterval,\n // Caching is opt-in per consumer: per the SDK's \"no memoization of dynamic RPC\n // data\" constraint, we never default a staleTime here. App code can set one\n // explicitly when it knows the consumer can tolerate cached pool state.\n staleTime: options?.staleTime,\n gcTime: options?.gcTime,\n })\n}\n\nexport function useUtilization(poolAddress: Address, options?: QueryOptions) {\n const { publicClient, chainId, clientScope } = usePanopticContext()\n return useQuery({\n queryKey: [\n ...queryKeys.utilization(chainId, poolAddress),\n getClientCacheScopeKey(publicClient, clientScope),\n ],\n queryFn: () => getUtilization({ client: publicClient, poolAddress }),\n enabled: options?.enabled,\n refetchInterval: options?.refetchInterval,\n staleTime: options?.staleTime,\n gcTime: options?.gcTime,\n })\n}\n\nexport function useOracleState(poolAddress: Address, options?: QueryOptions) {\n const { publicClient, chainId, clientScope } = usePanopticContext()\n return useQuery({\n queryKey: [\n ...queryKeys.oracle(chainId, poolAddress),\n getClientCacheScopeKey(publicClient, clientScope),\n ],\n queryFn: () => getOracleState({ client: publicClient, poolAddress }),\n enabled: options?.enabled,\n refetchInterval: options?.refetchInterval,\n staleTime: options?.staleTime,\n gcTime: options?.gcTime,\n })\n}\n\nexport function useRiskParameters(poolAddress: Address, options?: QueryOptions) {\n const { publicClient, chainId, clientScope } = usePanopticContext()\n return useQuery({\n queryKey: [\n ...queryKeys.riskParameters(chainId, poolAddress),\n getClientCacheScopeKey(publicClient, clientScope),\n ],\n queryFn: () => getRiskParameters({ client: publicClient, poolAddress }),\n enabled: options?.enabled,\n refetchInterval: options?.refetchInterval,\n staleTime: options?.staleTime,\n gcTime: options?.gcTime,\n })\n}\n\nexport function useCurrentRates(poolAddress: Address, options?: QueryOptions) {\n const { publicClient, chainId, clientScope } = usePanopticContext()\n return useQuery({\n queryKey: [\n ...queryKeys.rates(chainId, poolAddress),\n getClientCacheScopeKey(publicClient, clientScope),\n ],\n queryFn: () => getCurrentRates({ client: publicClient, poolAddress }),\n enabled: options?.enabled,\n refetchInterval: options?.refetchInterval,\n staleTime: options?.staleTime,\n gcTime: options?.gcTime,\n })\n}\n\nexport function useSafeMode(poolAddress: Address, options?: QueryOptions) {\n const { publicClient, chainId, clientScope } = usePanopticContext()\n return useQuery({\n queryKey: [\n ...queryKeys.safeMode(chainId, poolAddress),\n getClientCacheScopeKey(publicClient, clientScope),\n ],\n queryFn: () => getSafeMode({ client: publicClient, poolAddress }),\n enabled: options?.enabled,\n refetchInterval: options?.refetchInterval,\n staleTime: options?.staleTime,\n gcTime: options?.gcTime,\n })\n}\n\n/**\n * React hook for the Guardian pending-unlock state of a pool.\n *\n * Reads `unlockEta` + `isPoolUnlockReady` from the PanopticGuardian so the UI\n * can surface the unlock timelock while a pool is locked (close-only). Gate it\n * via `options.enabled` so it only runs when the pool is actually locked.\n *\n * @param poolAddress - The PanopticPool address\n * @param options - Optional react-query settings (enabled, refetchInterval, staleTime, gcTime)\n * @returns A react-query result whose `data` is a `GuardianUnlockState`\n */\nexport function useGuardianUnlockState(poolAddress: Address, options?: QueryOptions) {\n const { publicClient, chainId, clientScope } = usePanopticContext()\n return useQuery({\n queryKey: [\n ...queryKeys.guardianUnlock(chainId, poolAddress),\n getClientCacheScopeKey(publicClient, clientScope),\n ],\n queryFn: () => getGuardianUnlockState({ client: publicClient, poolAddress }),\n enabled: options?.enabled,\n refetchInterval: options?.refetchInterval,\n staleTime: options?.staleTime,\n gcTime: options?.gcTime,\n })\n}\n\nexport function useCollateralData(poolAddress: Address, tokenIndex: 0 | 1, options?: QueryOptions) {\n const { publicClient, chainId, clientScope } = usePanopticContext()\n return useQuery({\n queryKey: [\n ...queryKeys.collateralData(chainId, poolAddress),\n getClientCacheScopeKey(publicClient, clientScope),\n tokenIndex,\n ],\n queryFn: () => getCollateralData({ client: publicClient, poolAddress, tokenIndex }),\n enabled: options?.enabled,\n refetchInterval: options?.refetchInterval,\n staleTime: options?.staleTime,\n gcTime: options?.gcTime,\n })\n}\n\nexport function usePoolLiquidities(\n poolAddress: Address,\n params: { queryAddress: Address; startTick: bigint; nTicks: bigint },\n options?: QueryOptions,\n) {\n const { publicClient, chainId, clientScope } = usePanopticContext()\n return useQuery({\n queryKey: [\n ...queryKeys.poolLiquidities(chainId, poolAddress),\n getClientCacheScopeKey(publicClient, clientScope),\n params.queryAddress,\n params.startTick,\n params.nTicks,\n ],\n queryFn: () =>\n getPoolLiquidities({\n client: publicClient,\n poolAddress,\n queryAddress: params.queryAddress,\n startTick: params.startTick,\n nTicks: params.nTicks,\n }),\n enabled: options?.enabled,\n refetchInterval: options?.refetchInterval,\n staleTime: options?.staleTime,\n gcTime: options?.gcTime,\n })\n}\n\nexport function useScanChunks(\n poolAddress: Address,\n params: { queryAddress: Address; tickLower: bigint; tickUpper: bigint; width: bigint },\n options?: QueryOptions,\n) {\n const { publicClient, chainId, clientScope } = usePanopticContext()\n return useQuery({\n queryKey: [\n ...queryKeys.chunkSpreads(chainId, poolAddress),\n 'scanChunks',\n getClientCacheScopeKey(publicClient, clientScope),\n params.queryAddress,\n params.tickLower,\n params.tickUpper,\n params.width,\n ],\n queryFn: () =>\n scanChunks({\n client: publicClient,\n poolAddress,\n queryAddress: params.queryAddress,\n tickLower: params.tickLower,\n tickUpper: params.tickUpper,\n width: params.width,\n }),\n enabled: options?.enabled,\n refetchInterval: options?.refetchInterval,\n staleTime: options?.staleTime,\n gcTime: options?.gcTime,\n })\n}\n\nexport function useChunkSpreads(\n poolAddress: Address,\n params: { sfpmAddress: Address },\n options?: QueryOptions,\n) {\n const { publicClient, chainId, clientScope, storageScope } = usePanopticContext()\n const storage = useRequireStorage()\n return useQuery({\n queryKey: [\n ...queryKeys.chunkSpreads(chainId, poolAddress),\n getClientCacheScopeKey(publicClient, clientScope),\n params.sfpmAddress,\n getStorageCacheScopeKey(storage, storageScope),\n ],\n queryFn: () =>\n getChunkSpreads({\n client: publicClient,\n chainId,\n poolAddress,\n sfpmAddress: params.sfpmAddress,\n storage,\n }),\n enabled: options?.enabled,\n refetchInterval: options?.refetchInterval,\n staleTime: options?.staleTime,\n gcTime: options?.gcTime,\n })\n}\n\n// --- Position reads ---\n\nexport function usePosition(\n poolAddress: Address,\n owner: Address,\n tokenId: bigint,\n options?: QueryOptions,\n) {\n const { publicClient, chainId, clientScope } = usePanopticContext()\n return useQuery({\n queryKey: [\n ...queryKeys.position(chainId, poolAddress, tokenId),\n getClientCacheScopeKey(publicClient, clientScope),\n owner,\n ],\n queryFn: () => getPosition({ client: publicClient, poolAddress, owner, tokenId }),\n enabled: options?.enabled,\n refetchInterval: options?.refetchInterval,\n staleTime: options?.staleTime,\n gcTime: options?.gcTime,\n })\n}\n\nexport function usePositions(\n poolAddress: Address,\n tokenIds: bigint[],\n owner?: Address,\n options?: QueryOptions,\n) {\n const ctx = usePanopticContext()\n const resolvedOwner = owner ?? ctx.account\n return useQuery({\n queryKey: [\n ...queryKeys.positions(ctx.chainId, poolAddress, resolvedOwner ?? ('' as Address)),\n getClientCacheScopeKey(ctx.publicClient, ctx.clientScope),\n tokenIds,\n ],\n queryFn: () => {\n if (!resolvedOwner) throw new Error('owner required for getPositions')\n return getPositions({ client: ctx.publicClient, poolAddress, owner: resolvedOwner, tokenIds })\n },\n enabled: (options?.enabled ?? true) && !!resolvedOwner,\n refetchInterval: options?.refetchInterval,\n staleTime: options?.staleTime,\n gcTime: options?.gcTime,\n })\n}\n\nexport function usePositionGreeks(\n poolAddress: Address,\n tokenId: bigint,\n owner: Address,\n options?: QueryOptions,\n) {\n const { publicClient, chainId, clientScope } = usePanopticContext()\n return useQuery({\n queryKey: [\n ...queryKeys.positionGreeks(chainId, poolAddress, tokenId),\n getClientCacheScopeKey(publicClient, clientScope),\n owner,\n ],\n queryFn: () => getPositionGreeks({ client: publicClient, poolAddress, tokenId, owner }),\n enabled: options?.enabled,\n refetchInterval: options?.refetchInterval,\n staleTime: options?.staleTime,\n gcTime: options?.gcTime,\n })\n}\n\n// --- Account reads ---\n\nexport function useAccountCollateral(\n poolAddress: Address,\n account?: Address,\n options?: QueryOptions,\n) {\n const ctx = usePanopticContext()\n const resolvedAccount = account ?? ctx.account\n return useQuery({\n queryKey: [\n ...queryKeys.accountCollateral(ctx.chainId, poolAddress, resolvedAccount ?? ('' as Address)),\n getClientCacheScopeKey(ctx.publicClient, ctx.clientScope),\n ],\n queryFn: () => {\n if (!resolvedAccount) throw new Error('account required for getAccountCollateral')\n return getAccountCollateral({\n client: ctx.publicClient,\n poolAddress,\n account: resolvedAccount,\n })\n },\n enabled: (options?.enabled ?? true) && !!resolvedAccount,\n refetchInterval: options?.refetchInterval,\n staleTime: options?.staleTime,\n gcTime: options?.gcTime,\n })\n}\n\nexport function useInterestState(poolAddress: Address, account?: Address, options?: QueryOptions) {\n const ctx = usePanopticContext()\n const resolvedAccount = account ?? ctx.account\n return useQuery({\n queryKey: [\n ...queryKeys.interestState(ctx.chainId, poolAddress, resolvedAccount ?? ('' as Address)),\n getClientCacheScopeKey(ctx.publicClient, ctx.clientScope),\n ],\n queryFn: () => {\n if (!resolvedAccount) throw new Error('account required for getInterestState')\n return getInterestState({\n client: ctx.publicClient,\n poolAddress,\n account: resolvedAccount,\n })\n },\n enabled: (options?.enabled ?? true) && !!resolvedAccount,\n refetchInterval: options?.refetchInterval,\n staleTime: options?.staleTime,\n gcTime: options?.gcTime,\n })\n}\n\nexport function useAccountSummaryBasic(\n poolAddress: Address,\n tokenIds: bigint[],\n account?: Address,\n options?: QueryOptions,\n) {\n const ctx = usePanopticContext()\n const resolvedAccount = account ?? ctx.account\n return useQuery({\n queryKey: [\n ...queryKeys.accountSummaryBasic(\n ctx.chainId,\n poolAddress,\n resolvedAccount ?? ('' as Address),\n ),\n getClientCacheScopeKey(ctx.publicClient, ctx.clientScope),\n tokenIds,\n ],\n queryFn: () => {\n if (!resolvedAccount) throw new Error('account required for getAccountSummaryBasic')\n return getAccountSummaryBasic({\n client: ctx.publicClient,\n poolAddress,\n account: resolvedAccount,\n chainId: ctx.chainId,\n tokenIds,\n })\n },\n enabled: (options?.enabled ?? true) && !!resolvedAccount,\n refetchInterval: options?.refetchInterval,\n staleTime: options?.staleTime,\n gcTime: options?.gcTime,\n })\n}\n\nexport function useAccountSummaryRisk(\n poolAddress: Address,\n tokenIds: bigint[],\n queryAddress: Address,\n account?: Address,\n options?: QueryOptions & { atTick?: bigint; includePendingPremium?: boolean },\n) {\n const ctx = usePanopticContext()\n const resolvedAccount = account ?? ctx.account\n return useQuery({\n queryKey: [\n ...queryKeys.accountSummaryRisk(ctx.chainId, poolAddress, resolvedAccount!),\n getClientCacheScopeKey(ctx.publicClient, ctx.clientScope),\n tokenIds,\n queryAddress,\n options?.atTick,\n options?.includePendingPremium,\n ],\n queryFn: () =>\n getAccountSummaryRisk({\n client: ctx.publicClient,\n poolAddress,\n account: resolvedAccount!,\n chainId: ctx.chainId,\n tokenIds,\n queryAddress,\n atTick: options?.atTick,\n includePendingPremium: options?.includePendingPremium,\n }),\n enabled: (options?.enabled ?? true) && !!resolvedAccount,\n refetchInterval: options?.refetchInterval,\n staleTime: options?.staleTime,\n gcTime: options?.gcTime,\n })\n}\n\nexport function useNetLiquidationValue(\n poolAddress: Address,\n tokenIds: bigint[],\n queryAddress: Address,\n account?: Address,\n options?: QueryOptions & { atTick?: bigint },\n) {\n const ctx = usePanopticContext()\n const resolvedAccount = account ?? ctx.account\n return useQuery({\n queryKey: [\n ...queryKeys.all,\n 'netLiquidationValue',\n ctx.chainId.toString(),\n poolAddress,\n resolvedAccount!,\n getAtTickCacheKey(options?.atTick),\n getClientCacheScopeKey(ctx.publicClient, ctx.clientScope),\n tokenIds,\n queryAddress,\n ],\n queryFn: () =>\n getNetLiquidationValue({\n client: ctx.publicClient,\n poolAddress,\n account: resolvedAccount!,\n tokenIds,\n atTick: options?.atTick,\n queryAddress,\n }),\n enabled: (options?.enabled ?? true) && !!resolvedAccount,\n refetchInterval: options?.refetchInterval,\n staleTime: options?.staleTime,\n gcTime: options?.gcTime,\n })\n}\n\nexport function useNetLiquidationValues(\n poolAddress: Address,\n tokenIds: bigint[],\n queryAddress: Address,\n atTicks: bigint[],\n account?: Address,\n options?: QueryOptions,\n) {\n const ctx = usePanopticContext()\n const resolvedAccount = account ?? ctx.account\n return useQuery({\n queryKey: [\n ...queryKeys.all,\n 'netLiquidationValues',\n ctx.chainId.toString(),\n poolAddress,\n resolvedAccount!,\n getClientCacheScopeKey(ctx.publicClient, ctx.clientScope),\n tokenIds,\n queryAddress,\n atTicks,\n ],\n queryFn: () =>\n getNetLiquidationValues({\n client: ctx.publicClient,\n poolAddress,\n account: resolvedAccount!,\n tokenIds,\n atTicks,\n queryAddress,\n }),\n enabled: (options?.enabled ?? true) && !!resolvedAccount && atTicks.length > 0,\n refetchInterval: options?.refetchInterval,\n staleTime: options?.staleTime,\n gcTime: options?.gcTime,\n })\n}\n\nexport function useLiquidationPrices(\n poolAddress: Address,\n tokenIds: bigint[],\n queryAddress: Address,\n account?: Address,\n options?: QueryOptions,\n) {\n const ctx = usePanopticContext()\n const resolvedAccount = account ?? ctx.account\n return useQuery({\n queryKey: [\n ...queryKeys.liquidationPrices(ctx.chainId, poolAddress, resolvedAccount!),\n getClientCacheScopeKey(ctx.publicClient, ctx.clientScope),\n tokenIds,\n queryAddress,\n ],\n queryFn: () =>\n getLiquidationPrices({\n client: ctx.publicClient,\n poolAddress,\n account: resolvedAccount!,\n tokenIds,\n queryAddress,\n }),\n enabled: (options?.enabled ?? true) && !!resolvedAccount,\n refetchInterval: options?.refetchInterval,\n staleTime: options?.staleTime,\n gcTime: options?.gcTime,\n })\n}\n\nexport function useAccountGreeks(poolAddress: Address, account?: Address, options?: QueryOptions) {\n const ctx = usePanopticContext()\n const storage = useRequireStorage()\n const resolvedAccount = account ?? ctx.account\n return useQuery({\n queryKey: [\n ...queryKeys.accountGreeks(ctx.chainId, poolAddress, resolvedAccount!),\n getClientCacheScopeKey(ctx.publicClient, ctx.clientScope),\n getStorageCacheScopeKey(storage, ctx.storageScope),\n ],\n queryFn: () =>\n getAccountGreeks({\n client: ctx.publicClient,\n chainId: ctx.chainId,\n poolAddress,\n account: resolvedAccount!,\n storage,\n }),\n enabled: (options?.enabled ?? true) && !!resolvedAccount,\n refetchInterval: options?.refetchInterval,\n staleTime: options?.staleTime,\n gcTime: options?.gcTime,\n })\n}\n\nexport function useMarginBuffer(\n poolAddress: Address,\n tokenIds: bigint[],\n queryAddress: Address,\n account?: Address,\n options?: QueryOptions,\n) {\n const ctx = usePanopticContext()\n const resolvedAccount = account ?? ctx.account\n return useQuery({\n queryKey: [\n ...queryKeys.marginBuffer(ctx.chainId, poolAddress, resolvedAccount!),\n getClientCacheScopeKey(ctx.publicClient, ctx.clientScope),\n tokenIds,\n queryAddress,\n ],\n queryFn: () =>\n getMarginBuffer({\n client: ctx.publicClient,\n poolAddress,\n account: resolvedAccount!,\n tokenIds,\n queryAddress,\n }),\n enabled: (options?.enabled ?? true) && !!resolvedAccount,\n refetchInterval: options?.refetchInterval,\n staleTime: options?.staleTime,\n gcTime: options?.gcTime,\n })\n}\n\nexport function useIsLiquidatable(\n poolAddress: Address,\n tokenIds: bigint[],\n queryAddress: Address,\n account?: Address,\n options?: QueryOptions,\n) {\n const ctx = usePanopticContext()\n const resolvedAccount = account ?? ctx.account\n return useQuery({\n queryKey: [\n ...queryKeys.isLiquidatable(ctx.chainId, poolAddress, resolvedAccount!),\n getClientCacheScopeKey(ctx.publicClient, ctx.clientScope),\n tokenIds,\n queryAddress,\n ],\n queryFn: () =>\n isLiquidatable({\n client: ctx.publicClient,\n poolAddress,\n account: resolvedAccount!,\n tokenIds,\n queryAddress,\n }),\n enabled: (options?.enabled ?? true) && !!resolvedAccount,\n refetchInterval: options?.refetchInterval,\n staleTime: options?.staleTime,\n gcTime: options?.gcTime,\n })\n}\n\nexport function useAccountPremia(\n poolAddress: Address,\n tokenIds: bigint[],\n account?: Address,\n options?: QueryOptions,\n) {\n const ctx = usePanopticContext()\n const resolvedAccount = account ?? ctx.account\n return useQuery({\n queryKey: [\n ...queryKeys.accountPremia(ctx.chainId, poolAddress, resolvedAccount!),\n getClientCacheScopeKey(ctx.publicClient, ctx.clientScope),\n tokenIds,\n ],\n queryFn: () =>\n getAccountPremia({\n client: ctx.publicClient,\n poolAddress,\n account: resolvedAccount!,\n tokenIds,\n }),\n enabled: (options?.enabled ?? true) && !!resolvedAccount,\n refetchInterval: options?.refetchInterval,\n staleTime: options?.staleTime,\n gcTime: options?.gcTime,\n })\n}\n\nexport function usePositionsWithPremia(\n poolAddress: Address,\n tokenIds: bigint[],\n account?: Address,\n options?: QueryOptions,\n) {\n const ctx = usePanopticContext()\n const resolvedAccount = account ?? ctx.account\n return useQuery({\n queryKey: [\n ...queryKeys.positionsWithPremia(ctx.chainId, poolAddress, resolvedAccount!),\n getClientCacheScopeKey(ctx.publicClient, ctx.clientScope),\n tokenIds,\n ],\n queryFn: () =>\n getPositionsWithPremia({\n client: ctx.publicClient,\n poolAddress,\n account: resolvedAccount!,\n tokenIds,\n }),\n enabled: (options?.enabled ?? true) && !!resolvedAccount,\n refetchInterval: options?.refetchInterval,\n staleTime: options?.staleTime,\n gcTime: options?.gcTime,\n })\n}\n\n// --- ERC4626 previews ---\n\nexport function usePreviewDeposit(\n poolAddress: Address,\n tokenIndex: 0 | 1,\n amount: bigint,\n options?: QueryOptions,\n) {\n const { publicClient, chainId, clientScope } = usePanopticContext()\n return useQuery({\n queryKey: [\n ...queryKeys.erc4626Preview(chainId, poolAddress, 'deposit', amount),\n getClientCacheScopeKey(publicClient, clientScope),\n tokenIndex,\n ],\n queryFn: () => previewDeposit({ client: publicClient, poolAddress, tokenIndex, amount }),\n enabled: options?.enabled,\n refetchInterval: options?.refetchInterval,\n staleTime: options?.staleTime,\n gcTime: options?.gcTime,\n })\n}\n\nexport function usePreviewWithdraw(\n poolAddress: Address,\n tokenIndex: 0 | 1,\n amount: bigint,\n options?: QueryOptions,\n) {\n const { publicClient, chainId, clientScope } = usePanopticContext()\n return useQuery({\n queryKey: [\n ...queryKeys.erc4626Preview(chainId, poolAddress, 'withdraw', amount),\n getClientCacheScopeKey(publicClient, clientScope),\n tokenIndex,\n ],\n queryFn: () => previewWithdraw({ client: publicClient, poolAddress, tokenIndex, amount }),\n enabled: options?.enabled,\n refetchInterval: options?.refetchInterval,\n staleTime: options?.staleTime,\n gcTime: options?.gcTime,\n })\n}\n\nexport function usePreviewMint(\n poolAddress: Address,\n tokenIndex: 0 | 1,\n amount: bigint,\n options?: QueryOptions,\n) {\n const { publicClient, chainId, clientScope } = usePanopticContext()\n return useQuery({\n queryKey: [\n ...queryKeys.erc4626Preview(chainId, poolAddress, 'mint', amount),\n getClientCacheScopeKey(publicClient, clientScope),\n tokenIndex,\n ],\n queryFn: () => previewMint({ client: publicClient, poolAddress, tokenIndex, amount }),\n enabled: options?.enabled,\n refetchInterval: options?.refetchInterval,\n staleTime: options?.staleTime,\n gcTime: options?.gcTime,\n })\n}\n\nexport function usePreviewRedeem(\n poolAddress: Address,\n tokenIndex: 0 | 1,\n amount: bigint,\n options?: QueryOptions,\n) {\n const { publicClient, chainId, clientScope } = usePanopticContext()\n return useQuery({\n queryKey: [\n ...queryKeys.erc4626Preview(chainId, poolAddress, 'redeem', amount),\n getClientCacheScopeKey(publicClient, clientScope),\n tokenIndex,\n ],\n queryFn: () => previewRedeem({ client: publicClient, poolAddress, tokenIndex, amount }),\n enabled: options?.enabled,\n refetchInterval: options?.refetchInterval,\n staleTime: options?.staleTime,\n gcTime: options?.gcTime,\n })\n}\n\n// --- Collateral estimation ---\n\nexport function useEstimateCollateralRequired(\n poolAddress: Address,\n tokenId: bigint,\n positionSize: bigint,\n queryAddress: Address,\n account?: Address,\n options?: QueryOptions & { atTick?: bigint },\n) {\n const ctx = usePanopticContext()\n // `getRequiredBase` is account-agnostic (it evaluates a synthetic position under\n // `address(0xdead)`), so the estimate must NOT be gated on a connected account.\n // Gating it here was what made a disconnected / view-only user fall through to the\n // UI's buggy client-side per-leg math instead of this on-chain number.\n const resolvedAccount = account ?? ctx.account ?? zeroAddress\n return useQuery({\n queryKey: [\n ...queryKeys.collateralEstimate(ctx.chainId, poolAddress, resolvedAccount, tokenId),\n getClientCacheScopeKey(ctx.publicClient, ctx.clientScope),\n positionSize,\n queryAddress,\n options?.atTick,\n ],\n queryFn: () =>\n estimateCollateralRequired({\n client: ctx.publicClient,\n poolAddress,\n account: resolvedAccount,\n tokenId,\n positionSize,\n queryAddress,\n atTick: options?.atTick,\n }),\n enabled: options?.enabled ?? true,\n refetchInterval: options?.refetchInterval,\n staleTime: options?.staleTime,\n gcTime: options?.gcTime,\n })\n}\n\nexport function useRequiredCreditForITM(\n poolAddress: Address,\n tokenId: bigint,\n positionSize: bigint,\n account?: Address,\n options?: QueryOptions & { existingPositionIds?: bigint[] },\n) {\n const ctx = usePanopticContext()\n const resolvedAccount = account ?? ctx.account\n return useQuery({\n queryKey: [\n ...queryKeys.requiredCreditForITM(\n ctx.chainId,\n poolAddress,\n resolvedAccount ?? ('' as Address),\n tokenId,\n ),\n getClientCacheScopeKey(ctx.publicClient, ctx.clientScope),\n positionSize.toString(),\n (options?.existingPositionIds ?? []).map(String).join(','),\n positionSize,\n options?.existingPositionIds,\n ],\n queryFn: () => {\n if (!resolvedAccount) throw new Error('account required for getRequiredCreditForITM')\n return getRequiredCreditForITM({\n client: ctx.publicClient,\n poolAddress,\n account: resolvedAccount,\n tokenId,\n positionSize,\n existingPositionIds: options?.existingPositionIds,\n })\n },\n enabled: (options?.enabled ?? true) && !!resolvedAccount && tokenId !== 0n && positionSize > 0n,\n refetchInterval: options?.refetchInterval,\n placeholderData: keepPreviousData,\n })\n}\n\nexport function useFlowNeutralTokenId(\n poolAddress: Address,\n tokenId: bigint,\n positionSize: bigint,\n account?: Address,\n options?: QueryOptions & {\n existingPositionIds?: bigint[]\n neutralizeITM?: boolean\n swapAtMint?: boolean\n /** Size to measure the base flow at (defaults to positionSize). See SDK param. */\n referenceSize?: bigint\n /** PanopticQuery address — gates OTM on true intrinsic. See SDK param. */\n queryAddress?: Address\n },\n) {\n const ctx = usePanopticContext()\n const resolvedAccount = account ?? ctx.account\n const neutralizeITM = options?.neutralizeITM ?? true\n const swapAtMint = options?.swapAtMint ?? true\n const referenceSize = options?.referenceSize\n const queryAddress = options?.queryAddress\n return useQuery({\n queryKey: [\n ...queryKeys.flowNeutralTokenId(ctx.chainId, poolAddress, tokenId),\n getClientCacheScopeKey(ctx.publicClient, ctx.clientScope),\n resolvedAccount ?? '',\n positionSize.toString(),\n (options?.existingPositionIds ?? []).map(String).join(','),\n neutralizeITM,\n swapAtMint,\n positionSize,\n options?.existingPositionIds,\n (referenceSize ?? 0n).toString(),\n referenceSize,\n queryAddress ?? '',\n ],\n queryFn: () => {\n if (!resolvedAccount) throw new Error('account required for createFlowNeutralTokenId')\n return createFlowNeutralTokenId({\n client: ctx.publicClient,\n poolAddress,\n account: resolvedAccount,\n tokenId,\n positionSize,\n existingPositionIds: options?.existingPositionIds,\n swapAtMint,\n referenceSize,\n queryAddress,\n })\n },\n enabled:\n (options?.enabled ?? true) &&\n neutralizeITM &&\n !!resolvedAccount &&\n tokenId !== 0n &&\n positionSize > 0n,\n refetchInterval: options?.refetchInterval,\n // Intentionally NO keepPreviousData: the result encodes a specific tokenId that\n // will be minted, so serving stale data from a prior legs/size input could mint\n // the wrong position. Consumers must gate the mint on a fresh, matching result.\n })\n}\n\nexport function useMaxPositionSize(\n poolAddress: Address,\n tokenId: bigint,\n queryAddress: Address,\n account?: Address,\n options?: QueryOptions & {\n existingPositionIds?: bigint[]\n swapAtMint?: boolean\n precisionPct?: number\n usePremiaAsCollateral?: boolean\n },\n) {\n const ctx = usePanopticContext()\n const resolvedAccount = account ?? ctx.account\n return useQuery({\n queryKey: [\n ...queryKeys.maxPositionSize(\n ctx.chainId,\n poolAddress,\n resolvedAccount ?? ('' as Address),\n tokenId,\n ),\n getClientCacheScopeKey(ctx.publicClient, ctx.clientScope),\n queryAddress,\n options?.existingPositionIds?.map(String).join(',') ?? '',\n options?.existingPositionIds,\n options?.swapAtMint ?? false,\n options?.precisionPct ?? 1,\n options?.usePremiaAsCollateral ?? false,\n ],\n queryFn: () => {\n if (!resolvedAccount) throw new Error('account required for getMaxPositionSize')\n return getMaxPositionSize({\n client: ctx.publicClient,\n poolAddress,\n account: resolvedAccount,\n tokenId,\n queryAddress,\n existingPositionIds: options?.existingPositionIds,\n swapAtMint: options?.swapAtMint,\n precisionPct: options?.precisionPct,\n usePremiaAsCollateral: options?.usePremiaAsCollateral,\n })\n },\n enabled: (options?.enabled ?? true) && !!resolvedAccount,\n refetchInterval: options?.refetchInterval,\n placeholderData: keepPreviousData,\n })\n}\n\nexport function useOptimizeRiskPartners(\n poolAddress: Address,\n tokenId: bigint,\n queryAddress: Address,\n atTick?: bigint,\n options?: QueryOptions,\n) {\n const { publicClient, chainId, clientScope } = usePanopticContext()\n return useQuery({\n queryKey: [\n ...queryKeys.optimizeRiskPartners(chainId, poolAddress, tokenId),\n getClientCacheScopeKey(publicClient, clientScope),\n queryAddress,\n getAtTickCacheKey(atTick),\n ],\n queryFn: () =>\n optimizeTokenIdRiskPartners({\n client: publicClient,\n poolAddress,\n tokenId,\n queryAddress,\n atTick,\n }),\n enabled: options?.enabled,\n refetchInterval: options?.refetchInterval,\n placeholderData: keepPreviousData,\n })\n}\n\nexport function useMaxWithdrawable(\n collateralTrackerAddress: Address,\n positionIdList: bigint[],\n totalAssets: bigint,\n account?: Address,\n options?: QueryOptions & { client?: PublicClient },\n) {\n const ctx = usePanopticContext()\n const client = options?.client ?? ctx.publicClient\n const resolvedAccount = account ?? ctx.account\n return useQuery({\n queryKey: [\n ...queryKeys.maxWithdrawable(\n ctx.chainId,\n collateralTrackerAddress,\n positionIdList,\n totalAssets,\n resolvedAccount ?? ('' as Address),\n ),\n getClientCacheScopeKey(client, ctx.clientScope),\n ],\n queryFn: () => {\n if (!resolvedAccount) throw new Error('account required for getMaxWithdrawable')\n return getMaxWithdrawable({\n client,\n collateralTrackerAddress,\n account: resolvedAccount,\n positionIdList,\n totalAssets,\n })\n },\n enabled: (options?.enabled ?? true) && !!resolvedAccount && totalAssets > 0n,\n refetchInterval: options?.refetchInterval,\n staleTime: options?.staleTime,\n gcTime: options?.gcTime,\n })\n}\n\n/**\n * Read the maximum redeemable shares (`maxRedeem`) for an account on a collateral tracker.\n *\n * Redeeming exactly this many shares performs a dust-free full exit (it burns the account's\n * whole available share balance), so it is the correct primitive for a MAX withdraw when the\n * account has no open positions. Returns 0 when positions are open.\n */\nexport function useMaxRedeem(\n collateralTrackerAddress: Address,\n account?: Address,\n options?: QueryOptions & { client?: PublicClient },\n) {\n const ctx = usePanopticContext()\n const client = options?.client ?? ctx.publicClient\n const resolvedAccount = account ?? ctx.account\n return useQuery({\n queryKey: [\n ...queryKeys.maxRedeem(\n ctx.chainId,\n collateralTrackerAddress,\n resolvedAccount ?? ('' as Address),\n ),\n getClientCacheScopeKey(client, ctx.clientScope),\n ],\n queryFn: () => {\n if (!resolvedAccount) throw new Error('account required for getMaxRedeem')\n return getMaxRedeem({ client, collateralTrackerAddress, account: resolvedAccount })\n },\n enabled: (options?.enabled ?? true) && !!resolvedAccount,\n refetchInterval: options?.refetchInterval,\n staleTime: options?.staleTime,\n gcTime: options?.gcTime,\n })\n}\n\n// --- Open position preview ---\n\nexport function useOpenPositionPreview(\n poolAddress: Address,\n account: Address | undefined,\n existingPositionIds: bigint[],\n tokenId: bigint,\n positionSize: bigint,\n queryAddress: Address,\n tickLimitLow: bigint,\n tickLimitHigh: bigint,\n options?: QueryOptions & {\n spreadLimit?: bigint\n swapAtMint?: boolean\n usePremiaAsCollateral?: boolean\n blockNumber?: bigint\n },\n) {\n const ctx = usePanopticContext()\n const resolvedAccount = account ?? ctx.account\n return useQuery({\n // eslint-disable-next-line @tanstack/query/exhaustive-deps -- deps serialized as strings\n queryKey: [\n ...queryKeys.all,\n 'openPositionPreview',\n ctx.chainId.toString(),\n poolAddress,\n resolvedAccount!,\n getClientCacheScopeKey(ctx.publicClient, ctx.clientScope),\n tokenId.toString(),\n positionSize.toString(),\n existingPositionIds.map(String).join(','),\n queryAddress,\n tickLimitLow.toString(),\n tickLimitHigh.toString(),\n options?.spreadLimit?.toString(),\n options?.swapAtMint,\n options?.usePremiaAsCollateral,\n options?.blockNumber?.toString(),\n ],\n queryFn: () =>\n getOpenPositionPreview({\n client: ctx.publicClient,\n poolAddress,\n account: resolvedAccount!,\n existingPositionIds,\n tokenId,\n positionSize,\n queryAddress,\n tickLimitLow,\n tickLimitHigh,\n spreadLimit: options?.spreadLimit,\n swapAtMint: options?.swapAtMint,\n usePremiaAsCollateral: options?.usePremiaAsCollateral,\n chainId: ctx.chainId,\n blockNumber: options?.blockNumber,\n }),\n enabled: (options?.enabled ?? true) && !!resolvedAccount && tokenId !== 0n,\n staleTime: options?.staleTime ?? 0,\n })\n}\n\n// --- Storage-backed reads ---\n\nexport function useTrackedPositionIds(\n poolAddress: Address,\n account?: Address,\n options?: QueryOptions,\n) {\n const ctx = usePanopticContext()\n const storage = useRequireStorage()\n const resolvedAccount = account ?? ctx.account\n return useQuery({\n queryKey: [\n ...queryKeys.trackedPositionIds(ctx.chainId, poolAddress, resolvedAccount!),\n getStorageCacheScopeKey(storage, ctx.storageScope),\n ],\n queryFn: () =>\n getTrackedPositionIds({\n chainId: ctx.chainId,\n poolAddress,\n account: resolvedAccount!,\n storage,\n }),\n enabled: (options?.enabled ?? true) && !!resolvedAccount,\n refetchInterval: options?.refetchInterval,\n staleTime: options?.staleTime,\n gcTime: options?.gcTime,\n })\n}\n\nexport function useTradeHistory(poolAddress: Address, account?: Address, options?: QueryOptions) {\n const ctx = usePanopticContext()\n const storage = useRequireStorage()\n const resolvedAccount = account ?? ctx.account\n return useQuery({\n queryKey: [\n ...queryKeys.tradeHistory(ctx.chainId, poolAddress, resolvedAccount!),\n getStorageCacheScopeKey(storage, ctx.storageScope),\n ],\n queryFn: () =>\n getTradeHistory({ chainId: ctx.chainId, poolAddress, account: resolvedAccount!, storage }),\n enabled: (options?.enabled ?? true) && !!resolvedAccount,\n refetchInterval: options?.refetchInterval,\n staleTime: options?.staleTime,\n gcTime: options?.gcTime,\n })\n}\n\nexport function useRealizedPnL(poolAddress: Address, account?: Address, options?: QueryOptions) {\n const ctx = usePanopticContext()\n const storage = useRequireStorage()\n const resolvedAccount = account ?? ctx.account\n return useQuery({\n queryKey: [\n ...queryKeys.realizedPnL(ctx.chainId, poolAddress, resolvedAccount!),\n getStorageCacheScopeKey(storage, ctx.storageScope),\n ],\n queryFn: () =>\n getRealizedPnL({ chainId: ctx.chainId, poolAddress, account: resolvedAccount!, storage }),\n enabled: (options?.enabled ?? true) && !!resolvedAccount,\n refetchInterval: options?.refetchInterval,\n staleTime: options?.staleTime,\n gcTime: options?.gcTime,\n })\n}\n\nexport function useClosedPositions(\n poolAddress: Address,\n account?: Address,\n options?: QueryOptions,\n) {\n const ctx = usePanopticContext()\n const storage = useRequireStorage()\n const resolvedAccount = account ?? ctx.account\n return useQuery({\n queryKey: [\n ...queryKeys.closedPositions(ctx.chainId, poolAddress, resolvedAccount!),\n getStorageCacheScopeKey(storage, ctx.storageScope),\n ],\n queryFn: () =>\n getClosedPositions({ chainId: ctx.chainId, poolAddress, account: resolvedAccount!, storage }),\n enabled: (options?.enabled ?? true) && !!resolvedAccount,\n refetchInterval: options?.refetchInterval,\n staleTime: options?.staleTime,\n gcTime: options?.gcTime,\n })\n}\n\nexport function useSyncStatus(poolAddress: Address, account?: Address, options?: QueryOptions) {\n const ctx = usePanopticContext()\n const storage = useRequireStorage()\n const resolvedAccount = account ?? ctx.account\n return useQuery({\n queryKey: [\n ...queryKeys.syncStatus(ctx.chainId, poolAddress, resolvedAccount!),\n getClientCacheScopeKey(ctx.publicClient, ctx.clientScope),\n getStorageCacheScopeKey(storage, ctx.storageScope),\n ],\n queryFn: () =>\n getSyncStatus({\n client: ctx.publicClient,\n chainId: ctx.chainId,\n poolAddress,\n account: resolvedAccount!,\n storage,\n }),\n enabled: (options?.enabled ?? true) && !!resolvedAccount,\n refetchInterval: options?.refetchInterval,\n staleTime: options?.staleTime,\n gcTime: options?.gcTime,\n })\n}\n\n// --- Factory reads ---\n\ntype OmitFactoryClient<T> = T extends unknown ? Omit<T, 'client'> : never\n\nexport function usePanopticPoolAddress(\n params?: OmitFactoryClient<GetPanopticPoolAddressParams>,\n options?: QueryOptions,\n) {\n const { publicClient, clientScope } = usePanopticContext()\n return useQuery({\n queryKey: [\n ...queryKeys.all,\n 'factory',\n 'getPanopticPool',\n params?.factoryAddress,\n getClientCacheScopeKey(publicClient, clientScope),\n params,\n ] as const,\n queryFn: () => {\n if (!params) throw new PanopticValidationError('params is required')\n return getPanopticPoolAddress({ client: publicClient, ...params })\n },\n enabled: (options?.enabled ?? true) && params !== undefined,\n refetchInterval: options?.refetchInterval,\n staleTime: options?.staleTime,\n gcTime: options?.gcTime,\n })\n}\n\nexport function useFactoryTokenURI(\n params?: OmitFactoryClient<GetFactoryTokenURIParams>,\n options?: QueryOptions,\n) {\n const { publicClient, clientScope } = usePanopticContext()\n return useQuery({\n queryKey: [\n ...queryKeys.all,\n 'factory',\n 'tokenURI',\n params?.factoryAddress,\n params?.tokenId?.toString(),\n getClientCacheScopeKey(publicClient, clientScope),\n params,\n ] as const,\n queryFn: () => {\n if (!params) throw new PanopticValidationError('params is required')\n return getFactoryTokenURI({ client: publicClient, ...params })\n },\n enabled: (options?.enabled ?? true) && params !== undefined,\n refetchInterval: options?.refetchInterval,\n staleTime: options?.staleTime,\n gcTime: options?.gcTime,\n })\n}\n\nexport function useFactoryOwnerOf(\n params?: OmitFactoryClient<GetFactoryOwnerOfParams>,\n options?: QueryOptions,\n) {\n const { publicClient, clientScope } = usePanopticContext()\n return useQuery({\n queryKey: [\n ...queryKeys.all,\n 'factory',\n 'ownerOf',\n params?.factoryAddress,\n params?.tokenId?.toString(),\n getClientCacheScopeKey(publicClient, clientScope),\n params,\n ] as const,\n queryFn: () => {\n if (!params) throw new PanopticValidationError('params is required')\n return getFactoryOwnerOf({ client: publicClient, ...params })\n },\n enabled: (options?.enabled ?? true) && params !== undefined,\n refetchInterval: options?.refetchInterval,\n staleTime: options?.staleTime,\n gcTime: options?.gcTime,\n })\n}\n\nexport function useMinePoolAddress() {\n return useMutation({\n mutationFn: (params: MinePoolAddressLocalParams) => minePoolAddressLocalAsync(params),\n })\n}\n\nexport function useFactoryConstructMetadata(\n params?: OmitFactoryClient<GetFactoryConstructMetadataParams>,\n options?: QueryOptions,\n) {\n const { publicClient, clientScope } = usePanopticContext()\n return useQuery({\n queryKey: [\n ...queryKeys.all,\n 'factory',\n 'constructMetadata',\n params?.factoryAddress,\n params?.panopticPoolAddress,\n params?.symbol0,\n params?.symbol1,\n params?.fee?.toString(),\n getClientCacheScopeKey(publicClient, clientScope),\n params,\n ] as const,\n queryFn: () => {\n if (!params) throw new PanopticValidationError('params is required')\n return getFactoryConstructMetadata({ client: publicClient, ...params })\n },\n enabled: (options?.enabled ?? true) && params !== undefined,\n refetchInterval: options?.refetchInterval,\n staleTime: options?.staleTime,\n gcTime: options?.gcTime,\n })\n}\n\ntype OmitMineClient<T> = T extends unknown ? Omit<T, 'client'> : never\n\nexport function useSimulateDeployNewPool(\n params?: OmitMineClient<SimulateDeployNewPoolParams>,\n options?: QueryOptions,\n) {\n const { publicClient, clientScope } = usePanopticContext()\n return useQuery({\n queryKey: [\n ...queryKeys.all,\n 'factory',\n 'simulateDeployNewPool',\n params?.factoryAddress,\n params?.account,\n params?.salt?.toString(),\n getClientCacheScopeKey(publicClient, clientScope),\n params,\n ] as const,\n queryFn: () => {\n if (!params) throw new PanopticValidationError('params is required')\n return simulateDeployNewPool({ client: publicClient, ...params })\n },\n enabled: (options?.enabled ?? true) && params !== undefined,\n refetchInterval: options?.refetchInterval,\n staleTime: options?.staleTime,\n gcTime: options?.gcTime,\n })\n}\n\n// --- Price history ---\n\n/** Timestamp-based time range. Start/end resolved to blocks via RPC binary search or estimation. */\nexport interface TimestampTimeRange {\n mode: 'timestamps'\n /** Start of the range (Unix seconds) */\n startTimestamp: number\n /** End of the range (Unix seconds). Defaults to now if omitted. */\n endTimestamp?: number\n /** Number of evenly-spaced data points to fetch */\n points: number\n /** Extra block numbers to include in the fetched set (e.g. blockAtMint) */\n pinnedBlocks?: bigint[]\n /**\n * Block resolution strategy.\n * - 'exact': RPC binary search (~25 sequential getBlock calls). Default.\n * - 'estimate': 2-RPC linear extrapolation. Suitable for charts where\n * ±N-block error is invisible. Saves ~23 RPCs per call.\n */\n resolution?: 'exact' | 'estimate'\n}\n\n/** Block-based time range. No RPC resolution needed. */\nexport interface BlockTimeRange {\n mode: 'blocks'\n /** Start block number */\n startBlock: bigint\n /** End block number. Defaults to latest if omitted. */\n endBlock?: bigint\n /** Number of evenly-spaced data points to fetch */\n points: number\n /** Extra block numbers to include in the fetched set (e.g. blockAtMint) */\n pinnedBlocks?: bigint[]\n}\n\nexport type PriceHistoryTimeRange = TimestampTimeRange | BlockTimeRange\n\n/**\n * Build a stable string cache key from time range params (no object references).\n */\nfunction buildRangeHash(timeRange: PriceHistoryTimeRange): string {\n const pinnedSuffix = timeRange.pinnedBlocks?.length\n ? `-pin:${timeRange.pinnedBlocks.join(',')}`\n : ''\n return timeRange.mode === 'timestamps'\n ? `ts:${timeRange.startTimestamp}-${timeRange.endTimestamp ?? 'now'}-${timeRange.points}-${timeRange.resolution ?? 'exact'}${pinnedSuffix}`\n : `blk:${timeRange.startBlock}-${timeRange.endBlock ?? 'latest'}-${timeRange.points}${pinnedSuffix}`\n}\n\n/**\n * Resolve a PriceHistoryTimeRange to start/end block numbers.\n */\nasync function resolveTimeRange(\n client: PublicClient,\n timeRange: PriceHistoryTimeRange,\n): Promise<{ startBlock: bigint; endBlock: bigint }> {\n if (timeRange.mode === 'timestamps') {\n const resolver =\n timeRange.resolution === 'estimate' ? estimateBlockNumbers : resolveBlockNumbers\n if (timeRange.endTimestamp !== undefined) {\n const resolved = await resolver({\n client,\n timestamps: [timeRange.startTimestamp, timeRange.endTimestamp],\n })\n return { startBlock: resolved[0], endBlock: resolved[1] }\n } else {\n const [resolved, latest] = await Promise.all([\n resolver({ client, timestamps: [timeRange.startTimestamp] }),\n client.getBlockNumber(),\n ])\n return { startBlock: resolved[0], endBlock: latest }\n }\n } else {\n return {\n startBlock: timeRange.startBlock,\n endBlock: timeRange.endBlock ?? (await client.getBlockNumber()),\n }\n }\n}\n\n/**\n * Hook to fetch historical price data (tick + sqrtPriceX96) for a pool.\n *\n * Supports two modes:\n * - **timestamps**: Resolves start/end timestamps to blocks (2 RPC binary searches),\n * then interpolates the blocks in between (pure math).\n * - **blocks**: Uses start/end blocks directly, interpolates in between.\n * Zero resolution overhead.\n *\n * In both cases, the actual price reads are O(points) slot0 calls.\n * Reads at different historical blocks cannot be coalesced into one multicall.\n *\n * @param poolConfig - Pool version config (V3 pool address or V4 StateView + poolId)\n * @param timeRange - Time range specification (timestamps or blocks)\n * @param options - Query options (enabled, refetchInterval, staleTime, gcTime)\n */\nexport function usePriceHistory(\n poolConfig: PoolVersionConfig,\n timeRange: PriceHistoryTimeRange,\n options?: QueryOptions,\n) {\n const { publicClient, chainId, clientScope } = usePanopticContext()\n\n const poolKey = poolConfig.version === 'v3' ? poolConfig.poolAddress : poolConfig.poolId\n const rangeHash = buildRangeHash(timeRange)\n\n return useQuery({\n // rangeHash serializes timeRange; poolKey serializes poolConfig\n // eslint-disable-next-line @tanstack/query/exhaustive-deps\n queryKey: [\n ...queryKeys.priceHistory(chainId, poolKey, rangeHash),\n getClientCacheScopeKey(publicClient, clientScope),\n ],\n queryFn: async () => {\n const { startBlock, endBlock } = await resolveTimeRange(publicClient, timeRange)\n let blockNumbers = interpolateBlocks(startBlock, endBlock, timeRange.points)\n\n // Merge pinned blocks (e.g. blockAtMint) into the sorted array\n if (timeRange.pinnedBlocks?.length) {\n const blockSet = new Set(blockNumbers.map(String))\n const extras = timeRange.pinnedBlocks.filter(\n (b) => b >= startBlock && b <= endBlock && !blockSet.has(String(b)),\n )\n if (extras.length > 0) {\n blockNumbers = [...blockNumbers, ...extras].sort((a, b) => (a < b ? -1 : a > b ? 1 : 0))\n }\n }\n\n return getPriceHistory({ client: publicClient, blockNumbers, poolConfig })\n },\n enabled: (options?.enabled ?? true) && timeRange.points > 0,\n staleTime: options?.staleTime ?? Infinity,\n gcTime: options?.gcTime ?? 60 * 60_000,\n refetchInterval: options?.refetchInterval ?? false,\n refetchOnWindowFocus: false,\n refetchOnReconnect: false,\n })\n}\n\n/**\n * Hook to fetch historical streamia (streaming premia + Uniswap fee) data for a position.\n *\n * @param panopticPoolAddress - PanopticPool contract address\n * @param account - Account whose position to query\n * @param tokenId - The encoded tokenId\n * @param legs - Decoded legs with pre-computed liquidity\n * @param poolConfig - Pool version config (V3 pool address or V4 StateView + poolId)\n * @param timeRange - Time range specification (timestamps or blocks)\n * @param options - Query options + optional includeUniswapFees and settledEvents\n */\nexport function useStreamiaHistory(\n panopticPoolAddress: Address,\n account: Address,\n tokenId: bigint,\n legs: StreamiaLeg[],\n poolConfig: PoolVersionConfig,\n timeRange: PriceHistoryTimeRange,\n options?: QueryOptions & {\n includeUniswapFees?: boolean\n settledEvents?: Array<{ blockNumber: bigint; settled0: bigint; settled1: bigint }>\n },\n) {\n const { publicClient, chainId, clientScope } = usePanopticContext()\n\n const poolKey = poolConfig.version === 'v3' ? poolConfig.poolAddress : poolConfig.poolId\n const rangeHash = buildRangeHash(timeRange)\n\n const legsKey = legs.map((l) => `${l.lowerTick}:${l.upperTick}:${l.liquidity}`).join(',')\n const includeUniswapFees = options?.includeUniswapFees ?? true\n const settledEventsKey = options?.settledEvents\n ? options.settledEvents.map((e) => `${e.blockNumber}:${e.settled0}:${e.settled1}`).join(',')\n : ''\n\n return useQuery({\n // rangeHash serializes timeRange; poolKey serializes poolConfig; legsKey serializes legs\n // eslint-disable-next-line @tanstack/query/exhaustive-deps\n queryKey: [\n ...queryKeys.streamiaHistory(chainId, poolKey, rangeHash),\n getClientCacheScopeKey(publicClient, clientScope),\n panopticPoolAddress,\n account,\n tokenId.toString(),\n legsKey,\n includeUniswapFees,\n settledEventsKey,\n ],\n queryFn: async () => {\n const { startBlock, endBlock } = await resolveTimeRange(publicClient, timeRange)\n let blockNumbers = interpolateBlocks(startBlock, endBlock, timeRange.points)\n if (timeRange.pinnedBlocks?.length) {\n const pinSet = new Set(blockNumbers.map(String))\n const pins = timeRange.pinnedBlocks.filter(\n (b) => b >= startBlock && b <= endBlock && !pinSet.has(String(b)),\n )\n if (pins.length) {\n blockNumbers = [...blockNumbers, ...pins].sort((a, b) => (a < b ? -1 : a > b ? 1 : 0))\n }\n }\n return getStreamiaHistory({\n client: publicClient,\n panopticPoolAddress,\n account,\n tokenId,\n blockNumbers,\n legs,\n poolConfig,\n includeUniswapFees: options?.includeUniswapFees,\n settledEvents: options?.settledEvents,\n })\n },\n enabled: (options?.enabled ?? true) && timeRange.points > 0,\n staleTime: options?.staleTime ?? Infinity,\n gcTime: options?.gcTime ?? 60 * 60_000,\n refetchInterval: options?.refetchInterval ?? false,\n refetchOnWindowFocus: false,\n refetchOnReconnect: false,\n })\n}\n\n/**\n * Hook to fetch historical Uniswap fee data for a set of liquidity legs.\n *\n * @param legs - Decoded legs with pre-computed liquidity\n * @param poolConfig - Pool version config (V3 pool address or V4 StateView + poolId)\n * @param timeRange - Time range specification (timestamps or blocks)\n * @param options - Query options (enabled, refetchInterval, staleTime, gcTime)\n */\nexport function useUniswapFeeHistory(\n legs: StreamiaLeg[],\n poolConfig: PoolVersionConfig,\n timeRange: PriceHistoryTimeRange,\n options?: QueryOptions,\n) {\n const { publicClient, chainId, clientScope } = usePanopticContext()\n\n const poolKey = poolConfig.version === 'v3' ? poolConfig.poolAddress : poolConfig.poolId\n const rangeHash = buildRangeHash(timeRange)\n\n const legsKey = legs.map((l) => `${l.lowerTick}:${l.upperTick}:${l.liquidity}`).join(',')\n\n return useQuery({\n // rangeHash serializes timeRange; poolKey serializes poolConfig; legsKey serializes legs\n // eslint-disable-next-line @tanstack/query/exhaustive-deps\n queryKey: [\n ...queryKeys.uniswapFeeHistory(chainId, poolKey, rangeHash),\n getClientCacheScopeKey(publicClient, clientScope),\n legsKey,\n ],\n queryFn: async () => {\n const { startBlock, endBlock } = await resolveTimeRange(publicClient, timeRange)\n let blockNumbers = interpolateBlocks(startBlock, endBlock, timeRange.points)\n if (timeRange.pinnedBlocks?.length) {\n const pinSet = new Set(blockNumbers.map(String))\n const pins = timeRange.pinnedBlocks.filter(\n (b) => b >= startBlock && b <= endBlock && !pinSet.has(String(b)),\n )\n if (pins.length) {\n blockNumbers = [...blockNumbers, ...pins].sort((a, b) => (a < b ? -1 : a > b ? 1 : 0))\n }\n }\n return getUniswapFeeHistory({ client: publicClient, blockNumbers, legs, poolConfig })\n },\n enabled: (options?.enabled ?? true) && timeRange.points > 0 && legs.length > 0,\n staleTime: options?.staleTime ?? Infinity,\n gcTime: options?.gcTime ?? 60 * 60_000,\n refetchInterval: options?.refetchInterval ?? false,\n refetchOnWindowFocus: false,\n refetchOnReconnect: false,\n })\n}\n\n// --- Direct Uniswap V3 pool info (no Panoptic required) ---\n\n/**\n * Reads basic on-chain info (token0, token1, fee, tickSpacing, slot0, liquidity) from a Uniswap V3 pool.\n * @param poolAddress - The Uniswap V3 pool contract address.\n * @param options - Optional React Query options (`enabled`, `staleTime`, `gcTime`, `refetchInterval`).\n * @returns React Query result resolving to the pool info object.\n */\nexport function useUniswapV3PoolInfo(poolAddress: Address | undefined, options?: QueryOptions) {\n const { publicClient, chainId, clientScope } = usePanopticContext()\n return useQuery({\n queryKey: [\n ...queryKeys.all,\n 'uniswapV3PoolInfo',\n chainId.toString(),\n poolAddress,\n getClientCacheScopeKey(publicClient, clientScope),\n ],\n queryFn: () =>\n getUniswapV3PoolInfo({ client: publicClient, poolAddress: poolAddress as Address }),\n enabled: (options?.enabled ?? true) && !!poolAddress,\n refetchInterval: options?.refetchInterval,\n staleTime: options?.staleTime,\n gcTime: options?.gcTime,\n })\n}\n\n/**\n * Reads per-tick active liquidity from a Uniswap V3 pool via PanopticQuery's `getTickNetsV3`.\n * @param poolAddress - The Uniswap V3 pool contract address.\n * @param queryAddress - The PanopticQuery helper contract address.\n * @param args - Tick window: `startTick` (inclusive) and `nTicks` count to scan.\n * @param options - Optional React Query options (`enabled`, `staleTime`, `gcTime`, `refetchInterval`).\n * @returns React Query result resolving to `{ ticks, liquidityNets }` parallel arrays.\n */\nexport function useUniswapV3PoolLiquidities(\n poolAddress: Address | undefined,\n queryAddress: Address | undefined,\n args: { startTick: number; nTicks: bigint } | undefined,\n options?: QueryOptions,\n) {\n const { publicClient, chainId, clientScope } = usePanopticContext()\n return useQuery({\n // eslint-disable-next-line @tanstack/query/exhaustive-deps\n queryKey: [\n ...queryKeys.all,\n 'uniswapV3PoolLiquidities',\n chainId.toString(),\n poolAddress,\n queryAddress,\n args?.startTick,\n args?.nTicks,\n getClientCacheScopeKey(publicClient, clientScope),\n ],\n queryFn: () => {\n if (!poolAddress || !queryAddress || !args) {\n throw new PanopticValidationError('useUniswapV3PoolLiquidities: missing required args')\n }\n const { startTick, nTicks } = args\n return getUniswapV3PoolLiquidities({\n client: publicClient,\n poolAddress,\n queryAddress,\n startTick,\n nTicks,\n })\n },\n enabled: (options?.enabled ?? true) && !!poolAddress && !!queryAddress && !!args,\n refetchInterval: options?.refetchInterval,\n staleTime: options?.staleTime,\n gcTime: options?.gcTime,\n })\n}\n\n// --- Uniswap V4 direct reads (no Panoptic required) ---\n\n/**\n * Resolves a Uniswap V4 PoolKey from a poolId hash by scanning `Initialize` event logs on the PoolManager.\n * PoolKey is immutable, so results are cached indefinitely within the session by default.\n * @param poolManager - The Uniswap V4 PoolManager contract address.\n * @param poolId - The 32-byte poolId hash.\n * @param args - Optional `fromBlock` and `chunkSize` for log paging.\n * @param options - Optional React Query options (`enabled`, `staleTime`, `gcTime`, `refetchInterval`).\n * @returns React Query result resolving to the resolved `UniswapV4PoolKey`.\n */\nexport function useResolveUniswapV4PoolKey(\n poolManager: Address | undefined,\n poolId: `0x${string}` | undefined,\n args?: { fromBlock?: bigint; chunkSize?: bigint },\n options?: QueryOptions,\n) {\n const { publicClient, chainId, clientScope } = usePanopticContext()\n return useQuery({\n // eslint-disable-next-line @tanstack/query/exhaustive-deps\n queryKey: [\n ...queryKeys.all,\n 'uniswapV4PoolKey',\n chainId.toString(),\n poolManager,\n poolId,\n args?.fromBlock?.toString(),\n args?.chunkSize?.toString(),\n getClientCacheScopeKey(publicClient, clientScope),\n ],\n queryFn: () =>\n resolveUniswapV4PoolKey({\n client: publicClient,\n poolManager: poolManager as Address,\n poolId: poolId as `0x${string}`,\n fromBlock: args?.fromBlock,\n chunkSize: args?.chunkSize,\n }),\n enabled: (options?.enabled ?? true) && !!poolManager && !!poolId,\n // PoolKey is immutable — cache forever within the session.\n staleTime: options?.staleTime ?? Infinity,\n gcTime: options?.gcTime,\n refetchInterval: options?.refetchInterval,\n })\n}\n\n/**\n * Reads basic on-chain state (slot0, liquidity) for a Uniswap V4 pool via the StateView contract.\n * @param stateViewAddress - The Uniswap V4 StateView contract address.\n * @param poolId - The 32-byte poolId hash.\n * @param options - Optional React Query options (`enabled`, `staleTime`, `gcTime`, `refetchInterval`).\n * @returns React Query result resolving to the pool's basic state.\n */\nexport function useUniswapV4PoolBasicState(\n stateViewAddress: Address | undefined,\n poolId: `0x${string}` | undefined,\n options?: QueryOptions,\n) {\n const { publicClient, chainId, clientScope } = usePanopticContext()\n return useQuery({\n queryKey: [\n ...queryKeys.all,\n 'uniswapV4PoolBasicState',\n chainId.toString(),\n stateViewAddress,\n poolId,\n getClientCacheScopeKey(publicClient, clientScope),\n ],\n queryFn: () =>\n getUniswapV4PoolBasicState({\n client: publicClient,\n stateViewAddress: stateViewAddress as Address,\n poolId: poolId as `0x${string}`,\n }),\n enabled: (options?.enabled ?? true) && !!stateViewAddress && !!poolId,\n refetchInterval: options?.refetchInterval,\n staleTime: options?.staleTime,\n gcTime: options?.gcTime,\n })\n}\n\n/**\n * Reads full pool info (slot0, liquidity, and PoolKey-derived metadata) for a Uniswap V4 pool via the StateView contract.\n * @param stateViewAddress - The Uniswap V4 StateView contract address.\n * @param poolKey - The pool's `UniswapV4PoolKey` (currency0, currency1, fee, tickSpacing, hooks).\n * @param options - Optional React Query options (`enabled`, `staleTime`, `gcTime`, `refetchInterval`).\n * @returns React Query result resolving to the full pool info object.\n */\nexport function useUniswapV4PoolInfo(\n stateViewAddress: Address | undefined,\n poolKey: UniswapV4PoolKey | undefined,\n options?: QueryOptions,\n) {\n const { publicClient, chainId, clientScope } = usePanopticContext()\n return useQuery({\n // eslint-disable-next-line @tanstack/query/exhaustive-deps\n queryKey: [\n ...queryKeys.all,\n 'uniswapV4PoolInfo',\n chainId.toString(),\n stateViewAddress,\n poolKey?.currency0,\n poolKey?.currency1,\n poolKey?.fee,\n poolKey?.tickSpacing,\n poolKey?.hooks,\n getClientCacheScopeKey(publicClient, clientScope),\n ],\n queryFn: () =>\n getUniswapV4PoolInfo({\n client: publicClient,\n stateViewAddress: stateViewAddress as Address,\n poolKey: poolKey as UniswapV4PoolKey,\n }),\n enabled: (options?.enabled ?? true) && !!stateViewAddress && !!poolKey,\n refetchInterval: options?.refetchInterval,\n staleTime: options?.staleTime,\n gcTime: options?.gcTime,\n })\n}\n\n/**\n * Reads per-tick active liquidity from a Uniswap V4 pool via PanopticQuery's `getTickNetsV4`.\n * @param queryAddress - The PanopticQuery helper contract address.\n * @param poolManager - The Uniswap V4 PoolManager contract address.\n * @param poolId - The 32-byte poolId hash.\n * @param args - `tickSpacing`, `startTick` (inclusive), and `nTicks` count to scan.\n * @param options - Optional React Query options (`enabled`, `staleTime`, `gcTime`, `refetchInterval`).\n * @returns React Query result resolving to `{ ticks, liquidityNets }` parallel arrays.\n */\nexport function useUniswapV4PoolLiquidities(\n queryAddress: Address | undefined,\n poolManager: Address | undefined,\n poolId: `0x${string}` | undefined,\n args: { tickSpacing: number; startTick: number; nTicks: bigint } | undefined,\n options?: QueryOptions,\n) {\n const { publicClient, chainId, clientScope } = usePanopticContext()\n return useQuery({\n // eslint-disable-next-line @tanstack/query/exhaustive-deps\n queryKey: [\n ...queryKeys.all,\n 'uniswapV4PoolLiquidities',\n chainId.toString(),\n queryAddress,\n poolManager,\n poolId,\n args?.tickSpacing,\n args?.startTick,\n args?.nTicks,\n getClientCacheScopeKey(publicClient, clientScope),\n ],\n queryFn: () => {\n if (!queryAddress || !poolManager || !poolId || !args) {\n throw new PanopticValidationError('useUniswapV4PoolLiquidities: missing required args')\n }\n const { tickSpacing, startTick, nTicks } = args\n return getUniswapV4PoolLiquidities({\n client: publicClient,\n queryAddress,\n poolManager,\n poolId,\n tickSpacing,\n startTick,\n nTicks,\n })\n },\n enabled: (options?.enabled ?? true) && !!queryAddress && !!poolManager && !!poolId && !!args,\n refetchInterval: options?.refetchInterval,\n staleTime: options?.staleTime,\n gcTime: options?.gcTime,\n })\n}\n\n// --- Native token price ---\n\nexport function useNativeTokenPrice(\n panopticPoolAddress: Address | undefined,\n token0Decimals: bigint,\n token1Decimals: bigint,\n nativeIsToken0: boolean,\n options?: QueryOptions,\n) {\n const { publicClient, chainId, clientScope } = usePanopticContext()\n return useQuery({\n queryKey: [\n ...queryKeys.all,\n 'nativeTokenPrice',\n chainId,\n panopticPoolAddress,\n token0Decimals,\n token1Decimals,\n nativeIsToken0,\n getClientCacheScopeKey(publicClient, clientScope),\n ],\n queryFn: () =>\n getNativeTokenPrice({\n client: publicClient,\n panopticPoolAddress: panopticPoolAddress!,\n token0Decimals,\n token1Decimals,\n nativeIsToken0,\n }),\n enabled: (options?.enabled ?? true) && panopticPoolAddress !== undefined,\n refetchInterval: options?.refetchInterval ?? 30_000,\n staleTime: options?.staleTime,\n gcTime: options?.gcTime,\n })\n}\n\n// --- SFPM reads ---\n\ntype OmitSfpmClient<T> = Omit<T, 'client'>\n\nexport function useUniswapV3PoolFromId(\n params?: OmitSfpmClient<GetUniswapV3PoolFromIdParams>,\n options?: QueryOptions,\n) {\n const { publicClient, clientScope } = usePanopticContext()\n return useQuery({\n queryKey: [\n ...queryKeys.all,\n 'sfpm',\n 'getUniswapV3PoolFromId',\n params?.sfpmAddress,\n params?.poolId?.toString(),\n getClientCacheScopeKey(publicClient, clientScope),\n params,\n ] as const,\n queryFn: () => {\n if (!params) throw new PanopticValidationError('params is required')\n return getUniswapV3PoolFromId({ client: publicClient, ...params })\n },\n enabled: (options?.enabled ?? true) && params !== undefined,\n refetchInterval: options?.refetchInterval,\n staleTime: options?.staleTime,\n gcTime: options?.gcTime,\n })\n}\n\nexport function useUniswapV4PoolKeyFromId(\n params?: OmitSfpmClient<GetUniswapV4PoolKeyFromIdParams>,\n options?: QueryOptions,\n) {\n const { publicClient, clientScope } = usePanopticContext()\n return useQuery({\n queryKey: [\n ...queryKeys.all,\n 'sfpm',\n 'getUniswapV4PoolKeyFromId',\n params?.sfpmAddress,\n params?.poolId?.toString(),\n getClientCacheScopeKey(publicClient, clientScope),\n params,\n ] as const,\n queryFn: () => {\n if (!params) throw new PanopticValidationError('params is required')\n return getUniswapV4PoolKeyFromId({ client: publicClient, ...params })\n },\n enabled: (options?.enabled ?? true) && params !== undefined,\n refetchInterval: options?.refetchInterval,\n staleTime: options?.staleTime,\n gcTime: options?.gcTime,\n })\n}\n\nexport function useEnforcedTickLimits(\n params?: OmitSfpmClient<GetEnforcedTickLimitsParams>,\n options?: QueryOptions,\n) {\n const { publicClient, clientScope } = usePanopticContext()\n return useQuery({\n queryKey: [\n ...queryKeys.all,\n 'sfpm',\n 'getEnforcedTickLimits',\n params?.sfpmAddress,\n params?.poolId?.toString(),\n getClientCacheScopeKey(publicClient, clientScope),\n params,\n ] as const,\n queryFn: () => {\n if (!params) throw new PanopticValidationError('params is required')\n return getEnforcedTickLimits({ client: publicClient, ...params })\n },\n enabled: (options?.enabled ?? true) && params !== undefined,\n refetchInterval: options?.refetchInterval,\n staleTime: options?.staleTime,\n gcTime: options?.gcTime,\n })\n}\n\n// --- Factory + SFPM composite reads ---\n\nexport function usePanopticPoolFromPoolId(\n params?: OmitFactoryClient<GetPanopticPoolFromPoolIdParams>,\n options?: QueryOptions,\n) {\n const { publicClient, clientScope } = usePanopticContext()\n return useQuery({\n queryKey: [\n ...queryKeys.all,\n 'factory',\n 'getPanopticPoolFromPoolId',\n params?.sfpmAddress,\n params?.factoryAddress,\n params?.riskEngine,\n params?.poolId?.toString(),\n getClientCacheScopeKey(publicClient, clientScope),\n params,\n ] as const,\n queryFn: () => {\n if (!params) throw new PanopticValidationError('params is required')\n return getPanopticPoolFromPoolId({ client: publicClient, ...params })\n },\n enabled: (options?.enabled ?? true) && params !== undefined,\n refetchInterval: options?.refetchInterval,\n staleTime: options?.staleTime,\n gcTime: options?.gcTime,\n })\n}\n\ntype OmitResolveClient = Omit<ResolvePanopticPoolFromPoolIdParams, 'client'>\n\nexport function useResolvePanopticPoolFromPoolId(\n params?: OmitResolveClient,\n options?: QueryOptions,\n) {\n const { publicClient, clientScope } = usePanopticContext()\n return useQuery({\n queryKey: [\n ...queryKeys.all,\n 'factory',\n 'resolvePanopticPoolFromPoolId',\n params?.poolId?.toString(),\n params?.riskEngine,\n params?.v3?.sfpmAddress,\n params?.v3?.factoryAddress,\n params?.v4?.sfpmAddress,\n params?.v4?.factoryAddress,\n getClientCacheScopeKey(publicClient, clientScope),\n params,\n ] as const,\n queryFn: () => {\n if (!params) throw new PanopticValidationError('params is required')\n return resolvePanopticPoolFromPoolId({ client: publicClient, ...params })\n },\n enabled: (options?.enabled ?? true) && params !== undefined,\n refetchInterval: options?.refetchInterval,\n staleTime: options?.staleTime,\n gcTime: options?.gcTime,\n })\n}\n\n// --- Borrow preview ---\n\nexport function usePreviewBorrow(\n poolAddress: Address,\n params?: {\n account: Address\n token: Address\n amount: bigint\n slippageBps: bigint\n existingPositionIds: bigint[]\n },\n options?: QueryOptions,\n) {\n const ctx = usePanopticContext()\n return useQuery({\n queryKey: [\n ...queryKeys.all,\n 'previewBorrow',\n ctx.chainId,\n poolAddress,\n params?.account,\n params?.token,\n params?.amount?.toString(),\n params?.slippageBps?.toString(),\n params?.existingPositionIds?.map(String).join(','),\n getClientCacheScopeKey(ctx.publicClient, ctx.clientScope),\n ],\n queryFn: () =>\n previewBorrow({\n client: ctx.publicClient,\n poolAddress,\n chainId: ctx.chainId,\n account: params!.account,\n token: params!.token,\n amount: params!.amount,\n slippageBps: params!.slippageBps,\n existingPositionIds: params!.existingPositionIds,\n }),\n enabled: (options?.enabled ?? true) && !!params && params.amount > 0n,\n staleTime: options?.staleTime ?? 10_000,\n gcTime: options?.gcTime,\n placeholderData: keepPreviousData,\n })\n}\n\n/**\n * Validate whether a builder code maps to a deployed builder wallet.\n *\n * Returns `{ data: true }` for valid codes, `{ data: false }` for invalid.\n * Disabled when `builderCode` is `undefined` or `0n`.\n */\nexport function useValidateBuilderCode(\n poolAddress: Address,\n builderCode: bigint | undefined,\n options?: QueryOptions,\n) {\n const { publicClient, clientScope } = usePanopticContext()\n return useQuery({\n queryKey: [\n 'validateBuilderCode',\n poolAddress,\n String(builderCode),\n getClientCacheScopeKey(publicClient, clientScope),\n ],\n queryFn: () => {\n if (builderCode === undefined) throw new Error('builderCode is undefined')\n return validateBuilderCode({\n client: publicClient,\n poolAddress,\n builderCode,\n })\n },\n enabled: (options?.enabled ?? true) && builderCode !== undefined && builderCode !== 0n,\n staleTime: options?.staleTime ?? 60_000,\n gcTime: options?.gcTime,\n })\n}\n","/**\n * Mutation effects for cache invalidation with TanStack Query / SWR.\n * @module v2/react/mutationEffects\n */\n\nimport type { Address } from 'viem'\n\nimport { queryKeys } from './queryKeys'\n\n/**\n * Mutation type identifiers.\n */\nexport type MutationType =\n | 'openPosition'\n | 'closePosition'\n | 'forceExercise'\n | 'liquidate'\n | 'settleAccumulatedPremia'\n | 'deposit'\n | 'withdraw'\n | 'mint'\n | 'redeem'\n | 'approve'\n | 'pokeOracle'\n\n/**\n * Parameters for determining which queries to invalidate.\n */\nexport interface MutationEffectParams {\n chainId: bigint\n poolAddress: Address\n account: Address\n tokenId?: bigint\n}\n\n/**\n * Returns query keys that should be invalidated after a mutation.\n *\n * Use with TanStack Query's `queryClient.invalidateQueries()` or SWR's `mutate()`.\n *\n * @example\n * ```typescript\n * import { useMutation, useQueryClient } from '@tanstack/react-query'\n * import { mutationEffects, openPosition } from 'panoptic-v2-sdk'\n *\n * function useOpenPosition(config: WriteConfig) {\n * const queryClient = useQueryClient()\n *\n * return useMutation({\n * mutationFn: (params) => openPosition(config, params),\n * onSuccess: () => {\n * const keysToInvalidate = mutationEffects.openPosition({\n * chainId: config.chainId,\n * poolAddress: config.poolAddress,\n * account: config.walletClient.account.address,\n * })\n *\n * for (const key of keysToInvalidate) {\n * queryClient.invalidateQueries({ queryKey: key })\n * }\n * },\n * })\n * }\n * ```\n */\nexport const mutationEffects = {\n /**\n * Queries to invalidate after opening a position.\n */\n openPosition: (params: MutationEffectParams): readonly (readonly string[])[] => {\n const { chainId, poolAddress, account } = params\n return [\n queryKeys.pool(chainId, poolAddress),\n queryKeys.utilization(chainId, poolAddress),\n queryKeys.positions(chainId, poolAddress, account),\n queryKeys.trackedPositionIds(chainId, poolAddress, account),\n queryKeys.accountCollateral(chainId, poolAddress, account),\n queryKeys.accountSummaryBasic(chainId, poolAddress, account),\n queryKeys.accountSummaryRisk(chainId, poolAddress, account),\n queryKeys.isLiquidatable(chainId, poolAddress, account),\n queryKeys.liquidationPrices(chainId, poolAddress, account),\n queryKeys.accountGreeks(chainId, poolAddress, account),\n queryKeys.chunkSpreads(chainId, poolAddress),\n ]\n },\n\n /**\n * Queries to invalidate after closing a position.\n */\n closePosition: (params: MutationEffectParams): readonly (readonly string[])[] => {\n const { chainId, poolAddress, account, tokenId } = params\n const keys: (readonly string[])[] = [\n queryKeys.pool(chainId, poolAddress),\n queryKeys.utilization(chainId, poolAddress),\n queryKeys.positions(chainId, poolAddress, account),\n queryKeys.trackedPositionIds(chainId, poolAddress, account),\n queryKeys.accountCollateral(chainId, poolAddress, account),\n queryKeys.accountSummaryBasic(chainId, poolAddress, account),\n queryKeys.accountSummaryRisk(chainId, poolAddress, account),\n queryKeys.isLiquidatable(chainId, poolAddress, account),\n queryKeys.liquidationPrices(chainId, poolAddress, account),\n queryKeys.accountGreeks(chainId, poolAddress, account),\n queryKeys.closedPositions(chainId, poolAddress, account),\n queryKeys.tradeHistory(chainId, poolAddress, account),\n queryKeys.realizedPnL(chainId, poolAddress, account),\n queryKeys.chunkSpreads(chainId, poolAddress),\n ]\n\n if (tokenId !== undefined) {\n keys.push(queryKeys.position(chainId, poolAddress, tokenId))\n keys.push(queryKeys.positionGreeks(chainId, poolAddress, tokenId))\n }\n\n return keys\n },\n\n /**\n * Queries to invalidate after force exercising a position.\n */\n forceExercise: (params: MutationEffectParams): readonly (readonly string[])[] => {\n const { chainId, poolAddress, account, tokenId } = params\n const keys: (readonly string[])[] = [\n queryKeys.pool(chainId, poolAddress),\n queryKeys.utilization(chainId, poolAddress),\n queryKeys.accountCollateral(chainId, poolAddress, account),\n queryKeys.accountSummaryBasic(chainId, poolAddress, account),\n queryKeys.accountSummaryRisk(chainId, poolAddress, account),\n queryKeys.chunkSpreads(chainId, poolAddress),\n ]\n\n if (tokenId !== undefined) {\n keys.push(queryKeys.position(chainId, poolAddress, tokenId))\n }\n\n return keys\n },\n\n /**\n * Queries to invalidate after liquidating an account.\n */\n liquidate: (params: MutationEffectParams): readonly (readonly string[])[] => {\n const { chainId, poolAddress, account } = params\n return [\n queryKeys.pool(chainId, poolAddress),\n queryKeys.utilization(chainId, poolAddress),\n queryKeys.positions(chainId, poolAddress, account),\n queryKeys.trackedPositionIds(chainId, poolAddress, account),\n queryKeys.accountCollateral(chainId, poolAddress, account),\n queryKeys.accountSummaryBasic(chainId, poolAddress, account),\n queryKeys.accountSummaryRisk(chainId, poolAddress, account),\n queryKeys.isLiquidatable(chainId, poolAddress, account),\n queryKeys.liquidationPrices(chainId, poolAddress, account),\n queryKeys.accountGreeks(chainId, poolAddress, account),\n queryKeys.closedPositions(chainId, poolAddress, account),\n queryKeys.chunkSpreads(chainId, poolAddress),\n ]\n },\n\n /**\n * Queries to invalidate after settling accumulated premia.\n */\n settleAccumulatedPremia: (params: MutationEffectParams): readonly (readonly string[])[] => {\n const { chainId, poolAddress, account, tokenId } = params\n const keys: (readonly string[])[] = [\n queryKeys.accountCollateral(chainId, poolAddress, account),\n queryKeys.accountSummaryBasic(chainId, poolAddress, account),\n queryKeys.accountSummaryRisk(chainId, poolAddress, account),\n ]\n\n if (tokenId !== undefined) {\n keys.push(queryKeys.position(chainId, poolAddress, tokenId))\n }\n\n return keys\n },\n\n /**\n * Queries to invalidate after depositing to collateral tracker.\n */\n deposit: (params: MutationEffectParams): readonly (readonly string[])[] => {\n const { chainId, poolAddress, account } = params\n return [\n queryKeys.accountCollateral(chainId, poolAddress, account),\n queryKeys.accountSummaryBasic(chainId, poolAddress, account),\n queryKeys.accountSummaryRisk(chainId, poolAddress, account),\n queryKeys.isLiquidatable(chainId, poolAddress, account),\n queryKeys.liquidationPrices(chainId, poolAddress, account),\n ]\n },\n\n /**\n * Queries to invalidate after withdrawing from collateral tracker.\n */\n withdraw: (params: MutationEffectParams): readonly (readonly string[])[] => {\n const { chainId, poolAddress, account } = params\n return [\n queryKeys.accountCollateral(chainId, poolAddress, account),\n queryKeys.accountSummaryBasic(chainId, poolAddress, account),\n queryKeys.accountSummaryRisk(chainId, poolAddress, account),\n queryKeys.isLiquidatable(chainId, poolAddress, account),\n queryKeys.liquidationPrices(chainId, poolAddress, account),\n ]\n },\n\n /**\n * Queries to invalidate after minting collateral shares.\n */\n mint: (params: MutationEffectParams): readonly (readonly string[])[] => {\n return mutationEffects.deposit(params)\n },\n\n /**\n * Queries to invalidate after redeeming collateral shares.\n */\n redeem: (params: MutationEffectParams): readonly (readonly string[])[] => {\n return mutationEffects.withdraw(params)\n },\n\n /**\n * Queries to invalidate after approving token spending.\n */\n approve: (\n chainId: bigint,\n token: Address,\n owner: Address,\n spender: Address,\n ): readonly (readonly string[])[] => {\n return [queryKeys.approval(chainId, token, owner, spender)]\n },\n\n /**\n * Queries to invalidate after poking the oracle.\n */\n pokeOracle: (\n params: Pick<MutationEffectParams, 'chainId' | 'poolAddress'>,\n ): readonly (readonly string[])[] => {\n const { chainId, poolAddress } = params\n return [queryKeys.oracle(chainId, poolAddress), queryKeys.safeMode(chainId, poolAddress)]\n },\n} as const\n","/**\n * TanStack Query v5 mutation hooks for the Panoptic v2 SDK.\n * @module v2/react/hooks/writes\n */\n\nimport { type QueryClient, useMutation, useQueryClient } from '@tanstack/react-query'\nimport type { Address, WalletClient } from 'viem'\n\nimport {\n type ApproveParams,\n type ApprovePoolParams,\n type BorrowParams,\n type ClosePositionParams,\n type DeployNewPoolParams,\n type DepositParams,\n type DispatchParams,\n type ExecuteBatchDispatchParams,\n type ForceExerciseParams,\n type LiquidateParams,\n type MintParams,\n type OpenPositionParams,\n type PokeOracleParams,\n type RedeemParams,\n type RepayParams,\n type RollPositionParams,\n type SettleParams,\n type SmartRepayParams,\n type SupplyParams,\n type SwapExactInParams,\n type SwapExactOutParams,\n type UnsupplyParams,\n type UnwrapWethParams,\n type UnwrapXstockParams,\n type WithdrawParams,\n type WithdrawWithPositionsParams,\n type WrapEthParams,\n type WrapXstockParams,\n approve,\n approvePool,\n borrow,\n closePosition,\n deployNewPool,\n deposit,\n dispatch,\n executeBatchDispatch,\n forceExerciseAndWait,\n liquidate,\n mint,\n openPosition,\n pokeOracle,\n redeem,\n repay,\n rollPosition,\n settleAccumulatedPremia,\n smartRepay,\n supply,\n swapExactIn,\n swapExactOut,\n unsupply,\n unwrapWeth,\n unwrapXstock,\n withdraw,\n withdrawWithPositions,\n wrapEth,\n wrapXstock,\n} from '../../writes'\nimport { mutationEffects } from '../mutationEffects'\nimport { usePanopticContext } from '../provider'\nimport { queryKeys } from '../queryKeys'\n\ntype OmitInjected<T> = T extends unknown ? Omit<T, 'client' | 'walletClient' | 'account'> : never\ntype OmitInjectedWithPool<T> = Omit<T, 'client' | 'walletClient' | 'account' | 'poolAddress'>\ntype OmitInjectedWithPoolAndChain<T> = Omit<\n T,\n 'client' | 'walletClient' | 'account' | 'poolAddress' | 'chainId'\n>\n\ntype WalletInputs = {\n walletClient?: WalletClient\n account?: Address\n}\n\ntype WalletMutationContext = {\n signerAccount: Address\n}\n\nfunction requireWallet(inputs: WalletInputs): { walletClient: WalletClient; account: Address } {\n if (!inputs.walletClient || !inputs.account) {\n throw new Error('walletClient and account are required. Provide them via PanopticProvider.')\n }\n\n return {\n walletClient: inputs.walletClient,\n account: inputs.account,\n }\n}\n\nfunction createWalletMutationContext(inputs: WalletInputs): WalletMutationContext {\n return { signerAccount: requireWallet(inputs).account }\n}\n\nfunction invalidateKeys(\n queryClient: QueryClient,\n keysToInvalidate: readonly (readonly string[])[],\n): void {\n const seen = new Set<string>()\n\n for (const key of keysToInvalidate) {\n const serialized = JSON.stringify(key)\n if (seen.has(serialized)) {\n continue\n }\n\n seen.add(serialized)\n queryClient.invalidateQueries({ queryKey: key })\n }\n}\n\nexport function useApprove() {\n const { publicClient, chainId, walletClient, account } = usePanopticContext()\n const queryClient = useQueryClient()\n\n return useMutation({\n onMutate: () => createWalletMutationContext({ walletClient, account }),\n mutationFn: (params: OmitInjected<ApproveParams>) => {\n const wallet = requireWallet({ walletClient, account })\n return approve({ client: publicClient, ...wallet, ...params })\n },\n onSuccess: (_data, params, context) => {\n if (!context) {\n return\n }\n\n invalidateKeys(\n queryClient,\n mutationEffects.approve(\n chainId,\n params.tokenAddress,\n context.signerAccount,\n params.spenderAddress,\n ),\n )\n },\n })\n}\n\nexport function useApprovePool(poolAddress: Address) {\n const { publicClient, walletClient, account } = usePanopticContext()\n const queryClient = useQueryClient()\n\n return useMutation({\n onMutate: () => createWalletMutationContext({ walletClient, account }),\n mutationFn: (params: OmitInjectedWithPool<ApprovePoolParams>) => {\n const wallet = requireWallet({ walletClient, account })\n return approvePool({ client: publicClient, ...wallet, poolAddress, ...params })\n },\n onSuccess: () => {\n queryClient.invalidateQueries({ queryKey: [...queryKeys.all, 'approval'] })\n },\n })\n}\n\nexport function useDeposit(poolAddress: Address) {\n const { publicClient, chainId, walletClient, account } = usePanopticContext()\n const queryClient = useQueryClient()\n\n return useMutation({\n onMutate: () => createWalletMutationContext({ walletClient, account }),\n mutationFn: (params: OmitInjected<DepositParams>) => {\n const wallet = requireWallet({ walletClient, account })\n return deposit({ client: publicClient, ...wallet, ...params })\n },\n onSuccess: (_data, _params, context) => {\n if (!context) {\n return\n }\n\n invalidateKeys(\n queryClient,\n mutationEffects.deposit({ chainId, poolAddress, account: context.signerAccount }),\n )\n },\n })\n}\n\nexport function useWithdraw(poolAddress: Address) {\n const { publicClient, chainId, walletClient, account } = usePanopticContext()\n const queryClient = useQueryClient()\n\n return useMutation({\n onMutate: () => createWalletMutationContext({ walletClient, account }),\n mutationFn: (params: OmitInjected<WithdrawParams>) => {\n const wallet = requireWallet({ walletClient, account })\n return withdraw({ client: publicClient, ...wallet, ...params })\n },\n onSuccess: (_data, _params, context) => {\n if (!context) {\n return\n }\n\n invalidateKeys(\n queryClient,\n mutationEffects.withdraw({ chainId, poolAddress, account: context.signerAccount }),\n )\n },\n })\n}\n\n/**\n * Wrap an underlying xStock into its ERC4626 wrapper (`deposit`). Requires a\n * prior approval of the underlying to the wrapper (use {@link useApprove}).\n * Invalidates SDK queries so balances refetch.\n */\nexport function useWrapXstock() {\n const { publicClient, walletClient, account } = usePanopticContext()\n const queryClient = useQueryClient()\n\n return useMutation({\n onMutate: () => createWalletMutationContext({ walletClient, account }),\n mutationFn: (params: OmitInjected<WrapXstockParams>) => {\n const wallet = requireWallet({ walletClient, account })\n return wrapXstock({ client: publicClient, ...wallet, ...params })\n },\n onSuccess: () => {\n queryClient.invalidateQueries({ queryKey: [...queryKeys.all] })\n },\n })\n}\n\n/**\n * Unwrap wrapper shares back into the underlying xStock (`redeem`). Burns the\n * owner's own shares — no approval needed.\n */\nexport function useUnwrapXstock() {\n const { publicClient, walletClient, account } = usePanopticContext()\n const queryClient = useQueryClient()\n\n return useMutation({\n onMutate: () => createWalletMutationContext({ walletClient, account }),\n mutationFn: (params: OmitInjected<UnwrapXstockParams>) => {\n const wallet = requireWallet({ walletClient, account })\n return unwrapXstock({ client: publicClient, ...wallet, ...params })\n },\n onSuccess: () => {\n queryClient.invalidateQueries({ queryKey: [...queryKeys.all] })\n },\n })\n}\n\n/**\n * Wrap native ETH into WETH (`deposit` payable). No approval needed.\n * Invalidates SDK queries so balances refetch.\n */\nexport function useWrapEth() {\n const { publicClient, walletClient, account } = usePanopticContext()\n const queryClient = useQueryClient()\n\n return useMutation({\n onMutate: () => createWalletMutationContext({ walletClient, account }),\n mutationFn: (params: OmitInjected<WrapEthParams>) => {\n const wallet = requireWallet({ walletClient, account })\n return wrapEth({ client: publicClient, ...wallet, ...params })\n },\n onSuccess: () => {\n queryClient.invalidateQueries({ queryKey: [...queryKeys.all] })\n },\n })\n}\n\n/**\n * Unwrap WETH back into native ETH (`withdraw`). Burns the caller's own WETH —\n * no approval needed. Invalidates SDK queries so balances refetch.\n */\nexport function useUnwrapWeth() {\n const { publicClient, walletClient, account } = usePanopticContext()\n const queryClient = useQueryClient()\n\n return useMutation({\n onMutate: () => createWalletMutationContext({ walletClient, account }),\n mutationFn: (params: OmitInjected<UnwrapWethParams>) => {\n const wallet = requireWallet({ walletClient, account })\n return unwrapWeth({ client: publicClient, ...wallet, ...params })\n },\n onSuccess: () => {\n queryClient.invalidateQueries({ queryKey: [...queryKeys.all] })\n },\n })\n}\n\nexport function useMintShares(poolAddress: Address) {\n const { publicClient, chainId, walletClient, account } = usePanopticContext()\n const queryClient = useQueryClient()\n\n return useMutation({\n onMutate: () => createWalletMutationContext({ walletClient, account }),\n mutationFn: (params: OmitInjected<MintParams>) => {\n const wallet = requireWallet({ walletClient, account })\n return mint({ client: publicClient, ...wallet, ...params })\n },\n onSuccess: (_data, _params, context) => {\n if (!context) {\n return\n }\n\n invalidateKeys(\n queryClient,\n mutationEffects.mint({ chainId, poolAddress, account: context.signerAccount }),\n )\n },\n })\n}\n\nexport function useRedeem(poolAddress: Address) {\n const { publicClient, chainId, walletClient, account } = usePanopticContext()\n const queryClient = useQueryClient()\n\n return useMutation({\n onMutate: () => createWalletMutationContext({ walletClient, account }),\n mutationFn: (params: OmitInjected<RedeemParams>) => {\n const wallet = requireWallet({ walletClient, account })\n return redeem({ client: publicClient, ...wallet, ...params })\n },\n onSuccess: (_data, _params, context) => {\n if (!context) {\n return\n }\n\n invalidateKeys(\n queryClient,\n mutationEffects.redeem({ chainId, poolAddress, account: context.signerAccount }),\n )\n },\n })\n}\n\nexport function useWithdrawWithPositions(poolAddress: Address) {\n const { publicClient, chainId, walletClient, account } = usePanopticContext()\n const queryClient = useQueryClient()\n\n return useMutation({\n onMutate: () => createWalletMutationContext({ walletClient, account }),\n mutationFn: (params: OmitInjected<WithdrawWithPositionsParams>) => {\n const wallet = requireWallet({ walletClient, account })\n return withdrawWithPositions({ client: publicClient, ...wallet, ...params })\n },\n onSuccess: (_data, _params, context) => {\n if (!context) {\n return\n }\n\n invalidateKeys(\n queryClient,\n mutationEffects.withdraw({ chainId, poolAddress, account: context.signerAccount }),\n )\n },\n })\n}\n\nexport function useOpenPosition(poolAddress: Address) {\n const { publicClient, chainId, walletClient, account } = usePanopticContext()\n const queryClient = useQueryClient()\n\n return useMutation({\n onMutate: () => createWalletMutationContext({ walletClient, account }),\n mutationFn: (params: OmitInjectedWithPool<OpenPositionParams>) => {\n const wallet = requireWallet({ walletClient, account })\n return openPosition({ client: publicClient, ...wallet, poolAddress, ...params })\n },\n onSuccess: (_data, _params, context) => {\n if (!context) {\n return\n }\n\n invalidateKeys(\n queryClient,\n mutationEffects.openPosition({ chainId, poolAddress, account: context.signerAccount }),\n )\n },\n })\n}\n\nexport function useClosePosition(poolAddress: Address) {\n const { publicClient, chainId, walletClient, account } = usePanopticContext()\n const queryClient = useQueryClient()\n\n return useMutation({\n onMutate: () => createWalletMutationContext({ walletClient, account }),\n mutationFn: (params: OmitInjectedWithPool<ClosePositionParams>) => {\n const wallet = requireWallet({ walletClient, account })\n return closePosition({ client: publicClient, ...wallet, poolAddress, ...params })\n },\n onSuccess: (_data, params, context) => {\n if (!context) {\n return\n }\n\n invalidateKeys(\n queryClient,\n mutationEffects.closePosition({\n chainId,\n poolAddress,\n account: context.signerAccount,\n tokenId: params.tokenId,\n }),\n )\n },\n })\n}\n\nexport function useRollPosition(poolAddress: Address) {\n const { publicClient, chainId, walletClient, account } = usePanopticContext()\n const queryClient = useQueryClient()\n\n return useMutation({\n onMutate: () => createWalletMutationContext({ walletClient, account }),\n mutationFn: (params: OmitInjectedWithPool<RollPositionParams>) => {\n const wallet = requireWallet({ walletClient, account })\n return rollPosition({ client: publicClient, ...wallet, poolAddress, ...params })\n },\n onSuccess: (_data, _params, context) => {\n if (!context) {\n return\n }\n\n invalidateKeys(\n queryClient,\n mutationEffects.openPosition({ chainId, poolAddress, account: context.signerAccount }),\n )\n },\n })\n}\n\nexport function useLiquidate(poolAddress: Address) {\n const { publicClient, chainId, walletClient, account } = usePanopticContext()\n const queryClient = useQueryClient()\n\n return useMutation({\n onMutate: () => createWalletMutationContext({ walletClient, account }),\n mutationFn: (params: OmitInjectedWithPool<LiquidateParams>) => {\n const wallet = requireWallet({ walletClient, account })\n return liquidate({ client: publicClient, ...wallet, poolAddress, ...params })\n },\n onSuccess: (_data, params, context) => {\n if (!context) {\n return\n }\n\n invalidateKeys(queryClient, [\n ...mutationEffects.liquidate({ chainId, poolAddress, account: context.signerAccount }),\n ...mutationEffects.liquidate({ chainId, poolAddress, account: params.liquidatee }),\n ])\n },\n })\n}\n\nexport function useForceExercise(poolAddress: Address) {\n const { publicClient, chainId, walletClient, account, storage } = usePanopticContext()\n const queryClient = useQueryClient()\n\n return useMutation({\n onMutate: () => createWalletMutationContext({ walletClient, account }),\n mutationFn: (\n params: Omit<\n ForceExerciseParams,\n 'client' | 'walletClient' | 'account' | 'poolAddress' | 'chainId' | 'storage'\n >,\n ) => {\n const wallet = requireWallet({ walletClient, account })\n return forceExerciseAndWait({\n client: publicClient,\n ...wallet,\n poolAddress,\n ...params,\n storage,\n chainId,\n })\n },\n onSuccess: (_data, params, context) => {\n if (!context) {\n return\n }\n\n invalidateKeys(queryClient, [\n ...mutationEffects.forceExercise({ chainId, poolAddress, account: context.signerAccount }),\n ...mutationEffects.forceExercise({ chainId, poolAddress, account: params.user }),\n ])\n },\n })\n}\n\nexport function useSettleAccumulatedPremia(poolAddress: Address) {\n const { publicClient, chainId, walletClient, account } = usePanopticContext()\n const queryClient = useQueryClient()\n\n return useMutation({\n onMutate: () => createWalletMutationContext({ walletClient, account }),\n mutationFn: (params: OmitInjectedWithPool<SettleParams>) => {\n const wallet = requireWallet({ walletClient, account })\n return settleAccumulatedPremia({ client: publicClient, ...wallet, poolAddress, ...params })\n },\n onSuccess: (_data, _params, context) => {\n if (!context) {\n return\n }\n\n invalidateKeys(\n queryClient,\n mutationEffects.settleAccumulatedPremia({\n chainId,\n poolAddress,\n account: context.signerAccount,\n }),\n )\n },\n })\n}\n\nexport function usePokeOracle(poolAddress: Address) {\n const { publicClient, chainId, walletClient, account } = usePanopticContext()\n const queryClient = useQueryClient()\n\n return useMutation({\n onMutate: () => createWalletMutationContext({ walletClient, account }),\n mutationFn: (params?: OmitInjectedWithPool<PokeOracleParams>) => {\n const wallet = requireWallet({ walletClient, account })\n return pokeOracle({ client: publicClient, ...wallet, poolAddress, ...params })\n },\n onSuccess: () => {\n invalidateKeys(queryClient, mutationEffects.pokeOracle({ chainId, poolAddress }))\n },\n })\n}\n\nexport function useDispatch(poolAddress: Address) {\n const { publicClient, chainId, walletClient, account } = usePanopticContext()\n const queryClient = useQueryClient()\n\n return useMutation({\n onMutate: () => createWalletMutationContext({ walletClient, account }),\n mutationFn: (params: OmitInjectedWithPool<DispatchParams>) => {\n const wallet = requireWallet({ walletClient, account })\n return dispatch({ client: publicClient, ...wallet, poolAddress, ...params })\n },\n onSuccess: (_data, _params, context) => {\n if (!context) {\n return\n }\n\n invalidateKeys(\n queryClient,\n mutationEffects.openPosition({ chainId, poolAddress, account: context.signerAccount }),\n )\n },\n })\n}\n\nexport function useBatchDispatch(poolAddress: Address) {\n const { publicClient, chainId, walletClient, account } = usePanopticContext()\n const queryClient = useQueryClient()\n\n return useMutation({\n onMutate: () => createWalletMutationContext({ walletClient, account }),\n mutationFn: (params: OmitInjectedWithPool<ExecuteBatchDispatchParams>) => {\n const wallet = requireWallet({ walletClient, account })\n return executeBatchDispatch({ client: publicClient, ...wallet, poolAddress, ...params })\n },\n onSuccess: (_data, params, context) => {\n if (!context) {\n return\n }\n\n const closedTokenIds = params.items.filter((i) => i.kind === 'burn').map((i) => i.tokenId)\n\n const keys = [\n ...mutationEffects.openPosition({\n chainId,\n poolAddress,\n account: context.signerAccount,\n }),\n ...closedTokenIds.flatMap((tokenId) =>\n mutationEffects.closePosition({\n chainId,\n poolAddress,\n account: context.signerAccount,\n tokenId,\n }),\n ),\n ]\n invalidateKeys(queryClient, keys)\n },\n })\n}\n\nexport function useDeployNewPool() {\n const { publicClient, walletClient, account } = usePanopticContext()\n const queryClient = useQueryClient()\n\n return useMutation({\n onMutate: () => createWalletMutationContext({ walletClient, account }),\n mutationFn: (params: OmitInjected<DeployNewPoolParams>) => {\n const wallet = requireWallet({ walletClient, account })\n return deployNewPool({ client: publicClient, ...wallet, ...params })\n },\n onSuccess: () => {\n queryClient.invalidateQueries({ queryKey: [...queryKeys.all, 'factory'] })\n },\n })\n}\n\nexport function useSwapExactOut(poolAddress: Address) {\n const { publicClient, chainId, walletClient, account } = usePanopticContext()\n const queryClient = useQueryClient()\n\n return useMutation({\n onMutate: () => createWalletMutationContext({ walletClient, account }),\n mutationFn: (params: OmitInjectedWithPoolAndChain<SwapExactOutParams>) => {\n const wallet = requireWallet({ walletClient, account })\n return swapExactOut({ client: publicClient, ...wallet, poolAddress, chainId, ...params })\n },\n onSuccess: (_data, _params, context) => {\n if (!context) return\n invalidateKeys(\n queryClient,\n mutationEffects.deposit({ chainId, poolAddress, account: context.signerAccount }),\n )\n },\n })\n}\n\nexport function useSupply(poolAddress: Address) {\n const { publicClient, chainId, walletClient, account } = usePanopticContext()\n const queryClient = useQueryClient()\n\n return useMutation({\n onMutate: () => createWalletMutationContext({ walletClient, account }),\n mutationFn: (params: OmitInjectedWithPoolAndChain<SupplyParams>) => {\n const wallet = requireWallet({ walletClient, account })\n return supply({ client: publicClient, ...wallet, poolAddress, chainId, ...params })\n },\n onSuccess: (_data, _params, context) => {\n if (!context) return\n invalidateKeys(\n queryClient,\n mutationEffects.deposit({ chainId, poolAddress, account: context.signerAccount }),\n )\n },\n })\n}\n\nexport function useUnsupply(poolAddress: Address) {\n const { publicClient, chainId, walletClient, account } = usePanopticContext()\n const queryClient = useQueryClient()\n\n return useMutation({\n onMutate: () => createWalletMutationContext({ walletClient, account }),\n mutationFn: (params: OmitInjectedWithPoolAndChain<UnsupplyParams>) => {\n const wallet = requireWallet({ walletClient, account })\n return unsupply({ client: publicClient, ...wallet, poolAddress, chainId, ...params })\n },\n onSuccess: (_data, _params, context) => {\n if (!context) return\n invalidateKeys(\n queryClient,\n mutationEffects.withdraw({ chainId, poolAddress, account: context.signerAccount }),\n )\n },\n })\n}\n\nexport function useBorrow(poolAddress: Address) {\n const { publicClient, chainId, walletClient, account } = usePanopticContext()\n const queryClient = useQueryClient()\n\n return useMutation({\n onMutate: () => createWalletMutationContext({ walletClient, account }),\n mutationFn: (params: OmitInjectedWithPoolAndChain<BorrowParams>) => {\n const wallet = requireWallet({ walletClient, account })\n return borrow({ client: publicClient, ...wallet, poolAddress, chainId, ...params })\n },\n onSuccess: (_data, _params, context) => {\n if (!context) return\n invalidateKeys(\n queryClient,\n mutationEffects.openPosition({ chainId, poolAddress, account: context.signerAccount }),\n )\n },\n })\n}\n\nexport function useRepay(poolAddress: Address) {\n const { publicClient, chainId, walletClient, account } = usePanopticContext()\n const queryClient = useQueryClient()\n\n return useMutation({\n onMutate: () => createWalletMutationContext({ walletClient, account }),\n mutationFn: (params: OmitInjectedWithPoolAndChain<RepayParams>) => {\n const wallet = requireWallet({ walletClient, account })\n return repay({ client: publicClient, ...wallet, poolAddress, chainId, ...params })\n },\n onSuccess: (_data, params, context) => {\n if (!context) return\n invalidateKeys(\n queryClient,\n mutationEffects.closePosition({\n chainId,\n poolAddress,\n account: context.signerAccount,\n tokenId: params.loanTokenId,\n }),\n )\n },\n })\n}\n\nexport function useSmartRepay(poolAddress: Address) {\n const { publicClient, chainId, walletClient, account } = usePanopticContext()\n const queryClient = useQueryClient()\n\n return useMutation({\n onMutate: () => createWalletMutationContext({ walletClient, account }),\n mutationFn: (params: OmitInjectedWithPoolAndChain<SmartRepayParams>) => {\n const wallet = requireWallet({ walletClient, account })\n return smartRepay({ client: publicClient, ...wallet, poolAddress, chainId, ...params })\n },\n onSuccess: (_data, _params, context) => {\n if (!context) return\n invalidateKeys(\n queryClient,\n mutationEffects.closePosition({\n chainId,\n poolAddress,\n account: context.signerAccount,\n }),\n )\n },\n })\n}\n\nexport function useSwapExactIn(poolAddress: Address) {\n const { publicClient, chainId, walletClient, account } = usePanopticContext()\n const queryClient = useQueryClient()\n\n return useMutation({\n onMutate: () => createWalletMutationContext({ walletClient, account }),\n mutationFn: (params: OmitInjectedWithPoolAndChain<SwapExactInParams>) => {\n const wallet = requireWallet({ walletClient, account })\n return swapExactIn({ client: publicClient, ...wallet, poolAddress, chainId, ...params })\n },\n onSuccess: (_data, _params, context) => {\n if (!context) return\n invalidateKeys(\n queryClient,\n mutationEffects.deposit({ chainId, poolAddress, account: context.signerAccount }),\n )\n },\n })\n}\n","/**\n * TanStack Query v5 simulation hooks for the Panoptic v2 SDK.\n * @module v2/react/hooks/simulations\n */\n\nimport { useQuery } from '@tanstack/react-query'\nimport type { Address } from 'viem'\n\nimport {\n type SimulateBatchDispatchParams,\n type SimulateClosePositionParams,\n type SimulateDepositParams,\n type SimulateDispatchParams,\n type SimulateForceExerciseParams,\n type SimulateLiquidateParams,\n type SimulateOpenPositionParams,\n type SimulateSettleParams,\n type SimulateSFPMParams,\n type SimulateSwapExactInParams,\n type SimulateSwapExactOutParams,\n type SimulateWithdrawParams,\n simulateBatchDispatch,\n simulateClosePosition,\n simulateDeposit,\n simulateDispatch,\n simulateForceExercise,\n simulateLiquidate,\n simulateOpenPosition,\n simulateSettle,\n simulateSFPMBurn,\n simulateSFPMMint,\n simulateSwapExactIn,\n simulateSwapExactOut,\n simulateWithdraw,\n} from '../../simulations'\nimport { getClientCacheScopeKey } from '../cacheScopes'\nimport { usePanopticContext } from '../provider'\nimport { queryKeys } from '../queryKeys'\n\ntype OmitClient<T> = Omit<T, 'client'>\ntype OmitClientAndPool<T> = Omit<T, 'client' | 'poolAddress'>\n\nexport function useSimulateOpenPosition(\n poolAddress: Address,\n params?: OmitClientAndPool<SimulateOpenPositionParams>,\n) {\n const { publicClient, clientScope } = usePanopticContext()\n return useQuery({\n queryKey: [\n ...queryKeys.all,\n 'sim',\n 'openPosition',\n poolAddress,\n params?.tokenId?.toString(),\n getClientCacheScopeKey(publicClient, clientScope),\n params,\n ] as const,\n queryFn: () => simulateOpenPosition({ client: publicClient, poolAddress, ...params! }),\n enabled: params !== undefined,\n staleTime: 0,\n })\n}\n\nexport function useSimulateClosePosition(\n poolAddress: Address,\n params?: OmitClientAndPool<SimulateClosePositionParams>,\n) {\n const { publicClient, clientScope } = usePanopticContext()\n return useQuery({\n queryKey: [\n ...queryKeys.all,\n 'sim',\n 'closePosition',\n poolAddress,\n params?.tokenId?.toString(),\n getClientCacheScopeKey(publicClient, clientScope),\n params,\n ] as const,\n queryFn: () => simulateClosePosition({ client: publicClient, poolAddress, ...params! }),\n enabled: params !== undefined,\n staleTime: 0,\n })\n}\n\nexport function useSimulateDeposit(params?: OmitClient<SimulateDepositParams>) {\n const { publicClient, clientScope } = usePanopticContext()\n return useQuery({\n queryKey: [\n ...queryKeys.all,\n 'sim',\n 'deposit',\n params?.collateralTrackerAddress,\n params?.assets?.toString(),\n getClientCacheScopeKey(publicClient, clientScope),\n params,\n ] as const,\n queryFn: () => simulateDeposit({ client: publicClient, ...params! }),\n enabled: params !== undefined,\n staleTime: 0,\n })\n}\n\nexport function useSimulateWithdraw(params?: OmitClient<SimulateWithdrawParams>) {\n const { publicClient, clientScope } = usePanopticContext()\n return useQuery({\n queryKey: [\n ...queryKeys.all,\n 'sim',\n 'withdraw',\n params?.collateralTrackerAddress,\n params?.assets?.toString(),\n getClientCacheScopeKey(publicClient, clientScope),\n params,\n ] as const,\n queryFn: () => simulateWithdraw({ client: publicClient, ...params! }),\n enabled: params !== undefined,\n staleTime: 0,\n })\n}\n\nexport function useSimulateLiquidate(\n poolAddress: Address,\n params?: OmitClientAndPool<SimulateLiquidateParams>,\n) {\n const { publicClient, clientScope } = usePanopticContext()\n return useQuery({\n queryKey: [\n ...queryKeys.all,\n 'sim',\n 'liquidate',\n poolAddress,\n params?.liquidatee,\n getClientCacheScopeKey(publicClient, clientScope),\n params,\n ] as const,\n queryFn: () => simulateLiquidate({ client: publicClient, poolAddress, ...params! }),\n enabled: params !== undefined,\n staleTime: 0,\n })\n}\n\nexport function useSimulateForceExercise(\n poolAddress: Address,\n params?: OmitClientAndPool<SimulateForceExerciseParams>,\n) {\n const { publicClient, clientScope } = usePanopticContext()\n return useQuery({\n queryKey: [\n ...queryKeys.all,\n 'sim',\n 'forceExercise',\n poolAddress,\n params?.user,\n getClientCacheScopeKey(publicClient, clientScope),\n params,\n ] as const,\n queryFn: () => simulateForceExercise({ client: publicClient, poolAddress, ...params! }),\n enabled: params !== undefined,\n staleTime: 0,\n })\n}\n\nexport function useSimulateSettle(\n poolAddress: Address,\n params?: OmitClientAndPool<SimulateSettleParams>,\n) {\n const { publicClient, clientScope } = usePanopticContext()\n return useQuery({\n queryKey: [\n ...queryKeys.all,\n 'sim',\n 'settle',\n poolAddress,\n params?.account,\n getClientCacheScopeKey(publicClient, clientScope),\n params,\n ] as const,\n queryFn: () => simulateSettle({ client: publicClient, poolAddress, ...params! }),\n enabled: params !== undefined,\n staleTime: 0,\n })\n}\n\nexport function useSimulateBatchDispatch(\n poolAddress: Address,\n params?: OmitClientAndPool<SimulateBatchDispatchParams>,\n) {\n const { publicClient, clientScope } = usePanopticContext()\n return useQuery({\n queryKey: [\n ...queryKeys.all,\n 'sim',\n 'batchDispatch',\n poolAddress,\n params?.account,\n params?.items?.length,\n JSON.stringify(params?.items?.map((i) => `${i.kind}:${i.tokenId.toString()}`)),\n JSON.stringify(params?.existingPositionIds?.map(String)),\n getClientCacheScopeKey(publicClient, clientScope),\n params,\n ] as const,\n queryFn: () => simulateBatchDispatch({ client: publicClient, poolAddress, ...params! }),\n enabled: params !== undefined && params.items !== undefined,\n staleTime: 0,\n })\n}\n\nexport function useSimulateDispatch(\n poolAddress: Address,\n params?: OmitClientAndPool<SimulateDispatchParams>,\n) {\n const { publicClient, clientScope } = usePanopticContext()\n return useQuery({\n queryKey: [\n ...queryKeys.all,\n 'sim',\n 'dispatch',\n poolAddress,\n JSON.stringify(params?.positionIdList?.map(String)),\n getClientCacheScopeKey(publicClient, clientScope),\n params,\n ] as const,\n queryFn: () => simulateDispatch({ client: publicClient, poolAddress, ...params! }),\n enabled: params !== undefined,\n staleTime: 0,\n })\n}\n\nexport function useSimulateSFPMMint(params?: OmitClient<SimulateSFPMParams>) {\n const { publicClient, clientScope } = usePanopticContext()\n return useQuery({\n queryKey: [\n ...queryKeys.all,\n 'sim',\n 'sfpmMint',\n params?.sfpmAddress,\n params?.tokenId?.toString(),\n getClientCacheScopeKey(publicClient, clientScope),\n params,\n ] as const,\n queryFn: () => {\n if (!params) throw new Error('params required for simulateSFPMMint')\n return simulateSFPMMint({ client: publicClient, ...params })\n },\n enabled: params !== undefined,\n staleTime: 0,\n })\n}\n\nexport function useSimulateSFPMBurn(params?: OmitClient<SimulateSFPMParams>) {\n const { publicClient, clientScope } = usePanopticContext()\n return useQuery({\n queryKey: [\n ...queryKeys.all,\n 'sim',\n 'sfpmBurn',\n params?.sfpmAddress,\n params?.tokenId?.toString(),\n getClientCacheScopeKey(publicClient, clientScope),\n params,\n ] as const,\n queryFn: () => {\n if (!params) throw new Error('params required for simulateSFPMBurn')\n return simulateSFPMBurn({ client: publicClient, ...params })\n },\n enabled: params !== undefined,\n staleTime: 0,\n })\n}\n\nexport function useSimulateSwapExactOut(\n poolAddress: Address,\n params?: OmitClientAndPool<SimulateSwapExactOutParams>,\n) {\n const { publicClient, clientScope } = usePanopticContext()\n return useQuery({\n queryKey: [\n ...queryKeys.all,\n 'sim',\n 'swapExactOut',\n poolAddress,\n params?.tokenOut,\n params?.amountOut?.toString(),\n getClientCacheScopeKey(publicClient, clientScope),\n params,\n ] as const,\n queryFn: () => simulateSwapExactOut({ client: publicClient, poolAddress, ...params! }),\n enabled: params !== undefined,\n staleTime: 0,\n })\n}\n\nexport function useSimulateSwapExactIn(\n poolAddress: Address,\n params?: OmitClientAndPool<SimulateSwapExactInParams>,\n) {\n const { publicClient, clientScope } = usePanopticContext()\n return useQuery({\n queryKey: [\n ...queryKeys.all,\n 'sim',\n 'swapExactIn',\n poolAddress,\n params?.tokenIn,\n params?.amountIn?.toString(),\n getClientCacheScopeKey(publicClient, clientScope),\n params,\n ] as const,\n queryFn: () => simulateSwapExactIn({ client: publicClient, poolAddress, ...params! }),\n enabled: params !== undefined,\n staleTime: 0,\n })\n}\n","/**\n * TanStack Query v5 hooks for the Uniswap v4 Universal Router swap path.\n *\n * Mirrors the writes/simulations hook ergonomics (usePanopticContext injection,\n * OmitInjected* params, cache invalidation) but targets the generic Uniswap v4\n * router functions in `src/uniswap`.\n *\n * @module v2/react/hooks/uniswapRouter\n */\n\nimport { useMutation, useQuery, useQueryClient } from '@tanstack/react-query'\nimport type { Address, WalletClient } from 'viem'\n\nimport {\n type ApproveErc20ForPermit2Params,\n type ApproveRouterViaPermit2Params,\n type CheckRouterApprovalParams,\n type QuoteSwapExactInViaRouterParams,\n type QuoteSwapExactOutViaRouterParams,\n type SwapExactInViaRouterParams,\n type SwapExactOutViaRouterParams,\n approveErc20ForPermit2,\n approveRouterViaPermit2,\n checkRouterApproval,\n quoteSwapExactInViaRouter,\n quoteSwapExactOutViaRouter,\n swapExactInViaRouter,\n swapExactOutViaRouter,\n} from '../../../../uniswap/v4/router'\nimport { PanopticError } from '../../errors'\nimport { getClientCacheScopeKey } from '../cacheScopes'\nimport { mutationEffects } from '../mutationEffects'\nimport { usePanopticContext } from '../provider'\nimport { queryKeys } from '../queryKeys'\n\ntype OmitInjectedWithPoolAndChain<T> = Omit<\n T,\n 'client' | 'walletClient' | 'account' | 'poolAddress' | 'chainId'\n>\ntype OmitInjectedWithChain<T> = Omit<T, 'client' | 'walletClient' | 'account' | 'chainId'>\ntype OmitClientPoolAndChain<T> = Omit<T, 'client' | 'poolAddress' | 'chainId'>\n\nfunction requireWallet(walletClient?: WalletClient, account?: Address) {\n if (!walletClient || !account) {\n throw new PanopticError(\n 'walletClient and account are required. Provide them via PanopticProvider.',\n )\n }\n return { walletClient, account }\n}\n\n/**\n * Quote an exact-in spot swap via the Universal Router (V4Quoter-backed).\n * Returns a `SimulationResult`, matching `useSimulateSwapExactIn`'s shape.\n */\nexport function useQuoteSwapExactInViaRouter(\n poolAddress: Address,\n params?: OmitClientPoolAndChain<QuoteSwapExactInViaRouterParams>,\n) {\n const { publicClient, chainId, clientScope } = usePanopticContext()\n return useQuery({\n // Raw `params` carries bigints that break TanStack v5's JSON key hashing; the\n // stringified scalars below fully capture the query identity.\n // eslint-disable-next-line @tanstack/query/exhaustive-deps\n queryKey: [\n ...queryKeys.all,\n 'uniswapRouter',\n 'quote',\n chainId,\n poolAddress,\n params?.tokenIn,\n params?.amountIn?.toString(),\n params?.slippageBps?.toString(),\n getClientCacheScopeKey(publicClient, clientScope),\n ] as const,\n queryFn: () =>\n quoteSwapExactInViaRouter({\n client: publicClient,\n poolAddress,\n chainId,\n ...params!,\n }),\n enabled: params !== undefined,\n staleTime: 0,\n })\n}\n\n/**\n * Quote an exact-out spot swap via the Universal Router (V4Quoter-backed).\n * Returns a `SimulationResult` carrying the required input + `amountInMaximum`.\n */\nexport function useQuoteSwapExactOutViaRouter(\n poolAddress: Address,\n params?: OmitClientPoolAndChain<QuoteSwapExactOutViaRouterParams>,\n) {\n const { publicClient, chainId, clientScope } = usePanopticContext()\n return useQuery({\n // Raw `params` carries bigints that break TanStack v5's JSON key hashing; the\n // stringified scalars below fully capture the query identity.\n // eslint-disable-next-line @tanstack/query/exhaustive-deps\n queryKey: [\n ...queryKeys.all,\n 'uniswapRouter',\n 'quoteExactOut',\n chainId,\n poolAddress,\n params?.tokenIn,\n params?.amountOut?.toString(),\n params?.slippageBps?.toString(),\n getClientCacheScopeKey(publicClient, clientScope),\n ] as const,\n queryFn: () =>\n quoteSwapExactOutViaRouter({\n client: publicClient,\n poolAddress,\n chainId,\n ...params!,\n }),\n enabled: params !== undefined,\n staleTime: 0,\n })\n}\n\n/**\n * Check the ERC20 → Permit2 → Universal Router allowance chain.\n */\nexport function useCheckRouterApproval(params?: OmitInjectedWithChain<CheckRouterApprovalParams>) {\n const { publicClient, chainId, clientScope } = usePanopticContext()\n return useQuery({\n // Raw `params` carries bigints that break TanStack v5's JSON key hashing; the\n // stringified scalars below fully capture the query identity.\n // eslint-disable-next-line @tanstack/query/exhaustive-deps\n queryKey: [\n ...queryKeys.all,\n 'uniswapRouter',\n 'approval',\n chainId,\n params?.tokenIn,\n params?.owner,\n params?.amount?.toString(),\n getClientCacheScopeKey(publicClient, clientScope),\n ] as const,\n queryFn: () => checkRouterApproval({ client: publicClient, chainId, ...params! }),\n enabled: params !== undefined,\n staleTime: 0,\n })\n}\n\n/**\n * Execute an exact-in spot swap via the Universal Router.\n */\nexport function useSwapExactInViaRouter(poolAddress: Address) {\n const { publicClient, chainId, walletClient, account } = usePanopticContext()\n const queryClient = useQueryClient()\n\n return useMutation({\n mutationFn: (params: OmitInjectedWithPoolAndChain<SwapExactInViaRouterParams>) => {\n const wallet = requireWallet(walletClient, account)\n return swapExactInViaRouter({\n client: publicClient,\n ...wallet,\n poolAddress,\n chainId,\n ...params,\n })\n },\n onSuccess: () => {\n if (!account) return\n for (const key of mutationEffects.deposit({ chainId, poolAddress, account })) {\n queryClient.invalidateQueries({ queryKey: key })\n }\n },\n })\n}\n\n/**\n * Execute an exact-out spot swap via the Universal Router.\n */\nexport function useSwapExactOutViaRouter(poolAddress: Address) {\n const { publicClient, chainId, walletClient, account } = usePanopticContext()\n const queryClient = useQueryClient()\n\n return useMutation({\n mutationFn: (params: OmitInjectedWithPoolAndChain<SwapExactOutViaRouterParams>) => {\n const wallet = requireWallet(walletClient, account)\n return swapExactOutViaRouter({\n client: publicClient,\n ...wallet,\n poolAddress,\n chainId,\n ...params,\n })\n },\n onSuccess: () => {\n if (!account) return\n for (const key of mutationEffects.deposit({ chainId, poolAddress, account })) {\n queryClient.invalidateQueries({ queryKey: key })\n }\n },\n })\n}\n\n/**\n * Step 1 approval mutation: ERC20 → Permit2.\n */\nexport function useApproveErc20ForPermit2() {\n const { publicClient, chainId, walletClient, account } = usePanopticContext()\n return useMutation({\n mutationFn: (params: OmitInjectedWithChain<ApproveErc20ForPermit2Params>) => {\n const wallet = requireWallet(walletClient, account)\n return approveErc20ForPermit2({ client: publicClient, ...wallet, chainId, ...params })\n },\n })\n}\n\n/**\n * Step 2 approval mutation: Permit2 → Universal Router.\n */\nexport function useApproveRouterViaPermit2() {\n const { publicClient, chainId, walletClient, account } = usePanopticContext()\n return useMutation({\n mutationFn: (params: OmitInjectedWithChain<ApproveRouterViaPermit2Params>) => {\n const wallet = requireWallet(walletClient, account)\n return approveRouterViaPermit2({ client: publicClient, ...wallet, chainId, ...params })\n },\n })\n}\n","/**\n * TanStack Query v5 hooks for the CoW Protocol swap path.\n *\n * Mirrors the Universal Router hooks (usePanopticContext injection,\n * OmitInjected* params) but targets the order-book functions in `src/cow`.\n * Orders settle asynchronously: submission returns an order UID, and\n * `useCowOrderStatus` polls until the order reaches a terminal state.\n *\n * @module v2/react/hooks/cowSwap\n */\n\nimport { useMutation, useQuery, useQueryClient } from '@tanstack/react-query'\nimport type { Address, Hex, WalletClient } from 'viem'\n\nimport {\n type ApproveErc20ForCowParams,\n type CancelCowOrderParams,\n type CheckCowApprovalParams,\n type QuoteCowSwapParams,\n type SignAndSubmitCowOrderParams,\n approveErc20ForCow,\n cancelCowOrder,\n checkCowApproval,\n getCowOrderStatus,\n isCowSupportedChain,\n quoteCowSwap,\n signAndSubmitCowOrder,\n} from '../../../../cow'\nimport { PanopticError } from '../../errors'\nimport { getClientCacheScopeKey } from '../cacheScopes'\nimport { usePanopticContext } from '../provider'\nimport { queryKeys } from '../queryKeys'\n\ntype OmitChainAndFrom<T> = Omit<T, 'chainId' | 'from'>\ntype OmitInjectedWithChain<T> = Omit<T, 'client' | 'walletClient' | 'account' | 'chainId'>\ntype OmitClientOnly<T> = Omit<T, 'client'>\n\nfunction requireWallet(walletClient?: WalletClient, account?: Address) {\n if (!walletClient || !account) {\n throw new PanopticError(\n 'walletClient and account are required. Provide them via PanopticProvider.',\n )\n }\n return { walletClient, account }\n}\n\n/** How often open-order status is re-polled (ms). */\nconst ORDER_POLL_INTERVAL_MS = 5_000\n/** How often quotes refresh (ms) — CoW quotes go stale quickly. */\nconst QUOTE_REFETCH_INTERVAL_MS = 15_000\n\n/**\n * Placeholder order owner for quotes when no wallet is connected — the order\n * book accepts any non-zero `from` for quoting (verification happens at order\n * submission, which always uses the real account).\n */\nconst QUOTE_STUB_FROM = '0x0000000000000000000000000000000000000001' as const\n\n/**\n * Quote a swap via the CoW order book. The connected account (or a stub when\n * disconnected) is used as the order owner (`from`); disabled while the chain\n * has no order book.\n */\nexport function useQuoteCowSwap(params?: OmitChainAndFrom<QuoteCowSwapParams>) {\n const { publicClient, chainId, account, clientScope } = usePanopticContext()\n return useQuery({\n // Raw `params` carries bigints that break TanStack v5's JSON key hashing; the\n // stringified scalars below fully capture the query identity.\n // eslint-disable-next-line @tanstack/query/exhaustive-deps\n queryKey: [\n ...queryKeys.all,\n 'cowSwap',\n 'quote',\n chainId,\n params?.sellToken,\n params?.buyToken,\n params?.kind,\n params?.amount?.toString(),\n params?.slippageBps?.toString(),\n account,\n getClientCacheScopeKey(publicClient, clientScope),\n ] as const,\n queryFn: () => quoteCowSwap({ chainId, from: account ?? QUOTE_STUB_FROM, ...params! }),\n enabled: params !== undefined && isCowSupportedChain(chainId),\n staleTime: 0,\n refetchInterval: QUOTE_REFETCH_INTERVAL_MS,\n })\n}\n\n/** Check the ERC20 → GPv2VaultRelayer allowance for the sell token. */\nexport function useCheckCowApproval(params?: OmitClientOnly<CheckCowApprovalParams>) {\n const { publicClient, chainId, clientScope } = usePanopticContext()\n return useQuery({\n // Raw `params` carries bigints that break TanStack v5's JSON key hashing; the\n // stringified scalars below fully capture the query identity.\n // eslint-disable-next-line @tanstack/query/exhaustive-deps\n queryKey: [\n ...queryKeys.all,\n 'cowSwap',\n 'approval',\n chainId,\n params?.sellToken,\n params?.owner,\n params?.amount?.toString(),\n getClientCacheScopeKey(publicClient, clientScope),\n ] as const,\n queryFn: () => checkCowApproval({ client: publicClient, ...params! }),\n enabled: params !== undefined,\n staleTime: 0,\n })\n}\n\n/** Approval mutation: ERC20 → GPv2VaultRelayer (single step, no Permit2). */\nexport function useApproveErc20ForCow() {\n const { publicClient, walletClient, account } = usePanopticContext()\n const queryClient = useQueryClient()\n return useMutation({\n mutationFn: (params: OmitInjectedWithChain<ApproveErc20ForCowParams>) => {\n const wallet = requireWallet(walletClient, account)\n return approveErc20ForCow({ client: publicClient, ...wallet, ...params })\n },\n // Refresh the cached allowance read (useCheckCowApproval) so the swap CTA\n // advances past \"Approve\" once the approval confirms.\n onSuccess: () => {\n void queryClient.invalidateQueries({ queryKey: [...queryKeys.all, 'cowSwap', 'approval'] })\n },\n })\n}\n\n/**\n * Sign an order (EIP-712) and post it to the order book. Resolves with the\n * order UID — not a tx hash; settlement is asynchronous.\n */\nexport function useSubmitCowOrder() {\n const { chainId, walletClient, account } = usePanopticContext()\n return useMutation({\n mutationFn: (\n params: Omit<SignAndSubmitCowOrderParams, 'walletClient' | 'account' | 'chainId'>,\n ) => {\n const wallet = requireWallet(walletClient, account)\n return signAndSubmitCowOrder({ ...wallet, chainId, ...params })\n },\n })\n}\n\n/**\n * Poll an order's lifecycle state every few seconds while it is open; polling\n * stops automatically once the order reaches a terminal state.\n */\nexport function useCowOrderStatus(orderUid?: Hex) {\n const { chainId } = usePanopticContext()\n return useQuery({\n queryKey: [...queryKeys.all, 'cowSwap', 'orderStatus', chainId, orderUid] as const,\n queryFn: () => getCowOrderStatus({ chainId, orderUid: orderUid! }),\n enabled: orderUid !== undefined,\n refetchInterval: (query) => {\n const status = query.state.data?.status\n return status === undefined || status === 'open' || status === 'presignaturePending'\n ? ORDER_POLL_INTERVAL_MS\n : false\n },\n })\n}\n\n/** Off-chain (signed, free) order cancellation mutation. */\nexport function useCancelCowOrder() {\n const { chainId, walletClient, account } = usePanopticContext()\n return useMutation({\n mutationFn: (params: Omit<CancelCowOrderParams, 'walletClient' | 'account' | 'chainId'>) => {\n const wallet = requireWallet(walletClient, account)\n return cancelCowOrder({ ...wallet, chainId, ...params })\n },\n })\n}\n\n// Re-export the chain gate so UI code can branch without importing `/cow`.\nexport { isCowSupportedChain }\n","/**\n * TanStack Query v5 sync hooks for the Panoptic v2 SDK.\n * @module v2/react/hooks/sync\n */\n\nimport { useMutation, useQueryClient } from '@tanstack/react-query'\nimport { useState } from 'react'\nimport type { Address, Hash } from 'viem'\n\nimport {\n type PendingPosition,\n type SyncProgressEvent,\n addPendingPosition,\n clearTrackedPositions,\n confirmPendingPosition,\n failPendingPosition,\n syncPositions,\n} from '../../sync'\nimport { usePanopticContext, useRequireStorage } from '../provider'\nimport { queryKeys } from '../queryKeys'\n\n/**\n * Hook for syncing positions with progress tracking.\n */\nexport function useSyncPositions(poolAddress: Address) {\n const { publicClient, chainId } = usePanopticContext()\n const storage = useRequireStorage()\n const account = usePanopticContext().account\n const queryClient = useQueryClient()\n const [progress, setProgress] = useState<SyncProgressEvent | null>(null)\n\n const mutation = useMutation({\n mutationFn: async (params?: { fromBlock?: bigint; toBlock?: bigint }) => {\n if (!account) throw new Error('account is required for sync')\n const result = await syncPositions({\n client: publicClient,\n chainId,\n poolAddress,\n account,\n storage,\n fromBlock: params?.fromBlock,\n toBlock: params?.toBlock,\n onUpdate: setProgress,\n })\n return result\n },\n onSuccess: () => {\n if (!account) return\n queryClient.invalidateQueries({\n queryKey: queryKeys.trackedPositionIds(chainId, poolAddress, account),\n })\n queryClient.invalidateQueries({\n queryKey: queryKeys.syncStatus(chainId, poolAddress, account),\n })\n queryClient.invalidateQueries({\n queryKey: queryKeys.positions(chainId, poolAddress, account),\n })\n queryClient.invalidateQueries({\n queryKey: queryKeys.closedPositions(chainId, poolAddress, account),\n })\n queryClient.invalidateQueries({\n queryKey: queryKeys.tradeHistory(chainId, poolAddress, account),\n })\n },\n })\n\n return { ...mutation, progress }\n}\n\n/**\n * Hook for adding a pending position (optimistic update).\n */\nexport function useAddPendingPosition(poolAddress: Address) {\n const { chainId } = usePanopticContext()\n const storage = useRequireStorage()\n const account = usePanopticContext().account\n const queryClient = useQueryClient()\n\n return useMutation({\n mutationFn: (position: PendingPosition) => {\n if (!account) throw new Error('account is required')\n return addPendingPosition({ chainId, poolAddress, account, storage, position })\n },\n onSuccess: () => {\n if (!account) return\n queryClient.invalidateQueries({\n queryKey: queryKeys.trackedPositionIds(chainId, poolAddress, account),\n })\n },\n })\n}\n\n/**\n * Hook for confirming a pending position.\n */\nexport function useConfirmPendingPosition(poolAddress: Address) {\n const { chainId } = usePanopticContext()\n const storage = useRequireStorage()\n const account = usePanopticContext().account\n const queryClient = useQueryClient()\n\n return useMutation({\n mutationFn: (tokenId: bigint) => {\n if (!account) throw new Error('account is required')\n return confirmPendingPosition({ chainId, poolAddress, account, storage, tokenId })\n },\n onSuccess: () => {\n if (!account) return\n queryClient.invalidateQueries({\n queryKey: queryKeys.trackedPositionIds(chainId, poolAddress, account),\n })\n queryClient.invalidateQueries({\n queryKey: queryKeys.positions(chainId, poolAddress, account),\n })\n },\n })\n}\n\n/**\n * Hook for marking a pending position as failed.\n */\nexport function useFailPendingPosition(poolAddress: Address) {\n const { chainId } = usePanopticContext()\n const storage = useRequireStorage()\n const account = usePanopticContext().account\n const queryClient = useQueryClient()\n\n return useMutation({\n mutationFn: (txHash: Hash) => {\n if (!account) throw new Error('account is required')\n return failPendingPosition({ chainId, poolAddress, account, storage, txHash })\n },\n onSuccess: () => {\n if (!account) return\n queryClient.invalidateQueries({\n queryKey: queryKeys.trackedPositionIds(chainId, poolAddress, account),\n })\n },\n })\n}\n\n/**\n * Hook for clearing all tracked positions.\n */\nexport function useClearTrackedPositions(poolAddress: Address) {\n const { chainId } = usePanopticContext()\n const storage = useRequireStorage()\n const account = usePanopticContext().account\n const queryClient = useQueryClient()\n\n return useMutation({\n mutationFn: () => {\n if (!account) throw new Error('account is required')\n return clearTrackedPositions({ chainId, poolAddress, account, storage })\n },\n onSuccess: () => {\n if (!account) return\n queryClient.invalidateQueries({\n queryKey: queryKeys.trackedPositionIds(chainId, poolAddress, account),\n })\n queryClient.invalidateQueries({\n queryKey: queryKeys.positions(chainId, poolAddress, account),\n })\n },\n })\n}\n","/**\n * TanStack Query v5 event hooks for the Panoptic v2 SDK.\n * @module v2/react/hooks/events\n */\n\nimport { useEffect, useRef, useState } from 'react'\nimport type { Address, Hash } from 'viem'\nimport { zeroAddress } from 'viem'\n\nimport { watchEvents } from '../../events'\nimport {\n type EventPoller,\n type EventSubscriptionHandle,\n createEventPoller,\n createEventSubscription,\n} from '../../events'\nimport type { PanopticEvent, PanopticEventType } from '../../types'\nimport { usePanopticContext } from '../provider'\n\n/**\n * Watch events via WebSocket. Returns cleanup automatically on unmount.\n */\nexport function useWatchEvents(\n poolAddress: Address,\n eventTypes: PanopticEventType[] | undefined,\n onEvent: (events: PanopticEvent[]) => void,\n options?: {\n enabled?: boolean\n collateralTracker0?: Address\n collateralTracker1?: Address\n riskEngineAddress?: Address\n sfpmAddress?: Address\n poolManagerAddress?: Address\n onError?: (error: Error) => void\n },\n) {\n const { publicClient } = usePanopticContext()\n const onEventRef = useRef(onEvent)\n onEventRef.current = onEvent\n const onErrorRef = useRef(options?.onError)\n onErrorRef.current = options?.onError\n\n const eventTypesKey = eventTypes?.join(',')\n\n useEffect(() => {\n if (options?.enabled === false) return\n\n const unwatch = watchEvents({\n client: publicClient,\n poolAddress,\n eventTypes,\n collateralTracker0: options?.collateralTracker0,\n collateralTracker1: options?.collateralTracker1,\n riskEngineAddress: options?.riskEngineAddress,\n sfpmAddress: options?.sfpmAddress,\n poolManagerAddress: options?.poolManagerAddress,\n onLogs: (events) => onEventRef.current(events),\n onError: (error) => onErrorRef.current?.(error),\n })\n\n return unwatch\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [\n publicClient,\n poolAddress,\n options?.enabled,\n options?.collateralTracker0,\n options?.collateralTracker1,\n options?.riskEngineAddress,\n options?.sfpmAddress,\n options?.poolManagerAddress,\n eventTypesKey,\n ])\n}\n\n/**\n * Create a resilient event subscription with auto-reconnect.\n */\nexport function useEventSubscription(\n poolAddress: Address,\n eventTypes: PanopticEventType[] | undefined,\n onEvent: (events: PanopticEvent[]) => void,\n options?: {\n enabled?: boolean\n collateralTracker0?: Address\n collateralTracker1?: Address\n riskEngineAddress?: Address\n sfpmAddress?: Address\n poolManagerAddress?: Address\n onError?: (error: Error) => void\n onReconnect?: (attempt: bigint, nextDelayMs: bigint) => void\n onConnected?: () => void\n },\n) {\n const { publicClient } = usePanopticContext()\n const onEventRef = useRef(onEvent)\n onEventRef.current = onEvent\n const onErrorRef = useRef(options?.onError)\n onErrorRef.current = options?.onError\n const onReconnectRef = useRef(options?.onReconnect)\n onReconnectRef.current = options?.onReconnect\n const onConnectedRef = useRef(options?.onConnected)\n onConnectedRef.current = options?.onConnected\n\n const eventTypesKey = eventTypes?.join(',')\n\n useEffect(() => {\n if (options?.enabled === false) return\n\n const handle: EventSubscriptionHandle = createEventSubscription({\n client: publicClient,\n poolAddress,\n eventTypes,\n collateralTracker0: options?.collateralTracker0,\n collateralTracker1: options?.collateralTracker1,\n riskEngineAddress: options?.riskEngineAddress,\n sfpmAddress: options?.sfpmAddress,\n poolManagerAddress: options?.poolManagerAddress,\n onLogs: (events) => onEventRef.current(events),\n onError: (error) => onErrorRef.current?.(error),\n onReconnect: (attempt, delay) => onReconnectRef.current?.(attempt, delay),\n onConnected: () => onConnectedRef.current?.(),\n })\n\n handle.start()\n return () => handle.stop()\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [\n publicClient,\n poolAddress,\n options?.enabled,\n options?.collateralTracker0,\n options?.collateralTracker1,\n options?.riskEngineAddress,\n options?.sfpmAddress,\n options?.poolManagerAddress,\n eventTypesKey,\n ])\n}\n\n/**\n * Create an HTTP polling event fetcher.\n */\nexport function useEventPoller(\n poolAddress: Address,\n eventTypes: PanopticEventType[] | undefined,\n onEvent: (events: PanopticEvent[]) => void,\n options?: {\n enabled?: boolean\n intervalMs?: bigint\n collateralTracker0?: Address\n collateralTracker1?: Address\n riskEngineAddress?: Address\n sfpmAddress?: Address\n poolManagerAddress?: Address\n onError?: (error: Error) => void\n },\n) {\n const { publicClient } = usePanopticContext()\n const onEventRef = useRef(onEvent)\n onEventRef.current = onEvent\n const onErrorRef = useRef(options?.onError)\n onErrorRef.current = options?.onError\n\n const eventTypesKey = eventTypes?.join(',')\n\n useEffect(() => {\n if (options?.enabled === false) return\n\n const poller: EventPoller = createEventPoller({\n client: publicClient,\n poolAddress,\n eventTypes,\n collateralTracker0: options?.collateralTracker0,\n collateralTracker1: options?.collateralTracker1,\n riskEngineAddress: options?.riskEngineAddress,\n sfpmAddress: options?.sfpmAddress,\n poolManagerAddress: options?.poolManagerAddress,\n intervalMs: options?.intervalMs,\n onLogs: (events) => onEventRef.current(events),\n onError: (error) => onErrorRef.current?.(error),\n })\n\n poller.start()\n return () => poller.stop()\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [\n publicClient,\n poolAddress,\n options?.enabled,\n options?.intervalMs,\n options?.collateralTracker0,\n options?.collateralTracker1,\n options?.riskEngineAddress,\n options?.sfpmAddress,\n options?.poolManagerAddress,\n eventTypesKey,\n ])\n}\n\n/**\n * Confirms a transaction by watching for its corresponding on-chain event.\n *\n * An event log only exists in a confirmed (non-reverted) transaction, so\n * matching on `transactionHash` is sufficient proof of 1-block inclusion.\n * This bypasses the N-block confirmation wait of `useWaitForTransactionReceipt`,\n * making it faster on chains with high confirmation counts (e.g. Base = 150 blocks).\n *\n * Use alongside `useWaitForTransactionReceipt` (confirmations: 1) for revert\n * detection — reverted transactions emit no events.\n *\n * @example\n * ```tsx\n * const confirmation = useTxEventConfirmation({\n * txHash: write.data,\n * poolAddress,\n * eventType: 'OptionMinted',\n * enabled: write.data !== undefined,\n * })\n *\n * useEffect(() => {\n * if (confirmation.isSuccess) onSuccess?.()\n * }, [confirmation.isSuccess])\n * ```\n */\nexport function useTxEventConfirmation({\n txHash,\n poolAddress = zeroAddress,\n collateralTrackerAddress,\n eventType,\n enabled = true,\n intervalMs = 3000n,\n}: {\n /** Transaction hash to confirm. Polling starts when this is defined. */\n txHash: Hash | undefined\n /** PanopticPool address to watch for the event. Optional when watching collateral events only. */\n poolAddress?: Address\n /** CollateralTracker address to watch for Deposit/Withdraw events. */\n collateralTrackerAddress?: Address\n /** The event type expected from this transaction. */\n eventType: PanopticEventType\n /** Set to false to disable polling entirely. Default: true. */\n enabled?: boolean\n /** Polling interval in ms. Default: 3000 (~1 block on L2s). */\n intervalMs?: bigint\n}): {\n /** The matched event, set once the tx is confirmed. */\n data: PanopticEvent | undefined\n /** True while polling and not yet confirmed. */\n isLoading: boolean\n /** True once the matching event has been observed. */\n isSuccess: boolean\n} {\n const { publicClient } = usePanopticContext()\n const [data, setData] = useState<PanopticEvent | undefined>()\n const [isLoading, setIsLoading] = useState(false)\n\n // Refs to avoid stale closures inside the async poller callback\n const txHashRef = useRef(txHash)\n txHashRef.current = txHash\n const confirmedRef = useRef(false)\n const pollerRef = useRef<EventPoller | null>(null)\n\n useEffect(() => {\n // Reset for new tx\n confirmedRef.current = false\n setData(undefined)\n\n if (!txHash || !enabled) {\n pollerRef.current?.stop()\n pollerRef.current = null\n setIsLoading(false)\n return\n }\n\n setIsLoading(true)\n let cancelled = false\n\n // Capture current block before starting so we don't miss an event that\n // lands in the same block as poller initialisation.\n publicClient\n .getBlockNumber()\n .then((currentBlock) => {\n if (cancelled) return\n\n const fromBlock = currentBlock > 0n ? currentBlock - 1n : 0n\n\n const poller = createEventPoller({\n client: publicClient,\n poolAddress,\n collateralTracker0: collateralTrackerAddress,\n eventTypes: [eventType],\n intervalMs,\n fromBlock,\n onLogs: (events) => {\n const hash = txHashRef.current\n if (!hash || confirmedRef.current) return\n const match = events.find((e) => e.transactionHash === hash)\n if (match) {\n confirmedRef.current = true\n pollerRef.current?.stop()\n pollerRef.current = null\n setIsLoading(false)\n setData(match)\n }\n },\n })\n\n pollerRef.current = poller\n poller.start()\n })\n .catch(() => {\n if (cancelled || confirmedRef.current) return\n pollerRef.current?.stop()\n pollerRef.current = null\n setIsLoading(false)\n })\n\n return () => {\n cancelled = true\n pollerRef.current?.stop()\n pollerRef.current = null\n }\n }, [txHash, enabled, publicClient, poolAddress, collateralTrackerAddress, eventType, intervalMs])\n\n return {\n data,\n isLoading: isLoading && data === undefined,\n isSuccess: data !== undefined,\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAKA,MAAM,6BAA6B;AACnC,MAAM,8BAA8B;AAEpC,SAAgB,oBAAoBA,OAAwB;AAC1D,QAAO,SAAS;AACjB;AAED,SAAgB,qBAAqBA,OAAwB;AAC3D,QAAO,SAAS;AACjB;AAED,SAAgB,uBAAuBC,QAAiBD,OAAwB;AAG9E,QAAO,oBAAoB,MAAM;AAClC;AAED,SAAgB,wBAAwBE,SAAkBF,OAAwB;AAGhF,QAAO,qBAAqB,MAAM;AACnC;AAED,SAAgB,kBAAkBG,QAAyB;AACzD,QAAO,oBAAuB,WAAW,OAAO,UAAU;AAC3D;;;;ACQD,MAAM,kBAAkB,cAA2C,KAAK;;;;;;;;;;;;;;;;;;;;;AA6BxE,SAAgB,iBAAiB,EAAE,SAAU,GAAG,OAA8B,EAAE;AAC9E,wBAAO,IAAC,gBAAgB;EAAgB;EAAQ;GAAoC;AACrF;;;;;;;AAQD,SAAgB,qBAA2C;CACzD,MAAM,MAAM,WAAW,gBAAgB;AACvC,MAAK,IACH,OAAM,IAAI,MAAM;AAElB,QAAO;AACR;;;;;;;AAsBD,SAAgB,oBAAoC;CAClD,MAAM,EAAE,SAAS,GAAG,oBAAoB;AACxC,MAAK,QACH,OAAM,IAAI,MAAM;AAElB,QAAO;AACR;;;;;;;;;;;;;;;;;;;;;;;ACrFD,MAAa,YAAY;CAIvB,KAAK,CAAC,aAAc;CAKpB,MAAM,CAACC,SAAiBC,gBACtB;EAAC,GAAG,UAAU;EAAK;EAAQ,QAAQ,UAA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M;AACzB,aAAU,UAAU;AACpB,gBAAa,MAAM;EACpB,EAAC;AAEJ,SAAO,MAAM;AACX,eAAY;AACZ,aAAU,SAAS,MAAM;AACzB,aAAU,UAAU;EACrB;CACF,GAAE;EAAC;EAAQ;EAAS;EAAc;EAAa;EAA0B;EAAW;CAAW,EAAC;AAEjG,QAAO;EACL;EACA,WAAW,aAAa;EACxB,WAAW;CACZ;AACF"}
1
+ {"version":3,"file":"react-public.js","names":["scope?: string","client: unknown","storage: unknown","atTick?: bigint","chainId: bigint","poolAddress: Address","tokenId: bigint","account: Address","atTick: bigint","positionSize: bigint","queryAddress: Address","atTick?: bigint","authoritativeRequired0?: bigint","collateralTrackerAddress: Address","positionIdList: bigint[]","totalAssets: bigint","token: Address","owner: Address","spender: Address","tracker: Address","operation: string","amount: bigint","poolAddress: string","timestampsHash: string","rangeHash: string","poolAddress: Address","options?: QueryOptions","tokenIndex: 0 | 1","params: { queryAddress: Address; startTick: bigint; nTicks: bigint }","params: { sfpmAddress: Address }","owner: Address","tokenId: bigint","tokenIds: bigint[]","owner?: Address","account?: Address","queryAddress: Address","options?: QueryOptions & { atTick?: bigint; includePendingPremium?: boolean }","options?: QueryOptions & { atTick?: bigint }","atTicks: bigint[]","amount: bigint","positionSize: bigint","options?: QueryOptions & { atTick?: bigint; authoritativeRequired0?: bigint }","options?: QueryOptions & {\n existingPositionIds?: bigint[]\n neutralizeITM?: boolean\n swapAtMint?: boolean\n /** Size to measure the base flow at (defaults to positionSize). See SDK param. */\n referenceSize?: bigint\n /** PanopticQuery address — gates OTM on true intrinsic. See SDK param. */\n queryAddress?: Address\n }","options?: QueryOptions & {\n existingPositionIds?: bigint[]\n swapAtMint?: boolean\n precisionPct?: number\n usePremiaAsCollateral?: boolean\n }","atTick?: bigint","collateralTrackerAddress: Address","positionIdList: bigint[]","totalAssets: bigint","options?: QueryOptions & { client?: PublicClient }","account: Address | undefined","existingPositionIds: bigint[]","tickLimitLow: bigint","tickLimitHigh: bigint","options?: QueryOptions & {\n spreadLimit?: bigint\n swapAtMint?: boolean\n usePremiaAsCollateral?: boolean\n blockNumber?: bigint\n }","params?: OmitFactoryClient<GetPanopticPoolAddressParams>","params?: OmitFactoryClient<GetFactoryTokenURIParams>","params?: OmitFactoryClient<GetFactoryOwnerOfParams>","params: MinePoolAddressLocalParams","params?: OmitFactoryClient<GetFactoryConstructMetadataParams>","params?: OmitMineClient<SimulateDeployNewPoolParams>","timeRange: PriceHistoryTimeRange","client: PublicClient","poolConfig: PoolVersionConfig","panopticPoolAddress: Address","account: Address","legs: StreamiaLeg[]","options?: QueryOptions & {\n includeUniswapFees?: boolean\n settledEvents?: Array<{ blockNumber: bigint; settled0: bigint; settled1: bigint }>\n }","poolAddress: Address | undefined","queryAddress: Address | undefined","args: { startTick: number; nTicks: bigint } | undefined","poolManager: Address | undefined","poolId: `0x${string}` | undefined","args?: { fromBlock?: bigint; chunkSize?: bigint }","stateViewAddress: Address | undefined","poolKey: UniswapV4PoolKey | undefined","args: { tickSpacing: number; startTick: number; nTicks: bigint } | undefined","panopticPoolAddress: Address | undefined","token0Decimals: bigint","token1Decimals: bigint","nativeIsToken0: boolean","params?: {\n account: Address\n token: Address\n amount: bigint\n slippageBps: bigint\n existingPositionIds: bigint[]\n }","builderCode: bigint | undefined","params: MutationEffectParams","keys: (readonly string[])[]","chainId: bigint","token: Address","owner: Address","spender: Address","params: Pick<MutationEffectParams, 'chainId' | 'poolAddress'>","requireWallet","inputs: WalletInputs","queryClient: QueryClient","keysToInvalidate: readonly (readonly string[])[]","params: OmitInjected<ApproveParams>","poolAddress: Address","params: OmitInjectedWithPool<ApprovePoolParams>","params: OmitInjected<DepositParams>","params: OmitInjected<WithdrawParams>","params: OmitInjected<WrapXstockParams>","params: OmitInjected<UnwrapXstockParams>","params: OmitInjected<WrapEthParams>","params: OmitInjected<UnwrapWethParams>","params: OmitInjected<MintParams>","params: OmitInjected<RedeemParams>","params: OmitInjected<WithdrawWithPositionsParams>","params: OmitInjectedWithPool<OpenPositionParams>","params: OmitInjectedWithPool<ClosePositionParams>","params: OmitInjectedWithPool<RollPositionParams>","params: OmitInjectedWithPool<LiquidateParams>","params: Omit<\n ForceExerciseParams,\n 'client' | 'walletClient' | 'account' | 'poolAddress' | 'chainId' | 'storage'\n >","params: OmitInjectedWithPool<SettleParams>","params?: OmitInjectedWithPool<PokeOracleParams>","params: OmitInjectedWithPool<DispatchParams>","params: OmitInjectedWithPool<ExecuteBatchDispatchParams>","params: OmitInjected<DeployNewPoolParams>","params: OmitInjectedWithPoolAndChain<SwapExactOutParams>","params: OmitInjectedWithPoolAndChain<SupplyParams>","params: OmitInjectedWithPoolAndChain<UnsupplyParams>","params: OmitInjectedWithPoolAndChain<BorrowParams>","params: OmitInjectedWithPoolAndChain<RepayParams>","params: OmitInjectedWithPoolAndChain<SmartRepayParams>","params: OmitInjectedWithPoolAndChain<SwapExactInParams>","poolAddress: Address","params?: OmitClientAndPool<SimulateOpenPositionParams>","params?: OmitClientAndPool<SimulateClosePositionParams>","params?: OmitClient<SimulateDepositParams>","params?: OmitClient<SimulateWithdrawParams>","params?: OmitClientAndPool<SimulateLiquidateParams>","params?: OmitClientAndPool<SimulateForceExerciseParams>","params?: OmitClientAndPool<SimulateSettleParams>","params?: OmitClientAndPool<SimulateBatchDispatchParams>","params?: OmitClientAndPool<SimulateDispatchParams>","params?: OmitClient<SimulateSFPMParams>","params?: OmitClientAndPool<SimulateSwapExactOutParams>","params?: OmitClientAndPool<SimulateSwapExactInParams>","requireWallet","walletClient?: WalletClient","account?: Address","poolAddress: Address","params?: OmitClientPoolAndChain<QuoteSwapExactInViaRouterParams>","params?: OmitClientPoolAndChain<QuoteSwapExactOutViaRouterParams>","params?: OmitInjectedWithChain<CheckRouterApprovalParams>","params: OmitInjectedWithPoolAndChain<SwapExactInViaRouterParams>","params: OmitInjectedWithPoolAndChain<SwapExactOutViaRouterParams>","params: OmitInjectedWithChain<ApproveErc20ForPermit2Params>","params: OmitInjectedWithChain<ApproveRouterViaPermit2Params>","walletClient?: WalletClient","account?: Address","params?: OmitChainAndFrom<QuoteCowSwapParams>","params?: OmitClientOnly<CheckCowApprovalParams>","params: OmitInjectedWithChain<ApproveErc20ForCowParams>","params: Omit<SignAndSubmitCowOrderParams, 'walletClient' | 'account' | 'chainId'>","orderUid?: Hex","params: Omit<CancelCowOrderParams, 'walletClient' | 'account' | 'chainId'>","poolAddress: Address","params?: { fromBlock?: bigint; toBlock?: bigint }","position: PendingPosition","tokenId: bigint","txHash: Hash","poolAddress: Address","eventTypes: PanopticEventType[] | undefined","onEvent: (events: PanopticEvent[]) => void","options?: {\n enabled?: boolean\n collateralTracker0?: Address\n collateralTracker1?: Address\n riskEngineAddress?: Address\n sfpmAddress?: Address\n poolManagerAddress?: Address\n onError?: (error: Error) => void\n }","options?: {\n enabled?: boolean\n collateralTracker0?: Address\n collateralTracker1?: Address\n riskEngineAddress?: Address\n sfpmAddress?: Address\n poolManagerAddress?: Address\n onError?: (error: Error) => void\n onReconnect?: (attempt: bigint, nextDelayMs: bigint) => void\n onConnected?: () => void\n }","handle: EventSubscriptionHandle","options?: {\n enabled?: boolean\n intervalMs?: bigint\n collateralTracker0?: Address\n collateralTracker1?: Address\n riskEngineAddress?: Address\n sfpmAddress?: Address\n poolManagerAddress?: Address\n onError?: (error: Error) => void\n }","poller: EventPoller"],"sources":["../../../src/panoptic/v2/react/cacheScopes.ts","../../../src/panoptic/v2/react/provider.tsx","../../../src/panoptic/v2/react/queryKeys.ts","../../../src/panoptic/v2/react/hooks/reads.ts","../../../src/panoptic/v2/react/mutationEffects.ts","../../../src/panoptic/v2/react/hooks/writes.ts","../../../src/panoptic/v2/react/hooks/simulations.ts","../../../src/panoptic/v2/react/hooks/uniswapRouter.ts","../../../src/panoptic/v2/react/hooks/cowSwap.ts","../../../src/panoptic/v2/react/hooks/sync.ts","../../../src/panoptic/v2/react/hooks/events.ts"],"sourcesContent":["/**\n * Stable cache-scope helpers for React query keys.\n * @module v2/react/cacheScopes\n */\n\nconst DEFAULT_CLIENT_CACHE_SCOPE = 'default-client'\nconst DEFAULT_STORAGE_CACHE_SCOPE = 'default-storage'\n\nexport function getClientCacheScope(scope?: string): string {\n return scope ?? DEFAULT_CLIENT_CACHE_SCOPE\n}\n\nexport function getStorageCacheScope(scope?: string): string {\n return scope ?? DEFAULT_STORAGE_CACHE_SCOPE\n}\n\nexport function getClientCacheScopeKey(client: unknown, scope?: string): string {\n // Keep client in the queryKey expression for exhaustive-deps while keying by stable scope.\n void client\n return getClientCacheScope(scope)\n}\n\nexport function getStorageCacheScopeKey(storage: unknown, scope?: string): string {\n // Keep storage in the queryKey expression for exhaustive-deps while keying by stable scope.\n void storage\n return getStorageCacheScope(scope)\n}\n\nexport function getAtTickCacheKey(atTick?: bigint): string {\n return atTick === undefined ? 'latest' : atTick.toString()\n}\n","/**\n * React context provider for the Panoptic v2 SDK.\n * @module v2/react/provider\n */\n\nimport { type ReactNode, createContext, useContext } from 'react'\nimport type { Address, PublicClient, WalletClient } from 'viem'\n\nimport type { StorageAdapter } from '../storage'\n\n/**\n * Panoptic SDK context value.\n */\nexport interface PanopticContextValue {\n /** viem PublicClient for reading chain state */\n publicClient: PublicClient\n /**\n * Optional cache scope for read/simulation query keys.\n * Use this when multiple environments share the same QueryClient.\n */\n clientScope?: string\n /** Optional viem WalletClient for write operations */\n walletClient?: WalletClient\n /** Optional account address for write operations */\n account?: Address\n /** Chain ID */\n chainId: bigint\n /** Optional StateView address for V4 Uniswap pool reads (per-chain singleton) */\n stateViewAddress?: Address\n /** Optional storage adapter for position tracking */\n storage?: StorageAdapter\n /**\n * Optional cache scope for storage-backed query keys.\n * Set this when swapping storage adapters at runtime.\n */\n storageScope?: string\n}\n\nconst PanopticContext = createContext<PanopticContextValue | null>(null)\n\n/**\n * Props for PanopticProvider.\n */\nexport interface PanopticProviderProps extends PanopticContextValue {\n children: ReactNode\n}\n\n/**\n * Context provider for Panoptic v2 SDK hooks.\n *\n * Wraps children with shared publicClient, walletClient, account, chainId, and storage.\n * Does NOT include QueryClientProvider — you must provide your own.\n *\n * @example\n * ```tsx\n * <QueryClientProvider client={queryClient}>\n * <PanopticProvider\n * publicClient={publicClient}\n * walletClient={walletClient}\n * account={address}\n * chainId={1n}\n * >\n * <App />\n * </PanopticProvider>\n * </QueryClientProvider>\n * ```\n */\nexport function PanopticProvider({ children, ...value }: PanopticProviderProps) {\n return <PanopticContext.Provider value={value}>{children}</PanopticContext.Provider>\n}\n\n/**\n * Access the Panoptic SDK context.\n *\n * @throws Error if used outside PanopticProvider\n * @returns PanopticContextValue\n */\nexport function usePanopticContext(): PanopticContextValue {\n const ctx = useContext(PanopticContext)\n if (!ctx) {\n throw new Error('usePanopticContext must be used within a PanopticProvider')\n }\n return ctx\n}\n\n/**\n * Internal hook that requires walletClient and account.\n *\n * @throws Error if walletClient or account not provided in context\n * @returns { walletClient, account } guaranteed non-undefined\n */\nexport function useRequireWallet(): { walletClient: WalletClient; account: Address } {\n const { walletClient, account } = usePanopticContext()\n if (!walletClient || !account) {\n throw new Error('walletClient and account are required. Provide them via PanopticProvider.')\n }\n return { walletClient, account }\n}\n\n/**\n * Internal hook that requires storage adapter.\n *\n * @throws Error if storage not provided in context\n * @returns StorageAdapter guaranteed non-undefined\n */\nexport function useRequireStorage(): StorageAdapter {\n const { storage } = usePanopticContext()\n if (!storage) {\n throw new Error('storage is required. Provide a StorageAdapter via PanopticProvider.')\n }\n return storage\n}\n","/**\n * Query key factory for TanStack Query / SWR integration.\n * @module v2/react/queryKeys\n */\n\nimport type { Address } from 'viem'\n\n/**\n * Query key factory for Panoptic v2 SDK data.\n *\n * Use with TanStack Query or SWR for cache key consistency.\n * All keys are arrays for proper cache matching and invalidation.\n *\n * @example\n * ```typescript\n * import { useQuery } from '@tanstack/react-query'\n * import { queryKeys, getPool } from 'panoptic-v2-sdk'\n *\n * function usePool(config: PanopticConfig) {\n * return useQuery({\n * queryKey: queryKeys.pool(config.chainId, config.poolAddress),\n * queryFn: () => getPool(config),\n * })\n * }\n * ```\n */\nexport const queryKeys = {\n /**\n * Base key for all Panoptic v2 queries.\n */\n all: ['panoptic-v2'] as const,\n\n /**\n * Key for pool data.\n */\n pool: (chainId: bigint, poolAddress: Address) =>\n [...queryKeys.all, 'pool', chainId.toString(), poolAddress] as const,\n\n /**\n * Key for pool utilization.\n */\n utilization: (chainId: bigint, poolAddress: Address) =>\n [...queryKeys.all, 'utilization', chainId.toString(), poolAddress] as const,\n\n /**\n * Key for oracle state.\n */\n oracle: (chainId: bigint, poolAddress: Address) =>\n [...queryKeys.all, 'oracle', chainId.toString(), poolAddress] as const,\n\n /**\n * Key for safe mode state.\n */\n safeMode: (chainId: bigint, poolAddress: Address) =>\n [...queryKeys.all, 'safeMode', chainId.toString(), poolAddress] as const,\n\n /**\n * Key for Guardian pool-unlock state.\n */\n guardianUnlock: (chainId: bigint, poolAddress: Address) =>\n [...queryKeys.all, 'guardianUnlock', chainId.toString(), poolAddress] as const,\n\n /**\n * Key for risk parameters.\n */\n riskParameters: (chainId: bigint, poolAddress: Address) =>\n [...queryKeys.all, 'riskParameters', chainId.toString(), poolAddress] as const,\n\n /**\n * Key for current rates.\n */\n rates: (chainId: bigint, poolAddress: Address) =>\n [...queryKeys.all, 'rates', chainId.toString(), poolAddress] as const,\n\n /**\n * Key for a single position.\n */\n position: (chainId: bigint, poolAddress: Address, tokenId: bigint) =>\n [...queryKeys.all, 'position', chainId.toString(), poolAddress, tokenId.toString()] as const,\n\n /**\n * Key for all positions of an account.\n */\n positions: (chainId: bigint, poolAddress: Address, account: Address) =>\n [...queryKeys.all, 'positions', chainId.toString(), poolAddress, account] as const,\n\n /**\n * Key for tracked position IDs.\n */\n trackedPositionIds: (chainId: bigint, poolAddress: Address, account: Address) =>\n [...queryKeys.all, 'trackedPositionIds', chainId.toString(), poolAddress, account] as const,\n\n /**\n * Key for sync status.\n */\n syncStatus: (chainId: bigint, poolAddress: Address, account: Address) =>\n [...queryKeys.all, 'syncStatus', chainId.toString(), poolAddress, account] as const,\n\n /**\n * Key for account collateral.\n */\n accountCollateral: (chainId: bigint, poolAddress: Address, account: Address) =>\n [...queryKeys.all, 'accountCollateral', chainId.toString(), poolAddress, account] as const,\n\n /**\n * Key for base account summary (aggregate dashboard data).\n */\n accountSummaryBasic: (chainId: bigint, poolAddress: Address, account: Address) =>\n [...queryKeys.all, 'accountSummaryBasic', chainId.toString(), poolAddress, account] as const,\n\n /**\n * Key for risk-focused account summary.\n */\n accountSummaryRisk: (chainId: bigint, poolAddress: Address, account: Address) =>\n [...queryKeys.all, 'accountSummaryRisk', chainId.toString(), poolAddress, account] as const,\n\n /**\n * Key for liquidation check.\n */\n isLiquidatable: (chainId: bigint, poolAddress: Address, account: Address) =>\n [...queryKeys.all, 'isLiquidatable', chainId.toString(), poolAddress, account] as const,\n\n /**\n * Key for liquidation prices.\n */\n liquidationPrices: (chainId: bigint, poolAddress: Address, account: Address) =>\n [...queryKeys.all, 'liquidationPrices', chainId.toString(), poolAddress, account] as const,\n\n /**\n * Key for net liquidation value.\n */\n netLiquidationValue: (chainId: bigint, poolAddress: Address, account: Address, atTick: bigint) =>\n [\n ...queryKeys.all,\n 'netLiquidationValue',\n chainId.toString(),\n poolAddress,\n account,\n atTick.toString(),\n ] as const,\n\n /**\n * Key for chunk spreads.\n */\n chunkSpreads: (chainId: bigint, poolAddress: Address) =>\n [...queryKeys.all, 'chunkSpreads', chainId.toString(), poolAddress] as const,\n\n /**\n * Key for closed positions.\n */\n closedPositions: (chainId: bigint, poolAddress: Address, account: Address) =>\n [...queryKeys.all, 'closedPositions', chainId.toString(), poolAddress, account] as const,\n\n /**\n * Key for trade history.\n */\n tradeHistory: (chainId: bigint, poolAddress: Address, account: Address) =>\n [...queryKeys.all, 'tradeHistory', chainId.toString(), poolAddress, account] as const,\n\n /**\n * Key for realized PnL.\n */\n realizedPnL: (chainId: bigint, poolAddress: Address, account: Address) =>\n [...queryKeys.all, 'realizedPnL', chainId.toString(), poolAddress, account] as const,\n\n /**\n * Key for position greeks.\n */\n positionGreeks: (chainId: bigint, poolAddress: Address, tokenId: bigint) =>\n [\n ...queryKeys.all,\n 'positionGreeks',\n chainId.toString(),\n poolAddress,\n tokenId.toString(),\n ] as const,\n\n /**\n * Key for account greeks.\n */\n accountGreeks: (chainId: bigint, poolAddress: Address, account: Address) =>\n [...queryKeys.all, 'accountGreeks', chainId.toString(), poolAddress, account] as const,\n\n /**\n * Key for collateral estimate.\n */\n collateralEstimate: (chainId: bigint, poolAddress: Address, account: Address, tokenId: bigint) =>\n [\n ...queryKeys.all,\n 'collateralEstimate',\n chainId.toString(),\n poolAddress,\n account,\n tokenId.toString(),\n ] as const,\n\n /**\n * Key for a position's collateral strategy breakdown.\n */\n collateralBreakdown: (\n chainId: bigint,\n poolAddress: Address,\n tokenId: bigint,\n positionSize: bigint,\n queryAddress: Address,\n atTick?: bigint,\n authoritativeRequired0?: bigint,\n ) =>\n [\n ...queryKeys.all,\n 'collateralBreakdown',\n chainId.toString(),\n poolAddress,\n tokenId.toString(),\n positionSize.toString(),\n queryAddress,\n atTick?.toString(),\n authoritativeRequired0?.toString(),\n ] as const,\n\n /**\n * Key for max position size.\n */\n maxPositionSize: (chainId: bigint, poolAddress: Address, account: Address, tokenId: bigint) =>\n [\n ...queryKeys.all,\n 'maxPositionSize',\n chainId.toString(),\n poolAddress,\n account,\n tokenId.toString(),\n ] as const,\n\n /**\n * Key for max withdrawable assets from a collateral tracker.\n */\n maxWithdrawable: (\n chainId: bigint,\n collateralTrackerAddress: Address,\n positionIdList: bigint[],\n totalAssets: bigint,\n account: Address,\n ) =>\n [\n ...queryKeys.all,\n chainId.toString(),\n 'maxWithdrawable',\n collateralTrackerAddress,\n positionIdList.map(String).join(','),\n totalAssets.toString(),\n account,\n ] as const,\n\n /**\n * Key for max redeemable shares from a collateral tracker.\n */\n maxRedeem: (chainId: bigint, collateralTrackerAddress: Address, account: Address) =>\n [...queryKeys.all, chainId.toString(), 'maxRedeem', collateralTrackerAddress, account] as const,\n\n /**\n * Key for approval check.\n */\n approval: (chainId: bigint, token: Address, owner: Address, spender: Address) =>\n [...queryKeys.all, 'approval', chainId.toString(), token, owner, spender] as const,\n\n /**\n * Key for ERC4626 preview operations.\n */\n erc4626Preview: (chainId: bigint, tracker: Address, operation: string, amount: bigint) =>\n [\n ...queryKeys.all,\n 'erc4626Preview',\n chainId.toString(),\n tracker,\n operation,\n amount.toString(),\n ] as const,\n\n /**\n * Key for margin buffer.\n */\n marginBuffer: (chainId: bigint, poolAddress: Address, account: Address) =>\n [...queryKeys.all, 'marginBuffer', chainId.toString(), poolAddress, account] as const,\n\n /**\n * Key for account premia.\n */\n accountPremia: (chainId: bigint, poolAddress: Address, account: Address) =>\n [...queryKeys.all, 'accountPremia', chainId.toString(), poolAddress, account] as const,\n\n /**\n * Key for positions with premia.\n */\n positionsWithPremia: (chainId: bigint, poolAddress: Address, account: Address) =>\n [...queryKeys.all, 'positionsWithPremia', chainId.toString(), poolAddress, account] as const,\n\n /**\n * Key for collateral data.\n */\n collateralData: (chainId: bigint, poolAddress: Address) =>\n [...queryKeys.all, 'collateralData', chainId.toString(), poolAddress] as const,\n\n /**\n * Key for pool liquidities.\n */\n poolLiquidities: (chainId: bigint, poolAddress: Address) =>\n [...queryKeys.all, 'poolLiquidities', chainId.toString(), poolAddress] as const,\n\n /**\n * Key for optimized risk partners.\n */\n optimizeRiskPartners: (chainId: bigint, poolAddress: Address, tokenId: bigint) =>\n [\n ...queryKeys.all,\n 'optimizeRiskPartners',\n chainId.toString(),\n poolAddress,\n tokenId.toString(),\n ] as const,\n /**\n * Key for price history.\n * Uses a hash of timestamps for cache busting when the time range changes.\n */\n priceHistory: (chainId: bigint, poolAddress: string, timestampsHash: string) =>\n [...queryKeys.all, 'priceHistory', chainId.toString(), poolAddress, timestampsHash] as const,\n\n /**\n * Key for streamia history.\n */\n streamiaHistory: (chainId: bigint, poolAddress: string, rangeHash: string) =>\n [...queryKeys.all, 'streamiaHistory', chainId.toString(), poolAddress, rangeHash] as const,\n\n /**\n * Key for Uniswap fee history.\n */\n uniswapFeeHistory: (chainId: bigint, poolAddress: string, rangeHash: string) =>\n [...queryKeys.all, 'uniswapFeeHistory', chainId.toString(), poolAddress, rangeHash] as const,\n\n /**\n * Key for required credit for ITM position.\n */\n requiredCreditForITM: (\n chainId: bigint,\n poolAddress: Address,\n account: Address,\n tokenId: bigint,\n ) =>\n [\n ...queryKeys.all,\n 'requiredCreditForITM',\n chainId.toString(),\n poolAddress,\n account,\n tokenId.toString(),\n ] as const,\n /**\n * Key for flow-neutral tokenId (ITM-neutralizing legs). Account-independent —\n * itmAmounts is a pure projection of the tokenId + size.\n */\n flowNeutralTokenId: (chainId: bigint, poolAddress: Address, tokenId: bigint) =>\n [\n ...queryKeys.all,\n 'flowNeutralTokenId',\n chainId.toString(),\n poolAddress,\n tokenId.toString(),\n ] as const,\n /**\n * Key for interest state (per-user borrows).\n */\n interestState: (chainId: bigint, poolAddress: Address, account: Address) =>\n [...queryKeys.all, 'interestState', chainId.toString(), poolAddress, account] as const,\n} as const\n","/**\n * TanStack Query v5 read hooks for the Panoptic v2 SDK.\n * @module v2/react/hooks/reads\n */\n\nimport { keepPreviousData, useMutation, useQuery } from '@tanstack/react-query'\nimport type { Address, PublicClient } from 'viem'\nimport { zeroAddress } from 'viem'\n\nimport { estimateBlockNumbers, resolveBlockNumbers } from '../../clients/blocksByTimestamp'\nimport { PanopticValidationError } from '../../errors'\nimport {\n type GetEnforcedTickLimitsParams,\n type GetFactoryConstructMetadataParams,\n type GetFactoryOwnerOfParams,\n type GetFactoryTokenURIParams,\n type GetPanopticPoolAddressParams,\n type GetPanopticPoolFromPoolIdParams,\n type GetUniswapV3PoolFromIdParams,\n type GetUniswapV4PoolKeyFromIdParams,\n type MinePoolAddressLocalParams,\n type ResolvePanopticPoolFromPoolIdParams,\n type SimulateDeployNewPoolParams,\n type UniswapV4PoolKey,\n createFlowNeutralTokenId,\n estimateCollateralBreakdown,\n estimateCollateralRequired,\n getAccountCollateral,\n getAccountGreeks,\n getAccountPremia,\n getAccountSummaryBasic,\n getAccountSummaryRisk,\n getCollateralData,\n getCurrentRates,\n getEnforcedTickLimits,\n getFactoryConstructMetadata,\n getFactoryOwnerOf,\n getFactoryTokenURI,\n getGuardianUnlockState,\n getInterestState,\n getLiquidationPrices,\n getMarginBuffer,\n getMaxPositionSize,\n getMaxRedeem,\n getMaxWithdrawable,\n getNativeTokenPrice,\n getNetLiquidationValue,\n getNetLiquidationValues,\n getOpenPositionPreview,\n getOracleState,\n getPanopticPoolAddress,\n getPanopticPoolFromPoolId,\n getPool,\n getPoolLiquidities,\n getPosition,\n getPositionGreeks,\n getPositions,\n getPositionsWithPremia,\n getRequiredCreditForITM,\n getRiskParameters,\n getSafeMode,\n getUniswapV3PoolFromId,\n getUniswapV3PoolInfo,\n getUniswapV3PoolLiquidities,\n getUniswapV4PoolBasicState,\n getUniswapV4PoolInfo,\n getUniswapV4PoolKeyFromId,\n getUniswapV4PoolLiquidities,\n getUtilization,\n isLiquidatable,\n minePoolAddressLocalAsync,\n previewDeposit,\n previewMint,\n previewRedeem,\n previewWithdraw,\n resolvePanopticPoolFromPoolId,\n resolveUniswapV4PoolKey,\n simulateDeployNewPool,\n validateBuilderCode,\n} from '../../reads'\nimport { getPriceHistory } from '../../reads/priceHistory'\nimport { optimizeTokenIdRiskPartners } from '../../reads/queryUtils'\nimport type { StreamiaLeg } from '../../reads/streamiaHistory'\nimport { getStreamiaHistory } from '../../reads/streamiaHistory'\nimport { getUniswapFeeHistory } from '../../reads/uniswapFeeHistory'\nimport {\n getChunkSpreads,\n getClosedPositions,\n getRealizedPnL,\n getSyncStatus,\n getTrackedPositionIds,\n getTradeHistory,\n scanChunks,\n} from '../../sync'\nimport type { PoolVersionConfig } from '../../types/poolConfig'\nimport { interpolateBlocks } from '../../utils/interpolateBlocks'\nimport { previewBorrow } from '../../writes/lending'\nimport { getAtTickCacheKey, getClientCacheScopeKey, getStorageCacheScopeKey } from '../cacheScopes'\nimport { usePanopticContext, useRequireStorage } from '../provider'\nimport { queryKeys } from '../queryKeys'\n\n/**\n * Common query options exposed to consumers.\n */\nexport interface QueryOptions {\n /** Whether the query is enabled */\n enabled?: boolean\n /** Refetch interval in milliseconds */\n refetchInterval?: number | false\n /** Time in milliseconds that data is considered fresh */\n staleTime?: number\n /** Time in milliseconds that unused data is kept in cache */\n gcTime?: number\n}\n\n// --- Pool reads ---\n\nexport function usePool(poolAddress: Address, options?: QueryOptions) {\n const { publicClient, chainId, clientScope, stateViewAddress } = usePanopticContext()\n return useQuery({\n queryKey: [\n ...queryKeys.pool(chainId, poolAddress),\n getClientCacheScopeKey(publicClient, clientScope),\n stateViewAddress,\n ],\n queryFn: () => getPool({ client: publicClient, poolAddress, chainId, stateViewAddress }),\n enabled: options?.enabled,\n refetchInterval: options?.refetchInterval,\n // Caching is opt-in per consumer: per the SDK's \"no memoization of dynamic RPC\n // data\" constraint, we never default a staleTime here. App code can set one\n // explicitly when it knows the consumer can tolerate cached pool state.\n staleTime: options?.staleTime,\n gcTime: options?.gcTime,\n })\n}\n\nexport function useUtilization(poolAddress: Address, options?: QueryOptions) {\n const { publicClient, chainId, clientScope } = usePanopticContext()\n return useQuery({\n queryKey: [\n ...queryKeys.utilization(chainId, poolAddress),\n getClientCacheScopeKey(publicClient, clientScope),\n ],\n queryFn: () => getUtilization({ client: publicClient, poolAddress }),\n enabled: options?.enabled,\n refetchInterval: options?.refetchInterval,\n staleTime: options?.staleTime,\n gcTime: options?.gcTime,\n })\n}\n\nexport function useOracleState(poolAddress: Address, options?: QueryOptions) {\n const { publicClient, chainId, clientScope } = usePanopticContext()\n return useQuery({\n queryKey: [\n ...queryKeys.oracle(chainId, poolAddress),\n getClientCacheScopeKey(publicClient, clientScope),\n ],\n queryFn: () => getOracleState({ client: publicClient, poolAddress }),\n enabled: options?.enabled,\n refetchInterval: options?.refetchInterval,\n staleTime: options?.staleTime,\n gcTime: options?.gcTime,\n })\n}\n\nexport function useRiskParameters(poolAddress: Address, options?: QueryOptions) {\n const { publicClient, chainId, clientScope } = usePanopticContext()\n return useQuery({\n queryKey: [\n ...queryKeys.riskParameters(chainId, poolAddress),\n getClientCacheScopeKey(publicClient, clientScope),\n ],\n queryFn: () => getRiskParameters({ client: publicClient, poolAddress }),\n enabled: options?.enabled,\n refetchInterval: options?.refetchInterval,\n staleTime: options?.staleTime,\n gcTime: options?.gcTime,\n })\n}\n\nexport function useCurrentRates(poolAddress: Address, options?: QueryOptions) {\n const { publicClient, chainId, clientScope } = usePanopticContext()\n return useQuery({\n queryKey: [\n ...queryKeys.rates(chainId, poolAddress),\n getClientCacheScopeKey(publicClient, clientScope),\n ],\n queryFn: () => getCurrentRates({ client: publicClient, poolAddress }),\n enabled: options?.enabled,\n refetchInterval: options?.refetchInterval,\n staleTime: options?.staleTime,\n gcTime: options?.gcTime,\n })\n}\n\nexport function useSafeMode(poolAddress: Address, options?: QueryOptions) {\n const { publicClient, chainId, clientScope } = usePanopticContext()\n return useQuery({\n queryKey: [\n ...queryKeys.safeMode(chainId, poolAddress),\n getClientCacheScopeKey(publicClient, clientScope),\n ],\n queryFn: () => getSafeMode({ client: publicClient, poolAddress }),\n enabled: options?.enabled,\n refetchInterval: options?.refetchInterval,\n staleTime: options?.staleTime,\n gcTime: options?.gcTime,\n })\n}\n\n/**\n * React hook for the Guardian pending-unlock state of a pool.\n *\n * Reads `unlockEta` + `isPoolUnlockReady` from the PanopticGuardian so the UI\n * can surface the unlock timelock while a pool is locked (close-only). Gate it\n * via `options.enabled` so it only runs when the pool is actually locked.\n *\n * @param poolAddress - The PanopticPool address\n * @param options - Optional react-query settings (enabled, refetchInterval, staleTime, gcTime)\n * @returns A react-query result whose `data` is a `GuardianUnlockState`\n */\nexport function useGuardianUnlockState(poolAddress: Address, options?: QueryOptions) {\n const { publicClient, chainId, clientScope } = usePanopticContext()\n return useQuery({\n queryKey: [\n ...queryKeys.guardianUnlock(chainId, poolAddress),\n getClientCacheScopeKey(publicClient, clientScope),\n ],\n queryFn: () => getGuardianUnlockState({ client: publicClient, poolAddress }),\n enabled: options?.enabled,\n refetchInterval: options?.refetchInterval,\n staleTime: options?.staleTime,\n gcTime: options?.gcTime,\n })\n}\n\nexport function useCollateralData(poolAddress: Address, tokenIndex: 0 | 1, options?: QueryOptions) {\n const { publicClient, chainId, clientScope } = usePanopticContext()\n return useQuery({\n queryKey: [\n ...queryKeys.collateralData(chainId, poolAddress),\n getClientCacheScopeKey(publicClient, clientScope),\n tokenIndex,\n ],\n queryFn: () => getCollateralData({ client: publicClient, poolAddress, tokenIndex }),\n enabled: options?.enabled,\n refetchInterval: options?.refetchInterval,\n staleTime: options?.staleTime,\n gcTime: options?.gcTime,\n })\n}\n\nexport function usePoolLiquidities(\n poolAddress: Address,\n params: { queryAddress: Address; startTick: bigint; nTicks: bigint },\n options?: QueryOptions,\n) {\n const { publicClient, chainId, clientScope } = usePanopticContext()\n return useQuery({\n queryKey: [\n ...queryKeys.poolLiquidities(chainId, poolAddress),\n getClientCacheScopeKey(publicClient, clientScope),\n params.queryAddress,\n params.startTick,\n params.nTicks,\n ],\n queryFn: () =>\n getPoolLiquidities({\n client: publicClient,\n poolAddress,\n queryAddress: params.queryAddress,\n startTick: params.startTick,\n nTicks: params.nTicks,\n }),\n enabled: options?.enabled,\n refetchInterval: options?.refetchInterval,\n staleTime: options?.staleTime,\n gcTime: options?.gcTime,\n })\n}\n\nexport function useScanChunks(\n poolAddress: Address,\n params: { queryAddress: Address; tickLower: bigint; tickUpper: bigint; width: bigint },\n options?: QueryOptions,\n) {\n const { publicClient, chainId, clientScope } = usePanopticContext()\n return useQuery({\n queryKey: [\n ...queryKeys.chunkSpreads(chainId, poolAddress),\n 'scanChunks',\n getClientCacheScopeKey(publicClient, clientScope),\n params.queryAddress,\n params.tickLower,\n params.tickUpper,\n params.width,\n ],\n queryFn: () =>\n scanChunks({\n client: publicClient,\n poolAddress,\n queryAddress: params.queryAddress,\n tickLower: params.tickLower,\n tickUpper: params.tickUpper,\n width: params.width,\n }),\n enabled: options?.enabled,\n refetchInterval: options?.refetchInterval,\n staleTime: options?.staleTime,\n gcTime: options?.gcTime,\n })\n}\n\nexport function useChunkSpreads(\n poolAddress: Address,\n params: { sfpmAddress: Address },\n options?: QueryOptions,\n) {\n const { publicClient, chainId, clientScope, storageScope } = usePanopticContext()\n const storage = useRequireStorage()\n return useQuery({\n queryKey: [\n ...queryKeys.chunkSpreads(chainId, poolAddress),\n getClientCacheScopeKey(publicClient, clientScope),\n params.sfpmAddress,\n getStorageCacheScopeKey(storage, storageScope),\n ],\n queryFn: () =>\n getChunkSpreads({\n client: publicClient,\n chainId,\n poolAddress,\n sfpmAddress: params.sfpmAddress,\n storage,\n }),\n enabled: options?.enabled,\n refetchInterval: options?.refetchInterval,\n staleTime: options?.staleTime,\n gcTime: options?.gcTime,\n })\n}\n\n// --- Position reads ---\n\nexport function usePosition(\n poolAddress: Address,\n owner: Address,\n tokenId: bigint,\n options?: QueryOptions,\n) {\n const { publicClient, chainId, clientScope } = usePanopticContext()\n return useQuery({\n queryKey: [\n ...queryKeys.position(chainId, poolAddress, tokenId),\n getClientCacheScopeKey(publicClient, clientScope),\n owner,\n ],\n queryFn: () => getPosition({ client: publicClient, poolAddress, owner, tokenId }),\n enabled: options?.enabled,\n refetchInterval: options?.refetchInterval,\n staleTime: options?.staleTime,\n gcTime: options?.gcTime,\n })\n}\n\nexport function usePositions(\n poolAddress: Address,\n tokenIds: bigint[],\n owner?: Address,\n options?: QueryOptions,\n) {\n const ctx = usePanopticContext()\n const resolvedOwner = owner ?? ctx.account\n return useQuery({\n queryKey: [\n ...queryKeys.positions(ctx.chainId, poolAddress, resolvedOwner ?? ('' as Address)),\n getClientCacheScopeKey(ctx.publicClient, ctx.clientScope),\n tokenIds,\n ],\n queryFn: () => {\n if (!resolvedOwner) throw new Error('owner required for getPositions')\n return getPositions({ client: ctx.publicClient, poolAddress, owner: resolvedOwner, tokenIds })\n },\n enabled: (options?.enabled ?? true) && !!resolvedOwner,\n refetchInterval: options?.refetchInterval,\n staleTime: options?.staleTime,\n gcTime: options?.gcTime,\n })\n}\n\nexport function usePositionGreeks(\n poolAddress: Address,\n tokenId: bigint,\n owner: Address,\n options?: QueryOptions,\n) {\n const { publicClient, chainId, clientScope } = usePanopticContext()\n return useQuery({\n queryKey: [\n ...queryKeys.positionGreeks(chainId, poolAddress, tokenId),\n getClientCacheScopeKey(publicClient, clientScope),\n owner,\n ],\n queryFn: () => getPositionGreeks({ client: publicClient, poolAddress, tokenId, owner }),\n enabled: options?.enabled,\n refetchInterval: options?.refetchInterval,\n staleTime: options?.staleTime,\n gcTime: options?.gcTime,\n })\n}\n\n// --- Account reads ---\n\nexport function useAccountCollateral(\n poolAddress: Address,\n account?: Address,\n options?: QueryOptions,\n) {\n const ctx = usePanopticContext()\n const resolvedAccount = account ?? ctx.account\n return useQuery({\n queryKey: [\n ...queryKeys.accountCollateral(ctx.chainId, poolAddress, resolvedAccount ?? ('' as Address)),\n getClientCacheScopeKey(ctx.publicClient, ctx.clientScope),\n ],\n queryFn: () => {\n if (!resolvedAccount) throw new Error('account required for getAccountCollateral')\n return getAccountCollateral({\n client: ctx.publicClient,\n poolAddress,\n account: resolvedAccount,\n })\n },\n enabled: (options?.enabled ?? true) && !!resolvedAccount,\n refetchInterval: options?.refetchInterval,\n staleTime: options?.staleTime,\n gcTime: options?.gcTime,\n })\n}\n\nexport function useInterestState(poolAddress: Address, account?: Address, options?: QueryOptions) {\n const ctx = usePanopticContext()\n const resolvedAccount = account ?? ctx.account\n return useQuery({\n queryKey: [\n ...queryKeys.interestState(ctx.chainId, poolAddress, resolvedAccount ?? ('' as Address)),\n getClientCacheScopeKey(ctx.publicClient, ctx.clientScope),\n ],\n queryFn: () => {\n if (!resolvedAccount) throw new Error('account required for getInterestState')\n return getInterestState({\n client: ctx.publicClient,\n poolAddress,\n account: resolvedAccount,\n })\n },\n enabled: (options?.enabled ?? true) && !!resolvedAccount,\n refetchInterval: options?.refetchInterval,\n staleTime: options?.staleTime,\n gcTime: options?.gcTime,\n })\n}\n\nexport function useAccountSummaryBasic(\n poolAddress: Address,\n tokenIds: bigint[],\n account?: Address,\n options?: QueryOptions,\n) {\n const ctx = usePanopticContext()\n const resolvedAccount = account ?? ctx.account\n return useQuery({\n queryKey: [\n ...queryKeys.accountSummaryBasic(\n ctx.chainId,\n poolAddress,\n resolvedAccount ?? ('' as Address),\n ),\n getClientCacheScopeKey(ctx.publicClient, ctx.clientScope),\n tokenIds,\n ],\n queryFn: () => {\n if (!resolvedAccount) throw new Error('account required for getAccountSummaryBasic')\n return getAccountSummaryBasic({\n client: ctx.publicClient,\n poolAddress,\n account: resolvedAccount,\n chainId: ctx.chainId,\n tokenIds,\n })\n },\n enabled: (options?.enabled ?? true) && !!resolvedAccount,\n refetchInterval: options?.refetchInterval,\n staleTime: options?.staleTime,\n gcTime: options?.gcTime,\n })\n}\n\nexport function useAccountSummaryRisk(\n poolAddress: Address,\n tokenIds: bigint[],\n queryAddress: Address,\n account?: Address,\n options?: QueryOptions & { atTick?: bigint; includePendingPremium?: boolean },\n) {\n const ctx = usePanopticContext()\n const resolvedAccount = account ?? ctx.account\n return useQuery({\n queryKey: [\n ...queryKeys.accountSummaryRisk(ctx.chainId, poolAddress, resolvedAccount!),\n getClientCacheScopeKey(ctx.publicClient, ctx.clientScope),\n tokenIds,\n queryAddress,\n options?.atTick,\n options?.includePendingPremium,\n ],\n queryFn: () =>\n getAccountSummaryRisk({\n client: ctx.publicClient,\n poolAddress,\n account: resolvedAccount!,\n chainId: ctx.chainId,\n tokenIds,\n queryAddress,\n atTick: options?.atTick,\n includePendingPremium: options?.includePendingPremium,\n }),\n enabled: (options?.enabled ?? true) && !!resolvedAccount,\n refetchInterval: options?.refetchInterval,\n staleTime: options?.staleTime,\n gcTime: options?.gcTime,\n })\n}\n\nexport function useNetLiquidationValue(\n poolAddress: Address,\n tokenIds: bigint[],\n queryAddress: Address,\n account?: Address,\n options?: QueryOptions & { atTick?: bigint },\n) {\n const ctx = usePanopticContext()\n const resolvedAccount = account ?? ctx.account\n return useQuery({\n queryKey: [\n ...queryKeys.all,\n 'netLiquidationValue',\n ctx.chainId.toString(),\n poolAddress,\n resolvedAccount!,\n getAtTickCacheKey(options?.atTick),\n getClientCacheScopeKey(ctx.publicClient, ctx.clientScope),\n tokenIds,\n queryAddress,\n ],\n queryFn: () =>\n getNetLiquidationValue({\n client: ctx.publicClient,\n poolAddress,\n account: resolvedAccount!,\n tokenIds,\n atTick: options?.atTick,\n queryAddress,\n }),\n enabled: (options?.enabled ?? true) && !!resolvedAccount,\n refetchInterval: options?.refetchInterval,\n staleTime: options?.staleTime,\n gcTime: options?.gcTime,\n })\n}\n\nexport function useNetLiquidationValues(\n poolAddress: Address,\n tokenIds: bigint[],\n queryAddress: Address,\n atTicks: bigint[],\n account?: Address,\n options?: QueryOptions,\n) {\n const ctx = usePanopticContext()\n const resolvedAccount = account ?? ctx.account\n return useQuery({\n queryKey: [\n ...queryKeys.all,\n 'netLiquidationValues',\n ctx.chainId.toString(),\n poolAddress,\n resolvedAccount!,\n getClientCacheScopeKey(ctx.publicClient, ctx.clientScope),\n tokenIds,\n queryAddress,\n atTicks,\n ],\n queryFn: () =>\n getNetLiquidationValues({\n client: ctx.publicClient,\n poolAddress,\n account: resolvedAccount!,\n tokenIds,\n atTicks,\n queryAddress,\n }),\n enabled: (options?.enabled ?? true) && !!resolvedAccount && atTicks.length > 0,\n refetchInterval: options?.refetchInterval,\n staleTime: options?.staleTime,\n gcTime: options?.gcTime,\n })\n}\n\nexport function useLiquidationPrices(\n poolAddress: Address,\n tokenIds: bigint[],\n queryAddress: Address,\n account?: Address,\n options?: QueryOptions,\n) {\n const ctx = usePanopticContext()\n const resolvedAccount = account ?? ctx.account\n return useQuery({\n queryKey: [\n ...queryKeys.liquidationPrices(ctx.chainId, poolAddress, resolvedAccount!),\n getClientCacheScopeKey(ctx.publicClient, ctx.clientScope),\n tokenIds,\n queryAddress,\n ],\n queryFn: () =>\n getLiquidationPrices({\n client: ctx.publicClient,\n poolAddress,\n account: resolvedAccount!,\n tokenIds,\n queryAddress,\n }),\n enabled: (options?.enabled ?? true) && !!resolvedAccount,\n refetchInterval: options?.refetchInterval,\n staleTime: options?.staleTime,\n gcTime: options?.gcTime,\n })\n}\n\nexport function useAccountGreeks(poolAddress: Address, account?: Address, options?: QueryOptions) {\n const ctx = usePanopticContext()\n const storage = useRequireStorage()\n const resolvedAccount = account ?? ctx.account\n return useQuery({\n queryKey: [\n ...queryKeys.accountGreeks(ctx.chainId, poolAddress, resolvedAccount!),\n getClientCacheScopeKey(ctx.publicClient, ctx.clientScope),\n getStorageCacheScopeKey(storage, ctx.storageScope),\n ],\n queryFn: () =>\n getAccountGreeks({\n client: ctx.publicClient,\n chainId: ctx.chainId,\n poolAddress,\n account: resolvedAccount!,\n storage,\n }),\n enabled: (options?.enabled ?? true) && !!resolvedAccount,\n refetchInterval: options?.refetchInterval,\n staleTime: options?.staleTime,\n gcTime: options?.gcTime,\n })\n}\n\nexport function useMarginBuffer(\n poolAddress: Address,\n tokenIds: bigint[],\n queryAddress: Address,\n account?: Address,\n options?: QueryOptions,\n) {\n const ctx = usePanopticContext()\n const resolvedAccount = account ?? ctx.account\n return useQuery({\n queryKey: [\n ...queryKeys.marginBuffer(ctx.chainId, poolAddress, resolvedAccount!),\n getClientCacheScopeKey(ctx.publicClient, ctx.clientScope),\n tokenIds,\n queryAddress,\n ],\n queryFn: () =>\n getMarginBuffer({\n client: ctx.publicClient,\n poolAddress,\n account: resolvedAccount!,\n tokenIds,\n queryAddress,\n }),\n enabled: (options?.enabled ?? true) && !!resolvedAccount,\n refetchInterval: options?.refetchInterval,\n staleTime: options?.staleTime,\n gcTime: options?.gcTime,\n })\n}\n\nexport function useIsLiquidatable(\n poolAddress: Address,\n tokenIds: bigint[],\n queryAddress: Address,\n account?: Address,\n options?: QueryOptions,\n) {\n const ctx = usePanopticContext()\n const resolvedAccount = account ?? ctx.account\n return useQuery({\n queryKey: [\n ...queryKeys.isLiquidatable(ctx.chainId, poolAddress, resolvedAccount!),\n getClientCacheScopeKey(ctx.publicClient, ctx.clientScope),\n tokenIds,\n queryAddress,\n ],\n queryFn: () =>\n isLiquidatable({\n client: ctx.publicClient,\n poolAddress,\n account: resolvedAccount!,\n tokenIds,\n queryAddress,\n }),\n enabled: (options?.enabled ?? true) && !!resolvedAccount,\n refetchInterval: options?.refetchInterval,\n staleTime: options?.staleTime,\n gcTime: options?.gcTime,\n })\n}\n\nexport function useAccountPremia(\n poolAddress: Address,\n tokenIds: bigint[],\n account?: Address,\n options?: QueryOptions,\n) {\n const ctx = usePanopticContext()\n const resolvedAccount = account ?? ctx.account\n return useQuery({\n queryKey: [\n ...queryKeys.accountPremia(ctx.chainId, poolAddress, resolvedAccount!),\n getClientCacheScopeKey(ctx.publicClient, ctx.clientScope),\n tokenIds,\n ],\n queryFn: () =>\n getAccountPremia({\n client: ctx.publicClient,\n poolAddress,\n account: resolvedAccount!,\n tokenIds,\n }),\n enabled: (options?.enabled ?? true) && !!resolvedAccount,\n refetchInterval: options?.refetchInterval,\n staleTime: options?.staleTime,\n gcTime: options?.gcTime,\n })\n}\n\nexport function usePositionsWithPremia(\n poolAddress: Address,\n tokenIds: bigint[],\n account?: Address,\n options?: QueryOptions,\n) {\n const ctx = usePanopticContext()\n const resolvedAccount = account ?? ctx.account\n return useQuery({\n queryKey: [\n ...queryKeys.positionsWithPremia(ctx.chainId, poolAddress, resolvedAccount!),\n getClientCacheScopeKey(ctx.publicClient, ctx.clientScope),\n tokenIds,\n ],\n queryFn: () =>\n getPositionsWithPremia({\n client: ctx.publicClient,\n poolAddress,\n account: resolvedAccount!,\n tokenIds,\n }),\n enabled: (options?.enabled ?? true) && !!resolvedAccount,\n refetchInterval: options?.refetchInterval,\n staleTime: options?.staleTime,\n gcTime: options?.gcTime,\n })\n}\n\n// --- ERC4626 previews ---\n\nexport function usePreviewDeposit(\n poolAddress: Address,\n tokenIndex: 0 | 1,\n amount: bigint,\n options?: QueryOptions,\n) {\n const { publicClient, chainId, clientScope } = usePanopticContext()\n return useQuery({\n queryKey: [\n ...queryKeys.erc4626Preview(chainId, poolAddress, 'deposit', amount),\n getClientCacheScopeKey(publicClient, clientScope),\n tokenIndex,\n ],\n queryFn: () => previewDeposit({ client: publicClient, poolAddress, tokenIndex, amount }),\n enabled: options?.enabled,\n refetchInterval: options?.refetchInterval,\n staleTime: options?.staleTime,\n gcTime: options?.gcTime,\n })\n}\n\nexport function usePreviewWithdraw(\n poolAddress: Address,\n tokenIndex: 0 | 1,\n amount: bigint,\n options?: QueryOptions,\n) {\n const { publicClient, chainId, clientScope } = usePanopticContext()\n return useQuery({\n queryKey: [\n ...queryKeys.erc4626Preview(chainId, poolAddress, 'withdraw', amount),\n getClientCacheScopeKey(publicClient, clientScope),\n tokenIndex,\n ],\n queryFn: () => previewWithdraw({ client: publicClient, poolAddress, tokenIndex, amount }),\n enabled: options?.enabled,\n refetchInterval: options?.refetchInterval,\n staleTime: options?.staleTime,\n gcTime: options?.gcTime,\n })\n}\n\nexport function usePreviewMint(\n poolAddress: Address,\n tokenIndex: 0 | 1,\n amount: bigint,\n options?: QueryOptions,\n) {\n const { publicClient, chainId, clientScope } = usePanopticContext()\n return useQuery({\n queryKey: [\n ...queryKeys.erc4626Preview(chainId, poolAddress, 'mint', amount),\n getClientCacheScopeKey(publicClient, clientScope),\n tokenIndex,\n ],\n queryFn: () => previewMint({ client: publicClient, poolAddress, tokenIndex, amount }),\n enabled: options?.enabled,\n refetchInterval: options?.refetchInterval,\n staleTime: options?.staleTime,\n gcTime: options?.gcTime,\n })\n}\n\nexport function usePreviewRedeem(\n poolAddress: Address,\n tokenIndex: 0 | 1,\n amount: bigint,\n options?: QueryOptions,\n) {\n const { publicClient, chainId, clientScope } = usePanopticContext()\n return useQuery({\n queryKey: [\n ...queryKeys.erc4626Preview(chainId, poolAddress, 'redeem', amount),\n getClientCacheScopeKey(publicClient, clientScope),\n tokenIndex,\n ],\n queryFn: () => previewRedeem({ client: publicClient, poolAddress, tokenIndex, amount }),\n enabled: options?.enabled,\n refetchInterval: options?.refetchInterval,\n staleTime: options?.staleTime,\n gcTime: options?.gcTime,\n })\n}\n\n// --- Collateral estimation ---\n\nexport function useEstimateCollateralRequired(\n poolAddress: Address,\n tokenId: bigint,\n positionSize: bigint,\n queryAddress: Address,\n account?: Address,\n options?: QueryOptions & { atTick?: bigint },\n) {\n const ctx = usePanopticContext()\n // `getRequiredBase` is account-agnostic (it evaluates a synthetic position under\n // `address(0xdead)`), so the estimate must NOT be gated on a connected account.\n // Gating it here was what made a disconnected / view-only user fall through to the\n // UI's buggy client-side per-leg math instead of this on-chain number.\n const resolvedAccount = account ?? ctx.account ?? zeroAddress\n return useQuery({\n queryKey: [\n ...queryKeys.collateralEstimate(ctx.chainId, poolAddress, resolvedAccount, tokenId),\n getClientCacheScopeKey(ctx.publicClient, ctx.clientScope),\n positionSize,\n queryAddress,\n options?.atTick,\n ],\n queryFn: () =>\n estimateCollateralRequired({\n client: ctx.publicClient,\n poolAddress,\n account: resolvedAccount,\n tokenId,\n positionSize,\n queryAddress,\n atTick: options?.atTick,\n }),\n enabled: options?.enabled ?? true,\n refetchInterval: options?.refetchInterval,\n staleTime: options?.staleTime,\n gcTime: options?.gcTime,\n })\n}\n\n/**\n * Classify a position into the strategies the RiskEngine recognizes, and split\n * an authoritative requirement across them.\n *\n * Account-agnostic, like the `getRequiredBase` estimate it builds on — a\n * disconnected or view-only user gets the same breakdown. Pass\n * `authoritativeRequired0` (the total the UI already displays) to get an\n * apportionment; omit it for classification and isolated prices only.\n */\nexport function useCollateralBreakdown(\n poolAddress: Address,\n tokenId: bigint,\n positionSize: bigint,\n queryAddress: Address,\n options?: QueryOptions & { atTick?: bigint; authoritativeRequired0?: bigint },\n) {\n const ctx = usePanopticContext()\n return useQuery({\n queryKey: [\n ...queryKeys.collateralBreakdown(\n ctx.chainId,\n poolAddress,\n tokenId,\n positionSize,\n queryAddress,\n options?.atTick,\n options?.authoritativeRequired0,\n ),\n getClientCacheScopeKey(ctx.publicClient, ctx.clientScope),\n ],\n queryFn: () =>\n estimateCollateralBreakdown({\n client: ctx.publicClient,\n poolAddress,\n queryAddress,\n tokenId,\n positionSize,\n atTick: options?.atTick,\n authoritativeRequired0: options?.authoritativeRequired0,\n }),\n enabled: options?.enabled ?? true,\n refetchInterval: options?.refetchInterval,\n staleTime: options?.staleTime,\n gcTime: options?.gcTime,\n })\n}\n\nexport function useRequiredCreditForITM(\n poolAddress: Address,\n tokenId: bigint,\n positionSize: bigint,\n account?: Address,\n options?: QueryOptions & { existingPositionIds?: bigint[] },\n) {\n const ctx = usePanopticContext()\n const resolvedAccount = account ?? ctx.account\n return useQuery({\n queryKey: [\n ...queryKeys.requiredCreditForITM(\n ctx.chainId,\n poolAddress,\n resolvedAccount ?? ('' as Address),\n tokenId,\n ),\n getClientCacheScopeKey(ctx.publicClient, ctx.clientScope),\n positionSize.toString(),\n (options?.existingPositionIds ?? []).map(String).join(','),\n positionSize,\n options?.existingPositionIds,\n ],\n queryFn: () => {\n if (!resolvedAccount) throw new Error('account required for getRequiredCreditForITM')\n return getRequiredCreditForITM({\n client: ctx.publicClient,\n poolAddress,\n account: resolvedAccount,\n tokenId,\n positionSize,\n existingPositionIds: options?.existingPositionIds,\n })\n },\n enabled: (options?.enabled ?? true) && !!resolvedAccount && tokenId !== 0n && positionSize > 0n,\n refetchInterval: options?.refetchInterval,\n placeholderData: keepPreviousData,\n })\n}\n\nexport function useFlowNeutralTokenId(\n poolAddress: Address,\n tokenId: bigint,\n positionSize: bigint,\n account?: Address,\n options?: QueryOptions & {\n existingPositionIds?: bigint[]\n neutralizeITM?: boolean\n swapAtMint?: boolean\n /** Size to measure the base flow at (defaults to positionSize). See SDK param. */\n referenceSize?: bigint\n /** PanopticQuery address — gates OTM on true intrinsic. See SDK param. */\n queryAddress?: Address\n },\n) {\n const ctx = usePanopticContext()\n const resolvedAccount = account ?? ctx.account\n const neutralizeITM = options?.neutralizeITM ?? true\n const swapAtMint = options?.swapAtMint ?? true\n const referenceSize = options?.referenceSize\n const queryAddress = options?.queryAddress\n return useQuery({\n queryKey: [\n ...queryKeys.flowNeutralTokenId(ctx.chainId, poolAddress, tokenId),\n getClientCacheScopeKey(ctx.publicClient, ctx.clientScope),\n resolvedAccount ?? '',\n positionSize.toString(),\n (options?.existingPositionIds ?? []).map(String).join(','),\n neutralizeITM,\n swapAtMint,\n positionSize,\n options?.existingPositionIds,\n (referenceSize ?? 0n).toString(),\n referenceSize,\n queryAddress ?? '',\n ],\n queryFn: () => {\n if (!resolvedAccount) throw new Error('account required for createFlowNeutralTokenId')\n return createFlowNeutralTokenId({\n client: ctx.publicClient,\n poolAddress,\n account: resolvedAccount,\n tokenId,\n positionSize,\n existingPositionIds: options?.existingPositionIds,\n swapAtMint,\n referenceSize,\n queryAddress,\n })\n },\n enabled:\n (options?.enabled ?? true) &&\n neutralizeITM &&\n !!resolvedAccount &&\n tokenId !== 0n &&\n positionSize > 0n,\n refetchInterval: options?.refetchInterval,\n // Intentionally NO keepPreviousData: the result encodes a specific tokenId that\n // will be minted, so serving stale data from a prior legs/size input could mint\n // the wrong position. Consumers must gate the mint on a fresh, matching result.\n })\n}\n\nexport function useMaxPositionSize(\n poolAddress: Address,\n tokenId: bigint,\n queryAddress: Address,\n account?: Address,\n options?: QueryOptions & {\n existingPositionIds?: bigint[]\n swapAtMint?: boolean\n precisionPct?: number\n usePremiaAsCollateral?: boolean\n },\n) {\n const ctx = usePanopticContext()\n const resolvedAccount = account ?? ctx.account\n return useQuery({\n queryKey: [\n ...queryKeys.maxPositionSize(\n ctx.chainId,\n poolAddress,\n resolvedAccount ?? ('' as Address),\n tokenId,\n ),\n getClientCacheScopeKey(ctx.publicClient, ctx.clientScope),\n queryAddress,\n options?.existingPositionIds?.map(String).join(',') ?? '',\n options?.existingPositionIds,\n options?.swapAtMint ?? false,\n options?.precisionPct ?? 1,\n options?.usePremiaAsCollateral ?? false,\n ],\n queryFn: () => {\n if (!resolvedAccount) throw new Error('account required for getMaxPositionSize')\n return getMaxPositionSize({\n client: ctx.publicClient,\n poolAddress,\n account: resolvedAccount,\n tokenId,\n queryAddress,\n existingPositionIds: options?.existingPositionIds,\n swapAtMint: options?.swapAtMint,\n precisionPct: options?.precisionPct,\n usePremiaAsCollateral: options?.usePremiaAsCollateral,\n })\n },\n enabled: (options?.enabled ?? true) && !!resolvedAccount,\n refetchInterval: options?.refetchInterval,\n placeholderData: keepPreviousData,\n })\n}\n\nexport function useOptimizeRiskPartners(\n poolAddress: Address,\n tokenId: bigint,\n queryAddress: Address,\n atTick?: bigint,\n options?: QueryOptions,\n) {\n const { publicClient, chainId, clientScope } = usePanopticContext()\n return useQuery({\n queryKey: [\n ...queryKeys.optimizeRiskPartners(chainId, poolAddress, tokenId),\n getClientCacheScopeKey(publicClient, clientScope),\n queryAddress,\n getAtTickCacheKey(atTick),\n ],\n queryFn: () =>\n optimizeTokenIdRiskPartners({\n client: publicClient,\n poolAddress,\n tokenId,\n queryAddress,\n atTick,\n }),\n enabled: options?.enabled,\n refetchInterval: options?.refetchInterval,\n placeholderData: keepPreviousData,\n })\n}\n\nexport function useMaxWithdrawable(\n collateralTrackerAddress: Address,\n positionIdList: bigint[],\n totalAssets: bigint,\n account?: Address,\n options?: QueryOptions & { client?: PublicClient },\n) {\n const ctx = usePanopticContext()\n const client = options?.client ?? ctx.publicClient\n const resolvedAccount = account ?? ctx.account\n return useQuery({\n queryKey: [\n ...queryKeys.maxWithdrawable(\n ctx.chainId,\n collateralTrackerAddress,\n positionIdList,\n totalAssets,\n resolvedAccount ?? ('' as Address),\n ),\n getClientCacheScopeKey(client, ctx.clientScope),\n ],\n queryFn: () => {\n if (!resolvedAccount) throw new Error('account required for getMaxWithdrawable')\n return getMaxWithdrawable({\n client,\n collateralTrackerAddress,\n account: resolvedAccount,\n positionIdList,\n totalAssets,\n })\n },\n enabled: (options?.enabled ?? true) && !!resolvedAccount && totalAssets > 0n,\n refetchInterval: options?.refetchInterval,\n staleTime: options?.staleTime,\n gcTime: options?.gcTime,\n })\n}\n\n/**\n * Read the maximum redeemable shares (`maxRedeem`) for an account on a collateral tracker.\n *\n * Redeeming exactly this many shares performs a dust-free full exit (it burns the account's\n * whole available share balance), so it is the correct primitive for a MAX withdraw when the\n * account has no open positions. Returns 0 when positions are open.\n */\nexport function useMaxRedeem(\n collateralTrackerAddress: Address,\n account?: Address,\n options?: QueryOptions & { client?: PublicClient },\n) {\n const ctx = usePanopticContext()\n const client = options?.client ?? ctx.publicClient\n const resolvedAccount = account ?? ctx.account\n return useQuery({\n queryKey: [\n ...queryKeys.maxRedeem(\n ctx.chainId,\n collateralTrackerAddress,\n resolvedAccount ?? ('' as Address),\n ),\n getClientCacheScopeKey(client, ctx.clientScope),\n ],\n queryFn: () => {\n if (!resolvedAccount) throw new Error('account required for getMaxRedeem')\n return getMaxRedeem({ client, collateralTrackerAddress, account: resolvedAccount })\n },\n enabled: (options?.enabled ?? true) && !!resolvedAccount,\n refetchInterval: options?.refetchInterval,\n staleTime: options?.staleTime,\n gcTime: options?.gcTime,\n })\n}\n\n// --- Open position preview ---\n\nexport function useOpenPositionPreview(\n poolAddress: Address,\n account: Address | undefined,\n existingPositionIds: bigint[],\n tokenId: bigint,\n positionSize: bigint,\n queryAddress: Address,\n tickLimitLow: bigint,\n tickLimitHigh: bigint,\n options?: QueryOptions & {\n spreadLimit?: bigint\n swapAtMint?: boolean\n usePremiaAsCollateral?: boolean\n blockNumber?: bigint\n },\n) {\n const ctx = usePanopticContext()\n const resolvedAccount = account ?? ctx.account\n return useQuery({\n // eslint-disable-next-line @tanstack/query/exhaustive-deps -- deps serialized as strings\n queryKey: [\n ...queryKeys.all,\n 'openPositionPreview',\n ctx.chainId.toString(),\n poolAddress,\n resolvedAccount!,\n getClientCacheScopeKey(ctx.publicClient, ctx.clientScope),\n tokenId.toString(),\n positionSize.toString(),\n existingPositionIds.map(String).join(','),\n queryAddress,\n tickLimitLow.toString(),\n tickLimitHigh.toString(),\n options?.spreadLimit?.toString(),\n options?.swapAtMint,\n options?.usePremiaAsCollateral,\n options?.blockNumber?.toString(),\n ],\n queryFn: () =>\n getOpenPositionPreview({\n client: ctx.publicClient,\n poolAddress,\n account: resolvedAccount!,\n existingPositionIds,\n tokenId,\n positionSize,\n queryAddress,\n tickLimitLow,\n tickLimitHigh,\n spreadLimit: options?.spreadLimit,\n swapAtMint: options?.swapAtMint,\n usePremiaAsCollateral: options?.usePremiaAsCollateral,\n chainId: ctx.chainId,\n blockNumber: options?.blockNumber,\n }),\n enabled: (options?.enabled ?? true) && !!resolvedAccount && tokenId !== 0n,\n staleTime: options?.staleTime ?? 0,\n })\n}\n\n// --- Storage-backed reads ---\n\nexport function useTrackedPositionIds(\n poolAddress: Address,\n account?: Address,\n options?: QueryOptions,\n) {\n const ctx = usePanopticContext()\n const storage = useRequireStorage()\n const resolvedAccount = account ?? ctx.account\n return useQuery({\n queryKey: [\n ...queryKeys.trackedPositionIds(ctx.chainId, poolAddress, resolvedAccount!),\n getStorageCacheScopeKey(storage, ctx.storageScope),\n ],\n queryFn: () =>\n getTrackedPositionIds({\n chainId: ctx.chainId,\n poolAddress,\n account: resolvedAccount!,\n storage,\n }),\n enabled: (options?.enabled ?? true) && !!resolvedAccount,\n refetchInterval: options?.refetchInterval,\n staleTime: options?.staleTime,\n gcTime: options?.gcTime,\n })\n}\n\nexport function useTradeHistory(poolAddress: Address, account?: Address, options?: QueryOptions) {\n const ctx = usePanopticContext()\n const storage = useRequireStorage()\n const resolvedAccount = account ?? ctx.account\n return useQuery({\n queryKey: [\n ...queryKeys.tradeHistory(ctx.chainId, poolAddress, resolvedAccount!),\n getStorageCacheScopeKey(storage, ctx.storageScope),\n ],\n queryFn: () =>\n getTradeHistory({ chainId: ctx.chainId, poolAddress, account: resolvedAccount!, storage }),\n enabled: (options?.enabled ?? true) && !!resolvedAccount,\n refetchInterval: options?.refetchInterval,\n staleTime: options?.staleTime,\n gcTime: options?.gcTime,\n })\n}\n\nexport function useRealizedPnL(poolAddress: Address, account?: Address, options?: QueryOptions) {\n const ctx = usePanopticContext()\n const storage = useRequireStorage()\n const resolvedAccount = account ?? ctx.account\n return useQuery({\n queryKey: [\n ...queryKeys.realizedPnL(ctx.chainId, poolAddress, resolvedAccount!),\n getStorageCacheScopeKey(storage, ctx.storageScope),\n ],\n queryFn: () =>\n getRealizedPnL({ chainId: ctx.chainId, poolAddress, account: resolvedAccount!, storage }),\n enabled: (options?.enabled ?? true) && !!resolvedAccount,\n refetchInterval: options?.refetchInterval,\n staleTime: options?.staleTime,\n gcTime: options?.gcTime,\n })\n}\n\nexport function useClosedPositions(\n poolAddress: Address,\n account?: Address,\n options?: QueryOptions,\n) {\n const ctx = usePanopticContext()\n const storage = useRequireStorage()\n const resolvedAccount = account ?? ctx.account\n return useQuery({\n queryKey: [\n ...queryKeys.closedPositions(ctx.chainId, poolAddress, resolvedAccount!),\n getStorageCacheScopeKey(storage, ctx.storageScope),\n ],\n queryFn: () =>\n getClosedPositions({ chainId: ctx.chainId, poolAddress, account: resolvedAccount!, storage }),\n enabled: (options?.enabled ?? true) && !!resolvedAccount,\n refetchInterval: options?.refetchInterval,\n staleTime: options?.staleTime,\n gcTime: options?.gcTime,\n })\n}\n\nexport function useSyncStatus(poolAddress: Address, account?: Address, options?: QueryOptions) {\n const ctx = usePanopticContext()\n const storage = useRequireStorage()\n const resolvedAccount = account ?? ctx.account\n return useQuery({\n queryKey: [\n ...queryKeys.syncStatus(ctx.chainId, poolAddress, resolvedAccount!),\n getClientCacheScopeKey(ctx.publicClient, ctx.clientScope),\n getStorageCacheScopeKey(storage, ctx.storageScope),\n ],\n queryFn: () =>\n getSyncStatus({\n client: ctx.publicClient,\n chainId: ctx.chainId,\n poolAddress,\n account: resolvedAccount!,\n storage,\n }),\n enabled: (options?.enabled ?? true) && !!resolvedAccount,\n refetchInterval: options?.refetchInterval,\n staleTime: options?.staleTime,\n gcTime: options?.gcTime,\n })\n}\n\n// --- Factory reads ---\n\ntype OmitFactoryClient<T> = T extends unknown ? Omit<T, 'client'> : never\n\nexport function usePanopticPoolAddress(\n params?: OmitFactoryClient<GetPanopticPoolAddressParams>,\n options?: QueryOptions,\n) {\n const { publicClient, clientScope } = usePanopticContext()\n return useQuery({\n queryKey: [\n ...queryKeys.all,\n 'factory',\n 'getPanopticPool',\n params?.factoryAddress,\n getClientCacheScopeKey(publicClient, clientScope),\n params,\n ] as const,\n queryFn: () => {\n if (!params) throw new PanopticValidationError('params is required')\n return getPanopticPoolAddress({ client: publicClient, ...params })\n },\n enabled: (options?.enabled ?? true) && params !== undefined,\n refetchInterval: options?.refetchInterval,\n staleTime: options?.staleTime,\n gcTime: options?.gcTime,\n })\n}\n\nexport function useFactoryTokenURI(\n params?: OmitFactoryClient<GetFactoryTokenURIParams>,\n options?: QueryOptions,\n) {\n const { publicClient, clientScope } = usePanopticContext()\n return useQuery({\n queryKey: [\n ...queryKeys.all,\n 'factory',\n 'tokenURI',\n params?.factoryAddress,\n params?.tokenId?.toString(),\n getClientCacheScopeKey(publicClient, clientScope),\n params,\n ] as const,\n queryFn: () => {\n if (!params) throw new PanopticValidationError('params is required')\n return getFactoryTokenURI({ client: publicClient, ...params })\n },\n enabled: (options?.enabled ?? true) && params !== undefined,\n refetchInterval: options?.refetchInterval,\n staleTime: options?.staleTime,\n gcTime: options?.gcTime,\n })\n}\n\nexport function useFactoryOwnerOf(\n params?: OmitFactoryClient<GetFactoryOwnerOfParams>,\n options?: QueryOptions,\n) {\n const { publicClient, clientScope } = usePanopticContext()\n return useQuery({\n queryKey: [\n ...queryKeys.all,\n 'factory',\n 'ownerOf',\n params?.factoryAddress,\n params?.tokenId?.toString(),\n getClientCacheScopeKey(publicClient, clientScope),\n params,\n ] as const,\n queryFn: () => {\n if (!params) throw new PanopticValidationError('params is required')\n return getFactoryOwnerOf({ client: publicClient, ...params })\n },\n enabled: (options?.enabled ?? true) && params !== undefined,\n refetchInterval: options?.refetchInterval,\n staleTime: options?.staleTime,\n gcTime: options?.gcTime,\n })\n}\n\nexport function useMinePoolAddress() {\n return useMutation({\n mutationFn: (params: MinePoolAddressLocalParams) => minePoolAddressLocalAsync(params),\n })\n}\n\nexport function useFactoryConstructMetadata(\n params?: OmitFactoryClient<GetFactoryConstructMetadataParams>,\n options?: QueryOptions,\n) {\n const { publicClient, clientScope } = usePanopticContext()\n return useQuery({\n queryKey: [\n ...queryKeys.all,\n 'factory',\n 'constructMetadata',\n params?.factoryAddress,\n params?.panopticPoolAddress,\n params?.symbol0,\n params?.symbol1,\n params?.fee?.toString(),\n getClientCacheScopeKey(publicClient, clientScope),\n params,\n ] as const,\n queryFn: () => {\n if (!params) throw new PanopticValidationError('params is required')\n return getFactoryConstructMetadata({ client: publicClient, ...params })\n },\n enabled: (options?.enabled ?? true) && params !== undefined,\n refetchInterval: options?.refetchInterval,\n staleTime: options?.staleTime,\n gcTime: options?.gcTime,\n })\n}\n\ntype OmitMineClient<T> = T extends unknown ? Omit<T, 'client'> : never\n\nexport function useSimulateDeployNewPool(\n params?: OmitMineClient<SimulateDeployNewPoolParams>,\n options?: QueryOptions,\n) {\n const { publicClient, clientScope } = usePanopticContext()\n return useQuery({\n queryKey: [\n ...queryKeys.all,\n 'factory',\n 'simulateDeployNewPool',\n params?.factoryAddress,\n params?.account,\n params?.salt?.toString(),\n getClientCacheScopeKey(publicClient, clientScope),\n params,\n ] as const,\n queryFn: () => {\n if (!params) throw new PanopticValidationError('params is required')\n return simulateDeployNewPool({ client: publicClient, ...params })\n },\n enabled: (options?.enabled ?? true) && params !== undefined,\n refetchInterval: options?.refetchInterval,\n staleTime: options?.staleTime,\n gcTime: options?.gcTime,\n })\n}\n\n// --- Price history ---\n\n/** Timestamp-based time range. Start/end resolved to blocks via RPC binary search or estimation. */\nexport interface TimestampTimeRange {\n mode: 'timestamps'\n /** Start of the range (Unix seconds) */\n startTimestamp: number\n /** End of the range (Unix seconds). Defaults to now if omitted. */\n endTimestamp?: number\n /** Number of evenly-spaced data points to fetch */\n points: number\n /** Extra block numbers to include in the fetched set (e.g. blockAtMint) */\n pinnedBlocks?: bigint[]\n /**\n * Block resolution strategy.\n * - 'exact': RPC binary search (~25 sequential getBlock calls). Default.\n * - 'estimate': 2-RPC linear extrapolation. Suitable for charts where\n * ±N-block error is invisible. Saves ~23 RPCs per call.\n */\n resolution?: 'exact' | 'estimate'\n}\n\n/** Block-based time range. No RPC resolution needed. */\nexport interface BlockTimeRange {\n mode: 'blocks'\n /** Start block number */\n startBlock: bigint\n /** End block number. Defaults to latest if omitted. */\n endBlock?: bigint\n /** Number of evenly-spaced data points to fetch */\n points: number\n /** Extra block numbers to include in the fetched set (e.g. blockAtMint) */\n pinnedBlocks?: bigint[]\n}\n\nexport type PriceHistoryTimeRange = TimestampTimeRange | BlockTimeRange\n\n/**\n * Build a stable string cache key from time range params (no object references).\n */\nfunction buildRangeHash(timeRange: PriceHistoryTimeRange): string {\n const pinnedSuffix = timeRange.pinnedBlocks?.length\n ? `-pin:${timeRange.pinnedBlocks.join(',')}`\n : ''\n return timeRange.mode === 'timestamps'\n ? `ts:${timeRange.startTimestamp}-${timeRange.endTimestamp ?? 'now'}-${timeRange.points}-${timeRange.resolution ?? 'exact'}${pinnedSuffix}`\n : `blk:${timeRange.startBlock}-${timeRange.endBlock ?? 'latest'}-${timeRange.points}${pinnedSuffix}`\n}\n\n/**\n * Resolve a PriceHistoryTimeRange to start/end block numbers.\n */\nasync function resolveTimeRange(\n client: PublicClient,\n timeRange: PriceHistoryTimeRange,\n): Promise<{ startBlock: bigint; endBlock: bigint }> {\n if (timeRange.mode === 'timestamps') {\n const resolver =\n timeRange.resolution === 'estimate' ? estimateBlockNumbers : resolveBlockNumbers\n if (timeRange.endTimestamp !== undefined) {\n const resolved = await resolver({\n client,\n timestamps: [timeRange.startTimestamp, timeRange.endTimestamp],\n })\n return { startBlock: resolved[0], endBlock: resolved[1] }\n } else {\n const [resolved, latest] = await Promise.all([\n resolver({ client, timestamps: [timeRange.startTimestamp] }),\n client.getBlockNumber(),\n ])\n return { startBlock: resolved[0], endBlock: latest }\n }\n } else {\n return {\n startBlock: timeRange.startBlock,\n endBlock: timeRange.endBlock ?? (await client.getBlockNumber()),\n }\n }\n}\n\n/**\n * Hook to fetch historical price data (tick + sqrtPriceX96) for a pool.\n *\n * Supports two modes:\n * - **timestamps**: Resolves start/end timestamps to blocks (2 RPC binary searches),\n * then interpolates the blocks in between (pure math).\n * - **blocks**: Uses start/end blocks directly, interpolates in between.\n * Zero resolution overhead.\n *\n * In both cases, the actual price reads are O(points) slot0 calls.\n * Reads at different historical blocks cannot be coalesced into one multicall.\n *\n * @param poolConfig - Pool version config (V3 pool address or V4 StateView + poolId)\n * @param timeRange - Time range specification (timestamps or blocks)\n * @param options - Query options (enabled, refetchInterval, staleTime, gcTime)\n */\nexport function usePriceHistory(\n poolConfig: PoolVersionConfig,\n timeRange: PriceHistoryTimeRange,\n options?: QueryOptions,\n) {\n const { publicClient, chainId, clientScope } = usePanopticContext()\n\n const poolKey = poolConfig.version === 'v3' ? poolConfig.poolAddress : poolConfig.poolId\n const rangeHash = buildRangeHash(timeRange)\n\n return useQuery({\n // rangeHash serializes timeRange; poolKey serializes poolConfig\n // eslint-disable-next-line @tanstack/query/exhaustive-deps\n queryKey: [\n ...queryKeys.priceHistory(chainId, poolKey, rangeHash),\n getClientCacheScopeKey(publicClient, clientScope),\n ],\n queryFn: async () => {\n const { startBlock, endBlock } = await resolveTimeRange(publicClient, timeRange)\n let blockNumbers = interpolateBlocks(startBlock, endBlock, timeRange.points)\n\n // Merge pinned blocks (e.g. blockAtMint) into the sorted array\n if (timeRange.pinnedBlocks?.length) {\n const blockSet = new Set(blockNumbers.map(String))\n const extras = timeRange.pinnedBlocks.filter(\n (b) => b >= startBlock && b <= endBlock && !blockSet.has(String(b)),\n )\n if (extras.length > 0) {\n blockNumbers = [...blockNumbers, ...extras].sort((a, b) => (a < b ? -1 : a > b ? 1 : 0))\n }\n }\n\n return getPriceHistory({ client: publicClient, blockNumbers, poolConfig })\n },\n enabled: (options?.enabled ?? true) && timeRange.points > 0,\n staleTime: options?.staleTime ?? Infinity,\n gcTime: options?.gcTime ?? 60 * 60_000,\n refetchInterval: options?.refetchInterval ?? false,\n refetchOnWindowFocus: false,\n refetchOnReconnect: false,\n })\n}\n\n/**\n * Hook to fetch historical streamia (streaming premia + Uniswap fee) data for a position.\n *\n * @param panopticPoolAddress - PanopticPool contract address\n * @param account - Account whose position to query\n * @param tokenId - The encoded tokenId\n * @param legs - Decoded legs with pre-computed liquidity\n * @param poolConfig - Pool version config (V3 pool address or V4 StateView + poolId)\n * @param timeRange - Time range specification (timestamps or blocks)\n * @param options - Query options + optional includeUniswapFees and settledEvents\n */\nexport function useStreamiaHistory(\n panopticPoolAddress: Address,\n account: Address,\n tokenId: bigint,\n legs: StreamiaLeg[],\n poolConfig: PoolVersionConfig,\n timeRange: PriceHistoryTimeRange,\n options?: QueryOptions & {\n includeUniswapFees?: boolean\n settledEvents?: Array<{ blockNumber: bigint; settled0: bigint; settled1: bigint }>\n },\n) {\n const { publicClient, chainId, clientScope } = usePanopticContext()\n\n const poolKey = poolConfig.version === 'v3' ? poolConfig.poolAddress : poolConfig.poolId\n const rangeHash = buildRangeHash(timeRange)\n\n const legsKey = legs.map((l) => `${l.lowerTick}:${l.upperTick}:${l.liquidity}`).join(',')\n const includeUniswapFees = options?.includeUniswapFees ?? true\n const settledEventsKey = options?.settledEvents\n ? options.settledEvents.map((e) => `${e.blockNumber}:${e.settled0}:${e.settled1}`).join(',')\n : ''\n\n return useQuery({\n // rangeHash serializes timeRange; poolKey serializes poolConfig; legsKey serializes legs\n // eslint-disable-next-line @tanstack/query/exhaustive-deps\n queryKey: [\n ...queryKeys.streamiaHistory(chainId, poolKey, rangeHash),\n getClientCacheScopeKey(publicClient, clientScope),\n panopticPoolAddress,\n account,\n tokenId.toString(),\n legsKey,\n includeUniswapFees,\n settledEventsKey,\n ],\n queryFn: async () => {\n const { startBlock, endBlock } = await resolveTimeRange(publicClient, timeRange)\n let blockNumbers = interpolateBlocks(startBlock, endBlock, timeRange.points)\n if (timeRange.pinnedBlocks?.length) {\n const pinSet = new Set(blockNumbers.map(String))\n const pins = timeRange.pinnedBlocks.filter(\n (b) => b >= startBlock && b <= endBlock && !pinSet.has(String(b)),\n )\n if (pins.length) {\n blockNumbers = [...blockNumbers, ...pins].sort((a, b) => (a < b ? -1 : a > b ? 1 : 0))\n }\n }\n return getStreamiaHistory({\n client: publicClient,\n panopticPoolAddress,\n account,\n tokenId,\n blockNumbers,\n legs,\n poolConfig,\n includeUniswapFees: options?.includeUniswapFees,\n settledEvents: options?.settledEvents,\n })\n },\n enabled: (options?.enabled ?? true) && timeRange.points > 0,\n staleTime: options?.staleTime ?? Infinity,\n gcTime: options?.gcTime ?? 60 * 60_000,\n refetchInterval: options?.refetchInterval ?? false,\n refetchOnWindowFocus: false,\n refetchOnReconnect: false,\n })\n}\n\n/**\n * Hook to fetch historical Uniswap fee data for a set of liquidity legs.\n *\n * @param legs - Decoded legs with pre-computed liquidity\n * @param poolConfig - Pool version config (V3 pool address or V4 StateView + poolId)\n * @param timeRange - Time range specification (timestamps or blocks)\n * @param options - Query options (enabled, refetchInterval, staleTime, gcTime)\n */\nexport function useUniswapFeeHistory(\n legs: StreamiaLeg[],\n poolConfig: PoolVersionConfig,\n timeRange: PriceHistoryTimeRange,\n options?: QueryOptions,\n) {\n const { publicClient, chainId, clientScope } = usePanopticContext()\n\n const poolKey = poolConfig.version === 'v3' ? poolConfig.poolAddress : poolConfig.poolId\n const rangeHash = buildRangeHash(timeRange)\n\n const legsKey = legs.map((l) => `${l.lowerTick}:${l.upperTick}:${l.liquidity}`).join(',')\n\n return useQuery({\n // rangeHash serializes timeRange; poolKey serializes poolConfig; legsKey serializes legs\n // eslint-disable-next-line @tanstack/query/exhaustive-deps\n queryKey: [\n ...queryKeys.uniswapFeeHistory(chainId, poolKey, rangeHash),\n getClientCacheScopeKey(publicClient, clientScope),\n legsKey,\n ],\n queryFn: async () => {\n const { startBlock, endBlock } = await resolveTimeRange(publicClient, timeRange)\n let blockNumbers = interpolateBlocks(startBlock, endBlock, timeRange.points)\n if (timeRange.pinnedBlocks?.length) {\n const pinSet = new Set(blockNumbers.map(String))\n const pins = timeRange.pinnedBlocks.filter(\n (b) => b >= startBlock && b <= endBlock && !pinSet.has(String(b)),\n )\n if (pins.length) {\n blockNumbers = [...blockNumbers, ...pins].sort((a, b) => (a < b ? -1 : a > b ? 1 : 0))\n }\n }\n return getUniswapFeeHistory({ client: publicClient, blockNumbers, legs, poolConfig })\n },\n enabled: (options?.enabled ?? true) && timeRange.points > 0 && legs.length > 0,\n staleTime: options?.staleTime ?? Infinity,\n gcTime: options?.gcTime ?? 60 * 60_000,\n refetchInterval: options?.refetchInterval ?? false,\n refetchOnWindowFocus: false,\n refetchOnReconnect: false,\n })\n}\n\n// --- Direct Uniswap V3 pool info (no Panoptic required) ---\n\n/**\n * Reads basic on-chain info (token0, token1, fee, tickSpacing, slot0, liquidity) from a Uniswap V3 pool.\n * @param poolAddress - The Uniswap V3 pool contract address.\n * @param options - Optional React Query options (`enabled`, `staleTime`, `gcTime`, `refetchInterval`).\n * @returns React Query result resolving to the pool info object.\n */\nexport function useUniswapV3PoolInfo(poolAddress: Address | undefined, options?: QueryOptions) {\n const { publicClient, chainId, clientScope } = usePanopticContext()\n return useQuery({\n queryKey: [\n ...queryKeys.all,\n 'uniswapV3PoolInfo',\n chainId.toString(),\n poolAddress,\n getClientCacheScopeKey(publicClient, clientScope),\n ],\n queryFn: () =>\n getUniswapV3PoolInfo({ client: publicClient, poolAddress: poolAddress as Address }),\n enabled: (options?.enabled ?? true) && !!poolAddress,\n refetchInterval: options?.refetchInterval,\n staleTime: options?.staleTime,\n gcTime: options?.gcTime,\n })\n}\n\n/**\n * Reads per-tick active liquidity from a Uniswap V3 pool via PanopticQuery's `getTickNetsV3`.\n * @param poolAddress - The Uniswap V3 pool contract address.\n * @param queryAddress - The PanopticQuery helper contract address.\n * @param args - Tick window: `startTick` (inclusive) and `nTicks` count to scan.\n * @param options - Optional React Query options (`enabled`, `staleTime`, `gcTime`, `refetchInterval`).\n * @returns React Query result resolving to `{ ticks, liquidityNets }` parallel arrays.\n */\nexport function useUniswapV3PoolLiquidities(\n poolAddress: Address | undefined,\n queryAddress: Address | undefined,\n args: { startTick: number; nTicks: bigint } | undefined,\n options?: QueryOptions,\n) {\n const { publicClient, chainId, clientScope } = usePanopticContext()\n return useQuery({\n // eslint-disable-next-line @tanstack/query/exhaustive-deps\n queryKey: [\n ...queryKeys.all,\n 'uniswapV3PoolLiquidities',\n chainId.toString(),\n poolAddress,\n queryAddress,\n args?.startTick,\n args?.nTicks,\n getClientCacheScopeKey(publicClient, clientScope),\n ],\n queryFn: () => {\n if (!poolAddress || !queryAddress || !args) {\n throw new PanopticValidationError('useUniswapV3PoolLiquidities: missing required args')\n }\n const { startTick, nTicks } = args\n return getUniswapV3PoolLiquidities({\n client: publicClient,\n poolAddress,\n queryAddress,\n startTick,\n nTicks,\n })\n },\n enabled: (options?.enabled ?? true) && !!poolAddress && !!queryAddress && !!args,\n refetchInterval: options?.refetchInterval,\n staleTime: options?.staleTime,\n gcTime: options?.gcTime,\n })\n}\n\n// --- Uniswap V4 direct reads (no Panoptic required) ---\n\n/**\n * Resolves a Uniswap V4 PoolKey from a poolId hash by scanning `Initialize` event logs on the PoolManager.\n * PoolKey is immutable, so results are cached indefinitely within the session by default.\n * @param poolManager - The Uniswap V4 PoolManager contract address.\n * @param poolId - The 32-byte poolId hash.\n * @param args - Optional `fromBlock` and `chunkSize` for log paging.\n * @param options - Optional React Query options (`enabled`, `staleTime`, `gcTime`, `refetchInterval`).\n * @returns React Query result resolving to the resolved `UniswapV4PoolKey`.\n */\nexport function useResolveUniswapV4PoolKey(\n poolManager: Address | undefined,\n poolId: `0x${string}` | undefined,\n args?: { fromBlock?: bigint; chunkSize?: bigint },\n options?: QueryOptions,\n) {\n const { publicClient, chainId, clientScope } = usePanopticContext()\n return useQuery({\n // eslint-disable-next-line @tanstack/query/exhaustive-deps\n queryKey: [\n ...queryKeys.all,\n 'uniswapV4PoolKey',\n chainId.toString(),\n poolManager,\n poolId,\n args?.fromBlock?.toString(),\n args?.chunkSize?.toString(),\n getClientCacheScopeKey(publicClient, clientScope),\n ],\n queryFn: () =>\n resolveUniswapV4PoolKey({\n client: publicClient,\n poolManager: poolManager as Address,\n poolId: poolId as `0x${string}`,\n fromBlock: args?.fromBlock,\n chunkSize: args?.chunkSize,\n }),\n enabled: (options?.enabled ?? true) && !!poolManager && !!poolId,\n // PoolKey is immutable — cache forever within the session.\n staleTime: options?.staleTime ?? Infinity,\n gcTime: options?.gcTime,\n refetchInterval: options?.refetchInterval,\n })\n}\n\n/**\n * Reads basic on-chain state (slot0, liquidity) for a Uniswap V4 pool via the StateView contract.\n * @param stateViewAddress - The Uniswap V4 StateView contract address.\n * @param poolId - The 32-byte poolId hash.\n * @param options - Optional React Query options (`enabled`, `staleTime`, `gcTime`, `refetchInterval`).\n * @returns React Query result resolving to the pool's basic state.\n */\nexport function useUniswapV4PoolBasicState(\n stateViewAddress: Address | undefined,\n poolId: `0x${string}` | undefined,\n options?: QueryOptions,\n) {\n const { publicClient, chainId, clientScope } = usePanopticContext()\n return useQuery({\n queryKey: [\n ...queryKeys.all,\n 'uniswapV4PoolBasicState',\n chainId.toString(),\n stateViewAddress,\n poolId,\n getClientCacheScopeKey(publicClient, clientScope),\n ],\n queryFn: () =>\n getUniswapV4PoolBasicState({\n client: publicClient,\n stateViewAddress: stateViewAddress as Address,\n poolId: poolId as `0x${string}`,\n }),\n enabled: (options?.enabled ?? true) && !!stateViewAddress && !!poolId,\n refetchInterval: options?.refetchInterval,\n staleTime: options?.staleTime,\n gcTime: options?.gcTime,\n })\n}\n\n/**\n * Reads full pool info (slot0, liquidity, and PoolKey-derived metadata) for a Uniswap V4 pool via the StateView contract.\n * @param stateViewAddress - The Uniswap V4 StateView contract address.\n * @param poolKey - The pool's `UniswapV4PoolKey` (currency0, currency1, fee, tickSpacing, hooks).\n * @param options - Optional React Query options (`enabled`, `staleTime`, `gcTime`, `refetchInterval`).\n * @returns React Query result resolving to the full pool info object.\n */\nexport function useUniswapV4PoolInfo(\n stateViewAddress: Address | undefined,\n poolKey: UniswapV4PoolKey | undefined,\n options?: QueryOptions,\n) {\n const { publicClient, chainId, clientScope } = usePanopticContext()\n return useQuery({\n // eslint-disable-next-line @tanstack/query/exhaustive-deps\n queryKey: [\n ...queryKeys.all,\n 'uniswapV4PoolInfo',\n chainId.toString(),\n stateViewAddress,\n poolKey?.currency0,\n poolKey?.currency1,\n poolKey?.fee,\n poolKey?.tickSpacing,\n poolKey?.hooks,\n getClientCacheScopeKey(publicClient, clientScope),\n ],\n queryFn: () =>\n getUniswapV4PoolInfo({\n client: publicClient,\n stateViewAddress: stateViewAddress as Address,\n poolKey: poolKey as UniswapV4PoolKey,\n }),\n enabled: (options?.enabled ?? true) && !!stateViewAddress && !!poolKey,\n refetchInterval: options?.refetchInterval,\n staleTime: options?.staleTime,\n gcTime: options?.gcTime,\n })\n}\n\n/**\n * Reads per-tick active liquidity from a Uniswap V4 pool via PanopticQuery's `getTickNetsV4`.\n * @param queryAddress - The PanopticQuery helper contract address.\n * @param poolManager - The Uniswap V4 PoolManager contract address.\n * @param poolId - The 32-byte poolId hash.\n * @param args - `tickSpacing`, `startTick` (inclusive), and `nTicks` count to scan.\n * @param options - Optional React Query options (`enabled`, `staleTime`, `gcTime`, `refetchInterval`).\n * @returns React Query result resolving to `{ ticks, liquidityNets }` parallel arrays.\n */\nexport function useUniswapV4PoolLiquidities(\n queryAddress: Address | undefined,\n poolManager: Address | undefined,\n poolId: `0x${string}` | undefined,\n args: { tickSpacing: number; startTick: number; nTicks: bigint } | undefined,\n options?: QueryOptions,\n) {\n const { publicClient, chainId, clientScope } = usePanopticContext()\n return useQuery({\n // eslint-disable-next-line @tanstack/query/exhaustive-deps\n queryKey: [\n ...queryKeys.all,\n 'uniswapV4PoolLiquidities',\n chainId.toString(),\n queryAddress,\n poolManager,\n poolId,\n args?.tickSpacing,\n args?.startTick,\n args?.nTicks,\n getClientCacheScopeKey(publicClient, clientScope),\n ],\n queryFn: () => {\n if (!queryAddress || !poolManager || !poolId || !args) {\n throw new PanopticValidationError('useUniswapV4PoolLiquidities: missing required args')\n }\n const { tickSpacing, startTick, nTicks } = args\n return getUniswapV4PoolLiquidities({\n client: publicClient,\n queryAddress,\n poolManager,\n poolId,\n tickSpacing,\n startTick,\n nTicks,\n })\n },\n enabled: (options?.enabled ?? true) && !!queryAddress && !!poolManager && !!poolId && !!args,\n refetchInterval: options?.refetchInterval,\n staleTime: options?.staleTime,\n gcTime: options?.gcTime,\n })\n}\n\n// --- Native token price ---\n\nexport function useNativeTokenPrice(\n panopticPoolAddress: Address | undefined,\n token0Decimals: bigint,\n token1Decimals: bigint,\n nativeIsToken0: boolean,\n options?: QueryOptions,\n) {\n const { publicClient, chainId, clientScope } = usePanopticContext()\n return useQuery({\n queryKey: [\n ...queryKeys.all,\n 'nativeTokenPrice',\n chainId,\n panopticPoolAddress,\n token0Decimals,\n token1Decimals,\n nativeIsToken0,\n getClientCacheScopeKey(publicClient, clientScope),\n ],\n queryFn: () =>\n getNativeTokenPrice({\n client: publicClient,\n panopticPoolAddress: panopticPoolAddress!,\n token0Decimals,\n token1Decimals,\n nativeIsToken0,\n }),\n enabled: (options?.enabled ?? true) && panopticPoolAddress !== undefined,\n refetchInterval: options?.refetchInterval ?? 30_000,\n staleTime: options?.staleTime,\n gcTime: options?.gcTime,\n })\n}\n\n// --- SFPM reads ---\n\ntype OmitSfpmClient<T> = Omit<T, 'client'>\n\nexport function useUniswapV3PoolFromId(\n params?: OmitSfpmClient<GetUniswapV3PoolFromIdParams>,\n options?: QueryOptions,\n) {\n const { publicClient, clientScope } = usePanopticContext()\n return useQuery({\n queryKey: [\n ...queryKeys.all,\n 'sfpm',\n 'getUniswapV3PoolFromId',\n params?.sfpmAddress,\n params?.poolId?.toString(),\n getClientCacheScopeKey(publicClient, clientScope),\n params,\n ] as const,\n queryFn: () => {\n if (!params) throw new PanopticValidationError('params is required')\n return getUniswapV3PoolFromId({ client: publicClient, ...params })\n },\n enabled: (options?.enabled ?? true) && params !== undefined,\n refetchInterval: options?.refetchInterval,\n staleTime: options?.staleTime,\n gcTime: options?.gcTime,\n })\n}\n\nexport function useUniswapV4PoolKeyFromId(\n params?: OmitSfpmClient<GetUniswapV4PoolKeyFromIdParams>,\n options?: QueryOptions,\n) {\n const { publicClient, clientScope } = usePanopticContext()\n return useQuery({\n queryKey: [\n ...queryKeys.all,\n 'sfpm',\n 'getUniswapV4PoolKeyFromId',\n params?.sfpmAddress,\n params?.poolId?.toString(),\n getClientCacheScopeKey(publicClient, clientScope),\n params,\n ] as const,\n queryFn: () => {\n if (!params) throw new PanopticValidationError('params is required')\n return getUniswapV4PoolKeyFromId({ client: publicClient, ...params })\n },\n enabled: (options?.enabled ?? true) && params !== undefined,\n refetchInterval: options?.refetchInterval,\n staleTime: options?.staleTime,\n gcTime: options?.gcTime,\n })\n}\n\nexport function useEnforcedTickLimits(\n params?: OmitSfpmClient<GetEnforcedTickLimitsParams>,\n options?: QueryOptions,\n) {\n const { publicClient, clientScope } = usePanopticContext()\n return useQuery({\n queryKey: [\n ...queryKeys.all,\n 'sfpm',\n 'getEnforcedTickLimits',\n params?.sfpmAddress,\n params?.poolId?.toString(),\n getClientCacheScopeKey(publicClient, clientScope),\n params,\n ] as const,\n queryFn: () => {\n if (!params) throw new PanopticValidationError('params is required')\n return getEnforcedTickLimits({ client: publicClient, ...params })\n },\n enabled: (options?.enabled ?? true) && params !== undefined,\n refetchInterval: options?.refetchInterval,\n staleTime: options?.staleTime,\n gcTime: options?.gcTime,\n })\n}\n\n// --- Factory + SFPM composite reads ---\n\nexport function usePanopticPoolFromPoolId(\n params?: OmitFactoryClient<GetPanopticPoolFromPoolIdParams>,\n options?: QueryOptions,\n) {\n const { publicClient, clientScope } = usePanopticContext()\n return useQuery({\n queryKey: [\n ...queryKeys.all,\n 'factory',\n 'getPanopticPoolFromPoolId',\n params?.sfpmAddress,\n params?.factoryAddress,\n params?.riskEngine,\n params?.poolId?.toString(),\n getClientCacheScopeKey(publicClient, clientScope),\n params,\n ] as const,\n queryFn: () => {\n if (!params) throw new PanopticValidationError('params is required')\n return getPanopticPoolFromPoolId({ client: publicClient, ...params })\n },\n enabled: (options?.enabled ?? true) && params !== undefined,\n refetchInterval: options?.refetchInterval,\n staleTime: options?.staleTime,\n gcTime: options?.gcTime,\n })\n}\n\ntype OmitResolveClient = Omit<ResolvePanopticPoolFromPoolIdParams, 'client'>\n\nexport function useResolvePanopticPoolFromPoolId(\n params?: OmitResolveClient,\n options?: QueryOptions,\n) {\n const { publicClient, clientScope } = usePanopticContext()\n return useQuery({\n queryKey: [\n ...queryKeys.all,\n 'factory',\n 'resolvePanopticPoolFromPoolId',\n params?.poolId?.toString(),\n params?.riskEngine,\n params?.v3?.sfpmAddress,\n params?.v3?.factoryAddress,\n params?.v4?.sfpmAddress,\n params?.v4?.factoryAddress,\n getClientCacheScopeKey(publicClient, clientScope),\n params,\n ] as const,\n queryFn: () => {\n if (!params) throw new PanopticValidationError('params is required')\n return resolvePanopticPoolFromPoolId({ client: publicClient, ...params })\n },\n enabled: (options?.enabled ?? true) && params !== undefined,\n refetchInterval: options?.refetchInterval,\n staleTime: options?.staleTime,\n gcTime: options?.gcTime,\n })\n}\n\n// --- Borrow preview ---\n\nexport function usePreviewBorrow(\n poolAddress: Address,\n params?: {\n account: Address\n token: Address\n amount: bigint\n slippageBps: bigint\n existingPositionIds: bigint[]\n },\n options?: QueryOptions,\n) {\n const ctx = usePanopticContext()\n return useQuery({\n queryKey: [\n ...queryKeys.all,\n 'previewBorrow',\n ctx.chainId,\n poolAddress,\n params?.account,\n params?.token,\n params?.amount?.toString(),\n params?.slippageBps?.toString(),\n params?.existingPositionIds?.map(String).join(','),\n getClientCacheScopeKey(ctx.publicClient, ctx.clientScope),\n ],\n queryFn: () =>\n previewBorrow({\n client: ctx.publicClient,\n poolAddress,\n chainId: ctx.chainId,\n account: params!.account,\n token: params!.token,\n amount: params!.amount,\n slippageBps: params!.slippageBps,\n existingPositionIds: params!.existingPositionIds,\n }),\n enabled: (options?.enabled ?? true) && !!params && params.amount > 0n,\n staleTime: options?.staleTime ?? 10_000,\n gcTime: options?.gcTime,\n placeholderData: keepPreviousData,\n })\n}\n\n/**\n * Validate whether a builder code maps to a deployed builder wallet.\n *\n * Returns `{ data: true }` for valid codes, `{ data: false }` for invalid.\n * Disabled when `builderCode` is `undefined` or `0n`.\n */\nexport function useValidateBuilderCode(\n poolAddress: Address,\n builderCode: bigint | undefined,\n options?: QueryOptions,\n) {\n const { publicClient, clientScope } = usePanopticContext()\n return useQuery({\n queryKey: [\n 'validateBuilderCode',\n poolAddress,\n String(builderCode),\n getClientCacheScopeKey(publicClient, clientScope),\n ],\n queryFn: () => {\n if (builderCode === undefined) throw new Error('builderCode is undefined')\n return validateBuilderCode({\n client: publicClient,\n poolAddress,\n builderCode,\n })\n },\n enabled: (options?.enabled ?? true) && builderCode !== undefined && builderCode !== 0n,\n staleTime: options?.staleTime ?? 60_000,\n gcTime: options?.gcTime,\n })\n}\n","/**\n * Mutation effects for cache invalidation with TanStack Query / SWR.\n * @module v2/react/mutationEffects\n */\n\nimport type { Address } from 'viem'\n\nimport { queryKeys } from './queryKeys'\n\n/**\n * Mutation type identifiers.\n */\nexport type MutationType =\n | 'openPosition'\n | 'closePosition'\n | 'forceExercise'\n | 'liquidate'\n | 'settleAccumulatedPremia'\n | 'deposit'\n | 'withdraw'\n | 'mint'\n | 'redeem'\n | 'approve'\n | 'pokeOracle'\n\n/**\n * Parameters for determining which queries to invalidate.\n */\nexport interface MutationEffectParams {\n chainId: bigint\n poolAddress: Address\n account: Address\n tokenId?: bigint\n}\n\n/**\n * Returns query keys that should be invalidated after a mutation.\n *\n * Use with TanStack Query's `queryClient.invalidateQueries()` or SWR's `mutate()`.\n *\n * @example\n * ```typescript\n * import { useMutation, useQueryClient } from '@tanstack/react-query'\n * import { mutationEffects, openPosition } from 'panoptic-v2-sdk'\n *\n * function useOpenPosition(config: WriteConfig) {\n * const queryClient = useQueryClient()\n *\n * return useMutation({\n * mutationFn: (params) => openPosition(config, params),\n * onSuccess: () => {\n * const keysToInvalidate = mutationEffects.openPosition({\n * chainId: config.chainId,\n * poolAddress: config.poolAddress,\n * account: config.walletClient.account.address,\n * })\n *\n * for (const key of keysToInvalidate) {\n * queryClient.invalidateQueries({ queryKey: key })\n * }\n * },\n * })\n * }\n * ```\n */\nexport const mutationEffects = {\n /**\n * Queries to invalidate after opening a position.\n */\n openPosition: (params: MutationEffectParams): readonly (readonly string[])[] => {\n const { chainId, poolAddress, account } = params\n return [\n queryKeys.pool(chainId, poolAddress),\n queryKeys.utilization(chainId, poolAddress),\n queryKeys.positions(chainId, poolAddress, account),\n queryKeys.trackedPositionIds(chainId, poolAddress, account),\n queryKeys.accountCollateral(chainId, poolAddress, account),\n queryKeys.accountSummaryBasic(chainId, poolAddress, account),\n queryKeys.accountSummaryRisk(chainId, poolAddress, account),\n queryKeys.isLiquidatable(chainId, poolAddress, account),\n queryKeys.liquidationPrices(chainId, poolAddress, account),\n queryKeys.accountGreeks(chainId, poolAddress, account),\n queryKeys.chunkSpreads(chainId, poolAddress),\n ]\n },\n\n /**\n * Queries to invalidate after closing a position.\n */\n closePosition: (params: MutationEffectParams): readonly (readonly string[])[] => {\n const { chainId, poolAddress, account, tokenId } = params\n const keys: (readonly string[])[] = [\n queryKeys.pool(chainId, poolAddress),\n queryKeys.utilization(chainId, poolAddress),\n queryKeys.positions(chainId, poolAddress, account),\n queryKeys.trackedPositionIds(chainId, poolAddress, account),\n queryKeys.accountCollateral(chainId, poolAddress, account),\n queryKeys.accountSummaryBasic(chainId, poolAddress, account),\n queryKeys.accountSummaryRisk(chainId, poolAddress, account),\n queryKeys.isLiquidatable(chainId, poolAddress, account),\n queryKeys.liquidationPrices(chainId, poolAddress, account),\n queryKeys.accountGreeks(chainId, poolAddress, account),\n queryKeys.closedPositions(chainId, poolAddress, account),\n queryKeys.tradeHistory(chainId, poolAddress, account),\n queryKeys.realizedPnL(chainId, poolAddress, account),\n queryKeys.chunkSpreads(chainId, poolAddress),\n ]\n\n if (tokenId !== undefined) {\n keys.push(queryKeys.position(chainId, poolAddress, tokenId))\n keys.push(queryKeys.positionGreeks(chainId, poolAddress, tokenId))\n }\n\n return keys\n },\n\n /**\n * Queries to invalidate after force exercising a position.\n */\n forceExercise: (params: MutationEffectParams): readonly (readonly string[])[] => {\n const { chainId, poolAddress, account, tokenId } = params\n const keys: (readonly string[])[] = [\n queryKeys.pool(chainId, poolAddress),\n queryKeys.utilization(chainId, poolAddress),\n queryKeys.accountCollateral(chainId, poolAddress, account),\n queryKeys.accountSummaryBasic(chainId, poolAddress, account),\n queryKeys.accountSummaryRisk(chainId, poolAddress, account),\n queryKeys.chunkSpreads(chainId, poolAddress),\n ]\n\n if (tokenId !== undefined) {\n keys.push(queryKeys.position(chainId, poolAddress, tokenId))\n }\n\n return keys\n },\n\n /**\n * Queries to invalidate after liquidating an account.\n */\n liquidate: (params: MutationEffectParams): readonly (readonly string[])[] => {\n const { chainId, poolAddress, account } = params\n return [\n queryKeys.pool(chainId, poolAddress),\n queryKeys.utilization(chainId, poolAddress),\n queryKeys.positions(chainId, poolAddress, account),\n queryKeys.trackedPositionIds(chainId, poolAddress, account),\n queryKeys.accountCollateral(chainId, poolAddress, account),\n queryKeys.accountSummaryBasic(chainId, poolAddress, account),\n queryKeys.accountSummaryRisk(chainId, poolAddress, account),\n queryKeys.isLiquidatable(chainId, poolAddress, account),\n queryKeys.liquidationPrices(chainId, poolAddress, account),\n queryKeys.accountGreeks(chainId, poolAddress, account),\n queryKeys.closedPositions(chainId, poolAddress, account),\n queryKeys.chunkSpreads(chainId, poolAddress),\n ]\n },\n\n /**\n * Queries to invalidate after settling accumulated premia.\n */\n settleAccumulatedPremia: (params: MutationEffectParams): readonly (readonly string[])[] => {\n const { chainId, poolAddress, account, tokenId } = params\n const keys: (readonly string[])[] = [\n queryKeys.accountCollateral(chainId, poolAddress, account),\n queryKeys.accountSummaryBasic(chainId, poolAddress, account),\n queryKeys.accountSummaryRisk(chainId, poolAddress, account),\n ]\n\n if (tokenId !== undefined) {\n keys.push(queryKeys.position(chainId, poolAddress, tokenId))\n }\n\n return keys\n },\n\n /**\n * Queries to invalidate after depositing to collateral tracker.\n */\n deposit: (params: MutationEffectParams): readonly (readonly string[])[] => {\n const { chainId, poolAddress, account } = params\n return [\n queryKeys.accountCollateral(chainId, poolAddress, account),\n queryKeys.accountSummaryBasic(chainId, poolAddress, account),\n queryKeys.accountSummaryRisk(chainId, poolAddress, account),\n queryKeys.isLiquidatable(chainId, poolAddress, account),\n queryKeys.liquidationPrices(chainId, poolAddress, account),\n ]\n },\n\n /**\n * Queries to invalidate after withdrawing from collateral tracker.\n */\n withdraw: (params: MutationEffectParams): readonly (readonly string[])[] => {\n const { chainId, poolAddress, account } = params\n return [\n queryKeys.accountCollateral(chainId, poolAddress, account),\n queryKeys.accountSummaryBasic(chainId, poolAddress, account),\n queryKeys.accountSummaryRisk(chainId, poolAddress, account),\n queryKeys.isLiquidatable(chainId, poolAddress, account),\n queryKeys.liquidationPrices(chainId, poolAddress, account),\n ]\n },\n\n /**\n * Queries to invalidate after minting collateral shares.\n */\n mint: (params: MutationEffectParams): readonly (readonly string[])[] => {\n return mutationEffects.deposit(params)\n },\n\n /**\n * Queries to invalidate after redeeming collateral shares.\n */\n redeem: (params: MutationEffectParams): readonly (readonly string[])[] => {\n return mutationEffects.withdraw(params)\n },\n\n /**\n * Queries to invalidate after approving token spending.\n */\n approve: (\n chainId: bigint,\n token: Address,\n owner: Address,\n spender: Address,\n ): readonly (readonly string[])[] => {\n return [queryKeys.approval(chainId, token, owner, spender)]\n },\n\n /**\n * Queries to invalidate after poking the oracle.\n */\n pokeOracle: (\n params: Pick<MutationEffectParams, 'chainId' | 'poolAddress'>,\n ): readonly (readonly string[])[] => {\n const { chainId, poolAddress } = params\n return [queryKeys.oracle(chainId, poolAddress), queryKeys.safeMode(chainId, poolAddress)]\n },\n} as const\n","/**\n * TanStack Query v5 mutation hooks for the Panoptic v2 SDK.\n * @module v2/react/hooks/writes\n */\n\nimport { type QueryClient, useMutation, useQueryClient } from '@tanstack/react-query'\nimport type { Address, WalletClient } from 'viem'\n\nimport {\n type ApproveParams,\n type ApprovePoolParams,\n type BorrowParams,\n type ClosePositionParams,\n type DeployNewPoolParams,\n type DepositParams,\n type DispatchParams,\n type ExecuteBatchDispatchParams,\n type ForceExerciseParams,\n type LiquidateParams,\n type MintParams,\n type OpenPositionParams,\n type PokeOracleParams,\n type RedeemParams,\n type RepayParams,\n type RollPositionParams,\n type SettleParams,\n type SmartRepayParams,\n type SupplyParams,\n type SwapExactInParams,\n type SwapExactOutParams,\n type UnsupplyParams,\n type UnwrapWethParams,\n type UnwrapXstockParams,\n type WithdrawParams,\n type WithdrawWithPositionsParams,\n type WrapEthParams,\n type WrapXstockParams,\n approve,\n approvePool,\n borrow,\n closePosition,\n deployNewPool,\n deposit,\n dispatch,\n executeBatchDispatch,\n forceExerciseAndWait,\n liquidate,\n mint,\n openPosition,\n pokeOracle,\n redeem,\n repay,\n rollPosition,\n settleAccumulatedPremia,\n smartRepay,\n supply,\n swapExactIn,\n swapExactOut,\n unsupply,\n unwrapWeth,\n unwrapXstock,\n withdraw,\n withdrawWithPositions,\n wrapEth,\n wrapXstock,\n} from '../../writes'\nimport { mutationEffects } from '../mutationEffects'\nimport { usePanopticContext } from '../provider'\nimport { queryKeys } from '../queryKeys'\n\ntype OmitInjected<T> = T extends unknown ? Omit<T, 'client' | 'walletClient' | 'account'> : never\ntype OmitInjectedWithPool<T> = Omit<T, 'client' | 'walletClient' | 'account' | 'poolAddress'>\ntype OmitInjectedWithPoolAndChain<T> = Omit<\n T,\n 'client' | 'walletClient' | 'account' | 'poolAddress' | 'chainId'\n>\n\ntype WalletInputs = {\n walletClient?: WalletClient\n account?: Address\n}\n\ntype WalletMutationContext = {\n signerAccount: Address\n}\n\nfunction requireWallet(inputs: WalletInputs): { walletClient: WalletClient; account: Address } {\n if (!inputs.walletClient || !inputs.account) {\n throw new Error('walletClient and account are required. Provide them via PanopticProvider.')\n }\n\n return {\n walletClient: inputs.walletClient,\n account: inputs.account,\n }\n}\n\nfunction createWalletMutationContext(inputs: WalletInputs): WalletMutationContext {\n return { signerAccount: requireWallet(inputs).account }\n}\n\nfunction invalidateKeys(\n queryClient: QueryClient,\n keysToInvalidate: readonly (readonly string[])[],\n): void {\n const seen = new Set<string>()\n\n for (const key of keysToInvalidate) {\n const serialized = JSON.stringify(key)\n if (seen.has(serialized)) {\n continue\n }\n\n seen.add(serialized)\n queryClient.invalidateQueries({ queryKey: key })\n }\n}\n\nexport function useApprove() {\n const { publicClient, chainId, walletClient, account } = usePanopticContext()\n const queryClient = useQueryClient()\n\n return useMutation({\n onMutate: () => createWalletMutationContext({ walletClient, account }),\n mutationFn: (params: OmitInjected<ApproveParams>) => {\n const wallet = requireWallet({ walletClient, account })\n return approve({ client: publicClient, ...wallet, ...params })\n },\n onSuccess: (_data, params, context) => {\n if (!context) {\n return\n }\n\n invalidateKeys(\n queryClient,\n mutationEffects.approve(\n chainId,\n params.tokenAddress,\n context.signerAccount,\n params.spenderAddress,\n ),\n )\n },\n })\n}\n\nexport function useApprovePool(poolAddress: Address) {\n const { publicClient, walletClient, account } = usePanopticContext()\n const queryClient = useQueryClient()\n\n return useMutation({\n onMutate: () => createWalletMutationContext({ walletClient, account }),\n mutationFn: (params: OmitInjectedWithPool<ApprovePoolParams>) => {\n const wallet = requireWallet({ walletClient, account })\n return approvePool({ client: publicClient, ...wallet, poolAddress, ...params })\n },\n onSuccess: () => {\n queryClient.invalidateQueries({ queryKey: [...queryKeys.all, 'approval'] })\n },\n })\n}\n\nexport function useDeposit(poolAddress: Address) {\n const { publicClient, chainId, walletClient, account } = usePanopticContext()\n const queryClient = useQueryClient()\n\n return useMutation({\n onMutate: () => createWalletMutationContext({ walletClient, account }),\n mutationFn: (params: OmitInjected<DepositParams>) => {\n const wallet = requireWallet({ walletClient, account })\n return deposit({ client: publicClient, ...wallet, ...params })\n },\n onSuccess: (_data, _params, context) => {\n if (!context) {\n return\n }\n\n invalidateKeys(\n queryClient,\n mutationEffects.deposit({ chainId, poolAddress, account: context.signerAccount }),\n )\n },\n })\n}\n\nexport function useWithdraw(poolAddress: Address) {\n const { publicClient, chainId, walletClient, account } = usePanopticContext()\n const queryClient = useQueryClient()\n\n return useMutation({\n onMutate: () => createWalletMutationContext({ walletClient, account }),\n mutationFn: (params: OmitInjected<WithdrawParams>) => {\n const wallet = requireWallet({ walletClient, account })\n return withdraw({ client: publicClient, ...wallet, ...params })\n },\n onSuccess: (_data, _params, context) => {\n if (!context) {\n return\n }\n\n invalidateKeys(\n queryClient,\n mutationEffects.withdraw({ chainId, poolAddress, account: context.signerAccount }),\n )\n },\n })\n}\n\n/**\n * Wrap an underlying xStock into its ERC4626 wrapper (`deposit`). Requires a\n * prior approval of the underlying to the wrapper (use {@link useApprove}).\n * Invalidates SDK queries so balances refetch.\n */\nexport function useWrapXstock() {\n const { publicClient, walletClient, account } = usePanopticContext()\n const queryClient = useQueryClient()\n\n return useMutation({\n onMutate: () => createWalletMutationContext({ walletClient, account }),\n mutationFn: (params: OmitInjected<WrapXstockParams>) => {\n const wallet = requireWallet({ walletClient, account })\n return wrapXstock({ client: publicClient, ...wallet, ...params })\n },\n onSuccess: () => {\n queryClient.invalidateQueries({ queryKey: [...queryKeys.all] })\n },\n })\n}\n\n/**\n * Unwrap wrapper shares back into the underlying xStock (`redeem`). Burns the\n * owner's own shares — no approval needed.\n */\nexport function useUnwrapXstock() {\n const { publicClient, walletClient, account } = usePanopticContext()\n const queryClient = useQueryClient()\n\n return useMutation({\n onMutate: () => createWalletMutationContext({ walletClient, account }),\n mutationFn: (params: OmitInjected<UnwrapXstockParams>) => {\n const wallet = requireWallet({ walletClient, account })\n return unwrapXstock({ client: publicClient, ...wallet, ...params })\n },\n onSuccess: () => {\n queryClient.invalidateQueries({ queryKey: [...queryKeys.all] })\n },\n })\n}\n\n/**\n * Wrap native ETH into WETH (`deposit` payable). No approval needed.\n * Invalidates SDK queries so balances refetch.\n */\nexport function useWrapEth() {\n const { publicClient, walletClient, account } = usePanopticContext()\n const queryClient = useQueryClient()\n\n return useMutation({\n onMutate: () => createWalletMutationContext({ walletClient, account }),\n mutationFn: (params: OmitInjected<WrapEthParams>) => {\n const wallet = requireWallet({ walletClient, account })\n return wrapEth({ client: publicClient, ...wallet, ...params })\n },\n onSuccess: () => {\n queryClient.invalidateQueries({ queryKey: [...queryKeys.all] })\n },\n })\n}\n\n/**\n * Unwrap WETH back into native ETH (`withdraw`). Burns the caller's own WETH —\n * no approval needed. Invalidates SDK queries so balances refetch.\n */\nexport function useUnwrapWeth() {\n const { publicClient, walletClient, account } = usePanopticContext()\n const queryClient = useQueryClient()\n\n return useMutation({\n onMutate: () => createWalletMutationContext({ walletClient, account }),\n mutationFn: (params: OmitInjected<UnwrapWethParams>) => {\n const wallet = requireWallet({ walletClient, account })\n return unwrapWeth({ client: publicClient, ...wallet, ...params })\n },\n onSuccess: () => {\n queryClient.invalidateQueries({ queryKey: [...queryKeys.all] })\n },\n })\n}\n\nexport function useMintShares(poolAddress: Address) {\n const { publicClient, chainId, walletClient, account } = usePanopticContext()\n const queryClient = useQueryClient()\n\n return useMutation({\n onMutate: () => createWalletMutationContext({ walletClient, account }),\n mutationFn: (params: OmitInjected<MintParams>) => {\n const wallet = requireWallet({ walletClient, account })\n return mint({ client: publicClient, ...wallet, ...params })\n },\n onSuccess: (_data, _params, context) => {\n if (!context) {\n return\n }\n\n invalidateKeys(\n queryClient,\n mutationEffects.mint({ chainId, poolAddress, account: context.signerAccount }),\n )\n },\n })\n}\n\nexport function useRedeem(poolAddress: Address) {\n const { publicClient, chainId, walletClient, account } = usePanopticContext()\n const queryClient = useQueryClient()\n\n return useMutation({\n onMutate: () => createWalletMutationContext({ walletClient, account }),\n mutationFn: (params: OmitInjected<RedeemParams>) => {\n const wallet = requireWallet({ walletClient, account })\n return redeem({ client: publicClient, ...wallet, ...params })\n },\n onSuccess: (_data, _params, context) => {\n if (!context) {\n return\n }\n\n invalidateKeys(\n queryClient,\n mutationEffects.redeem({ chainId, poolAddress, account: context.signerAccount }),\n )\n },\n })\n}\n\nexport function useWithdrawWithPositions(poolAddress: Address) {\n const { publicClient, chainId, walletClient, account } = usePanopticContext()\n const queryClient = useQueryClient()\n\n return useMutation({\n onMutate: () => createWalletMutationContext({ walletClient, account }),\n mutationFn: (params: OmitInjected<WithdrawWithPositionsParams>) => {\n const wallet = requireWallet({ walletClient, account })\n return withdrawWithPositions({ client: publicClient, ...wallet, ...params })\n },\n onSuccess: (_data, _params, context) => {\n if (!context) {\n return\n }\n\n invalidateKeys(\n queryClient,\n mutationEffects.withdraw({ chainId, poolAddress, account: context.signerAccount }),\n )\n },\n })\n}\n\nexport function useOpenPosition(poolAddress: Address) {\n const { publicClient, chainId, walletClient, account } = usePanopticContext()\n const queryClient = useQueryClient()\n\n return useMutation({\n onMutate: () => createWalletMutationContext({ walletClient, account }),\n mutationFn: (params: OmitInjectedWithPool<OpenPositionParams>) => {\n const wallet = requireWallet({ walletClient, account })\n return openPosition({ client: publicClient, ...wallet, poolAddress, ...params })\n },\n onSuccess: (_data, _params, context) => {\n if (!context) {\n return\n }\n\n invalidateKeys(\n queryClient,\n mutationEffects.openPosition({ chainId, poolAddress, account: context.signerAccount }),\n )\n },\n })\n}\n\nexport function useClosePosition(poolAddress: Address) {\n const { publicClient, chainId, walletClient, account } = usePanopticContext()\n const queryClient = useQueryClient()\n\n return useMutation({\n onMutate: () => createWalletMutationContext({ walletClient, account }),\n mutationFn: (params: OmitInjectedWithPool<ClosePositionParams>) => {\n const wallet = requireWallet({ walletClient, account })\n return closePosition({ client: publicClient, ...wallet, poolAddress, ...params })\n },\n onSuccess: (_data, params, context) => {\n if (!context) {\n return\n }\n\n invalidateKeys(\n queryClient,\n mutationEffects.closePosition({\n chainId,\n poolAddress,\n account: context.signerAccount,\n tokenId: params.tokenId,\n }),\n )\n },\n })\n}\n\nexport function useRollPosition(poolAddress: Address) {\n const { publicClient, chainId, walletClient, account } = usePanopticContext()\n const queryClient = useQueryClient()\n\n return useMutation({\n onMutate: () => createWalletMutationContext({ walletClient, account }),\n mutationFn: (params: OmitInjectedWithPool<RollPositionParams>) => {\n const wallet = requireWallet({ walletClient, account })\n return rollPosition({ client: publicClient, ...wallet, poolAddress, ...params })\n },\n onSuccess: (_data, _params, context) => {\n if (!context) {\n return\n }\n\n invalidateKeys(\n queryClient,\n mutationEffects.openPosition({ chainId, poolAddress, account: context.signerAccount }),\n )\n },\n })\n}\n\nexport function useLiquidate(poolAddress: Address) {\n const { publicClient, chainId, walletClient, account } = usePanopticContext()\n const queryClient = useQueryClient()\n\n return useMutation({\n onMutate: () => createWalletMutationContext({ walletClient, account }),\n mutationFn: (params: OmitInjectedWithPool<LiquidateParams>) => {\n const wallet = requireWallet({ walletClient, account })\n return liquidate({ client: publicClient, ...wallet, poolAddress, ...params })\n },\n onSuccess: (_data, params, context) => {\n if (!context) {\n return\n }\n\n invalidateKeys(queryClient, [\n ...mutationEffects.liquidate({ chainId, poolAddress, account: context.signerAccount }),\n ...mutationEffects.liquidate({ chainId, poolAddress, account: params.liquidatee }),\n ])\n },\n })\n}\n\nexport function useForceExercise(poolAddress: Address) {\n const { publicClient, chainId, walletClient, account, storage } = usePanopticContext()\n const queryClient = useQueryClient()\n\n return useMutation({\n onMutate: () => createWalletMutationContext({ walletClient, account }),\n mutationFn: (\n params: Omit<\n ForceExerciseParams,\n 'client' | 'walletClient' | 'account' | 'poolAddress' | 'chainId' | 'storage'\n >,\n ) => {\n const wallet = requireWallet({ walletClient, account })\n return forceExerciseAndWait({\n client: publicClient,\n ...wallet,\n poolAddress,\n ...params,\n storage,\n chainId,\n })\n },\n onSuccess: (_data, params, context) => {\n if (!context) {\n return\n }\n\n invalidateKeys(queryClient, [\n ...mutationEffects.forceExercise({ chainId, poolAddress, account: context.signerAccount }),\n ...mutationEffects.forceExercise({ chainId, poolAddress, account: params.user }),\n ])\n },\n })\n}\n\nexport function useSettleAccumulatedPremia(poolAddress: Address) {\n const { publicClient, chainId, walletClient, account } = usePanopticContext()\n const queryClient = useQueryClient()\n\n return useMutation({\n onMutate: () => createWalletMutationContext({ walletClient, account }),\n mutationFn: (params: OmitInjectedWithPool<SettleParams>) => {\n const wallet = requireWallet({ walletClient, account })\n return settleAccumulatedPremia({ client: publicClient, ...wallet, poolAddress, ...params })\n },\n onSuccess: (_data, _params, context) => {\n if (!context) {\n return\n }\n\n invalidateKeys(\n queryClient,\n mutationEffects.settleAccumulatedPremia({\n chainId,\n poolAddress,\n account: context.signerAccount,\n }),\n )\n },\n })\n}\n\nexport function usePokeOracle(poolAddress: Address) {\n const { publicClient, chainId, walletClient, account } = usePanopticContext()\n const queryClient = useQueryClient()\n\n return useMutation({\n onMutate: () => createWalletMutationContext({ walletClient, account }),\n mutationFn: (params?: OmitInjectedWithPool<PokeOracleParams>) => {\n const wallet = requireWallet({ walletClient, account })\n return pokeOracle({ client: publicClient, ...wallet, poolAddress, ...params })\n },\n onSuccess: () => {\n invalidateKeys(queryClient, mutationEffects.pokeOracle({ chainId, poolAddress }))\n },\n })\n}\n\nexport function useDispatch(poolAddress: Address) {\n const { publicClient, chainId, walletClient, account } = usePanopticContext()\n const queryClient = useQueryClient()\n\n return useMutation({\n onMutate: () => createWalletMutationContext({ walletClient, account }),\n mutationFn: (params: OmitInjectedWithPool<DispatchParams>) => {\n const wallet = requireWallet({ walletClient, account })\n return dispatch({ client: publicClient, ...wallet, poolAddress, ...params })\n },\n onSuccess: (_data, _params, context) => {\n if (!context) {\n return\n }\n\n invalidateKeys(\n queryClient,\n mutationEffects.openPosition({ chainId, poolAddress, account: context.signerAccount }),\n )\n },\n })\n}\n\nexport function useBatchDispatch(poolAddress: Address) {\n const { publicClient, chainId, walletClient, account } = usePanopticContext()\n const queryClient = useQueryClient()\n\n return useMutation({\n onMutate: () => createWalletMutationContext({ walletClient, account }),\n mutationFn: (params: OmitInjectedWithPool<ExecuteBatchDispatchParams>) => {\n const wallet = requireWallet({ walletClient, account })\n return executeBatchDispatch({ client: publicClient, ...wallet, poolAddress, ...params })\n },\n onSuccess: (_data, params, context) => {\n if (!context) {\n return\n }\n\n const closedTokenIds = params.items.filter((i) => i.kind === 'burn').map((i) => i.tokenId)\n\n const keys = [\n ...mutationEffects.openPosition({\n chainId,\n poolAddress,\n account: context.signerAccount,\n }),\n ...closedTokenIds.flatMap((tokenId) =>\n mutationEffects.closePosition({\n chainId,\n poolAddress,\n account: context.signerAccount,\n tokenId,\n }),\n ),\n ]\n invalidateKeys(queryClient, keys)\n },\n })\n}\n\nexport function useDeployNewPool() {\n const { publicClient, walletClient, account } = usePanopticContext()\n const queryClient = useQueryClient()\n\n return useMutation({\n onMutate: () => createWalletMutationContext({ walletClient, account }),\n mutationFn: (params: OmitInjected<DeployNewPoolParams>) => {\n const wallet = requireWallet({ walletClient, account })\n return deployNewPool({ client: publicClient, ...wallet, ...params })\n },\n onSuccess: () => {\n queryClient.invalidateQueries({ queryKey: [...queryKeys.all, 'factory'] })\n },\n })\n}\n\nexport function useSwapExactOut(poolAddress: Address) {\n const { publicClient, chainId, walletClient, account } = usePanopticContext()\n const queryClient = useQueryClient()\n\n return useMutation({\n onMutate: () => createWalletMutationContext({ walletClient, account }),\n mutationFn: (params: OmitInjectedWithPoolAndChain<SwapExactOutParams>) => {\n const wallet = requireWallet({ walletClient, account })\n return swapExactOut({ client: publicClient, ...wallet, poolAddress, chainId, ...params })\n },\n onSuccess: (_data, _params, context) => {\n if (!context) return\n invalidateKeys(\n queryClient,\n mutationEffects.deposit({ chainId, poolAddress, account: context.signerAccount }),\n )\n },\n })\n}\n\nexport function useSupply(poolAddress: Address) {\n const { publicClient, chainId, walletClient, account } = usePanopticContext()\n const queryClient = useQueryClient()\n\n return useMutation({\n onMutate: () => createWalletMutationContext({ walletClient, account }),\n mutationFn: (params: OmitInjectedWithPoolAndChain<SupplyParams>) => {\n const wallet = requireWallet({ walletClient, account })\n return supply({ client: publicClient, ...wallet, poolAddress, chainId, ...params })\n },\n onSuccess: (_data, _params, context) => {\n if (!context) return\n invalidateKeys(\n queryClient,\n mutationEffects.deposit({ chainId, poolAddress, account: context.signerAccount }),\n )\n },\n })\n}\n\nexport function useUnsupply(poolAddress: Address) {\n const { publicClient, chainId, walletClient, account } = usePanopticContext()\n const queryClient = useQueryClient()\n\n return useMutation({\n onMutate: () => createWalletMutationContext({ walletClient, account }),\n mutationFn: (params: OmitInjectedWithPoolAndChain<UnsupplyParams>) => {\n const wallet = requireWallet({ walletClient, account })\n return unsupply({ client: publicClient, ...wallet, poolAddress, chainId, ...params })\n },\n onSuccess: (_data, _params, context) => {\n if (!context) return\n invalidateKeys(\n queryClient,\n mutationEffects.withdraw({ chainId, poolAddress, account: context.signerAccount }),\n )\n },\n })\n}\n\nexport function useBorrow(poolAddress: Address) {\n const { publicClient, chainId, walletClient, account } = usePanopticContext()\n const queryClient = useQueryClient()\n\n return useMutation({\n onMutate: () => createWalletMutationContext({ walletClient, account }),\n mutationFn: (params: OmitInjectedWithPoolAndChain<BorrowParams>) => {\n const wallet = requireWallet({ walletClient, account })\n return borrow({ client: publicClient, ...wallet, poolAddress, chainId, ...params })\n },\n onSuccess: (_data, _params, context) => {\n if (!context) return\n invalidateKeys(\n queryClient,\n mutationEffects.openPosition({ chainId, poolAddress, account: context.signerAccount }),\n )\n },\n })\n}\n\nexport function useRepay(poolAddress: Address) {\n const { publicClient, chainId, walletClient, account } = usePanopticContext()\n const queryClient = useQueryClient()\n\n return useMutation({\n onMutate: () => createWalletMutationContext({ walletClient, account }),\n mutationFn: (params: OmitInjectedWithPoolAndChain<RepayParams>) => {\n const wallet = requireWallet({ walletClient, account })\n return repay({ client: publicClient, ...wallet, poolAddress, chainId, ...params })\n },\n onSuccess: (_data, params, context) => {\n if (!context) return\n invalidateKeys(\n queryClient,\n mutationEffects.closePosition({\n chainId,\n poolAddress,\n account: context.signerAccount,\n tokenId: params.loanTokenId,\n }),\n )\n },\n })\n}\n\nexport function useSmartRepay(poolAddress: Address) {\n const { publicClient, chainId, walletClient, account } = usePanopticContext()\n const queryClient = useQueryClient()\n\n return useMutation({\n onMutate: () => createWalletMutationContext({ walletClient, account }),\n mutationFn: (params: OmitInjectedWithPoolAndChain<SmartRepayParams>) => {\n const wallet = requireWallet({ walletClient, account })\n return smartRepay({ client: publicClient, ...wallet, poolAddress, chainId, ...params })\n },\n onSuccess: (_data, _params, context) => {\n if (!context) return\n invalidateKeys(\n queryClient,\n mutationEffects.closePosition({\n chainId,\n poolAddress,\n account: context.signerAccount,\n }),\n )\n },\n })\n}\n\nexport function useSwapExactIn(poolAddress: Address) {\n const { publicClient, chainId, walletClient, account } = usePanopticContext()\n const queryClient = useQueryClient()\n\n return useMutation({\n onMutate: () => createWalletMutationContext({ walletClient, account }),\n mutationFn: (params: OmitInjectedWithPoolAndChain<SwapExactInParams>) => {\n const wallet = requireWallet({ walletClient, account })\n return swapExactIn({ client: publicClient, ...wallet, poolAddress, chainId, ...params })\n },\n onSuccess: (_data, _params, context) => {\n if (!context) return\n invalidateKeys(\n queryClient,\n mutationEffects.deposit({ chainId, poolAddress, account: context.signerAccount }),\n )\n },\n })\n}\n","/**\n * TanStack Query v5 simulation hooks for the Panoptic v2 SDK.\n * @module v2/react/hooks/simulations\n */\n\nimport { useQuery } from '@tanstack/react-query'\nimport type { Address } from 'viem'\n\nimport {\n type SimulateBatchDispatchParams,\n type SimulateClosePositionParams,\n type SimulateDepositParams,\n type SimulateDispatchParams,\n type SimulateForceExerciseParams,\n type SimulateLiquidateParams,\n type SimulateOpenPositionParams,\n type SimulateSettleParams,\n type SimulateSFPMParams,\n type SimulateSwapExactInParams,\n type SimulateSwapExactOutParams,\n type SimulateWithdrawParams,\n simulateBatchDispatch,\n simulateClosePosition,\n simulateDeposit,\n simulateDispatch,\n simulateForceExercise,\n simulateLiquidate,\n simulateOpenPosition,\n simulateSettle,\n simulateSFPMBurn,\n simulateSFPMMint,\n simulateSwapExactIn,\n simulateSwapExactOut,\n simulateWithdraw,\n} from '../../simulations'\nimport { getClientCacheScopeKey } from '../cacheScopes'\nimport { usePanopticContext } from '../provider'\nimport { queryKeys } from '../queryKeys'\n\ntype OmitClient<T> = Omit<T, 'client'>\ntype OmitClientAndPool<T> = Omit<T, 'client' | 'poolAddress'>\n\nexport function useSimulateOpenPosition(\n poolAddress: Address,\n params?: OmitClientAndPool<SimulateOpenPositionParams>,\n) {\n const { publicClient, clientScope } = usePanopticContext()\n return useQuery({\n queryKey: [\n ...queryKeys.all,\n 'sim',\n 'openPosition',\n poolAddress,\n params?.tokenId?.toString(),\n getClientCacheScopeKey(publicClient, clientScope),\n params,\n ] as const,\n queryFn: () => simulateOpenPosition({ client: publicClient, poolAddress, ...params! }),\n enabled: params !== undefined,\n staleTime: 0,\n })\n}\n\nexport function useSimulateClosePosition(\n poolAddress: Address,\n params?: OmitClientAndPool<SimulateClosePositionParams>,\n) {\n const { publicClient, clientScope } = usePanopticContext()\n return useQuery({\n queryKey: [\n ...queryKeys.all,\n 'sim',\n 'closePosition',\n poolAddress,\n params?.tokenId?.toString(),\n getClientCacheScopeKey(publicClient, clientScope),\n params,\n ] as const,\n queryFn: () => simulateClosePosition({ client: publicClient, poolAddress, ...params! }),\n enabled: params !== undefined,\n staleTime: 0,\n })\n}\n\nexport function useSimulateDeposit(params?: OmitClient<SimulateDepositParams>) {\n const { publicClient, clientScope } = usePanopticContext()\n return useQuery({\n queryKey: [\n ...queryKeys.all,\n 'sim',\n 'deposit',\n params?.collateralTrackerAddress,\n params?.assets?.toString(),\n getClientCacheScopeKey(publicClient, clientScope),\n params,\n ] as const,\n queryFn: () => simulateDeposit({ client: publicClient, ...params! }),\n enabled: params !== undefined,\n staleTime: 0,\n })\n}\n\nexport function useSimulateWithdraw(params?: OmitClient<SimulateWithdrawParams>) {\n const { publicClient, clientScope } = usePanopticContext()\n return useQuery({\n queryKey: [\n ...queryKeys.all,\n 'sim',\n 'withdraw',\n params?.collateralTrackerAddress,\n params?.assets?.toString(),\n getClientCacheScopeKey(publicClient, clientScope),\n params,\n ] as const,\n queryFn: () => simulateWithdraw({ client: publicClient, ...params! }),\n enabled: params !== undefined,\n staleTime: 0,\n })\n}\n\nexport function useSimulateLiquidate(\n poolAddress: Address,\n params?: OmitClientAndPool<SimulateLiquidateParams>,\n) {\n const { publicClient, clientScope } = usePanopticContext()\n return useQuery({\n queryKey: [\n ...queryKeys.all,\n 'sim',\n 'liquidate',\n poolAddress,\n params?.liquidatee,\n getClientCacheScopeKey(publicClient, clientScope),\n params,\n ] as const,\n queryFn: () => simulateLiquidate({ client: publicClient, poolAddress, ...params! }),\n enabled: params !== undefined,\n staleTime: 0,\n })\n}\n\nexport function useSimulateForceExercise(\n poolAddress: Address,\n params?: OmitClientAndPool<SimulateForceExerciseParams>,\n) {\n const { publicClient, clientScope } = usePanopticContext()\n return useQuery({\n queryKey: [\n ...queryKeys.all,\n 'sim',\n 'forceExercise',\n poolAddress,\n params?.user,\n getClientCacheScopeKey(publicClient, clientScope),\n params,\n ] as const,\n queryFn: () => simulateForceExercise({ client: publicClient, poolAddress, ...params! }),\n enabled: params !== undefined,\n staleTime: 0,\n })\n}\n\nexport function useSimulateSettle(\n poolAddress: Address,\n params?: OmitClientAndPool<SimulateSettleParams>,\n) {\n const { publicClient, clientScope } = usePanopticContext()\n return useQuery({\n queryKey: [\n ...queryKeys.all,\n 'sim',\n 'settle',\n poolAddress,\n params?.account,\n getClientCacheScopeKey(publicClient, clientScope),\n params,\n ] as const,\n queryFn: () => simulateSettle({ client: publicClient, poolAddress, ...params! }),\n enabled: params !== undefined,\n staleTime: 0,\n })\n}\n\nexport function useSimulateBatchDispatch(\n poolAddress: Address,\n params?: OmitClientAndPool<SimulateBatchDispatchParams>,\n) {\n const { publicClient, clientScope } = usePanopticContext()\n return useQuery({\n queryKey: [\n ...queryKeys.all,\n 'sim',\n 'batchDispatch',\n poolAddress,\n params?.account,\n params?.items?.length,\n JSON.stringify(params?.items?.map((i) => `${i.kind}:${i.tokenId.toString()}`)),\n JSON.stringify(params?.existingPositionIds?.map(String)),\n getClientCacheScopeKey(publicClient, clientScope),\n params,\n ] as const,\n queryFn: () => simulateBatchDispatch({ client: publicClient, poolAddress, ...params! }),\n enabled: params !== undefined && params.items !== undefined,\n staleTime: 0,\n })\n}\n\nexport function useSimulateDispatch(\n poolAddress: Address,\n params?: OmitClientAndPool<SimulateDispatchParams>,\n) {\n const { publicClient, clientScope } = usePanopticContext()\n return useQuery({\n queryKey: [\n ...queryKeys.all,\n 'sim',\n 'dispatch',\n poolAddress,\n JSON.stringify(params?.positionIdList?.map(String)),\n getClientCacheScopeKey(publicClient, clientScope),\n params,\n ] as const,\n queryFn: () => simulateDispatch({ client: publicClient, poolAddress, ...params! }),\n enabled: params !== undefined,\n staleTime: 0,\n })\n}\n\nexport function useSimulateSFPMMint(params?: OmitClient<SimulateSFPMParams>) {\n const { publicClient, clientScope } = usePanopticContext()\n return useQuery({\n queryKey: [\n ...queryKeys.all,\n 'sim',\n 'sfpmMint',\n params?.sfpmAddress,\n params?.tokenId?.toString(),\n getClientCacheScopeKey(publicClient, clientScope),\n params,\n ] as const,\n queryFn: () => {\n if (!params) throw new Error('params required for simulateSFPMMint')\n return simulateSFPMMint({ client: publicClient, ...params })\n },\n enabled: params !== undefined,\n staleTime: 0,\n })\n}\n\nexport function useSimulateSFPMBurn(params?: OmitClient<SimulateSFPMParams>) {\n const { publicClient, clientScope } = usePanopticContext()\n return useQuery({\n queryKey: [\n ...queryKeys.all,\n 'sim',\n 'sfpmBurn',\n params?.sfpmAddress,\n params?.tokenId?.toString(),\n getClientCacheScopeKey(publicClient, clientScope),\n params,\n ] as const,\n queryFn: () => {\n if (!params) throw new Error('params required for simulateSFPMBurn')\n return simulateSFPMBurn({ client: publicClient, ...params })\n },\n enabled: params !== undefined,\n staleTime: 0,\n })\n}\n\nexport function useSimulateSwapExactOut(\n poolAddress: Address,\n params?: OmitClientAndPool<SimulateSwapExactOutParams>,\n) {\n const { publicClient, clientScope } = usePanopticContext()\n return useQuery({\n queryKey: [\n ...queryKeys.all,\n 'sim',\n 'swapExactOut',\n poolAddress,\n params?.tokenOut,\n params?.amountOut?.toString(),\n getClientCacheScopeKey(publicClient, clientScope),\n params,\n ] as const,\n queryFn: () => simulateSwapExactOut({ client: publicClient, poolAddress, ...params! }),\n enabled: params !== undefined,\n staleTime: 0,\n })\n}\n\nexport function useSimulateSwapExactIn(\n poolAddress: Address,\n params?: OmitClientAndPool<SimulateSwapExactInParams>,\n) {\n const { publicClient, clientScope } = usePanopticContext()\n return useQuery({\n queryKey: [\n ...queryKeys.all,\n 'sim',\n 'swapExactIn',\n poolAddress,\n params?.tokenIn,\n params?.amountIn?.toString(),\n getClientCacheScopeKey(publicClient, clientScope),\n params,\n ] as const,\n queryFn: () => simulateSwapExactIn({ client: publicClient, poolAddress, ...params! }),\n enabled: params !== undefined,\n staleTime: 0,\n })\n}\n","/**\n * TanStack Query v5 hooks for the Uniswap v4 Universal Router swap path.\n *\n * Mirrors the writes/simulations hook ergonomics (usePanopticContext injection,\n * OmitInjected* params, cache invalidation) but targets the generic Uniswap v4\n * router functions in `src/uniswap`.\n *\n * @module v2/react/hooks/uniswapRouter\n */\n\nimport { useMutation, useQuery, useQueryClient } from '@tanstack/react-query'\nimport type { Address, WalletClient } from 'viem'\n\nimport {\n type ApproveErc20ForPermit2Params,\n type ApproveRouterViaPermit2Params,\n type CheckRouterApprovalParams,\n type QuoteSwapExactInViaRouterParams,\n type QuoteSwapExactOutViaRouterParams,\n type SwapExactInViaRouterParams,\n type SwapExactOutViaRouterParams,\n approveErc20ForPermit2,\n approveRouterViaPermit2,\n checkRouterApproval,\n quoteSwapExactInViaRouter,\n quoteSwapExactOutViaRouter,\n swapExactInViaRouter,\n swapExactOutViaRouter,\n} from '../../../../uniswap/v4/router'\nimport { PanopticError } from '../../errors'\nimport { getClientCacheScopeKey } from '../cacheScopes'\nimport { mutationEffects } from '../mutationEffects'\nimport { usePanopticContext } from '../provider'\nimport { queryKeys } from '../queryKeys'\n\ntype OmitInjectedWithPoolAndChain<T> = Omit<\n T,\n 'client' | 'walletClient' | 'account' | 'poolAddress' | 'chainId'\n>\ntype OmitInjectedWithChain<T> = Omit<T, 'client' | 'walletClient' | 'account' | 'chainId'>\ntype OmitClientPoolAndChain<T> = Omit<T, 'client' | 'poolAddress' | 'chainId'>\n\nfunction requireWallet(walletClient?: WalletClient, account?: Address) {\n if (!walletClient || !account) {\n throw new PanopticError(\n 'walletClient and account are required. Provide them via PanopticProvider.',\n )\n }\n return { walletClient, account }\n}\n\n/**\n * Quote an exact-in spot swap via the Universal Router (V4Quoter-backed).\n * Returns a `SimulationResult`, matching `useSimulateSwapExactIn`'s shape.\n */\nexport function useQuoteSwapExactInViaRouter(\n poolAddress: Address,\n params?: OmitClientPoolAndChain<QuoteSwapExactInViaRouterParams>,\n) {\n const { publicClient, chainId, clientScope } = usePanopticContext()\n return useQuery({\n // Raw `params` carries bigints that break TanStack v5's JSON key hashing; the\n // stringified scalars below fully capture the query identity.\n // eslint-disable-next-line @tanstack/query/exhaustive-deps\n queryKey: [\n ...queryKeys.all,\n 'uniswapRouter',\n 'quote',\n chainId,\n poolAddress,\n params?.tokenIn,\n params?.amountIn?.toString(),\n params?.slippageBps?.toString(),\n getClientCacheScopeKey(publicClient, clientScope),\n ] as const,\n queryFn: () =>\n quoteSwapExactInViaRouter({\n client: publicClient,\n poolAddress,\n chainId,\n ...params!,\n }),\n enabled: params !== undefined,\n staleTime: 0,\n })\n}\n\n/**\n * Quote an exact-out spot swap via the Universal Router (V4Quoter-backed).\n * Returns a `SimulationResult` carrying the required input + `amountInMaximum`.\n */\nexport function useQuoteSwapExactOutViaRouter(\n poolAddress: Address,\n params?: OmitClientPoolAndChain<QuoteSwapExactOutViaRouterParams>,\n) {\n const { publicClient, chainId, clientScope } = usePanopticContext()\n return useQuery({\n // Raw `params` carries bigints that break TanStack v5's JSON key hashing; the\n // stringified scalars below fully capture the query identity.\n // eslint-disable-next-line @tanstack/query/exhaustive-deps\n queryKey: [\n ...queryKeys.all,\n 'uniswapRouter',\n 'quoteExactOut',\n chainId,\n poolAddress,\n params?.tokenIn,\n params?.amountOut?.toString(),\n params?.slippageBps?.toString(),\n getClientCacheScopeKey(publicClient, clientScope),\n ] as const,\n queryFn: () =>\n quoteSwapExactOutViaRouter({\n client: publicClient,\n poolAddress,\n chainId,\n ...params!,\n }),\n enabled: params !== undefined,\n staleTime: 0,\n })\n}\n\n/**\n * Check the ERC20 → Permit2 → Universal Router allowance chain.\n */\nexport function useCheckRouterApproval(params?: OmitInjectedWithChain<CheckRouterApprovalParams>) {\n const { publicClient, chainId, clientScope } = usePanopticContext()\n return useQuery({\n // Raw `params` carries bigints that break TanStack v5's JSON key hashing; the\n // stringified scalars below fully capture the query identity.\n // eslint-disable-next-line @tanstack/query/exhaustive-deps\n queryKey: [\n ...queryKeys.all,\n 'uniswapRouter',\n 'approval',\n chainId,\n params?.tokenIn,\n params?.owner,\n params?.amount?.toString(),\n getClientCacheScopeKey(publicClient, clientScope),\n ] as const,\n queryFn: () => checkRouterApproval({ client: publicClient, chainId, ...params! }),\n enabled: params !== undefined,\n staleTime: 0,\n })\n}\n\n/**\n * Execute an exact-in spot swap via the Universal Router.\n */\nexport function useSwapExactInViaRouter(poolAddress: Address) {\n const { publicClient, chainId, walletClient, account } = usePanopticContext()\n const queryClient = useQueryClient()\n\n return useMutation({\n mutationFn: (params: OmitInjectedWithPoolAndChain<SwapExactInViaRouterParams>) => {\n const wallet = requireWallet(walletClient, account)\n return swapExactInViaRouter({\n client: publicClient,\n ...wallet,\n poolAddress,\n chainId,\n ...params,\n })\n },\n onSuccess: () => {\n if (!account) return\n for (const key of mutationEffects.deposit({ chainId, poolAddress, account })) {\n queryClient.invalidateQueries({ queryKey: key })\n }\n },\n })\n}\n\n/**\n * Execute an exact-out spot swap via the Universal Router.\n */\nexport function useSwapExactOutViaRouter(poolAddress: Address) {\n const { publicClient, chainId, walletClient, account } = usePanopticContext()\n const queryClient = useQueryClient()\n\n return useMutation({\n mutationFn: (params: OmitInjectedWithPoolAndChain<SwapExactOutViaRouterParams>) => {\n const wallet = requireWallet(walletClient, account)\n return swapExactOutViaRouter({\n client: publicClient,\n ...wallet,\n poolAddress,\n chainId,\n ...params,\n })\n },\n onSuccess: () => {\n if (!account) return\n for (const key of mutationEffects.deposit({ chainId, poolAddress, account })) {\n queryClient.invalidateQueries({ queryKey: key })\n }\n },\n })\n}\n\n/**\n * Step 1 approval mutation: ERC20 → Permit2.\n */\nexport function useApproveErc20ForPermit2() {\n const { publicClient, chainId, walletClient, account } = usePanopticContext()\n return useMutation({\n mutationFn: (params: OmitInjectedWithChain<ApproveErc20ForPermit2Params>) => {\n const wallet = requireWallet(walletClient, account)\n return approveErc20ForPermit2({ client: publicClient, ...wallet, chainId, ...params })\n },\n })\n}\n\n/**\n * Step 2 approval mutation: Permit2 → Universal Router.\n */\nexport function useApproveRouterViaPermit2() {\n const { publicClient, chainId, walletClient, account } = usePanopticContext()\n return useMutation({\n mutationFn: (params: OmitInjectedWithChain<ApproveRouterViaPermit2Params>) => {\n const wallet = requireWallet(walletClient, account)\n return approveRouterViaPermit2({ client: publicClient, ...wallet, chainId, ...params })\n },\n })\n}\n","/**\n * TanStack Query v5 hooks for the CoW Protocol swap path.\n *\n * Mirrors the Universal Router hooks (usePanopticContext injection,\n * OmitInjected* params) but targets the order-book functions in `src/cow`.\n * Orders settle asynchronously: submission returns an order UID, and\n * `useCowOrderStatus` polls until the order reaches a terminal state.\n *\n * @module v2/react/hooks/cowSwap\n */\n\nimport { useMutation, useQuery, useQueryClient } from '@tanstack/react-query'\nimport type { Address, Hex, WalletClient } from 'viem'\n\nimport {\n type ApproveErc20ForCowParams,\n type CancelCowOrderParams,\n type CheckCowApprovalParams,\n type QuoteCowSwapParams,\n type SignAndSubmitCowOrderParams,\n approveErc20ForCow,\n cancelCowOrder,\n checkCowApproval,\n getCowOrderStatus,\n isCowSupportedChain,\n quoteCowSwap,\n signAndSubmitCowOrder,\n} from '../../../../cow'\nimport { PanopticError } from '../../errors'\nimport { getClientCacheScopeKey } from '../cacheScopes'\nimport { usePanopticContext } from '../provider'\nimport { queryKeys } from '../queryKeys'\n\ntype OmitChainAndFrom<T> = Omit<T, 'chainId' | 'from'>\ntype OmitInjectedWithChain<T> = Omit<T, 'client' | 'walletClient' | 'account' | 'chainId'>\ntype OmitClientOnly<T> = Omit<T, 'client'>\n\nfunction requireWallet(walletClient?: WalletClient, account?: Address) {\n if (!walletClient || !account) {\n throw new PanopticError(\n 'walletClient and account are required. Provide them via PanopticProvider.',\n )\n }\n return { walletClient, account }\n}\n\n/** How often open-order status is re-polled (ms). */\nconst ORDER_POLL_INTERVAL_MS = 5_000\n/** How often quotes refresh (ms) — CoW quotes go stale quickly. */\nconst QUOTE_REFETCH_INTERVAL_MS = 15_000\n\n/**\n * Placeholder order owner for quotes when no wallet is connected — the order\n * book accepts any non-zero `from` for quoting (verification happens at order\n * submission, which always uses the real account).\n */\nconst QUOTE_STUB_FROM = '0x0000000000000000000000000000000000000001' as const\n\n/**\n * Quote a swap via the CoW order book. The connected account (or a stub when\n * disconnected) is used as the order owner (`from`); disabled while the chain\n * has no order book.\n */\nexport function useQuoteCowSwap(params?: OmitChainAndFrom<QuoteCowSwapParams>) {\n const { publicClient, chainId, account, clientScope } = usePanopticContext()\n return useQuery({\n // Raw `params` carries bigints that break TanStack v5's JSON key hashing; the\n // stringified scalars below fully capture the query identity.\n // eslint-disable-next-line @tanstack/query/exhaustive-deps\n queryKey: [\n ...queryKeys.all,\n 'cowSwap',\n 'quote',\n chainId,\n params?.sellToken,\n params?.buyToken,\n params?.kind,\n params?.amount?.toString(),\n params?.slippageBps?.toString(),\n account,\n getClientCacheScopeKey(publicClient, clientScope),\n ] as const,\n queryFn: () => quoteCowSwap({ chainId, from: account ?? QUOTE_STUB_FROM, ...params! }),\n enabled: params !== undefined && isCowSupportedChain(chainId),\n staleTime: 0,\n refetchInterval: QUOTE_REFETCH_INTERVAL_MS,\n })\n}\n\n/** Check the ERC20 → GPv2VaultRelayer allowance for the sell token. */\nexport function useCheckCowApproval(params?: OmitClientOnly<CheckCowApprovalParams>) {\n const { publicClient, chainId, clientScope } = usePanopticContext()\n return useQuery({\n // Raw `params` carries bigints that break TanStack v5's JSON key hashing; the\n // stringified scalars below fully capture the query identity.\n // eslint-disable-next-line @tanstack/query/exhaustive-deps\n queryKey: [\n ...queryKeys.all,\n 'cowSwap',\n 'approval',\n chainId,\n params?.sellToken,\n params?.owner,\n params?.amount?.toString(),\n getClientCacheScopeKey(publicClient, clientScope),\n ] as const,\n queryFn: () => checkCowApproval({ client: publicClient, ...params! }),\n enabled: params !== undefined,\n staleTime: 0,\n })\n}\n\n/** Approval mutation: ERC20 → GPv2VaultRelayer (single step, no Permit2). */\nexport function useApproveErc20ForCow() {\n const { publicClient, walletClient, account } = usePanopticContext()\n const queryClient = useQueryClient()\n return useMutation({\n mutationFn: (params: OmitInjectedWithChain<ApproveErc20ForCowParams>) => {\n const wallet = requireWallet(walletClient, account)\n return approveErc20ForCow({ client: publicClient, ...wallet, ...params })\n },\n // Refresh the cached allowance read (useCheckCowApproval) so the swap CTA\n // advances past \"Approve\" once the approval confirms.\n onSuccess: () => {\n void queryClient.invalidateQueries({ queryKey: [...queryKeys.all, 'cowSwap', 'approval'] })\n },\n })\n}\n\n/**\n * Sign an order (EIP-712) and post it to the order book. Resolves with the\n * order UID — not a tx hash; settlement is asynchronous.\n */\nexport function useSubmitCowOrder() {\n const { chainId, walletClient, account } = usePanopticContext()\n return useMutation({\n mutationFn: (\n params: Omit<SignAndSubmitCowOrderParams, 'walletClient' | 'account' | 'chainId'>,\n ) => {\n const wallet = requireWallet(walletClient, account)\n return signAndSubmitCowOrder({ ...wallet, chainId, ...params })\n },\n })\n}\n\n/**\n * Poll an order's lifecycle state every few seconds while it is open; polling\n * stops automatically once the order reaches a terminal state.\n */\nexport function useCowOrderStatus(orderUid?: Hex) {\n const { chainId } = usePanopticContext()\n return useQuery({\n queryKey: [...queryKeys.all, 'cowSwap', 'orderStatus', chainId, orderUid] as const,\n queryFn: () => getCowOrderStatus({ chainId, orderUid: orderUid! }),\n enabled: orderUid !== undefined,\n refetchInterval: (query) => {\n const status = query.state.data?.status\n return status === undefined || status === 'open' || status === 'presignaturePending'\n ? ORDER_POLL_INTERVAL_MS\n : false\n },\n })\n}\n\n/** Off-chain (signed, free) order cancellation mutation. */\nexport function useCancelCowOrder() {\n const { chainId, walletClient, account } = usePanopticContext()\n return useMutation({\n mutationFn: (params: Omit<CancelCowOrderParams, 'walletClient' | 'account' | 'chainId'>) => {\n const wallet = requireWallet(walletClient, account)\n return cancelCowOrder({ ...wallet, chainId, ...params })\n },\n })\n}\n\n// Re-export the chain gate so UI code can branch without importing `/cow`.\nexport { isCowSupportedChain }\n","/**\n * TanStack Query v5 sync hooks for the Panoptic v2 SDK.\n * @module v2/react/hooks/sync\n */\n\nimport { useMutation, useQueryClient } from '@tanstack/react-query'\nimport { useState } from 'react'\nimport type { Address, Hash } from 'viem'\n\nimport {\n type PendingPosition,\n type SyncProgressEvent,\n addPendingPosition,\n clearTrackedPositions,\n confirmPendingPosition,\n failPendingPosition,\n syncPositions,\n} from '../../sync'\nimport { usePanopticContext, useRequireStorage } from '../provider'\nimport { queryKeys } from '../queryKeys'\n\n/**\n * Hook for syncing positions with progress tracking.\n */\nexport function useSyncPositions(poolAddress: Address) {\n const { publicClient, chainId } = usePanopticContext()\n const storage = useRequireStorage()\n const account = usePanopticContext().account\n const queryClient = useQueryClient()\n const [progress, setProgress] = useState<SyncProgressEvent | null>(null)\n\n const mutation = useMutation({\n mutationFn: async (params?: { fromBlock?: bigint; toBlock?: bigint }) => {\n if (!account) throw new Error('account is required for sync')\n const result = await syncPositions({\n client: publicClient,\n chainId,\n poolAddress,\n account,\n storage,\n fromBlock: params?.fromBlock,\n toBlock: params?.toBlock,\n onUpdate: setProgress,\n })\n return result\n },\n onSuccess: () => {\n if (!account) return\n queryClient.invalidateQueries({\n queryKey: queryKeys.trackedPositionIds(chainId, poolAddress, account),\n })\n queryClient.invalidateQueries({\n queryKey: queryKeys.syncStatus(chainId, poolAddress, account),\n })\n queryClient.invalidateQueries({\n queryKey: queryKeys.positions(chainId, poolAddress, account),\n })\n queryClient.invalidateQueries({\n queryKey: queryKeys.closedPositions(chainId, poolAddress, account),\n })\n queryClient.invalidateQueries({\n queryKey: queryKeys.tradeHistory(chainId, poolAddress, account),\n })\n },\n })\n\n return { ...mutation, progress }\n}\n\n/**\n * Hook for adding a pending position (optimistic update).\n */\nexport function useAddPendingPosition(poolAddress: Address) {\n const { chainId } = usePanopticContext()\n const storage = useRequireStorage()\n const account = usePanopticContext().account\n const queryClient = useQueryClient()\n\n return useMutation({\n mutationFn: (position: PendingPosition) => {\n if (!account) throw new Error('account is required')\n return addPendingPosition({ chainId, poolAddress, account, storage, position })\n },\n onSuccess: () => {\n if (!account) return\n queryClient.invalidateQueries({\n queryKey: queryKeys.trackedPositionIds(chainId, poolAddress, account),\n })\n },\n })\n}\n\n/**\n * Hook for confirming a pending position.\n */\nexport function useConfirmPendingPosition(poolAddress: Address) {\n const { chainId } = usePanopticContext()\n const storage = useRequireStorage()\n const account = usePanopticContext().account\n const queryClient = useQueryClient()\n\n return useMutation({\n mutationFn: (tokenId: bigint) => {\n if (!account) throw new Error('account is required')\n return confirmPendingPosition({ chainId, poolAddress, account, storage, tokenId })\n },\n onSuccess: () => {\n if (!account) return\n queryClient.invalidateQueries({\n queryKey: queryKeys.trackedPositionIds(chainId, poolAddress, account),\n })\n queryClient.invalidateQueries({\n queryKey: queryKeys.positions(chainId, poolAddress, account),\n })\n },\n })\n}\n\n/**\n * Hook for marking a pending position as failed.\n */\nexport function useFailPendingPosition(poolAddress: Address) {\n const { chainId } = usePanopticContext()\n const storage = useRequireStorage()\n const account = usePanopticContext().account\n const queryClient = useQueryClient()\n\n return useMutation({\n mutationFn: (txHash: Hash) => {\n if (!account) throw new Error('account is required')\n return failPendingPosition({ chainId, poolAddress, account, storage, txHash })\n },\n onSuccess: () => {\n if (!account) return\n queryClient.invalidateQueries({\n queryKey: queryKeys.trackedPositionIds(chainId, poolAddress, account),\n })\n },\n })\n}\n\n/**\n * Hook for clearing all tracked positions.\n */\nexport function useClearTrackedPositions(poolAddress: Address) {\n const { chainId } = usePanopticContext()\n const storage = useRequireStorage()\n const account = usePanopticContext().account\n const queryClient = useQueryClient()\n\n return useMutation({\n mutationFn: () => {\n if (!account) throw new Error('account is required')\n return clearTrackedPositions({ chainId, poolAddress, account, storage })\n },\n onSuccess: () => {\n if (!account) return\n queryClient.invalidateQueries({\n queryKey: queryKeys.trackedPositionIds(chainId, poolAddress, account),\n })\n queryClient.invalidateQueries({\n queryKey: queryKeys.positions(chainId, poolAddress, account),\n })\n },\n })\n}\n","/**\n * TanStack Query v5 event hooks for the Panoptic v2 SDK.\n * @module v2/react/hooks/events\n */\n\nimport { useEffect, useRef, useState } from 'react'\nimport type { Address, Hash } from 'viem'\nimport { zeroAddress } from 'viem'\n\nimport { watchEvents } from '../../events'\nimport {\n type EventPoller,\n type EventSubscriptionHandle,\n createEventPoller,\n createEventSubscription,\n} from '../../events'\nimport type { PanopticEvent, PanopticEventType } from '../../types'\nimport { usePanopticContext } from '../provider'\n\n/**\n * Watch events via WebSocket. Returns cleanup automatically on unmount.\n */\nexport function useWatchEvents(\n poolAddress: Address,\n eventTypes: PanopticEventType[] | undefined,\n onEvent: (events: PanopticEvent[]) => void,\n options?: {\n enabled?: boolean\n collateralTracker0?: Address\n collateralTracker1?: Address\n riskEngineAddress?: Address\n sfpmAddress?: Address\n poolManagerAddress?: Address\n onError?: (error: Error) => void\n },\n) {\n const { publicClient } = usePanopticContext()\n const onEventRef = useRef(onEvent)\n onEventRef.current = onEvent\n const onErrorRef = useRef(options?.onError)\n onErrorRef.current = options?.onError\n\n const eventTypesKey = eventTypes?.join(',')\n\n useEffect(() => {\n if (options?.enabled === false) return\n\n const unwatch = watchEvents({\n client: publicClient,\n poolAddress,\n eventTypes,\n collateralTracker0: options?.collateralTracker0,\n collateralTracker1: options?.collateralTracker1,\n riskEngineAddress: options?.riskEngineAddress,\n sfpmAddress: options?.sfpmAddress,\n poolManagerAddress: options?.poolManagerAddress,\n onLogs: (events) => onEventRef.current(events),\n onError: (error) => onErrorRef.current?.(error),\n })\n\n return unwatch\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [\n publicClient,\n poolAddress,\n options?.enabled,\n options?.collateralTracker0,\n options?.collateralTracker1,\n options?.riskEngineAddress,\n options?.sfpmAddress,\n options?.poolManagerAddress,\n eventTypesKey,\n ])\n}\n\n/**\n * Create a resilient event subscription with auto-reconnect.\n */\nexport function useEventSubscription(\n poolAddress: Address,\n eventTypes: PanopticEventType[] | undefined,\n onEvent: (events: PanopticEvent[]) => void,\n options?: {\n enabled?: boolean\n collateralTracker0?: Address\n collateralTracker1?: Address\n riskEngineAddress?: Address\n sfpmAddress?: Address\n poolManagerAddress?: Address\n onError?: (error: Error) => void\n onReconnect?: (attempt: bigint, nextDelayMs: bigint) => void\n onConnected?: () => void\n },\n) {\n const { publicClient } = usePanopticContext()\n const onEventRef = useRef(onEvent)\n onEventRef.current = onEvent\n const onErrorRef = useRef(options?.onError)\n onErrorRef.current = options?.onError\n const onReconnectRef = useRef(options?.onReconnect)\n onReconnectRef.current = options?.onReconnect\n const onConnectedRef = useRef(options?.onConnected)\n onConnectedRef.current = options?.onConnected\n\n const eventTypesKey = eventTypes?.join(',')\n\n useEffect(() => {\n if (options?.enabled === false) return\n\n const handle: EventSubscriptionHandle = createEventSubscription({\n client: publicClient,\n poolAddress,\n eventTypes,\n collateralTracker0: options?.collateralTracker0,\n collateralTracker1: options?.collateralTracker1,\n riskEngineAddress: options?.riskEngineAddress,\n sfpmAddress: options?.sfpmAddress,\n poolManagerAddress: options?.poolManagerAddress,\n onLogs: (events) => onEventRef.current(events),\n onError: (error) => onErrorRef.current?.(error),\n onReconnect: (attempt, delay) => onReconnectRef.current?.(attempt, delay),\n onConnected: () => onConnectedRef.current?.(),\n })\n\n handle.start()\n return () => handle.stop()\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [\n publicClient,\n poolAddress,\n options?.enabled,\n options?.collateralTracker0,\n options?.collateralTracker1,\n options?.riskEngineAddress,\n options?.sfpmAddress,\n options?.poolManagerAddress,\n eventTypesKey,\n ])\n}\n\n/**\n * Create an HTTP polling event fetcher.\n */\nexport function useEventPoller(\n poolAddress: Address,\n eventTypes: PanopticEventType[] | undefined,\n onEvent: (events: PanopticEvent[]) => void,\n options?: {\n enabled?: boolean\n intervalMs?: bigint\n collateralTracker0?: Address\n collateralTracker1?: Address\n riskEngineAddress?: Address\n sfpmAddress?: Address\n poolManagerAddress?: Address\n onError?: (error: Error) => void\n },\n) {\n const { publicClient } = usePanopticContext()\n const onEventRef = useRef(onEvent)\n onEventRef.current = onEvent\n const onErrorRef = useRef(options?.onError)\n onErrorRef.current = options?.onError\n\n const eventTypesKey = eventTypes?.join(',')\n\n useEffect(() => {\n if (options?.enabled === false) return\n\n const poller: EventPoller = createEventPoller({\n client: publicClient,\n poolAddress,\n eventTypes,\n collateralTracker0: options?.collateralTracker0,\n collateralTracker1: options?.collateralTracker1,\n riskEngineAddress: options?.riskEngineAddress,\n sfpmAddress: options?.sfpmAddress,\n poolManagerAddress: options?.poolManagerAddress,\n intervalMs: options?.intervalMs,\n onLogs: (events) => onEventRef.current(events),\n onError: (error) => onErrorRef.current?.(error),\n })\n\n poller.start()\n return () => poller.stop()\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [\n publicClient,\n poolAddress,\n options?.enabled,\n options?.intervalMs,\n options?.collateralTracker0,\n options?.collateralTracker1,\n options?.riskEngineAddress,\n options?.sfpmAddress,\n options?.poolManagerAddress,\n eventTypesKey,\n ])\n}\n\n/**\n * Confirms a transaction by watching for its corresponding on-chain event.\n *\n * An event log only exists in a confirmed (non-reverted) transaction, so\n * matching on `transactionHash` is sufficient proof of 1-block inclusion.\n * This bypasses the N-block confirmation wait of `useWaitForTransactionReceipt`,\n * making it faster on chains with high confirmation counts (e.g. Base = 150 blocks).\n *\n * Use alongside `useWaitForTransactionReceipt` (confirmations: 1) for revert\n * detection — reverted transactions emit no events.\n *\n * @example\n * ```tsx\n * const confirmation = useTxEventConfirmation({\n * txHash: write.data,\n * poolAddress,\n * eventType: 'OptionMinted',\n * enabled: write.data !== undefined,\n * })\n *\n * useEffect(() => {\n * if (confirmation.isSuccess) onSuccess?.()\n * }, [confirmation.isSuccess])\n * ```\n */\nexport function useTxEventConfirmation({\n txHash,\n poolAddress = zeroAddress,\n collateralTrackerAddress,\n eventType,\n enabled = true,\n intervalMs = 3000n,\n}: {\n /** Transaction hash to confirm. Polling starts when this is defined. */\n txHash: Hash | undefined\n /** PanopticPool address to watch for the event. Optional when watching collateral events only. */\n poolAddress?: Address\n /** CollateralTracker address to watch for Deposit/Withdraw events. */\n collateralTrackerAddress?: Address\n /** The event type expected from this transaction. */\n eventType: PanopticEventType\n /** Set to false to disable polling entirely. Default: true. */\n enabled?: boolean\n /** Polling interval in ms. Default: 3000 (~1 block on L2s). */\n intervalMs?: bigint\n}): {\n /** The matched event, set once the tx is confirmed. */\n data: PanopticEvent | undefined\n /** True while polling and not yet confirmed. */\n isLoading: boolean\n /** True once the matching event has been observed. */\n isSuccess: boolean\n} {\n const { publicClient } = usePanopticContext()\n const [data, setData] = useState<PanopticEvent | undefined>()\n const [isLoading, setIsLoading] = useState(false)\n\n // Refs to avoid stale closures inside the async poller callback\n const txHashRef = useRef(txHash)\n txHashRef.current = txHash\n const confirmedRef = useRef(false)\n const pollerRef = useRef<EventPoller | null>(null)\n\n useEffect(() => {\n // Reset for new tx\n confirmedRef.current = false\n setData(undefined)\n\n if (!txHash || !enabled) {\n pollerRef.current?.stop()\n pollerRef.current = null\n setIsLoading(false)\n return\n }\n\n setIsLoading(true)\n let cancelled = false\n\n // Capture current block before starting so we don't miss an event that\n // lands in the same block as poller initialisation.\n publicClient\n .getBlockNumber()\n .then((currentBlock) => {\n if (cancelled) return\n\n const fromBlock = currentBlock > 0n ? currentBlock - 1n : 0n\n\n const poller = createEventPoller({\n client: publicClient,\n poolAddress,\n collateralTracker0: collateralTrackerAddress,\n eventTypes: [eventType],\n intervalMs,\n fromBlock,\n onLogs: (events) => {\n const hash = txHashRef.current\n if (!hash || confirmedRef.current) return\n const match = events.find((e) => e.transactionHash === hash)\n if (match) {\n confirmedRef.current = true\n pollerRef.current?.stop()\n pollerRef.current = null\n setIsLoading(false)\n setData(match)\n }\n },\n })\n\n pollerRef.current = poller\n poller.start()\n })\n .catch(() => {\n if (cancelled || confirmedRef.current) return\n pollerRef.current?.stop()\n pollerRef.current = null\n setIsLoading(false)\n })\n\n return () => {\n cancelled = true\n pollerRef.current?.stop()\n pollerRef.current = null\n }\n }, [txHash, enabled, publicClient, poolAddress, collateralTrackerAddress, eventType, intervalMs])\n\n return {\n data,\n isLoading: isLoading && data === undefined,\n isSuccess: data !== undefined,\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAKA,MAAM,6BAA6B;AACnC,MAAM,8BAA8B;AAEpC,SAAgB,oBAAoBA,OAAwB;AAC1D,QAAO,SAAS;AACjB;AAED,SAAgB,qBAAqBA,OAAwB;AAC3D,QAAO,SAAS;AACjB;AAED,SAAgB,uBAAuBC,QAAiBD,OAAwB;AAG9E,QAAO,oBAAoB,MAAM;AAClC;AAED,SAAgB,wBAAwBE,SAAkBF,OAAwB;AAGhF,QAAO,qBAAqB,MAAM;AACnC;AAED,SAAgB,kBAAkBG,QAAyB;AACzD,QAAO,oBAAuB,WAAW,OAAO,UAAU;AAC3D;;;;ACQD,MAAM,kBAAkB,cAA2C,KAAK;;;;;;;;;;;;;;;;;;;;;AA6BxE,SAAgB,iBAAiB,EAAE,SAAU,GAAG,OAA8B,EAAE;AAC9E,wBAA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