@panoptic-eng/sdk 1.0.17 → 1.0.18

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.
@@ -1,4 +1,4 @@
1
- import { PanopticError$1 as PanopticError, getBlockMeta, getPool$1 as getPool, submitWrite } from "./position-xJ_rnVZ0.js";
1
+ import { PanopticError$1 as PanopticError, getBlockMeta, getPool$1 as getPool, submitWrite } from "./position-Bo7y8jcj.js";
2
2
  import { encodeAbiParameters, encodeFunctionData, encodePacked, erc20Abi, isAddressEqual, maxUint256, zeroAddress } from "viem";
3
3
 
4
4
  //#region src/uniswap/v4/router/errors.ts
@@ -1009,4 +1009,4 @@ async function swapExactOutViaRouterAndWait(params) {
1009
1009
 
1010
1010
  //#endregion
1011
1011
  export { AmountExceedsUint128Error, InvalidSwapTokenError, MissingSweepRecipientError, PERMIT2_ADDRESS, QuoterUnavailableError, SETTLE_ALL, SWAP_EXACT_IN_SINGLE, SWAP_EXACT_OUT_SINGLE, SWEEP, TAKE_ALL, UNISWAP_V4_ADDRESSES, UnsupportedChainError, V4_SWAP, approveErc20ForPermit2, approveErc20ForPermit2AndWait, approveRouterViaPermit2, approveRouterViaPermit2AndWait, buildV4ExactOutSwapExecuteArgs, buildV4ExactOutSwapExecuteCalldata, buildV4SwapExecuteArgs, buildV4SwapExecuteCalldata, checkRouterApproval, getUniswapV4Addresses, quoteSwapExactInViaRouter, quoteSwapExactOutViaRouter, resolveSwapRoute, swapExactInViaRouter, swapExactInViaRouterAndWait, swapExactOutViaRouter, swapExactOutViaRouterAndWait };
1012
- //# sourceMappingURL=router-B6Or2RvX.js.map
1012
+ //# sourceMappingURL=router-qZEEc47U.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"router-B6Or2RvX.js","names":["chainId: bigint","cause?: Error","token: Address","currency0: Address","currency1: Address","amount: bigint","PERMIT2_ADDRESS: Address","UNISWAP_V4_ADDRESSES: Record<number, UniswapV4Addresses>","chainId: bigint","overrides?: Partial<UniswapV4Addresses>","merged: Partial<UniswapV4Addresses>","UINT128_MAX","amount: bigint","recipient: Address","tokenOut: Address","recipient: Address | undefined","nativeAmount: bigint","erc20Amount: bigint","args: BuildV4SwapCalldataArgs","args: BuildV4ExactOutSwapCalldataArgs","commandList: number[]","inputs: Hex[]","params: CheckRouterApprovalParams","params: ApproveErc20ForPermit2Params","params: ApproveRouterViaPermit2Params","params: ResolveSwapRouteParams","slippageBps: bigint","params: QuoteSwapExactInViaRouterParams","params: QuoteSwapExactOutViaRouterParams","params: SwapExactInViaRouterParams","params: SwapExactOutViaRouterParams"],"sources":["../src/uniswap/v4/router/errors.ts","../src/uniswap/v4/addresses.ts","../src/uniswap/v4/abis/universalRouter.ts","../src/uniswap/v4/router/encodeSwap.ts","../src/uniswap/v4/abis/permit2.ts","../src/uniswap/v4/router/permit2.ts","../src/uniswap/v4/abis/v4Quoter.ts","../src/uniswap/v4/router/resolvePoolKey.ts","../src/uniswap/v4/router/quote.ts","../src/uniswap/v4/router/swap.ts"],"sourcesContent":["/**\n * Errors for the Uniswap v4 Universal Router swap module.\n *\n * All extend {@link PanopticError} so callers can keep a single\n * `instanceof PanopticError` check and so they satisfy `SimulationResult`'s\n * error type.\n *\n * @module uniswap/v4/router/errors\n */\n\nimport type { Address } from 'viem'\n\nimport { PanopticError } from '../../../panoptic/v2/errors'\n\n/**\n * The chain has no configured Uniswap v4 addresses and none were supplied via\n * overrides.\n */\nexport class UnsupportedChainError extends PanopticError {\n override readonly name = 'UnsupportedChainError'\n\n constructor(\n public readonly chainId: bigint,\n cause?: Error,\n ) {\n super(`Uniswap v4 router not configured for chain ${chainId}`, cause)\n }\n}\n\n/**\n * `tokenIn` is neither `currency0` nor `currency1` of the resolved pool.\n */\nexport class InvalidSwapTokenError extends PanopticError {\n override readonly name = 'InvalidSwapTokenError'\n\n constructor(\n public readonly token: Address,\n public readonly currency0: Address,\n public readonly currency1: Address,\n cause?: Error,\n ) {\n super(\n `Token ${token} is not part of the pool (currency0=${currency0}, currency1=${currency1})`,\n cause,\n )\n }\n}\n\n/**\n * An amount exceeds the uint128 range required by the v4 swap encoding.\n */\nexport class AmountExceedsUint128Error extends PanopticError {\n override readonly name = 'AmountExceedsUint128Error'\n\n constructor(\n public readonly amount: bigint,\n cause?: Error,\n ) {\n super(`Amount ${amount} exceeds uint128 maximum`, cause)\n }\n}\n\n/**\n * A native-ETH swap needs a trailing Universal Router SWEEP to deliver the ETH\n * output (or refund the input overpay), but no `recipient` was supplied.\n */\nexport class MissingSweepRecipientError extends PanopticError {\n override readonly name = 'MissingSweepRecipientError'\n\n constructor(cause?: Error) {\n super('A recipient is required to sweep native ETH back to the user', cause)\n }\n}\n\n/**\n * The V4Quoter is not available for the chain (no fallback in v1).\n */\nexport class QuoterUnavailableError extends PanopticError {\n override readonly name = 'QuoterUnavailableError'\n\n constructor(\n public readonly chainId: bigint,\n cause?: Error,\n ) {\n super(`V4Quoter unavailable for chain ${chainId}`, cause)\n }\n}\n","/**\n * Per-chain Uniswap v4 infrastructure addresses (Universal Router, V4Quoter,\n * PoolManager, Permit2).\n *\n * v1 supports mainnet only; other chains throw {@link UnsupportedChainError}\n * unless every address is supplied via the `overrides` argument (e.g. anvil\n * fork tests, or bots targeting a not-yet-listed chain).\n *\n * @module uniswap/v4/addresses\n */\n\nimport type { Address } from 'viem'\n\nimport { UnsupportedChainError } from './router/errors'\n\n/**\n * Uniswap v4 contract addresses required for a Universal Router spot swap.\n */\nexport interface UniswapV4Addresses {\n /** Universal Router (v4-capable build) — entrypoint for `execute(...)`. */\n universalRouter: Address\n /** V4Quoter — `quoteExactInputSingle` (revert/staticcall-based). */\n v4Quoter: Address\n /** Uniswap v4 PoolManager (singleton). */\n poolManager: Address\n /** Canonical Permit2 (same address on every chain). */\n permit2: Address\n}\n\n/**\n * Canonical Permit2, identical across all chains.\n */\nexport const PERMIT2_ADDRESS: Address = '0x000000000022D473030F116dDEE9F6B43aC78BA3'\n\n/**\n * Verified Uniswap v4 deployment addresses keyed by chainId.\n *\n * Sourced from the official Uniswap v4 deployments. Add a chain here only after\n * verifying each address against the canonical Uniswap deployment listing —\n * Universal Router in particular is NOT the same address across chains.\n */\nexport const UNISWAP_V4_ADDRESSES: Record<number, UniswapV4Addresses> = {\n // Ethereum mainnet\n 1: {\n universalRouter: '0x66a9893cC07D91D95644AEDD05D03f95e1dBA8Af',\n v4Quoter: '0x52F0E24D1c21C8A0cB1e5a5dD6198556BD9E1203',\n poolManager: '0x000000000004444c5dc75cB358380D2e3dE08A90',\n permit2: PERMIT2_ADDRESS,\n },\n}\n\n/**\n * Resolve the Uniswap v4 addresses for a chain, applying optional overrides.\n *\n * @param chainId - Target chain ID.\n * @param overrides - Partial override of any address (e.g. for fork tests).\n * @returns Fully-resolved {@link UniswapV4Addresses}.\n * @throws {UnsupportedChainError} when the chain is not listed and the\n * overrides do not supply every required address.\n */\nexport function getUniswapV4Addresses(\n chainId: bigint,\n overrides?: Partial<UniswapV4Addresses>,\n): UniswapV4Addresses {\n const base = UNISWAP_V4_ADDRESSES[Number(chainId)]\n\n const merged: Partial<UniswapV4Addresses> = {\n ...base,\n ...overrides,\n permit2: overrides?.permit2 ?? base?.permit2 ?? PERMIT2_ADDRESS,\n }\n\n if (\n merged.universalRouter === undefined ||\n merged.v4Quoter === undefined ||\n merged.poolManager === undefined ||\n merged.permit2 === undefined\n ) {\n throw new UnsupportedChainError(chainId)\n }\n\n return merged as UniswapV4Addresses\n}\n","/**\n * Minimal Universal Router ABI (only the `execute` overload we use).\n * @module uniswap/v4/abis/universalRouter\n */\n\nexport const universalRouterAbi = [\n {\n type: 'function',\n name: 'execute',\n stateMutability: 'payable',\n inputs: [\n { name: 'commands', type: 'bytes' },\n { name: 'inputs', type: 'bytes[]' },\n { name: 'deadline', type: 'uint256' },\n ],\n outputs: [],\n },\n] as const\n","/**\n * Pure calldata builders for exact-in and exact-out single-hop swaps via the\n * Uniswap v4 Universal Router.\n *\n * Opcodes verified against `@uniswap/universal-router` `Commands.sol` and\n * `@uniswap/v4-periphery` `Actions.sol`:\n * - Universal Router commands `V4_SWAP = 0x10`, `SWEEP = 0x04`.\n * - v4 actions `SWAP_EXACT_IN_SINGLE = 0x06`, `SWAP_EXACT_OUT_SINGLE = 0x08`,\n * `SETTLE_ALL = 0x0c`, `TAKE = 0x0e`, `TAKE_ALL = 0x0f`.\n *\n * Native ETH is `address(0)` in the PoolKey and needs special handling per side:\n * - Native-ETH OUTPUT: the implicit-recipient `TAKE_ALL` leaves the bought ETH\n * held by the Universal Router, so output is taken with the explicit-recipient\n * `TAKE` action instead, delivering ETH straight to the recipient. No trailing\n * SWEEP is appended for native output.\n * - Native-ETH INPUT on exact-out: the router is funded with the full\n * `amountInMaximum` overpay, so a trailing Universal-Router-level `SWEEP`\n * command (NOT the v4 SWEEP action, which this router does not support) refunds\n * the unused ETH to the recipient.\n * Native-ETH input on exact-in needs neither (msg.value equals the exact input;\n * ERC20 output is delivered by `TAKE_ALL`).\n *\n * @module uniswap/v4/router/encodeSwap\n */\n\nimport type { Address, Hex } from 'viem'\nimport { encodeAbiParameters, encodeFunctionData, encodePacked, zeroAddress } from 'viem'\n\nimport type { PoolKey } from '../../../panoptic/v2/types'\nimport { universalRouterAbi } from '../abis/universalRouter'\nimport { AmountExceedsUint128Error, MissingSweepRecipientError } from './errors'\n\n/** Universal Router command byte for a v4 swap. */\nexport const V4_SWAP = 0x10\n/** v4 action: exact-in single-hop swap. */\nexport const SWAP_EXACT_IN_SINGLE = 0x06\n/** v4 action: pay all of the input currency owed. */\nexport const SETTLE_ALL = 0x0c\n/** v4 action: take all of the output currency owed. */\nexport const TAKE_ALL = 0x0f\n/** v4 action: take an output currency to an explicit recipient. */\nexport const TAKE = 0x0e\n/** v4 action: exact-out single-hop swap. */\nexport const SWAP_EXACT_OUT_SINGLE = 0x08\n/** Universal Router command: sweep the router's token balance to a recipient. */\nexport const SWEEP = 0x04\n\n/** v4 sentinel: take the full positive currency delta (used with TAKE). */\nconst OPEN_DELTA = 0n\n\nconst UINT128_MAX = (1n << 128n) - 1n\n\nconst poolKeyComponents = [\n { name: 'currency0', type: 'address' },\n { name: 'currency1', type: 'address' },\n { name: 'fee', type: 'uint24' },\n { name: 'tickSpacing', type: 'int24' },\n { name: 'hooks', type: 'address' },\n] as const\n\nconst exactInputSingleParamsAbi = [\n {\n type: 'tuple',\n components: [\n { name: 'poolKey', type: 'tuple', components: poolKeyComponents },\n { name: 'zeroForOne', type: 'bool' },\n { name: 'amountIn', type: 'uint128' },\n { name: 'amountOutMinimum', type: 'uint128' },\n { name: 'hookData', type: 'bytes' },\n ],\n },\n] as const\n\nconst exactOutputSingleParamsAbi = [\n {\n type: 'tuple',\n components: [\n { name: 'poolKey', type: 'tuple', components: poolKeyComponents },\n { name: 'zeroForOne', type: 'bool' },\n { name: 'amountOut', type: 'uint128' },\n { name: 'amountInMaximum', type: 'uint128' },\n { name: 'hookData', type: 'bytes' },\n ],\n },\n] as const\n\nconst currencyAmountAbi = [\n { name: 'currency', type: 'address' },\n { name: 'amount', type: 'uint256' },\n] as const\n\n// v4 TAKE action params: take `amount` of `currency` to an explicit recipient.\nconst takeToRecipientAbi = [\n { name: 'currency', type: 'address' },\n { name: 'recipient', type: 'address' },\n { name: 'amount', type: 'uint256' },\n] as const\n\n// Universal Router SWEEP command params: forward `token` above `amountMin` to\n// `recipient`.\nconst sweepParamsAbi = [\n { name: 'token', type: 'address' },\n { name: 'recipient', type: 'address' },\n { name: 'amountMin', type: 'uint256' },\n] as const\n\nfunction assertUint128(amount: bigint): void {\n if (amount < 0n || amount > UINT128_MAX) {\n throw new AmountExceedsUint128Error(amount)\n }\n}\n\n/**\n * Encode the input for a Universal Router `SWEEP` command that forwards the\n * router's full native-ETH balance (above `amountMin = 0`) to `recipient`.\n */\nfunction encodeEthSweepInput(recipient: Address): Hex {\n return encodeAbiParameters(sweepParamsAbi, [zeroAddress, recipient, 0n])\n}\n\n/**\n * Build the output-take v4 action byte + param.\n *\n * Native-ETH output is taken with the explicit-recipient `TAKE` action so the\n * router forwards the ETH straight to `recipient` (the implicit-`msgSender`\n * `TAKE_ALL` leaves native ETH held by the router). ERC20 output uses\n * `TAKE_ALL`, which already credits the caller.\n *\n * @param nativeAmount - TAKE amount for native-ETH output: `OPEN_DELTA` (0) to\n * take the full credit (exact-in, protected by the swap's min) or the exact\n * output (exact-out).\n * @param erc20Amount - TAKE_ALL min/amount for ERC20 output: `amountOutMinimum`\n * (exact-in) or the exact output (exact-out).\n */\nfunction buildOutputTake(\n tokenOut: Address,\n recipient: Address | undefined,\n nativeAmount: bigint,\n erc20Amount: bigint,\n): { action: number; param: Hex } {\n if (tokenOut === zeroAddress) {\n if (recipient === undefined) {\n throw new MissingSweepRecipientError()\n }\n return {\n action: TAKE,\n param: encodeAbiParameters(takeToRecipientAbi, [zeroAddress, recipient, nativeAmount]),\n }\n }\n return {\n action: TAKE_ALL,\n param: encodeAbiParameters(currencyAmountAbi, [tokenOut, erc20Amount]),\n }\n}\n\n/**\n * Arguments for {@link buildV4SwapExecuteCalldata}.\n */\nexport interface BuildV4SwapCalldataArgs {\n /** The v4 PoolKey (currency0, currency1, fee, tickSpacing, hooks). */\n poolKey: PoolKey\n /** Whether the swap goes currency0 → currency1. */\n zeroForOne: boolean\n /** Exact input amount (uint128). */\n amountIn: bigint\n /** Minimum acceptable output (uint128). */\n amountOutMinimum: bigint\n /** Input token address (`address(0)` for native ETH). */\n tokenIn: Address\n /** Output token address (`address(0)` for native ETH). */\n tokenOut: Address\n /** Absolute deadline (unix seconds). */\n deadline: bigint\n /**\n * Recipient of native-ETH output. Required when `tokenOut` is `address(0)`,\n * since the explicit-recipient `TAKE` action forwards the bought ETH there\n * (the implicit-recipient `TAKE_ALL` would leave it held by the router).\n */\n recipient?: Address\n /** Hook data; defaults to `0x` (hook-less pools). */\n hookData?: Hex\n}\n\n/**\n * Build the typed `execute(...)` args + msg.value for an exact-in single-hop v4\n * swap. Use this when submitting via viem (`writeContract` / `submitWrite`).\n *\n * When `tokenOut` is native ETH the explicit-recipient `TAKE` action forwards\n * the bought ETH to `recipient` (no trailing SWEEP is needed for exact-in).\n *\n * @returns `args` ready to spread into `execute` and the ETH `value` to send\n * (= `amountIn` for native-ETH input, otherwise `0n`).\n */\nexport function buildV4SwapExecuteArgs(args: BuildV4SwapCalldataArgs): {\n args: readonly [Hex, readonly Hex[], bigint]\n value: bigint\n} {\n const {\n poolKey,\n zeroForOne,\n amountIn,\n amountOutMinimum,\n tokenIn,\n tokenOut,\n deadline,\n recipient,\n hookData = '0x',\n } = args\n\n assertUint128(amountIn)\n assertUint128(amountOutMinimum)\n\n const swapParam = encodeAbiParameters(exactInputSingleParamsAbi, [\n {\n poolKey: {\n currency0: poolKey.currency0,\n currency1: poolKey.currency1,\n fee: Number(poolKey.fee),\n tickSpacing: Number(poolKey.tickSpacing),\n hooks: poolKey.hooks,\n },\n zeroForOne,\n amountIn,\n amountOutMinimum,\n hookData,\n },\n ])\n\n // SETTLE_ALL pays the input; the output take credits the recipient. Native-ETH\n // output uses the explicit-recipient TAKE so the router forwards the ETH (with\n // OPEN_DELTA to take the full, slippage-protected swap output).\n const settleParam = encodeAbiParameters(currencyAmountAbi, [tokenIn, amountIn])\n const take = buildOutputTake(tokenOut, recipient, OPEN_DELTA, amountOutMinimum)\n\n const actions = encodePacked(\n ['uint8', 'uint8', 'uint8'],\n [SWAP_EXACT_IN_SINGLE, SETTLE_ALL, take.action],\n )\n\n const v4Input = encodeAbiParameters(\n [\n { name: 'actions', type: 'bytes' },\n { name: 'params', type: 'bytes[]' },\n ],\n [actions, [swapParam, settleParam, take.param]],\n )\n\n // Native-ETH input on exact-in needs no SWEEP (msg.value equals the exact input).\n const commands = encodePacked(['uint8'], [V4_SWAP])\n const value = tokenIn === zeroAddress ? amountIn : 0n\n\n return { args: [commands, [v4Input], deadline] as const, value }\n}\n\n/**\n * Build the `execute(commands, inputs, deadline)` calldata + msg.value for an\n * exact-in single-hop v4 swap.\n *\n * @returns The encoded calldata and the ETH `value` to send.\n */\nexport function buildV4SwapExecuteCalldata(args: BuildV4SwapCalldataArgs): {\n data: Hex\n value: bigint\n} {\n const { args: executeArgs, value } = buildV4SwapExecuteArgs(args)\n const data = encodeFunctionData({\n abi: universalRouterAbi,\n functionName: 'execute',\n args: executeArgs,\n })\n return { data, value }\n}\n\n/**\n * Arguments for {@link buildV4ExactOutSwapExecuteCalldata}.\n */\nexport interface BuildV4ExactOutSwapCalldataArgs {\n /** The v4 PoolKey (currency0, currency1, fee, tickSpacing, hooks). */\n poolKey: PoolKey\n /** Whether the swap goes currency0 → currency1. */\n zeroForOne: boolean\n /** Exact output amount to receive (uint128). */\n amountOut: bigint\n /** Maximum acceptable input to spend (uint128). */\n amountInMaximum: bigint\n /** Input token address (`address(0)` for native ETH). */\n tokenIn: Address\n /** Output token address (`address(0)` for native ETH). */\n tokenOut: Address\n /** Absolute deadline (unix seconds). */\n deadline: bigint\n /**\n * Recipient of any swept native-ETH refund (only used for native-ETH input).\n * Must be the payer; the leftover `amountInMaximum - actualInput` is returned\n * here.\n */\n recipient: Address\n /** Hook data; defaults to `0x` (hook-less pools). */\n hookData?: Hex\n}\n\n/**\n * Build the typed `execute(...)` args + msg.value for an exact-out single-hop v4\n * swap. Use this when submitting via viem (`writeContract` / `submitWrite`).\n *\n * For native-ETH input, `value` is `amountInMaximum` (an overpay) and a trailing\n * `SWEEP` action refunds the unused ETH to `recipient`. For ERC20 input, Permit2\n * pulls only the settled amount, so no SWEEP is appended and `value` is `0n`.\n *\n * @returns `args` ready to spread into `execute` and the ETH `value` to send.\n */\nexport function buildV4ExactOutSwapExecuteArgs(args: BuildV4ExactOutSwapCalldataArgs): {\n args: readonly [Hex, readonly Hex[], bigint]\n value: bigint\n} {\n const {\n poolKey,\n zeroForOne,\n amountOut,\n amountInMaximum,\n tokenIn,\n tokenOut,\n deadline,\n recipient,\n hookData = '0x',\n } = args\n\n assertUint128(amountOut)\n assertUint128(amountInMaximum)\n\n const swapParam = encodeAbiParameters(exactOutputSingleParamsAbi, [\n {\n poolKey: {\n currency0: poolKey.currency0,\n currency1: poolKey.currency1,\n fee: Number(poolKey.fee),\n tickSpacing: Number(poolKey.tickSpacing),\n hooks: poolKey.hooks,\n },\n zeroForOne,\n amountOut,\n amountInMaximum,\n hookData,\n },\n ])\n\n // SETTLE_ALL caps the input at amountInMaximum; the output take delivers the\n // exact output. Native-ETH output uses the explicit-recipient TAKE so the\n // router forwards the ETH straight to `recipient`.\n const settleParam = encodeAbiParameters(currencyAmountAbi, [tokenIn, amountInMaximum])\n const take = buildOutputTake(tokenOut, recipient, amountOut, amountOut)\n\n const actions = encodePacked(\n ['uint8', 'uint8', 'uint8'],\n [SWAP_EXACT_OUT_SINGLE, SETTLE_ALL, take.action],\n )\n\n const v4Input = encodeAbiParameters(\n [\n { name: 'actions', type: 'bytes' },\n { name: 'params', type: 'bytes[]' },\n ],\n [actions, [swapParam, settleParam, take.param]],\n )\n\n const isNativeIn = tokenIn === zeroAddress\n\n // Native-ETH input funds the router with the full overpay cap; a trailing\n // Universal Router SWEEP command (the v4 SWEEP *action* is unsupported here)\n // refunds the unused ETH to the recipient.\n const commandList: number[] = [V4_SWAP]\n const inputs: Hex[] = [v4Input]\n if (isNativeIn) {\n commandList.push(SWEEP)\n inputs.push(encodeEthSweepInput(recipient))\n }\n\n const commands = encodePacked(\n commandList.map(() => 'uint8'),\n commandList,\n )\n const value = isNativeIn ? amountInMaximum : 0n\n\n return { args: [commands, inputs, deadline] as const, value }\n}\n\n/**\n * Build the `execute(commands, inputs, deadline)` calldata + msg.value for an\n * exact-out single-hop v4 swap.\n *\n * @returns The encoded calldata and the ETH `value` to send.\n */\nexport function buildV4ExactOutSwapExecuteCalldata(args: BuildV4ExactOutSwapCalldataArgs): {\n data: Hex\n value: bigint\n} {\n const { args: executeArgs, value } = buildV4ExactOutSwapExecuteArgs(args)\n const data = encodeFunctionData({\n abi: universalRouterAbi,\n functionName: 'execute',\n args: executeArgs,\n })\n return { data, value }\n}\n","/**\n * Minimal Permit2 ABI (`IAllowanceTransfer` subset: `approve` + `allowance`).\n * @module uniswap/v4/abis/permit2\n */\n\nexport const permit2Abi = [\n {\n type: 'function',\n name: 'approve',\n stateMutability: 'nonpayable',\n inputs: [\n { name: 'token', type: 'address' },\n { name: 'spender', type: 'address' },\n { name: 'amount', type: 'uint160' },\n { name: 'expiration', type: 'uint48' },\n ],\n outputs: [],\n },\n {\n type: 'function',\n name: 'allowance',\n stateMutability: 'view',\n inputs: [\n { name: 'user', type: 'address' },\n { name: 'token', type: 'address' },\n { name: 'spender', type: 'address' },\n ],\n outputs: [\n { name: 'amount', type: 'uint160' },\n { name: 'expiration', type: 'uint48' },\n { name: 'nonce', type: 'uint48' },\n ],\n },\n] as const\n","/**\n * Permit2 approval helpers for the Universal Router ERC20 input side.\n *\n * Two-step on-chain flow (only when `tokenIn` is an ERC20):\n * 1. ERC20 `approve(Permit2, amount)` — lets Permit2 pull the token.\n * 2. `Permit2.approve(token, universalRouter, amount, expiration)` — lets the\n * router spend via Permit2.\n *\n * Native ETH skips both steps.\n *\n * @module uniswap/v4/router/permit2\n */\n\nimport { erc20Abi, maxUint256 } from 'viem'\n\nimport { getBlockMeta } from '../../../panoptic/v2/clients'\nimport type { TxReceipt, TxResult } from '../../../panoptic/v2/types'\nimport { submitWrite } from '../../../panoptic/v2/writes'\nimport { permit2Abi } from '../abis/permit2'\nimport { getUniswapV4Addresses } from '../addresses'\nimport type {\n ApproveErc20ForPermit2Params,\n ApproveRouterViaPermit2Params,\n CheckRouterApprovalParams,\n RouterApprovalStatus,\n} from './types'\n\n/** uint160 max — the largest Permit2 allowance amount. */\nconst UINT160_MAX = (1n << 160n) - 1n\n/** Default Permit2 allowance expiration window (30 days). */\nconst DEFAULT_EXPIRATION_SECONDS = 2_592_000n\n/** uint48 max — the largest Permit2 expiration. */\nconst UINT48_MAX = (1n << 48n) - 1n\n\n/**\n * Check whether the ERC20 → Permit2 → Universal Router allowance chain is\n * sufficient for an exact-in swap of `amount`.\n */\nexport async function checkRouterApproval(\n params: CheckRouterApprovalParams,\n): Promise<RouterApprovalStatus> {\n const { client, chainId, tokenIn, owner, amount, addresses } = params\n const { permit2, universalRouter } = getUniswapV4Addresses(chainId, addresses)\n\n const [erc20Allowance, permit2Allowance, blockMeta] = await Promise.all([\n client.readContract({\n address: tokenIn,\n abi: erc20Abi,\n functionName: 'allowance',\n args: [owner, permit2],\n }),\n client.readContract({\n address: permit2,\n abi: permit2Abi,\n functionName: 'allowance',\n args: [owner, tokenIn, universalRouter],\n }),\n getBlockMeta({ client }),\n ])\n\n const [permit2Amount, permit2Expiration] = permit2Allowance\n\n const needsErc20Approval = erc20Allowance < amount\n const needsPermit2Approval =\n permit2Amount < amount || BigInt(permit2Expiration) <= blockMeta.blockTimestamp\n\n return {\n needsErc20Approval,\n needsPermit2Approval,\n erc20Allowance,\n permit2Amount,\n permit2Expiration: BigInt(permit2Expiration),\n }\n}\n\n/**\n * Step 1: approve the ERC20 token to Permit2 (defaults to unlimited).\n */\nexport async function approveErc20ForPermit2(\n params: ApproveErc20ForPermit2Params,\n): Promise<TxResult> {\n const {\n client,\n walletClient,\n account,\n chainId,\n tokenIn,\n amount = maxUint256,\n txOverrides,\n addresses,\n } = params\n const { permit2 } = getUniswapV4Addresses(chainId, addresses)\n\n return submitWrite({\n client,\n walletClient,\n account,\n address: tokenIn,\n abi: erc20Abi,\n functionName: 'approve',\n args: [permit2, amount],\n txOverrides,\n })\n}\n\n/**\n * Step 1 (and wait): approve the ERC20 token to Permit2.\n */\nexport async function approveErc20ForPermit2AndWait(\n params: ApproveErc20ForPermit2Params,\n): Promise<TxReceipt> {\n const result = await approveErc20ForPermit2(params)\n return result.wait()\n}\n\n/**\n * Step 2: approve the Universal Router as a Permit2 spender for the token.\n */\nexport async function approveRouterViaPermit2(\n params: ApproveRouterViaPermit2Params,\n): Promise<TxResult> {\n const {\n client,\n walletClient,\n account,\n chainId,\n tokenIn,\n amount = UINT160_MAX,\n expiration,\n txOverrides,\n addresses,\n } = params\n const { permit2, universalRouter } = getUniswapV4Addresses(chainId, addresses)\n\n const resolvedExpiration =\n expiration ?? (await getBlockMeta({ client })).blockTimestamp + DEFAULT_EXPIRATION_SECONDS\n const cappedExpiration = resolvedExpiration > UINT48_MAX ? UINT48_MAX : resolvedExpiration\n\n return submitWrite({\n client,\n walletClient,\n account,\n address: permit2,\n abi: permit2Abi,\n functionName: 'approve',\n args: [tokenIn, universalRouter, amount, cappedExpiration],\n txOverrides,\n })\n}\n\n/**\n * Step 2 (and wait): approve the Universal Router via Permit2.\n */\nexport async function approveRouterViaPermit2AndWait(\n params: ApproveRouterViaPermit2Params,\n): Promise<TxReceipt> {\n const result = await approveRouterViaPermit2(params)\n return result.wait()\n}\n","/**\n * Minimal V4Quoter ABI (`quoteExactInputSingle`, `quoteExactOutputSingle`).\n *\n * Note: neither function is `view` — they mutate state internally and are\n * intended to be called via `eth_call` / viem `simulateContract`, never\n * `readContract`.\n *\n * @module uniswap/v4/abis/v4Quoter\n */\n\nconst quoteExactSingleParams = {\n name: 'params',\n type: 'tuple',\n components: [\n {\n name: 'poolKey',\n type: 'tuple',\n components: [\n { name: 'currency0', type: 'address' },\n { name: 'currency1', type: 'address' },\n { name: 'fee', type: 'uint24' },\n { name: 'tickSpacing', type: 'int24' },\n { name: 'hooks', type: 'address' },\n ],\n },\n { name: 'zeroForOne', type: 'bool' },\n { name: 'exactAmount', type: 'uint128' },\n { name: 'hookData', type: 'bytes' },\n ],\n} as const\n\nexport const v4QuoterAbi = [\n {\n type: 'function',\n name: 'quoteExactInputSingle',\n stateMutability: 'nonpayable',\n inputs: [quoteExactSingleParams],\n outputs: [\n { name: 'amountOut', type: 'uint256' },\n { name: 'gasEstimate', type: 'uint256' },\n ],\n },\n {\n type: 'function',\n name: 'quoteExactOutputSingle',\n stateMutability: 'nonpayable',\n inputs: [quoteExactSingleParams],\n outputs: [\n { name: 'amountIn', type: 'uint256' },\n { name: 'gasEstimate', type: 'uint256' },\n ],\n },\n] as const\n","/**\n * Resolve the Uniswap v4 PoolKey + swap direction from a PanopticPool address.\n * @module uniswap/v4/router/resolvePoolKey\n */\n\nimport type { Address, PublicClient } from 'viem'\nimport { isAddressEqual } from 'viem'\n\nimport { getPool } from '../../../panoptic/v2/reads/pool'\nimport type { PoolKey } from '../../../panoptic/v2/types'\nimport { InvalidSwapTokenError } from './errors'\n\n/**\n * Resolved swap routing info for a given `tokenIn`.\n */\nexport interface ResolvedSwapRoute {\n /** Underlying v4 PoolKey. */\n poolKey: PoolKey\n /** Whether the swap goes currency0 → currency1. */\n zeroForOne: boolean\n /** Output token address. */\n tokenOut: Address\n /** Decimals of the output token. */\n tokenOutDecimals: bigint\n /** Symbol of the output token. */\n tokenOutSymbol: string\n}\n\n/**\n * Parameters for {@link resolveSwapRoute}.\n */\nexport interface ResolveSwapRouteParams {\n client: PublicClient\n poolAddress: Address\n chainId: bigint\n tokenIn: Address\n blockNumber?: bigint\n}\n\n/**\n * Resolve the PoolKey, swap direction, and output token metadata for a swap.\n *\n * @throws {InvalidSwapTokenError} when `tokenIn` is not part of the pool.\n */\nexport async function resolveSwapRoute(params: ResolveSwapRouteParams): Promise<ResolvedSwapRoute> {\n const { client, poolAddress, chainId, tokenIn, blockNumber } = params\n\n const pool = await getPool({ client, poolAddress, chainId, blockNumber })\n const { poolKey } = pool\n\n const isCurrency0 = isAddressEqual(tokenIn, poolKey.currency0)\n const isCurrency1 = isAddressEqual(tokenIn, poolKey.currency1)\n if (!isCurrency0 && !isCurrency1) {\n throw new InvalidSwapTokenError(tokenIn, poolKey.currency0, poolKey.currency1)\n }\n\n const zeroForOne = isCurrency0\n const tokenOut = zeroForOne ? poolKey.currency1 : poolKey.currency0\n const outTracker = zeroForOne ? pool.collateralTracker1 : pool.collateralTracker0\n\n return {\n poolKey,\n zeroForOne,\n tokenOut,\n tokenOutDecimals: outTracker.decimals,\n tokenOutSymbol: outTracker.symbol,\n }\n}\n","/**\n * Quote exact-in and exact-out swaps via the Uniswap v4 V4Quoter.\n * @module uniswap/v4/router/quote\n */\n\nimport { zeroAddress } from 'viem'\n\nimport { getBlockMeta } from '../../../panoptic/v2/clients'\nimport { PanopticError } from '../../../panoptic/v2/errors'\nimport type { SimulationResult } from '../../../panoptic/v2/types'\nimport { v4QuoterAbi } from '../abis/v4Quoter'\nimport { getUniswapV4Addresses } from '../addresses'\nimport { QuoterUnavailableError } from './errors'\nimport { resolveSwapRoute } from './resolvePoolKey'\nimport type {\n QuoteSwapExactInViaRouterParams,\n QuoteSwapExactOutViaRouterParams,\n SwapExactInQuote,\n SwapExactOutQuote,\n} from './types'\n\nconst BPS_DENOMINATOR = 10_000n\nconst UINT128_MAX = (1n << 128n) - 1n\n\n/** Reject out-of-range slippage so the min/max amount math can't underflow/overflow. */\nfunction assertSlippageBps(slippageBps: bigint): void {\n if (slippageBps < 0n || slippageBps > BPS_DENOMINATOR) {\n throw new PanopticError(`invalid slippageBps ${slippageBps}, must be 0..10000`)\n }\n}\n\nconst FALLBACK_META = {\n blockNumber: 0n,\n blockTimestamp: 0n,\n blockHash: '0x0' as `0x${string}`,\n}\n\n/**\n * Quote an exact-in spot swap against the underlying Uniswap v4 pool.\n *\n * Uses the V4Quoter `quoteExactInputSingle` via `eth_call` (the quoter is\n * state-mutating / revert-based, so it must be simulated, not read). Returns a\n * `SimulationResult` so failures carry a structured error rather than throwing.\n */\nexport async function quoteSwapExactInViaRouter(\n params: QuoteSwapExactInViaRouterParams,\n): Promise<SimulationResult<SwapExactInQuote>> {\n const { client, poolAddress, chainId, tokenIn, amountIn, slippageBps, blockNumber, addresses } =\n params\n\n try {\n if (amountIn < 0n || amountIn > UINT128_MAX) {\n throw new PanopticError(`amountIn ${amountIn} exceeds uint128 maximum`)\n }\n assertSlippageBps(slippageBps)\n\n const targetBlockNumber = blockNumber ?? (await client.getBlockNumber())\n const metaPromise = getBlockMeta({ client, blockNumber: targetBlockNumber })\n\n const { v4Quoter } = getUniswapV4Addresses(chainId, addresses)\n if (v4Quoter === zeroAddress) {\n throw new QuoterUnavailableError(chainId)\n }\n\n const route = await resolveSwapRoute({\n client,\n poolAddress,\n chainId,\n tokenIn,\n blockNumber: targetBlockNumber,\n })\n\n const { result } = await client.simulateContract({\n address: v4Quoter,\n abi: v4QuoterAbi,\n functionName: 'quoteExactInputSingle',\n blockNumber: targetBlockNumber,\n args: [\n {\n poolKey: {\n currency0: route.poolKey.currency0,\n currency1: route.poolKey.currency1,\n fee: Number(route.poolKey.fee),\n tickSpacing: Number(route.poolKey.tickSpacing),\n hooks: route.poolKey.hooks,\n },\n zeroForOne: route.zeroForOne,\n exactAmount: amountIn,\n hookData: '0x',\n },\n ],\n })\n\n const [amountOut, gasEstimate] = result\n const amountOutMinimum = (amountOut * (BPS_DENOMINATOR - slippageBps)) / BPS_DENOMINATOR\n\n const _meta = await metaPromise\n\n return {\n success: true,\n data: {\n amountOut,\n amountOutMinimum,\n zeroForOne: route.zeroForOne,\n tokenOut: route.tokenOut,\n poolKey: route.poolKey,\n gasEstimate,\n },\n gasEstimate,\n _meta,\n }\n } catch (error) {\n return {\n success: false,\n error:\n error instanceof PanopticError\n ? error\n : new PanopticError(\n error instanceof Error ? error.message : 'Quote failed',\n error instanceof Error ? error : undefined,\n ),\n _meta: FALLBACK_META,\n }\n }\n}\n\n/**\n * Quote an exact-out spot swap against the underlying Uniswap v4 pool.\n *\n * Uses the V4Quoter `quoteExactOutputSingle` via `eth_call` (the quoter is\n * state-mutating / revert-based, so it must be simulated, not read). Returns a\n * `SimulationResult` so failures carry a structured error rather than throwing.\n */\nexport async function quoteSwapExactOutViaRouter(\n params: QuoteSwapExactOutViaRouterParams,\n): Promise<SimulationResult<SwapExactOutQuote>> {\n const { client, poolAddress, chainId, tokenIn, amountOut, slippageBps, blockNumber, addresses } =\n params\n\n try {\n if (amountOut < 0n || amountOut > UINT128_MAX) {\n throw new PanopticError(`amountOut ${amountOut} exceeds uint128 maximum`)\n }\n assertSlippageBps(slippageBps)\n\n const targetBlockNumber = blockNumber ?? (await client.getBlockNumber())\n const metaPromise = getBlockMeta({ client, blockNumber: targetBlockNumber })\n\n const { v4Quoter } = getUniswapV4Addresses(chainId, addresses)\n if (v4Quoter === zeroAddress) {\n throw new QuoterUnavailableError(chainId)\n }\n\n const route = await resolveSwapRoute({\n client,\n poolAddress,\n chainId,\n tokenIn,\n blockNumber: targetBlockNumber,\n })\n\n const { result } = await client.simulateContract({\n address: v4Quoter,\n abi: v4QuoterAbi,\n functionName: 'quoteExactOutputSingle',\n blockNumber: targetBlockNumber,\n args: [\n {\n poolKey: {\n currency0: route.poolKey.currency0,\n currency1: route.poolKey.currency1,\n fee: Number(route.poolKey.fee),\n tickSpacing: Number(route.poolKey.tickSpacing),\n hooks: route.poolKey.hooks,\n },\n zeroForOne: route.zeroForOne,\n exactAmount: amountOut,\n hookData: '0x',\n },\n ],\n })\n\n const [amountIn, gasEstimate] = result\n // Ceiling division: never round the input cap down (would tighten the buffer).\n const amountInMaximum =\n (amountIn * (BPS_DENOMINATOR + slippageBps) + BPS_DENOMINATOR - 1n) / BPS_DENOMINATOR\n\n const _meta = await metaPromise\n\n return {\n success: true,\n data: {\n amountIn,\n amountInMaximum,\n zeroForOne: route.zeroForOne,\n tokenOut: route.tokenOut,\n poolKey: route.poolKey,\n gasEstimate,\n },\n gasEstimate,\n _meta,\n }\n } catch (error) {\n return {\n success: false,\n error:\n error instanceof PanopticError\n ? error\n : new PanopticError(\n error instanceof Error ? error.message : 'Quote failed',\n error instanceof Error ? error : undefined,\n ),\n _meta: FALLBACK_META,\n }\n }\n}\n","/**\n * Exact-in and exact-out spot swaps via the Uniswap v4 Universal Router.\n *\n * Swaps directly on the underlying Uniswap v4 pool, bypassing Panoptic (no SFPM,\n * no Panoptic LP fees, no pool collateral required). Native ETH (`address(0)`)\n * is supported via `msg.value` with no Permit2 approval.\n *\n * @module uniswap/v4/router/swap\n */\n\nimport { isAddressEqual } from 'viem'\n\nimport { getBlockMeta } from '../../../panoptic/v2/clients'\nimport { PanopticError } from '../../../panoptic/v2/errors'\nimport type { TxReceipt, TxResult } from '../../../panoptic/v2/types'\nimport { submitWrite } from '../../../panoptic/v2/writes'\nimport { universalRouterAbi } from '../abis/universalRouter'\nimport { getUniswapV4Addresses } from '../addresses'\nimport { buildV4ExactOutSwapExecuteArgs, buildV4SwapExecuteArgs } from './encodeSwap'\nimport { quoteSwapExactInViaRouter, quoteSwapExactOutViaRouter } from './quote'\nimport type { SwapExactInViaRouterParams, SwapExactOutViaRouterParams } from './types'\n\n/** Default swap deadline window (30 minutes) when no deadline is provided. */\nconst DEFAULT_DEADLINE_SECONDS = 1800n\n\n/**\n * Execute an exact-in spot swap via the Universal Router.\n *\n * @param params - Swap parameters.\n * @returns TxResult with hash + wait().\n *\n * @example\n * ```typescript\n * const result = await swapExactInViaRouter({\n * client, walletClient, account, poolAddress,\n * chainId: 1n,\n * tokenIn: ZERO_ADDRESS, // native ETH\n * amountIn: 10n ** 17n, // 0.1 ETH\n * slippageBps: 50n, // 0.5%\n * })\n * await result.wait()\n * ```\n */\nexport async function swapExactInViaRouter(params: SwapExactInViaRouterParams): Promise<TxResult> {\n const {\n client,\n walletClient,\n account,\n poolAddress,\n chainId,\n tokenIn,\n amountIn,\n slippageBps,\n deadline,\n recipient,\n txOverrides,\n addresses,\n } = params\n\n if (recipient !== undefined && !isAddressEqual(recipient, account)) {\n // The Universal Router pays the configured router recipient; routing output\n // to an arbitrary recipient requires an extra action not wired in v1.\n throw new PanopticError('Custom recipient is not supported yet; output goes to the sender')\n }\n\n const resolved = getUniswapV4Addresses(chainId, addresses)\n\n const quote = await quoteSwapExactInViaRouter({\n client,\n poolAddress,\n chainId,\n tokenIn,\n amountIn,\n slippageBps,\n addresses,\n })\n\n if (!quote.success) {\n throw quote.error\n }\n\n const resolvedDeadline =\n deadline ?? (await getBlockMeta({ client })).blockTimestamp + DEFAULT_DEADLINE_SECONDS\n\n const { args, value } = buildV4SwapExecuteArgs({\n poolKey: quote.data.poolKey,\n zeroForOne: quote.data.zeroForOne,\n amountIn,\n amountOutMinimum: quote.data.amountOutMinimum,\n tokenIn,\n tokenOut: quote.data.tokenOut,\n deadline: resolvedDeadline,\n recipient: account,\n })\n\n return submitWrite({\n client,\n walletClient,\n account,\n address: resolved.universalRouter,\n abi: universalRouterAbi,\n functionName: 'execute',\n args,\n value,\n txOverrides,\n })\n}\n\n/**\n * Execute an exact-in swap via the Universal Router and wait for confirmation.\n */\nexport async function swapExactInViaRouterAndWait(\n params: SwapExactInViaRouterParams,\n): Promise<TxReceipt> {\n const result = await swapExactInViaRouter(params)\n return result.wait()\n}\n\n/**\n * Execute an exact-out spot swap via the Universal Router.\n *\n * The caller specifies the exact `amountOut` to receive; the input (pay) amount\n * is quoted and capped at `amountInMaximum`. For native-ETH input the router is\n * funded with `amountInMaximum` and the unused surplus is swept back to the\n * sender.\n *\n * @param params - Swap parameters.\n * @returns TxResult with hash + wait().\n */\nexport async function swapExactOutViaRouter(\n params: SwapExactOutViaRouterParams,\n): Promise<TxResult> {\n const {\n client,\n walletClient,\n account,\n poolAddress,\n chainId,\n tokenIn,\n amountOut,\n slippageBps,\n deadline,\n recipient,\n txOverrides,\n addresses,\n } = params\n\n if (recipient !== undefined && !isAddressEqual(recipient, account)) {\n // The Universal Router pays the configured router recipient; routing output\n // to an arbitrary recipient requires an extra action not wired in v1.\n throw new PanopticError('Custom recipient is not supported yet; output goes to the sender')\n }\n\n const resolved = getUniswapV4Addresses(chainId, addresses)\n\n const quote = await quoteSwapExactOutViaRouter({\n client,\n poolAddress,\n chainId,\n tokenIn,\n amountOut,\n slippageBps,\n addresses,\n })\n\n if (!quote.success) {\n throw quote.error\n }\n\n const resolvedDeadline =\n deadline ?? (await getBlockMeta({ client })).blockTimestamp + DEFAULT_DEADLINE_SECONDS\n\n const { args, value } = buildV4ExactOutSwapExecuteArgs({\n poolKey: quote.data.poolKey,\n zeroForOne: quote.data.zeroForOne,\n amountOut,\n amountInMaximum: quote.data.amountInMaximum,\n tokenIn,\n tokenOut: quote.data.tokenOut,\n deadline: resolvedDeadline,\n recipient: account,\n })\n\n return submitWrite({\n client,\n walletClient,\n account,\n address: resolved.universalRouter,\n abi: universalRouterAbi,\n functionName: 'execute',\n args,\n value,\n txOverrides,\n })\n}\n\n/**\n * Execute an exact-out swap via the Universal Router and wait for confirmation.\n */\nexport async function swapExactOutViaRouterAndWait(\n params: SwapExactOutViaRouterParams,\n): Promise<TxReceipt> {\n const result = await swapExactOutViaRouter(params)\n return result.wait()\n}\n"],"mappings":";;;;;;;;AAkBA,IAAa,wBAAb,cAA2C,cAAc;CACvD,AAAkB,OAAO;CAEzB,YACkBA,SAChBC,OACA;AACA,SAAO,6CAA6C,QAAQ,GAAG,MAAM;EA8DxE,KAjEmB;CAIjB;AACF;;;;AAKD,IAAa,wBAAb,cAA2C,cAAc;CACvD,AAAkB,OAAO;CAEzB,YACkBC,OACAC,WACAC,WAChBH,OACA;AACA,SACG,QAAQ,MAAM,sCAAsC,UAAU,cAAc,UAAU,IACvF,MACD;EA2CH,KAnDkB;EAmDjB,KAlDiB;EAkDhB,KAjDgB;CAOjB;AACF;;;;AAKD,IAAa,4BAAb,cAA+C,cAAc;CAC3D,AAAkB,OAAO;CAEzB,YACkBI,QAChBJ,OACA;AACA,SAAO,SAAS,OAAO,2BAA2B,MAAM;EA6BvD,KAhCe;CAIjB;AACF;;;;;AAMD,IAAa,6BAAb,cAAgD,cAAc;CAC5D,AAAkB,OAAO;CAEzB,YAAYA,OAAe;AACzB,QAAM,gEAAgE,MAAM;CAC7E;AACF;;;;AAKD,IAAa,yBAAb,cAA4C,cAAc;CACxD,AAAkB,OAAO;CAEzB,YACkBD,SAChBC,OACA;AACA,SAAO,iCAAiC,QAAQ,GAAG,MAAM;EAGvD,KANc;CAIjB;AACF;;;;;;;ACtDD,MAAaK,kBAA2B;;;;;;;;AASxC,MAAaC,uBAA2D,EAEtE,GAAG;CACD,iBAAiB;CACjB,UAAU;CACV,aAAa;CACb,SAAS;AACV,EACF;;;;;;;;;;AAWD,SAAgB,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AAS;EAClB,KAAK;EACL,cAAc;EACd;EACA;EACA;CACD,EAAC;AACH;;;;AAKD,eAAsB,6BACpBA,QACoB;CACpB,MAAM,SAAS,MAAM,sBAAsB,OAAO;AAClD,QAAO,OAAO,MAAM;AACrB"}
1
+ {"version":3,"file":"router-qZEEc47U.js","names":["chainId: bigint","cause?: Error","token: Address","currency0: Address","currency1: Address","amount: bigint","PERMIT2_ADDRESS: Address","UNISWAP_V4_ADDRESSES: Record<number, UniswapV4Addresses>","chainId: bigint","overrides?: Partial<UniswapV4Addresses>","merged: Partial<UniswapV4Addresses>","UINT128_MAX","amount: bigint","recipient: Address","tokenOut: Address","recipient: Address | undefined","nativeAmount: bigint","erc20Amount: bigint","args: BuildV4SwapCalldataArgs","args: BuildV4ExactOutSwapCalldataArgs","commandList: number[]","inputs: Hex[]","params: CheckRouterApprovalParams","params: ApproveErc20ForPermit2Params","params: ApproveRouterViaPermit2Params","params: ResolveSwapRouteParams","slippageBps: bigint","params: QuoteSwapExactInViaRouterParams","params: QuoteSwapExactOutViaRouterParams","params: SwapExactInViaRouterParams","params: SwapExactOutViaRouterParams"],"sources":["../src/uniswap/v4/router/errors.ts","../src/uniswap/v4/addresses.ts","../src/uniswap/v4/abis/universalRouter.ts","../src/uniswap/v4/router/encodeSwap.ts","../src/uniswap/v4/abis/permit2.ts","../src/uniswap/v4/router/permit2.ts","../src/uniswap/v4/abis/v4Quoter.ts","../src/uniswap/v4/router/resolvePoolKey.ts","../src/uniswap/v4/router/quote.ts","../src/uniswap/v4/router/swap.ts"],"sourcesContent":["/**\n * Errors for the Uniswap v4 Universal Router swap module.\n *\n * All extend {@link PanopticError} so callers can keep a single\n * `instanceof PanopticError` check and so they satisfy `SimulationResult`'s\n * error type.\n *\n * @module uniswap/v4/router/errors\n */\n\nimport type { Address } from 'viem'\n\nimport { PanopticError } from '../../../panoptic/v2/errors'\n\n/**\n * The chain has no configured Uniswap v4 addresses and none were supplied via\n * overrides.\n */\nexport class UnsupportedChainError extends PanopticError {\n override readonly name = 'UnsupportedChainError'\n\n constructor(\n public readonly chainId: bigint,\n cause?: Error,\n ) {\n super(`Uniswap v4 router not configured for chain ${chainId}`, cause)\n }\n}\n\n/**\n * `tokenIn` is neither `currency0` nor `currency1` of the resolved pool.\n */\nexport class InvalidSwapTokenError extends PanopticError {\n override readonly name = 'InvalidSwapTokenError'\n\n constructor(\n public readonly token: Address,\n public readonly currency0: Address,\n public readonly currency1: Address,\n cause?: Error,\n ) {\n super(\n `Token ${token} is not part of the pool (currency0=${currency0}, currency1=${currency1})`,\n cause,\n )\n }\n}\n\n/**\n * An amount exceeds the uint128 range required by the v4 swap encoding.\n */\nexport class AmountExceedsUint128Error extends PanopticError {\n override readonly name = 'AmountExceedsUint128Error'\n\n constructor(\n public readonly amount: bigint,\n cause?: Error,\n ) {\n super(`Amount ${amount} exceeds uint128 maximum`, cause)\n }\n}\n\n/**\n * A native-ETH swap needs a trailing Universal Router SWEEP to deliver the ETH\n * output (or refund the input overpay), but no `recipient` was supplied.\n */\nexport class MissingSweepRecipientError extends PanopticError {\n override readonly name = 'MissingSweepRecipientError'\n\n constructor(cause?: Error) {\n super('A recipient is required to sweep native ETH back to the user', cause)\n }\n}\n\n/**\n * The V4Quoter is not available for the chain (no fallback in v1).\n */\nexport class QuoterUnavailableError extends PanopticError {\n override readonly name = 'QuoterUnavailableError'\n\n constructor(\n public readonly chainId: bigint,\n cause?: Error,\n ) {\n super(`V4Quoter unavailable for chain ${chainId}`, cause)\n }\n}\n","/**\n * Per-chain Uniswap v4 infrastructure addresses (Universal Router, V4Quoter,\n * PoolManager, Permit2).\n *\n * v1 supports mainnet only; other chains throw {@link UnsupportedChainError}\n * unless every address is supplied via the `overrides` argument (e.g. anvil\n * fork tests, or bots targeting a not-yet-listed chain).\n *\n * @module uniswap/v4/addresses\n */\n\nimport type { Address } from 'viem'\n\nimport { UnsupportedChainError } from './router/errors'\n\n/**\n * Uniswap v4 contract addresses required for a Universal Router spot swap.\n */\nexport interface UniswapV4Addresses {\n /** Universal Router (v4-capable build) — entrypoint for `execute(...)`. */\n universalRouter: Address\n /** V4Quoter — `quoteExactInputSingle` (revert/staticcall-based). */\n v4Quoter: Address\n /** Uniswap v4 PoolManager (singleton). */\n poolManager: Address\n /** Canonical Permit2 (same address on every chain). */\n permit2: Address\n}\n\n/**\n * Canonical Permit2, identical across all chains.\n */\nexport const PERMIT2_ADDRESS: Address = '0x000000000022D473030F116dDEE9F6B43aC78BA3'\n\n/**\n * Verified Uniswap v4 deployment addresses keyed by chainId.\n *\n * Sourced from the official Uniswap v4 deployments. Add a chain here only after\n * verifying each address against the canonical Uniswap deployment listing —\n * Universal Router in particular is NOT the same address across chains.\n */\nexport const UNISWAP_V4_ADDRESSES: Record<number, UniswapV4Addresses> = {\n // Ethereum mainnet\n 1: {\n universalRouter: '0x66a9893cC07D91D95644AEDD05D03f95e1dBA8Af',\n v4Quoter: '0x52F0E24D1c21C8A0cB1e5a5dD6198556BD9E1203',\n poolManager: '0x000000000004444c5dc75cB358380D2e3dE08A90',\n permit2: PERMIT2_ADDRESS,\n },\n}\n\n/**\n * Resolve the Uniswap v4 addresses for a chain, applying optional overrides.\n *\n * @param chainId - Target chain ID.\n * @param overrides - Partial override of any address (e.g. for fork tests).\n * @returns Fully-resolved {@link UniswapV4Addresses}.\n * @throws {UnsupportedChainError} when the chain is not listed and the\n * overrides do not supply every required address.\n */\nexport function getUniswapV4Addresses(\n chainId: bigint,\n overrides?: Partial<UniswapV4Addresses>,\n): UniswapV4Addresses {\n const base = UNISWAP_V4_ADDRESSES[Number(chainId)]\n\n const merged: Partial<UniswapV4Addresses> = {\n ...base,\n ...overrides,\n permit2: overrides?.permit2 ?? base?.permit2 ?? PERMIT2_ADDRESS,\n }\n\n if (\n merged.universalRouter === undefined ||\n merged.v4Quoter === undefined ||\n merged.poolManager === undefined ||\n merged.permit2 === undefined\n ) {\n throw new UnsupportedChainError(chainId)\n }\n\n return merged as UniswapV4Addresses\n}\n","/**\n * Minimal Universal Router ABI (only the `execute` overload we use).\n * @module uniswap/v4/abis/universalRouter\n */\n\nexport const universalRouterAbi = [\n {\n type: 'function',\n name: 'execute',\n stateMutability: 'payable',\n inputs: [\n { name: 'commands', type: 'bytes' },\n { name: 'inputs', type: 'bytes[]' },\n { name: 'deadline', type: 'uint256' },\n ],\n outputs: [],\n },\n] as const\n","/**\n * Pure calldata builders for exact-in and exact-out single-hop swaps via the\n * Uniswap v4 Universal Router.\n *\n * Opcodes verified against `@uniswap/universal-router` `Commands.sol` and\n * `@uniswap/v4-periphery` `Actions.sol`:\n * - Universal Router commands `V4_SWAP = 0x10`, `SWEEP = 0x04`.\n * - v4 actions `SWAP_EXACT_IN_SINGLE = 0x06`, `SWAP_EXACT_OUT_SINGLE = 0x08`,\n * `SETTLE_ALL = 0x0c`, `TAKE = 0x0e`, `TAKE_ALL = 0x0f`.\n *\n * Native ETH is `address(0)` in the PoolKey and needs special handling per side:\n * - Native-ETH OUTPUT: the implicit-recipient `TAKE_ALL` leaves the bought ETH\n * held by the Universal Router, so output is taken with the explicit-recipient\n * `TAKE` action instead, delivering ETH straight to the recipient. No trailing\n * SWEEP is appended for native output.\n * - Native-ETH INPUT on exact-out: the router is funded with the full\n * `amountInMaximum` overpay, so a trailing Universal-Router-level `SWEEP`\n * command (NOT the v4 SWEEP action, which this router does not support) refunds\n * the unused ETH to the recipient.\n * Native-ETH input on exact-in needs neither (msg.value equals the exact input;\n * ERC20 output is delivered by `TAKE_ALL`).\n *\n * @module uniswap/v4/router/encodeSwap\n */\n\nimport type { Address, Hex } from 'viem'\nimport { encodeAbiParameters, encodeFunctionData, encodePacked, zeroAddress } from 'viem'\n\nimport type { PoolKey } from '../../../panoptic/v2/types'\nimport { universalRouterAbi } from '../abis/universalRouter'\nimport { AmountExceedsUint128Error, MissingSweepRecipientError } from './errors'\n\n/** Universal Router command byte for a v4 swap. */\nexport const V4_SWAP = 0x10\n/** v4 action: exact-in single-hop swap. */\nexport const SWAP_EXACT_IN_SINGLE = 0x06\n/** v4 action: pay all of the input currency owed. */\nexport const SETTLE_ALL = 0x0c\n/** v4 action: take all of the output currency owed. */\nexport const TAKE_ALL = 0x0f\n/** v4 action: take an output currency to an explicit recipient. */\nexport const TAKE = 0x0e\n/** v4 action: exact-out single-hop swap. */\nexport const SWAP_EXACT_OUT_SINGLE = 0x08\n/** Universal Router command: sweep the router's token balance to a recipient. */\nexport const SWEEP = 0x04\n\n/** v4 sentinel: take the full positive currency delta (used with TAKE). */\nconst OPEN_DELTA = 0n\n\nconst UINT128_MAX = (1n << 128n) - 1n\n\nconst poolKeyComponents = [\n { name: 'currency0', type: 'address' },\n { name: 'currency1', type: 'address' },\n { name: 'fee', type: 'uint24' },\n { name: 'tickSpacing', type: 'int24' },\n { name: 'hooks', type: 'address' },\n] as const\n\nconst exactInputSingleParamsAbi = [\n {\n type: 'tuple',\n components: [\n { name: 'poolKey', type: 'tuple', components: poolKeyComponents },\n { name: 'zeroForOne', type: 'bool' },\n { name: 'amountIn', type: 'uint128' },\n { name: 'amountOutMinimum', type: 'uint128' },\n { name: 'hookData', type: 'bytes' },\n ],\n },\n] as const\n\nconst exactOutputSingleParamsAbi = [\n {\n type: 'tuple',\n components: [\n { name: 'poolKey', type: 'tuple', components: poolKeyComponents },\n { name: 'zeroForOne', type: 'bool' },\n { name: 'amountOut', type: 'uint128' },\n { name: 'amountInMaximum', type: 'uint128' },\n { name: 'hookData', type: 'bytes' },\n ],\n },\n] as const\n\nconst currencyAmountAbi = [\n { name: 'currency', type: 'address' },\n { name: 'amount', type: 'uint256' },\n] as const\n\n// v4 TAKE action params: take `amount` of `currency` to an explicit recipient.\nconst takeToRecipientAbi = [\n { name: 'currency', type: 'address' },\n { name: 'recipient', type: 'address' },\n { name: 'amount', type: 'uint256' },\n] as const\n\n// Universal Router SWEEP command params: forward `token` above `amountMin` to\n// `recipient`.\nconst sweepParamsAbi = [\n { name: 'token', type: 'address' },\n { name: 'recipient', type: 'address' },\n { name: 'amountMin', type: 'uint256' },\n] as const\n\nfunction assertUint128(amount: bigint): void {\n if (amount < 0n || amount > UINT128_MAX) {\n throw new AmountExceedsUint128Error(amount)\n }\n}\n\n/**\n * Encode the input for a Universal Router `SWEEP` command that forwards the\n * router's full native-ETH balance (above `amountMin = 0`) to `recipient`.\n */\nfunction encodeEthSweepInput(recipient: Address): Hex {\n return encodeAbiParameters(sweepParamsAbi, [zeroAddress, recipient, 0n])\n}\n\n/**\n * Build the output-take v4 action byte + param.\n *\n * Native-ETH output is taken with the explicit-recipient `TAKE` action so the\n * router forwards the ETH straight to `recipient` (the implicit-`msgSender`\n * `TAKE_ALL` leaves native ETH held by the router). ERC20 output uses\n * `TAKE_ALL`, which already credits the caller.\n *\n * @param nativeAmount - TAKE amount for native-ETH output: `OPEN_DELTA` (0) to\n * take the full credit (exact-in, protected by the swap's min) or the exact\n * output (exact-out).\n * @param erc20Amount - TAKE_ALL min/amount for ERC20 output: `amountOutMinimum`\n * (exact-in) or the exact output (exact-out).\n */\nfunction buildOutputTake(\n tokenOut: Address,\n recipient: Address | undefined,\n nativeAmount: bigint,\n erc20Amount: bigint,\n): { action: number; param: Hex } {\n if (tokenOut === zeroAddress) {\n if (recipient === undefined) {\n throw new MissingSweepRecipientError()\n }\n return {\n action: TAKE,\n param: encodeAbiParameters(takeToRecipientAbi, [zeroAddress, recipient, nativeAmount]),\n }\n }\n return {\n action: TAKE_ALL,\n param: encodeAbiParameters(currencyAmountAbi, [tokenOut, erc20Amount]),\n }\n}\n\n/**\n * Arguments for {@link buildV4SwapExecuteCalldata}.\n */\nexport interface BuildV4SwapCalldataArgs {\n /** The v4 PoolKey (currency0, currency1, fee, tickSpacing, hooks). */\n poolKey: PoolKey\n /** Whether the swap goes currency0 → currency1. */\n zeroForOne: boolean\n /** Exact input amount (uint128). */\n amountIn: bigint\n /** Minimum acceptable output (uint128). */\n amountOutMinimum: bigint\n /** Input token address (`address(0)` for native ETH). */\n tokenIn: Address\n /** Output token address (`address(0)` for native ETH). */\n tokenOut: Address\n /** Absolute deadline (unix seconds). */\n deadline: bigint\n /**\n * Recipient of native-ETH output. Required when `tokenOut` is `address(0)`,\n * since the explicit-recipient `TAKE` action forwards the bought ETH there\n * (the implicit-recipient `TAKE_ALL` would leave it held by the router).\n */\n recipient?: Address\n /** Hook data; defaults to `0x` (hook-less pools). */\n hookData?: Hex\n}\n\n/**\n * Build the typed `execute(...)` args + msg.value for an exact-in single-hop v4\n * swap. Use this when submitting via viem (`writeContract` / `submitWrite`).\n *\n * When `tokenOut` is native ETH the explicit-recipient `TAKE` action forwards\n * the bought ETH to `recipient` (no trailing SWEEP is needed for exact-in).\n *\n * @returns `args` ready to spread into `execute` and the ETH `value` to send\n * (= `amountIn` for native-ETH input, otherwise `0n`).\n */\nexport function buildV4SwapExecuteArgs(args: BuildV4SwapCalldataArgs): {\n args: readonly [Hex, readonly Hex[], bigint]\n value: bigint\n} {\n const {\n poolKey,\n zeroForOne,\n amountIn,\n amountOutMinimum,\n tokenIn,\n tokenOut,\n deadline,\n recipient,\n hookData = '0x',\n } = args\n\n assertUint128(amountIn)\n assertUint128(amountOutMinimum)\n\n const swapParam = encodeAbiParameters(exactInputSingleParamsAbi, [\n {\n poolKey: {\n currency0: poolKey.currency0,\n currency1: poolKey.currency1,\n fee: Number(poolKey.fee),\n tickSpacing: Number(poolKey.tickSpacing),\n hooks: poolKey.hooks,\n },\n zeroForOne,\n amountIn,\n amountOutMinimum,\n hookData,\n },\n ])\n\n // SETTLE_ALL pays the input; the output take credits the recipient. Native-ETH\n // output uses the explicit-recipient TAKE so the router forwards the ETH (with\n // OPEN_DELTA to take the full, slippage-protected swap output).\n const settleParam = encodeAbiParameters(currencyAmountAbi, [tokenIn, amountIn])\n const take = buildOutputTake(tokenOut, recipient, OPEN_DELTA, amountOutMinimum)\n\n const actions = encodePacked(\n ['uint8', 'uint8', 'uint8'],\n [SWAP_EXACT_IN_SINGLE, SETTLE_ALL, take.action],\n )\n\n const v4Input = encodeAbiParameters(\n [\n { name: 'actions', type: 'bytes' },\n { name: 'params', type: 'bytes[]' },\n ],\n [actions, [swapParam, settleParam, take.param]],\n )\n\n // Native-ETH input on exact-in needs no SWEEP (msg.value equals the exact input).\n const commands = encodePacked(['uint8'], [V4_SWAP])\n const value = tokenIn === zeroAddress ? amountIn : 0n\n\n return { args: [commands, [v4Input], deadline] as const, value }\n}\n\n/**\n * Build the `execute(commands, inputs, deadline)` calldata + msg.value for an\n * exact-in single-hop v4 swap.\n *\n * @returns The encoded calldata and the ETH `value` to send.\n */\nexport function buildV4SwapExecuteCalldata(args: BuildV4SwapCalldataArgs): {\n data: Hex\n value: bigint\n} {\n const { args: executeArgs, value } = buildV4SwapExecuteArgs(args)\n const data = encodeFunctionData({\n abi: universalRouterAbi,\n functionName: 'execute',\n args: executeArgs,\n })\n return { data, value }\n}\n\n/**\n * Arguments for {@link buildV4ExactOutSwapExecuteCalldata}.\n */\nexport interface BuildV4ExactOutSwapCalldataArgs {\n /** The v4 PoolKey (currency0, currency1, fee, tickSpacing, hooks). */\n poolKey: PoolKey\n /** Whether the swap goes currency0 → currency1. */\n zeroForOne: boolean\n /** Exact output amount to receive (uint128). */\n amountOut: bigint\n /** Maximum acceptable input to spend (uint128). */\n amountInMaximum: bigint\n /** Input token address (`address(0)` for native ETH). */\n tokenIn: Address\n /** Output token address (`address(0)` for native ETH). */\n tokenOut: Address\n /** Absolute deadline (unix seconds). */\n deadline: bigint\n /**\n * Recipient of any swept native-ETH refund (only used for native-ETH input).\n * Must be the payer; the leftover `amountInMaximum - actualInput` is returned\n * here.\n */\n recipient: Address\n /** Hook data; defaults to `0x` (hook-less pools). */\n hookData?: Hex\n}\n\n/**\n * Build the typed `execute(...)` args + msg.value for an exact-out single-hop v4\n * swap. Use this when submitting via viem (`writeContract` / `submitWrite`).\n *\n * For native-ETH input, `value` is `amountInMaximum` (an overpay) and a trailing\n * `SWEEP` action refunds the unused ETH to `recipient`. For ERC20 input, Permit2\n * pulls only the settled amount, so no SWEEP is appended and `value` is `0n`.\n *\n * @returns `args` ready to spread into `execute` and the ETH `value` to send.\n */\nexport function buildV4ExactOutSwapExecuteArgs(args: BuildV4ExactOutSwapCalldataArgs): {\n args: readonly [Hex, readonly Hex[], bigint]\n value: bigint\n} {\n const {\n poolKey,\n zeroForOne,\n amountOut,\n amountInMaximum,\n tokenIn,\n tokenOut,\n deadline,\n recipient,\n hookData = '0x',\n } = args\n\n assertUint128(amountOut)\n assertUint128(amountInMaximum)\n\n const swapParam = encodeAbiParameters(exactOutputSingleParamsAbi, [\n {\n poolKey: {\n currency0: poolKey.currency0,\n currency1: poolKey.currency1,\n fee: Number(poolKey.fee),\n tickSpacing: Number(poolKey.tickSpacing),\n hooks: poolKey.hooks,\n },\n zeroForOne,\n amountOut,\n amountInMaximum,\n hookData,\n },\n ])\n\n // SETTLE_ALL caps the input at amountInMaximum; the output take delivers the\n // exact output. Native-ETH output uses the explicit-recipient TAKE so the\n // router forwards the ETH straight to `recipient`.\n const settleParam = encodeAbiParameters(currencyAmountAbi, [tokenIn, amountInMaximum])\n const take = buildOutputTake(tokenOut, recipient, amountOut, amountOut)\n\n const actions = encodePacked(\n ['uint8', 'uint8', 'uint8'],\n [SWAP_EXACT_OUT_SINGLE, SETTLE_ALL, take.action],\n )\n\n const v4Input = encodeAbiParameters(\n [\n { name: 'actions', type: 'bytes' },\n { name: 'params', type: 'bytes[]' },\n ],\n [actions, [swapParam, settleParam, take.param]],\n )\n\n const isNativeIn = tokenIn === zeroAddress\n\n // Native-ETH input funds the router with the full overpay cap; a trailing\n // Universal Router SWEEP command (the v4 SWEEP *action* is unsupported here)\n // refunds the unused ETH to the recipient.\n const commandList: number[] = [V4_SWAP]\n const inputs: Hex[] = [v4Input]\n if (isNativeIn) {\n commandList.push(SWEEP)\n inputs.push(encodeEthSweepInput(recipient))\n }\n\n const commands = encodePacked(\n commandList.map(() => 'uint8'),\n commandList,\n )\n const value = isNativeIn ? amountInMaximum : 0n\n\n return { args: [commands, inputs, deadline] as const, value }\n}\n\n/**\n * Build the `execute(commands, inputs, deadline)` calldata + msg.value for an\n * exact-out single-hop v4 swap.\n *\n * @returns The encoded calldata and the ETH `value` to send.\n */\nexport function buildV4ExactOutSwapExecuteCalldata(args: BuildV4ExactOutSwapCalldataArgs): {\n data: Hex\n value: bigint\n} {\n const { args: executeArgs, value } = buildV4ExactOutSwapExecuteArgs(args)\n const data = encodeFunctionData({\n abi: universalRouterAbi,\n functionName: 'execute',\n args: executeArgs,\n })\n return { data, value }\n}\n","/**\n * Minimal Permit2 ABI (`IAllowanceTransfer` subset: `approve` + `allowance`).\n * @module uniswap/v4/abis/permit2\n */\n\nexport const permit2Abi = [\n {\n type: 'function',\n name: 'approve',\n stateMutability: 'nonpayable',\n inputs: [\n { name: 'token', type: 'address' },\n { name: 'spender', type: 'address' },\n { name: 'amount', type: 'uint160' },\n { name: 'expiration', type: 'uint48' },\n ],\n outputs: [],\n },\n {\n type: 'function',\n name: 'allowance',\n stateMutability: 'view',\n inputs: [\n { name: 'user', type: 'address' },\n { name: 'token', type: 'address' },\n { name: 'spender', type: 'address' },\n ],\n outputs: [\n { name: 'amount', type: 'uint160' },\n { name: 'expiration', type: 'uint48' },\n { name: 'nonce', type: 'uint48' },\n ],\n },\n] as const\n","/**\n * Permit2 approval helpers for the Universal Router ERC20 input side.\n *\n * Two-step on-chain flow (only when `tokenIn` is an ERC20):\n * 1. ERC20 `approve(Permit2, amount)` — lets Permit2 pull the token.\n * 2. `Permit2.approve(token, universalRouter, amount, expiration)` — lets the\n * router spend via Permit2.\n *\n * Native ETH skips both steps.\n *\n * @module uniswap/v4/router/permit2\n */\n\nimport { erc20Abi, maxUint256 } from 'viem'\n\nimport { getBlockMeta } from '../../../panoptic/v2/clients'\nimport type { TxReceipt, TxResult } from '../../../panoptic/v2/types'\nimport { submitWrite } from '../../../panoptic/v2/writes'\nimport { permit2Abi } from '../abis/permit2'\nimport { getUniswapV4Addresses } from '../addresses'\nimport type {\n ApproveErc20ForPermit2Params,\n ApproveRouterViaPermit2Params,\n CheckRouterApprovalParams,\n RouterApprovalStatus,\n} from './types'\n\n/** uint160 max — the largest Permit2 allowance amount. */\nconst UINT160_MAX = (1n << 160n) - 1n\n/** Default Permit2 allowance expiration window (30 days). */\nconst DEFAULT_EXPIRATION_SECONDS = 2_592_000n\n/** uint48 max — the largest Permit2 expiration. */\nconst UINT48_MAX = (1n << 48n) - 1n\n\n/**\n * Check whether the ERC20 → Permit2 → Universal Router allowance chain is\n * sufficient for an exact-in swap of `amount`.\n */\nexport async function checkRouterApproval(\n params: CheckRouterApprovalParams,\n): Promise<RouterApprovalStatus> {\n const { client, chainId, tokenIn, owner, amount, addresses } = params\n const { permit2, universalRouter } = getUniswapV4Addresses(chainId, addresses)\n\n const [erc20Allowance, permit2Allowance, blockMeta] = await Promise.all([\n client.readContract({\n address: tokenIn,\n abi: erc20Abi,\n functionName: 'allowance',\n args: [owner, permit2],\n }),\n client.readContract({\n address: permit2,\n abi: permit2Abi,\n functionName: 'allowance',\n args: [owner, tokenIn, universalRouter],\n }),\n getBlockMeta({ client }),\n ])\n\n const [permit2Amount, permit2Expiration] = permit2Allowance\n\n const needsErc20Approval = erc20Allowance < amount\n const needsPermit2Approval =\n permit2Amount < amount || BigInt(permit2Expiration) <= blockMeta.blockTimestamp\n\n return {\n needsErc20Approval,\n needsPermit2Approval,\n erc20Allowance,\n permit2Amount,\n permit2Expiration: BigInt(permit2Expiration),\n }\n}\n\n/**\n * Step 1: approve the ERC20 token to Permit2 (defaults to unlimited).\n */\nexport async function approveErc20ForPermit2(\n params: ApproveErc20ForPermit2Params,\n): Promise<TxResult> {\n const {\n client,\n walletClient,\n account,\n chainId,\n tokenIn,\n amount = maxUint256,\n txOverrides,\n addresses,\n } = params\n const { permit2 } = getUniswapV4Addresses(chainId, addresses)\n\n return submitWrite({\n client,\n walletClient,\n account,\n address: tokenIn,\n abi: erc20Abi,\n functionName: 'approve',\n args: [permit2, amount],\n txOverrides,\n })\n}\n\n/**\n * Step 1 (and wait): approve the ERC20 token to Permit2.\n */\nexport async function approveErc20ForPermit2AndWait(\n params: ApproveErc20ForPermit2Params,\n): Promise<TxReceipt> {\n const result = await approveErc20ForPermit2(params)\n return result.wait()\n}\n\n/**\n * Step 2: approve the Universal Router as a Permit2 spender for the token.\n */\nexport async function approveRouterViaPermit2(\n params: ApproveRouterViaPermit2Params,\n): Promise<TxResult> {\n const {\n client,\n walletClient,\n account,\n chainId,\n tokenIn,\n amount = UINT160_MAX,\n expiration,\n txOverrides,\n addresses,\n } = params\n const { permit2, universalRouter } = getUniswapV4Addresses(chainId, addresses)\n\n const resolvedExpiration =\n expiration ?? (await getBlockMeta({ client })).blockTimestamp + DEFAULT_EXPIRATION_SECONDS\n const cappedExpiration = resolvedExpiration > UINT48_MAX ? UINT48_MAX : resolvedExpiration\n\n return submitWrite({\n client,\n walletClient,\n account,\n address: permit2,\n abi: permit2Abi,\n functionName: 'approve',\n args: [tokenIn, universalRouter, amount, cappedExpiration],\n txOverrides,\n })\n}\n\n/**\n * Step 2 (and wait): approve the Universal Router via Permit2.\n */\nexport async function approveRouterViaPermit2AndWait(\n params: ApproveRouterViaPermit2Params,\n): Promise<TxReceipt> {\n const result = await approveRouterViaPermit2(params)\n return result.wait()\n}\n","/**\n * Minimal V4Quoter ABI (`quoteExactInputSingle`, `quoteExactOutputSingle`).\n *\n * Note: neither function is `view` — they mutate state internally and are\n * intended to be called via `eth_call` / viem `simulateContract`, never\n * `readContract`.\n *\n * @module uniswap/v4/abis/v4Quoter\n */\n\nconst quoteExactSingleParams = {\n name: 'params',\n type: 'tuple',\n components: [\n {\n name: 'poolKey',\n type: 'tuple',\n components: [\n { name: 'currency0', type: 'address' },\n { name: 'currency1', type: 'address' },\n { name: 'fee', type: 'uint24' },\n { name: 'tickSpacing', type: 'int24' },\n { name: 'hooks', type: 'address' },\n ],\n },\n { name: 'zeroForOne', type: 'bool' },\n { name: 'exactAmount', type: 'uint128' },\n { name: 'hookData', type: 'bytes' },\n ],\n} as const\n\nexport const v4QuoterAbi = [\n {\n type: 'function',\n name: 'quoteExactInputSingle',\n stateMutability: 'nonpayable',\n inputs: [quoteExactSingleParams],\n outputs: [\n { name: 'amountOut', type: 'uint256' },\n { name: 'gasEstimate', type: 'uint256' },\n ],\n },\n {\n type: 'function',\n name: 'quoteExactOutputSingle',\n stateMutability: 'nonpayable',\n inputs: [quoteExactSingleParams],\n outputs: [\n { name: 'amountIn', type: 'uint256' },\n { name: 'gasEstimate', type: 'uint256' },\n ],\n },\n] as const\n","/**\n * Resolve the Uniswap v4 PoolKey + swap direction from a PanopticPool address.\n * @module uniswap/v4/router/resolvePoolKey\n */\n\nimport type { Address, PublicClient } from 'viem'\nimport { isAddressEqual } from 'viem'\n\nimport { getPool } from '../../../panoptic/v2/reads/pool'\nimport type { PoolKey } from '../../../panoptic/v2/types'\nimport { InvalidSwapTokenError } from './errors'\n\n/**\n * Resolved swap routing info for a given `tokenIn`.\n */\nexport interface ResolvedSwapRoute {\n /** Underlying v4 PoolKey. */\n poolKey: PoolKey\n /** Whether the swap goes currency0 → currency1. */\n zeroForOne: boolean\n /** Output token address. */\n tokenOut: Address\n /** Decimals of the output token. */\n tokenOutDecimals: bigint\n /** Symbol of the output token. */\n tokenOutSymbol: string\n}\n\n/**\n * Parameters for {@link resolveSwapRoute}.\n */\nexport interface ResolveSwapRouteParams {\n client: PublicClient\n poolAddress: Address\n chainId: bigint\n tokenIn: Address\n blockNumber?: bigint\n}\n\n/**\n * Resolve the PoolKey, swap direction, and output token metadata for a swap.\n *\n * @throws {InvalidSwapTokenError} when `tokenIn` is not part of the pool.\n */\nexport async function resolveSwapRoute(params: ResolveSwapRouteParams): Promise<ResolvedSwapRoute> {\n const { client, poolAddress, chainId, tokenIn, blockNumber } = params\n\n const pool = await getPool({ client, poolAddress, chainId, blockNumber })\n const { poolKey } = pool\n\n const isCurrency0 = isAddressEqual(tokenIn, poolKey.currency0)\n const isCurrency1 = isAddressEqual(tokenIn, poolKey.currency1)\n if (!isCurrency0 && !isCurrency1) {\n throw new InvalidSwapTokenError(tokenIn, poolKey.currency0, poolKey.currency1)\n }\n\n const zeroForOne = isCurrency0\n const tokenOut = zeroForOne ? poolKey.currency1 : poolKey.currency0\n const outTracker = zeroForOne ? pool.collateralTracker1 : pool.collateralTracker0\n\n return {\n poolKey,\n zeroForOne,\n tokenOut,\n tokenOutDecimals: outTracker.decimals,\n tokenOutSymbol: outTracker.symbol,\n }\n}\n","/**\n * Quote exact-in and exact-out swaps via the Uniswap v4 V4Quoter.\n * @module uniswap/v4/router/quote\n */\n\nimport { zeroAddress } from 'viem'\n\nimport { getBlockMeta } from '../../../panoptic/v2/clients'\nimport { PanopticError } from '../../../panoptic/v2/errors'\nimport type { SimulationResult } from '../../../panoptic/v2/types'\nimport { v4QuoterAbi } from '../abis/v4Quoter'\nimport { getUniswapV4Addresses } from '../addresses'\nimport { QuoterUnavailableError } from './errors'\nimport { resolveSwapRoute } from './resolvePoolKey'\nimport type {\n QuoteSwapExactInViaRouterParams,\n QuoteSwapExactOutViaRouterParams,\n SwapExactInQuote,\n SwapExactOutQuote,\n} from './types'\n\nconst BPS_DENOMINATOR = 10_000n\nconst UINT128_MAX = (1n << 128n) - 1n\n\n/** Reject out-of-range slippage so the min/max amount math can't underflow/overflow. */\nfunction assertSlippageBps(slippageBps: bigint): void {\n if (slippageBps < 0n || slippageBps > BPS_DENOMINATOR) {\n throw new PanopticError(`invalid slippageBps ${slippageBps}, must be 0..10000`)\n }\n}\n\nconst FALLBACK_META = {\n blockNumber: 0n,\n blockTimestamp: 0n,\n blockHash: '0x0' as `0x${string}`,\n}\n\n/**\n * Quote an exact-in spot swap against the underlying Uniswap v4 pool.\n *\n * Uses the V4Quoter `quoteExactInputSingle` via `eth_call` (the quoter is\n * state-mutating / revert-based, so it must be simulated, not read). Returns a\n * `SimulationResult` so failures carry a structured error rather than throwing.\n */\nexport async function quoteSwapExactInViaRouter(\n params: QuoteSwapExactInViaRouterParams,\n): Promise<SimulationResult<SwapExactInQuote>> {\n const { client, poolAddress, chainId, tokenIn, amountIn, slippageBps, blockNumber, addresses } =\n params\n\n try {\n if (amountIn < 0n || amountIn > UINT128_MAX) {\n throw new PanopticError(`amountIn ${amountIn} exceeds uint128 maximum`)\n }\n assertSlippageBps(slippageBps)\n\n const targetBlockNumber = blockNumber ?? (await client.getBlockNumber())\n const metaPromise = getBlockMeta({ client, blockNumber: targetBlockNumber })\n\n const { v4Quoter } = getUniswapV4Addresses(chainId, addresses)\n if (v4Quoter === zeroAddress) {\n throw new QuoterUnavailableError(chainId)\n }\n\n const route = await resolveSwapRoute({\n client,\n poolAddress,\n chainId,\n tokenIn,\n blockNumber: targetBlockNumber,\n })\n\n const { result } = await client.simulateContract({\n address: v4Quoter,\n abi: v4QuoterAbi,\n functionName: 'quoteExactInputSingle',\n blockNumber: targetBlockNumber,\n args: [\n {\n poolKey: {\n currency0: route.poolKey.currency0,\n currency1: route.poolKey.currency1,\n fee: Number(route.poolKey.fee),\n tickSpacing: Number(route.poolKey.tickSpacing),\n hooks: route.poolKey.hooks,\n },\n zeroForOne: route.zeroForOne,\n exactAmount: amountIn,\n hookData: '0x',\n },\n ],\n })\n\n const [amountOut, gasEstimate] = result\n const amountOutMinimum = (amountOut * (BPS_DENOMINATOR - slippageBps)) / BPS_DENOMINATOR\n\n const _meta = await metaPromise\n\n return {\n success: true,\n data: {\n amountOut,\n amountOutMinimum,\n zeroForOne: route.zeroForOne,\n tokenOut: route.tokenOut,\n poolKey: route.poolKey,\n gasEstimate,\n },\n gasEstimate,\n _meta,\n }\n } catch (error) {\n return {\n success: false,\n error:\n error instanceof PanopticError\n ? error\n : new PanopticError(\n error instanceof Error ? error.message : 'Quote failed',\n error instanceof Error ? error : undefined,\n ),\n _meta: FALLBACK_META,\n }\n }\n}\n\n/**\n * Quote an exact-out spot swap against the underlying Uniswap v4 pool.\n *\n * Uses the V4Quoter `quoteExactOutputSingle` via `eth_call` (the quoter is\n * state-mutating / revert-based, so it must be simulated, not read). Returns a\n * `SimulationResult` so failures carry a structured error rather than throwing.\n */\nexport async function quoteSwapExactOutViaRouter(\n params: QuoteSwapExactOutViaRouterParams,\n): Promise<SimulationResult<SwapExactOutQuote>> {\n const { client, poolAddress, chainId, tokenIn, amountOut, slippageBps, blockNumber, addresses } =\n params\n\n try {\n if (amountOut < 0n || amountOut > UINT128_MAX) {\n throw new PanopticError(`amountOut ${amountOut} exceeds uint128 maximum`)\n }\n assertSlippageBps(slippageBps)\n\n const targetBlockNumber = blockNumber ?? (await client.getBlockNumber())\n const metaPromise = getBlockMeta({ client, blockNumber: targetBlockNumber })\n\n const { v4Quoter } = getUniswapV4Addresses(chainId, addresses)\n if (v4Quoter === zeroAddress) {\n throw new QuoterUnavailableError(chainId)\n }\n\n const route = await resolveSwapRoute({\n client,\n poolAddress,\n chainId,\n tokenIn,\n blockNumber: targetBlockNumber,\n })\n\n const { result } = await client.simulateContract({\n address: v4Quoter,\n abi: v4QuoterAbi,\n functionName: 'quoteExactOutputSingle',\n blockNumber: targetBlockNumber,\n args: [\n {\n poolKey: {\n currency0: route.poolKey.currency0,\n currency1: route.poolKey.currency1,\n fee: Number(route.poolKey.fee),\n tickSpacing: Number(route.poolKey.tickSpacing),\n hooks: route.poolKey.hooks,\n },\n zeroForOne: route.zeroForOne,\n exactAmount: amountOut,\n hookData: '0x',\n },\n ],\n })\n\n const [amountIn, gasEstimate] = result\n // Ceiling division: never round the input cap down (would tighten the buffer).\n const amountInMaximum =\n (amountIn * (BPS_DENOMINATOR + slippageBps) + BPS_DENOMINATOR - 1n) / BPS_DENOMINATOR\n\n const _meta = await metaPromise\n\n return {\n success: true,\n data: {\n amountIn,\n amountInMaximum,\n zeroForOne: route.zeroForOne,\n tokenOut: route.tokenOut,\n poolKey: route.poolKey,\n gasEstimate,\n },\n gasEstimate,\n _meta,\n }\n } catch (error) {\n return {\n success: false,\n error:\n error instanceof PanopticError\n ? error\n : new PanopticError(\n error instanceof Error ? error.message : 'Quote failed',\n error instanceof Error ? error : undefined,\n ),\n _meta: FALLBACK_META,\n }\n }\n}\n","/**\n * Exact-in and exact-out spot swaps via the Uniswap v4 Universal Router.\n *\n * Swaps directly on the underlying Uniswap v4 pool, bypassing Panoptic (no SFPM,\n * no Panoptic LP fees, no pool collateral required). Native ETH (`address(0)`)\n * is supported via `msg.value` with no Permit2 approval.\n *\n * @module uniswap/v4/router/swap\n */\n\nimport { isAddressEqual } from 'viem'\n\nimport { getBlockMeta } from '../../../panoptic/v2/clients'\nimport { PanopticError } from '../../../panoptic/v2/errors'\nimport type { TxReceipt, TxResult } from '../../../panoptic/v2/types'\nimport { submitWrite } from '../../../panoptic/v2/writes'\nimport { universalRouterAbi } from '../abis/universalRouter'\nimport { getUniswapV4Addresses } from '../addresses'\nimport { buildV4ExactOutSwapExecuteArgs, buildV4SwapExecuteArgs } from './encodeSwap'\nimport { quoteSwapExactInViaRouter, quoteSwapExactOutViaRouter } from './quote'\nimport type { SwapExactInViaRouterParams, SwapExactOutViaRouterParams } from './types'\n\n/** Default swap deadline window (30 minutes) when no deadline is provided. */\nconst DEFAULT_DEADLINE_SECONDS = 1800n\n\n/**\n * Execute an exact-in spot swap via the Universal Router.\n *\n * @param params - Swap parameters.\n * @returns TxResult with hash + wait().\n *\n * @example\n * ```typescript\n * const result = await swapExactInViaRouter({\n * client, walletClient, account, poolAddress,\n * chainId: 1n,\n * tokenIn: ZERO_ADDRESS, // native ETH\n * amountIn: 10n ** 17n, // 0.1 ETH\n * slippageBps: 50n, // 0.5%\n * })\n * await result.wait()\n * ```\n */\nexport async function swapExactInViaRouter(params: SwapExactInViaRouterParams): Promise<TxResult> {\n const {\n client,\n walletClient,\n account,\n poolAddress,\n chainId,\n tokenIn,\n amountIn,\n slippageBps,\n deadline,\n recipient,\n txOverrides,\n addresses,\n } = params\n\n if (recipient !== undefined && !isAddressEqual(recipient, account)) {\n // The Universal Router pays the configured router recipient; routing output\n // to an arbitrary recipient requires an extra action not wired in v1.\n throw new PanopticError('Custom recipient is not supported yet; output goes to the sender')\n }\n\n const resolved = getUniswapV4Addresses(chainId, addresses)\n\n const quote = await quoteSwapExactInViaRouter({\n client,\n poolAddress,\n chainId,\n tokenIn,\n amountIn,\n slippageBps,\n addresses,\n })\n\n if (!quote.success) {\n throw quote.error\n }\n\n const resolvedDeadline =\n deadline ?? (await getBlockMeta({ client })).blockTimestamp + DEFAULT_DEADLINE_SECONDS\n\n const { args, value } = buildV4SwapExecuteArgs({\n poolKey: quote.data.poolKey,\n zeroForOne: quote.data.zeroForOne,\n amountIn,\n amountOutMinimum: quote.data.amountOutMinimum,\n tokenIn,\n tokenOut: quote.data.tokenOut,\n deadline: resolvedDeadline,\n recipient: account,\n })\n\n return submitWrite({\n client,\n walletClient,\n account,\n address: resolved.universalRouter,\n abi: universalRouterAbi,\n functionName: 'execute',\n args,\n value,\n txOverrides,\n })\n}\n\n/**\n * Execute an exact-in swap via the Universal Router and wait for confirmation.\n */\nexport async function swapExactInViaRouterAndWait(\n params: SwapExactInViaRouterParams,\n): Promise<TxReceipt> {\n const result = await swapExactInViaRouter(params)\n return result.wait()\n}\n\n/**\n * Execute an exact-out spot swap via the Universal Router.\n *\n * The caller specifies the exact `amountOut` to receive; the input (pay) amount\n * is quoted and capped at `amountInMaximum`. For native-ETH input the router is\n * funded with `amountInMaximum` and the unused surplus is swept back to the\n * sender.\n *\n * @param params - Swap parameters.\n * @returns TxResult with hash + wait().\n */\nexport async function swapExactOutViaRouter(\n params: SwapExactOutViaRouterParams,\n): Promise<TxResult> {\n const {\n client,\n walletClient,\n account,\n poolAddress,\n chainId,\n tokenIn,\n amountOut,\n slippageBps,\n deadline,\n recipient,\n txOverrides,\n addresses,\n } = params\n\n if (recipient !== undefined && !isAddressEqual(recipient, account)) {\n // The Universal Router pays the configured router recipient; routing output\n // to an arbitrary recipient requires an extra action not wired in v1.\n throw new PanopticError('Custom recipient is not supported yet; output goes to the sender')\n }\n\n const resolved = getUniswapV4Addresses(chainId, addresses)\n\n const quote = await quoteSwapExactOutViaRouter({\n client,\n poolAddress,\n chainId,\n tokenIn,\n amountOut,\n slippageBps,\n addresses,\n })\n\n if (!quote.success) {\n throw quote.error\n }\n\n const resolvedDeadline =\n deadline ?? (await getBlockMeta({ client })).blockTimestamp + DEFAULT_DEADLINE_SECONDS\n\n const { args, value } = buildV4ExactOutSwapExecuteArgs({\n poolKey: quote.data.poolKey,\n zeroForOne: quote.data.zeroForOne,\n amountOut,\n amountInMaximum: quote.data.amountInMaximum,\n tokenIn,\n tokenOut: quote.data.tokenOut,\n deadline: resolvedDeadline,\n recipient: account,\n })\n\n return submitWrite({\n client,\n walletClient,\n account,\n address: resolved.universalRouter,\n abi: universalRouterAbi,\n functionName: 'execute',\n args,\n value,\n txOverrides,\n })\n}\n\n/**\n * Execute an exact-out swap via the Universal Router and wait for confirmation.\n */\nexport async function swapExactOutViaRouterAndWait(\n params: SwapExactOutViaRouterParams,\n): Promise<TxReceipt> {\n const result = await swapExactOutViaRouter(params)\n return result.wait()\n}\n"],"mappings":";;;;;;;;AAkBA,IAAa,wBAAb,cAA2C,cAAc;CACvD,AAAkB,OAAO;CAEzB,YACkBA,SAChBC,OACA;AACA,SAAO,6CAA6C,QAAQ,GAAG,MAAM;EA8DxE,KAjEmB;CAIjB;AACF;;;;AAKD,IAAa,wBAAb,cAA2C,cAAc;CACvD,AAAkB,OAAO;CAEzB,YACkBC,OACAC,WACAC,WAChBH,OACA;AACA,SACG,QAAQ,MAAM,sCAAsC,UAAU,cAAc,UAAU,IACvF,MACD;EA2CH,KAnDkB;EAmDjB,KAlDiB;EAkDhB,KAjDgB;CAOjB;AACF;;;;AAKD,IAAa,4BAAb,cAA+C,cAAc;CAC3D,AAAkB,OAAO;CAEzB,YACkBI,QAChBJ,OACA;AACA,SAAO,SAAS,OAAO,2BAA2B,MAAM;EA6BvD,KAhCe;CAIjB;AACF;;;;;AAMD,IAAa,6BAAb,cAAgD,cAAc;CAC5D,AAAkB,OAAO;CAEzB,YAAYA,OAAe;AACzB,QAAM,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,QACT,OAAM,MAAM;CAGd,MAAM,mBACJ,aAAa,MAAM,aAAa,EAAE,OAAQ,EAAC,EAAE,iBAAiB;CAEhE,MAAM,EAAE,MAAM,OAAO,GAAG,+BAA+B;EACrD,SAAS,MAAM,KAAK;EACpB,YAAY,MAAM,KAAK;EACvB;EACA,iBAAiB,MAAM,KAAK;EAC5B;EACA,UAAU,MAAM,KAAK;EACrB,UAAU;EACV,WAAW;CACZ,EAAC;AAEF,QAAO,YAAY;EACjB;EACA;EACA;EACA,SAAS,SAAS;EAClB,KAAK;EACL,cAAc;EACd;EACA;EACA;CACD,EAAC;AACH;;;;AAKD,eAAsB,6BACpBA,QACoB;CACpB,MAAM,SAAS,MAAM,sBAAsB,OAAO;AAClD,QAAO,OAAO,MAAM;AACrB"}
@@ -1,5 +1,5 @@
1
- import "../position-xJ_rnVZ0.js";
2
- import "../writes-D8AayW_8.js";
3
- import { AmountExceedsUint128Error, InvalidSwapTokenError, MissingSweepRecipientError, PERMIT2_ADDRESS, QuoterUnavailableError, SETTLE_ALL, SWAP_EXACT_IN_SINGLE, SWAP_EXACT_OUT_SINGLE, SWEEP, TAKE_ALL, UNISWAP_V4_ADDRESSES, UnsupportedChainError, V4_SWAP, approveErc20ForPermit2, approveErc20ForPermit2AndWait, approveRouterViaPermit2, approveRouterViaPermit2AndWait, buildV4ExactOutSwapExecuteArgs, buildV4ExactOutSwapExecuteCalldata, buildV4SwapExecuteArgs, buildV4SwapExecuteCalldata, checkRouterApproval, getUniswapV4Addresses, quoteSwapExactInViaRouter, quoteSwapExactOutViaRouter, resolveSwapRoute, swapExactInViaRouter, swapExactInViaRouterAndWait, swapExactOutViaRouter, swapExactOutViaRouterAndWait } from "../router-B6Or2RvX.js";
1
+ import "../position-Bo7y8jcj.js";
2
+ import "../writes-DQ-H14sj.js";
3
+ import { AmountExceedsUint128Error, InvalidSwapTokenError, MissingSweepRecipientError, PERMIT2_ADDRESS, QuoterUnavailableError, SETTLE_ALL, SWAP_EXACT_IN_SINGLE, SWAP_EXACT_OUT_SINGLE, SWEEP, TAKE_ALL, UNISWAP_V4_ADDRESSES, UnsupportedChainError, V4_SWAP, approveErc20ForPermit2, approveErc20ForPermit2AndWait, approveRouterViaPermit2, approveRouterViaPermit2AndWait, buildV4ExactOutSwapExecuteArgs, buildV4ExactOutSwapExecuteCalldata, buildV4SwapExecuteArgs, buildV4SwapExecuteCalldata, checkRouterApproval, getUniswapV4Addresses, quoteSwapExactInViaRouter, quoteSwapExactOutViaRouter, resolveSwapRoute, swapExactInViaRouter, swapExactInViaRouterAndWait, swapExactOutViaRouter, swapExactOutViaRouterAndWait } from "../router-qZEEc47U.js";
4
4
 
5
5
  export { AmountExceedsUint128Error, InvalidSwapTokenError, MissingSweepRecipientError, PERMIT2_ADDRESS, QuoterUnavailableError, SETTLE_ALL, SWAP_EXACT_IN_SINGLE, SWAP_EXACT_OUT_SINGLE, SWEEP, TAKE_ALL, UNISWAP_V4_ADDRESSES, UnsupportedChainError, V4_SWAP, approveErc20ForPermit2, approveErc20ForPermit2AndWait, approveRouterViaPermit2, approveRouterViaPermit2AndWait, buildV4ExactOutSwapExecuteArgs, buildV4ExactOutSwapExecuteCalldata, buildV4SwapExecuteArgs, buildV4SwapExecuteCalldata, checkRouterApproval, getUniswapV4Addresses, quoteSwapExactInViaRouter, quoteSwapExactOutViaRouter, resolveSwapRoute, swapExactInViaRouter, swapExactInViaRouterAndWait, swapExactOutViaRouter, swapExactOutViaRouterAndWait };
@@ -1,4 +1,4 @@
1
- import { BatchValidationError, DEFAULT_VEGOID, InputListFailError, InvalidTickLimitsError, InvalidTokenIdParameterError, LEG_BITS, LEG_LIMITS, LEG_MASKS, LoanSlotExhaustedError, MaxRetriesExceededError, MissingPositionIdsError, NoLoanPositionsError, OracleRateLimitedError, PanopticError$1 as PanopticError, ProviderLagError, REORG_DEPTH, SCHEMA_VERSION, STORAGE_PREFIX, STRIKE_CONVERSION_FACTOR, SafeModeError, StaleDataError, SwapTokenMismatchError, SyncTimeoutError, TOKEN_ID_BITS, UnhealthyPoolError, calculatePositionGreeks, collateralTrackerV2Abi, createTxResult, decodeLeftRightUnsigned, getBlockMeta, getPool$1 as getPool, getPoolMetadata$1 as getPoolMetadata, getPositions, panopticErrorsAbi, panopticFactoryV3Abi, panopticFactoryV4Abi, panopticPoolV2Abi, parsePanopticError, submitWrite, tickLimits$1 as tickLimits } from "./position-xJ_rnVZ0.js";
1
+ import { BatchValidationError, DEFAULT_VEGOID, InputListFailError, InvalidTickLimitsError, InvalidTokenIdParameterError, LEG_BITS, LEG_LIMITS, LEG_MASKS, LoanSlotExhaustedError, MaxRetriesExceededError, MissingPositionIdsError, NoLoanPositionsError, OracleRateLimitedError, PanopticError$1 as PanopticError, ProviderLagError, REORG_DEPTH, SCHEMA_VERSION, STORAGE_PREFIX, STRIKE_CONVERSION_FACTOR, SafeModeError, StaleDataError, SwapTokenMismatchError, SyncTimeoutError, TOKEN_ID_BITS, UnhealthyPoolError, calculatePositionGreeks, collateralTrackerV2Abi, createTxResult, decodeLeftRightUnsigned, getBlockMeta, getPool$1 as getPool, getPoolMetadata$1 as getPoolMetadata, getPositions, panopticErrorsAbi, panopticFactoryV3Abi, panopticFactoryV4Abi, panopticPoolV2Abi, parsePanopticError, submitWrite, tickLimits$1 as tickLimits } from "./position-Bo7y8jcj.js";
2
2
  import { decodeFunctionData, decodeFunctionResult, encodeFunctionData, erc20Abi, toFunctionSelector } from "viem";
3
3
 
4
4
  //#region src/panoptic/v2/writes/broadcaster.ts
@@ -4483,4 +4483,4 @@ async function smartRepayAndWait(params) {
4483
4483
 
4484
4484
  //#endregion
4485
4485
  export { addLegToTokenId, approve, approveAndWait, approvePool, assertCanBurn, assertCanForceExercise, assertCanLiquidate, assertCanMint, assertFresh, assertHealthy, assertTradeable, borrow, borrowAndWait, buildBatchDispatchArgs, buildOpenPositionCalldata, buildUniqueLoan, calculateResyncBlock, cancelTransaction, checkApproval, clearCheckpoint, clearTrackedPositions, closePosition, closePositionAndWait, countLegs, createFileStorage, createMemoryStorage, createNonceManager, createTokenIdBuilder, decodeAllDispatchCalldata, decodeAllLegs, decodeDispatchCalldata, decodeLeg, decodePoolId, decodeTickSpacing as decodeTickSpacing$1, decodeTokenId, decodeVegoid, deployNewPool, deployNewPoolAndWait, deposit, depositAndWait, detectReorg, dispatch, dispatchAndWait, encodeLeg, encodePoolId, encodeV4PoolId, executeBatchDispatch, executeBatchDispatchAndWait, forceExercise, forceExerciseAndWait, getAssetIndex, getClosedPositionsKey, getOpenPositionIds, getPendingPositionsKey, getPoolMetaKey, getPoolPrefix, getPositionMetaKey, getPositionsKey, getSchemaVersionKey, getSyncCheckpointKey, getTrackedChunksKey, getTrackedPositionIds, hasLoanOrCredit, hasLongLeg, isCredit, isCreditLeg, isGasError, isInputListFailError, isLoan, isLoanLeg, isNonceError, isPositionTracked, isRetryableRpcError, isShortOnly, isSpread, jsonSerializer, liquidate, liquidateAndWait, loadCheckpoint, mint, mintAndWait, openPosition, openPositionAndWait, pokeOracle, pokeOracleAndWait, previewBorrow, previewUnwrap, previewWrap, publicBroadcaster, recoverSnapshot, recoverSnapshotFromTx, redeem, redeemAndWait, repay, repayAndWait, resolveTokenIndex, rollPosition, rollPositionAndWait, saveCheckpoint, selectDispatchForAccount, settleAccumulatedPremia, settleAccumulatedPremiaAndWait, simulateOpenPosition, simulateWithTokenFlow, smartRepay, smartRepayAndWait, speedUpTransaction, supply, supplyAndWait, swapExactIn, swapExactInAndWait, swapExactOut, swapExactOutAndWait, syncPositions, unsupply, unsupplyAndWait, unwrapWeth, unwrapWethAndWait, unwrapXstock, unwrapXstockAndWait, validateBatch, validatePoolId, verifyBlockContinuity, wethWrapAbi, withdraw, withdrawAndWait, withdrawWithPositions, withdrawWithPositionsAndWait, wrapEth, wrapEthAndWait, wrapXstock, wrapXstockAndWait, xstockWrapperAbi };
4486
- //# sourceMappingURL=writes-D8AayW_8.js.map
4486
+ //# sourceMappingURL=writes-DQ-H14sj.js.map