@panoptic-eng/sdk 1.0.69 → 1.0.70

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.
@@ -97,7 +97,7 @@ const UTILIZATION_DENOMINATOR = 10000n;
97
97
 
98
98
  //#endregion
99
99
  //#region src/panoptic/v2/formatters/tick.ts
100
- const Q192$7 = 1n << 192n;
100
+ const Q192$8 = 1n << 192n;
101
101
  const RAW_PRICE_PRECISION = 40n;
102
102
  function pow10$2(exponent) {
103
103
  if (exponent < 0n) throw new RangeError("Exponent must be non-negative");
@@ -187,7 +187,7 @@ const MAX_SQRT_PRICE_X96 = tickToSqrtPriceX96(MAX_TICK);
187
187
  function getPriceRatioFromSqrtPriceX96(sqrtPriceX96) {
188
188
  return {
189
189
  numerator: sqrtPriceX96 * sqrtPriceX96,
190
- denominator: Q192$7
190
+ denominator: Q192$8
191
191
  };
192
192
  }
193
193
  function getRawPriceRatio(tick) {
@@ -10071,7 +10071,7 @@ function hasLoanOrCredit(tokenId) {
10071
10071
  const POOL_ID_MASK$4 = (1n << 64n) - 1n;
10072
10072
  const MAX_LEGS = TOKEN_ID_BITS.MAX_LEGS;
10073
10073
  const MAX_OPTION_RATIO = LEG_LIMITS.MAX_RATIO;
10074
- const Q192$6 = 1n << 192n;
10074
+ const Q192$7 = 1n << 192n;
10075
10075
  /**
10076
10076
  * Floor integer square root for bigints (Newton's method). Mirrors the isqrt
10077
10077
  * used in reads/collateralEstimate.ts (buildNeutralLeg).
@@ -10118,7 +10118,7 @@ function computeTinyCreditSignedStrike(positionSize, tickSpacing) {
10118
10118
  const maxSafe = MAX_TICK - tickSpacing - 1n;
10119
10119
  let signedStrike;
10120
10120
  try {
10121
- const sqrtKrawX96 = isqrt$1(TINY_CREDIT_TARGET_NOTIONAL_WEI * Q192$6 / positionSize);
10121
+ const sqrtKrawX96 = isqrt$1(TINY_CREDIT_TARGET_NOTIONAL_WEI * Q192$7 / positionSize);
10122
10122
  signedStrike = sqrtPriceX96ToTick(sqrtKrawX96);
10123
10123
  } catch {
10124
10124
  signedStrike = minSafe;
@@ -10990,7 +10990,7 @@ function formatGwei(wei, precision) {
10990
10990
  //#region src/panoptic/v2/tokenId/generateOverlapping.ts
10991
10991
  const MAX_UINT64$2 = (1n << 64n) - 1n;
10992
10992
  const MAX_UINT128$4 = (1n << 128n) - 1n;
10993
- const Q192$5 = 1n << 192n;
10993
+ const Q192$6 = 1n << 192n;
10994
10994
  const MAX_TOKEN_DECIMALS = 255n;
10995
10995
  const MAX_DECIMAL_EXPONENT = 512n;
10996
10996
  function invalid$1(message) {
@@ -11036,7 +11036,7 @@ function quotePriceAtTick(tick, asset, assetDecimals, quoteDecimals) {
11036
11036
  const orientedTick = asset === 0n ? tick : -tick;
11037
11037
  const sqrtPriceX96 = tickToSqrtPriceX96(orientedTick);
11038
11038
  let numerator = sqrtPriceX96 * sqrtPriceX96;
11039
- let denominator = Q192$5;
11039
+ let denominator = Q192$6;
11040
11040
  const decimalDifference = assetDecimals - quoteDecimals;
11041
11041
  if (decimalDifference > 0n) numerator *= pow10$1(decimalDifference);
11042
11042
  else if (decimalDifference < 0n) denominator *= pow10$1(-decimalDifference);
@@ -11056,7 +11056,7 @@ function isPriceGridStrike(strike, params, spacing, tickSpacing) {
11056
11056
  }
11057
11057
  return false;
11058
11058
  }
11059
- function ceilDiv$5(value, divisor) {
11059
+ function ceilDiv$6(value, divisor) {
11060
11060
  const quotient = value / divisor;
11061
11061
  const remainder = value % divisor;
11062
11062
  return remainder > 0n ? quotient + 1n : quotient;
@@ -11089,7 +11089,7 @@ function resolveLegs(legs) {
11089
11089
  function getCandidateStrikes(params, spacing, tickSpacing, halfWidth) {
11090
11090
  const lower = MIN_TICK + halfWidth > params.currentTick - halfWidth + 1n ? MIN_TICK + halfWidth : params.currentTick - halfWidth + 1n;
11091
11091
  const upper = MAX_TICK - halfWidth < params.currentTick + halfWidth - 1n ? MAX_TICK - halfWidth : params.currentTick + halfWidth - 1n;
11092
- const firstStrike = ceilDiv$5(lower, tickSpacing) * tickSpacing;
11092
+ const firstStrike = ceilDiv$6(lower, tickSpacing) * tickSpacing;
11093
11093
  const lastStrike = floorDiv$1(upper, tickSpacing) * tickSpacing;
11094
11094
  const strikes = [];
11095
11095
  for (let strike = firstStrike; strike <= lastStrike; strike += tickSpacing) if (isPriceGridStrike(strike, params, spacing, tickSpacing)) strikes.push(strike);
@@ -11311,10 +11311,41 @@ function splitTokenIdByTimescale(tokenId, positionSize, targetTimescale) {
11311
11311
  };
11312
11312
  }
11313
11313
 
11314
+ //#endregion
11315
+ //#region src/panoptic/v2/tokenId/validate.ts
11316
+ /**
11317
+ * Validate a TokenId's structure using the rules of TokenId.validate.
11318
+ * This does not check pool registration, available liquidity, or account collateral.
11319
+ */
11320
+ function getTokenIdValidationError(tokenId) {
11321
+ if (tokenId < 0n || tokenId >= 1n << 256n) return "Token ID must fit in uint256.";
11322
+ const legs = [];
11323
+ for (let index = 0n; index < TOKEN_ID_BITS.MAX_LEGS; index++) {
11324
+ const leg = decodeLeg(tokenId, index);
11325
+ if (leg.optionRatio === 0n) {
11326
+ const offset = TOKEN_ID_BITS.POOL_ID_SIZE + index * TOKEN_ID_BITS.LEG_SIZE;
11327
+ if (tokenId >> offset !== 0n) return "Position contains empty or non-contiguous legs.";
11328
+ break;
11329
+ }
11330
+ legs.push(leg);
11331
+ }
11332
+ if (legs.length === 0) return "Position must contain at least one leg.";
11333
+ const chunks = new Set();
11334
+ for (const leg of legs) {
11335
+ const chunk = `${leg.strike}:${leg.width}:${leg.tokenType}`;
11336
+ if (chunks.has(chunk)) return "Position contains duplicate legs sharing the same liquidity chunk.";
11337
+ chunks.add(chunk);
11338
+ if (leg.strike <= -887272n || leg.strike >= 887272n) return "Position strike must be inside the pool tick bounds.";
11339
+ const partner = legs[Number(leg.riskPartner)];
11340
+ if (!partner || partner.riskPartner !== leg.index) return "Position risk partners must reference existing legs and be mutual.";
11341
+ }
11342
+ return null;
11343
+ }
11344
+
11314
11345
  //#endregion
11315
11346
  //#region src/uniswap/lpDeposit.ts
11316
- const Q96$5 = 1n << 96n;
11317
- const ceilDiv$4 = (n, d) => (n + d - 1n) / d;
11347
+ const Q96$6 = 1n << 96n;
11348
+ const ceilDiv$5 = (n, d) => (n + d - 1n) / d;
11318
11349
  /** Principal and separately identified funding headroom, in native token units. */
11319
11350
  function getLpDepositBreakdown(ranges, sqrtPriceX96) {
11320
11351
  if (sqrtPriceX96 <= 0n) throw new Error("Invalid pool price");
@@ -11325,12 +11356,12 @@ function getLpDepositBreakdown(ranges, sqrtPriceX96) {
11325
11356
  const lower = tickToSqrtPriceX96(BigInt(tickLower));
11326
11357
  const upper = tickToSqrtPriceX96(BigInt(tickUpper));
11327
11358
  const price = sqrtPriceX96 < lower ? lower : sqrtPriceX96 > upper ? upper : sqrtPriceX96;
11328
- amount0 += ceilDiv$4(liquidity * Q96$5 * (upper - price), upper * price);
11329
- amount1 += ceilDiv$4(liquidity * (price - lower), Q96$5);
11359
+ amount0 += ceilDiv$5(liquidity * Q96$6 * (upper - price), upper * price);
11360
+ amount1 += ceilDiv$5(liquidity * (price - lower), Q96$6);
11330
11361
  }
11331
11362
  const buffer = {
11332
- amount0: ceilDiv$4(amount0 * 5n, 100n),
11333
- amount1: ceilDiv$4(amount1 * 5n, 100n)
11363
+ amount0: ceilDiv$5(amount0 * 5n, 100n),
11364
+ amount1: ceilDiv$5(amount1 * 5n, 100n)
11334
11365
  };
11335
11366
  return {
11336
11367
  principal: {
@@ -11354,7 +11385,7 @@ function getUnhedgedLpRanges({ tokenId, positionSize, tickSpacing }) {
11354
11385
  const lower = tickToSqrtPriceX96(tickLower);
11355
11386
  const upper = tickToSqrtPriceX96(tickUpper);
11356
11387
  const amount = positionSize * leg.optionRatio;
11357
- const liquidity = leg.asset === 0n ? amount * (lower * upper / Q96$5) / (upper - lower) : amount * Q96$5 / (upper - lower);
11388
+ const liquidity = leg.asset === 0n ? amount * (lower * upper / Q96$6) / (upper - lower) : amount * Q96$6 / (upper - lower);
11358
11389
  return liquidity <= 0n ? [] : [{
11359
11390
  tickLower: Number(tickLower),
11360
11391
  tickUpper: Number(tickUpper),
@@ -11375,7 +11406,7 @@ function getLpPositionFunding(params) {
11375
11406
  });
11376
11407
  const breakdown = getLpDepositBreakdown(ranges, sqrtPriceX96);
11377
11408
  const priceSquared = valuationSqrtPriceX96 * valuationSqrtPriceX96;
11378
- const value = ({ amount0, amount1 }) => quoteTokenIndex === 0 ? amount0 + ceilDiv$4(amount1 * Q96$5 * Q96$5, priceSquared) : amount1 + ceilDiv$4(amount0 * priceSquared, Q96$5 * Q96$5);
11409
+ const value = ({ amount0, amount1 }) => quoteTokenIndex === 0 ? amount0 + ceilDiv$5(amount1 * Q96$6 * Q96$6, priceSquared) : amount1 + ceilDiv$5(amount0 * priceSquared, Q96$6 * Q96$6);
11379
11410
  const principalInQuote = value(breakdown.principal);
11380
11411
  const totalInQuote = value(breakdown.total);
11381
11412
  return {
@@ -11397,7 +11428,7 @@ function getMaxLpPositionSize(params) {
11397
11428
  ...params,
11398
11429
  positionSize: mid
11399
11430
  });
11400
- const minimum = params.minimumRequirement ? ceilDiv$4(params.minimumRequirement.requiredInQuote * mid, params.minimumRequirement.referenceSize) : 0n;
11431
+ const minimum = params.minimumRequirement ? ceilDiv$5(params.minimumRequirement.requiredInQuote * mid, params.minimumRequirement.referenceSize) : 0n;
11401
11432
  if (funding.totalInQuote <= params.availableInQuote && minimum <= params.availableInQuote) low = mid;
11402
11433
  else high = mid - 1n;
11403
11434
  }
@@ -12857,7 +12888,7 @@ async function submitWriteRequest(params) {
12857
12888
  * Exported so callers can display the constant; prefer {@link applyMintBuffer}
12858
12889
  * over multiplying by it directly, which is how the rounding bug reappears.
12859
12890
  */
12860
- const MINT_BUFFER = 10666667n;
12891
+ const MINT_BUFFER = 10750000n;
12861
12892
  /** `RiskEngine.DECIMALS` — the denominator {@link MINT_BUFFER} is taken over. */
12862
12893
  const MINT_BUFFER_DENOMINATOR = 10000000n;
12863
12894
  /** The compiled-in default, matching the deployed RiskEngine. */
@@ -14588,8 +14619,8 @@ async function assertLpPositionFunded(params) {
14588
14619
 
14589
14620
  //#endregion
14590
14621
  //#region src/uniswap/lpGreeks.ts
14591
- const Q96$4 = 1n << 96n;
14592
- const Q192$4 = 1n << 192n;
14622
+ const Q96$5 = 1n << 96n;
14623
+ const Q192$5 = 1n << 192n;
14593
14624
  /**
14594
14625
  * Compute the token0/token1 amounts backing `liquidity` over `[sqrtA, sqrtB]`
14595
14626
  * at the current price `sqrtP`, mirroring Uniswap's `LiquidityAmounts`
@@ -14599,8 +14630,8 @@ const Q192$4 = 1n << 192n;
14599
14630
  function getAmountsForLiquidity(sqrtPriceX96, sqrtRatioAX96, sqrtRatioBX96, liquidity) {
14600
14631
  const [sqrtA, sqrtB] = sqrtRatioAX96 <= sqrtRatioBX96 ? [sqrtRatioAX96, sqrtRatioBX96] : [sqrtRatioBX96, sqrtRatioAX96];
14601
14632
  const sqrtC = sqrtPriceX96 < sqrtA ? sqrtA : sqrtPriceX96 > sqrtB ? sqrtB : sqrtPriceX96;
14602
- const amount0 = sqrtC < sqrtB ? liquidity * (sqrtB - sqrtC) * Q96$4 / (sqrtC * sqrtB) : 0n;
14603
- const amount1 = sqrtC > sqrtA ? liquidity * (sqrtC - sqrtA) / Q96$4 : 0n;
14633
+ const amount0 = sqrtC < sqrtB ? liquidity * (sqrtB - sqrtC) * Q96$5 / (sqrtC * sqrtB) : 0n;
14634
+ const amount1 = sqrtC > sqrtA ? liquidity * (sqrtC - sqrtA) / Q96$5 : 0n;
14604
14635
  return {
14605
14636
  amount0,
14606
14637
  amount1
@@ -14609,7 +14640,7 @@ function getAmountsForLiquidity(sqrtPriceX96, sqrtRatioAX96, sqrtRatioBX96, liqu
14609
14640
 
14610
14641
  //#endregion
14611
14642
  //#region src/panoptic/v2/greeks/legLiquidity.ts
14612
- const Q96$3 = 1n << 96n;
14643
+ const Q96$4 = 1n << 96n;
14613
14644
  function divCeil(numerator, denominator) {
14614
14645
  return (numerator + denominator - 1n) / denominator;
14615
14646
  }
@@ -14622,7 +14653,7 @@ function getLegLiquidityRange(leg, positionSize, tickSpacing) {
14622
14653
  const sqrtLower = tickToSqrtPriceX96(lowerTick);
14623
14654
  const sqrtUpper = tickToSqrtPriceX96(upperTick);
14624
14655
  const amount = positionSize * leg.optionRatio;
14625
- const liquidity = leg.asset === 0n ? amount * (sqrtLower * sqrtUpper / Q96$3) / (sqrtUpper - sqrtLower) : amount * Q96$3 / (sqrtUpper - sqrtLower);
14656
+ const liquidity = leg.asset === 0n ? amount * (sqrtLower * sqrtUpper / Q96$4) / (sqrtUpper - sqrtLower) : amount * Q96$4 / (sqrtUpper - sqrtLower);
14626
14657
  return {
14627
14658
  lowerTick,
14628
14659
  upperTick,
@@ -14645,7 +14676,7 @@ function getLegTokenInventory(leg, currentTick, positionSize, tickSpacing, token
14645
14676
  if (tokenIndex === 0n) {
14646
14677
  const scaled = (liquidity << 96n) * span;
14647
14678
  movedAmount = leg.isLong ? scaled / sqrtUpper / sqrtLower : divCeil(divCeil(scaled, sqrtUpper), sqrtLower);
14648
- } else movedAmount = leg.isLong ? liquidity * span / Q96$3 : divCeil(liquidity * span, Q96$3);
14679
+ } else movedAmount = leg.isLong ? liquidity * span / Q96$4 : divCeil(liquidity * span, Q96$4);
14649
14680
  }
14650
14681
  const net = heldAmount - movedAmount;
14651
14682
  return leg.isLong ? -net : net;
@@ -14654,8 +14685,8 @@ function getLegTokenInventory(leg, currentTick, positionSize, tickSpacing, token
14654
14685
  //#endregion
14655
14686
  //#region src/panoptic/v2/greeks/index.ts
14656
14687
  /** Fixed-point scale constants for sqrtPriceX96 arithmetic */
14657
- const Q96$2 = 1n << 96n;
14658
- const Q192$3 = 1n << 192n;
14688
+ const Q96$3 = 1n << 96n;
14689
+ const Q192$4 = 1n << 192n;
14659
14690
  /**
14660
14691
  * Convert tick to quote-denominated tick based on asset direction.
14661
14692
  *
@@ -14709,7 +14740,7 @@ function computeWidth0Notional(leg, m) {
14709
14740
  const signedStrike = leg.asset === 0n ? leg.strike : -leg.strike;
14710
14741
  const sqrtKraw = tickToSqrtPriceX96(signedStrike);
14711
14742
  const KrawX192 = sqrtKraw * sqrtKraw;
14712
- return divTrunc(m * KrawX192, Q192$3);
14743
+ return divTrunc(m * KrawX192, Q192$4);
14713
14744
  }
14714
14745
  /**
14715
14746
  * Calculate value for a width=0 (loan/credit) leg.
@@ -14729,7 +14760,7 @@ function getLegValueWidth0(leg, m, qCurrentTick, qStrikeTick, qMintTick, isAsset
14729
14760
  const sqrtPm = tickToSqrtPriceX96(qMintTick);
14730
14761
  const PX192 = sqrtP * sqrtP;
14731
14762
  const PmX192 = sqrtPm * sqrtPm;
14732
- return divTrunc(-notional * (PX192 - PmX192), Q192$3);
14763
+ return divTrunc(-notional * (PX192 - PmX192), Q192$4);
14733
14764
  } else return 0n;
14734
14765
  }
14735
14766
  /**
@@ -14758,7 +14789,7 @@ function getLegNetValueWidth0(leg, m, qCurrentTick, qMintTick, isAssetToken0, sw
14758
14789
  const sqrtPm = tickToSqrtPriceX96(qMintTick);
14759
14790
  const PX192 = sqrtP * sqrtP;
14760
14791
  const PmX192 = sqrtPm * sqrtPm;
14761
- if (borrowsAsset) return divTrunc(-notional * (PX192 - PmX192), Q192$3);
14792
+ if (borrowsAsset) return divTrunc(-notional * (PX192 - PmX192), Q192$4);
14762
14793
  return divTrunc(notional * PX192, PmX192) - notional;
14763
14794
  }
14764
14795
  /**
@@ -14780,7 +14811,7 @@ function computeOptionItm(m, qStrikeTick, qMintTick, halfWidthTick, isPut) {
14780
14811
  const sqrtPm$2 = tickToSqrtPriceX96(qMintTick);
14781
14812
  const KX192 = sqrtK$1 * sqrtK$1;
14782
14813
  const PmX192 = sqrtPm$2 * sqrtPm$2;
14783
- return divTrunc(m * (KX192 - PmX192), Q192$3);
14814
+ return divTrunc(m * (KX192 - PmX192), Q192$4);
14784
14815
  } else if (qMintTick > qStrikeTick + halfWidthTick) return 0n;
14785
14816
  const sqrtKR = tickToSqrtPriceX96(qStrikeTick + halfWidthTick);
14786
14817
  const sqrtPm$1 = tickToSqrtPriceX96(qMintTick);
@@ -14788,7 +14819,7 @@ function computeOptionItm(m, qStrikeTick, qMintTick, halfWidthTick, isPut) {
14788
14819
  const rX192$1 = sqrtR$1 * sqrtR$1;
14789
14820
  const diff$1 = sqrtKR - sqrtPm$1;
14790
14821
  const diffSqX192$1 = diff$1 * diff$1;
14791
- return divTrunc(m * diffSqX192$1, rX192$1 - Q192$3);
14822
+ return divTrunc(m * diffSqX192$1, rX192$1 - Q192$4);
14792
14823
  }
14793
14824
  if (qMintTick < qStrikeTick - halfWidthTick) return 0n;
14794
14825
  else if (qMintTick > qStrikeTick + halfWidthTick) {
@@ -14802,10 +14833,10 @@ function computeOptionItm(m, qStrikeTick, qMintTick, halfWidthTick, isPut) {
14802
14833
  const sqrtK = tickToSqrtPriceX96(qStrikeTick);
14803
14834
  const sqrtPm = tickToSqrtPriceX96(qMintTick);
14804
14835
  const rX192 = sqrtR * sqrtR;
14805
- const sqrtKPmX96 = divTrunc(sqrtK * Q96$2, sqrtPm);
14836
+ const sqrtKPmX96 = divTrunc(sqrtK * Q96$3, sqrtPm);
14806
14837
  const diff = sqrtR - sqrtKPmX96;
14807
14838
  const diffSqX192 = diff * diff;
14808
- return divTrunc(m * diffSqX192, rX192 - Q192$3);
14839
+ return divTrunc(m * diffSqX192, rX192 - Q192$4);
14809
14840
  }
14810
14841
  /**
14811
14842
  * Check if leg is a call option (vs put).
@@ -14861,11 +14892,11 @@ function getLegValue(leg, currentTick, mintTick, positionSize, poolTickSpacing,
14861
14892
  if (qCurrentTick < qStrikeTick - halfWidthTick) {
14862
14893
  const sqrtP = tickToSqrtPriceX96(qCurrentTick);
14863
14894
  const PX192 = sqrtP * sqrtP;
14864
- v = divTrunc(m * PX192, Q192$3);
14895
+ v = divTrunc(m * PX192, Q192$4);
14865
14896
  } else if (qCurrentTick > qStrikeTick + halfWidthTick) {
14866
14897
  const sqrtK = tickToSqrtPriceX96(qStrikeTick);
14867
14898
  const KX192 = sqrtK * sqrtK;
14868
- v = divTrunc(m * KX192, Q192$3);
14899
+ v = divTrunc(m * KX192, Q192$4);
14869
14900
  } else {
14870
14901
  const sqrtP = tickToSqrtPriceX96(qCurrentTick);
14871
14902
  const sqrtK = tickToSqrtPriceX96(qStrikeTick);
@@ -14874,8 +14905,8 @@ function getLegValue(leg, currentTick, mintTick, positionSize, poolTickSpacing,
14874
14905
  const PX192 = sqrtP * sqrtP;
14875
14906
  const KX192 = sqrtK * sqrtK;
14876
14907
  const rX192 = sqrtR * sqrtR;
14877
- const numerator = m * (2n * sqrtPKR * Q96$2 - PX192 - KX192);
14878
- const denominator = rX192 - Q192$3;
14908
+ const numerator = m * (2n * sqrtPKR * Q96$3 - PX192 - KX192);
14909
+ const denominator = rX192 - Q192$4;
14879
14910
  v = divTrunc(numerator, denominator);
14880
14911
  }
14881
14912
  const debt = -m;
@@ -14884,19 +14915,19 @@ function getLegValue(leg, currentTick, mintTick, positionSize, poolTickSpacing,
14884
14915
  if (isPut) {
14885
14916
  const sqrtK = tickToSqrtPriceX96(qStrikeTick);
14886
14917
  const KX192 = sqrtK * sqrtK;
14887
- const debtK = divTrunc(debt * KX192, Q192$3);
14918
+ const debtK = divTrunc(debt * KX192, Q192$4);
14888
14919
  return debtK + v + itm;
14889
14920
  } else {
14890
14921
  const sqrtP = tickToSqrtPriceX96(qCurrentTick);
14891
14922
  const PX192 = sqrtP * sqrtP;
14892
- const debtP = divTrunc(debt * PX192, Q192$3);
14923
+ const debtP = divTrunc(debt * PX192, Q192$4);
14893
14924
  if (definedRisk) {
14894
14925
  const sqrtPm = tickToSqrtPriceX96(qMintTick);
14895
14926
  const PmX192 = sqrtPm * sqrtPm;
14896
- const itmPm = divTrunc(itm * PmX192, Q192$3);
14927
+ const itmPm = divTrunc(itm * PmX192, Q192$4);
14897
14928
  return debtP + v + itmPm;
14898
14929
  } else {
14899
- const itmP = divTrunc(itm * PX192, Q192$3);
14930
+ const itmP = divTrunc(itm * PX192, Q192$4);
14900
14931
  return debtP + v + itmP;
14901
14932
  }
14902
14933
  }
@@ -14932,7 +14963,7 @@ function getLegDelta(leg, currentTick, positionSize, poolTickSpacing, mintTick,
14932
14963
  const signedStrike = leg.asset === 0n ? leg.strike : -leg.strike;
14933
14964
  const sqrtKraw = tickToSqrtPriceX96(signedStrike);
14934
14965
  const KrawX192 = sqrtKraw * sqrtKraw;
14935
- const notional = divTrunc(m * KrawX192, Q192$3);
14966
+ const notional = divTrunc(m * KrawX192, Q192$4);
14936
14967
  return -notional;
14937
14968
  }
14938
14969
  if (halfWidthTick === 0n) {
@@ -14961,8 +14992,8 @@ function getLegDelta(leg, currentTick, positionSize, poolTickSpacing, mintTick,
14961
14992
  const sqrtKR = tickToSqrtPriceX96(qStrikeTick + halfWidthTick);
14962
14993
  const sqrtR = tickToSqrtPriceX96(halfWidthTick);
14963
14994
  const rX192 = sqrtR * sqrtR;
14964
- const numerator = m * (sqrtKR - sqrtP) * Q192$3;
14965
- const denominator = sqrtP * (rX192 - Q192$3);
14995
+ const numerator = m * (sqrtKR - sqrtP) * Q192$4;
14996
+ const denominator = sqrtP * (rX192 - Q192$4);
14966
14997
  vDelta = divTrunc(numerator, denominator);
14967
14998
  }
14968
14999
  const isPut = !isCall(leg.tokenType, isAssetToken0);
@@ -14982,10 +15013,10 @@ function getLegDelta(leg, currentTick, positionSize, poolTickSpacing, mintTick,
14982
15013
  const sqrtK = tickToSqrtPriceX96(qStrikeTick);
14983
15014
  const sqrtPm = tickToSqrtPriceX96(qMintTick);
14984
15015
  const rX192 = sqrtR * sqrtR;
14985
- const sqrtKPmX96 = sqrtK * Q96$2 / sqrtPm;
15016
+ const sqrtKPmX96 = sqrtK * Q96$3 / sqrtPm;
14986
15017
  const diff = sqrtR - sqrtKPmX96;
14987
15018
  const diffSqX192 = diff * diff;
14988
- return divTrunc(m * diffSqX192, rX192 - Q192$3);
15019
+ return divTrunc(m * diffSqX192, rX192 - Q192$4);
14989
15020
  }
14990
15021
  })();
14991
15022
  return definedRisk ? debtDelta + vDelta : debtDelta + vDelta + itmDelta;
@@ -14994,7 +15025,7 @@ function getLegDelta(leg, currentTick, positionSize, poolTickSpacing, mintTick,
14994
15025
  function toVaultFrameAtTick(delta, fromAsset, vaultAssetIndex, currentTick, flipSignOnAssetInversion = false) {
14995
15026
  if (fromAsset === vaultAssetIndex) return delta;
14996
15027
  const sqrtPriceX96 = tickToSqrtPriceX96(currentTick);
14997
- const converted = vaultAssetIndex === 0n ? delta * Q192$3 / (sqrtPriceX96 * sqrtPriceX96) : delta * sqrtPriceX96 * sqrtPriceX96 / Q192$3;
15028
+ const converted = vaultAssetIndex === 0n ? delta * Q192$4 / (sqrtPriceX96 * sqrtPriceX96) : delta * sqrtPriceX96 * sqrtPriceX96 / Q192$4;
14998
15029
  return flipSignOnAssetInversion ? -converted : converted;
14999
15030
  }
15000
15031
  /**
@@ -15043,8 +15074,8 @@ function getLegGamma(leg, currentTick, positionSize, poolTickSpacing, assetIndex
15043
15074
  const sqrtKPR = tickToSqrtPriceX96(qStrikeTick + qCurrentTick + halfWidthTick);
15044
15075
  const sqrtR = tickToSqrtPriceX96(halfWidthTick);
15045
15076
  const rX192 = sqrtR * sqrtR;
15046
- const numerator = m * sqrtKPR * Q96$2;
15047
- const denominator = 2n * (rX192 - Q192$3);
15077
+ const numerator = m * sqrtKPR * Q96$3;
15078
+ const denominator = 2n * (rX192 - Q192$4);
15048
15079
  return divTrunc(numerator, denominator);
15049
15080
  }
15050
15081
  /**
@@ -17675,7 +17706,7 @@ function maximumAmountIn(estimatedAmountIn, slippageBps) {
17675
17706
  if (slippageBps < 0n) throw new PanopticError("slippageBps must be non-negative");
17676
17707
  return (estimatedAmountIn * (BPS_DENOMINATOR$6 + slippageBps) + BPS_DENOMINATOR$6 - 1n) / BPS_DENOMINATOR$6;
17677
17708
  }
17678
- function ceilDiv$3(numerator, denominator) {
17709
+ function ceilDiv$4(numerator, denominator) {
17679
17710
  return (numerator + denominator - 1n) / denominator;
17680
17711
  }
17681
17712
  function getInputAmount(tokenFlow, tokenInIndex) {
@@ -17780,7 +17811,7 @@ async function quoteTokenShortfallRecovery(params) {
17780
17811
  const estimatedAmountIn = getInputAmount(swapSimulation.tokenFlow, tokenInIndex);
17781
17812
  const estimatedAmountOut = getOutputAmount(swapSimulation.tokenFlow, tokenOutIndex);
17782
17813
  if (estimatedAmountOut < requiredOutput) {
17783
- creditInput = estimatedAmountOut > 0n ? ceilDiv$3(creditInput * requiredOutput, estimatedAmountOut) + 1n : creditInput * 2n;
17814
+ creditInput = estimatedAmountOut > 0n ? ceilDiv$4(creditInput * requiredOutput, estimatedAmountOut) + 1n : creditInput * 2n;
17784
17815
  continue;
17785
17816
  }
17786
17817
  const recoveredDispatch = buildPrefixedExactInputRecoveryDispatch({
@@ -17835,7 +17866,7 @@ async function quoteTokenShortfallRecovery(params) {
17835
17866
  };
17836
17867
  const residual = remainingShortfall.assetsRequested - remainingShortfall.assetBalance;
17837
17868
  requiredOutput += residual > 0n ? residual : requiredOutput;
17838
- creditInput = ceilDiv$3(creditInput * requiredOutput, estimatedAmountOut) + 1n;
17869
+ creditInput = ceilDiv$4(creditInput * requiredOutput, estimatedAmountOut) + 1n;
17839
17870
  }
17840
17871
  return {
17841
17872
  available: false,
@@ -17890,7 +17921,7 @@ async function quoteTokenShortfallRecovery(params) {
17890
17921
  const maxAmountIn = maximumAmountIn(estimatedAmountIn, params.slippageBps);
17891
17922
  const swapOutput = getOutputAmount(swapSimulation.tokenFlow, tokenOutIndex);
17892
17923
  if (swapOutput < amountOut) {
17893
- creditOutSize = swapOutput > 0n ? ceilDiv$3(creditOutSize * amountOut, swapOutput) + 1n : creditOutSize * 2n;
17924
+ creditOutSize = swapOutput > 0n ? ceilDiv$4(creditOutSize * amountOut, swapOutput) + 1n : creditOutSize * 2n;
17894
17925
  continue;
17895
17926
  }
17896
17927
  const recoverySimulation = await simulateDispatch({
@@ -17945,7 +17976,7 @@ async function quoteTokenShortfallRecovery(params) {
17945
17976
  if (decodedShortfall >= shortfallError.assetsRequested - shortfallError.assetBalance) return quotePrefixedExactInput(amountOut);
17946
17977
  const additionalAmountOut = decodedShortfall > 0n ? decodedShortfall : amountOut;
17947
17978
  amountOut += additionalAmountOut;
17948
- creditOutSize = swapOutput > 0n ? ceilDiv$3(creditOutSize * amountOut, swapOutput) + 1n : creditOutSize * 2n;
17979
+ creditOutSize = swapOutput > 0n ? ceilDiv$4(creditOutSize * amountOut, swapOutput) + 1n : creditOutSize * 2n;
17949
17980
  }
17950
17981
  return quotePrefixedExactInput(shortfallError.assetsRequested - shortfallError.assetBalance);
17951
17982
  }
@@ -21364,7 +21395,7 @@ async function getItmAmounts(params) {
21364
21395
  * high-decimal amount can't masquerade as real flow.
21365
21396
  */
21366
21397
  const FLOW_NEUTRAL_DUST_THRESHOLD = 1000n;
21367
- const Q192$2 = 1n << 192n;
21398
+ const Q192$3 = 1n << 192n;
21368
21399
  const POOL_ID_MASK$2 = (1n << 64n) - 1n;
21369
21400
  /**
21370
21401
  * Floor integer square root for bigints (Newton's method). Exact for all
@@ -21400,7 +21431,7 @@ function buildNeutralLeg(tokenIndex, signedAmount, positionSize) {
21400
21431
  const absAmount = signedAmount < 0n ? -signedAmount : signedAmount;
21401
21432
  const legAsset = tokenIndex === 0n ? 1n : 0n;
21402
21433
  const legIsLong = signedAmount < 0n;
21403
- const sqrtKrawX96 = isqrt(absAmount * Q192$2 / positionSize);
21434
+ const sqrtKrawX96 = isqrt(absAmount * Q192$3 / positionSize);
21404
21435
  let signedTick;
21405
21436
  try {
21406
21437
  signedTick = sqrtPriceX96ToTick(sqrtKrawX96);
@@ -21658,7 +21689,7 @@ async function createFlowNeutralTokenId(params) {
21658
21689
  const sqrtPX96 = tickToSqrtPriceX96(tickBefore);
21659
21690
  const valueAbs = (index, amount) => {
21660
21691
  const abs$1 = amount < 0n ? -amount : amount;
21661
- return index === 0n ? abs$1 * sqrtPX96 * sqrtPX96 / Q192$2 : abs$1;
21692
+ return index === 0n ? abs$1 * sqrtPX96 * sqrtPX96 / Q192$3 : abs$1;
21662
21693
  };
21663
21694
  const flowFor = (index) => index === 0n ? credit.creditAmount0 : credit.creditAmount1;
21664
21695
  if (queryAddress !== void 0) {
@@ -22631,7 +22662,7 @@ async function getPoolLiquidities(params) {
22631
22662
 
22632
22663
  //#endregion
22633
22664
  //#region src/panoptic/v2/reads/accountGreeks.ts
22634
- const Q192$1 = 1n << 192n;
22665
+ const Q192$2 = 1n << 192n;
22635
22666
  /**
22636
22667
  * Calculate account-level greeks using stored position data.
22637
22668
  *
@@ -22752,8 +22783,8 @@ async function getAccountGreeks(params) {
22752
22783
  const assetBal = isAssetToken0 ? collateral.token0.assets : collateral.token1.assets;
22753
22784
  const otherBal = isAssetToken0 ? collateral.token1.assets : collateral.token0.assets;
22754
22785
  const sqrtPriceX96 = tickToSqrtPriceX96(BigInt(currentTick));
22755
- if (isAssetToken0) collateralValue = assetBal * sqrtPriceX96 * sqrtPriceX96 / Q192$1 + otherBal;
22756
- else collateralValue = assetBal * Q192$1 / (sqrtPriceX96 * sqrtPriceX96) + otherBal;
22786
+ if (isAssetToken0) collateralValue = assetBal * sqrtPriceX96 * sqrtPriceX96 / Q192$2 + otherBal;
22787
+ else collateralValue = assetBal * Q192$2 / (sqrtPriceX96 * sqrtPriceX96) + otherBal;
22757
22788
  collateralDelta = assetBal;
22758
22789
  }
22759
22790
  return {
@@ -22793,7 +22824,7 @@ function calculateAccountGreeksPure(params) {
22793
22824
  const totalDelta$1 = [];
22794
22825
  for (let i = 0; i < n; i++) {
22795
22826
  const sqrtPriceX96 = tickToSqrtPriceX96(atTicks[i]);
22796
- const assetValueInNumeraire = isAssetToken0 ? assetBal * sqrtPriceX96 * sqrtPriceX96 / Q192$1 : assetBal * Q192$1 / (sqrtPriceX96 * sqrtPriceX96);
22827
+ const assetValueInNumeraire = isAssetToken0 ? assetBal * sqrtPriceX96 * sqrtPriceX96 / Q192$2 : assetBal * Q192$2 / (sqrtPriceX96 * sqrtPriceX96);
22797
22828
  totalValue$1.push(assetValueInNumeraire + otherBal);
22798
22829
  totalDelta$1.push(assetBal);
22799
22830
  }
@@ -22843,7 +22874,7 @@ function calculateAccountGreeksPure(params) {
22843
22874
  }
22844
22875
  for (let i = 0; i < n; i++) {
22845
22876
  const sqrtPriceX96 = tickToSqrtPriceX96(atTicks[i]);
22846
- const assetValueInNumeraire = isAssetToken0 ? assetBal * sqrtPriceX96 * sqrtPriceX96 / Q192$1 : assetBal * Q192$1 / (sqrtPriceX96 * sqrtPriceX96);
22877
+ const assetValueInNumeraire = isAssetToken0 ? assetBal * sqrtPriceX96 * sqrtPriceX96 / Q192$2 : assetBal * Q192$2 / (sqrtPriceX96 * sqrtPriceX96);
22847
22878
  totalValue[i] += assetValueInNumeraire + otherBal;
22848
22879
  totalDelta[i] += assetBal;
22849
22880
  }
@@ -25258,10 +25289,10 @@ async function processClosedPositions(client, queryAddress, positions) {
25258
25289
  //#endregion
25259
25290
  //#region src/panoptic/v2/reads/hedgeCapacity.ts
25260
25291
  const SCALE$1 = 10000000n;
25261
- const FEE_SCALE = 10000n;
25262
- const Q192 = 1n << 192n;
25292
+ const FEE_SCALE$1 = 10000n;
25293
+ const Q192$1 = 1n << 192n;
25263
25294
  const MASK128$1 = (1n << 128n) - 1n;
25264
- const ceilDiv$2 = (value, divisor) => (value + divisor - 1n) / divisor;
25295
+ const ceilDiv$3 = (value, divisor) => (value + divisor - 1n) / divisor;
25265
25296
  function accountHedgeDelta({ positionIds, balances, collateralDelta, tick, tickSpacing, assetIndex }) {
25266
25297
  return positionIds.reduce((sum$1, id, index) => {
25267
25298
  const balance = balances[index];
@@ -25281,8 +25312,8 @@ function accountHedgeDelta({ positionIds, balances, collateralDelta, tick, tickS
25281
25312
  function buildCapacityHedge({ delta, assetIndex, tick, tickSpacing, poolId, notionalFee, swapFee }) {
25282
25313
  const borrowToken = delta >= 0n ? assetIndex : assetIndex === 0n ? 1n : 0n;
25283
25314
  const receiveToken = borrowToken === 0n ? 1n : 0n;
25284
- const amount = delta >= 0n ? delta : ceilDiv$2((toVaultFrameAtTick(-delta, assetIndex, borrowToken, tick) + 1n) * 1000000n * FEE_SCALE, (1000000n - swapFee) * (FEE_SCALE - notionalFee));
25285
- const commission = ceilDiv$2(amount * notionalFee, FEE_SCALE);
25315
+ const amount = delta >= 0n ? delta : ceilDiv$3((toVaultFrameAtTick(-delta, assetIndex, borrowToken, tick) + 1n) * 1000000n * FEE_SCALE$1, (1000000n - swapFee) * (FEE_SCALE$1 - notionalFee));
25316
+ const commission = ceilDiv$3(amount * notionalFee, FEE_SCALE$1);
25286
25317
  const proceeds = toVaultFrameAtTick((amount - commission) * (1000000n - swapFee) / 1000000n, borrowToken, receiveToken, tick);
25287
25318
  const tokenId = addLegToTokenId(poolId, {
25288
25319
  index: 0n,
@@ -25314,7 +25345,7 @@ function hedgeMargin({ tokenData, balanceChanges, crossRatios, tick, buffer }) {
25314
25345
  const surplus1 = balances[1] > required1 ? (balances[1] - required1) * crossRatios[1] / SCALE$1 : 0n;
25315
25346
  const sqrt = tickToSqrtPriceX96(tick);
25316
25347
  const price = sqrt * sqrt;
25317
- const pairs = sqrt < 1n << 96n ? [[balances[0] + surplus1 * Q192 / price, required0], [balances[1] * Q192 / price + surplus0, ceilDiv$2(required1 * Q192, price)]] : [[balances[0] * price / Q192 + surplus1, ceilDiv$2(required0 * price, Q192)], [balances[1] + surplus0 * price / Q192, required1]];
25348
+ const pairs = sqrt < 1n << 96n ? [[balances[0] + surplus1 * Q192$1 / price, required0], [balances[1] * Q192$1 / price + surplus0, ceilDiv$3(required1 * Q192$1, price)]] : [[balances[0] * price / Q192$1 + surplus1, ceilDiv$3(required0 * price, Q192$1)], [balances[1] + surplus0 * price / Q192$1, required1]];
25318
25349
  const headroom = pairs.map(([balance, required]) => balance - required);
25319
25350
  return {
25320
25351
  solvent: balances.every((balance) => balance >= 0n) && headroom.every((value) => value >= 0n),
@@ -25527,7 +25558,7 @@ async function getHedgeLimits({ client, poolAddress, account, positionIds, asset
25527
25558
  if (hedge.amount > 0n && BigInt(legCount) >= maxLegs) return unavailable("leg-limit");
25528
25559
  const totalAssets = hedge.borrowToken === 0n ? total0 : total1;
25529
25560
  if (hedge.amount > 0n && (hedge.amount > MAX_SIZE || hedge.amount > borrowCapacity[Number(hedge.borrowToken)] || totalAssets === 0n)) return unavailable("capacity");
25530
- const projectedUtilization = currentUtilizations.map((util, i) => hedge.amount > 0n && BigInt(i) === hedge.borrowToken ? ceilDiv$2(util * totalAssets + hedge.amount * 10000n, totalAssets) : util);
25561
+ const projectedUtilization = currentUtilizations.map((util, i) => hedge.amount > 0n && BigInt(i) === hedge.borrowToken ? ceilDiv$3(util * totalAssets + hedge.amount * 10000n, totalAssets) : util);
25531
25562
  if (hedge.amount > 0n && projectedUtilization.some((util) => util > 10000n)) return unavailable("capacity");
25532
25563
  const global = projectedUtilization.map((util, i) => util > globalUtilizations[i] ? util : globalUtilizations[i]);
25533
25564
  const syntheticBalance = hedge.amount | projectedUtilization[0] << 128n | projectedUtilization[1] << 144n;
@@ -25619,6 +25650,90 @@ async function getHedgeLimits({ client, poolAddress, account, positionIds, asset
25619
25650
  };
25620
25651
  }
25621
25652
 
25653
+ //#endregion
25654
+ //#region src/panoptic/v2/reads/positionMintFunding.ts
25655
+ const Q96$2 = 1n << 96n;
25656
+ const Q192 = 1n << 192n;
25657
+ const BPS = 10000n;
25658
+ const FEE_SCALE = 1000000n;
25659
+ const max = (a, b) => a > b ? a : b;
25660
+ const ceilDiv$2 = (n, d) => n > 0n ? (n + d - 1n) / d : n / d;
25661
+ /**
25662
+ * Estimate deposit-independent mint funding, including settlement and commission.
25663
+ * Swaps use spot conversion with fees and slippage allowance; execution still needs a live quote.
25664
+ * Received tokens cover post-mint margin but cannot fund the other tracker's upfront payment.
25665
+ * Each requiredValue is the starting balance when funding entirely in that token.
25666
+ */
25667
+ function getPositionMintFunding(params) {
25668
+ const { tokenId, positionSize, sqrtPriceX96, valuationSqrtPriceX96, swapAtMint, commissionRate, swapFee, slippageBps, required0, required1 } = params;
25669
+ if (positionSize < 0n || sqrtPriceX96 <= 0n || valuationSqrtPriceX96 <= 0n || commissionRate < 0n || swapFee < 0n || swapFee >= FEE_SCALE || slippageBps < 0n || slippageBps >= BPS || required0 < 0n || required1 < 0n) throw new RangeError("Invalid mint funding inputs");
25670
+ const { legs, tickSpacing } = decodeTokenId(tokenId);
25671
+ const firstLeg = legs[0];
25672
+ if (!firstLeg || tickSpacing <= 0n) throw new RangeError("Invalid position");
25673
+ let paid0 = 0n;
25674
+ let paid1 = 0n;
25675
+ let itm0 = 0n;
25676
+ let itm1 = 0n;
25677
+ let notional0 = 0n;
25678
+ let notional1 = 0n;
25679
+ for (const leg of legs) {
25680
+ const { sqrtLower, sqrtUpper, liquidity } = getLegLiquidityRange(leg.width === 0n ? {
25681
+ ...leg,
25682
+ width: 2n
25683
+ } : leg, positionSize, tickSpacing);
25684
+ const round = !leg.isLong || leg.width === 0n ? ceilDiv$2 : (n, d) => n / d;
25685
+ const moved0 = round((liquidity << 96n) * (sqrtUpper - sqrtLower), sqrtUpper * sqrtLower);
25686
+ const moved1 = round(liquidity * (sqrtUpper - sqrtLower), Q96$2);
25687
+ const sign = leg.isLong ? -1n : 1n;
25688
+ let amm0 = 0n;
25689
+ let amm1 = 0n;
25690
+ if (leg.width > 0n) {
25691
+ const price = max(sqrtLower, sqrtPriceX96 < sqrtUpper ? sqrtPriceX96 : sqrtUpper);
25692
+ amm0 = sign * round((liquidity << 96n) * (sqrtUpper - price), sqrtUpper * price);
25693
+ amm1 = sign * round(liquidity * (price - sqrtLower), Q96$2);
25694
+ itm0 += leg.tokenType === 1n ? amm0 : 0n;
25695
+ itm1 += leg.tokenType === 0n ? amm1 : 0n;
25696
+ } else {
25697
+ itm0 -= leg.tokenType === 0n ? sign * moved0 : 0n;
25698
+ itm1 -= leg.tokenType === 1n ? sign * moved1 : 0n;
25699
+ }
25700
+ paid0 += amm0 - (leg.tokenType === 0n ? sign * moved0 : 0n);
25701
+ paid1 += amm1 - (leg.tokenType === 1n ? sign * moved1 : 0n);
25702
+ notional0 += leg.tokenType === 0n ? moved0 : 0n;
25703
+ notional1 += leg.tokenType === 1n ? moved1 : 0n;
25704
+ }
25705
+ if (swapAtMint && (itm0 !== 0n || itm1 !== 0n)) {
25706
+ const swapToken0 = itm0 !== 0n && (itm1 === 0n || firstLeg.asset === 0n);
25707
+ const priceSquared$1 = sqrtPriceX96 * sqrtPriceX96;
25708
+ const itm = swapToken0 ? itm0 : itm1;
25709
+ const numerator = swapToken0 ? priceSquared$1 : Q192;
25710
+ const denominator = swapToken0 ? Q192 : priceSquared$1;
25711
+ const retained$1 = (FEE_SCALE - swapFee) * (BPS - slippageBps);
25712
+ const scale$1 = FEE_SCALE * BPS;
25713
+ const payment = itm > 0n ? ceilDiv$2(itm * numerator * scale$1, denominator * retained$1) : itm * numerator * retained$1 / (denominator * scale$1);
25714
+ paid0 += swapToken0 ? -itm : payment;
25715
+ paid1 += swapToken0 ? payment : -itm;
25716
+ }
25717
+ paid0 += ceilDiv$2(notional0 * commissionRate, BPS);
25718
+ paid1 += ceilDiv$2(notional1 * commissionRate, BPS);
25719
+ const priceSquared = valuationSqrtPriceX96 * valuationSqrtPriceX96;
25720
+ const inToken0 = (amount0, amount1) => amount0 + ceilDiv$2(amount1 * Q192, priceSquared);
25721
+ const inToken1 = (amount0, amount1) => amount1 + ceilDiv$2(amount0 * priceSquared, Q192);
25722
+ const retained = (FEE_SCALE - swapFee) * (BPS - slippageBps);
25723
+ const scale = FEE_SCALE * BPS;
25724
+ const spotSquared = sqrtPriceX96 * sqrtPriceX96;
25725
+ const upfront0 = max(paid0, 0n) + ceilDiv$2(max(paid1, 0n) * Q192 * scale, spotSquared * retained);
25726
+ const upfront1 = max(paid1, 0n) + ceilDiv$2(max(paid0, 0n) * spotSquared * scale, Q192 * retained);
25727
+ const requiredValue0 = upfront0 + max(0n, inToken0(required0 - max(-paid0, 0n), required1 - max(-paid1, 0n)));
25728
+ const requiredValue1 = upfront1 + max(0n, inToken1(required0 - max(-paid0, 0n), required1 - max(-paid1, 0n)));
25729
+ return {
25730
+ paid0,
25731
+ paid1,
25732
+ requiredValue0,
25733
+ requiredValue1
25734
+ };
25735
+ }
25736
+
25622
25737
  //#endregion
25623
25738
  //#region src/panoptic/v2/sync/getSyncStatus.ts
25624
25739
  /**
@@ -32158,7 +32273,7 @@ const DEFAULT_INTERVAL_MS = 12000n;
32158
32273
  /**
32159
32274
  * Default maximum block range per poll.
32160
32275
  */
32161
- const DEFAULT_MAX_BLOCK_RANGE = 1000n;
32276
+ const DEFAULT_MAX_BLOCK_RANGE$1 = 1000n;
32162
32277
  /**
32163
32278
  * Create an HTTP polling-based event fetcher.
32164
32279
  *
@@ -32195,7 +32310,7 @@ const DEFAULT_MAX_BLOCK_RANGE = 1000n;
32195
32310
  * ```
32196
32311
  */
32197
32312
  function createEventPoller(params) {
32198
- const { client, poolAddress, collateralTracker0, collateralTracker1, riskEngineAddress, sfpmAddress, poolManagerAddress, eventTypes, onLogs, onError, intervalMs = DEFAULT_INTERVAL_MS, maxBlockRange = DEFAULT_MAX_BLOCK_RANGE, fromBlock } = params;
32313
+ const { client, poolAddress, collateralTracker0, collateralTracker1, riskEngineAddress, sfpmAddress, poolManagerAddress, eventTypes, onLogs, onError, intervalMs = DEFAULT_INTERVAL_MS, maxBlockRange = DEFAULT_MAX_BLOCK_RANGE$1, fromBlock } = params;
32199
32314
  let isRunning = false;
32200
32315
  let lastPolledBlock = fromBlock ?? 0n;
32201
32316
  let pollTimeout = null;
@@ -32383,6 +32498,1355 @@ function createEventPoller(params) {
32383
32498
  };
32384
32499
  }
32385
32500
 
32501
+ //#endregion
32502
+ //#region src/abis/UniswapV3Pool.ts
32503
+ const UniswapV3PoolAbi = [
32504
+ {
32505
+ inputs: [],
32506
+ stateMutability: "payable",
32507
+ type: "constructor"
32508
+ },
32509
+ {
32510
+ anonymous: false,
32511
+ inputs: [
32512
+ {
32513
+ indexed: true,
32514
+ internalType: "address",
32515
+ name: "owner",
32516
+ type: "address"
32517
+ },
32518
+ {
32519
+ indexed: true,
32520
+ internalType: "int24",
32521
+ name: "tickLower",
32522
+ type: "int24"
32523
+ },
32524
+ {
32525
+ indexed: true,
32526
+ internalType: "int24",
32527
+ name: "tickUpper",
32528
+ type: "int24"
32529
+ },
32530
+ {
32531
+ indexed: false,
32532
+ internalType: "uint128",
32533
+ name: "amount",
32534
+ type: "uint128"
32535
+ },
32536
+ {
32537
+ indexed: false,
32538
+ internalType: "uint256",
32539
+ name: "amount0",
32540
+ type: "uint256"
32541
+ },
32542
+ {
32543
+ indexed: false,
32544
+ internalType: "uint256",
32545
+ name: "amount1",
32546
+ type: "uint256"
32547
+ }
32548
+ ],
32549
+ name: "Burn",
32550
+ type: "event"
32551
+ },
32552
+ {
32553
+ anonymous: false,
32554
+ inputs: [
32555
+ {
32556
+ indexed: true,
32557
+ internalType: "address",
32558
+ name: "owner",
32559
+ type: "address"
32560
+ },
32561
+ {
32562
+ indexed: false,
32563
+ internalType: "address",
32564
+ name: "recipient",
32565
+ type: "address"
32566
+ },
32567
+ {
32568
+ indexed: true,
32569
+ internalType: "int24",
32570
+ name: "tickLower",
32571
+ type: "int24"
32572
+ },
32573
+ {
32574
+ indexed: true,
32575
+ internalType: "int24",
32576
+ name: "tickUpper",
32577
+ type: "int24"
32578
+ },
32579
+ {
32580
+ indexed: false,
32581
+ internalType: "uint128",
32582
+ name: "amount0",
32583
+ type: "uint128"
32584
+ },
32585
+ {
32586
+ indexed: false,
32587
+ internalType: "uint128",
32588
+ name: "amount1",
32589
+ type: "uint128"
32590
+ }
32591
+ ],
32592
+ name: "Collect",
32593
+ type: "event"
32594
+ },
32595
+ {
32596
+ anonymous: false,
32597
+ inputs: [
32598
+ {
32599
+ indexed: true,
32600
+ internalType: "address",
32601
+ name: "sender",
32602
+ type: "address"
32603
+ },
32604
+ {
32605
+ indexed: true,
32606
+ internalType: "address",
32607
+ name: "recipient",
32608
+ type: "address"
32609
+ },
32610
+ {
32611
+ indexed: false,
32612
+ internalType: "uint128",
32613
+ name: "amount0",
32614
+ type: "uint128"
32615
+ },
32616
+ {
32617
+ indexed: false,
32618
+ internalType: "uint128",
32619
+ name: "amount1",
32620
+ type: "uint128"
32621
+ }
32622
+ ],
32623
+ name: "CollectProtocol",
32624
+ type: "event"
32625
+ },
32626
+ {
32627
+ anonymous: false,
32628
+ inputs: [
32629
+ {
32630
+ indexed: true,
32631
+ internalType: "address",
32632
+ name: "sender",
32633
+ type: "address"
32634
+ },
32635
+ {
32636
+ indexed: true,
32637
+ internalType: "address",
32638
+ name: "recipient",
32639
+ type: "address"
32640
+ },
32641
+ {
32642
+ indexed: false,
32643
+ internalType: "uint256",
32644
+ name: "amount0",
32645
+ type: "uint256"
32646
+ },
32647
+ {
32648
+ indexed: false,
32649
+ internalType: "uint256",
32650
+ name: "amount1",
32651
+ type: "uint256"
32652
+ },
32653
+ {
32654
+ indexed: false,
32655
+ internalType: "uint256",
32656
+ name: "paid0",
32657
+ type: "uint256"
32658
+ },
32659
+ {
32660
+ indexed: false,
32661
+ internalType: "uint256",
32662
+ name: "paid1",
32663
+ type: "uint256"
32664
+ }
32665
+ ],
32666
+ name: "Flash",
32667
+ type: "event"
32668
+ },
32669
+ {
32670
+ anonymous: false,
32671
+ inputs: [{
32672
+ indexed: false,
32673
+ internalType: "uint16",
32674
+ name: "observationCardinalityNextOld",
32675
+ type: "uint16"
32676
+ }, {
32677
+ indexed: false,
32678
+ internalType: "uint16",
32679
+ name: "observationCardinalityNextNew",
32680
+ type: "uint16"
32681
+ }],
32682
+ name: "IncreaseObservationCardinalityNext",
32683
+ type: "event"
32684
+ },
32685
+ {
32686
+ anonymous: false,
32687
+ inputs: [{
32688
+ indexed: false,
32689
+ internalType: "uint160",
32690
+ name: "sqrtPriceX96",
32691
+ type: "uint160"
32692
+ }, {
32693
+ indexed: false,
32694
+ internalType: "int24",
32695
+ name: "tick",
32696
+ type: "int24"
32697
+ }],
32698
+ name: "Initialize",
32699
+ type: "event"
32700
+ },
32701
+ {
32702
+ anonymous: false,
32703
+ inputs: [
32704
+ {
32705
+ indexed: false,
32706
+ internalType: "address",
32707
+ name: "sender",
32708
+ type: "address"
32709
+ },
32710
+ {
32711
+ indexed: true,
32712
+ internalType: "address",
32713
+ name: "owner",
32714
+ type: "address"
32715
+ },
32716
+ {
32717
+ indexed: true,
32718
+ internalType: "int24",
32719
+ name: "tickLower",
32720
+ type: "int24"
32721
+ },
32722
+ {
32723
+ indexed: true,
32724
+ internalType: "int24",
32725
+ name: "tickUpper",
32726
+ type: "int24"
32727
+ },
32728
+ {
32729
+ indexed: false,
32730
+ internalType: "uint128",
32731
+ name: "amount",
32732
+ type: "uint128"
32733
+ },
32734
+ {
32735
+ indexed: false,
32736
+ internalType: "uint256",
32737
+ name: "amount0",
32738
+ type: "uint256"
32739
+ },
32740
+ {
32741
+ indexed: false,
32742
+ internalType: "uint256",
32743
+ name: "amount1",
32744
+ type: "uint256"
32745
+ }
32746
+ ],
32747
+ name: "Mint",
32748
+ type: "event"
32749
+ },
32750
+ {
32751
+ anonymous: false,
32752
+ inputs: [
32753
+ {
32754
+ indexed: false,
32755
+ internalType: "uint8",
32756
+ name: "feeProtocol0Old",
32757
+ type: "uint8"
32758
+ },
32759
+ {
32760
+ indexed: false,
32761
+ internalType: "uint8",
32762
+ name: "feeProtocol1Old",
32763
+ type: "uint8"
32764
+ },
32765
+ {
32766
+ indexed: false,
32767
+ internalType: "uint8",
32768
+ name: "feeProtocol0New",
32769
+ type: "uint8"
32770
+ },
32771
+ {
32772
+ indexed: false,
32773
+ internalType: "uint8",
32774
+ name: "feeProtocol1New",
32775
+ type: "uint8"
32776
+ }
32777
+ ],
32778
+ name: "SetFeeProtocol",
32779
+ type: "event"
32780
+ },
32781
+ {
32782
+ anonymous: false,
32783
+ inputs: [
32784
+ {
32785
+ indexed: true,
32786
+ internalType: "address",
32787
+ name: "sender",
32788
+ type: "address"
32789
+ },
32790
+ {
32791
+ indexed: true,
32792
+ internalType: "address",
32793
+ name: "recipient",
32794
+ type: "address"
32795
+ },
32796
+ {
32797
+ indexed: false,
32798
+ internalType: "int256",
32799
+ name: "amount0",
32800
+ type: "int256"
32801
+ },
32802
+ {
32803
+ indexed: false,
32804
+ internalType: "int256",
32805
+ name: "amount1",
32806
+ type: "int256"
32807
+ },
32808
+ {
32809
+ indexed: false,
32810
+ internalType: "uint160",
32811
+ name: "sqrtPriceX96",
32812
+ type: "uint160"
32813
+ },
32814
+ {
32815
+ indexed: false,
32816
+ internalType: "uint128",
32817
+ name: "liquidity",
32818
+ type: "uint128"
32819
+ },
32820
+ {
32821
+ indexed: false,
32822
+ internalType: "int24",
32823
+ name: "tick",
32824
+ type: "int24"
32825
+ }
32826
+ ],
32827
+ name: "Swap",
32828
+ type: "event"
32829
+ },
32830
+ {
32831
+ inputs: [
32832
+ {
32833
+ internalType: "int24",
32834
+ name: "tickLower",
32835
+ type: "int24"
32836
+ },
32837
+ {
32838
+ internalType: "int24",
32839
+ name: "tickUpper",
32840
+ type: "int24"
32841
+ },
32842
+ {
32843
+ internalType: "uint128",
32844
+ name: "amount",
32845
+ type: "uint128"
32846
+ }
32847
+ ],
32848
+ name: "burn",
32849
+ outputs: [{
32850
+ internalType: "uint256",
32851
+ name: "amount0",
32852
+ type: "uint256"
32853
+ }, {
32854
+ internalType: "uint256",
32855
+ name: "amount1",
32856
+ type: "uint256"
32857
+ }],
32858
+ stateMutability: "payable",
32859
+ type: "function"
32860
+ },
32861
+ {
32862
+ inputs: [
32863
+ {
32864
+ internalType: "address",
32865
+ name: "recipient",
32866
+ type: "address"
32867
+ },
32868
+ {
32869
+ internalType: "int24",
32870
+ name: "tickLower",
32871
+ type: "int24"
32872
+ },
32873
+ {
32874
+ internalType: "int24",
32875
+ name: "tickUpper",
32876
+ type: "int24"
32877
+ },
32878
+ {
32879
+ internalType: "uint128",
32880
+ name: "amount0Requested",
32881
+ type: "uint128"
32882
+ },
32883
+ {
32884
+ internalType: "uint128",
32885
+ name: "amount1Requested",
32886
+ type: "uint128"
32887
+ }
32888
+ ],
32889
+ name: "collect",
32890
+ outputs: [{
32891
+ internalType: "uint128",
32892
+ name: "amount0",
32893
+ type: "uint128"
32894
+ }, {
32895
+ internalType: "uint128",
32896
+ name: "amount1",
32897
+ type: "uint128"
32898
+ }],
32899
+ stateMutability: "payable",
32900
+ type: "function"
32901
+ },
32902
+ {
32903
+ inputs: [
32904
+ {
32905
+ internalType: "address",
32906
+ name: "recipient",
32907
+ type: "address"
32908
+ },
32909
+ {
32910
+ internalType: "uint128",
32911
+ name: "amount0Requested",
32912
+ type: "uint128"
32913
+ },
32914
+ {
32915
+ internalType: "uint128",
32916
+ name: "amount1Requested",
32917
+ type: "uint128"
32918
+ }
32919
+ ],
32920
+ name: "collectProtocol",
32921
+ outputs: [{
32922
+ internalType: "uint128",
32923
+ name: "amount0",
32924
+ type: "uint128"
32925
+ }, {
32926
+ internalType: "uint128",
32927
+ name: "amount1",
32928
+ type: "uint128"
32929
+ }],
32930
+ stateMutability: "payable",
32931
+ type: "function"
32932
+ },
32933
+ {
32934
+ inputs: [],
32935
+ name: "factory",
32936
+ outputs: [{
32937
+ internalType: "address",
32938
+ name: "",
32939
+ type: "address"
32940
+ }],
32941
+ stateMutability: "view",
32942
+ type: "function"
32943
+ },
32944
+ {
32945
+ inputs: [],
32946
+ name: "fee",
32947
+ outputs: [{
32948
+ internalType: "uint24",
32949
+ name: "",
32950
+ type: "uint24"
32951
+ }],
32952
+ stateMutability: "view",
32953
+ type: "function"
32954
+ },
32955
+ {
32956
+ inputs: [],
32957
+ name: "feeGrowthGlobal0X128",
32958
+ outputs: [{
32959
+ internalType: "uint256",
32960
+ name: "",
32961
+ type: "uint256"
32962
+ }],
32963
+ stateMutability: "view",
32964
+ type: "function"
32965
+ },
32966
+ {
32967
+ inputs: [],
32968
+ name: "feeGrowthGlobal1X128",
32969
+ outputs: [{
32970
+ internalType: "uint256",
32971
+ name: "",
32972
+ type: "uint256"
32973
+ }],
32974
+ stateMutability: "view",
32975
+ type: "function"
32976
+ },
32977
+ {
32978
+ inputs: [
32979
+ {
32980
+ internalType: "address",
32981
+ name: "recipient",
32982
+ type: "address"
32983
+ },
32984
+ {
32985
+ internalType: "uint256",
32986
+ name: "amount0",
32987
+ type: "uint256"
32988
+ },
32989
+ {
32990
+ internalType: "uint256",
32991
+ name: "amount1",
32992
+ type: "uint256"
32993
+ },
32994
+ {
32995
+ internalType: "bytes",
32996
+ name: "data",
32997
+ type: "bytes"
32998
+ }
32999
+ ],
33000
+ name: "flash",
33001
+ outputs: [],
33002
+ stateMutability: "payable",
33003
+ type: "function"
33004
+ },
33005
+ {
33006
+ inputs: [{
33007
+ internalType: "uint16",
33008
+ name: "observationCardinalityNext",
33009
+ type: "uint16"
33010
+ }],
33011
+ name: "increaseObservationCardinalityNext",
33012
+ outputs: [],
33013
+ stateMutability: "payable",
33014
+ type: "function"
33015
+ },
33016
+ {
33017
+ inputs: [{
33018
+ internalType: "uint160",
33019
+ name: "sqrtPriceX96",
33020
+ type: "uint160"
33021
+ }],
33022
+ name: "initialize",
33023
+ outputs: [],
33024
+ stateMutability: "payable",
33025
+ type: "function"
33026
+ },
33027
+ {
33028
+ inputs: [],
33029
+ name: "liquidity",
33030
+ outputs: [{
33031
+ internalType: "uint128",
33032
+ name: "",
33033
+ type: "uint128"
33034
+ }],
33035
+ stateMutability: "view",
33036
+ type: "function"
33037
+ },
33038
+ {
33039
+ inputs: [],
33040
+ name: "maxLiquidityPerTick",
33041
+ outputs: [{
33042
+ internalType: "uint128",
33043
+ name: "",
33044
+ type: "uint128"
33045
+ }],
33046
+ stateMutability: "view",
33047
+ type: "function"
33048
+ },
33049
+ {
33050
+ inputs: [
33051
+ {
33052
+ internalType: "address",
33053
+ name: "recipient",
33054
+ type: "address"
33055
+ },
33056
+ {
33057
+ internalType: "int24",
33058
+ name: "tickLower",
33059
+ type: "int24"
33060
+ },
33061
+ {
33062
+ internalType: "int24",
33063
+ name: "tickUpper",
33064
+ type: "int24"
33065
+ },
33066
+ {
33067
+ internalType: "uint128",
33068
+ name: "amount",
33069
+ type: "uint128"
33070
+ },
33071
+ {
33072
+ internalType: "bytes",
33073
+ name: "data",
33074
+ type: "bytes"
33075
+ }
33076
+ ],
33077
+ name: "mint",
33078
+ outputs: [{
33079
+ internalType: "uint256",
33080
+ name: "amount0",
33081
+ type: "uint256"
33082
+ }, {
33083
+ internalType: "uint256",
33084
+ name: "amount1",
33085
+ type: "uint256"
33086
+ }],
33087
+ stateMutability: "payable",
33088
+ type: "function"
33089
+ },
33090
+ {
33091
+ inputs: [{
33092
+ internalType: "uint256",
33093
+ name: "",
33094
+ type: "uint256"
33095
+ }],
33096
+ name: "observations",
33097
+ outputs: [
33098
+ {
33099
+ internalType: "uint32",
33100
+ name: "blockTimestamp",
33101
+ type: "uint32"
33102
+ },
33103
+ {
33104
+ internalType: "int56",
33105
+ name: "tickCumulative",
33106
+ type: "int56"
33107
+ },
33108
+ {
33109
+ internalType: "uint160",
33110
+ name: "secondsPerLiquidityCumulativeX128",
33111
+ type: "uint160"
33112
+ },
33113
+ {
33114
+ internalType: "bool",
33115
+ name: "initialized",
33116
+ type: "bool"
33117
+ }
33118
+ ],
33119
+ stateMutability: "view",
33120
+ type: "function"
33121
+ },
33122
+ {
33123
+ inputs: [{
33124
+ internalType: "uint32[]",
33125
+ name: "secondsAgos",
33126
+ type: "uint32[]"
33127
+ }],
33128
+ name: "observe",
33129
+ outputs: [{
33130
+ internalType: "int56[]",
33131
+ name: "tickCumulatives",
33132
+ type: "int56[]"
33133
+ }, {
33134
+ internalType: "uint160[]",
33135
+ name: "secondsPerLiquidityCumulativeX128s",
33136
+ type: "uint160[]"
33137
+ }],
33138
+ stateMutability: "view",
33139
+ type: "function"
33140
+ },
33141
+ {
33142
+ inputs: [{
33143
+ internalType: "bytes32",
33144
+ name: "",
33145
+ type: "bytes32"
33146
+ }],
33147
+ name: "positions",
33148
+ outputs: [
33149
+ {
33150
+ internalType: "uint128",
33151
+ name: "liquidity",
33152
+ type: "uint128"
33153
+ },
33154
+ {
33155
+ internalType: "uint256",
33156
+ name: "feeGrowthInside0LastX128",
33157
+ type: "uint256"
33158
+ },
33159
+ {
33160
+ internalType: "uint256",
33161
+ name: "feeGrowthInside1LastX128",
33162
+ type: "uint256"
33163
+ },
33164
+ {
33165
+ internalType: "uint128",
33166
+ name: "tokensOwed0",
33167
+ type: "uint128"
33168
+ },
33169
+ {
33170
+ internalType: "uint128",
33171
+ name: "tokensOwed1",
33172
+ type: "uint128"
33173
+ }
33174
+ ],
33175
+ stateMutability: "view",
33176
+ type: "function"
33177
+ },
33178
+ {
33179
+ inputs: [],
33180
+ name: "protocolFees",
33181
+ outputs: [{
33182
+ internalType: "uint128",
33183
+ name: "token0",
33184
+ type: "uint128"
33185
+ }, {
33186
+ internalType: "uint128",
33187
+ name: "token1",
33188
+ type: "uint128"
33189
+ }],
33190
+ stateMutability: "view",
33191
+ type: "function"
33192
+ },
33193
+ {
33194
+ inputs: [{
33195
+ internalType: "uint8",
33196
+ name: "feeProtocol0",
33197
+ type: "uint8"
33198
+ }, {
33199
+ internalType: "uint8",
33200
+ name: "feeProtocol1",
33201
+ type: "uint8"
33202
+ }],
33203
+ name: "setFeeProtocol",
33204
+ outputs: [],
33205
+ stateMutability: "payable",
33206
+ type: "function"
33207
+ },
33208
+ {
33209
+ inputs: [],
33210
+ name: "slot0",
33211
+ outputs: [
33212
+ {
33213
+ internalType: "uint160",
33214
+ name: "sqrtPriceX96",
33215
+ type: "uint160"
33216
+ },
33217
+ {
33218
+ internalType: "int24",
33219
+ name: "tick",
33220
+ type: "int24"
33221
+ },
33222
+ {
33223
+ internalType: "uint16",
33224
+ name: "observationIndex",
33225
+ type: "uint16"
33226
+ },
33227
+ {
33228
+ internalType: "uint16",
33229
+ name: "observationCardinality",
33230
+ type: "uint16"
33231
+ },
33232
+ {
33233
+ internalType: "uint16",
33234
+ name: "observationCardinalityNext",
33235
+ type: "uint16"
33236
+ },
33237
+ {
33238
+ internalType: "uint8",
33239
+ name: "feeProtocol",
33240
+ type: "uint8"
33241
+ },
33242
+ {
33243
+ internalType: "bool",
33244
+ name: "unlocked",
33245
+ type: "bool"
33246
+ }
33247
+ ],
33248
+ stateMutability: "view",
33249
+ type: "function"
33250
+ },
33251
+ {
33252
+ inputs: [{
33253
+ internalType: "int24",
33254
+ name: "tickLower",
33255
+ type: "int24"
33256
+ }, {
33257
+ internalType: "int24",
33258
+ name: "tickUpper",
33259
+ type: "int24"
33260
+ }],
33261
+ name: "snapshotCumulativesInside",
33262
+ outputs: [
33263
+ {
33264
+ internalType: "int56",
33265
+ name: "tickCumulativeInside",
33266
+ type: "int56"
33267
+ },
33268
+ {
33269
+ internalType: "uint160",
33270
+ name: "secondsPerLiquidityInsideX128",
33271
+ type: "uint160"
33272
+ },
33273
+ {
33274
+ internalType: "uint32",
33275
+ name: "secondsInside",
33276
+ type: "uint32"
33277
+ }
33278
+ ],
33279
+ stateMutability: "view",
33280
+ type: "function"
33281
+ },
33282
+ {
33283
+ inputs: [
33284
+ {
33285
+ internalType: "address",
33286
+ name: "recipient",
33287
+ type: "address"
33288
+ },
33289
+ {
33290
+ internalType: "bool",
33291
+ name: "zeroForOne",
33292
+ type: "bool"
33293
+ },
33294
+ {
33295
+ internalType: "int256",
33296
+ name: "amountSpecified",
33297
+ type: "int256"
33298
+ },
33299
+ {
33300
+ internalType: "uint160",
33301
+ name: "sqrtPriceLimitX96",
33302
+ type: "uint160"
33303
+ },
33304
+ {
33305
+ internalType: "bytes",
33306
+ name: "data",
33307
+ type: "bytes"
33308
+ }
33309
+ ],
33310
+ name: "swap",
33311
+ outputs: [{
33312
+ internalType: "int256",
33313
+ name: "amount0",
33314
+ type: "int256"
33315
+ }, {
33316
+ internalType: "int256",
33317
+ name: "amount1",
33318
+ type: "int256"
33319
+ }],
33320
+ stateMutability: "payable",
33321
+ type: "function"
33322
+ },
33323
+ {
33324
+ inputs: [{
33325
+ internalType: "int16",
33326
+ name: "",
33327
+ type: "int16"
33328
+ }],
33329
+ name: "tickBitmap",
33330
+ outputs: [{
33331
+ internalType: "uint256",
33332
+ name: "",
33333
+ type: "uint256"
33334
+ }],
33335
+ stateMutability: "view",
33336
+ type: "function"
33337
+ },
33338
+ {
33339
+ inputs: [],
33340
+ name: "tickSpacing",
33341
+ outputs: [{
33342
+ internalType: "int24",
33343
+ name: "",
33344
+ type: "int24"
33345
+ }],
33346
+ stateMutability: "view",
33347
+ type: "function"
33348
+ },
33349
+ {
33350
+ inputs: [{
33351
+ internalType: "int24",
33352
+ name: "",
33353
+ type: "int24"
33354
+ }],
33355
+ name: "ticks",
33356
+ outputs: [
33357
+ {
33358
+ internalType: "uint128",
33359
+ name: "liquidityGross",
33360
+ type: "uint128"
33361
+ },
33362
+ {
33363
+ internalType: "int128",
33364
+ name: "liquidityNet",
33365
+ type: "int128"
33366
+ },
33367
+ {
33368
+ internalType: "uint256",
33369
+ name: "feeGrowthOutside0X128",
33370
+ type: "uint256"
33371
+ },
33372
+ {
33373
+ internalType: "uint256",
33374
+ name: "feeGrowthOutside1X128",
33375
+ type: "uint256"
33376
+ },
33377
+ {
33378
+ internalType: "int56",
33379
+ name: "tickCumulativeOutside",
33380
+ type: "int56"
33381
+ },
33382
+ {
33383
+ internalType: "uint160",
33384
+ name: "secondsPerLiquidityOutsideX128",
33385
+ type: "uint160"
33386
+ },
33387
+ {
33388
+ internalType: "uint32",
33389
+ name: "secondsOutside",
33390
+ type: "uint32"
33391
+ },
33392
+ {
33393
+ internalType: "bool",
33394
+ name: "initialized",
33395
+ type: "bool"
33396
+ }
33397
+ ],
33398
+ stateMutability: "view",
33399
+ type: "function"
33400
+ },
33401
+ {
33402
+ inputs: [],
33403
+ name: "token0",
33404
+ outputs: [{
33405
+ internalType: "address",
33406
+ name: "",
33407
+ type: "address"
33408
+ }],
33409
+ stateMutability: "view",
33410
+ type: "function"
33411
+ },
33412
+ {
33413
+ inputs: [],
33414
+ name: "token1",
33415
+ outputs: [{
33416
+ internalType: "address",
33417
+ name: "",
33418
+ type: "address"
33419
+ }],
33420
+ stateMutability: "view",
33421
+ type: "function"
33422
+ }
33423
+ ];
33424
+
33425
+ //#endregion
33426
+ //#region src/panoptic/v2/events/poolSwapStream.ts
33427
+ const DEFAULT_POLL_INTERVAL_MS$1 = 3e3;
33428
+ const FAILURE_WINDOW_MS = 3e4;
33429
+ const FAILURES_BEFORE_POLL = 3;
33430
+ const STREAM_RETRY_MIN_MS = 15e3;
33431
+ const STREAM_RETRY_MAX_MS = 3e5;
33432
+ const RESYNC_JITTER_MS = 2e3;
33433
+ const EVENT_SOURCE_CLOSED = 2;
33434
+ function parseRecord(data) {
33435
+ const value = JSON.parse(data);
33436
+ if (typeof value !== "object" || value === null) throw new Error("Malformed stream frame");
33437
+ return value;
33438
+ }
33439
+ function bigintField(record, field) {
33440
+ const value = record[field];
33441
+ if (typeof value !== "string") throw new Error(`Stream frame is missing ${field}`);
33442
+ return BigInt(value);
33443
+ }
33444
+ function numberField(record, field) {
33445
+ const value = record[field];
33446
+ if (typeof value !== "number") throw new Error(`Stream frame is missing ${field}`);
33447
+ return value;
33448
+ }
33449
+ function parseStreamedKey(data) {
33450
+ const record = parseRecord(data);
33451
+ return {
33452
+ blockNumber: bigintField(record, "blockNumber"),
33453
+ logIndex: numberField(record, "logIndex")
33454
+ };
33455
+ }
33456
+ function parseStreamedSwap(data) {
33457
+ const record = parseRecord(data);
33458
+ const transactionHash = record.transactionHash;
33459
+ if (typeof transactionHash !== "string") throw new Error("Stream frame is missing transactionHash");
33460
+ return {
33461
+ ...parseStreamedKey(data),
33462
+ timestamp: bigintField(record, "timestamp"),
33463
+ transactionHash,
33464
+ tick: numberField(record, "tick"),
33465
+ amount0: bigintField(record, "amount0"),
33466
+ amount1: bigintField(record, "amount1"),
33467
+ sqrtPriceX96: bigintField(record, "sqrtPriceX96"),
33468
+ liquidity: bigintField(record, "liquidity")
33469
+ };
33470
+ }
33471
+ function parseHead(data) {
33472
+ return bigintField(parseRecord(data ?? ""), "head");
33473
+ }
33474
+ function defaultEventSource() {
33475
+ const EventSourceCtor = globalThis.EventSource;
33476
+ return EventSourceCtor && ((url) => new EventSourceCtor(url));
33477
+ }
33478
+ function toError$1(error) {
33479
+ return error instanceof Error ? error : new Error(String(error));
33480
+ }
33481
+ /**
33482
+ * Stream a pool's swaps from the relay at `streamUrl`.
33483
+ *
33484
+ * Every `ready`/`resync` frame carries the relay's head; swaps from the cursor up
33485
+ * to that head are fetched over HTTP so nothing is lost across reconnects. A
33486
+ * stream that closes, or errors three times in 30 s, is replaced by HTTP polling
33487
+ * and retried with backoff; one that closes before ever opening is not retried.
33488
+ */
33489
+ function streamPoolSwaps(params) {
33490
+ const { client, pool, fromBlock, pollIntervalMs = DEFAULT_POLL_INTERVAL_MS$1, maxBlockRange = DEFAULT_MAX_BLOCK_RANGE, streamUrl, onSwaps, onError, onRemoved, onTransport, eventSource = defaultEventSource() } = params;
33491
+ let running = true;
33492
+ let cursor = fromBlock === void 0 ? void 0 : fromBlock - 1n;
33493
+ let transport = "off";
33494
+ let failures = [];
33495
+ let source;
33496
+ let poller;
33497
+ let retryTimer;
33498
+ let retryDelayMs = STREAM_RETRY_MIN_MS;
33499
+ let catchUpTimer;
33500
+ let catchUpTarget;
33501
+ let catchingUp = false;
33502
+ let everOpened = false;
33503
+ const setTransport = (next) => {
33504
+ if (next === transport) return;
33505
+ transport = next;
33506
+ onTransport?.(next);
33507
+ };
33508
+ const advance = (block) => {
33509
+ if (block !== void 0 && (cursor === void 0 || block > cursor)) cursor = block;
33510
+ };
33511
+ const report = (error) => {
33512
+ if (running) onError?.(toError$1(error));
33513
+ };
33514
+ const catchUpPending = () => catchingUp || catchUpTarget !== void 0;
33515
+ const runCatchUp = async () => {
33516
+ catchingUp = true;
33517
+ while (running && catchUpTarget !== void 0) {
33518
+ const head = catchUpTarget;
33519
+ catchUpTarget = void 0;
33520
+ if (cursor === void 0) {
33521
+ cursor = head;
33522
+ continue;
33523
+ }
33524
+ try {
33525
+ const { swaps } = await fetchPoolSwaps(client, pool, cursor + 1n, head, maxBlockRange);
33526
+ if (!running) break;
33527
+ const first = swaps[0];
33528
+ const last = swaps[swaps.length - 1];
33529
+ if (first && last) onSwaps(swaps, {
33530
+ fromBlock: first.blockNumber,
33531
+ toBlock: last.blockNumber
33532
+ });
33533
+ advance(head);
33534
+ } catch (error) {
33535
+ report(error);
33536
+ if (catchUpTarget === void 0 || catchUpTarget < head) catchUpTarget = head;
33537
+ catchingUp = false;
33538
+ catchUpTimer = setTimeout(() => void runCatchUp(), pollIntervalMs);
33539
+ return;
33540
+ }
33541
+ }
33542
+ catchingUp = false;
33543
+ };
33544
+ const catchUp = (head, delayMs = 0) => {
33545
+ if (catchUpTarget === void 0 || head > catchUpTarget) catchUpTarget = head;
33546
+ if (catchingUp) return;
33547
+ if (catchUpTimer !== void 0) clearTimeout(catchUpTimer);
33548
+ catchUpTimer = setTimeout(() => {
33549
+ catchUpTimer = void 0;
33550
+ runCatchUp();
33551
+ }, delayMs);
33552
+ };
33553
+ const startPolling = () => {
33554
+ if (poller) return;
33555
+ poller = watchPoolSwaps({
33556
+ client,
33557
+ pool,
33558
+ fromBlock: cursor === void 0 ? void 0 : cursor + 1n,
33559
+ pollIntervalMs,
33560
+ maxBlockRange,
33561
+ onSwaps,
33562
+ onError
33563
+ });
33564
+ setTransport("poll");
33565
+ };
33566
+ const stopPolling = () => {
33567
+ if (!poller) return;
33568
+ advance(poller.lastScannedBlock());
33569
+ poller.stop();
33570
+ poller = void 0;
33571
+ };
33572
+ const closeStream = () => {
33573
+ source?.close();
33574
+ source = void 0;
33575
+ };
33576
+ const scheduleStreamRetry = () => {
33577
+ retryTimer = setTimeout(() => {
33578
+ retryTimer = void 0;
33579
+ if (running) openStream();
33580
+ }, retryDelayMs);
33581
+ retryDelayMs = Math.min(retryDelayMs * 2, STREAM_RETRY_MAX_MS);
33582
+ };
33583
+ const openStream = () => {
33584
+ if (!eventSource) {
33585
+ startPolling();
33586
+ return;
33587
+ }
33588
+ const es = eventSource(streamUrl);
33589
+ source = es;
33590
+ failures = [];
33591
+ let opened = false;
33592
+ const listen = (type, handle) => es.addEventListener(type, (event) => {
33593
+ if (!running || source !== es) return;
33594
+ try {
33595
+ handle(event.data);
33596
+ } catch (error) {
33597
+ report(error);
33598
+ }
33599
+ });
33600
+ listen("open", () => {
33601
+ opened = true;
33602
+ everOpened = true;
33603
+ failures = [];
33604
+ retryDelayMs = STREAM_RETRY_MIN_MS;
33605
+ });
33606
+ listen("ready", (data) => {
33607
+ const head = parseHead(data);
33608
+ stopPolling();
33609
+ setTransport("stream");
33610
+ catchUp(head);
33611
+ });
33612
+ listen("resync", (data) => {
33613
+ catchUp(parseHead(data), Math.random() * RESYNC_JITTER_MS);
33614
+ });
33615
+ listen("swap", (data) => {
33616
+ const swap = parseStreamedSwap(data ?? "");
33617
+ onSwaps([swap], {
33618
+ fromBlock: swap.blockNumber,
33619
+ toBlock: swap.blockNumber
33620
+ });
33621
+ if (!catchUpPending()) advance(swap.blockNumber);
33622
+ });
33623
+ listen("removed", (data) => {
33624
+ onRemoved?.(parseStreamedKey(data ?? ""));
33625
+ });
33626
+ listen("error", () => {
33627
+ const now = Date.now();
33628
+ failures = failures.filter((at) => now - at < FAILURE_WINDOW_MS);
33629
+ failures.push(now);
33630
+ const closed = es.readyState === EVENT_SOURCE_CLOSED;
33631
+ if (!closed && failures.length < FAILURES_BEFORE_POLL) return;
33632
+ closeStream();
33633
+ startPolling();
33634
+ if (closed && !opened && !everOpened) return;
33635
+ scheduleStreamRetry();
33636
+ });
33637
+ };
33638
+ openStream();
33639
+ return {
33640
+ stop() {
33641
+ running = false;
33642
+ closeStream();
33643
+ stopPolling();
33644
+ if (retryTimer !== void 0) clearTimeout(retryTimer);
33645
+ if (catchUpTimer !== void 0) clearTimeout(catchUpTimer);
33646
+ setTransport("off");
33647
+ },
33648
+ lastScannedBlock: () => cursor,
33649
+ transport: () => transport
33650
+ };
33651
+ }
33652
+
33653
+ //#endregion
33654
+ //#region src/panoptic/v2/events/poolSwaps.ts
33655
+ const DEFAULT_POLL_INTERVAL_MS = 3e3;
33656
+ const DEFAULT_MAX_BLOCK_RANGE = 2000n;
33657
+ const SHARED_BUFFER_LIMIT = 4096;
33658
+ /**
33659
+ * Parse a decoded v3 `UniswapV3Pool.Swap` or v4 `PoolManager.Swap` log.
33660
+ */
33661
+ function parseSwapLog(log, timestamp) {
33662
+ if (log.blockNumber === null || log.logIndex === null || log.transactionHash === null) throw new Error("Cannot parse a pending Swap log");
33663
+ const args = log.args;
33664
+ return {
33665
+ blockNumber: log.blockNumber,
33666
+ logIndex: log.logIndex,
33667
+ timestamp,
33668
+ transactionHash: log.transactionHash,
33669
+ tick: Number(args.tick),
33670
+ amount0: args.amount0,
33671
+ amount1: args.amount1,
33672
+ sqrtPriceX96: args.sqrtPriceX96,
33673
+ liquidity: args.liquidity
33674
+ };
33675
+ }
33676
+ function toError(error) {
33677
+ return error instanceof Error ? error : new Error(String(error));
33678
+ }
33679
+ async function fetchSwapLogs(client, pool, fromBlock, toBlock) {
33680
+ if (pool.version === "v3") return client.getContractEvents({
33681
+ address: pool.poolAddress,
33682
+ abi: UniswapV3PoolAbi,
33683
+ eventName: "Swap",
33684
+ fromBlock,
33685
+ toBlock
33686
+ });
33687
+ return client.getContractEvents({
33688
+ address: pool.poolManager,
33689
+ abi: poolManagerAbi,
33690
+ eventName: "Swap",
33691
+ args: { id: pool.poolId },
33692
+ fromBlock,
33693
+ toBlock
33694
+ });
33695
+ }
33696
+ async function fetchSwaps(client, pool, fromBlock, toBlock) {
33697
+ const logs = await fetchSwapLogs(client, pool, fromBlock, toBlock);
33698
+ if (logs.length === 0) return [];
33699
+ const blockNumbers = [...new Set(logs.flatMap((log) => log.blockNumber === null ? [] : [log.blockNumber]))];
33700
+ const blocks = await Promise.all(blockNumbers.map((blockNumber) => client.getBlock({ blockNumber })));
33701
+ const timestamps = new Map(blocks.map((block, i) => [blockNumbers[i], block.timestamp]));
33702
+ return logs.map((log) => parseSwapLog(log, timestamps.get(log.blockNumber ?? -1n) ?? 0n)).sort((a, b) => a.blockNumber === b.blockNumber ? a.logIndex - b.logIndex : a.blockNumber < b.blockNumber ? -1 : 1);
33703
+ }
33704
+ /**
33705
+ * Fetch a pool's swaps in `[fromBlock, toBlock]` (default: the current head), in
33706
+ * chain order. Returns no swaps when `fromBlock > toBlock`.
33707
+ */
33708
+ async function fetchPoolSwaps(client, pool, fromBlock, toBlock, maxBlockRange = DEFAULT_MAX_BLOCK_RANGE) {
33709
+ const end = toBlock ?? await client.getBlockNumber();
33710
+ const swaps = [];
33711
+ for (let from = fromBlock; from <= end; from += maxBlockRange) {
33712
+ const to = from + maxBlockRange - 1n < end ? from + maxBlockRange - 1n : end;
33713
+ swaps.push(...await fetchSwaps(client, pool, from, to));
33714
+ }
33715
+ return {
33716
+ swaps,
33717
+ toBlock: end
33718
+ };
33719
+ }
33720
+ /**
33721
+ * Poll a single pool's `Swap` logs with `eth_getLogs`, timestamped by block.
33722
+ *
33723
+ * Works over plain HTTP (no filters or websockets). A chunk that fails is retried on
33724
+ * the next tick; errors never stop the loop.
33725
+ */
33726
+ function watchPoolSwaps(params) {
33727
+ const { client, pool, fromBlock, pollIntervalMs = DEFAULT_POLL_INTERVAL_MS, maxBlockRange = DEFAULT_MAX_BLOCK_RANGE, onSwaps, onError } = params;
33728
+ let running = true;
33729
+ let lastScanned;
33730
+ let timer;
33731
+ const poll = async () => {
33732
+ try {
33733
+ const head = await client.getBlockNumber();
33734
+ let from = lastScanned !== void 0 ? lastScanned + 1n : fromBlock ?? head;
33735
+ while (running && from <= head) {
33736
+ const to = from + maxBlockRange - 1n < head ? from + maxBlockRange - 1n : head;
33737
+ const swaps = await fetchSwaps(client, pool, from, to);
33738
+ if (!running) return;
33739
+ if (swaps.length > 0) onSwaps(swaps, {
33740
+ fromBlock: from,
33741
+ toBlock: to
33742
+ });
33743
+ lastScanned = to;
33744
+ from = to + 1n;
33745
+ }
33746
+ } catch (error) {
33747
+ if (running) onError?.(toError(error));
33748
+ }
33749
+ if (running) timer = setTimeout(() => void poll(), pollIntervalMs);
33750
+ };
33751
+ poll();
33752
+ return {
33753
+ stop() {
33754
+ running = false;
33755
+ if (timer !== void 0) clearTimeout(timer);
33756
+ },
33757
+ lastScannedBlock: () => lastScanned
33758
+ };
33759
+ }
33760
+ const sharedWatchers = new Map();
33761
+ function swapKey(key) {
33762
+ return `${key.blockNumber}:${key.logIndex}`;
33763
+ }
33764
+ /**
33765
+ * Ref-counted pool swap feed: subscribers with the same `key` share one watcher
33766
+ * (relay stream when `streamUrl` is set, else HTTP polling), duplicates are
33767
+ * dropped, late subscribers first receive the swaps already seen, and the watcher
33768
+ * stops when the last subscriber unsubscribes.
33769
+ */
33770
+ function subscribePoolSwaps(params) {
33771
+ const { key, streamUrl, onSwaps, onError, onRemoved, onTransport,...watchParams } = params;
33772
+ const listener = {
33773
+ onSwaps,
33774
+ onError,
33775
+ onRemoved,
33776
+ onTransport
33777
+ };
33778
+ const existing = sharedWatchers.get(key);
33779
+ if (existing) {
33780
+ existing.listeners.add(listener);
33781
+ const buffered = [...existing.buffer.values()];
33782
+ const first = buffered[0];
33783
+ const last = buffered[buffered.length - 1];
33784
+ if (first && last) onSwaps(buffered, {
33785
+ fromBlock: first.blockNumber,
33786
+ toBlock: last.blockNumber
33787
+ });
33788
+ onTransport?.(existing.transport);
33789
+ } else {
33790
+ const listeners = new Set([listener]);
33791
+ const buffer = new Map();
33792
+ const entry = {
33793
+ watcher: {
33794
+ stop: () => void 0,
33795
+ lastScannedBlock: () => void 0
33796
+ },
33797
+ listeners,
33798
+ buffer,
33799
+ transport: "off"
33800
+ };
33801
+ const setTransport = (transport) => {
33802
+ entry.transport = transport;
33803
+ for (const l of listeners) l.onTransport?.(transport);
33804
+ };
33805
+ const callbacks = {
33806
+ onSwaps: (swaps, range) => {
33807
+ const fresh = swaps.filter((swap) => !buffer.has(swapKey(swap)));
33808
+ if (fresh.length === 0) return;
33809
+ for (const swap of fresh) buffer.set(swapKey(swap), swap);
33810
+ for (const k of buffer.keys()) {
33811
+ if (buffer.size <= SHARED_BUFFER_LIMIT) break;
33812
+ buffer.delete(k);
33813
+ }
33814
+ for (const l of listeners) l.onSwaps(fresh, range);
33815
+ },
33816
+ onError: (error) => {
33817
+ for (const l of listeners) l.onError?.(error);
33818
+ }
33819
+ };
33820
+ sharedWatchers.set(key, entry);
33821
+ if (streamUrl !== void 0) entry.watcher = streamPoolSwaps({
33822
+ ...watchParams,
33823
+ ...callbacks,
33824
+ streamUrl,
33825
+ onRemoved: (removed) => {
33826
+ buffer.delete(swapKey(removed));
33827
+ for (const l of listeners) l.onRemoved?.(removed);
33828
+ },
33829
+ onTransport: setTransport
33830
+ });
33831
+ else {
33832
+ entry.watcher = watchPoolSwaps({
33833
+ ...watchParams,
33834
+ ...callbacks
33835
+ });
33836
+ setTransport("poll");
33837
+ }
33838
+ }
33839
+ return () => {
33840
+ const entry = sharedWatchers.get(key);
33841
+ if (!entry) return;
33842
+ entry.listeners.delete(listener);
33843
+ if (entry.listeners.size === 0) {
33844
+ entry.watcher.stop();
33845
+ sharedWatchers.delete(key);
33846
+ }
33847
+ };
33848
+ }
33849
+
32386
33850
  //#endregion
32387
33851
  //#region src/panoptic/v2/strike/ladder.ts
32388
33852
  /** Target number of rungs across a leg's full range (lower tick → upper tick). */
@@ -33860,7 +35324,7 @@ function calculatePositionVolatilityMetrics({ observations, netPremium, baseFees
33860
35324
  for (const point of points) if (!point.price.isFinite() || point.price.lte(0) || !point.gamma.isFinite() || point.rangeGammas.some((gamma) => !gamma.isFinite())) throw new RangeError("Invalid price or gamma observation");
33861
35325
  const quantum = new Precision(10).pow(-quoteDecimals);
33862
35326
  const gammas = points.flatMap((point) => [point.gamma, ...point.rangeGammas]);
33863
- const peak = gammas.reduce((max, gamma) => Precision.max(max, gamma.abs()), new Precision(0));
35327
+ const peak = gammas.reduce((max$1, gamma) => Precision.max(max$1, gamma.abs()), new Precision(0));
33864
35328
  const tolerance = Precision.max(quantum, peak.mul("1e-12"));
33865
35329
  const positive = gammas.some((gamma) => gamma.gt(tolerance));
33866
35330
  const negative = gammas.some((gamma) => gamma.lt(tolerance.neg()));
@@ -38984,7 +40448,53 @@ function useTxEventConfirmation({ txHash, poolAddress = zeroAddress, collateralT
38984
40448
  isSuccess: data !== void 0
38985
40449
  };
38986
40450
  }
40451
+ /**
40452
+ * Follow a pool's Uniswap `Swap` logs while `enabled`: streamed from `streamUrl`
40453
+ * when given, else polled over HTTP. Mounts with the same chain, pool, `fromBlock`
40454
+ * and `streamUrl` share one watcher. Takes the client explicitly so it works
40455
+ * outside `PanopticProvider`.
40456
+ */
40457
+ function usePoolSwaps(params) {
40458
+ const { client, chainId, pool, fromBlock, streamUrl, enabled } = params;
40459
+ const [transport, setTransport] = useState("off");
40460
+ const onSwapsRef = useRef(params.onSwaps);
40461
+ onSwapsRef.current = params.onSwaps;
40462
+ const onRemovedRef = useRef(params.onRemoved);
40463
+ onRemovedRef.current = params.onRemoved;
40464
+ const onErrorRef = useRef(params.onError);
40465
+ onErrorRef.current = params.onError;
40466
+ const poolKey = pool ? pool.version === "v3" ? pool.poolAddress.toLowerCase() : `${pool.poolManager.toLowerCase()}:${pool.poolId.toLowerCase()}` : void 0;
40467
+ const poolRef = useRef(pool);
40468
+ poolRef.current = pool;
40469
+ useEffect(() => {
40470
+ const currentPool = poolRef.current;
40471
+ if (!enabled || !client || !currentPool || poolKey === void 0 || fromBlock === void 0) return;
40472
+ const unsubscribe = subscribePoolSwaps({
40473
+ key: `${chainId}:${poolKey}:${fromBlock}:${streamUrl ?? "poll"}`,
40474
+ client,
40475
+ pool: currentPool,
40476
+ fromBlock,
40477
+ streamUrl,
40478
+ onSwaps: (swaps) => onSwapsRef.current(swaps),
40479
+ onRemoved: (key) => onRemovedRef.current?.(key),
40480
+ onError: (error) => onErrorRef.current?.(error),
40481
+ onTransport: setTransport
40482
+ });
40483
+ return () => {
40484
+ unsubscribe();
40485
+ setTransport("off");
40486
+ };
40487
+ }, [
40488
+ client,
40489
+ chainId,
40490
+ poolKey,
40491
+ fromBlock,
40492
+ streamUrl,
40493
+ enabled
40494
+ ]);
40495
+ return { transport };
40496
+ }
38987
40497
 
38988
40498
  //#endregion
38989
- export { AccountInsolventError, AlreadyInitializedError, BORROW_INDEX_BITS, BPS_DENOMINATOR, BPS_SCALE, BatchValidationError, BelowMinimumRedemptionError, CastingError, ChunkHasZeroLiquidityError, ChunkLimitError, CrossPoolError, DEFAULT_MAX_SPREAD, DEFAULT_MINT_BUFFER, DEFAULT_MIN_SWAP_RATIO_BPS, DEFAULT_RECONNECT_CONFIG, DEFAULT_VEGOID, DepositTooLargeError, DuplicateTokenIdError, EffectiveLiquidityAboveThresholdError, ExceedsMaximumRedemptionError, InputListFailError, InsufficientCreditLiquidityError, InvalidBuilderCodeError, InvalidHistoryRangeError, InvalidTickBoundError, InvalidTickError, InvalidTokenIdParameterError, InvalidUniswapCallbackError, LEG_BITS, LEG_LIMITS, LEG_MASKS, LengthMismatchError, LiquidityTooHighError, LoanSlotExhaustedError, MARKET_EPOCH_BITS, MARKET_EPOCH_SHIFT, MARKET_INDICATOR_PERIODS, MAX_TICK, MAX_TRACKED_CHUNKS, MINT_BUFFER, MINT_BUFFER_DENOMINATOR, MIN_TICK, MaxRetriesExceededError, MissingPositionIdsError, NO_LOWER_LIQUIDATION_TICK, NO_UPPER_LIQUIDATION_TICK, NetLiquidityZeroError, NetworkMismatchError, NoLegsExercisableError, NotALongLegError, NotBuilderError, NotEnoughLiquidityInChunkError, NotEnoughTokensError, NotGuardianError, NotMarginCalledError, NotPanopticPoolError, ORACLE_EPOCH_SECONDS, OracleRateLimitedError, PanopticError, PanopticHelperNotDeployedError, PanopticProvider, PanopticValidationError, PoolNotInitializedError, PositionCountNotZeroError, PositionNotOwnedError, PositionSnapshotNotFoundError, PositionTooLargeError, PriceBoundFailError, PriceImpactTooLargeError, ProviderLagError, RATE_AT_TARGET_BITS, REORG_DEPTH, REQUIRED_BASE_ERROR_SENTINEL, ReentrancyError, RpcError, RpcResponseError, SCHEMA_VERSION, SECONDS_PER_YEAR, STANDARD_TICK_WIDTHS, STORAGE_PREFIX, STRIKE_LADDER_TARGET_STRIKES, SafeModeError, StaleDataError, StaleOracleError, SwapTokenMismatchError, SyncTimeoutError, TOKEN_ID_BITS, TokenIdHasZeroLegsError, TooManyLegsOpenError, TransferFailedError, UNREALIZED_INTEREST_BITS, UTILIZATION_DENOMINATOR, UnauthorizedUniswapCallbackError, UnderOverFlowError, UnhealthyPoolError, UnsafePremiumSettlementError, VARIANCE_RATIO_LAG, WAD, WrongPoolIdError, WrongUniswapPoolError, ZERO_COLLATERAL, ZERO_VALUATION, ZeroAddressError, ZeroCollateralRequirementError, addLegToTokenId, addPendingPosition, addTrackedChunks, annualizePerSecondRateWad, applyMintBuffer, applyMintBufferPerToken, apportion, approve, approveAndWait, approvePool, assertCanBurn, assertCanForceExercise, assertCanLiquidate, assertCanMint, assertFresh, assertHealthy, assertLpPositionFunded, assertTradeable, borrow, borrowAndWait, buildBatchDispatchArgs, buildCreditSwapCall, buildCreditWrappedDispatch, buildOpenPositionCalldata, buildProtectedSettleDispatch, buildProtectedSettlePlan, buildSettleSequenceCalls, buildSfpmSwapCalldata, buildSfpmSwapPlan, buildTemporaryLoanRecoveryDispatch, buildTokenShortfallRecoveryDispatch, buildUniqueCredit, buildUniqueLoan, buildUniqueWidthZeroLeg, calculateAccountGreeksPure, calculateMarketIndicator, calculatePortfolioDelta, calculatePortfolioGamma, calculatePortfolioGreeks, calculatePortfolioValue, calculatePositionDelta, calculatePositionDeltaDebtOnly, calculatePositionDeltaWithSwap, calculatePositionGamma, calculatePositionGreeks, calculatePositionValue, calculatePositionValues, calculatePositionVolatilityMetrics, calculateResyncBlock, calculateSpreadWad, calculateVarianceProfile, cancelTransaction, checkApproval, checkCollateralAcrossTicks, classifyStrategyGroups, classifyStrike, cleanupStalePendingPositions, clearCheckpoint, clearPendingPositions, clearTrackedChunks, clearTrackedPositions, clearTradeHistory, closePosition, closePositionAndWait, collateralCurveTicks, collateralRuleKindFor, collateralTrackerV2Abi, computeV4PoolId, confirmPendingPosition, convertToAssets, convertToShares, countLegs, createEventPoller, createEventSubscription, createFileStorage, createFlowNeutralTokenId, createMemoryStorage, createNonceManager, createPoolFormatters, createTokenIdBuilder, decodeAllDispatchCalldata, decodeAllLegs, decodeDispatchCalldata, decodeLeftRightSigned, decodeLeftRightUnsigned, decodeLeg, decodeOraclePack, decodeOracleRiskParameters, decodeOracleTiming, decodePanopticTokenURI, decodePoolId, decodeTickSpacing, decodeTokenId, decodeVegoid, deployNewPool, deployNewPoolAndWait, deposit, depositAndWait, deriveSupplyRatePerSecWad, deriveUniqueTokenId, detectReorg, diagnoseOracleSafeMode, dispatch, dispatchAndWait, emptyLiquidateParams, encodeLeg, encodePoolId, encodePoolKeyBytes, encodeV3PoolKeyBytes, encodeV4PoolId, ensureSfpmV3PoolInitialized, estimateBlockNumbers, estimateCloseZapSwap, estimateCollateralBreakdown, estimateCollateralRequired, executeBatchDispatch, executeBatchDispatchAndWait, executeSettleSequence, executeSettleSequenceAndWait, failPendingPosition, feeGrowthInsideX128, feesFromFeeGrowthDelta, fetchPoolId, fetchSfpmV3PoolId, fetchUniswapFeeData, forceExercise, forceExerciseAndWait, formatBlockNumber, formatBps, formatCompact, formatDatetime, formatDuration, formatDurationSeconds, formatFeeTier, formatGas, formatGwei, formatPerSecondRateWadAsAprPct, formatPerSecondRateWadAsApyPct, formatPoolIdHex, formatPriceRange, formatRateWad, formatRatioPercent, formatTick, formatTickRange, formatTimestamp, formatTimestampLocale, formatTokenAmount, formatTokenAmountSigned, formatTokenDelta, formatTokenFlow, formatTokenIdHex, formatTokenIdShort, formatTxHash, formatUtilization, formatWad, formatWadPercent, formatWadSigned, formatWei, generateOverlappingTokenIds, getAccountBuyingPower, getAccountCollateral, getAccountGreeks, getAccountHistory, getAccountPremia, getAccountSummaryBasic, getAccountSummaryRisk, getAssetIndex, getBlockMeta, getChainDeployment, getChunkLiquidities, getChunkSpreads, getClosePositionTransferEstimate, getClosedPositions, getClosedPositionsKey, getCollateralAddresses, getCollateralCurve, getCollateralCurveInputs, getCollateralData, getCollateralRequiredBase, getCollateralSharePrices, getCollateralTotalAssetsBatch, getCurrentRates, getDeltaHedgeParams, getEnforcedTickLimits, getExecutableLpMaxSize, getFactoryConstructMetadata, getFactoryOwnerOf, getFactoryTokenURI, getForfeitablePremium, getGuardianUnlockState, getHedgeLimits, getInterestState, getIrmCurrent, getIrmCurve, getItmAmounts, getLegDelta, getLegDeltaInVaultFrame, getLegGamma, getLegNetValueWidth0, getLegValue, getLiquidationPrices, getMarginBuffer, getMaxPositionSize, getMaxRedeem, getMaxWithdrawable, getNativeTokenPrice, getNetLiquidationValue, getNetLiquidationValues, getNotEnoughTokensError, getOpenPositionIds, getOpenPositionPreview, getOracleRiskParameters, getOracleState, getPanopticPoolAddress, getPanopticPoolFromPoolId, getPendingPositions, getPendingPositionsKey, getPool, getPoolCurrentTick, getPoolDeploymentBlock, getPoolDisplayId, getPoolLiquidities, getPoolMetaKey, getPoolMetadata, getPoolPrefix, getPortfolioValue, getPosition, getPositionChunkData, getPositionDeltaMetrics, getPositionEnrichmentData, getPositionGreeks, getPositionMetaKey, getPositionValueCurve, getPositionVolatilityHistory, getPositions, getPositionsKey, getPositionsWithPremia, getPriceHistory, getPricesAtTick, getRealizedPnL, getRequiredCreditForITM, getRiskParameters, getSafeMode, getSchemaVersionKey, getSimpleLoanTokenIndex, getStreamiaHistory, getSyncCheckpointKey, getSyncStatus, getTickSpacing, getTokenListId, getTrackedChunks, getTrackedChunksKey, getTrackedPositionIds, getTradeHistory, getUniswapFeeHistory, getUniswapV3LpPositionState, getUniswapV3PoolFromId, getUniswapV3PoolInfo, getUniswapV3PoolLiquidities, getUniswapV4LpPositionState, getUniswapV4PoolBasicState, getUniswapV4PoolInfo, getUniswapV4PoolKeyFromId, getUniswapV4PoolLiquidities, getUtilization, hasLoanOrCredit, hasLongLeg, interpolateBlocks, isCall, isCowSupportedChain, isCredit, isCreditLeg, isDefinedRisk, isGasError, isInputListFailError, isLiquidatable, isLoan, isLoanLeg, isNonceError, isPanopticErrorType, isPositionTracked, isRetryableRpcError, isShortOnly, isSpread, isSupportedChain, isolateGroupTokenId, jsonSerializer, ladderStrikeSequence, liquidate, liquidateAndWait, loadCheckpoint, logReturns, marketPnlInQuote, marketRiskFromValues, marketScenario, minePoolAddress, mint, mintAndWait, mintableAfterBuffer, multicallRead, mutationEffects, netLiquidationValueInQuote, openPosition, openPositionAndWait, optimizeTokenIdRiskPartners, oracleEpochAt, orderListForSettle, packMarketState, panopticLiquidatorAbi, panopticPoolV2Abi, panopticQueryAbi, parseBps, parseCollateralLog, parsePanopticError, parsePoolLog, parseTokenAmount, parseTokenListId, parseWad, planDeriveStrategy, pokeOracle, pokeOracleAndWait, positionValueKey, positionValueTicks, prepareIndicatorCandles, prepareLiquidityGamma, preparePositionGamma, preparePositionValue, preparePositionValueCurve, previewBorrow, previewDeposit, previewMint, previewRedeem, previewRepay, previewUnwrap, previewWithdraw, previewWrap, priceToTick, publicBroadcaster, queryKeys, quoteLiquidation, quoteOneTokenFlow, quoteSfpmSwap, quoteTemporaryLoanRecovery, quoteTokenShortfallRecovery, quoteTokenShortfallSwap, quoteV3ExactIn, ratePerSecWadToAprPct, realizedBeta, reconstructFromEvents, recoverSnapshot, recoverSnapshotFromTx, redeem, redeemAndWait, removeTrackedChunks, repay, repayAndWait, requireChainDeployment, resolveBlockNumbers, resolveLadderStrike, resolvePanopticPoolFromPoolId, resolveTokenIndex, resolveUniswapV4PoolKey, riskEngineAbi, rollPosition, rollPositionAndWait, roundToTickSpacing, saveCheckpoint, saveClosedPosition, scaleCollateralRequired, scanChunks, screenAccountExact, selectDispatchForAccount, settleAccumulatedPremia, settleAccumulatedPremiaAndWait, settlePremiumFrom, settlePremiumFromAndWait, simulateBatchDispatch, simulateClosePosition, simulateClosePremiumProtection, simulateDeployNewPool, simulateDeposit, simulateDispatch, simulateForceExercise, simulateLiquidate, simulateOpenPosition, simulateSFPMBurn, simulateSFPMMint, simulateSettle, simulateSettlePremiumBatch, simulateSettlePremiumFrom, simulateSettleSequence, simulateSwapExactIn, simulateSwapExactOut, simulateWithTokenFlow, simulateWithdraw, slippageBpsToTickDistance, smartRepay, smartRepayAndWait, speedUpTransaction, splitTokenIdByTimescale, sqrtPriceX96ToPriceDecimalScaled, sqrtPriceX96ToTick, supply, supplyAndWait, swapExactIn, swapExactInAndWait, swapExactOut, swapExactOutAndWait, syncPositions, tickLimits, tickToPrice, tickToPriceDecimalScaled, tickToSqrtPriceX96, toVaultFrameAtTick, truncateAddress, unsupply, unsupplyAndWait, unwrapWeth, unwrapWethAndWait, unwrapXstock, unwrapXstockAndWait, useAccountCollateral, useAccountGreeks, useAccountPremia, useAccountSummaryBasic, useAccountSummaryRisk, useAddPendingPosition, useApprove, useApproveErc20ForCow, useApproveErc20ForPermit2, useApprovePool, useApproveRouterViaPermit2, useBatchDispatch as useBatchDispatchHook, useBorrow as useBorrowHook, useCancelCowOrder, useCheckCowApproval, useCheckRouterApproval, useChunkSpreads, useClearTrackedPositions, useClosePosition as useClosePositionHook, useClosedPositions, useCollateralBreakdown, useCollateralData, useConfirmPendingPosition, useCowOrderStatus, useCurrentRates, useDeployNewPool as useDeployNewPoolHook, useDeposit as useDepositHook, useDispatch as useDispatchHook, useEstimateCollateralRequired, useEventPoller, useEventSubscription, useExecuteSettleSequence, useFactoryConstructMetadata, useFactoryOwnerOf, useFactoryTokenURI, useFailPendingPosition, useFlowNeutralTokenId, useForceExercise as useForceExerciseHook, useForfeitablePremium, useGuardianUnlockState, useInterestState, useIsLiquidatable, useLiquidate as useLiquidateHook, useLiquidationPrices, useMarginBuffer, useMaxPositionSize, useMaxRedeem, useMaxWithdrawable, useMinePoolAddress as useMinePoolAddressHook, useMintShares, useNativeTokenPrice, useNetLiquidationValue, useNetLiquidationValues, useOpenPosition as useOpenPositionHook, useOpenPositionPreview, useOptimizeRiskPartners, useOracleState, usePanopticContext, usePanopticPoolAddress, usePokeOracle as usePokeOracleHook, usePool, usePoolLiquidities, usePoolVersion, usePosition, usePositionGreeks, usePositions, usePositionsWithPremia, usePreviewBorrow, usePreviewDeposit, usePreviewMint, usePreviewRedeem, usePreviewWithdraw, usePriceHistory, useQuoteCowSwap, useQuoteSwapExactInViaRouter, useQuoteSwapExactOutViaRouter, useRealizedPnL, useRedeem as useRedeemHook, useRepay as useRepayHook, useResolveUniswapV4PoolKey, useRiskParameters, useRollPosition as useRollPositionHook, useSafeMode, useSettleAccumulatedPremia as useSettleAccumulatedPremiaHook, useSettlePremiumFrom as useSettlePremiumFromHook, useSimulateBatchDispatch, useSimulateClosePosition, useSimulateDeployNewPool, useSimulateDeposit, useSimulateDispatch, useSimulateForceExercise, useSimulateLiquidate, useSimulateOpenPosition, useSimulateSFPMBurn, useSimulateSFPMMint, useSimulateSettle, useSimulateSettlePremiumBatch, useSimulateSettlePremiumFrom, useSimulateSettleSequence, useSimulateSwapExactIn, useSimulateSwapExactOut, useSimulateWithdraw, useSmartRepay as useSmartRepayHook, useStreamiaHistory, useSubmitCowOrder, useSupply as useSupplyHook, useSwapExactIn, useSwapExactInViaRouter, useSwapExactOut, useSwapExactOutViaRouter, useSyncPositions, useSyncStatus, useTrackedPositionIds, useTradeHistory, useTxEventConfirmation, useUniswapFeeHistory, useUniswapV3PoolInfo, useUniswapV3PoolLiquidities, useUniswapV4PoolBasicState, useUniswapV4PoolInfo, useUniswapV4PoolLiquidities, useUnsupply as useUnsupplyHook, useUnwrapWeth, useUnwrapXstock, useUtilization, useValidateBuilderCode, useWatchEvents, useWithdraw as useWithdrawHook, useWithdrawWithPositions as useWithdrawWithPositionsHook, useWrapEth, useWrapXstock, utilizationBpsToWad, utilizationPctToWad, validateBatch, validateBuilderCode, validatePoolId, valuePositionAccrual, verifyBlockContinuity, watchEvents, wethWrapAbi, withdraw, withdrawAndWait, withdrawWithPositions, withdrawWithPositionsAndWait, wrapEth, wrapEthAndWait, wrapXstock, wrapXstockAndWait, xstockWrapperAbi };
40499
+ export { AccountInsolventError, AlreadyInitializedError, BORROW_INDEX_BITS, BPS_DENOMINATOR, BPS_SCALE, BatchValidationError, BelowMinimumRedemptionError, CastingError, ChunkHasZeroLiquidityError, ChunkLimitError, CrossPoolError, DEFAULT_MAX_SPREAD, DEFAULT_MINT_BUFFER, DEFAULT_MIN_SWAP_RATIO_BPS, DEFAULT_RECONNECT_CONFIG, DEFAULT_VEGOID, DepositTooLargeError, DuplicateTokenIdError, EffectiveLiquidityAboveThresholdError, ExceedsMaximumRedemptionError, InputListFailError, InsufficientCreditLiquidityError, InvalidBuilderCodeError, InvalidHistoryRangeError, InvalidTickBoundError, InvalidTickError, InvalidTokenIdParameterError, InvalidUniswapCallbackError, LEG_BITS, LEG_LIMITS, LEG_MASKS, LengthMismatchError, LiquidityTooHighError, LoanSlotExhaustedError, MARKET_EPOCH_BITS, MARKET_EPOCH_SHIFT, MARKET_INDICATOR_PERIODS, MAX_TICK, MAX_TRACKED_CHUNKS, MINT_BUFFER, MINT_BUFFER_DENOMINATOR, MIN_TICK, MaxRetriesExceededError, MissingPositionIdsError, NO_LOWER_LIQUIDATION_TICK, NO_UPPER_LIQUIDATION_TICK, NetLiquidityZeroError, NetworkMismatchError, NoLegsExercisableError, NotALongLegError, NotBuilderError, NotEnoughLiquidityInChunkError, NotEnoughTokensError, NotGuardianError, NotMarginCalledError, NotPanopticPoolError, ORACLE_EPOCH_SECONDS, OracleRateLimitedError, PanopticError, PanopticHelperNotDeployedError, PanopticProvider, PanopticValidationError, PoolNotInitializedError, PositionCountNotZeroError, PositionNotOwnedError, PositionSnapshotNotFoundError, PositionTooLargeError, PriceBoundFailError, PriceImpactTooLargeError, ProviderLagError, RATE_AT_TARGET_BITS, REORG_DEPTH, REQUIRED_BASE_ERROR_SENTINEL, ReentrancyError, RpcError, RpcResponseError, SCHEMA_VERSION, SECONDS_PER_YEAR, STANDARD_TICK_WIDTHS, STORAGE_PREFIX, STRIKE_LADDER_TARGET_STRIKES, SafeModeError, StaleDataError, StaleOracleError, SwapTokenMismatchError, SyncTimeoutError, TOKEN_ID_BITS, TokenIdHasZeroLegsError, TooManyLegsOpenError, TransferFailedError, UNREALIZED_INTEREST_BITS, UTILIZATION_DENOMINATOR, UnauthorizedUniswapCallbackError, UnderOverFlowError, UnhealthyPoolError, UnsafePremiumSettlementError, VARIANCE_RATIO_LAG, WAD, WrongPoolIdError, WrongUniswapPoolError, ZERO_COLLATERAL, ZERO_VALUATION, ZeroAddressError, ZeroCollateralRequirementError, addLegToTokenId, addPendingPosition, addTrackedChunks, annualizePerSecondRateWad, applyMintBuffer, applyMintBufferPerToken, apportion, approve, approveAndWait, approvePool, assertCanBurn, assertCanForceExercise, assertCanLiquidate, assertCanMint, assertFresh, assertHealthy, assertLpPositionFunded, assertTradeable, borrow, borrowAndWait, buildBatchDispatchArgs, buildCreditSwapCall, buildCreditWrappedDispatch, buildOpenPositionCalldata, buildProtectedSettleDispatch, buildProtectedSettlePlan, buildSettleSequenceCalls, buildSfpmSwapCalldata, buildSfpmSwapPlan, buildTemporaryLoanRecoveryDispatch, buildTokenShortfallRecoveryDispatch, buildUniqueCredit, buildUniqueLoan, buildUniqueWidthZeroLeg, calculateAccountGreeksPure, calculateMarketIndicator, calculatePortfolioDelta, calculatePortfolioGamma, calculatePortfolioGreeks, calculatePortfolioValue, calculatePositionDelta, calculatePositionDeltaDebtOnly, calculatePositionDeltaWithSwap, calculatePositionGamma, calculatePositionGreeks, calculatePositionValue, calculatePositionValues, calculatePositionVolatilityMetrics, calculateResyncBlock, calculateSpreadWad, calculateVarianceProfile, cancelTransaction, checkApproval, checkCollateralAcrossTicks, classifyStrategyGroups, classifyStrike, cleanupStalePendingPositions, clearCheckpoint, clearPendingPositions, clearTrackedChunks, clearTrackedPositions, clearTradeHistory, closePosition, closePositionAndWait, collateralCurveTicks, collateralRuleKindFor, collateralTrackerV2Abi, computeV4PoolId, confirmPendingPosition, convertToAssets, convertToShares, countLegs, createEventPoller, createEventSubscription, createFileStorage, createFlowNeutralTokenId, createMemoryStorage, createNonceManager, createPoolFormatters, createTokenIdBuilder, decodeAllDispatchCalldata, decodeAllLegs, decodeDispatchCalldata, decodeLeftRightSigned, decodeLeftRightUnsigned, decodeLeg, decodeOraclePack, decodeOracleRiskParameters, decodeOracleTiming, decodePanopticTokenURI, decodePoolId, decodeTickSpacing, decodeTokenId, decodeVegoid, deployNewPool, deployNewPoolAndWait, deposit, depositAndWait, deriveSupplyRatePerSecWad, deriveUniqueTokenId, detectReorg, diagnoseOracleSafeMode, dispatch, dispatchAndWait, emptyLiquidateParams, encodeLeg, encodePoolId, encodePoolKeyBytes, encodeV3PoolKeyBytes, encodeV4PoolId, ensureSfpmV3PoolInitialized, estimateBlockNumbers, estimateCloseZapSwap, estimateCollateralBreakdown, estimateCollateralRequired, executeBatchDispatch, executeBatchDispatchAndWait, executeSettleSequence, executeSettleSequenceAndWait, failPendingPosition, feeGrowthInsideX128, feesFromFeeGrowthDelta, fetchPoolId, fetchPoolSwaps, fetchSfpmV3PoolId, fetchUniswapFeeData, forceExercise, forceExerciseAndWait, formatBlockNumber, formatBps, formatCompact, formatDatetime, formatDuration, formatDurationSeconds, formatFeeTier, formatGas, formatGwei, formatPerSecondRateWadAsAprPct, formatPerSecondRateWadAsApyPct, formatPoolIdHex, formatPriceRange, formatRateWad, formatRatioPercent, formatTick, formatTickRange, formatTimestamp, formatTimestampLocale, formatTokenAmount, formatTokenAmountSigned, formatTokenDelta, formatTokenFlow, formatTokenIdHex, formatTokenIdShort, formatTxHash, formatUtilization, formatWad, formatWadPercent, formatWadSigned, formatWei, generateOverlappingTokenIds, getAccountBuyingPower, getAccountCollateral, getAccountGreeks, getAccountHistory, getAccountPremia, getAccountSummaryBasic, getAccountSummaryRisk, getAssetIndex, getBlockMeta, getChainDeployment, getChunkLiquidities, getChunkSpreads, getClosePositionTransferEstimate, getClosedPositions, getClosedPositionsKey, getCollateralAddresses, getCollateralCurve, getCollateralCurveInputs, getCollateralData, getCollateralRequiredBase, getCollateralSharePrices, getCollateralTotalAssetsBatch, getCurrentRates, getDeltaHedgeParams, getEnforcedTickLimits, getExecutableLpMaxSize, getFactoryConstructMetadata, getFactoryOwnerOf, getFactoryTokenURI, getForfeitablePremium, getGuardianUnlockState, getHedgeLimits, getInterestState, getIrmCurrent, getIrmCurve, getItmAmounts, getLegDelta, getLegDeltaInVaultFrame, getLegGamma, getLegNetValueWidth0, getLegValue, getLiquidationPrices, getMarginBuffer, getMaxPositionSize, getMaxRedeem, getMaxWithdrawable, getNativeTokenPrice, getNetLiquidationValue, getNetLiquidationValues, getNotEnoughTokensError, getOpenPositionIds, getOpenPositionPreview, getOracleRiskParameters, getOracleState, getPanopticPoolAddress, getPanopticPoolFromPoolId, getPendingPositions, getPendingPositionsKey, getPool, getPoolCurrentTick, getPoolDeploymentBlock, getPoolDisplayId, getPoolLiquidities, getPoolMetaKey, getPoolMetadata, getPoolPrefix, getPortfolioValue, getPosition, getPositionChunkData, getPositionDeltaMetrics, getPositionEnrichmentData, getPositionGreeks, getPositionMetaKey, getPositionMintFunding, getPositionValueCurve, getPositionVolatilityHistory, getPositions, getPositionsKey, getPositionsWithPremia, getPriceHistory, getPricesAtTick, getRealizedPnL, getRequiredCreditForITM, getRiskParameters, getSafeMode, getSchemaVersionKey, getSimpleLoanTokenIndex, getStreamiaHistory, getSyncCheckpointKey, getSyncStatus, getTickSpacing, getTokenIdValidationError, getTokenListId, getTrackedChunks, getTrackedChunksKey, getTrackedPositionIds, getTradeHistory, getUniswapFeeHistory, getUniswapV3LpPositionState, getUniswapV3PoolFromId, getUniswapV3PoolInfo, getUniswapV3PoolLiquidities, getUniswapV4LpPositionState, getUniswapV4PoolBasicState, getUniswapV4PoolInfo, getUniswapV4PoolKeyFromId, getUniswapV4PoolLiquidities, getUtilization, hasLoanOrCredit, hasLongLeg, interpolateBlocks, isCall, isCowSupportedChain, isCredit, isCreditLeg, isDefinedRisk, isGasError, isInputListFailError, isLiquidatable, isLoan, isLoanLeg, isNonceError, isPanopticErrorType, isPositionTracked, isRetryableRpcError, isShortOnly, isSpread, isSupportedChain, isolateGroupTokenId, jsonSerializer, ladderStrikeSequence, liquidate, liquidateAndWait, loadCheckpoint, logReturns, marketPnlInQuote, marketRiskFromValues, marketScenario, minePoolAddress, mint, mintAndWait, mintableAfterBuffer, multicallRead, mutationEffects, netLiquidationValueInQuote, openPosition, openPositionAndWait, optimizeTokenIdRiskPartners, oracleEpochAt, orderListForSettle, packMarketState, panopticLiquidatorAbi, panopticPoolV2Abi, panopticQueryAbi, parseBps, parseCollateralLog, parsePanopticError, parsePoolLog, parseStreamedKey, parseStreamedSwap, parseSwapLog, parseTokenAmount, parseTokenListId, parseWad, planDeriveStrategy, pokeOracle, pokeOracleAndWait, positionValueKey, positionValueTicks, prepareIndicatorCandles, prepareLiquidityGamma, preparePositionGamma, preparePositionValue, preparePositionValueCurve, previewBorrow, previewDeposit, previewMint, previewRedeem, previewRepay, previewUnwrap, previewWithdraw, previewWrap, priceToTick, publicBroadcaster, queryKeys, quoteLiquidation, quoteOneTokenFlow, quoteSfpmSwap, quoteTemporaryLoanRecovery, quoteTokenShortfallRecovery, quoteTokenShortfallSwap, quoteV3ExactIn, ratePerSecWadToAprPct, realizedBeta, reconstructFromEvents, recoverSnapshot, recoverSnapshotFromTx, redeem, redeemAndWait, removeTrackedChunks, repay, repayAndWait, requireChainDeployment, resolveBlockNumbers, resolveLadderStrike, resolvePanopticPoolFromPoolId, resolveTokenIndex, resolveUniswapV4PoolKey, riskEngineAbi, rollPosition, rollPositionAndWait, roundToTickSpacing, saveCheckpoint, saveClosedPosition, scaleCollateralRequired, scanChunks, screenAccountExact, selectDispatchForAccount, settleAccumulatedPremia, settleAccumulatedPremiaAndWait, settlePremiumFrom, settlePremiumFromAndWait, simulateBatchDispatch, simulateClosePosition, simulateClosePremiumProtection, simulateDeployNewPool, simulateDeposit, simulateDispatch, simulateForceExercise, simulateLiquidate, simulateOpenPosition, simulateSFPMBurn, simulateSFPMMint, simulateSettle, simulateSettlePremiumBatch, simulateSettlePremiumFrom, simulateSettleSequence, simulateSwapExactIn, simulateSwapExactOut, simulateWithTokenFlow, simulateWithdraw, slippageBpsToTickDistance, smartRepay, smartRepayAndWait, speedUpTransaction, splitTokenIdByTimescale, sqrtPriceX96ToPriceDecimalScaled, sqrtPriceX96ToTick, streamPoolSwaps, subscribePoolSwaps, supply, supplyAndWait, swapExactIn, swapExactInAndWait, swapExactOut, swapExactOutAndWait, syncPositions, tickLimits, tickToPrice, tickToPriceDecimalScaled, tickToSqrtPriceX96, toVaultFrameAtTick, truncateAddress, unsupply, unsupplyAndWait, unwrapWeth, unwrapWethAndWait, unwrapXstock, unwrapXstockAndWait, useAccountCollateral, useAccountGreeks, useAccountPremia, useAccountSummaryBasic, useAccountSummaryRisk, useAddPendingPosition, useApprove, useApproveErc20ForCow, useApproveErc20ForPermit2, useApprovePool, useApproveRouterViaPermit2, useBatchDispatch as useBatchDispatchHook, useBorrow as useBorrowHook, useCancelCowOrder, useCheckCowApproval, useCheckRouterApproval, useChunkSpreads, useClearTrackedPositions, useClosePosition as useClosePositionHook, useClosedPositions, useCollateralBreakdown, useCollateralData, useConfirmPendingPosition, useCowOrderStatus, useCurrentRates, useDeployNewPool as useDeployNewPoolHook, useDeposit as useDepositHook, useDispatch as useDispatchHook, useEstimateCollateralRequired, useEventPoller, useEventSubscription, useExecuteSettleSequence, useFactoryConstructMetadata, useFactoryOwnerOf, useFactoryTokenURI, useFailPendingPosition, useFlowNeutralTokenId, useForceExercise as useForceExerciseHook, useForfeitablePremium, useGuardianUnlockState, useInterestState, useIsLiquidatable, useLiquidate as useLiquidateHook, useLiquidationPrices, useMarginBuffer, useMaxPositionSize, useMaxRedeem, useMaxWithdrawable, useMinePoolAddress as useMinePoolAddressHook, useMintShares, useNativeTokenPrice, useNetLiquidationValue, useNetLiquidationValues, useOpenPosition as useOpenPositionHook, useOpenPositionPreview, useOptimizeRiskPartners, useOracleState, usePanopticContext, usePanopticPoolAddress, usePokeOracle as usePokeOracleHook, usePool, usePoolLiquidities, usePoolSwaps, usePoolVersion, usePosition, usePositionGreeks, usePositions, usePositionsWithPremia, usePreviewBorrow, usePreviewDeposit, usePreviewMint, usePreviewRedeem, usePreviewWithdraw, usePriceHistory, useQuoteCowSwap, useQuoteSwapExactInViaRouter, useQuoteSwapExactOutViaRouter, useRealizedPnL, useRedeem as useRedeemHook, useRepay as useRepayHook, useResolveUniswapV4PoolKey, useRiskParameters, useRollPosition as useRollPositionHook, useSafeMode, useSettleAccumulatedPremia as useSettleAccumulatedPremiaHook, useSettlePremiumFrom as useSettlePremiumFromHook, useSimulateBatchDispatch, useSimulateClosePosition, useSimulateDeployNewPool, useSimulateDeposit, useSimulateDispatch, useSimulateForceExercise, useSimulateLiquidate, useSimulateOpenPosition, useSimulateSFPMBurn, useSimulateSFPMMint, useSimulateSettle, useSimulateSettlePremiumBatch, useSimulateSettlePremiumFrom, useSimulateSettleSequence, useSimulateSwapExactIn, useSimulateSwapExactOut, useSimulateWithdraw, useSmartRepay as useSmartRepayHook, useStreamiaHistory, useSubmitCowOrder, useSupply as useSupplyHook, useSwapExactIn, useSwapExactInViaRouter, useSwapExactOut, useSwapExactOutViaRouter, useSyncPositions, useSyncStatus, useTrackedPositionIds, useTradeHistory, useTxEventConfirmation, useUniswapFeeHistory, useUniswapV3PoolInfo, useUniswapV3PoolLiquidities, useUniswapV4PoolBasicState, useUniswapV4PoolInfo, useUniswapV4PoolLiquidities, useUnsupply as useUnsupplyHook, useUnwrapWeth, useUnwrapXstock, useUtilization, useValidateBuilderCode, useWatchEvents, useWithdraw as useWithdrawHook, useWithdrawWithPositions as useWithdrawWithPositionsHook, useWrapEth, useWrapXstock, utilizationBpsToWad, utilizationPctToWad, validateBatch, validateBuilderCode, validatePoolId, valuePositionAccrual, verifyBlockContinuity, watchEvents, watchPoolSwaps, wethWrapAbi, withdraw, withdrawAndWait, withdrawWithPositions, withdrawWithPositionsAndWait, wrapEth, wrapEthAndWait, wrapXstock, wrapXstockAndWait, xstockWrapperAbi };
38990
40500
  //# sourceMappingURL=react-public.js.map