@panoptic-eng/sdk 1.0.20 → 1.0.22

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (36) hide show
  1. package/dist/cow/index.js +3 -3
  2. package/dist/{cow-Cqw3sako.js → cow-C_SGXoWr.js} +2 -2
  3. package/dist/{cow-Cqw3sako.js.map → cow-C_SGXoWr.js.map} +1 -1
  4. package/dist/index.d.ts +696 -5907
  5. package/dist/index.d.ts.map +1 -1
  6. package/dist/index.js +1393 -579
  7. package/dist/index.js.map +1 -1
  8. package/dist/irm-C7OUVANR.d.ts +5641 -0
  9. package/dist/irm-C7OUVANR.d.ts.map +1 -0
  10. package/dist/{irm-DF4NwYIY.js → irm-DNK3N7qk.js} +301 -3
  11. package/dist/irm-DNK3N7qk.js.map +1 -0
  12. package/dist/panoptic/v2/index.d.ts +12 -4
  13. package/dist/panoptic/v2/index.d.ts.map +1 -1
  14. package/dist/panoptic/v2/index.js +25 -10
  15. package/dist/panoptic/v2/index.js.map +1 -1
  16. package/dist/{position-zqvENVuf.js → position-BK4a-Yyu.js} +2 -2
  17. package/dist/{position-zqvENVuf.js.map → position-BK4a-Yyu.js.map} +1 -1
  18. package/dist/{router-d09dxd-F.js → router-BZvOeloX.js} +90 -40
  19. package/dist/router-BZvOeloX.js.map +1 -0
  20. package/dist/test/index.d.ts +2 -2
  21. package/dist/test/index.d.ts.map +1 -1
  22. package/dist/uniswap/index.d.ts +118 -1
  23. package/dist/uniswap/index.d.ts.map +1 -1
  24. package/dist/uniswap/index.js +228 -4
  25. package/dist/uniswap/index.js.map +1 -0
  26. package/dist/{writes-CRjVFjMt.js → writes-DymnVbiE.js} +2 -2
  27. package/dist/{writes-CRjVFjMt.js.map → writes-DymnVbiE.js.map} +1 -1
  28. package/dist/zodiac/index.d.ts +444 -0
  29. package/dist/zodiac/index.d.ts.map +1 -0
  30. package/dist/zodiac/index.js +949 -0
  31. package/dist/zodiac/index.js.map +1 -0
  32. package/package.json +6 -1
  33. package/dist/irm-DF4NwYIY.js.map +0 -1
  34. package/dist/irm-zWjtffWA.d.ts +0 -85
  35. package/dist/irm-zWjtffWA.d.ts.map +0 -1
  36. package/dist/router-d09dxd-F.js.map +0 -1
@@ -1,5 +1,229 @@
1
- import "../position-zqvENVuf.js";
2
- import "../writes-CRjVFjMt.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-d09dxd-F.js";
1
+ import { PanopticError$1 as PanopticError } from "../position-BK4a-Yyu.js";
2
+ import "../writes-DymnVbiE.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, quoteV4ExactInByPoolKey, resolveSwapRoute, swapExactInViaRouter, swapExactInViaRouterAndWait, swapExactOutViaRouter, swapExactOutViaRouterAndWait, universalRouterAbi } from "../router-BZvOeloX.js";
4
+ import { BaseError, ContractFunctionRevertedError, encodeAbiParameters, encodeFunctionData, encodePacked, zeroAddress } from "viem";
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 };
6
+ //#region src/uniswap/v3/addresses.ts
7
+ /**
8
+ * Verified Uniswap v3 QuoterV2 addresses keyed by chainId. Add a chain only
9
+ * after verifying against the canonical Uniswap v3 deployment listing.
10
+ */
11
+ const UNISWAP_V3_ADDRESSES = { 1: { quoterV2: "0x61fFE014bA17989E743c5F6cB21bF9697530B21e" } };
12
+ /**
13
+ * Resolve Uniswap v3 addresses for a chain, applying optional overrides.
14
+ *
15
+ * @throws {UnsupportedChainError} when the chain is not listed and overrides do
16
+ * not supply every required address.
17
+ */
18
+ function getUniswapV3Addresses(chainId, overrides) {
19
+ const id = Number(chainId);
20
+ const base = UNISWAP_V3_ADDRESSES[id];
21
+ const merged = {
22
+ ...base,
23
+ ...overrides
24
+ };
25
+ if (!merged.quoterV2) throw new UnsupportedChainError(BigInt(id));
26
+ return merged;
27
+ }
28
+
29
+ //#endregion
30
+ //#region src/uniswap/v3/router/encodeSwap.ts
31
+ /** Universal Router command byte for a v3 exact-in swap. */
32
+ const V3_SWAP_EXACT_IN = 0;
33
+ /**
34
+ * Universal Router recipient sentinel: the router maps `address(1)` to
35
+ * `msg.sender` (the `execute` caller). Uniswap `Constants.MSG_SENDER`.
36
+ */
37
+ const MSG_SENDER = "0x0000000000000000000000000000000000000001";
38
+ const UINT128_MAX$1 = (1n << 128n) - 1n;
39
+ const v3ExactInInputAbi = [
40
+ {
41
+ name: "recipient",
42
+ type: "address"
43
+ },
44
+ {
45
+ name: "amountIn",
46
+ type: "uint256"
47
+ },
48
+ {
49
+ name: "amountOutMinimum",
50
+ type: "uint256"
51
+ },
52
+ {
53
+ name: "path",
54
+ type: "bytes"
55
+ },
56
+ {
57
+ name: "payerIsUser",
58
+ type: "bool"
59
+ }
60
+ ];
61
+ function assertUint128(amount) {
62
+ if (amount < 0n || amount > UINT128_MAX$1) throw new AmountExceedsUint128Error(amount);
63
+ }
64
+ /**
65
+ * Encode the packed v3 single-hop path `tokenIn ++ fee(uint24) ++ tokenOut`.
66
+ */
67
+ function encodeV3Path(tokenIn, fee, tokenOut) {
68
+ if (fee < 0n || fee > 0xffffffn) throw new PanopticError(`v3 fee ${fee} exceeds uint24`);
69
+ return encodePacked([
70
+ "address",
71
+ "uint24",
72
+ "address"
73
+ ], [
74
+ tokenIn,
75
+ Number(fee),
76
+ tokenOut
77
+ ]);
78
+ }
79
+ /**
80
+ * Build the typed `execute(...)` args for an exact-in single-hop v3 swap whose
81
+ * output is delivered to the `execute` caller (recipient = MSG_SENDER).
82
+ */
83
+ function buildV3SwapExecuteArgs(args) {
84
+ const { tokenIn, tokenOut, fee, amountIn, amountOutMinimum, deadline } = args;
85
+ if (tokenIn === zeroAddress || tokenOut === zeroAddress) throw new PanopticError("native ETH is not supported by the v3 exact-in router builder");
86
+ assertUint128(amountIn);
87
+ assertUint128(amountOutMinimum);
88
+ const path = encodeV3Path(tokenIn, fee, tokenOut);
89
+ const input = encodeAbiParameters(v3ExactInInputAbi, [
90
+ MSG_SENDER,
91
+ amountIn,
92
+ amountOutMinimum,
93
+ path,
94
+ true
95
+ ]);
96
+ const commands = encodePacked(["uint8"], [V3_SWAP_EXACT_IN]);
97
+ return {
98
+ args: [
99
+ commands,
100
+ [input],
101
+ deadline
102
+ ],
103
+ value: 0n
104
+ };
105
+ }
106
+ /**
107
+ * Build the `execute(commands, inputs, deadline)` calldata for an exact-in
108
+ * single-hop v3 swap.
109
+ */
110
+ function buildV3SwapExecuteCalldata(args) {
111
+ const { args: executeArgs, value } = buildV3SwapExecuteArgs(args);
112
+ const data = encodeFunctionData({
113
+ abi: universalRouterAbi,
114
+ functionName: "execute",
115
+ args: executeArgs
116
+ });
117
+ return {
118
+ data,
119
+ value
120
+ };
121
+ }
122
+
123
+ //#endregion
124
+ //#region src/uniswap/v3/abis/quoterV2.ts
125
+ /**
126
+ * Minimal Uniswap v3 QuoterV2 ABI (`quoteExactInputSingle`).
127
+ *
128
+ * QuoterV2 is revert/staticcall-based (nonpayable but intended for `eth_call` /
129
+ * `simulateContract`), so it must be simulated, not read.
130
+ * @module uniswap/v3/abis/quoterV2
131
+ */
132
+ const quoterV2Abi = [{
133
+ type: "function",
134
+ name: "quoteExactInputSingle",
135
+ stateMutability: "nonpayable",
136
+ inputs: [{
137
+ name: "params",
138
+ type: "tuple",
139
+ components: [
140
+ {
141
+ name: "tokenIn",
142
+ type: "address"
143
+ },
144
+ {
145
+ name: "tokenOut",
146
+ type: "address"
147
+ },
148
+ {
149
+ name: "amountIn",
150
+ type: "uint256"
151
+ },
152
+ {
153
+ name: "fee",
154
+ type: "uint24"
155
+ },
156
+ {
157
+ name: "sqrtPriceLimitX96",
158
+ type: "uint160"
159
+ }
160
+ ]
161
+ }],
162
+ outputs: [
163
+ {
164
+ name: "amountOut",
165
+ type: "uint256"
166
+ },
167
+ {
168
+ name: "sqrtPriceX96After",
169
+ type: "uint160"
170
+ },
171
+ {
172
+ name: "initializedTicksCrossed",
173
+ type: "uint32"
174
+ },
175
+ {
176
+ name: "gasEstimate",
177
+ type: "uint256"
178
+ }
179
+ ]
180
+ }];
181
+
182
+ //#endregion
183
+ //#region src/uniswap/v3/router/quote.ts
184
+ const BPS_DENOMINATOR = 10000n;
185
+ const UINT128_MAX = (1n << 128n) - 1n;
186
+ /**
187
+ * Quote an exact-in v3 swap. Returns `null` when the quote reverts (e.g. the
188
+ * pool does not exist / has no liquidity) so callers can skip that pool when
189
+ * ranking venues, rather than aborting the whole cycle.
190
+ */
191
+ async function quoteV3ExactIn(params) {
192
+ const { client, chainId, tokenIn, tokenOut, fee, amountIn, slippageBps, blockNumber } = params;
193
+ if (amountIn < 0n || amountIn > UINT128_MAX) throw new PanopticError(`amountIn ${amountIn} exceeds uint128 maximum`);
194
+ if (slippageBps < 0n || slippageBps > BPS_DENOMINATOR) throw new PanopticError(`invalid slippageBps ${slippageBps}, must be 0..10000`);
195
+ const { quoterV2 } = getUniswapV3Addresses(chainId, params.addresses);
196
+ try {
197
+ const { result } = await client.simulateContract({
198
+ address: quoterV2,
199
+ abi: quoterV2Abi,
200
+ functionName: "quoteExactInputSingle",
201
+ blockNumber,
202
+ args: [{
203
+ tokenIn,
204
+ tokenOut,
205
+ amountIn,
206
+ fee: Number(fee),
207
+ sqrtPriceLimitX96: 0n
208
+ }]
209
+ });
210
+ const [amountOut, , , gasEstimate] = result;
211
+ const amountOutMinimum = amountOut * (BPS_DENOMINATOR - slippageBps) / BPS_DENOMINATOR;
212
+ return {
213
+ amountOut,
214
+ amountOutMinimum,
215
+ gasEstimate
216
+ };
217
+ } catch (err) {
218
+ if (isRevert(err)) return null;
219
+ throw err;
220
+ }
221
+ }
222
+ /** True only for genuine contract reverts (missing pool / no liquidity). */
223
+ function isRevert(err) {
224
+ return err instanceof BaseError && err.walk((e) => e instanceof ContractFunctionRevertedError) instanceof ContractFunctionRevertedError;
225
+ }
226
+
227
+ //#endregion
228
+ export { AmountExceedsUint128Error, InvalidSwapTokenError, MSG_SENDER, MissingSweepRecipientError, PERMIT2_ADDRESS, QuoterUnavailableError, SETTLE_ALL, SWAP_EXACT_IN_SINGLE, SWAP_EXACT_OUT_SINGLE, SWEEP, TAKE_ALL, UNISWAP_V3_ADDRESSES, UNISWAP_V4_ADDRESSES, UnsupportedChainError, V3_SWAP_EXACT_IN, V4_SWAP, approveErc20ForPermit2, approveErc20ForPermit2AndWait, approveRouterViaPermit2, approveRouterViaPermit2AndWait, buildV3SwapExecuteArgs, buildV3SwapExecuteCalldata, buildV4ExactOutSwapExecuteArgs, buildV4ExactOutSwapExecuteCalldata, buildV4SwapExecuteArgs, buildV4SwapExecuteCalldata, checkRouterApproval, encodeV3Path, getUniswapV3Addresses, getUniswapV4Addresses, quoteSwapExactInViaRouter, quoteSwapExactOutViaRouter, quoteV3ExactIn, quoteV4ExactInByPoolKey, resolveSwapRoute, swapExactInViaRouter, swapExactInViaRouterAndWait, swapExactOutViaRouter, swapExactOutViaRouterAndWait };
229
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","names":["UNISWAP_V3_ADDRESSES: Record<number, UniswapV3Addresses>","chainId: number | bigint","overrides?: Partial<UniswapV3Addresses>","MSG_SENDER: Address","UINT128_MAX","amount: bigint","tokenIn: Address","fee: bigint","tokenOut: Address","args: BuildV3SwapCalldataArgs","params: QuoteV3ExactInParams","err: unknown"],"sources":["../../src/uniswap/v3/addresses.ts","../../src/uniswap/v3/router/encodeSwap.ts","../../src/uniswap/v3/abis/quoterV2.ts","../../src/uniswap/v3/router/quote.ts"],"sourcesContent":["/**\n * Per-chain Uniswap v3 addresses needed for spot quoting via the Universal\n * Router. The Universal Router itself is shared with v4 (see\n * `uniswap/v4/addresses`); only the v3 QuoterV2 is specific to v3.\n *\n * v1 supports mainnet only; other chains throw {@link UnsupportedChainError}\n * unless the address is supplied via overrides (fork tests / new chains).\n *\n * @module uniswap/v3/addresses\n */\n\nimport type { Address } from 'viem'\n\nimport { UnsupportedChainError } from '../v4/router/errors'\n\nexport interface UniswapV3Addresses {\n /** Uniswap v3 QuoterV2 — `quoteExactInputSingle` (revert/staticcall-based). */\n quoterV2: Address\n}\n\n/**\n * Verified Uniswap v3 QuoterV2 addresses keyed by chainId. Add a chain only\n * after verifying against the canonical Uniswap v3 deployment listing.\n */\nexport const UNISWAP_V3_ADDRESSES: Record<number, UniswapV3Addresses> = {\n // Ethereum mainnet\n 1: { quoterV2: '0x61fFE014bA17989E743c5F6cB21bF9697530B21e' },\n}\n\n/**\n * Resolve Uniswap v3 addresses for a chain, applying optional overrides.\n *\n * @throws {UnsupportedChainError} when the chain is not listed and overrides do\n * not supply every required address.\n */\nexport function getUniswapV3Addresses(\n chainId: number | bigint,\n overrides?: Partial<UniswapV3Addresses>,\n): UniswapV3Addresses {\n const id = Number(chainId)\n const base = UNISWAP_V3_ADDRESSES[id]\n const merged = { ...base, ...overrides }\n if (!merged.quoterV2) {\n throw new UnsupportedChainError(BigInt(id))\n }\n return merged as UniswapV3Addresses\n}\n","/**\n * Pure calldata builder for an exact-in single-hop swap through a Uniswap **v3**\n * pool via the Universal Router.\n *\n * Opcodes verified against `@uniswap/universal-router` `Commands.sol`:\n * - Universal Router command `V3_SWAP_EXACT_IN = 0x00`.\n *\n * The v3 command input is (unlike the v4 action list) a single flat tuple:\n * `(address recipient, uint256 amountIn, uint256 amountOutMinimum,\n * bytes path, bool payerIsUser)`\n * where:\n * - `recipient` is an EXPLICIT field. We encode the Universal Router sentinel\n * `MSG_SENDER = address(1)`, which the router maps to the `execute` caller —\n * so the output is delivered to the caller (e.g. a Safe) with no literal\n * address in the calldata to redirect.\n * - `path` is `abi.encodePacked(tokenIn, fee (uint24), tokenOut)` for a single\n * hop (43 bytes). The direction lives in the path ordering, not a bool.\n * - `payerIsUser = true`: the router pulls `tokenIn` from the caller via Permit2.\n *\n * ERC20-only: native ETH is intentionally unsupported here (the native paths\n * need WRAP/UNWRAP/SWEEP commands with explicit recipients).\n *\n * @module uniswap/v3/router/encodeSwap\n */\n\nimport type { Address, Hex } from 'viem'\nimport { encodeAbiParameters, encodeFunctionData, encodePacked, zeroAddress } from 'viem'\n\nimport { PanopticError } from '../../../panoptic/v2/errors'\nimport { universalRouterAbi } from '../../v4/abis/universalRouter'\nimport { AmountExceedsUint128Error } from '../../v4/router/errors'\n\n/** Universal Router command byte for a v3 exact-in swap. */\nexport const V3_SWAP_EXACT_IN = 0x00\n\n/**\n * Universal Router recipient sentinel: the router maps `address(1)` to\n * `msg.sender` (the `execute` caller). Uniswap `Constants.MSG_SENDER`.\n */\nexport const MSG_SENDER: Address = '0x0000000000000000000000000000000000000001'\n\nconst UINT128_MAX = (1n << 128n) - 1n\n\nconst v3ExactInInputAbi = [\n { name: 'recipient', type: 'address' },\n { name: 'amountIn', type: 'uint256' },\n { name: 'amountOutMinimum', type: 'uint256' },\n { name: 'path', type: 'bytes' },\n { name: 'payerIsUser', type: 'bool' },\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/** Arguments for {@link buildV3SwapExecuteCalldata}. */\nexport interface BuildV3SwapCalldataArgs {\n /** Input token (funds pulled from the caller via Permit2). */\n tokenIn: Address\n /** Output token. */\n tokenOut: Address\n /** v3 pool fee tier (e.g. 500, 3000). */\n fee: bigint\n /** Exact input amount (uint128). */\n amountIn: bigint\n /** Minimum acceptable output (uint128). */\n amountOutMinimum: bigint\n /**\n * Absolute deadline (unix seconds) — the `execute(commands, inputs, deadline)`\n * argument, enforced by the Universal Router.\n */\n deadline: bigint\n}\n\n/**\n * Encode the packed v3 single-hop path `tokenIn ++ fee(uint24) ++ tokenOut`.\n */\nexport function encodeV3Path(tokenIn: Address, fee: bigint, tokenOut: Address): Hex {\n if (fee < 0n || fee > 0xffffffn) {\n throw new PanopticError(`v3 fee ${fee} exceeds uint24`)\n }\n return encodePacked(['address', 'uint24', 'address'], [tokenIn, Number(fee), tokenOut])\n}\n\n/**\n * Build the typed `execute(...)` args for an exact-in single-hop v3 swap whose\n * output is delivered to the `execute` caller (recipient = MSG_SENDER).\n */\nexport function buildV3SwapExecuteArgs(args: BuildV3SwapCalldataArgs): {\n args: readonly [Hex, readonly Hex[], bigint]\n value: bigint\n} {\n const { tokenIn, tokenOut, fee, amountIn, amountOutMinimum, deadline } = args\n\n if (tokenIn === zeroAddress || tokenOut === zeroAddress) {\n throw new PanopticError('native ETH is not supported by the v3 exact-in router builder')\n }\n assertUint128(amountIn)\n assertUint128(amountOutMinimum)\n\n const path = encodeV3Path(tokenIn, fee, tokenOut)\n const input = encodeAbiParameters(v3ExactInInputAbi, [\n MSG_SENDER,\n amountIn,\n amountOutMinimum,\n path,\n true, // payerIsUser: pull tokenIn from the caller via Permit2\n ])\n\n const commands = encodePacked(['uint8'], [V3_SWAP_EXACT_IN])\n return { args: [commands, [input], deadline] as const, value: 0n }\n}\n\n/**\n * Build the `execute(commands, inputs, deadline)` calldata for an exact-in\n * single-hop v3 swap.\n */\nexport function buildV3SwapExecuteCalldata(args: BuildV3SwapCalldataArgs): {\n data: Hex\n value: bigint\n} {\n const { args: executeArgs, value } = buildV3SwapExecuteArgs(args)\n const data = encodeFunctionData({\n abi: universalRouterAbi,\n functionName: 'execute',\n args: executeArgs,\n })\n return { data, value }\n}\n","/**\n * Minimal Uniswap v3 QuoterV2 ABI (`quoteExactInputSingle`).\n *\n * QuoterV2 is revert/staticcall-based (nonpayable but intended for `eth_call` /\n * `simulateContract`), so it must be simulated, not read.\n * @module uniswap/v3/abis/quoterV2\n */\n\nexport const quoterV2Abi = [\n {\n type: 'function',\n name: 'quoteExactInputSingle',\n stateMutability: 'nonpayable',\n inputs: [\n {\n name: 'params',\n type: 'tuple',\n components: [\n { name: 'tokenIn', type: 'address' },\n { name: 'tokenOut', type: 'address' },\n { name: 'amountIn', type: 'uint256' },\n { name: 'fee', type: 'uint24' },\n { name: 'sqrtPriceLimitX96', type: 'uint160' },\n ],\n },\n ],\n outputs: [\n { name: 'amountOut', type: 'uint256' },\n { name: 'sqrtPriceX96After', type: 'uint160' },\n { name: 'initializedTicksCrossed', type: 'uint32' },\n { name: 'gasEstimate', type: 'uint256' },\n ],\n },\n] as const\n","/**\n * Quote an exact-in single-hop swap against a Uniswap v3 pool via QuoterV2.\n * @module uniswap/v3/router/quote\n */\n\nimport type { Address, PublicClient } from 'viem'\nimport { BaseError, ContractFunctionRevertedError } from 'viem'\n\nimport { PanopticError } from '../../../panoptic/v2/errors'\nimport { quoterV2Abi } from '../abis/quoterV2'\nimport { type UniswapV3Addresses, getUniswapV3Addresses } from '../addresses'\n\nconst BPS_DENOMINATOR = 10_000n\nconst UINT128_MAX = (1n << 128n) - 1n\n\nexport interface QuoteV3ExactInParams {\n client: PublicClient\n chainId: bigint\n tokenIn: Address\n tokenOut: Address\n fee: bigint\n amountIn: bigint\n /** Slippage tolerance in bps, used to compute `amountOutMinimum`. */\n slippageBps: bigint\n blockNumber?: bigint\n addresses?: Partial<UniswapV3Addresses>\n}\n\nexport interface V3ExactInQuote {\n amountOut: bigint\n amountOutMinimum: bigint\n gasEstimate: bigint\n}\n\n/**\n * Quote an exact-in v3 swap. Returns `null` when the quote reverts (e.g. the\n * pool does not exist / has no liquidity) so callers can skip that pool when\n * ranking venues, rather than aborting the whole cycle.\n */\nexport async function quoteV3ExactIn(params: QuoteV3ExactInParams): Promise<V3ExactInQuote | null> {\n const { client, chainId, tokenIn, tokenOut, fee, amountIn, slippageBps, blockNumber } = params\n if (amountIn < 0n || amountIn > UINT128_MAX) {\n throw new PanopticError(`amountIn ${amountIn} exceeds uint128 maximum`)\n }\n if (slippageBps < 0n || slippageBps > BPS_DENOMINATOR) {\n throw new PanopticError(`invalid slippageBps ${slippageBps}, must be 0..10000`)\n }\n\n const { quoterV2 } = getUniswapV3Addresses(chainId, params.addresses)\n\n try {\n const { result } = await client.simulateContract({\n address: quoterV2,\n abi: quoterV2Abi,\n functionName: 'quoteExactInputSingle',\n blockNumber,\n args: [{ tokenIn, tokenOut, amountIn, fee: Number(fee), sqrtPriceLimitX96: 0n }],\n })\n const [amountOut, , , gasEstimate] = result\n const amountOutMinimum = (amountOut * (BPS_DENOMINATOR - slippageBps)) / BPS_DENOMINATOR\n return { amountOut, amountOutMinimum, gasEstimate }\n } catch (err) {\n if (isRevert(err)) return null\n // Transport/RPC/timeout errors are NOT \"no liquidity\" — rethrow so routing\n // doesn't silently treat an unreachable node as an empty pool.\n throw err\n }\n}\n\n/** True only for genuine contract reverts (missing pool / no liquidity). */\nfunction isRevert(err: unknown): boolean {\n return (\n err instanceof BaseError &&\n err.walk((e) => e instanceof ContractFunctionRevertedError) instanceof\n ContractFunctionRevertedError\n )\n}\n"],"mappings":"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"}
@@ -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-zqvENVuf.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-BK4a-Yyu.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-CRjVFjMt.js.map
4486
+ //# sourceMappingURL=writes-DymnVbiE.js.map