@panoptic-eng/sdk 1.0.38 → 1.0.39

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 (80) hide show
  1. package/dist/cow/index.d.ts +804 -5
  2. package/dist/cow/index.d.ts.map +1 -0
  3. package/dist/cow/index.js +5268 -5
  4. package/dist/cow/index.js.map +1 -0
  5. package/dist/{cow-DB8siv6M.js → cow-tRUtAUZy.js} +2 -3
  6. package/dist/{getTrackedPositionIds-zYPIs5dt.js → getTrackedPositionIds-ms3W9dYB.js} +1 -2
  7. package/dist/greeks-GysWXct-.js +1 -2
  8. package/dist/index.d.ts +5752 -4
  9. package/dist/index.d.ts.map +1 -1
  10. package/dist/index.js +11952 -2130
  11. package/dist/index.js.map +1 -1
  12. package/dist/{irm-ChkvYphK.js → irm-SPC2KxLA.js} +321 -3
  13. package/dist/panoptic/v2/greeks/index.d.ts +277 -4
  14. package/dist/panoptic/v2/greeks/index.d.ts.map +1 -0
  15. package/dist/panoptic/v2/greeks/index.js +620 -2
  16. package/dist/panoptic/v2/greeks/index.js.map +1 -0
  17. package/dist/panoptic/v2/index.d.ts +14633 -7
  18. package/dist/panoptic/v2/index.d.ts.map +1 -0
  19. package/dist/panoptic/v2/index.js +27875 -9
  20. package/dist/panoptic/v2/index.js.map +1 -0
  21. package/dist/panoptic/v2/react-public.d.ts +14779 -15
  22. package/dist/panoptic/v2/react-public.d.ts.map +1 -1
  23. package/dist/panoptic/v2/react-public.js +29463 -89
  24. package/dist/panoptic/v2/react-public.js.map +1 -1
  25. package/dist/{router-tCRa0ekE.js → router-BTfbaRfg.js} +2 -3
  26. package/dist/{router-BCUJkY8j.js → router-mLWy0MD9.js} +3 -4
  27. package/dist/test/index.d.ts +3 -3
  28. package/dist/test/index.d.ts.map +1 -1
  29. package/dist/test/index.js +2 -2
  30. package/dist/{transactionFees-CVi2TrJh.js → transactionFees-C_Qx07mx.js} +1 -2
  31. package/dist/uniswap/index.d.ts +813 -78
  32. package/dist/uniswap/index.d.ts.map +1 -1
  33. package/dist/uniswap/index.js +5884 -13
  34. package/dist/uniswap/index.js.map +1 -1
  35. package/dist/{v2-BxtzpUnV.js → v2-DG7qG6di.js} +4 -5
  36. package/dist/vault-transaction-fees.d.ts +63 -2
  37. package/dist/vault-transaction-fees.d.ts.map +1 -0
  38. package/dist/vault-transaction-fees.js +174 -2
  39. package/dist/vault-transaction-fees.js.map +1 -0
  40. package/dist/{writes-D3bj1wth.js → writes-Xp9Wa8GQ.js} +2 -3
  41. package/package.json +4 -3
  42. package/dist/cow/types.d.ts +0 -4
  43. package/dist/cow/types.js +0 -0
  44. package/dist/cow-DB8siv6M.js.map +0 -1
  45. package/dist/getTrackedPositionIds-zYPIs5dt.js.map +0 -1
  46. package/dist/greeks-GysWXct-.js.map +0 -1
  47. package/dist/hypoVault/vaultDisplayNames.d.ts +0 -2
  48. package/dist/hypoVault/vaultDisplayNames.js +0 -4
  49. package/dist/index-BhEBx83X.d.ts +0 -9760
  50. package/dist/index-BhEBx83X.d.ts.map +0 -1
  51. package/dist/index-Bo9tHtD7.d.ts +0 -1901
  52. package/dist/index-Bo9tHtD7.d.ts.map +0 -1
  53. package/dist/index-CttjEZ-S.d.ts +0 -275
  54. package/dist/index-CttjEZ-S.d.ts.map +0 -1
  55. package/dist/index-DktZq9Kb.d.ts +0 -261
  56. package/dist/index-DktZq9Kb.d.ts.map +0 -1
  57. package/dist/irm-ChkvYphK.js.map +0 -1
  58. package/dist/irm-D2WTHtuo.d.ts +0 -5667
  59. package/dist/irm-D2WTHtuo.d.ts.map +0 -1
  60. package/dist/irm-D5plRhpB.d.ts +0 -32
  61. package/dist/irm-D5plRhpB.d.ts.map +0 -1
  62. package/dist/panoptic/v2/types/index.d.ts +0 -3
  63. package/dist/panoptic/v2/types/index.js +0 -0
  64. package/dist/quote-DeHNUR0Z.d.ts +0 -52
  65. package/dist/quote-DeHNUR0Z.d.ts.map +0 -1
  66. package/dist/router-BCUJkY8j.js.map +0 -1
  67. package/dist/router-tCRa0ekE.js.map +0 -1
  68. package/dist/src-CRAtPwWk.js +0 -321
  69. package/dist/src-CRAtPwWk.js.map +0 -1
  70. package/dist/transactionFees-CVi2TrJh.js.map +0 -1
  71. package/dist/transactionFees-DzDyt50k.d.ts +0 -63
  72. package/dist/transactionFees-DzDyt50k.d.ts.map +0 -1
  73. package/dist/types-Cad5m4Td.d.ts +0 -246
  74. package/dist/types-Cad5m4Td.d.ts.map +0 -1
  75. package/dist/types-DM0nxlZr.d.ts +0 -128
  76. package/dist/types-DM0nxlZr.d.ts.map +0 -1
  77. package/dist/v2-BxtzpUnV.js.map +0 -1
  78. package/dist/vaultDisplayNames-CKpz51Hu.js +0 -0
  79. package/dist/vaultDisplayNames-Q6htUcch.d.ts +0 -2
  80. package/dist/writes-D3bj1wth.js.map +0 -1
@@ -1,12 +1,113 @@
1
- import { PanopticError, PoolKey, SimulationResult, TxReceipt, TxResult } from "../index-Bo9tHtD7.js";
2
- import "../irm-D5plRhpB.js";
3
- import { QuoteV3ExactInParams, UNISWAP_V3_ADDRESSES$1 as UNISWAP_V3_ADDRESSES, UniswapV3Addresses, V3ExactInQuote, getUniswapV3Addresses$1 as getUniswapV3Addresses, quoteV3ExactIn$1 as quoteV3ExactIn } from "../quote-DeHNUR0Z.js";
4
- import { ApproveErc20ForPermit2Params, ApproveRouterViaPermit2Params, CheckRouterApprovalParams, PERMIT2_ADDRESS$1 as PERMIT2_ADDRESS, QuoteSwapExactInViaRouterParams, QuoteSwapExactOutViaRouterParams, RouterApprovalStatus, SwapExactInQuote, SwapExactInViaRouterParams, SwapExactOutQuote, SwapExactOutViaRouterParams, UNISWAP_V4_ADDRESSES$1 as UNISWAP_V4_ADDRESSES, UniswapV4Addresses, getUniswapV4Addresses$1 as getUniswapV4Addresses } from "../types-Cad5m4Td.js";
5
- import { Address, Hex, PublicClient } from "viem";
1
+ import { Address, Hash, Hex, PublicClient, WalletClient } from "viem";
6
2
 
7
- //#region src/uniswap/v3/router/encodeSwap.d.ts
8
- /** Universal Router command byte for a v3 exact-in swap. */
3
+ //#region src/uniswap/lpGreeks.d.ts
4
+ /**
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
+ /**
24
+ * Greeks for plain (non-Panoptic) Uniswap v3/v4 concentrated-liquidity LP
25
+ * positions. Pure math over on-chain position fields (liquidity + tick range)
26
+ * and the pool's current price — no RPC, no protocol dependency.
27
+ *
28
+ * Units follow the Panoptic v2 greeks convention (see
29
+ * `packages/sdk/src/panoptic/v2/greeks/index.ts`) so a caller can present LP
30
+ * and Panoptic greeks side by side:
31
+ * - `value` → numeraire-token smallest units
32
+ * - `delta` → asset-token smallest units (the asset held by the LP)
33
+ * - `gamma` → numeraire-token smallest units (dollar-gamma `P²·d²V/dP²`;
34
+ * always ≤ 0 because an LP is short gamma)
35
+ *
36
+ * `assetIndex` selects which token is the "asset" (the volatile leg being
37
+ * hedged): `0` → token0 is the asset / token1 the numeraire; `1` → the reverse.
38
+ *
39
+ * @module uniswap/lpGreeks
40
+ */
41
+ /** Token amounts currently backing a concentrated-liquidity position. */
42
+ interface LpAmounts {
43
+ /** token0 amount in its smallest units. */
44
+ amount0: bigint;
45
+ /** token1 amount in its smallest units. */
46
+ amount1: bigint;
47
+ }
48
+ /** Greeks of a Uniswap LP position in one asset frame (see module docs for units). */
49
+ interface LpGreeks {
50
+ /** Position value in numeraire-token smallest units. */
51
+ value: bigint;
52
+ /** Delta in asset-token smallest units (the asset amount the LP is long). */
53
+ delta: bigint;
54
+ /** Dollar-gamma in numeraire-token smallest units; ≤ 0 (LP is short gamma). */
55
+ gamma: bigint;
56
+ }
57
+ /** Inputs describing a single LP position + the pool's current price. */
58
+ interface LpGreeksInput {
59
+ /** Position liquidity `L`. */
60
+ liquidity: bigint;
61
+ /** Lower tick of the range. */
62
+ tickLower: bigint;
63
+ /** Upper tick of the range. */
64
+ tickUpper: bigint;
65
+ /** Pool's current tick. */
66
+ currentTick: bigint;
67
+ /** Which token is the asset: `0` (token0) or `1` (token1). */
68
+ assetIndex: 0 | 1;
69
+ }
70
+ /**
71
+ * Compute the token0/token1 amounts backing `liquidity` over `[sqrtA, sqrtB]`
72
+ * at the current price `sqrtP`, mirroring Uniswap's `LiquidityAmounts`
73
+ * (`getAmountsForLiquidity`). All sqrt prices are X96. The current price is
74
+ * clamped into the range, so out-of-range positions collapse to a single token.
75
+ */
76
+ declare function getAmountsForLiquidity(sqrtPriceX96: bigint, sqrtRatioAX96: bigint, sqrtRatioBX96: bigint, liquidity: bigint): LpAmounts;
77
+ /**
78
+ * Greeks (value, delta, gamma) for a Uniswap LP position in the chosen asset
79
+ * frame. See the module docs for the unit conventions.
80
+ *
81
+ * Closed forms (in-range, numeraire = token1 / asset = token0):
82
+ * value = amount1 + amount0·P (P = sqrtP² / 2^192)
83
+ * delta = amount0 (= dV/dP)
84
+ * gamma = P²·d²V/dP² = -L·sqrt(P)/2 (short gamma)
85
+ * The `assetIndex = 1` frame is the symmetric inverse (numeraire = token0).
86
+ * Gamma is zero when the price is outside the range (no curvature there).
87
+ */
88
+ declare function getLpGreeks(input: LpGreeksInput): LpGreeks; //#endregion
89
+ //#region src/uniswap/v3/addresses.d.ts
90
+ interface UniswapV3Addresses {
91
+ /** Uniswap v3 QuoterV2 — `quoteExactInputSingle` (revert/staticcall-based). */
92
+ quoterV2: Address;
93
+ /** Uniswap v3 NonfungiblePositionManager — ERC721 LP position NFTs. */
94
+ nonfungiblePositionManager: Address;
95
+ }
96
+ /**
97
+ * Verified Uniswap v3 QuoterV2 addresses keyed by chainId. Add a chain only
98
+ * after verifying against the canonical Uniswap v3 deployment listing.
99
+ */
100
+ declare const UNISWAP_V3_ADDRESSES: Record<number, UniswapV3Addresses>;
101
+ /**
102
+ * Resolve Uniswap v3 addresses for a chain, applying optional overrides.
103
+ *
104
+ * @throws {UnsupportedChainError} when the chain is not listed and overrides do
105
+ * not supply every required address.
106
+ */
107
+ declare function getUniswapV3Addresses(chainId: number | bigint, overrides?: Partial<UniswapV3Addresses>): UniswapV3Addresses;
9
108
 
109
+ //#endregion
110
+ //#region src/uniswap/v3/router/encodeSwap.d.ts
10
111
  /** Universal Router command byte for a v3 exact-in swap. */
11
112
  declare const V3_SWAP_EXACT_IN = 0;
12
113
  /**
@@ -51,8 +152,508 @@ declare function buildV3SwapExecuteArgs(args: BuildV3SwapCalldataArgs): {
51
152
  declare function buildV3SwapExecuteCalldata(args: BuildV3SwapCalldataArgs): {
52
153
  data: Hex;
53
154
  value: bigint;
54
- }; //#endregion
155
+ };
156
+
157
+ //#endregion
158
+ //#region src/uniswap/v3/router/quote.d.ts
159
+ interface QuoteV3ExactInParams {
160
+ client: PublicClient;
161
+ chainId: bigint;
162
+ tokenIn: Address;
163
+ tokenOut: Address;
164
+ fee: bigint;
165
+ amountIn: bigint;
166
+ /** Slippage tolerance in bps, used to compute `amountOutMinimum`. */
167
+ slippageBps: bigint;
168
+ blockNumber?: bigint;
169
+ addresses?: Partial<UniswapV3Addresses>;
170
+ }
171
+ interface V3ExactInQuote {
172
+ amountOut: bigint;
173
+ amountOutMinimum: bigint;
174
+ gasEstimate: bigint;
175
+ }
176
+ /**
177
+ * Quote an exact-in v3 swap. Returns `null` when the quote reverts (e.g. the
178
+ * pool does not exist / has no liquidity) so callers can skip that pool when
179
+ * ranking venues, rather than aborting the whole cycle.
180
+ */
181
+ 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;
199
+ }
200
+ /**
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.
220
+ */
221
+ declare function getUniswapV4Addresses(chainId: bigint, overrides?: Partial<UniswapV4Addresses>): UniswapV4Addresses;
222
+
223
+ //#endregion
224
+ //#region src/panoptic/v2/types/meta.d.ts
225
+ /**
226
+ * Block metadata types for the Panoptic v2 SDK.
227
+ * @module v2/types/meta
228
+ */
229
+ /**
230
+ * Block metadata attached to all RPC responses.
231
+ * Used for freshness checks and reorg detection.
232
+ */
233
+ interface BlockMeta {
234
+ /** Block number when the data was fetched */
235
+ blockNumber: bigint;
236
+ /** Block timestamp in Unix seconds */
237
+ blockTimestamp: bigint;
238
+ /** Block hash for reorg detection */
239
+ blockHash: `0x${string}`;
240
+ /** Whether the data is considered stale */
241
+ isStale?: boolean;
242
+ }
243
+
244
+ //#endregion
245
+ //#region src/panoptic/v2/types/pool.d.ts
246
+ /**
247
+ * Uniswap V4 pool key.
248
+ */
249
+ interface PoolKey {
250
+ /** Token 0 address */
251
+ currency0: Address;
252
+ /** Token 1 address */
253
+ currency1: Address;
254
+ /** Fee tier */
255
+ fee: bigint;
256
+ /** Tick spacing */
257
+ tickSpacing: bigint;
258
+ /** Hook address (if any) */
259
+ hooks: Address;
260
+ }
261
+
262
+ //#endregion
263
+ //#region src/panoptic/v2/types/events.d.ts
264
+ /**
265
+ * Pool data returned by getPool().
266
+ */
267
+ /**
268
+ * Supported Panoptic event types.
269
+ */
270
+ type PanopticEventType = 'OptionMinted' | 'OptionBurnt' | 'AccountLiquidated' | 'ForcedExercised' | 'PremiumSettled' | 'Deposit' | 'Withdraw' | 'BorrowRateUpdated' | 'LiquidityChunkUpdated' | 'ProtocolLossRealized' | 'ModifyLiquidity' | 'Swap' | 'Donate';
271
+ /**
272
+ * Base event data common to all events.
273
+ */
274
+ interface BaseEvent {
275
+ /** Event type */
276
+ type: PanopticEventType;
277
+ /** Transaction hash */
278
+ transactionHash: Hash;
279
+ /** Block number */
280
+ blockNumber: bigint;
281
+ /** Block hash */
282
+ blockHash: Hash;
283
+ /** Log index within the block */
284
+ logIndex: bigint;
285
+ }
286
+ /**
287
+ * OptionMinted event data.
288
+ */
289
+ interface OptionMintedEvent extends BaseEvent {
290
+ type: 'OptionMinted';
291
+ /** Recipient of the minted position */
292
+ recipient: Address;
293
+ /** TokenId of the minted position */
294
+ tokenId: bigint;
295
+ /** Position size */
296
+ positionSize: bigint;
297
+ /** Pool utilization for token 0 at mint */
298
+ poolUtilization0: bigint;
299
+ /** Pool utilization for token 1 at mint */
300
+ poolUtilization1: bigint;
301
+ /** Tick at mint */
302
+ tickAtMint: bigint;
303
+ /** Timestamp at mint (Unix seconds) */
304
+ timestampAtMint: bigint;
305
+ /** Block number at mint */
306
+ blockAtMint: bigint;
307
+ /** Whether a swap happened at mint */
308
+ swapAtMint: boolean;
309
+ }
310
+ /**
311
+ * OptionBurnt event data.
312
+ */
313
+ interface OptionBurntEvent extends BaseEvent {
314
+ type: 'OptionBurnt';
315
+ /** Recipient (owner) of the burnt position */
316
+ recipient: Address;
317
+ /** TokenId of the burnt position */
318
+ tokenId: bigint;
319
+ /** Position size that was burnt */
320
+ positionSize: bigint;
321
+ /** Premia settled for each leg (token0 right, token1 left per leg) */
322
+ premiaByLeg: readonly [bigint, bigint, bigint, bigint];
323
+ }
324
+ /**
325
+ * AccountLiquidated event data.
326
+ */
327
+ interface AccountLiquidatedEvent extends BaseEvent {
328
+ type: 'AccountLiquidated';
329
+ /** Address of the liquidator */
330
+ liquidator: Address;
331
+ /** Address of the liquidated account */
332
+ liquidatee: Address;
333
+ /** Bonus paid to liquidator for token 0 */
334
+ bonusAmount0: bigint;
335
+ /** Bonus paid to liquidator for token 1 */
336
+ bonusAmount1: bigint;
337
+ }
338
+ /**
339
+ * ForcedExercised event data.
340
+ */
341
+ interface ForcedExercisedEvent extends BaseEvent {
342
+ type: 'ForcedExercised';
343
+ /** Address of the exerciser */
344
+ exercisor: Address;
345
+ /** Address of the position owner */
346
+ user: Address;
347
+ /** TokenId of the exercised position */
348
+ tokenId: bigint;
349
+ /** Exercise fee for token 0 (negative = cost to exerciser) */
350
+ exerciseFee0: bigint;
351
+ /** Exercise fee for token 1 (negative = cost to exerciser) */
352
+ exerciseFee1: bigint;
353
+ }
354
+ /**
355
+ * PremiumSettled event data.
356
+ */
357
+ interface PremiumSettledEvent extends BaseEvent {
358
+ type: 'PremiumSettled';
359
+ /** Position owner */
360
+ user: Address;
361
+ /** TokenId */
362
+ tokenId: bigint;
363
+ /** Leg index that was settled */
364
+ legIndex: bigint;
365
+ /** Settled amount for token 0 */
366
+ settledAmount0: bigint;
367
+ /** Settled amount for token 1 */
368
+ settledAmount1: bigint;
369
+ }
370
+ /**
371
+ * Deposit event data (ERC4626).
372
+ */
373
+ interface DepositEvent extends BaseEvent {
374
+ type: 'Deposit';
375
+ /** Sender address */
376
+ sender: Address;
377
+ /** Owner address */
378
+ owner: Address;
379
+ /** Assets deposited */
380
+ assets: bigint;
381
+ /** Shares minted */
382
+ shares: bigint;
383
+ }
384
+ /**
385
+ * Withdraw event data (ERC4626).
386
+ */
387
+ interface WithdrawEvent extends BaseEvent {
388
+ type: 'Withdraw';
389
+ /** Sender address */
390
+ sender: Address;
391
+ /** Receiver address */
392
+ receiver: Address;
393
+ /** Owner address */
394
+ owner: Address;
395
+ /** Assets withdrawn */
396
+ assets: bigint;
397
+ /** Shares burned */
398
+ shares: bigint;
399
+ }
400
+ /**
401
+ * BorrowRateUpdated event data (RiskEngine).
402
+ */
403
+ interface BorrowRateUpdatedEvent extends BaseEvent {
404
+ type: 'BorrowRateUpdated';
405
+ /** Collateral token address */
406
+ collateralToken: Address;
407
+ /** Average borrow rate */
408
+ avgBorrowRate: bigint;
409
+ /** Rate at target utilization */
410
+ rateAtTarget: bigint;
411
+ }
412
+ /**
413
+ * LiquidityChunkUpdated event data (SFPM).
414
+ */
415
+ interface LiquidityChunkUpdatedEvent extends BaseEvent {
416
+ type: 'LiquidityChunkUpdated';
417
+ /** Pool ID (bytes32) */
418
+ poolId: Hash;
419
+ /** Owner address */
420
+ owner: Address;
421
+ /** Token type (0 or 1) */
422
+ tokenType: bigint;
423
+ /** Lower tick */
424
+ tickLower: number;
425
+ /** Upper tick */
426
+ tickUpper: number;
427
+ /** Liquidity delta (positive = added, negative = removed) */
428
+ liquidityDelta: bigint;
429
+ }
430
+ /**
431
+ * ProtocolLossRealized event data (CollateralTracker).
432
+ */
433
+ interface ProtocolLossRealizedEvent extends BaseEvent {
434
+ type: 'ProtocolLossRealized';
435
+ /** Liquidated account */
436
+ liquidatee: Address;
437
+ /** Liquidator address */
438
+ liquidator: Address;
439
+ /** Protocol loss in assets */
440
+ protocolLossAssets: bigint;
441
+ /** Protocol loss in shares */
442
+ protocolLossShares: bigint;
443
+ }
444
+ /**
445
+ * ModifyLiquidity event data (v4 PoolManager).
446
+ */
447
+ interface ModifyLiquidityEvent extends BaseEvent {
448
+ type: 'ModifyLiquidity';
449
+ /** Pool ID (bytes32) */
450
+ id: Hash;
451
+ /** Sender address */
452
+ sender: Address;
453
+ /** Lower tick */
454
+ tickLower: number;
455
+ /** Upper tick */
456
+ tickUpper: number;
457
+ /** Liquidity delta */
458
+ liquidityDelta: bigint;
459
+ /** Salt */
460
+ salt: Hash;
461
+ }
462
+ /**
463
+ * Swap event data (v4 PoolManager).
464
+ */
465
+ interface SwapEvent extends BaseEvent {
466
+ type: 'Swap';
467
+ /** Pool ID (bytes32) */
468
+ id: Hash;
469
+ /** Sender address */
470
+ sender: Address;
471
+ /** Amount of token 0 */
472
+ amount0: bigint;
473
+ /** Amount of token 1 */
474
+ amount1: bigint;
475
+ /** Square root price X96 */
476
+ sqrtPriceX96: bigint;
477
+ /** Liquidity */
478
+ liquidity: bigint;
479
+ /** Tick */
480
+ tick: number;
481
+ /** Fee */
482
+ fee: number;
483
+ }
484
+ /**
485
+ * Donate event data (v4 PoolManager).
486
+ */
487
+ interface DonateEvent extends BaseEvent {
488
+ type: 'Donate';
489
+ /** Pool ID (bytes32) */
490
+ id: Hash;
491
+ /** Sender address */
492
+ sender: Address;
493
+ /** Amount of token 0 */
494
+ amount0: bigint;
495
+ /** Amount of token 1 */
496
+ amount1: bigint;
497
+ }
498
+ /**
499
+ * Union of all Panoptic event types.
500
+ */
501
+ type PanopticEvent = OptionMintedEvent | OptionBurntEvent | AccountLiquidatedEvent | ForcedExercisedEvent | PremiumSettledEvent | DepositEvent | WithdrawEvent | BorrowRateUpdatedEvent | LiquidityChunkUpdatedEvent | ProtocolLossRealizedEvent | ModifyLiquidityEvent | SwapEvent | DonateEvent;
502
+
503
+ //#endregion
504
+ //#region src/panoptic/v2/types/tx.d.ts
505
+ /**
506
+ * Leg update data from events.
507
+ */
508
+ /**
509
+ * Transaction result returned by write functions.
510
+ * Provides immediate access to hash and a wait function for confirmation.
511
+ */
512
+ interface TxResult {
513
+ /** Transaction hash, available immediately */
514
+ hash: Hash;
515
+ /** Wait for transaction confirmation */
516
+ wait: (confirmations?: bigint) => Promise<TxReceipt>;
517
+ }
518
+ /**
519
+ * Transaction result with receipt already awaited.
520
+ * Returned by *AndWait convenience functions.
521
+ */
522
+
523
+ /**
524
+ * Transaction receipt after confirmation.
525
+ */
526
+ interface TxReceipt {
527
+ /** Transaction hash */
528
+ hash: Hash;
529
+ /** Block number */
530
+ blockNumber: bigint;
531
+ /** Block hash */
532
+ blockHash: Hash;
533
+ /** Gas used */
534
+ gasUsed: bigint;
535
+ /** Transaction status */
536
+ status: 'success' | 'reverted';
537
+ /** Parsed Panoptic events from the transaction */
538
+ events: PanopticEvent[];
539
+ }
540
+ /**
541
+ * Transaction broadcaster interface for private transaction support.
542
+ * Allows plugging in Flashbots or other MEV protection services.
543
+ */
544
+ interface TxBroadcaster {
545
+ /**
546
+ * Broadcast a signed transaction.
547
+ * @param signedTx - The signed transaction bytes
548
+ * @returns The transaction hash
549
+ */
550
+ broadcast: (signedTx: `0x${string}`) => Promise<Hash>;
551
+ }
552
+ /**
553
+ * Gas and transaction overrides for write operations.
554
+ * Supports EIP-1559 gas parameters, explicit nonce, and custom broadcasters.
555
+ */
556
+ interface TxOverrides {
557
+ /** EIP-1559 max fee per gas */
558
+ maxFeePerGas?: bigint;
559
+ /** EIP-1559 max priority fee per gas (tip) */
560
+ maxPriorityFeePerGas?: bigint;
561
+ /** Gas limit override */
562
+ gas?: bigint;
563
+ /** Explicit nonce (for concurrent tx submission) */
564
+ nonce?: bigint;
565
+ /** Custom broadcaster for MEV protection (Flashbots, private mempool) */
566
+ broadcaster?: TxBroadcaster;
567
+ }
568
+
569
+ //#endregion
570
+ //#region src/panoptic/v2/errors/base.d.ts
571
+ /**
572
+ * Nonce manager for concurrent transaction submission.
573
+ */
574
+ /**
575
+ * Base error class for the Panoptic v2 SDK.
576
+ * @module v2/errors/base
577
+ */
578
+ /**
579
+ * Base error class for all Panoptic SDK errors.
580
+ * All errors thrown by the SDK extend this class.
581
+ *
582
+ * @example
583
+ * ```typescript
584
+ * try {
585
+ * await openPosition(config, params)
586
+ * } catch (error) {
587
+ * if (error instanceof PanopticError) {
588
+ * console.log('Panoptic error:', error.name, error.message)
589
+ * console.log('Original cause:', error.cause)
590
+ * }
591
+ * }
592
+ * ```
593
+ */
594
+ declare class PanopticError extends Error {
595
+ readonly cause?: Error | undefined;
596
+ readonly name: string;
597
+ /** The Solidity error name (e.g. 'PriceBoundFail', 'InputListFail'). Set by the parser. */
598
+ errorName?: string;
599
+ /**
600
+ * Creates a new PanopticError.
601
+ *
602
+ * @param message - Human-readable error message
603
+ * @param cause - Optional underlying error that caused this error
604
+ */
605
+ constructor(message: string, cause?: Error | undefined);
606
+ }
607
+
608
+ //#endregion
609
+ //#region src/panoptic/v2/types/simulation.d.ts
610
+ /**
611
+ * Token flow data from simulation.
612
+ * Measures collateral asset changes via getAssetsOf-dispatch-getAssetsOf pattern
613
+ * using PanopticPool.multicall.
614
+ */
615
+ interface TokenFlow {
616
+ /** Token 0 collateral change (negative = user deposits, positive = user receives) */
617
+ delta0: bigint;
618
+ /** Token 1 collateral change (negative = user deposits, positive = user receives) */
619
+ delta1: bigint;
620
+ /** Collateral assets in token 0 before the call */
621
+ balanceBefore0: bigint;
622
+ /** Collateral assets in token 1 before the call */
623
+ balanceBefore1: bigint;
624
+ /** Collateral assets in token 0 after the call */
625
+ balanceAfter0: bigint;
626
+ /** Collateral assets in token 1 after the call */
627
+ balanceAfter1: bigint;
628
+ /** Pool tick before the operation */
629
+ tickBefore: bigint | null;
630
+ /** Pool tick after the operation */
631
+ tickAfter: bigint | null;
632
+ }
633
+ /**
634
+ * Simulation result discriminated union.
635
+ * Success case returns data, failure case returns error.
636
+ *
637
+ * Note: tokenFlow is optional because some simulations (deposit/withdraw)
638
+ * don't use the PanopticPool.multicall token flow measurement.
639
+ */
640
+ type SimulationResult<T> = {
641
+ success: true;
642
+ data: T;
643
+ gasEstimate: bigint;
644
+ tokenFlow?: TokenFlow;
645
+ _meta: BlockMeta;
646
+ } | {
647
+ success: false;
648
+ error: PanopticError;
649
+ _meta: BlockMeta;
650
+ };
651
+
652
+ //#endregion
55
653
  //#region src/uniswap/v4/router/encodeSwap.d.ts
654
+ /**
655
+ * Open position simulation result data.
656
+ */
56
657
  /** Universal Router command byte for a v4 swap. */
57
658
  declare const V4_SWAP = 16;
58
659
  /** v4 action: exact-in single-hop swap. */
@@ -168,7 +769,9 @@ declare function buildV4ExactOutSwapExecuteArgs(args: BuildV4ExactOutSwapCalldat
168
769
  declare function buildV4ExactOutSwapExecuteCalldata(args: BuildV4ExactOutSwapCalldataArgs): {
169
770
  data: Hex;
170
771
  value: bigint;
171
- }; //#endregion
772
+ };
773
+
774
+ //#endregion
172
775
  //#region src/uniswap/v4/router/errors.d.ts
173
776
  /**
174
777
  * The chain has no configured Uniswap v4 addresses and none were supplied via
@@ -214,6 +817,207 @@ declare class QuoterUnavailableError extends PanopticError {
214
817
  constructor(chainId: bigint, cause?: Error);
215
818
  }
216
819
 
820
+ //#endregion
821
+ //#region src/uniswap/v4/router/types.d.ts
822
+ /**
823
+ * Parameters for {@link swapExactInViaRouter}.
824
+ */
825
+ interface SwapExactInViaRouterParams {
826
+ /** Public client for reads + receipts. */
827
+ client: PublicClient;
828
+ /** Wallet client for signing. */
829
+ walletClient: WalletClient;
830
+ /** Account address. */
831
+ account: Address;
832
+ /** PanopticPool address — used to resolve the underlying v4 PoolKey. */
833
+ poolAddress: Address;
834
+ /** Chain ID (selects per-chain Uniswap v4 addresses). */
835
+ chainId: bigint;
836
+ /** Token to sell. `address(0)` (zero address) for native ETH. */
837
+ tokenIn: Address;
838
+ /** Exact amount of `tokenIn` to spend (must fit uint128). */
839
+ amountIn: bigint;
840
+ /** Slippage tolerance in bps (e.g. 500n = 5%). */
841
+ slippageBps: bigint;
842
+ /** Absolute deadline (unix seconds). If omitted, derived from block timestamp. */
843
+ deadline?: bigint;
844
+ /** Recipient of the output. Defaults to `account`. */
845
+ recipient?: Address;
846
+ /** Gas and transaction overrides. */
847
+ txOverrides?: TxOverrides;
848
+ /** Override per-chain Uniswap v4 addresses (e.g. fork tests). */
849
+ addresses?: Partial<UniswapV4Addresses>;
850
+ }
851
+ /**
852
+ * Parameters for {@link quoteSwapExactInViaRouter}.
853
+ */
854
+ interface QuoteSwapExactInViaRouterParams {
855
+ /** Public client. */
856
+ client: PublicClient;
857
+ /** PanopticPool address — used to resolve the underlying v4 PoolKey. */
858
+ poolAddress: Address;
859
+ /** Chain ID. */
860
+ chainId: bigint;
861
+ /** Token to sell. `address(0)` for native ETH. */
862
+ tokenIn: Address;
863
+ /** Exact amount of `tokenIn` to spend (must fit uint128). */
864
+ amountIn: bigint;
865
+ /** Slippage tolerance in bps (used to compute `amountOutMinimum`). */
866
+ slippageBps: bigint;
867
+ /** Optional block number for the quote. */
868
+ blockNumber?: bigint;
869
+ /** Override per-chain Uniswap v4 addresses (e.g. fork tests). */
870
+ addresses?: Partial<UniswapV4Addresses>;
871
+ }
872
+ /**
873
+ * Quote result data (carried inside a `SimulationResult`).
874
+ */
875
+ interface SwapExactInQuote {
876
+ /** Quoted output amount of `tokenOut`. */
877
+ amountOut: bigint;
878
+ /** Minimum acceptable output after applying slippage. */
879
+ amountOutMinimum: bigint;
880
+ /** Whether the swap goes currency0 → currency1. */
881
+ zeroForOne: boolean;
882
+ /** Output token address (`address(0)` for native ETH). */
883
+ tokenOut: Address;
884
+ /** Resolved v4 PoolKey (reused by the swap calldata builder). */
885
+ poolKey: PoolKey;
886
+ /** Quoter's gas estimate. */
887
+ gasEstimate: bigint;
888
+ }
889
+ /**
890
+ * Parameters for {@link swapExactOutViaRouter}.
891
+ */
892
+ interface SwapExactOutViaRouterParams {
893
+ /** Public client for reads + receipts. */
894
+ client: PublicClient;
895
+ /** Wallet client for signing. */
896
+ walletClient: WalletClient;
897
+ /** Account address. */
898
+ account: Address;
899
+ /** PanopticPool address — used to resolve the underlying v4 PoolKey. */
900
+ poolAddress: Address;
901
+ /** Chain ID (selects per-chain Uniswap v4 addresses). */
902
+ chainId: bigint;
903
+ /** Token to sell (the pay token). `address(0)` (zero address) for native ETH. */
904
+ tokenIn: Address;
905
+ /** Exact amount of the output token to receive (must fit uint128). */
906
+ amountOut: bigint;
907
+ /** Slippage tolerance in bps (e.g. 500n = 5%); caps the input. */
908
+ slippageBps: bigint;
909
+ /** Absolute deadline (unix seconds). If omitted, derived from block timestamp. */
910
+ deadline?: bigint;
911
+ /** Recipient of the output. Defaults to `account`. */
912
+ recipient?: Address;
913
+ /** Gas and transaction overrides. */
914
+ txOverrides?: TxOverrides;
915
+ /** Override per-chain Uniswap v4 addresses (e.g. fork tests). */
916
+ addresses?: Partial<UniswapV4Addresses>;
917
+ }
918
+ /**
919
+ * Parameters for {@link quoteSwapExactOutViaRouter}.
920
+ */
921
+ interface QuoteSwapExactOutViaRouterParams {
922
+ /** Public client. */
923
+ client: PublicClient;
924
+ /** PanopticPool address — used to resolve the underlying v4 PoolKey. */
925
+ poolAddress: Address;
926
+ /** Chain ID. */
927
+ chainId: bigint;
928
+ /** Token to sell (the pay token). `address(0)` for native ETH. */
929
+ tokenIn: Address;
930
+ /** Exact amount of the output token to receive (must fit uint128). */
931
+ amountOut: bigint;
932
+ /** Slippage tolerance in bps (used to compute `amountInMaximum`). */
933
+ slippageBps: bigint;
934
+ /** Optional block number for the quote. */
935
+ blockNumber?: bigint;
936
+ /** Override per-chain Uniswap v4 addresses (e.g. fork tests). */
937
+ addresses?: Partial<UniswapV4Addresses>;
938
+ }
939
+ /**
940
+ * Quote result data for an exact-out swap (carried inside a `SimulationResult`).
941
+ */
942
+ interface SwapExactOutQuote {
943
+ /** Quoted input amount of `tokenIn` required for the exact output. */
944
+ amountIn: bigint;
945
+ /** Maximum acceptable input after applying slippage. */
946
+ amountInMaximum: bigint;
947
+ /** Whether the swap goes currency0 → currency1. */
948
+ zeroForOne: boolean;
949
+ /** Output token address (`address(0)` for native ETH). */
950
+ tokenOut: Address;
951
+ /** Resolved v4 PoolKey (reused by the swap calldata builder). */
952
+ poolKey: PoolKey;
953
+ /** Quoter's gas estimate. */
954
+ gasEstimate: bigint;
955
+ }
956
+ /**
957
+ * Parameters for {@link checkRouterApproval}.
958
+ */
959
+ interface CheckRouterApprovalParams {
960
+ /** Public client. */
961
+ client: PublicClient;
962
+ /** Chain ID. */
963
+ chainId: bigint;
964
+ /** ERC20 token being spent (must not be native ETH). */
965
+ tokenIn: Address;
966
+ /** Token owner. */
967
+ owner: Address;
968
+ /** Amount that must be spendable. */
969
+ amount: bigint;
970
+ /** Override per-chain Uniswap v4 addresses (e.g. fork tests). */
971
+ addresses?: Partial<UniswapV4Addresses>;
972
+ }
973
+ /**
974
+ * Result of {@link checkRouterApproval}.
975
+ */
976
+ interface RouterApprovalStatus {
977
+ /** ERC20 → Permit2 allowance is insufficient. */
978
+ needsErc20Approval: boolean;
979
+ /** Permit2 → Universal Router allowance is insufficient or expired. */
980
+ needsPermit2Approval: boolean;
981
+ /** Current ERC20 → Permit2 allowance. */
982
+ erc20Allowance: bigint;
983
+ /** Current Permit2 → router allowance amount. */
984
+ permit2Amount: bigint;
985
+ /** Current Permit2 → router allowance expiration (unix seconds). */
986
+ permit2Expiration: bigint;
987
+ }
988
+ /**
989
+ * Parameters for {@link approveErc20ForPermit2}.
990
+ */
991
+ interface ApproveErc20ForPermit2Params {
992
+ client: PublicClient;
993
+ walletClient: WalletClient;
994
+ account: Address;
995
+ chainId: bigint;
996
+ /** ERC20 token to approve to Permit2. */
997
+ tokenIn: Address;
998
+ /** Amount to approve. Defaults to uint256 max. */
999
+ amount?: bigint;
1000
+ txOverrides?: TxOverrides;
1001
+ addresses?: Partial<UniswapV4Addresses>;
1002
+ }
1003
+ /**
1004
+ * Parameters for {@link approveRouterViaPermit2}.
1005
+ */
1006
+ interface ApproveRouterViaPermit2Params {
1007
+ client: PublicClient;
1008
+ walletClient: WalletClient;
1009
+ account: Address;
1010
+ chainId: bigint;
1011
+ /** ERC20 token the router is allowed to spend via Permit2. */
1012
+ tokenIn: Address;
1013
+ /** Amount to approve (must fit uint160). Defaults to uint160 max. */
1014
+ amount?: bigint;
1015
+ /** Allowance expiration (unix seconds, uint48). If omitted, block timestamp + 30 days. */
1016
+ expiration?: bigint;
1017
+ txOverrides?: TxOverrides;
1018
+ addresses?: Partial<UniswapV4Addresses>;
1019
+ }
1020
+
217
1021
  //#endregion
218
1022
  //#region src/uniswap/v4/router/permit2.d.ts
219
1023
  /**
@@ -357,75 +1161,6 @@ declare function swapExactOutViaRouter(params: SwapExactOutViaRouterParams): Pro
357
1161
  */
358
1162
  declare function swapExactOutViaRouterAndWait(params: SwapExactOutViaRouterParams): Promise<TxReceipt>;
359
1163
 
360
- //#endregion
361
- //#region src/uniswap/lpGreeks.d.ts
362
- /**
363
- * Greeks for plain (non-Panoptic) Uniswap v3/v4 concentrated-liquidity LP
364
- * positions. Pure math over on-chain position fields (liquidity + tick range)
365
- * and the pool's current price — no RPC, no protocol dependency.
366
- *
367
- * Units follow the Panoptic v2 greeks convention (see
368
- * `packages/sdk/src/panoptic/v2/greeks/index.ts`) so a caller can present LP
369
- * and Panoptic greeks side by side:
370
- * - `value` → numeraire-token smallest units
371
- * - `delta` → asset-token smallest units (the asset held by the LP)
372
- * - `gamma` → numeraire-token smallest units (dollar-gamma `P²·d²V/dP²`;
373
- * always ≤ 0 because an LP is short gamma)
374
- *
375
- * `assetIndex` selects which token is the "asset" (the volatile leg being
376
- * hedged): `0` → token0 is the asset / token1 the numeraire; `1` → the reverse.
377
- *
378
- * @module uniswap/lpGreeks
379
- */
380
- /** Token amounts currently backing a concentrated-liquidity position. */
381
- interface LpAmounts {
382
- /** token0 amount in its smallest units. */
383
- amount0: bigint;
384
- /** token1 amount in its smallest units. */
385
- amount1: bigint;
386
- }
387
- /** Greeks of a Uniswap LP position in one asset frame (see module docs for units). */
388
- interface LpGreeks {
389
- /** Position value in numeraire-token smallest units. */
390
- value: bigint;
391
- /** Delta in asset-token smallest units (the asset amount the LP is long). */
392
- delta: bigint;
393
- /** Dollar-gamma in numeraire-token smallest units; ≤ 0 (LP is short gamma). */
394
- gamma: bigint;
395
- }
396
- /** Inputs describing a single LP position + the pool's current price. */
397
- interface LpGreeksInput {
398
- /** Position liquidity `L`. */
399
- liquidity: bigint;
400
- /** Lower tick of the range. */
401
- tickLower: bigint;
402
- /** Upper tick of the range. */
403
- tickUpper: bigint;
404
- /** Pool's current tick. */
405
- currentTick: bigint;
406
- /** Which token is the asset: `0` (token0) or `1` (token1). */
407
- assetIndex: 0 | 1;
408
- }
409
- /**
410
- * Compute the token0/token1 amounts backing `liquidity` over `[sqrtA, sqrtB]`
411
- * at the current price `sqrtP`, mirroring Uniswap's `LiquidityAmounts`
412
- * (`getAmountsForLiquidity`). All sqrt prices are X96. The current price is
413
- * clamped into the range, so out-of-range positions collapse to a single token.
414
- */
415
- declare function getAmountsForLiquidity(sqrtPriceX96: bigint, sqrtRatioAX96: bigint, sqrtRatioBX96: bigint, liquidity: bigint): LpAmounts;
416
- /**
417
- * Greeks (value, delta, gamma) for a Uniswap LP position in the chosen asset
418
- * frame. See the module docs for the unit conventions.
419
- *
420
- * Closed forms (in-range, numeraire = token1 / asset = token0):
421
- * value = amount1 + amount0·P (P = sqrtP² / 2^192)
422
- * delta = amount0 (= dV/dP)
423
- * gamma = P²·d²V/dP² = -L·sqrt(P)/2 (short gamma)
424
- * The `assetIndex = 1` frame is the symmetric inverse (numeraire = token0).
425
- * Gamma is zero when the price is outside the range (no curvature there).
426
- */
427
- declare function getLpGreeks(input: LpGreeksInput): LpGreeks;
428
-
429
1164
  //#endregion
430
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 };
431
1166
  //# sourceMappingURL=index.d.ts.map