@panoptic-eng/sdk 1.0.4 → 1.0.6

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 (42) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +75 -20
  3. package/dist/cow/index.d.ts +5 -0
  4. package/dist/cow/index.js +5 -0
  5. package/dist/cow/types.d.ts +4 -0
  6. package/dist/cow/types.js +0 -0
  7. package/dist/cow-Dy-Cd09v.js +1405 -0
  8. package/dist/cow-Dy-Cd09v.js.map +1 -0
  9. package/dist/index-BuJcj5aO.d.ts +275 -0
  10. package/dist/index-BuJcj5aO.d.ts.map +1 -0
  11. package/dist/index-DVMjZi1E.d.ts +1801 -0
  12. package/dist/index-DVMjZi1E.d.ts.map +1 -0
  13. package/dist/index.d.ts +6192 -2513
  14. package/dist/index.d.ts.map +1 -1
  15. package/dist/index.js +3242 -5537
  16. package/dist/index.js.map +1 -1
  17. package/dist/irm-CBrX8bjH.js +2375 -0
  18. package/dist/irm-CBrX8bjH.js.map +1 -0
  19. package/dist/irm-CGykVo3q.d.ts +32 -0
  20. package/dist/irm-CGykVo3q.d.ts.map +1 -0
  21. package/dist/irm-zWjtffWA.d.ts +85 -0
  22. package/dist/irm-zWjtffWA.d.ts.map +1 -0
  23. package/dist/panoptic/v2/index.d.ts +9370 -0
  24. package/dist/panoptic/v2/index.d.ts.map +1 -0
  25. package/dist/panoptic/v2/index.js +10765 -0
  26. package/dist/panoptic/v2/index.js.map +1 -0
  27. package/dist/panoptic/v2/types/index.d.ts +3 -0
  28. package/dist/panoptic/v2/types/index.js +0 -0
  29. package/dist/position-FxaZi608.js +10530 -0
  30. package/dist/position-FxaZi608.js.map +1 -0
  31. package/dist/router-gzYGM1OO.js +1012 -0
  32. package/dist/router-gzYGM1OO.js.map +1 -0
  33. package/dist/types-BQejAFnu.d.ts +245 -0
  34. package/dist/types-BQejAFnu.d.ts.map +1 -0
  35. package/dist/types-CRvvn2ce.d.ts +128 -0
  36. package/dist/types-CRvvn2ce.d.ts.map +1 -0
  37. package/dist/uniswap/index.d.ts +291 -0
  38. package/dist/uniswap/index.d.ts.map +1 -0
  39. package/dist/uniswap/index.js +5 -0
  40. package/dist/writes-CVCD6Ers.js +4302 -0
  41. package/dist/writes-CVCD6Ers.js.map +1 -0
  42. package/package.json +24 -7
@@ -0,0 +1,1801 @@
1
+ import { Address, Hash, PublicClient } from "viem";
2
+
3
+ //#region src/panoptic/v2/types/meta.d.ts
4
+ /**
5
+ * Block metadata types for the Panoptic v2 SDK.
6
+ * @module v2/types/meta
7
+ */
8
+ /**
9
+ * Block metadata attached to all RPC responses.
10
+ * Used for freshness checks and reorg detection.
11
+ */
12
+ /**
13
+ * Block metadata types for the Panoptic v2 SDK.
14
+ * @module v2/types/meta
15
+ */
16
+ /**
17
+ * Block metadata attached to all RPC responses.
18
+ * Used for freshness checks and reorg detection.
19
+ */
20
+ interface BlockMeta {
21
+ /** Block number when the data was fetched */
22
+ blockNumber: bigint;
23
+ /** Block timestamp in Unix seconds */
24
+ blockTimestamp: bigint;
25
+ /** Block hash for reorg detection */
26
+ blockHash: `0x${string}`;
27
+ /** Whether the data is considered stale */
28
+ isStale?: boolean;
29
+ } //#endregion
30
+ //#region src/panoptic/v2/formatters/tick.d.ts
31
+ /**
32
+ * Tick and price formatters for Uniswap V3/V4 pools.
33
+ *
34
+ * Ticks represent logarithmic prices where: price = 1.0001^tick
35
+ *
36
+ * @module v2/formatters/tick
37
+ */
38
+ declare function tickToSqrtPriceX96(tick: bigint): bigint;
39
+ /**
40
+ * Convert a tick to a raw price string (no decimal adjustment).
41
+ * Uses the formula: price = 1.0001^tick
42
+ *
43
+ * This returns the raw price ratio, not adjusted for token decimals.
44
+ * A fixed internal precision is used and trailing zeros are trimmed.
45
+ *
46
+ * @param tick - The tick value
47
+ * @returns Price string
48
+ *
49
+ * @example
50
+ * ```typescript
51
+ * tickToPrice(0n) // "1"
52
+ * tickToPrice(1000n) // "1.105..." (approximately)
53
+ * tickToPrice(-1000n) // "0.904..." (approximately)
54
+ * tickToPrice(200000n) // Very large number
55
+ * ```
56
+ */
57
+ declare function tickToPrice(tick: bigint): string;
58
+ /**
59
+ * Convert a tick to a human-readable price with decimal scaling.
60
+ * Uses the formula: price = 1.0001^tick * 10^(decimals0-decimals1)
61
+ *
62
+ * This adjusts for the different decimals of the two tokens in the pair.
63
+ *
64
+ * @param tick - The tick value
65
+ * @param decimals0 - Decimals of token0
66
+ * @param decimals1 - Decimals of token1
67
+ * @param precision - Number of decimal places to display
68
+ * @returns Formatted price string
69
+ *
70
+ * @example
71
+ * ```typescript
72
+ * // WETH/USDC pool (18 decimals / 6 decimals)
73
+ * // At tick ~200000, price is roughly $2000 per ETH
74
+ * tickToPriceDecimalScaled(200000n, 18n, 6n, 2n) // "2000.00" (approximately)
75
+ *
76
+ * // For token1/token0 price, swap the decimals
77
+ * tickToPriceDecimalScaled(200000n, 6n, 18n, 6n) // "0.000500" (approximately)
78
+ * ```
79
+ */
80
+ declare function tickToPriceDecimalScaled(tick: bigint, decimals0: bigint, decimals1: bigint, precision: bigint): string;
81
+ /**
82
+ * Convert a sqrtPriceX96 to a human-readable price with decimal scaling.
83
+ *
84
+ * Uses the formula: price = (sqrtPriceX96^2 / 2^192) * 10^(decimals0-decimals1)
85
+ *
86
+ * @param sqrtPriceX96 - The sqrt price in Q64.96 format
87
+ * @param decimals0 - Decimals of token0
88
+ * @param decimals1 - Decimals of token1
89
+ * @param precision - Number of decimal places to display
90
+ * @returns Formatted price string
91
+ *
92
+ * @example
93
+ * ```typescript
94
+ * sqrtPriceX96ToPriceDecimalScaled(2n ** 96n, 18n, 18n, 2n) // "1.00"
95
+ * ```
96
+ */
97
+ declare function sqrtPriceX96ToPriceDecimalScaled(sqrtPriceX96: bigint, decimals0: bigint, decimals1: bigint, precision: bigint): string;
98
+ /**
99
+ * Convert a price to a tick value.
100
+ *
101
+ * @param price - The price string
102
+ * @param decimals0 - Decimals of token0
103
+ * @param decimals1 - Decimals of token1
104
+ * @returns The tick value (rounded to nearest integer)
105
+ *
106
+ * @example
107
+ * ```typescript
108
+ * // WETH/USDC: What tick for $2000 per ETH?
109
+ * priceToTick("2000", 18n, 6n) // ~200000n
110
+ *
111
+ * // Inverse: What tick for 0.0005 ETH per USDC?
112
+ * priceToTick("0.0005", 6n, 18n) // ~200000n
113
+ * ```
114
+ */
115
+ declare function priceToTick(price: string, decimals0: bigint, decimals1: bigint): bigint;
116
+ /**
117
+ * Convert a sqrtPriceX96 value to the nearest tick.
118
+ *
119
+ * @param sqrtPriceX96 - The sqrt price in Q64.96 format
120
+ * @returns The tick value (rounded to nearest integer)
121
+ *
122
+ * @example
123
+ * ```typescript
124
+ * const tick = sqrtPriceX96ToTick(2n ** 96n) // 0n
125
+ * ```
126
+ */
127
+ declare function sqrtPriceX96ToTick(sqrtPriceX96: bigint): bigint;
128
+ /**
129
+ * Format a tick value for display.
130
+ *
131
+ * @param tick - The tick value
132
+ * @returns Formatted tick string
133
+ *
134
+ * @example
135
+ * ```typescript
136
+ * formatTick(200000n) // "200000"
137
+ * formatTick(-50000n) // "-50000"
138
+ * ```
139
+ */
140
+ declare function formatTick(tick: bigint): string;
141
+ /**
142
+ * Get the price at a specific tick, returning both token0/token1 and token1/token0 prices.
143
+ *
144
+ * @param tick - The tick value
145
+ * @param decimals0 - Decimals of token0
146
+ * @param decimals1 - Decimals of token1
147
+ * @param precision - Number of decimal places to display
148
+ * @returns Object with both price directions
149
+ *
150
+ * @example
151
+ * ```typescript
152
+ * const prices = getPricesAtTick(200000n, 18n, 6n, 2n)
153
+ * // prices.token0PerToken1 = "0.00" (very small)
154
+ * // prices.token1PerToken0 = "2000.00" (USDC per ETH)
155
+ * ```
156
+ */
157
+ declare function getPricesAtTick(tick: bigint, decimals0: bigint, decimals1: bigint, precision: bigint): {
158
+ token0PerToken1: string;
159
+ token1PerToken0: string;
160
+ };
161
+ /**
162
+ * Format a tick range for display.
163
+ *
164
+ * @param tickLower - Lower tick
165
+ * @param tickUpper - Upper tick
166
+ * @returns Formatted tick range string
167
+ *
168
+ * @example
169
+ * ```typescript
170
+ * formatTickRange(-50000n, 200000n) // "-50000 - 200000"
171
+ * ```
172
+ */
173
+ declare function formatTickRange(tickLower: bigint, tickUpper: bigint): string;
174
+ /**
175
+ * Format a price range for display.
176
+ *
177
+ * @param tickLower - Lower tick
178
+ * @param tickUpper - Upper tick
179
+ * @param decimals0 - Decimals of token0
180
+ * @param decimals1 - Decimals of token1
181
+ * @param precision - Number of decimal places to display
182
+ * @returns Formatted price range string
183
+ *
184
+ * @example
185
+ * ```typescript
186
+ * formatPriceRange(0n, 0n, 18n, 18n, 2n) // "1.00 - 1.00"
187
+ * ```
188
+ */
189
+ declare function formatPriceRange(tickLower: bigint, tickUpper: bigint, decimals0: bigint, decimals1: bigint, precision: bigint): string;
190
+ /**
191
+ * Calculate the tick spacing for a given fee tier.
192
+ *
193
+ * @param feeBps - Fee in basis points (e.g., 500n for 0.05%)
194
+ * @returns Tick spacing
195
+ *
196
+ * @example
197
+ * ```typescript
198
+ * getTickSpacing(100n) // 1n (0.01% fee tier)
199
+ * getTickSpacing(500n) // 10n (0.05% fee tier)
200
+ * getTickSpacing(3000n) // 60n (0.30% fee tier)
201
+ * getTickSpacing(10000n) // 200n (1.00% fee tier)
202
+ * ```
203
+ */
204
+ declare function getTickSpacing(feeBps: bigint): bigint;
205
+ /**
206
+ * Round a tick to the nearest valid tick for a given tick spacing.
207
+ *
208
+ * @param tick - The tick to round
209
+ * @param tickSpacing - The tick spacing
210
+ * @returns Rounded tick
211
+ *
212
+ * @example
213
+ * ```typescript
214
+ * roundToTickSpacing(12345n, 10n) // 12340n
215
+ * roundToTickSpacing(12345n, 60n) // 12360n
216
+ * roundToTickSpacing(-12345n, 10n) // -12350n
217
+ * ```
218
+ */
219
+ declare function roundToTickSpacing(tick: bigint, tickSpacing: bigint): bigint;
220
+ /**
221
+ * Result of {@link tickLimits}.
222
+ */
223
+ interface TickLimitsResult {
224
+ /** Lower tick limit (clamped to MIN_TICK). */
225
+ low: bigint;
226
+ /** Upper tick limit (clamped to MAX_TICK). */
227
+ high: bigint;
228
+ }
229
+ /**
230
+ * Compute slippage-bounded tick limits around the current tick.
231
+ *
232
+ * 1 tick ≈ 1 basis point (0.01 %) of price change, so a `toleranceBps`
233
+ * of 500 allows roughly 5 % price movement. The result is clamped to
234
+ * the protocol's `[MIN_TICK, MAX_TICK]` range.
235
+ *
236
+ * Useful for setting `tickLimitLow` / `tickLimitHigh` on `openPosition`
237
+ * and `closePosition` to protect against MEV sandwiches and volatile
238
+ * tick moves.
239
+ *
240
+ * @param currentTick - The current pool tick (must be within [MIN_TICK, MAX_TICK]).
241
+ * @param toleranceBps - Slippage tolerance in basis points (≈ ticks). Must be non-negative.
242
+ * @returns Clamped `{ low, high }` tick limits.
243
+ * @throws {RangeError} If `toleranceBps` is negative or `currentTick` is out of bounds.
244
+ *
245
+ * @example
246
+ * ```typescript
247
+ * const { low, high } = tickLimits(200_000n, 500n)
248
+ * // low = 199_500n
249
+ * // high = 200_500n
250
+ *
251
+ * await openPosition({ ..., tickLimitLow: low, tickLimitHigh: high })
252
+ * ```
253
+ */
254
+ declare function tickLimits(currentTick: bigint, toleranceBps: bigint): TickLimitsResult;
255
+
256
+ //#endregion
257
+ //#region src/panoptic/v2/reads/pool.d.ts
258
+ /**
259
+ * Immutable pool metadata that can be cached.
260
+ * These values never change for a given pool, so they're exempt from
261
+ * same-block consistency requirements (per PLAN.md "Static Prefetches" exception).
262
+ */
263
+ interface PoolMetadata {
264
+ /** Pool key bytes */
265
+ poolKeyBytes: `0x${string}`;
266
+ /** Pool ID */
267
+ poolId: bigint;
268
+ /** Collateral tracker 0 address */
269
+ collateralToken0Address: Address;
270
+ /** Collateral tracker 1 address */
271
+ collateralToken1Address: Address;
272
+ /** Risk engine address */
273
+ riskEngineAddress: Address;
274
+ /** Token 0 underlying asset address */
275
+ token0Asset: Address;
276
+ /** Token 1 underlying asset address */
277
+ token1Asset: Address;
278
+ /** Token 0 symbol */
279
+ token0Symbol: string;
280
+ /** Token 1 symbol */
281
+ token1Symbol: string;
282
+ /** Token 0 decimals */
283
+ token0Decimals: bigint;
284
+ /** Token 1 decimals */
285
+ token1Decimals: bigint;
286
+ /** Token 0 name */
287
+ token0Name: string;
288
+ /** Token 1 name */
289
+ token1Name: string;
290
+ /** Underlying pool ID (V3: pool address, V4: keccak256(poolKeyBytes)) */
291
+ underlyingPoolId: string;
292
+ /** Whether this is a V4 pool (poolManager is non-zero) */
293
+ isV4: boolean;
294
+ /** Tick spacing */
295
+ tickSpacing: bigint;
296
+ /** Fee tier (V4: from poolKey, V3: from Uniswap pool fee()) */
297
+ fee: bigint;
298
+ /** SemiFungiblePositionManager address */
299
+ sfpmAddress: Address;
300
+ }
301
+ /**
302
+ * Parameters for getPoolMetadata.
303
+ */
304
+ interface GetPoolMetadataParams {
305
+ /** viem PublicClient */
306
+ client: PublicClient;
307
+ /** PanopticPool address */
308
+ poolAddress: Address;
309
+ }
310
+ /**
311
+ * Fetch immutable pool metadata (addresses, symbols, decimals).
312
+ * This data never changes for a given pool and can be cached indefinitely.
313
+ *
314
+ * This is the "static prefetch" per PLAN.md §6 - exempt from same-block consistency.
315
+ *
316
+ * @param params - The parameters
317
+ * @returns Immutable pool metadata
318
+ */
319
+ declare function getPoolMetadata(params: GetPoolMetadataParams): Promise<PoolMetadata>;
320
+ /**
321
+ * Parameters for getPool.
322
+ */
323
+ interface GetPoolParams {
324
+ /** viem PublicClient */
325
+ client: PublicClient;
326
+ /** PanopticPool address */
327
+ poolAddress: Address;
328
+ /** Chain ID */
329
+ chainId: bigint;
330
+ /** Optional block number for historical queries */
331
+ blockNumber?: bigint;
332
+ /** Optional pre-fetched pool metadata (for caching/optimization) */
333
+ poolMetadata?: PoolMetadata;
334
+ /** Optional StateView address for V4 pools (needed to read Uniswap pool liquidity) */
335
+ stateViewAddress?: Address;
336
+ /** Optional pre-fetched block metadata (skips getBlockMeta RPC call) */
337
+ _meta?: BlockMeta;
338
+ }
339
+ /**
340
+ * Get full pool data including both collateral trackers and oracle state.
341
+ *
342
+ * ## Same-Block Guarantee
343
+ * All dynamic data is fetched in ONE multicall at the target block.
344
+ * Static metadata (addresses, symbols, decimals) is either provided via
345
+ * poolMetadata or fetched separately (static prefetch exception).
346
+ *
347
+ * @param params - The parameters
348
+ * @returns Pool data with block metadata
349
+ */
350
+ declare function getPool(params: GetPoolParams): Promise<Pool>;
351
+ /**
352
+ * Parameters for getUtilization.
353
+ */
354
+ interface GetUtilizationParams {
355
+ /** viem PublicClient */
356
+ client: PublicClient;
357
+ /** PanopticPool address */
358
+ poolAddress: Address;
359
+ /** Optional block number for historical queries */
360
+ blockNumber?: bigint;
361
+ /** Optional pre-fetched collateral tracker addresses (for caching/optimization) */
362
+ collateralAddresses?: {
363
+ collateralToken0: Address;
364
+ collateralToken1: Address;
365
+ };
366
+ /** Optional pre-fetched block metadata (skips getBlockMeta RPC call) */
367
+ _meta?: BlockMeta;
368
+ }
369
+ /**
370
+ * Get current pool utilization for both tokens.
371
+ *
372
+ * ## Same-Block Guarantee
373
+ * All dynamic data is fetched in ONE multicall at the target block.
374
+ * Collateral tracker addresses are either provided or fetched separately (static prefetch).
375
+ *
376
+ * @param params - The parameters
377
+ * @returns Utilization data with block metadata
378
+ */
379
+ declare function getUtilization(params: GetUtilizationParams): Promise<Utilization>;
380
+ /**
381
+ * Parameters for getOracleState.
382
+ */
383
+ interface GetOracleStateParams {
384
+ /** viem PublicClient */
385
+ client: PublicClient;
386
+ /** PanopticPool address */
387
+ poolAddress: Address;
388
+ /** Optional block number for historical queries */
389
+ blockNumber?: bigint;
390
+ /** Optional pre-fetched block metadata (skips getBlockMeta RPC call) */
391
+ _meta?: BlockMeta;
392
+ }
393
+ /**
394
+ * Get current oracle state from the pool.
395
+ *
396
+ * ## Same-Block Guarantee
397
+ * Single contract call + block meta fetch at the same block.
398
+ *
399
+ * @param params - The parameters
400
+ * @returns Oracle state with block metadata
401
+ */
402
+ declare function getOracleState(params: GetOracleStateParams): Promise<OracleState>;
403
+ /**
404
+ * Parameters for getRiskParameters.
405
+ */
406
+ interface GetRiskParametersParams {
407
+ /** viem PublicClient */
408
+ client: PublicClient;
409
+ /** PanopticPool address */
410
+ poolAddress: Address;
411
+ /** Builder code (default: 0) */
412
+ builderCode?: bigint;
413
+ /** Optional block number for historical queries */
414
+ blockNumber?: bigint;
415
+ /** Optional pre-fetched risk engine address (for caching/optimization) */
416
+ riskEngineAddress?: Address;
417
+ /** Optional pre-fetched block metadata (skips getBlockMeta RPC call) */
418
+ _meta?: BlockMeta;
419
+ }
420
+ /**
421
+ * Get risk parameters from the pool.
422
+ *
423
+ * ## Same-Block Guarantee
424
+ * All dynamic data is fetched in ONE multicall at the target block.
425
+ * Risk engine address is either provided or fetched separately (static prefetch).
426
+ *
427
+ * @param params - The parameters
428
+ * @returns Risk parameters with block metadata
429
+ */
430
+ declare function getRiskParameters(params: GetRiskParametersParams): Promise<RiskParameters>;
431
+ /**
432
+ * Validate whether a builder code maps to a deployed builder wallet.
433
+ *
434
+ * Calls `PanopticPool.getRiskParameters(builderCode)` — the contract reverts
435
+ * with `InvalidBuilderCode` when the computed CREATE2 address has no bytecode.
436
+ *
437
+ * @returns `true` when valid, `false` when the contract reverts.
438
+ */
439
+ declare function validateBuilderCode(params: {
440
+ client: PublicClient;
441
+ poolAddress: Address;
442
+ builderCode: bigint;
443
+ }): Promise<boolean>;
444
+ /**
445
+ * Parameters for fetchPoolId.
446
+ */
447
+ interface FetchPoolIdParams {
448
+ /** viem PublicClient */
449
+ client: PublicClient;
450
+ /** PanopticPool address */
451
+ poolAddress: Address;
452
+ }
453
+ /**
454
+ * Result of fetchPoolId, including block metadata for same-block consistency.
455
+ */
456
+ interface FetchPoolIdResult {
457
+ /** The encoded 64-bit pool ID */
458
+ poolId: bigint;
459
+ /** Block metadata from the pinned read */
460
+ _meta: BlockMeta;
461
+ }
462
+ /**
463
+ * Fetch the encoded 64-bit pool ID from a PanopticPool contract.
464
+ *
465
+ * Use this when you need the poolId without fetching the full pool state.
466
+ * The returned poolId can be passed directly to `createTokenIdBuilder()`.
467
+ * The read is pinned to the latest block at call time.
468
+ *
469
+ * @param params - The parameters
470
+ * @returns The pool ID and block metadata
471
+ */
472
+ declare function fetchPoolId(params: FetchPoolIdParams): Promise<FetchPoolIdResult>;
473
+
474
+ //#endregion
475
+ //#region src/panoptic/v2/types/pool.d.ts
476
+ /**
477
+ * Pool health status.
478
+ */
479
+ type PoolHealthStatus = 'active' | 'low_liquidity' | 'paused';
480
+ /**
481
+ * Collateral tracker information.
482
+ */
483
+ interface CollateralTracker {
484
+ /** Address of the collateral tracker contract */
485
+ address: Address;
486
+ /** Address of the underlying token */
487
+ token: Address;
488
+ /** Token symbol */
489
+ symbol: string;
490
+ /** Token decimals */
491
+ decimals: bigint;
492
+ /** Total assets accounted to the pool (deposited assets plus assets in the AMM) */
493
+ totalAssets: bigint;
494
+ /** Assets currently inside the AMM (deployed as liquidity) */
495
+ insideAMM: bigint;
496
+ /** Credited shares (shares owed to liquidity providers) */
497
+ creditedShares: bigint;
498
+ /** Total shares outstanding */
499
+ totalShares: bigint;
500
+ /** Current utilization (0-10000 bps) */
501
+ utilization: bigint;
502
+ /** Current borrow rate (annualized, WAD-scaled: 1e18 = 100%/year) */
503
+ borrowRate: bigint;
504
+ /** Current supply rate (annualized, WAD-scaled: 1e18 = 100%/year) */
505
+ supplyRate: bigint;
506
+ }
507
+ /**
508
+ * Risk engine information.
509
+ */
510
+ interface RiskEngine {
511
+ /** Address of the risk engine contract */
512
+ address: Address;
513
+ /** Collateral requirement factor (in bps) */
514
+ collateralRequirement: bigint;
515
+ /** Maintenance margin factor (in bps) */
516
+ maintenanceMargin: bigint;
517
+ /** Commission rate (in bps) */
518
+ commissionRate: bigint;
519
+ /** VEGOID constant used in spread calculation */
520
+ vegoid: bigint;
521
+ /** Maximum spread parameter (in bps) */
522
+ maxSpread: bigint;
523
+ }
524
+ /**
525
+ * Uniswap V4 pool key.
526
+ */
527
+ interface PoolKey {
528
+ /** Token 0 address */
529
+ currency0: Address;
530
+ /** Token 1 address */
531
+ currency1: Address;
532
+ /** Fee tier */
533
+ fee: bigint;
534
+ /** Tick spacing */
535
+ tickSpacing: bigint;
536
+ /** Hook address (if any) */
537
+ hooks: Address;
538
+ }
539
+ /**
540
+ * Pool data returned by getPool().
541
+ */
542
+ interface Pool {
543
+ /** Address of the PanopticPool contract */
544
+ address: Address;
545
+ /** Chain ID */
546
+ chainId: bigint;
547
+ /** Encoded pool ID (64-bit) */
548
+ poolId: bigint;
549
+ /** Uniswap pool key (V4: full struct, V3: zeroed fields) */
550
+ poolKey: PoolKey;
551
+ /** Tick spacing (extracted from encoded poolId) */
552
+ tickSpacing: bigint;
553
+ /** Token 0 collateral tracker */
554
+ collateralTracker0: CollateralTracker;
555
+ /** Token 1 collateral tracker */
556
+ collateralTracker1: CollateralTracker;
557
+ /** Risk engine */
558
+ riskEngine: RiskEngine;
559
+ /** Current tick */
560
+ currentTick: bigint;
561
+ /** Current sqrt price (Q64.96) */
562
+ sqrtPriceX96: bigint;
563
+ /** Uniswap pool in-range liquidity (from V3 pool.liquidity() or V4 StateView.getLiquidity()) */
564
+ uniswapPoolLiquidity: bigint;
565
+ /** Pool health status */
566
+ healthStatus: PoolHealthStatus;
567
+ /** Immutable pool metadata (addresses, symbols, decimals, names, underlyingPoolId) */
568
+ metadata: PoolMetadata;
569
+ /** Block metadata */
570
+ _meta: BlockMeta;
571
+ }
572
+ /**
573
+ * Utilization data for both tokens.
574
+ */
575
+ interface Utilization {
576
+ /** Token 0 utilization (0-10000 bps) */
577
+ utilization0: bigint;
578
+ /** Token 1 utilization (0-10000 bps) */
579
+ utilization1: bigint;
580
+ /** Block metadata */
581
+ _meta: BlockMeta;
582
+ }
583
+
584
+ //#endregion
585
+ //#region src/panoptic/v2/types/position.d.ts
586
+ /**
587
+ * A single leg of a TokenId.
588
+ */
589
+ interface TokenIdLeg {
590
+ /** Leg index (0-3) */
591
+ index: bigint;
592
+ /** Asset index (0 or 1) */
593
+ asset: bigint;
594
+ /** Option ratio (1-127) */
595
+ optionRatio: bigint;
596
+ /** Whether this is a long position (true) or short (false) */
597
+ isLong: boolean;
598
+ /** Token type (0 or 1) - which token is being moved */
599
+ tokenType: bigint;
600
+ /** Risk partner leg index (for spreads) */
601
+ riskPartner: bigint;
602
+ /** Strike tick (center of the range) */
603
+ strike: bigint;
604
+ /** Width in tick spacing units */
605
+ width: bigint;
606
+ /** Lower tick of the range */
607
+ tickLower: bigint;
608
+ /** Upper tick of the range */
609
+ tickUpper: bigint;
610
+ }
611
+ /**
612
+ * Position data.
613
+ */
614
+ interface Position {
615
+ /** The TokenId (256-bit identifier) */
616
+ tokenId: bigint;
617
+ /** Position size (number of contracts) */
618
+ positionSize: bigint;
619
+ /** Owner address */
620
+ owner: Address;
621
+ /** Pool address */
622
+ poolAddress: Address;
623
+ /** Decoded legs */
624
+ legs: TokenIdLeg[];
625
+ /** Pool utilization for token 0 at mint (0-10000 bps) */
626
+ poolUtilization0AtMint: bigint;
627
+ /** Pool utilization for token 1 at mint (0-10000 bps) */
628
+ poolUtilization1AtMint: bigint;
629
+ /** Tick at the time of minting */
630
+ tickAtMint: bigint;
631
+ /** Timestamp at the time of minting (Unix seconds) */
632
+ timestampAtMint: bigint;
633
+ /** Block number at the time of minting */
634
+ blockNumberAtMint: bigint;
635
+ /** Whether a swap occurred at mint */
636
+ swapAtMint: boolean;
637
+ /** Accumulated premia owed for token 0 */
638
+ premiaOwed0: bigint;
639
+ /** Accumulated premia owed for token 1 */
640
+ premiaOwed1: bigint;
641
+ /** Whether this is an optimistic pending position */
642
+ pending?: boolean;
643
+ /** Asset index used for greek calculations */
644
+ assetIndex: bigint;
645
+ /** Block metadata */
646
+ _meta: BlockMeta;
647
+ }
648
+ /**
649
+ * Parameters for client-side leg greek calculations.
650
+ */
651
+ interface LegGreeksParams {
652
+ /** The leg to calculate greeks for */
653
+ leg: TokenIdLeg;
654
+ /** Current tick */
655
+ tick: bigint;
656
+ /** Tick at mint (for value calculation) */
657
+ mintTick?: bigint;
658
+ /** Asset index (0 or 1) */
659
+ assetIndex: bigint;
660
+ /** Whether this is a defined risk position */
661
+ definedRisk: boolean;
662
+ }
663
+ /**
664
+ * Position greeks (value, delta, gamma).
665
+ */
666
+ interface PositionGreeks {
667
+ /** Position value in numeraire token units */
668
+ value: bigint;
669
+ /** Position delta in numeraire token units */
670
+ delta: bigint;
671
+ /** Position gamma in numeraire token units */
672
+ gamma: bigint;
673
+ }
674
+ /**
675
+ * Closed position data for trade history.
676
+ */
677
+ interface ClosedPosition {
678
+ /** The TokenId */
679
+ tokenId: bigint;
680
+ /** Owner address */
681
+ owner: Address;
682
+ /** Pool address */
683
+ poolAddress: Address;
684
+ /** Position size at close */
685
+ positionSize: bigint;
686
+ /** Open block number */
687
+ openBlock: bigint;
688
+ /** Close block number */
689
+ closeBlock: bigint;
690
+ /** Open timestamp */
691
+ openTimestamp: bigint;
692
+ /** Close timestamp */
693
+ closeTimestamp: bigint;
694
+ /** Tick at open */
695
+ tickAtOpen: bigint;
696
+ /** Tick at close */
697
+ tickAtClose: bigint;
698
+ /** Realized PnL for token 0 */
699
+ realizedPnL0: bigint;
700
+ /** Realized PnL for token 1 */
701
+ realizedPnL1: bigint;
702
+ /** Total premia collected for token 0 */
703
+ premiaCollected0: bigint;
704
+ /** Total premia collected for token 1 */
705
+ premiaCollected1: bigint;
706
+ /** Closure reason */
707
+ closureReason: 'closed' | 'liquidated' | 'force_exercised';
708
+ }
709
+ /**
710
+ * Realized PnL summary for an account.
711
+ */
712
+ interface RealizedPnL {
713
+ /** Total realized PnL for token 0 */
714
+ total0: bigint;
715
+ /** Total realized PnL for token 1 */
716
+ total1: bigint;
717
+ /** Number of closed positions */
718
+ positionCount: bigint;
719
+ /** Number of winning positions */
720
+ winCount: bigint;
721
+ /** Number of losing positions */
722
+ lossCount: bigint;
723
+ }
724
+ /**
725
+ * Stored position data (immutable fields only, no block metadata).
726
+ * Used for caching position data in storage.
727
+ */
728
+ interface StoredPositionData {
729
+ /** The TokenId (256-bit identifier) */
730
+ tokenId: bigint;
731
+ /** Position size (number of contracts) */
732
+ positionSize: bigint;
733
+ /** Decoded legs */
734
+ legs: TokenIdLeg[];
735
+ /** Tick at the time of minting */
736
+ tickAtMint: bigint;
737
+ /** Pool utilization for token 0 at mint (0-10000 bps) */
738
+ poolUtilization0AtMint: bigint;
739
+ /** Pool utilization for token 1 at mint (0-10000 bps) */
740
+ poolUtilization1AtMint: bigint;
741
+ /** Timestamp at the time of minting (Unix seconds) */
742
+ timestampAtMint: bigint;
743
+ /** Block number at the time of minting */
744
+ blockNumberAtMint: bigint;
745
+ /** Whether a swap occurred at mint */
746
+ swapAtMint: boolean;
747
+ }
748
+ /**
749
+ * Stored pool metadata (immutable fields fetched from chain).
750
+ * Does NOT include poolAddress/chainId as those are storage key components.
751
+ */
752
+ interface StoredPoolMeta {
753
+ /** Pool tick spacing */
754
+ tickSpacing: bigint;
755
+ /** Pool fee tier */
756
+ fee: bigint;
757
+ /** Pool ID */
758
+ poolId: bigint;
759
+ /** Collateral tracker 0 address */
760
+ collateralToken0Address: Address;
761
+ /** Collateral tracker 1 address */
762
+ collateralToken1Address: Address;
763
+ /** Risk engine address */
764
+ riskEngineAddress: Address;
765
+ /** Token 0 underlying asset address */
766
+ token0Asset: Address;
767
+ /** Token 1 underlying asset address */
768
+ token1Asset: Address;
769
+ /** Token 0 symbol */
770
+ token0Symbol: string;
771
+ /** Token 1 symbol */
772
+ token1Symbol: string;
773
+ /** Token 0 decimals */
774
+ token0Decimals: bigint;
775
+ /** Token 1 decimals */
776
+ token1Decimals: bigint;
777
+ }
778
+
779
+ //#endregion
780
+ //#region src/panoptic/v2/types/account.d.ts
781
+ /**
782
+ * Collateral data for a single token.
783
+ */
784
+ interface TokenCollateral {
785
+ /** Total assets deposited (in underlying token) */
786
+ assets: bigint;
787
+ /** Collateral shares owned */
788
+ shares: bigint;
789
+ /** Available (unlocked) assets */
790
+ availableAssets: bigint;
791
+ /** Locked assets (used as collateral for positions) */
792
+ lockedAssets: bigint;
793
+ }
794
+ /**
795
+ * Account collateral data for both tokens.
796
+ */
797
+ interface AccountCollateral {
798
+ /** Account address */
799
+ account: Address;
800
+ /** Pool address */
801
+ poolAddress: Address;
802
+ /** Token 0 collateral */
803
+ token0: TokenCollateral;
804
+ /** Token 1 collateral */
805
+ token1: TokenCollateral;
806
+ /** Number of open position legs */
807
+ legCount: bigint;
808
+ /** Block metadata */
809
+ _meta: BlockMeta;
810
+ }
811
+ /**
812
+ * Base account summary for UI dashboards.
813
+ *
814
+ * This shape contains non-helper-dependent data only.
815
+ */
816
+ interface AccountSummaryBasic {
817
+ /** Account address */
818
+ account: Address;
819
+ /** Pool data */
820
+ pool: Pool;
821
+ /** Collateral data */
822
+ collateral: AccountCollateral;
823
+ /** Open positions */
824
+ positions: Position[];
825
+ /** Health status of the pool */
826
+ healthStatus: PoolHealthStatus;
827
+ /** Whether wallet is on wrong network */
828
+ networkMismatch: boolean;
829
+ /** Block metadata */
830
+ _meta: BlockMeta;
831
+ }
832
+ /**
833
+ * Risk-focused account summary for UI dashboards and bots.
834
+ *
835
+ * Includes everything in AccountSummaryBasic plus helper-dependent risk fields.
836
+ */
837
+ interface AccountSummaryRisk extends AccountSummaryBasic {
838
+ /** Total position greeks */
839
+ totalGreeks: PositionGreeks;
840
+ /** Net liquidation value for token 0 */
841
+ netLiquidationValue0: bigint;
842
+ /** Net liquidation value for token 1 */
843
+ netLiquidationValue1: bigint;
844
+ /** Maintenance margin required for token 0 */
845
+ maintenanceMargin0: bigint;
846
+ /** Maintenance margin required for token 1 */
847
+ maintenanceMargin1: bigint;
848
+ /** Margin excess (positive) or deficit (negative) for token 0 */
849
+ marginExcess0: bigint;
850
+ /** Margin excess (positive) or deficit (negative) for token 1 */
851
+ marginExcess1: bigint;
852
+ /** Margin shortfall for token 0 (positive shortfall, negative excess) */
853
+ marginShortfall0: bigint;
854
+ /** Margin shortfall for token 1 (positive shortfall, negative excess) */
855
+ marginShortfall1: bigint;
856
+ /** Current margin (collateral balance) for token 0 */
857
+ currentMargin0: bigint;
858
+ /** Current margin (collateral balance) for token 1 */
859
+ currentMargin1: bigint;
860
+ /** Whether the account is liquidatable */
861
+ isLiquidatable: boolean;
862
+ /** Liquidation price bounds */
863
+ liquidationPrices: LiquidationPrices;
864
+ }
865
+ /**
866
+ * Net liquidation value result.
867
+ */
868
+ interface NetLiquidationValue {
869
+ /** Net liquidation value for token 0 */
870
+ value0: bigint;
871
+ /** Net liquidation value for token 1 */
872
+ value1: bigint;
873
+ /** Tick used for calculation */
874
+ atTick: bigint;
875
+ /** Whether pending premium was included */
876
+ includedPendingPremium: boolean;
877
+ /** Block metadata */
878
+ _meta: BlockMeta;
879
+ }
880
+ /**
881
+ * Net liquidation values at multiple ticks.
882
+ */
883
+ interface NetLiquidationValues {
884
+ /** Net liquidation values for token 0 at each tick */
885
+ values0: bigint[];
886
+ /** Net liquidation values for token 1 at each tick */
887
+ values1: bigint[];
888
+ /** Ticks used for calculation */
889
+ atTicks: bigint[];
890
+ /** Block metadata */
891
+ _meta: BlockMeta;
892
+ }
893
+ /**
894
+ * Liquidation prices result.
895
+ */
896
+ interface LiquidationPrices {
897
+ /** Lower liquidation tick (null if position is safe at MIN_TICK) */
898
+ lowerTick: bigint | null;
899
+ /** Upper liquidation tick (null if position is safe at MAX_TICK) */
900
+ upperTick: bigint | null;
901
+ /** Whether the account is currently liquidatable */
902
+ isLiquidatable: boolean;
903
+ /** Block metadata */
904
+ _meta: BlockMeta;
905
+ }
906
+ /**
907
+ * Collateral estimate for a potential position.
908
+ */
909
+ interface CollateralEstimate {
910
+ /** Required collateral for token 0 */
911
+ required0: bigint;
912
+ /** Required collateral for token 1 */
913
+ required1: bigint;
914
+ /** Post-position margin excess for token 0 */
915
+ postMarginExcess0: bigint;
916
+ /** Post-position margin excess for token 1 */
917
+ postMarginExcess1: bigint;
918
+ /** Whether the position would be openable */
919
+ canOpen: boolean;
920
+ /** Block metadata */
921
+ _meta: BlockMeta;
922
+ }
923
+
924
+ //#endregion
925
+ //#region src/panoptic/v2/types/oracle.d.ts
926
+ /**
927
+ * Safe mode level from the RiskEngine.
928
+ */
929
+ type SafeMode = 'normal' | 'restricted' | 'emergency';
930
+ /**
931
+ * Oracle state from the PanopticPool.
932
+ */
933
+ interface OracleState {
934
+ /** Last update epoch (64-second intervals) */
935
+ epoch: bigint;
936
+ /** Last update timestamp */
937
+ lastUpdateTimestamp: bigint;
938
+ /** Reference tick */
939
+ referenceTick: bigint;
940
+ /** Spot EMA tick */
941
+ spotEMA: bigint;
942
+ /** Fast EMA tick */
943
+ fastEMA: bigint;
944
+ /** Slow EMA tick */
945
+ slowEMA: bigint;
946
+ /** Eons EMA tick */
947
+ eonsEMA: bigint;
948
+ /** Lock mode (0 = unlocked, 1 = spot locked, 2 = full locked) */
949
+ lockMode: bigint;
950
+ /** Median tick from sorted observations */
951
+ medianTick: bigint;
952
+ /** Block metadata */
953
+ _meta: BlockMeta;
954
+ }
955
+ /**
956
+ * Safe mode state from the RiskEngine.
957
+ */
958
+ interface SafeModeState {
959
+ /** Current safe mode level */
960
+ mode: SafeMode;
961
+ /** Whether minting new positions is allowed */
962
+ canMint: boolean;
963
+ /** Whether burning positions is allowed */
964
+ canBurn: boolean;
965
+ /** Whether force exercise is allowed */
966
+ canForceExercise: boolean;
967
+ /** Whether liquidations are allowed */
968
+ canLiquidate: boolean;
969
+ /** Whether swapAtMint is allowed (false for NO_SWAP level 2+) */
970
+ canSwapAtMint: boolean;
971
+ /** Reason for current safe mode (if not normal) */
972
+ reason?: string;
973
+ /** Block metadata */
974
+ _meta: BlockMeta;
975
+ }
976
+ /**
977
+ * Risk parameters from the RiskEngine.
978
+ */
979
+ interface RiskParameters {
980
+ /** Collateral requirement multiplier (in bps, e.g., 10000 = 100%) */
981
+ collateralRequirement: bigint;
982
+ /** Maintenance margin requirement (in bps) */
983
+ maintenanceMargin: bigint;
984
+ /** Commission rate (in bps) */
985
+ commissionRate: bigint;
986
+ /** Target pool utilization (in bps) */
987
+ targetUtilization: bigint;
988
+ /** Saturated pool utilization threshold (in bps) */
989
+ saturatedUtilization: bigint;
990
+ /** ITM spread multiplier */
991
+ itmSpreadMultiplier: bigint;
992
+ /** Block metadata */
993
+ _meta: BlockMeta;
994
+ }
995
+ /**
996
+ * Current interest rates from the CollateralTrackers.
997
+ */
998
+ interface CurrentRates {
999
+ /** Token 0 borrow rate (per-second, WAD-scaled) */
1000
+ borrowRate0: bigint;
1001
+ /** Token 0 supply rate (per-second, WAD-scaled) */
1002
+ supplyRate0: bigint;
1003
+ /** Token 1 borrow rate (per-second, WAD-scaled) */
1004
+ borrowRate1: bigint;
1005
+ /** Token 1 supply rate (per-second, WAD-scaled) */
1006
+ supplyRate1: bigint;
1007
+ /** Block metadata */
1008
+ _meta: BlockMeta;
1009
+ }
1010
+
1011
+ //#endregion
1012
+ //#region src/panoptic/v2/types/events.d.ts
1013
+ /**
1014
+ * Supported Panoptic event types.
1015
+ */
1016
+ type PanopticEventType = 'OptionMinted' | 'OptionBurnt' | 'AccountLiquidated' | 'ForcedExercised' | 'PremiumSettled' | 'Deposit' | 'Withdraw' | 'BorrowRateUpdated' | 'LiquidityChunkUpdated' | 'ProtocolLossRealized' | 'ModifyLiquidity' | 'Swap' | 'Donate';
1017
+ /**
1018
+ * Base event data common to all events.
1019
+ */
1020
+ interface BaseEvent {
1021
+ /** Event type */
1022
+ type: PanopticEventType;
1023
+ /** Transaction hash */
1024
+ transactionHash: Hash;
1025
+ /** Block number */
1026
+ blockNumber: bigint;
1027
+ /** Block hash */
1028
+ blockHash: Hash;
1029
+ /** Log index within the block */
1030
+ logIndex: bigint;
1031
+ }
1032
+ /**
1033
+ * OptionMinted event data.
1034
+ */
1035
+ interface OptionMintedEvent extends BaseEvent {
1036
+ type: 'OptionMinted';
1037
+ /** Recipient of the minted position */
1038
+ recipient: Address;
1039
+ /** TokenId of the minted position */
1040
+ tokenId: bigint;
1041
+ /** Position size */
1042
+ positionSize: bigint;
1043
+ /** Pool utilization for token 0 at mint */
1044
+ poolUtilization0: bigint;
1045
+ /** Pool utilization for token 1 at mint */
1046
+ poolUtilization1: bigint;
1047
+ /** Tick at mint */
1048
+ tickAtMint: bigint;
1049
+ /** Timestamp at mint (Unix seconds) */
1050
+ timestampAtMint: bigint;
1051
+ /** Block number at mint */
1052
+ blockAtMint: bigint;
1053
+ /** Whether a swap happened at mint */
1054
+ swapAtMint: boolean;
1055
+ }
1056
+ /**
1057
+ * OptionBurnt event data.
1058
+ */
1059
+ interface OptionBurntEvent extends BaseEvent {
1060
+ type: 'OptionBurnt';
1061
+ /** Recipient (owner) of the burnt position */
1062
+ recipient: Address;
1063
+ /** TokenId of the burnt position */
1064
+ tokenId: bigint;
1065
+ /** Position size that was burnt */
1066
+ positionSize: bigint;
1067
+ /** Premia settled for each leg (token0 right, token1 left per leg) */
1068
+ premiaByLeg: readonly [bigint, bigint, bigint, bigint];
1069
+ }
1070
+ /**
1071
+ * AccountLiquidated event data.
1072
+ */
1073
+ interface AccountLiquidatedEvent extends BaseEvent {
1074
+ type: 'AccountLiquidated';
1075
+ /** Address of the liquidator */
1076
+ liquidator: Address;
1077
+ /** Address of the liquidated account */
1078
+ liquidatee: Address;
1079
+ /** Bonus paid to liquidator for token 0 */
1080
+ bonusAmount0: bigint;
1081
+ /** Bonus paid to liquidator for token 1 */
1082
+ bonusAmount1: bigint;
1083
+ }
1084
+ /**
1085
+ * ForcedExercised event data.
1086
+ */
1087
+ interface ForcedExercisedEvent extends BaseEvent {
1088
+ type: 'ForcedExercised';
1089
+ /** Address of the exerciser */
1090
+ exercisor: Address;
1091
+ /** Address of the position owner */
1092
+ user: Address;
1093
+ /** TokenId of the exercised position */
1094
+ tokenId: bigint;
1095
+ /** Exercise fee for token 0 (negative = cost to exerciser) */
1096
+ exerciseFee0: bigint;
1097
+ /** Exercise fee for token 1 (negative = cost to exerciser) */
1098
+ exerciseFee1: bigint;
1099
+ }
1100
+ /**
1101
+ * PremiumSettled event data.
1102
+ */
1103
+ interface PremiumSettledEvent extends BaseEvent {
1104
+ type: 'PremiumSettled';
1105
+ /** Position owner */
1106
+ user: Address;
1107
+ /** TokenId */
1108
+ tokenId: bigint;
1109
+ /** Leg index that was settled */
1110
+ legIndex: bigint;
1111
+ /** Settled amount for token 0 */
1112
+ settledAmount0: bigint;
1113
+ /** Settled amount for token 1 */
1114
+ settledAmount1: bigint;
1115
+ }
1116
+ /**
1117
+ * Deposit event data (ERC4626).
1118
+ */
1119
+ interface DepositEvent extends BaseEvent {
1120
+ type: 'Deposit';
1121
+ /** Sender address */
1122
+ sender: Address;
1123
+ /** Owner address */
1124
+ owner: Address;
1125
+ /** Assets deposited */
1126
+ assets: bigint;
1127
+ /** Shares minted */
1128
+ shares: bigint;
1129
+ }
1130
+ /**
1131
+ * Withdraw event data (ERC4626).
1132
+ */
1133
+ interface WithdrawEvent extends BaseEvent {
1134
+ type: 'Withdraw';
1135
+ /** Sender address */
1136
+ sender: Address;
1137
+ /** Receiver address */
1138
+ receiver: Address;
1139
+ /** Owner address */
1140
+ owner: Address;
1141
+ /** Assets withdrawn */
1142
+ assets: bigint;
1143
+ /** Shares burned */
1144
+ shares: bigint;
1145
+ }
1146
+ /**
1147
+ * BorrowRateUpdated event data (RiskEngine).
1148
+ */
1149
+ interface BorrowRateUpdatedEvent extends BaseEvent {
1150
+ type: 'BorrowRateUpdated';
1151
+ /** Collateral token address */
1152
+ collateralToken: Address;
1153
+ /** Average borrow rate */
1154
+ avgBorrowRate: bigint;
1155
+ /** Rate at target utilization */
1156
+ rateAtTarget: bigint;
1157
+ }
1158
+ /**
1159
+ * LiquidityChunkUpdated event data (SFPM).
1160
+ */
1161
+ interface LiquidityChunkUpdatedEvent extends BaseEvent {
1162
+ type: 'LiquidityChunkUpdated';
1163
+ /** Pool ID (bytes32) */
1164
+ poolId: Hash;
1165
+ /** Owner address */
1166
+ owner: Address;
1167
+ /** Token type (0 or 1) */
1168
+ tokenType: bigint;
1169
+ /** Lower tick */
1170
+ tickLower: number;
1171
+ /** Upper tick */
1172
+ tickUpper: number;
1173
+ /** Liquidity delta (positive = added, negative = removed) */
1174
+ liquidityDelta: bigint;
1175
+ }
1176
+ /**
1177
+ * ProtocolLossRealized event data (CollateralTracker).
1178
+ */
1179
+ interface ProtocolLossRealizedEvent extends BaseEvent {
1180
+ type: 'ProtocolLossRealized';
1181
+ /** Liquidated account */
1182
+ liquidatee: Address;
1183
+ /** Liquidator address */
1184
+ liquidator: Address;
1185
+ /** Protocol loss in assets */
1186
+ protocolLossAssets: bigint;
1187
+ /** Protocol loss in shares */
1188
+ protocolLossShares: bigint;
1189
+ }
1190
+ /**
1191
+ * ModifyLiquidity event data (v4 PoolManager).
1192
+ */
1193
+ interface ModifyLiquidityEvent extends BaseEvent {
1194
+ type: 'ModifyLiquidity';
1195
+ /** Pool ID (bytes32) */
1196
+ id: Hash;
1197
+ /** Sender address */
1198
+ sender: Address;
1199
+ /** Lower tick */
1200
+ tickLower: number;
1201
+ /** Upper tick */
1202
+ tickUpper: number;
1203
+ /** Liquidity delta */
1204
+ liquidityDelta: bigint;
1205
+ /** Salt */
1206
+ salt: Hash;
1207
+ }
1208
+ /**
1209
+ * Swap event data (v4 PoolManager).
1210
+ */
1211
+ interface SwapEvent extends BaseEvent {
1212
+ type: 'Swap';
1213
+ /** Pool ID (bytes32) */
1214
+ id: Hash;
1215
+ /** Sender address */
1216
+ sender: Address;
1217
+ /** Amount of token 0 */
1218
+ amount0: bigint;
1219
+ /** Amount of token 1 */
1220
+ amount1: bigint;
1221
+ /** Square root price X96 */
1222
+ sqrtPriceX96: bigint;
1223
+ /** Liquidity */
1224
+ liquidity: bigint;
1225
+ /** Tick */
1226
+ tick: number;
1227
+ /** Fee */
1228
+ fee: number;
1229
+ }
1230
+ /**
1231
+ * Donate event data (v4 PoolManager).
1232
+ */
1233
+ interface DonateEvent extends BaseEvent {
1234
+ type: 'Donate';
1235
+ /** Pool ID (bytes32) */
1236
+ id: Hash;
1237
+ /** Sender address */
1238
+ sender: Address;
1239
+ /** Amount of token 0 */
1240
+ amount0: bigint;
1241
+ /** Amount of token 1 */
1242
+ amount1: bigint;
1243
+ }
1244
+ /**
1245
+ * Union of all Panoptic event types.
1246
+ */
1247
+ type PanopticEvent = OptionMintedEvent | OptionBurntEvent | AccountLiquidatedEvent | ForcedExercisedEvent | PremiumSettledEvent | DepositEvent | WithdrawEvent | BorrowRateUpdatedEvent | LiquidityChunkUpdatedEvent | ProtocolLossRealizedEvent | ModifyLiquidityEvent | SwapEvent | DonateEvent;
1248
+ /**
1249
+ * Leg update data from events.
1250
+ */
1251
+ interface LegUpdate {
1252
+ /** Leg index */
1253
+ legIndex: bigint;
1254
+ /** Liquidity delta (positive = added, negative = removed) */
1255
+ liquidityDelta: bigint;
1256
+ /** Token 0 delta */
1257
+ amount0Delta: bigint;
1258
+ /** Token 1 delta */
1259
+ amount1Delta: bigint;
1260
+ }
1261
+ /**
1262
+ * Event subscription handle.
1263
+ */
1264
+ interface EventSubscription {
1265
+ /** Unsubscribe from events */
1266
+ unsubscribe: () => void;
1267
+ /** Current connection status */
1268
+ isConnected: () => boolean;
1269
+ }
1270
+ /**
1271
+ * Sync progress event for syncPositions callback.
1272
+ */
1273
+ interface SyncEvent {
1274
+ /** Current block being processed */
1275
+ currentBlock: bigint;
1276
+ /** Target block to sync to */
1277
+ targetBlock: bigint;
1278
+ /** Number of positions discovered so far */
1279
+ positionsFound: bigint;
1280
+ /** Percentage complete (0-100) */
1281
+ progress: bigint;
1282
+ }
1283
+
1284
+ //#endregion
1285
+ //#region src/panoptic/v2/types/tx.d.ts
1286
+ /**
1287
+ * Transaction result returned by write functions.
1288
+ * Provides immediate access to hash and a wait function for confirmation.
1289
+ */
1290
+ interface TxResult {
1291
+ /** Transaction hash, available immediately */
1292
+ hash: Hash;
1293
+ /** Wait for transaction confirmation */
1294
+ wait: (confirmations?: bigint) => Promise<TxReceipt>;
1295
+ }
1296
+ /**
1297
+ * Transaction result with receipt already awaited.
1298
+ * Returned by *AndWait convenience functions.
1299
+ */
1300
+ interface TxResultWithReceipt extends TxResult {
1301
+ /** The transaction receipt */
1302
+ receipt: TxReceipt;
1303
+ }
1304
+ /**
1305
+ * Transaction receipt after confirmation.
1306
+ */
1307
+ interface TxReceipt {
1308
+ /** Transaction hash */
1309
+ hash: Hash;
1310
+ /** Block number */
1311
+ blockNumber: bigint;
1312
+ /** Block hash */
1313
+ blockHash: Hash;
1314
+ /** Gas used */
1315
+ gasUsed: bigint;
1316
+ /** Transaction status */
1317
+ status: 'success' | 'reverted';
1318
+ /** Parsed Panoptic events from the transaction */
1319
+ events: PanopticEvent[];
1320
+ }
1321
+ /**
1322
+ * Transaction broadcaster interface for private transaction support.
1323
+ * Allows plugging in Flashbots or other MEV protection services.
1324
+ */
1325
+ interface TxBroadcaster {
1326
+ /**
1327
+ * Broadcast a signed transaction.
1328
+ * @param signedTx - The signed transaction bytes
1329
+ * @returns The transaction hash
1330
+ */
1331
+ broadcast: (signedTx: `0x${string}`) => Promise<Hash>;
1332
+ }
1333
+ /**
1334
+ * Gas and transaction overrides for write operations.
1335
+ * Supports EIP-1559 gas parameters, explicit nonce, and custom broadcasters.
1336
+ */
1337
+ interface TxOverrides {
1338
+ /** EIP-1559 max fee per gas */
1339
+ maxFeePerGas?: bigint;
1340
+ /** EIP-1559 max priority fee per gas (tip) */
1341
+ maxPriorityFeePerGas?: bigint;
1342
+ /** Gas limit override */
1343
+ gas?: bigint;
1344
+ /** Explicit nonce (for concurrent tx submission) */
1345
+ nonce?: bigint;
1346
+ /** Custom broadcaster for MEV protection (Flashbots, private mempool) */
1347
+ broadcaster?: TxBroadcaster;
1348
+ }
1349
+ /**
1350
+ * Nonce manager for concurrent transaction submission.
1351
+ */
1352
+ interface NonceManager {
1353
+ /** Get the next nonce for an account */
1354
+ getNextNonce: (account: Address) => Promise<bigint>;
1355
+ /** Reset nonce tracking (e.g., after failure) */
1356
+ reset: (account: Address) => void;
1357
+ }
1358
+ /**
1359
+ * Dispatch call for raw multi-operation transactions.
1360
+ */
1361
+ interface DispatchCall {
1362
+ /** TokenId to operate on */
1363
+ tokenId: bigint;
1364
+ /** Position size change (positive = mint, negative = burn) */
1365
+ positionSize: bigint;
1366
+ /** Whether this is a long (true) or short (false) */
1367
+ isLong: boolean;
1368
+ /** Recipient address (usually the sender) */
1369
+ recipient?: Address;
1370
+ }
1371
+
1372
+ //#endregion
1373
+ //#region src/panoptic/v2/errors/base.d.ts
1374
+ /**
1375
+ * Base error class for the Panoptic v2 SDK.
1376
+ * @module v2/errors/base
1377
+ */
1378
+ /**
1379
+ * Base error class for all Panoptic SDK errors.
1380
+ * All errors thrown by the SDK extend this class.
1381
+ *
1382
+ * @example
1383
+ * ```typescript
1384
+ * try {
1385
+ * await openPosition(config, params)
1386
+ * } catch (error) {
1387
+ * if (error instanceof PanopticError) {
1388
+ * console.log('Panoptic error:', error.name, error.message)
1389
+ * console.log('Original cause:', error.cause)
1390
+ * }
1391
+ * }
1392
+ * ```
1393
+ */
1394
+ declare class PanopticError extends Error {
1395
+ readonly cause?: Error | undefined;
1396
+ readonly name: string;
1397
+ /** The Solidity error name (e.g. 'PriceBoundFail', 'InputListFail'). Set by the parser. */
1398
+ errorName?: string;
1399
+ /**
1400
+ * Creates a new PanopticError.
1401
+ *
1402
+ * @param message - Human-readable error message
1403
+ * @param cause - Optional underlying error that caused this error
1404
+ */
1405
+ constructor(message: string, cause?: Error | undefined);
1406
+ }
1407
+
1408
+ //#endregion
1409
+ //#region src/panoptic/v2/types/simulation.d.ts
1410
+ /**
1411
+ * Token flow data from simulation.
1412
+ * Measures collateral asset changes via getAssetsOf-dispatch-getAssetsOf pattern
1413
+ * using PanopticPool.multicall.
1414
+ */
1415
+ interface TokenFlow {
1416
+ /** Token 0 collateral change (negative = user deposits, positive = user receives) */
1417
+ delta0: bigint;
1418
+ /** Token 1 collateral change (negative = user deposits, positive = user receives) */
1419
+ delta1: bigint;
1420
+ /** Collateral assets in token 0 before the call */
1421
+ balanceBefore0: bigint;
1422
+ /** Collateral assets in token 1 before the call */
1423
+ balanceBefore1: bigint;
1424
+ /** Collateral assets in token 0 after the call */
1425
+ balanceAfter0: bigint;
1426
+ /** Collateral assets in token 1 after the call */
1427
+ balanceAfter1: bigint;
1428
+ /** Pool tick before the operation */
1429
+ tickBefore: bigint | null;
1430
+ /** Pool tick after the operation */
1431
+ tickAfter: bigint | null;
1432
+ }
1433
+ /**
1434
+ * Simulation result discriminated union.
1435
+ * Success case returns data, failure case returns error.
1436
+ *
1437
+ * Note: tokenFlow is optional because some simulations (deposit/withdraw)
1438
+ * don't use the PanopticPool.multicall token flow measurement.
1439
+ */
1440
+ type SimulationResult<T> = {
1441
+ success: true;
1442
+ data: T;
1443
+ gasEstimate: bigint;
1444
+ tokenFlow?: TokenFlow;
1445
+ _meta: BlockMeta;
1446
+ } | {
1447
+ success: false;
1448
+ error: PanopticError;
1449
+ _meta: BlockMeta;
1450
+ };
1451
+ /**
1452
+ * Open position simulation result data.
1453
+ */
1454
+ interface OpenPositionSimulation {
1455
+ /** The position that would be created */
1456
+ position: Position;
1457
+ /** Post-trade greeks */
1458
+ greeks: PositionGreeks;
1459
+ /** Token 0 amount required */
1460
+ amount0Required: bigint;
1461
+ /** Token 1 amount required */
1462
+ amount1Required: bigint;
1463
+ /** Post-trade collateral for token 0 */
1464
+ postCollateral0: bigint;
1465
+ /** Post-trade collateral for token 1 */
1466
+ postCollateral1: bigint;
1467
+ /**
1468
+ * Post-mint collateral requirement in token0, from getFullPositionsData.collateralRequirements[].
1469
+ * Sum of per-position LeftRightUnsigned.right across all positions in finalPositionIdList.
1470
+ */
1471
+ postMintCollateralReqToken0: bigint;
1472
+ /**
1473
+ * Post-mint collateral requirement in token1, from getFullPositionsData.collateralRequirements[].
1474
+ * Sum of per-position LeftRightUnsigned.left across all positions in finalPositionIdList.
1475
+ */
1476
+ postMintCollateralReqToken1: bigint;
1477
+ /**
1478
+ * Per-position collateral requirements from getFullPositionsData.collateralRequirements[].
1479
+ * One entry per position in finalPositionIdList, in the same order.
1480
+ */
1481
+ perPositionCollateralReqs: {
1482
+ token0: bigint;
1483
+ token1: bigint;
1484
+ }[];
1485
+ /** Commission paid for token 0 (null: embedded in contract logic, not extractable from token flow) */
1486
+ commission0: bigint | null;
1487
+ /** Commission paid for token 1 (null: embedded in contract logic, not extractable from token flow) */
1488
+ commission1: bigint | null;
1489
+ }
1490
+ /**
1491
+ * Close position simulation result data.
1492
+ */
1493
+ interface ClosePositionSimulation {
1494
+ /** Token 0 amount received */
1495
+ amount0Received: bigint;
1496
+ /** Token 1 amount received */
1497
+ amount1Received: bigint;
1498
+ /** Premia collected for token 0 (null: requires pre-close premia snapshot) */
1499
+ premiaCollected0: bigint | null;
1500
+ /** Premia collected for token 1 (null: requires pre-close premia snapshot) */
1501
+ premiaCollected1: bigint | null;
1502
+ /** Post-trade collateral for token 0 */
1503
+ postCollateral0: bigint;
1504
+ /** Post-trade collateral for token 1 */
1505
+ postCollateral1: bigint;
1506
+ /** Realized PnL for token 0 (null: requires open position cost basis) */
1507
+ realizedPnL0: bigint | null;
1508
+ /** Realized PnL for token 1 (null: requires open position cost basis) */
1509
+ realizedPnL1: bigint | null;
1510
+ }
1511
+ /**
1512
+ * Force exercise simulation result data.
1513
+ */
1514
+ interface ForceExerciseSimulation {
1515
+ /** Exercise fee for token 0 (positive = received, negative = paid) */
1516
+ exerciseFee0: bigint;
1517
+ /** Exercise fee for token 1 */
1518
+ exerciseFee1: bigint;
1519
+ /** Whether the exercise would succeed */
1520
+ canExercise: boolean;
1521
+ /** Reason if cannot exercise */
1522
+ reason?: string;
1523
+ }
1524
+ /**
1525
+ * Liquidation simulation result data.
1526
+ */
1527
+ interface LiquidateSimulation {
1528
+ /** Bonus received for token 0 */
1529
+ bonus0: bigint;
1530
+ /** Bonus received for token 1 */
1531
+ bonus1: bigint;
1532
+ /** Positions that would be closed */
1533
+ positionsClosed: bigint[];
1534
+ /** Whether the account is liquidatable */
1535
+ isLiquidatable: boolean;
1536
+ /** Shortfall for token 0 (if liquidatable) */
1537
+ shortfall0: bigint;
1538
+ /** Shortfall for token 1 (if liquidatable) */
1539
+ shortfall1: bigint;
1540
+ }
1541
+ /**
1542
+ * Settle premia simulation result data.
1543
+ */
1544
+ interface SettleSimulation {
1545
+ /** Premia received for token 0 */
1546
+ premiaReceived0: bigint;
1547
+ /** Premia received for token 1 */
1548
+ premiaReceived1: bigint;
1549
+ /** Post-settle collateral for token 0 */
1550
+ postCollateral0: bigint;
1551
+ /** Post-settle collateral for token 1 */
1552
+ postCollateral1: bigint;
1553
+ /** Forfeit amounts [token0, token1] — present when tokenId was provided */
1554
+ forfeitAmounts?: [bigint, bigint];
1555
+ }
1556
+ /**
1557
+ * Deposit simulation result data.
1558
+ */
1559
+ interface DepositSimulation {
1560
+ /** Shares that would be minted */
1561
+ sharesMinted: bigint;
1562
+ /** Post-deposit assets */
1563
+ postAssets: bigint;
1564
+ /** Post-deposit shares */
1565
+ postShares: bigint;
1566
+ }
1567
+ /**
1568
+ * Withdraw simulation result data.
1569
+ */
1570
+ interface WithdrawSimulation {
1571
+ /** Shares that would be burned */
1572
+ sharesBurned: bigint;
1573
+ /** Assets that would be received */
1574
+ assetsReceived: bigint;
1575
+ /** Post-withdraw assets */
1576
+ postAssets: bigint;
1577
+ /** Post-withdraw shares */
1578
+ postShares: bigint;
1579
+ /** Whether the withdrawal is possible */
1580
+ canWithdraw: boolean;
1581
+ /** Reason if cannot withdraw */
1582
+ reason?: string;
1583
+ }
1584
+ /**
1585
+ * Dispatch simulation result data.
1586
+ */
1587
+ interface DispatchSimulation {
1588
+ /** Token 0 net change */
1589
+ netAmount0: bigint;
1590
+ /** Token 1 net change */
1591
+ netAmount1: bigint;
1592
+ /** Positions created */
1593
+ positionsCreated: bigint[];
1594
+ /** Positions closed */
1595
+ positionsClosed: bigint[];
1596
+ /** Post-dispatch collateral for token 0 */
1597
+ postCollateral0: bigint;
1598
+ /** Post-dispatch collateral for token 1 */
1599
+ postCollateral1: bigint;
1600
+ /** Post-dispatch margin excess for token 0 (null if full positions decode/token-flow balances are unavailable or omitted; see simulateDispatch/getFullPositionsData). */
1601
+ postMarginExcess0: bigint | null;
1602
+ /** Post-dispatch margin excess for token 1 (null if full positions decode/token-flow balances are unavailable or omitted; see simulateDispatch/getFullPositionsData). */
1603
+ postMarginExcess1: bigint | null;
1604
+ /** Pre-dispatch margin excess for token 0 (null if full positions decode/token-flow balances are unavailable or omitted; see simulateDispatch/getFullPositionsData). */
1605
+ preMarginExcess0: bigint | null;
1606
+ /** Pre-dispatch margin excess for token 1 (null if full positions decode/token-flow balances are unavailable or omitted; see simulateDispatch/getFullPositionsData). */
1607
+ preMarginExcess1: bigint | null;
1608
+ }
1609
+
1610
+ //#endregion
1611
+ //#region src/panoptic/v2/types/chunks.d.ts
1612
+ /**
1613
+ * Chunk spread represents a range of ticks being tracked.
1614
+ * Used to organize position data for efficient storage and retrieval.
1615
+ */
1616
+ interface ChunkSpread {
1617
+ /** Lower tick bound (inclusive) */
1618
+ tickLower: bigint;
1619
+ /** Upper tick bound (exclusive) */
1620
+ tickUpper: bigint;
1621
+ /** Pool address */
1622
+ poolAddress: Address;
1623
+ /** Chain ID */
1624
+ chainId: bigint;
1625
+ }
1626
+ /**
1627
+ * Chunk key for storage lookup.
1628
+ * Format: chain{chainId}:pool{poolAddress}:chunk{tickLower}:{tickUpper}
1629
+ */
1630
+ interface ChunkKey {
1631
+ /** Chain ID */
1632
+ chainId: bigint;
1633
+ /** Pool address */
1634
+ poolAddress: Address;
1635
+ /** Lower tick bound */
1636
+ tickLower: bigint;
1637
+ /** Upper tick bound */
1638
+ tickUpper: bigint;
1639
+ }
1640
+ /**
1641
+ * Chunk data stored in persistent storage.
1642
+ */
1643
+ interface ChunkData {
1644
+ /** The chunk key */
1645
+ key: ChunkKey;
1646
+ /** Token IDs in this chunk */
1647
+ tokenIds: bigint[];
1648
+ /** Last update block number */
1649
+ lastBlock: bigint;
1650
+ /** Last update block hash */
1651
+ lastBlockHash: Hash;
1652
+ /** Creation timestamp */
1653
+ createdAt: bigint;
1654
+ /** Last update timestamp */
1655
+ updatedAt: bigint;
1656
+ }
1657
+ /**
1658
+ * Chunk metadata for LRU eviction.
1659
+ */
1660
+ interface ChunkMetadata {
1661
+ /** The chunk key */
1662
+ key: ChunkKey;
1663
+ /** Access count for frequency-based eviction */
1664
+ accessCount: bigint;
1665
+ /** Last access timestamp */
1666
+ lastAccessedAt: bigint;
1667
+ /** Size in bytes (approximate) */
1668
+ sizeBytes: bigint;
1669
+ }
1670
+ /**
1671
+ * Chunk statistics for monitoring.
1672
+ */
1673
+ interface ChunkStats {
1674
+ /** Total number of chunks */
1675
+ totalChunks: bigint;
1676
+ /** Total token IDs across all chunks */
1677
+ totalTokenIds: bigint;
1678
+ /** Oldest chunk timestamp */
1679
+ oldestChunk: bigint;
1680
+ /** Newest chunk timestamp */
1681
+ newestChunk: bigint;
1682
+ /** Average chunk size */
1683
+ avgChunkSize: bigint;
1684
+ }
1685
+
1686
+ //#endregion
1687
+ //#region src/panoptic/v2/types/poolConfig.d.ts
1688
+ /** V3 pool configuration. */
1689
+ interface V3PoolConfig {
1690
+ version: 'v3';
1691
+ /** Uniswap V3 pool contract address */
1692
+ poolAddress: Address;
1693
+ }
1694
+ /** V4 pool configuration. */
1695
+ interface V4PoolConfig {
1696
+ version: 'v4';
1697
+ /** StateView contract address */
1698
+ stateViewAddress: Address;
1699
+ /** V4 pool ID (bytes32) */
1700
+ poolId: `0x${string}`;
1701
+ }
1702
+ /** Discriminated union of V3 and V4 pool configurations. */
1703
+ type PoolVersionConfig = V3PoolConfig | V4PoolConfig;
1704
+
1705
+ //#endregion
1706
+ //#region src/panoptic/v2/types/sync.d.ts
1707
+ /**
1708
+ * Sync status enum.
1709
+ */
1710
+ type SyncStatus = 'idle' | 'syncing' | 'error' | 'complete';
1711
+ /**
1712
+ * Sync state for tracking synchronization progress.
1713
+ */
1714
+ interface SyncState {
1715
+ /** Current sync status */
1716
+ status: SyncStatus;
1717
+ /** Last synced block number */
1718
+ lastSyncedBlock: bigint;
1719
+ /** Last synced block hash */
1720
+ lastSyncedBlockHash: Hash;
1721
+ /** Target block to sync to */
1722
+ targetBlock: bigint;
1723
+ /** Number of positions found during sync */
1724
+ positionsFound: bigint;
1725
+ /** Progress percentage (0-100) */
1726
+ progress: bigint;
1727
+ /** Error message if status is 'error' */
1728
+ errorMessage?: string;
1729
+ /** Timestamp when sync started */
1730
+ startedAt: bigint;
1731
+ /** Timestamp when sync completed (or errored) */
1732
+ completedAt?: bigint;
1733
+ }
1734
+ /**
1735
+ * Sync checkpoint for resumable syncs.
1736
+ */
1737
+ interface SyncCheckpoint {
1738
+ /** Chain ID */
1739
+ chainId: bigint;
1740
+ /** Pool address being synced */
1741
+ poolAddress: Address;
1742
+ /** Account address being synced */
1743
+ account: Address;
1744
+ /** Last processed block */
1745
+ lastBlock: bigint;
1746
+ /** Last processed block hash */
1747
+ lastBlockHash: Hash;
1748
+ /** Positions discovered so far */
1749
+ positionIds: bigint[];
1750
+ /** Checkpoint creation timestamp */
1751
+ createdAt: bigint;
1752
+ }
1753
+ /**
1754
+ * Sync options for customizing sync behavior.
1755
+ */
1756
+ interface SyncOptions {
1757
+ /** Starting block for sync (defaults to pool deployment block) */
1758
+ fromBlock?: bigint;
1759
+ /** Ending block for sync (defaults to latest) */
1760
+ toBlock?: bigint;
1761
+ /** Batch size for event fetching */
1762
+ batchSize?: bigint;
1763
+ /** Whether to use checkpoints for resumable syncs */
1764
+ useCheckpoints?: boolean;
1765
+ /** Progress callback */
1766
+ onProgress?: (state: SyncState) => void;
1767
+ }
1768
+ /**
1769
+ * Sync result after completion.
1770
+ */
1771
+ interface SyncResult {
1772
+ /** Whether sync completed successfully */
1773
+ success: boolean;
1774
+ /** Final sync state */
1775
+ state: SyncState;
1776
+ /** Position IDs discovered */
1777
+ positionIds: bigint[];
1778
+ /** Number of blocks processed */
1779
+ blocksProcessed: bigint;
1780
+ /** Duration in milliseconds */
1781
+ durationMs: bigint;
1782
+ }
1783
+ /**
1784
+ * Reorg detection result.
1785
+ */
1786
+ interface ReorgDetection {
1787
+ /** Whether a reorg was detected */
1788
+ detected: boolean;
1789
+ /** Block number where reorg started (if detected) */
1790
+ reorgBlock?: bigint;
1791
+ /** Expected block hash */
1792
+ expectedHash?: Hash;
1793
+ /** Actual block hash */
1794
+ actualHash?: Hash;
1795
+ /** Number of blocks to resync */
1796
+ blocksToResync?: bigint;
1797
+ }
1798
+
1799
+ //#endregion
1800
+ export { AccountCollateral, AccountLiquidatedEvent, AccountSummaryBasic, AccountSummaryRisk, BaseEvent, BlockMeta, BorrowRateUpdatedEvent, ChunkData, ChunkKey, ChunkMetadata, ChunkSpread, ChunkStats, ClosePositionSimulation, ClosedPosition, CollateralEstimate, CollateralTracker, CurrentRates, DepositEvent, DepositSimulation, DispatchCall, DispatchSimulation, DonateEvent, EventSubscription, FetchPoolIdParams, FetchPoolIdResult, ForceExerciseSimulation, ForcedExercisedEvent, GetOracleStateParams, GetPoolMetadataParams, GetPoolParams, GetRiskParametersParams, GetUtilizationParams, LegGreeksParams, LegUpdate, LiquidateSimulation, LiquidationPrices, LiquidityChunkUpdatedEvent, ModifyLiquidityEvent, NetLiquidationValue, NetLiquidationValues, NonceManager, OpenPositionSimulation, OptionBurntEvent, OptionMintedEvent, OracleState, PanopticError, PanopticEvent, PanopticEventType, Pool, PoolHealthStatus, PoolKey, PoolMetadata, PoolVersionConfig, Position, PositionGreeks, PremiumSettledEvent, ProtocolLossRealizedEvent, RealizedPnL, ReorgDetection, RiskEngine, RiskParameters, SafeMode, SafeModeState, SettleSimulation, SimulationResult, StoredPoolMeta, StoredPositionData, SwapEvent, SyncCheckpoint, SyncEvent, SyncOptions, SyncResult, SyncState, SyncStatus, TickLimitsResult, TokenCollateral, TokenFlow, TokenIdLeg, TxBroadcaster, TxOverrides, TxReceipt, TxResult, TxResultWithReceipt, Utilization, V3PoolConfig, V4PoolConfig, WithdrawEvent, WithdrawSimulation, fetchPoolId, formatPriceRange, formatTick, formatTickRange, getOracleState, getPool, getPoolMetadata, getPricesAtTick, getRiskParameters, getTickSpacing, getUtilization, priceToTick, roundToTickSpacing, sqrtPriceX96ToPriceDecimalScaled, sqrtPriceX96ToTick, tickLimits, tickToPrice, tickToPriceDecimalScaled, tickToSqrtPriceX96, validateBuilderCode };
1801
+ //# sourceMappingURL=index-DVMjZi1E.d.ts.map