@panoptic-eng/sdk 1.0.49 → 1.0.50

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 (39) hide show
  1. package/dist/cow/index.js.map +1 -1
  2. package/dist/{cow-DMX9ebPk.js → cow-CSSKPknb.js} +1 -1
  3. package/dist/deployments.d.ts +12 -4
  4. package/dist/deployments.d.ts.map +1 -1
  5. package/dist/deployments.js +78 -10
  6. package/dist/deployments.js.map +1 -1
  7. package/dist/{greeks-9aTE-DwO.js → greeks-CNi1-cnp.js} +39 -16
  8. package/dist/index.d.ts +518 -76
  9. package/dist/index.d.ts.map +1 -1
  10. package/dist/index.js +701 -84
  11. package/dist/index.js.map +1 -1
  12. package/dist/{irm-mySi_YMF.js → irm-BJaJSUjF.js} +80 -12
  13. package/dist/panoptic/v2/greeks/index.d.ts +12 -1
  14. package/dist/panoptic/v2/greeks/index.d.ts.map +1 -1
  15. package/dist/panoptic/v2/greeks/index.js +39 -16
  16. package/dist/panoptic/v2/greeks/index.js.map +1 -1
  17. package/dist/panoptic/v2/index.d.ts +1336 -74
  18. package/dist/panoptic/v2/index.d.ts.map +1 -1
  19. package/dist/panoptic/v2/index.js +20322 -18660
  20. package/dist/panoptic/v2/index.js.map +1 -1
  21. package/dist/panoptic/v2/react-public.d.ts +1518 -240
  22. package/dist/panoptic/v2/react-public.d.ts.map +1 -1
  23. package/dist/panoptic/v2/react-public.js +11518 -9319
  24. package/dist/panoptic/v2/react-public.js.map +1 -1
  25. package/dist/{rates-CDLIUGDz.js → rates-COAJpKRd.js} +612 -73
  26. package/dist/{router-45ulPnWe.js → router-B-I1eACz.js} +5 -43
  27. package/dist/router-BSS7HKd2.js +837 -0
  28. package/dist/uniswap/index.d.ts +465 -215
  29. package/dist/uniswap/index.d.ts.map +1 -1
  30. package/dist/uniswap/index.js +1799 -1076
  31. package/dist/uniswap/index.js.map +1 -1
  32. package/dist/{v2-DshssxX4.js → v2-zF6b01PI.js} +2488 -1596
  33. package/dist/{writes-2reV_omF.js → writes-D1zN0v9x.js} +4 -3
  34. package/dist/zodiac/index.d.ts +51 -7
  35. package/dist/zodiac/index.d.ts.map +1 -1
  36. package/dist/zodiac/index.js +154 -2
  37. package/dist/zodiac/index.js.map +1 -1
  38. package/package.json +2 -1
  39. package/dist/router-B2jY9Nyb.js +0 -312
@@ -1,25 +1,159 @@
1
+ import Decimal from "decimal.js";
1
2
  import { Address, Hash, Hex, PublicClient, WalletClient } from "viem";
2
3
 
3
- //#region src/uniswap/lpGreeks.d.ts
4
+ //#region src/uniswap/estimateLpFees.d.ts
5
+ interface LpFeeCandle {
6
+ t: number;
7
+ o: number;
8
+ h: number;
9
+ l: number;
10
+ c: number;
11
+ /** Absolute swap volume (inputs + outputs), in raw token units. */
12
+ v0: string;
13
+ v1: string;
14
+ /** Historical active liquidity at the candle close, when available. */
15
+ liq?: string;
16
+ }
17
+ interface LpFeeRange {
18
+ tickLower: number;
19
+ tickUpper: number;
20
+ liquidity: bigint;
21
+ }
4
22
  /**
5
- * Greeks for plain (non-Panoptic) Uniswap v3/v4 concentrated-liquidity LP
6
- * positions. Pure math over on-chain position fields (liquidity + tick range)
7
- * and the pool's current price — no RPC, no protocol dependency.
8
- *
9
- * Units follow the Panoptic v2 greeks convention (see
10
- * `packages/sdk/src/panoptic/v2/greeks/index.ts`) so a caller can present LP
11
- * and Panoptic greeks side by side:
12
- * - `value` → numeraire-token smallest units
13
- * - `delta` → asset-token smallest units (the asset held by the LP)
14
- * - `gamma` → numeraire-token smallest units (dollar-gamma `P²·d²V/dP²`;
15
- * always ≤ 0 because an LP is short gamma)
16
- *
17
- * `assetIndex` selects which token is the "asset" (the volatile leg being
18
- * hedged): `0` → token0 is the asset / token1 the numeraire; `1` → the reverse.
19
- *
20
- * @module uniswap/lpGreeks
21
- */
22
- /** Token amounts currently backing a concentrated-liquidity position. */
23
+ * Hypothetical added LP liquidity, with no compounding or price impact. Fees are raw
24
+ * token units. Bullish candles follow O→L→H→C; bearish candles O→H→L→C.
25
+ * Uniswap v3 deltas distribute absolute volume between inputs and outputs; only
26
+ * inputs pay fees. Split moves at every LP boundary, so overlapping ranges share
27
+ * the same denominator and out-of-range portions earn nothing.
28
+ *
29
+ * Closing historical liquidity approximates liquidity throughout a candle. If
30
+ * absent, infer it from volume / path deltas. Flat candles with volume use equal
31
+ * buy/sell flow and require historical liquidity; otherwise report them skipped.
32
+ * OHLC cannot recover unseen oscillations, exact swap ordering or liquidity changes.
33
+ */
34
+ declare function estimateLpFees({
35
+ candles,
36
+ ranges,
37
+ feePips
38
+ }: {
39
+ candles: readonly LpFeeCandle[];
40
+ ranges: readonly LpFeeRange[];
41
+ feePips: bigint;
42
+ }): {
43
+ points: {
44
+ time: number;
45
+ fees0: bigint;
46
+ fees1: bigint;
47
+ }[];
48
+ skippedCandles: number;
49
+ inferredCandles: number;
50
+ }; //#endregion
51
+ //#region src/uniswap/lpDeposit.d.ts
52
+ /** Uniswap mint principal in raw token units, rounded up per leg, plus 5% headroom. */
53
+ declare function getLpDepositAmounts(ranges: readonly LpFeeRange[], sqrtPriceX96: bigint): {
54
+ amount0: bigint;
55
+ amount1: bigint;
56
+ };
57
+ /** Principal and separately identified funding headroom, in native token units. */
58
+ declare function getLpDepositBreakdown(ranges: readonly LpFeeRange[], sqrtPriceX96: bigint): {
59
+ principal: {
60
+ amount0: bigint;
61
+ amount1: bigint;
62
+ };
63
+ buffer: {
64
+ amount0: bigint;
65
+ amount1: bigint;
66
+ };
67
+ total: {
68
+ amount0: bigint;
69
+ amount1: bigint;
70
+ };
71
+ };
72
+ interface LpPositionFundingParams {
73
+ tokenId: bigint;
74
+ positionSize: bigint;
75
+ tickSpacing: bigint;
76
+ sqrtPriceX96: bigint;
77
+ /** Price used consistently to value funding and account collateral. */
78
+ valuationSqrtPriceX96: bigint;
79
+ quoteTokenIndex: 0 | 1;
80
+ }
81
+ /** Full deployed liquidity value; never a leveraged protocol margin estimate. */
82
+ declare function getLpPositionFunding(params: LpPositionFundingParams): {
83
+ principalInQuote: bigint;
84
+ bufferInQuote: bigint;
85
+ totalInQuote: bigint;
86
+ principal: {
87
+ amount0: bigint;
88
+ amount1: bigint;
89
+ };
90
+ buffer: {
91
+ amount0: bigint;
92
+ amount1: bigint;
93
+ };
94
+ total: {
95
+ amount0: bigint;
96
+ amount1: bigint;
97
+ };
98
+ };
99
+ /** Remaining deposit in the requested token mix, rounded up to cover the shortfall. */
100
+ declare function getLpFundingDeposit({
101
+ funding,
102
+ availableInQuote,
103
+ minimumInQuote,
104
+ quoteTokenIndex,
105
+ valuationSqrtPriceX96,
106
+ quotePercent
107
+ }: {
108
+ funding: ReturnType<typeof getLpPositionFunding>;
109
+ availableInQuote: bigint;
110
+ minimumInQuote?: bigint;
111
+ quoteTokenIndex: 0 | 1;
112
+ valuationSqrtPriceX96: bigint;
113
+ quotePercent?: bigint;
114
+ }): {
115
+ requiredInQuote: bigint;
116
+ shortfallInQuote: bigint;
117
+ defaultQuotePercent: bigint;
118
+ amount0: bigint;
119
+ amount1: bigint;
120
+ };
121
+ /** Largest raw size funded by available collateral, including native-token rounding. */
122
+ declare function getMaxLpPositionSize(params: Omit<LpPositionFundingParams, 'positionSize'> & {
123
+ availableInQuote: bigint;
124
+ minimumRequirement?: {
125
+ referenceSize: bigint;
126
+ requiredInQuote: bigint;
127
+ };
128
+ }): bigint; //#endregion
129
+ //#region src/uniswap/lpFeeReturn.d.ts
130
+ /** Simple fee APR over the full selected viewport, without compounding. */
131
+ declare function annualizeLpFeeReturn(feeReturnPercent: Decimal, durationSeconds: bigint): Decimal;
132
+ /**
133
+ * Combine both fee tokens into a fee-only return on deployed LP capital.
134
+ * Value both capital and fees at the window's opening price: this keeps fee
135
+ * return flat when accrual stops and makes the ratio independent of quote
136
+ * orientation. Raw token amounts already account for differing decimals.
137
+ * Excludes principal price changes, impermanent loss and costs; not annualized.
138
+ * Returns undefined when the position has no representable deployed capital.
139
+ */
140
+ declare function getLpFeeReturnSeries<T extends {
141
+ fees0: bigint;
142
+ fees1: bigint;
143
+ }>({
144
+ points,
145
+ ranges,
146
+ startTick
147
+ }: {
148
+ points: readonly T[];
149
+ ranges: readonly LpFeeRange[];
150
+ startTick: number;
151
+ }): (T & {
152
+ feeReturnPercent: Decimal;
153
+ })[] | undefined;
154
+
155
+ //#endregion
156
+ //#region src/uniswap/lpGreeks.d.ts
23
157
  /**
24
158
  * Greeks for plain (non-Panoptic) Uniswap v3/v4 concentrated-liquidity LP
25
159
  * positions. Pure math over on-chain position fields (liquidity + tick range)
@@ -85,7 +219,9 @@ declare function getAmountsForLiquidity(sqrtPriceX96: bigint, sqrtRatioAX96: big
85
219
  * The `assetIndex = 1` frame is the symmetric inverse (numeraire = token0).
86
220
  * Gamma is zero when the price is outside the range (no curvature there).
87
221
  */
88
- declare function getLpGreeks(input: LpGreeksInput): LpGreeks; //#endregion
222
+ declare function getLpGreeks(input: LpGreeksInput): LpGreeks;
223
+
224
+ //#endregion
89
225
  //#region src/uniswap/v3/addresses.d.ts
90
226
  interface UniswapV3Addresses {
91
227
  /** Uniswap v3 QuoterV2 — `quoteExactInputSingle` (revert/staticcall-based). */
@@ -110,6 +246,8 @@ declare function getUniswapV3Addresses(chainId: number | bigint, overrides?: Par
110
246
  //#region src/uniswap/v3/router/encodeSwap.d.ts
111
247
  /** Universal Router command byte for a v3 exact-in swap. */
112
248
  declare const V3_SWAP_EXACT_IN = 0;
249
+ /** Universal Router command byte for a v3 exact-out swap. */
250
+ declare const V3_SWAP_EXACT_OUT = 1;
113
251
  /**
114
252
  * Universal Router recipient sentinel: the router maps `address(1)` to
115
253
  * `msg.sender` (the `execute` caller). Uniswap `Constants.MSG_SENDER`.
@@ -153,6 +291,26 @@ declare function buildV3SwapExecuteCalldata(args: BuildV3SwapCalldataArgs): {
153
291
  data: Hex;
154
292
  value: bigint;
155
293
  };
294
+ interface BuildV3ExactOutSwapCalldataArgs {
295
+ tokenIn: Address;
296
+ tokenOut: Address;
297
+ fee: bigint;
298
+ amountOut: bigint;
299
+ amountInMaximum: bigint;
300
+ deadline: bigint;
301
+ }
302
+ /**
303
+ * Build the typed `execute(...)` args for an exact-out single-hop v3 swap.
304
+ * The v3 exact-out path is reversed: `tokenOut ++ fee ++ tokenIn`.
305
+ */
306
+ declare function buildV3ExactOutSwapExecuteArgs(args: BuildV3ExactOutSwapCalldataArgs): {
307
+ args: readonly [Hex, readonly Hex[], bigint];
308
+ value: bigint;
309
+ };
310
+ declare function buildV3ExactOutSwapExecuteCalldata(args: BuildV3ExactOutSwapCalldataArgs): {
311
+ data: Hex;
312
+ value: bigint;
313
+ };
156
314
 
157
315
  //#endregion
158
316
  //#region src/uniswap/v3/router/quote.d.ts
@@ -163,7 +321,6 @@ interface QuoteV3ExactInParams {
163
321
  tokenOut: Address;
164
322
  fee: bigint;
165
323
  amountIn: bigint;
166
- /** Slippage tolerance in bps, used to compute `amountOutMinimum`. */
167
324
  slippageBps: bigint;
168
325
  blockNumber?: bigint;
169
326
  addresses?: Partial<UniswapV3Addresses>;
@@ -179,46 +336,26 @@ interface V3ExactInQuote {
179
336
  * ranking venues, rather than aborting the whole cycle.
180
337
  */
181
338
  declare function quoteV3ExactIn(params: QuoteV3ExactInParams): Promise<V3ExactInQuote | null>;
182
-
183
- //#endregion
184
- //#region src/uniswap/v4/addresses.d.ts
185
- /**
186
- * Uniswap v4 contract addresses required for a Universal Router spot swap.
187
- */
188
- interface UniswapV4Addresses {
189
- /** Universal Router (v4-capable build) — entrypoint for `execute(...)`. */
190
- universalRouter: Address;
191
- /** V4Quoter — `quoteExactInputSingle` (revert/staticcall-based). */
192
- v4Quoter: Address;
193
- /** Uniswap v4 PoolManager (singleton). */
194
- poolManager: Address;
195
- /** Uniswap v4 PositionManager (posm) — ERC721 LP position NFTs. */
196
- positionManager: Address;
197
- /** Canonical Permit2 (same address on every chain). */
198
- permit2: Address;
339
+ interface QuoteV3ExactOutParams {
340
+ client: PublicClient;
341
+ chainId: bigint;
342
+ tokenIn: Address;
343
+ tokenOut: Address;
344
+ fee: bigint;
345
+ amountOut: bigint;
346
+ slippageBps: bigint;
347
+ blockNumber?: bigint;
348
+ addresses?: Partial<UniswapV3Addresses>;
349
+ }
350
+ interface V3ExactOutQuote {
351
+ amountIn: bigint;
352
+ amountInMaximum: bigint;
353
+ gasEstimate: bigint;
199
354
  }
200
355
  /**
201
- * Canonical Permit2, identical across all chains.
202
- */
203
- declare const PERMIT2_ADDRESS: Address;
204
- /**
205
- * Verified Uniswap v4 deployment addresses keyed by chainId.
206
- *
207
- * Sourced from the official Uniswap v4 deployments. Add a chain here only after
208
- * verifying each address against the canonical Uniswap deployment listing —
209
- * Universal Router in particular is NOT the same address across chains.
210
- */
211
- declare const UNISWAP_V4_ADDRESSES: Record<number, UniswapV4Addresses>;
212
- /**
213
- * Resolve the Uniswap v4 addresses for a chain, applying optional overrides.
214
- *
215
- * @param chainId - Target chain ID.
216
- * @param overrides - Partial override of any address (e.g. for fork tests).
217
- * @returns Fully-resolved {@link UniswapV4Addresses}.
218
- * @throws {UnsupportedChainError} when the chain is not listed and the
219
- * overrides do not supply every required address.
356
+ * Quote an exact-out v3 swap. Returns `null` on revert (no pool / no liquidity).
220
357
  */
221
- declare function getUniswapV4Addresses(chainId: bigint, overrides?: Partial<UniswapV4Addresses>): UniswapV4Addresses;
358
+ declare function quoteV3ExactOut(params: QuoteV3ExactOutParams): Promise<V3ExactOutQuote | null>;
222
359
 
223
360
  //#endregion
224
361
  //#region src/panoptic/v2/types/meta.d.ts
@@ -650,172 +787,47 @@ type SimulationResult<T> = {
650
787
  };
651
788
 
652
789
  //#endregion
653
- //#region src/uniswap/v4/router/encodeSwap.d.ts
790
+ //#region src/uniswap/v4/addresses.d.ts
654
791
  /**
655
792
  * Open position simulation result data.
656
793
  */
657
- /** Universal Router command byte for a v4 swap. */
658
- declare const V4_SWAP = 16;
659
- /** v4 action: exact-in single-hop swap. */
660
- declare const SWAP_EXACT_IN_SINGLE = 6;
661
- /** v4 action: pay all of the input currency owed. */
662
- declare const SETTLE_ALL = 12;
663
- /** v4 action: take all of the output currency owed. */
664
- declare const TAKE_ALL = 15;
665
- /** v4 action: take an output currency to an explicit recipient. */
666
-
667
- /** v4 action: exact-out single-hop swap. */
668
- declare const SWAP_EXACT_OUT_SINGLE = 8;
669
- /** Universal Router command: sweep the router's token balance to a recipient. */
670
- declare const SWEEP = 4;
671
794
  /**
672
- * Arguments for {@link buildV4SwapExecuteCalldata}.
795
+ * Uniswap v4 contract addresses required for a Universal Router spot swap.
673
796
  */
674
- interface BuildV4SwapCalldataArgs {
675
- /** The v4 PoolKey (currency0, currency1, fee, tickSpacing, hooks). */
676
- poolKey: PoolKey;
677
- /** Whether the swap goes currency0 → currency1. */
678
- zeroForOne: boolean;
679
- /** Exact input amount (uint128). */
680
- amountIn: bigint;
681
- /** Minimum acceptable output (uint128). */
682
- amountOutMinimum: bigint;
683
- /** Input token address (`address(0)` for native ETH). */
684
- tokenIn: Address;
685
- /** Output token address (`address(0)` for native ETH). */
686
- tokenOut: Address;
687
- /** Absolute deadline (unix seconds). */
688
- deadline: bigint;
689
- /**
690
- * Recipient of native-ETH output. Required when `tokenOut` is `address(0)`,
691
- * since the explicit-recipient `TAKE` action forwards the bought ETH there
692
- * (the implicit-recipient `TAKE_ALL` would leave it held by the router).
693
- */
694
- recipient?: Address;
695
- /** Hook data; defaults to `0x` (hook-less pools). */
696
- hookData?: Hex;
797
+ interface UniswapV4Addresses {
798
+ /** Universal Router (v4-capable build) — entrypoint for `execute(...)`. */
799
+ universalRouter: Address;
800
+ /** V4Quoter — `quoteExactInputSingle` (revert/staticcall-based). */
801
+ v4Quoter: Address;
802
+ /** Uniswap v4 PoolManager (singleton). */
803
+ poolManager: Address;
804
+ /** Uniswap v4 PositionManager (posm) — ERC721 LP position NFTs. */
805
+ positionManager: Address;
806
+ /** Canonical Permit2 (same address on every chain). */
807
+ permit2: Address;
697
808
  }
698
809
  /**
699
- * Build the typed `execute(...)` args + msg.value for an exact-in single-hop v4
700
- * swap. Use this when submitting via viem (`writeContract` / `submitWrite`).
701
- *
702
- * When `tokenOut` is native ETH the explicit-recipient `TAKE` action forwards
703
- * the bought ETH to `recipient` (no trailing SWEEP is needed for exact-in).
704
- *
705
- * @returns `args` ready to spread into `execute` and the ETH `value` to send
706
- * (= `amountIn` for native-ETH input, otherwise `0n`).
707
- */
708
- declare function buildV4SwapExecuteArgs(args: BuildV4SwapCalldataArgs): {
709
- args: readonly [Hex, readonly Hex[], bigint];
710
- value: bigint;
711
- };
712
- /**
713
- * Build the `execute(commands, inputs, deadline)` calldata + msg.value for an
714
- * exact-in single-hop v4 swap.
715
- *
716
- * @returns The encoded calldata and the ETH `value` to send.
717
- */
718
- declare function buildV4SwapExecuteCalldata(args: BuildV4SwapCalldataArgs): {
719
- data: Hex;
720
- value: bigint;
721
- };
722
- /**
723
- * Arguments for {@link buildV4ExactOutSwapExecuteCalldata}.
810
+ * Canonical Permit2, identical across all chains.
724
811
  */
725
- interface BuildV4ExactOutSwapCalldataArgs {
726
- /** The v4 PoolKey (currency0, currency1, fee, tickSpacing, hooks). */
727
- poolKey: PoolKey;
728
- /** Whether the swap goes currency0 → currency1. */
729
- zeroForOne: boolean;
730
- /** Exact output amount to receive (uint128). */
731
- amountOut: bigint;
732
- /** Maximum acceptable input to spend (uint128). */
733
- amountInMaximum: bigint;
734
- /** Input token address (`address(0)` for native ETH). */
735
- tokenIn: Address;
736
- /** Output token address (`address(0)` for native ETH). */
737
- tokenOut: Address;
738
- /** Absolute deadline (unix seconds). */
739
- deadline: bigint;
740
- /**
741
- * Recipient of any swept native-ETH refund (only used for native-ETH input).
742
- * Must be the payer; the leftover `amountInMaximum - actualInput` is returned
743
- * here.
744
- */
745
- recipient: Address;
746
- /** Hook data; defaults to `0x` (hook-less pools). */
747
- hookData?: Hex;
748
- }
812
+ declare const PERMIT2_ADDRESS: Address;
749
813
  /**
750
- * Build the typed `execute(...)` args + msg.value for an exact-out single-hop v4
751
- * swap. Use this when submitting via viem (`writeContract` / `submitWrite`).
752
- *
753
- * For native-ETH input, `value` is `amountInMaximum` (an overpay) and a trailing
754
- * `SWEEP` action refunds the unused ETH to `recipient`. For ERC20 input, Permit2
755
- * pulls only the settled amount, so no SWEEP is appended and `value` is `0n`.
814
+ * Verified Uniswap v4 deployment addresses keyed by chainId.
756
815
  *
757
- * @returns `args` ready to spread into `execute` and the ETH `value` to send.
816
+ * Sourced from the official Uniswap v4 deployments. Add a chain here only after
817
+ * verifying each address against the canonical Uniswap deployment listing —
818
+ * Universal Router in particular is NOT the same address across chains.
758
819
  */
759
- declare function buildV4ExactOutSwapExecuteArgs(args: BuildV4ExactOutSwapCalldataArgs): {
760
- args: readonly [Hex, readonly Hex[], bigint];
761
- value: bigint;
762
- };
820
+ declare const UNISWAP_V4_ADDRESSES: Record<number, UniswapV4Addresses>;
763
821
  /**
764
- * Build the `execute(commands, inputs, deadline)` calldata + msg.value for an
765
- * exact-out single-hop v4 swap.
822
+ * Resolve the Uniswap v4 addresses for a chain, applying optional overrides.
766
823
  *
767
- * @returns The encoded calldata and the ETH `value` to send.
768
- */
769
- declare function buildV4ExactOutSwapExecuteCalldata(args: BuildV4ExactOutSwapCalldataArgs): {
770
- data: Hex;
771
- value: bigint;
772
- };
773
-
774
- //#endregion
775
- //#region src/uniswap/v4/router/errors.d.ts
776
- /**
777
- * The chain has no configured Uniswap v4 addresses and none were supplied via
778
- * overrides.
779
- */
780
- declare class UnsupportedChainError extends PanopticError {
781
- readonly chainId: bigint;
782
- readonly name = "UnsupportedChainError";
783
- constructor(chainId: bigint, cause?: Error);
784
- }
785
- /**
786
- * `tokenIn` is neither `currency0` nor `currency1` of the resolved pool.
787
- */
788
- declare class InvalidSwapTokenError extends PanopticError {
789
- readonly token: Address;
790
- readonly currency0: Address;
791
- readonly currency1: Address;
792
- readonly name = "InvalidSwapTokenError";
793
- constructor(token: Address, currency0: Address, currency1: Address, cause?: Error);
794
- }
795
- /**
796
- * An amount exceeds the uint128 range required by the v4 swap encoding.
797
- */
798
- declare class AmountExceedsUint128Error extends PanopticError {
799
- readonly amount: bigint;
800
- readonly name = "AmountExceedsUint128Error";
801
- constructor(amount: bigint, cause?: Error);
802
- }
803
- /**
804
- * A native-ETH swap needs a trailing Universal Router SWEEP to deliver the ETH
805
- * output (or refund the input overpay), but no `recipient` was supplied.
806
- */
807
- declare class MissingSweepRecipientError extends PanopticError {
808
- readonly name = "MissingSweepRecipientError";
809
- constructor(cause?: Error);
810
- }
811
- /**
812
- * The V4Quoter is not available for the chain (no fallback in v1).
824
+ * @param chainId - Target chain ID.
825
+ * @param overrides - Partial override of any address (e.g. for fork tests).
826
+ * @returns Fully-resolved {@link UniswapV4Addresses}.
827
+ * @throws {UnsupportedChainError} when the chain is not listed and the
828
+ * overrides do not supply every required address.
813
829
  */
814
- declare class QuoterUnavailableError extends PanopticError {
815
- readonly chainId: bigint;
816
- readonly name = "QuoterUnavailableError";
817
- constructor(chainId: bigint, cause?: Error);
818
- }
830
+ declare function getUniswapV4Addresses(chainId: bigint, overrides?: Partial<UniswapV4Addresses>): UniswapV4Addresses;
819
831
 
820
832
  //#endregion
821
833
  //#region src/uniswap/v4/router/types.d.ts
@@ -881,8 +893,8 @@ interface SwapExactInQuote {
881
893
  zeroForOne: boolean;
882
894
  /** Output token address (`address(0)` for native ETH). */
883
895
  tokenOut: Address;
884
- /** Resolved v4 PoolKey (reused by the swap calldata builder). */
885
- poolKey: PoolKey;
896
+ /** Resolved v4 PoolKey (reused by the v4 swap calldata builder; absent for v3). */
897
+ poolKey?: PoolKey;
886
898
  /** Quoter's gas estimate. */
887
899
  gasEstimate: bigint;
888
900
  }
@@ -948,8 +960,8 @@ interface SwapExactOutQuote {
948
960
  zeroForOne: boolean;
949
961
  /** Output token address (`address(0)` for native ETH). */
950
962
  tokenOut: Address;
951
- /** Resolved v4 PoolKey (reused by the swap calldata builder). */
952
- poolKey: PoolKey;
963
+ /** Resolved v4 PoolKey (reused by the v4 swap calldata builder; absent for v3). */
964
+ poolKey?: PoolKey;
953
965
  /** Quoter's gas estimate. */
954
966
  gasEstimate: bigint;
955
967
  }
@@ -1018,6 +1030,244 @@ interface ApproveRouterViaPermit2Params {
1018
1030
  addresses?: Partial<UniswapV4Addresses>;
1019
1031
  }
1020
1032
 
1033
+ //#endregion
1034
+ //#region src/uniswap/v3/router/quoteViaRouter.d.ts
1035
+ interface QuoteSwapExactInViaV3RouterParams {
1036
+ client: PublicClient;
1037
+ poolAddress: Address;
1038
+ chainId: bigint;
1039
+ tokenIn: Address;
1040
+ amountIn: bigint;
1041
+ slippageBps: bigint;
1042
+ blockNumber?: bigint;
1043
+ addresses?: Partial<UniswapV3Addresses>;
1044
+ }
1045
+ declare function quoteSwapExactInViaV3Router(params: QuoteSwapExactInViaV3RouterParams): Promise<SimulationResult<SwapExactInQuote>>;
1046
+ interface QuoteSwapExactOutViaV3RouterParams {
1047
+ client: PublicClient;
1048
+ poolAddress: Address;
1049
+ chainId: bigint;
1050
+ tokenIn: Address;
1051
+ amountOut: bigint;
1052
+ slippageBps: bigint;
1053
+ blockNumber?: bigint;
1054
+ addresses?: Partial<UniswapV3Addresses>;
1055
+ }
1056
+ declare function quoteSwapExactOutViaV3Router(params: QuoteSwapExactOutViaV3RouterParams): Promise<SimulationResult<SwapExactOutQuote>>;
1057
+
1058
+ //#endregion
1059
+ //#region src/uniswap/v3/router/resolveRoute.d.ts
1060
+ interface ResolvedV3SwapRoute {
1061
+ tokenIn: Address;
1062
+ tokenOut: Address;
1063
+ fee: bigint;
1064
+ zeroForOne: boolean;
1065
+ }
1066
+ interface ResolveV3SwapRouteParams {
1067
+ client: PublicClient;
1068
+ poolAddress: Address;
1069
+ tokenIn: Address;
1070
+ }
1071
+ declare function resolveV3SwapRoute(params: ResolveV3SwapRouteParams): Promise<ResolvedV3SwapRoute>;
1072
+
1073
+ //#endregion
1074
+ //#region src/uniswap/v3/router/swap.d.ts
1075
+ interface SwapExactInViaV3RouterParams {
1076
+ client: PublicClient;
1077
+ walletClient: WalletClient;
1078
+ account: Address;
1079
+ poolAddress: Address;
1080
+ chainId: bigint;
1081
+ tokenIn: Address;
1082
+ amountIn: bigint;
1083
+ slippageBps: bigint;
1084
+ deadline?: bigint;
1085
+ recipient?: Address;
1086
+ txOverrides?: TxOverrides;
1087
+ addresses?: Partial<UniswapV3Addresses & UniswapV4Addresses>;
1088
+ }
1089
+ declare function swapExactInViaV3Router(params: SwapExactInViaV3RouterParams): Promise<TxResult>;
1090
+ interface SwapExactOutViaV3RouterParams {
1091
+ client: PublicClient;
1092
+ walletClient: WalletClient;
1093
+ account: Address;
1094
+ poolAddress: Address;
1095
+ chainId: bigint;
1096
+ tokenIn: Address;
1097
+ amountOut: bigint;
1098
+ slippageBps: bigint;
1099
+ deadline?: bigint;
1100
+ recipient?: Address;
1101
+ txOverrides?: TxOverrides;
1102
+ addresses?: Partial<UniswapV3Addresses & UniswapV4Addresses>;
1103
+ }
1104
+ declare function swapExactOutViaV3Router(params: SwapExactOutViaV3RouterParams): Promise<TxResult>;
1105
+
1106
+ //#endregion
1107
+ //#region src/uniswap/v4/router/encodeSwap.d.ts
1108
+ /** Universal Router command byte for a v4 swap. */
1109
+ declare const V4_SWAP = 16;
1110
+ /** v4 action: exact-in single-hop swap. */
1111
+ declare const SWAP_EXACT_IN_SINGLE = 6;
1112
+ /** v4 action: pay all of the input currency owed. */
1113
+ declare const SETTLE_ALL = 12;
1114
+ /** v4 action: take all of the output currency owed. */
1115
+ declare const TAKE_ALL = 15;
1116
+ /** v4 action: take an output currency to an explicit recipient. */
1117
+
1118
+ /** v4 action: exact-out single-hop swap. */
1119
+ declare const SWAP_EXACT_OUT_SINGLE = 8;
1120
+ /** Universal Router command: sweep the router's token balance to a recipient. */
1121
+ declare const SWEEP = 4;
1122
+ /**
1123
+ * Arguments for {@link buildV4SwapExecuteCalldata}.
1124
+ */
1125
+ interface BuildV4SwapCalldataArgs {
1126
+ /** The v4 PoolKey (currency0, currency1, fee, tickSpacing, hooks). */
1127
+ poolKey: PoolKey;
1128
+ /** Whether the swap goes currency0 → currency1. */
1129
+ zeroForOne: boolean;
1130
+ /** Exact input amount (uint128). */
1131
+ amountIn: bigint;
1132
+ /** Minimum acceptable output (uint128). */
1133
+ amountOutMinimum: bigint;
1134
+ /** Input token address (`address(0)` for native ETH). */
1135
+ tokenIn: Address;
1136
+ /** Output token address (`address(0)` for native ETH). */
1137
+ tokenOut: Address;
1138
+ /** Absolute deadline (unix seconds). */
1139
+ deadline: bigint;
1140
+ /**
1141
+ * Recipient of native-ETH output. Required when `tokenOut` is `address(0)`,
1142
+ * since the explicit-recipient `TAKE` action forwards the bought ETH there
1143
+ * (the implicit-recipient `TAKE_ALL` would leave it held by the router).
1144
+ */
1145
+ recipient?: Address;
1146
+ /** Hook data; defaults to `0x` (hook-less pools). */
1147
+ hookData?: Hex;
1148
+ }
1149
+ /**
1150
+ * Build the typed `execute(...)` args + msg.value for an exact-in single-hop v4
1151
+ * swap. Use this when submitting via viem (`writeContract` / `submitWrite`).
1152
+ *
1153
+ * When `tokenOut` is native ETH the explicit-recipient `TAKE` action forwards
1154
+ * the bought ETH to `recipient` (no trailing SWEEP is needed for exact-in).
1155
+ *
1156
+ * @returns `args` ready to spread into `execute` and the ETH `value` to send
1157
+ * (= `amountIn` for native-ETH input, otherwise `0n`).
1158
+ */
1159
+ declare function buildV4SwapExecuteArgs(args: BuildV4SwapCalldataArgs): {
1160
+ args: readonly [Hex, readonly Hex[], bigint];
1161
+ value: bigint;
1162
+ };
1163
+ /**
1164
+ * Build the `execute(commands, inputs, deadline)` calldata + msg.value for an
1165
+ * exact-in single-hop v4 swap.
1166
+ *
1167
+ * @returns The encoded calldata and the ETH `value` to send.
1168
+ */
1169
+ declare function buildV4SwapExecuteCalldata(args: BuildV4SwapCalldataArgs): {
1170
+ data: Hex;
1171
+ value: bigint;
1172
+ };
1173
+ /**
1174
+ * Arguments for {@link buildV4ExactOutSwapExecuteCalldata}.
1175
+ */
1176
+ interface BuildV4ExactOutSwapCalldataArgs {
1177
+ /** The v4 PoolKey (currency0, currency1, fee, tickSpacing, hooks). */
1178
+ poolKey: PoolKey;
1179
+ /** Whether the swap goes currency0 → currency1. */
1180
+ zeroForOne: boolean;
1181
+ /** Exact output amount to receive (uint128). */
1182
+ amountOut: bigint;
1183
+ /** Maximum acceptable input to spend (uint128). */
1184
+ amountInMaximum: bigint;
1185
+ /** Input token address (`address(0)` for native ETH). */
1186
+ tokenIn: Address;
1187
+ /** Output token address (`address(0)` for native ETH). */
1188
+ tokenOut: Address;
1189
+ /** Absolute deadline (unix seconds). */
1190
+ deadline: bigint;
1191
+ /**
1192
+ * Recipient of any swept native-ETH refund (only used for native-ETH input).
1193
+ * Must be the payer; the leftover `amountInMaximum - actualInput` is returned
1194
+ * here.
1195
+ */
1196
+ recipient: Address;
1197
+ /** Hook data; defaults to `0x` (hook-less pools). */
1198
+ hookData?: Hex;
1199
+ }
1200
+ /**
1201
+ * Build the typed `execute(...)` args + msg.value for an exact-out single-hop v4
1202
+ * swap. Use this when submitting via viem (`writeContract` / `submitWrite`).
1203
+ *
1204
+ * For native-ETH input, `value` is `amountInMaximum` (an overpay) and a trailing
1205
+ * `SWEEP` action refunds the unused ETH to `recipient`. For ERC20 input, Permit2
1206
+ * pulls only the settled amount, so no SWEEP is appended and `value` is `0n`.
1207
+ *
1208
+ * @returns `args` ready to spread into `execute` and the ETH `value` to send.
1209
+ */
1210
+ declare function buildV4ExactOutSwapExecuteArgs(args: BuildV4ExactOutSwapCalldataArgs): {
1211
+ args: readonly [Hex, readonly Hex[], bigint];
1212
+ value: bigint;
1213
+ };
1214
+ /**
1215
+ * Build the `execute(commands, inputs, deadline)` calldata + msg.value for an
1216
+ * exact-out single-hop v4 swap.
1217
+ *
1218
+ * @returns The encoded calldata and the ETH `value` to send.
1219
+ */
1220
+ declare function buildV4ExactOutSwapExecuteCalldata(args: BuildV4ExactOutSwapCalldataArgs): {
1221
+ data: Hex;
1222
+ value: bigint;
1223
+ };
1224
+
1225
+ //#endregion
1226
+ //#region src/uniswap/v4/router/errors.d.ts
1227
+ /**
1228
+ * The chain has no configured Uniswap v4 addresses and none were supplied via
1229
+ * overrides.
1230
+ */
1231
+ declare class UnsupportedChainError extends PanopticError {
1232
+ readonly chainId: bigint;
1233
+ readonly name = "UnsupportedChainError";
1234
+ constructor(chainId: bigint, cause?: Error);
1235
+ }
1236
+ /**
1237
+ * `tokenIn` is neither `currency0` nor `currency1` of the resolved pool.
1238
+ */
1239
+ declare class InvalidSwapTokenError extends PanopticError {
1240
+ readonly token: Address;
1241
+ readonly currency0: Address;
1242
+ readonly currency1: Address;
1243
+ readonly name = "InvalidSwapTokenError";
1244
+ constructor(token: Address, currency0: Address, currency1: Address, cause?: Error);
1245
+ }
1246
+ /**
1247
+ * An amount exceeds the uint128 range required by the v4 swap encoding.
1248
+ */
1249
+ declare class AmountExceedsUint128Error extends PanopticError {
1250
+ readonly amount: bigint;
1251
+ readonly name = "AmountExceedsUint128Error";
1252
+ constructor(amount: bigint, cause?: Error);
1253
+ }
1254
+ /**
1255
+ * A native-ETH swap needs a trailing Universal Router SWEEP to deliver the ETH
1256
+ * output (or refund the input overpay), but no `recipient` was supplied.
1257
+ */
1258
+ declare class MissingSweepRecipientError extends PanopticError {
1259
+ readonly name = "MissingSweepRecipientError";
1260
+ constructor(cause?: Error);
1261
+ }
1262
+ /**
1263
+ * The V4Quoter is not available for the chain (no fallback in v1).
1264
+ */
1265
+ declare class QuoterUnavailableError extends PanopticError {
1266
+ readonly chainId: bigint;
1267
+ readonly name = "QuoterUnavailableError";
1268
+ constructor(chainId: bigint, cause?: Error);
1269
+ }
1270
+
1021
1271
  //#endregion
1022
1272
  //#region src/uniswap/v4/router/permit2.d.ts
1023
1273
  /**
@@ -1162,5 +1412,5 @@ declare function swapExactOutViaRouter(params: SwapExactOutViaRouterParams): Pro
1162
1412
  declare function swapExactOutViaRouterAndWait(params: SwapExactOutViaRouterParams): Promise<TxReceipt>;
1163
1413
 
1164
1414
  //#endregion
1165
- export { AmountExceedsUint128Error, ApproveErc20ForPermit2Params, ApproveRouterViaPermit2Params, BuildV3SwapCalldataArgs, BuildV4ExactOutSwapCalldataArgs, BuildV4SwapCalldataArgs, CheckRouterApprovalParams, InvalidSwapTokenError, LpAmounts, LpGreeks, LpGreeksInput, MSG_SENDER, MissingSweepRecipientError, PERMIT2_ADDRESS, QuoteSwapExactInViaRouterParams, QuoteSwapExactOutViaRouterParams, QuoteV3ExactInParams, QuoteV4ExactInByPoolKeyParams, QuoterUnavailableError, ResolveSwapRouteParams, ResolvedSwapRoute, RouterApprovalStatus, SETTLE_ALL, SWAP_EXACT_IN_SINGLE, SWAP_EXACT_OUT_SINGLE, SWEEP, SwapExactInQuote, SwapExactInViaRouterParams, SwapExactOutQuote, SwapExactOutViaRouterParams, TAKE_ALL, UNISWAP_V3_ADDRESSES, UNISWAP_V4_ADDRESSES, UniswapV3Addresses, UniswapV4Addresses, UnsupportedChainError, V3ExactInQuote, V3_SWAP_EXACT_IN, V4ExactInQuote, V4_SWAP, approveErc20ForPermit2, approveErc20ForPermit2AndWait, approveRouterViaPermit2, approveRouterViaPermit2AndWait, buildV3SwapExecuteArgs, buildV3SwapExecuteCalldata, buildV4ExactOutSwapExecuteArgs, buildV4ExactOutSwapExecuteCalldata, buildV4SwapExecuteArgs, buildV4SwapExecuteCalldata, checkRouterApproval, encodeV3Path, getAmountsForLiquidity, getLpGreeks, getUniswapV3Addresses, getUniswapV4Addresses, quoteSwapExactInViaRouter, quoteSwapExactOutViaRouter, quoteV3ExactIn, quoteV4ExactInByPoolKey, resolveSwapRoute, swapExactInViaRouter, swapExactInViaRouterAndWait, swapExactOutViaRouter, swapExactOutViaRouterAndWait };
1415
+ export { AmountExceedsUint128Error, ApproveErc20ForPermit2Params, ApproveRouterViaPermit2Params, BuildV3ExactOutSwapCalldataArgs, BuildV3SwapCalldataArgs, BuildV4ExactOutSwapCalldataArgs, BuildV4SwapCalldataArgs, CheckRouterApprovalParams, InvalidSwapTokenError, LpAmounts, LpFeeCandle, LpFeeRange, LpGreeks, LpGreeksInput, LpPositionFundingParams, MSG_SENDER, MissingSweepRecipientError, PERMIT2_ADDRESS, QuoteSwapExactInViaRouterParams, QuoteSwapExactInViaV3RouterParams, QuoteSwapExactOutViaRouterParams, QuoteSwapExactOutViaV3RouterParams, QuoteV3ExactInParams, QuoteV3ExactOutParams, QuoteV4ExactInByPoolKeyParams, QuoterUnavailableError, ResolveSwapRouteParams, ResolveV3SwapRouteParams, ResolvedSwapRoute, ResolvedV3SwapRoute, RouterApprovalStatus, SETTLE_ALL, SWAP_EXACT_IN_SINGLE, SWAP_EXACT_OUT_SINGLE, SWEEP, SwapExactInQuote, SwapExactInViaRouterParams, SwapExactInViaV3RouterParams, SwapExactOutQuote, SwapExactOutViaRouterParams, SwapExactOutViaV3RouterParams, TAKE_ALL, UNISWAP_V3_ADDRESSES, UNISWAP_V4_ADDRESSES, UniswapV3Addresses, UniswapV4Addresses, UnsupportedChainError, V3ExactInQuote, V3ExactOutQuote, V3_SWAP_EXACT_IN, V3_SWAP_EXACT_OUT, V4ExactInQuote, V4_SWAP, annualizeLpFeeReturn, approveErc20ForPermit2, approveErc20ForPermit2AndWait, approveRouterViaPermit2, approveRouterViaPermit2AndWait, buildV3ExactOutSwapExecuteArgs, buildV3ExactOutSwapExecuteCalldata, buildV3SwapExecuteArgs, buildV3SwapExecuteCalldata, buildV4ExactOutSwapExecuteArgs, buildV4ExactOutSwapExecuteCalldata, buildV4SwapExecuteArgs, buildV4SwapExecuteCalldata, checkRouterApproval, encodeV3Path, estimateLpFees, getAmountsForLiquidity, getLpDepositAmounts, getLpDepositBreakdown, getLpFeeReturnSeries, getLpFundingDeposit, getLpGreeks, getLpPositionFunding, getMaxLpPositionSize, getUniswapV3Addresses, getUniswapV4Addresses, quoteSwapExactInViaRouter, quoteSwapExactInViaV3Router, quoteSwapExactOutViaRouter, quoteSwapExactOutViaV3Router, quoteV3ExactIn, quoteV3ExactOut, quoteV4ExactInByPoolKey, resolveSwapRoute, resolveV3SwapRoute, swapExactInViaRouter, swapExactInViaRouterAndWait, swapExactInViaV3Router, swapExactOutViaRouter, swapExactOutViaRouterAndWait, swapExactOutViaV3Router };
1166
1416
  //# sourceMappingURL=index.d.ts.map