@panoptic-eng/sdk 1.0.30 → 1.0.31

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (32) hide show
  1. package/dist/cow/index.js +3 -3
  2. package/dist/{cow-CSt61vNU.js → cow-CLFJQ-OP.js} +2 -2
  3. package/dist/{cow-CSt61vNU.js.map → cow-CLFJQ-OP.js.map} +1 -1
  4. package/dist/index-DQS8Luef.d.ts.map +1 -1
  5. package/dist/{index-B3JZRUNo.d.ts → index-DVtqKAH3.d.ts} +207 -13
  6. package/dist/index-DVtqKAH3.d.ts.map +1 -0
  7. package/dist/index.js +2 -2
  8. package/dist/{irm-IcePQm1r.js → irm-iAI9hTYQ.js} +3 -3
  9. package/dist/{irm-IcePQm1r.js.map → irm-iAI9hTYQ.js.map} +1 -1
  10. package/dist/{oracle-BnpPVG8V.d.ts → oracle-DaNTHk7B.d.ts} +14 -1
  11. package/dist/{oracle-BnpPVG8V.d.ts.map → oracle-DaNTHk7B.d.ts.map} +1 -1
  12. package/dist/panoptic/v2/index.d.ts +3 -3
  13. package/dist/panoptic/v2/index.js +5 -5
  14. package/dist/panoptic/v2/react-public.d.ts +4 -4
  15. package/dist/panoptic/v2/react-public.js +7 -7
  16. package/dist/{position-UL1gOvqZ.js → position-ClU7GrTa.js} +44 -12
  17. package/dist/position-ClU7GrTa.js.map +1 -0
  18. package/dist/{router-Del9H6e0.js → router-DKFR_vnu.js} +2 -2
  19. package/dist/{router-Del9H6e0.js.map → router-DKFR_vnu.js.map} +1 -1
  20. package/dist/{types-VeWdNN0j.d.ts → types-Cy6v8iPf.d.ts} +2 -2
  21. package/dist/{types-VeWdNN0j.d.ts.map → types-Cy6v8iPf.d.ts.map} +1 -1
  22. package/dist/uniswap/index.d.ts +2 -2
  23. package/dist/uniswap/index.js +3 -3
  24. package/dist/{v2-BSV35bpu.js → v2-D3B5BKml.js} +436 -167
  25. package/dist/v2-D3B5BKml.js.map +1 -0
  26. package/dist/{writes-RyS0kHpB.js → writes-DQLGdkJ5.js} +50 -26
  27. package/dist/writes-DQLGdkJ5.js.map +1 -0
  28. package/package.json +1 -1
  29. package/dist/index-B3JZRUNo.d.ts.map +0 -1
  30. package/dist/position-UL1gOvqZ.js.map +0 -1
  31. package/dist/v2-BSV35bpu.js.map +0 -1
  32. package/dist/writes-RyS0kHpB.js.map +0 -1
@@ -1,7 +1,7 @@
1
- import { formatTokenAmount$1 as formatTokenAmount, getAccountCollateral$1 as getAccountCollateral, panopticQueryAbi$1 as panopticQueryAbi, parseTokenAmount$1 as parseTokenAmount, readBlockAndAggregate, requireReturnData } from "./irm-IcePQm1r.js";
2
- import { AccountInsolventError$1 as AccountInsolventError, ChunkLimitError$1 as ChunkLimitError, DEFAULT_VEGOID$1 as DEFAULT_VEGOID, InvalidHistoryRangeError$1 as InvalidHistoryRangeError, NotEnoughTokensError$1 as NotEnoughTokensError, PanopticError, PanopticValidationError$1 as PanopticValidationError, StorageDataNotFoundError, SwapTokenMismatchError$1 as SwapTokenMismatchError, collateralTrackerV2Abi, decodeLeftRightSigned$1 as decodeLeftRightSigned, decodeLeftRightUnsigned$1 as decodeLeftRightUnsigned, decodePosition, decodePositionBalance, decodeTickSpacing$1 as decodeTickSpacing, getBlockMeta$1 as getBlockMeta, getPool, panopticFactoryV3Abi, panopticFactoryV4Abi, panopticGuardianAbi, panopticPoolV2Abi, panopticQueryAbi as panopticQueryAbi$1, parsePanopticError$1 as parsePanopticError, riskEngineAbi, semiFungiblePositionManagerV3Abi, semiFungiblePositionManagerV4Abi, stateViewAbi, uniswapV3PoolAbi } from "./position-UL1gOvqZ.js";
1
+ import { formatTokenAmount$1 as formatTokenAmount, getAccountCollateral$1 as getAccountCollateral, panopticQueryAbi, parseTokenAmount$1 as parseTokenAmount, readBlockAndAggregate, requireReturnData } from "./irm-iAI9hTYQ.js";
2
+ import { AccountInsolventError$1 as AccountInsolventError, ChunkLimitError$1 as ChunkLimitError, DEFAULT_VEGOID$1 as DEFAULT_VEGOID, InvalidHistoryRangeError$1 as InvalidHistoryRangeError, NotEnoughTokensError$1 as NotEnoughTokensError, PanopticError, PanopticValidationError$1 as PanopticValidationError, StorageDataNotFoundError, collateralTrackerV2Abi, decodeLeftRightSigned$1 as decodeLeftRightSigned, decodeLeftRightUnsigned$1 as decodeLeftRightUnsigned, decodePosition, decodePositionBalance, decodeTickSpacing$1 as decodeTickSpacing, getBlockMeta$1 as getBlockMeta, getPool, panopticFactoryV3Abi, panopticFactoryV4Abi, panopticGuardianAbi, panopticPoolV2Abi, panopticQueryAbi$1, parsePanopticError$1 as parsePanopticError, riskEngineAbi, semiFungiblePositionManagerV3Abi, semiFungiblePositionManagerV4Abi, stateViewAbi, uniswapV3PoolAbi } from "./position-ClU7GrTa.js";
3
3
  import { MAX_TICK, MAX_TRACKED_CHUNKS, MIN_TICK, WAD, calculatePositionDelta, calculatePositionGamma, calculatePositionValue, priceToTick, sqrtPriceX96ToTick, tickLimits, tickToPrice, tickToPriceDecimalScaled, tickToSqrtPriceX96 } from "./greeks-GysWXct-.js";
4
- import { addLegToTokenId$1 as addLegToTokenId, buildBatchDispatchArgs$1 as buildBatchDispatchArgs, countLegs$1 as countLegs, createTokenIdBuilder$1 as createTokenIdBuilder, decodeAllLegs$1 as decodeAllLegs, decodeTokenId$1 as decodeTokenId, getClosedPositionsKey$1 as getClosedPositionsKey, getPendingPositionsKey$1 as getPendingPositionsKey, getPoolMetaKey$1 as getPoolMetaKey, getPositionMetaKey$1 as getPositionMetaKey, getPositionsKey$1 as getPositionsKey, getTrackedChunksKey$1 as getTrackedChunksKey, getTrackedPositionIds$1 as getTrackedPositionIds, jsonSerializer$1 as jsonSerializer, loadCheckpoint$1 as loadCheckpoint, simulateOpenPosition$1 as simulateOpenPosition, simulateWithTokenFlow } from "./writes-RyS0kHpB.js";
4
+ import { addLegToTokenId$1 as addLegToTokenId, buildBatchDispatchArgs$1 as buildBatchDispatchArgs, buildUniqueCredit$1 as buildUniqueCredit, countLegs$1 as countLegs, decodeAllLegs$1 as decodeAllLegs, decodeTokenId$1 as decodeTokenId, getClosedPositionsKey$1 as getClosedPositionsKey, getPendingPositionsKey$1 as getPendingPositionsKey, getPoolMetaKey$1 as getPoolMetaKey, getPositionMetaKey$1 as getPositionMetaKey, getPositionsKey$1 as getPositionsKey, getTrackedChunksKey$1 as getTrackedChunksKey, getTrackedPositionIds$1 as getTrackedPositionIds, jsonSerializer$1 as jsonSerializer, loadCheckpoint$1 as loadCheckpoint, resolveTokenIndex$1 as resolveTokenIndex, simulateOpenPosition$1 as simulateOpenPosition, simulateWithTokenFlow } from "./writes-DQLGdkJ5.js";
5
5
  import { ContractFunctionExecutionError, decodeFunctionResult, encodeAbiParameters, encodeFunctionData, getAddress, keccak256, zeroAddress } from "viem";
6
6
  import { multicall } from "viem/actions";
7
7
 
@@ -2849,6 +2849,17 @@ const MIN_TICK$1 = -887272n;
2849
2849
  const MAX_TICK$1 = 887272n;
2850
2850
  const FP96 = 1n << 96n;
2851
2851
  const Q128$1 = 1n << 128n;
2852
+ /** Cap for a usage ratio with no collateral behind it. */
2853
+ const MAX_USAGE_BPS = 1000000n;
2854
+ const bigintMax = (a, b) => a > b ? a : b;
2855
+ const bigintMin = (a, b) => a < b ? a : b;
2856
+ /**
2857
+ * `RiskEngine.BP_DECREASE_BUFFER` over `PanopticPool.NO_BUFFER` — the extra
2858
+ * margin the solvency check demands at mint (and on collateral withdrawal),
2859
+ * above the maintenance requirement that governs liquidation.
2860
+ */
2861
+ const MINT_BUFFER = 10666667n;
2862
+ const MINT_BUFFER_DENOMINATOR = 10000000n;
2852
2863
  /**
2853
2864
  * Convert a token0 amount to its token1-equivalent at the given sqrtPriceX96.
2854
2865
  *
@@ -2960,6 +2971,19 @@ async function getMarginBuffer(params) {
2960
2971
  ]
2961
2972
  })
2962
2973
  });
2974
+ const checkCollateralIndex = hasPositions ? calls.length : null;
2975
+ if (checkCollateralIndex !== null) calls.push({
2976
+ target: queryAddress,
2977
+ callData: encodeFunctionData({
2978
+ abi: panopticQueryAbi,
2979
+ functionName: "checkCollateral",
2980
+ args: [
2981
+ poolAddress,
2982
+ account,
2983
+ tokenIds
2984
+ ]
2985
+ })
2986
+ });
2963
2987
  const { _meta, results } = await readBlockAndAggregate({
2964
2988
  client,
2965
2989
  calls,
@@ -2991,6 +3015,34 @@ async function getMarginBuffer(params) {
2991
3015
  functionName: "getLiquidationPrices",
2992
3016
  data: requireReturnData(results, liqPricesIndex, "PanopticQuery.getLiquidationPrices")
2993
3017
  });
3018
+ const checkCollateralResult = checkCollateralIndex === null ? null : decodeFunctionResult({
3019
+ abi: panopticQueryAbi,
3020
+ functionName: "checkCollateral",
3021
+ data: requireReturnData(results, checkCollateralIndex, "PanopticQuery.checkCollateral")
3022
+ });
3023
+ let usageBps0 = null;
3024
+ let usageBps1 = null;
3025
+ let crossMarginUsageBps = null;
3026
+ let mintableMarginBinding = null;
3027
+ if (checkCollateralResult) {
3028
+ const [balances0, requireds0, balances1, requireds1] = checkCollateralResult;
3029
+ const ratio = (required, balance) => {
3030
+ if (required === void 0 || balance === void 0) return null;
3031
+ if (balance === 0n) return required > 0n ? MAX_USAGE_BPS : 0n;
3032
+ return required * 10000n / balance;
3033
+ };
3034
+ usageBps0 = ratio(requireds0[0], balances0[0]);
3035
+ usageBps1 = ratio(requireds1[0], balances1[0]);
3036
+ if (usageBps0 !== null || usageBps1 !== null) crossMarginUsageBps = usageBps0 === null ? usageBps1 : usageBps1 === null ? usageBps0 : bigintMax(usageBps0, usageBps1);
3037
+ const mintable = (balance, required) => {
3038
+ if (balance === void 0 || required === void 0) return null;
3039
+ const requiredAtMint = (required * MINT_BUFFER + MINT_BUFFER_DENOMINATOR - 1n) / MINT_BUFFER_DENOMINATOR;
3040
+ return balance > requiredAtMint ? balance - requiredAtMint : 0n;
3041
+ };
3042
+ const mintable0 = mintable(balances0[0], requireds0[0]);
3043
+ const mintable1 = mintable(balances1[0], requireds1[0]);
3044
+ if (mintable0 !== null || mintable1 !== null) mintableMarginBinding = mintable0 === null ? mintable1 : mintable1 === null ? mintable0 : bigintMin(mintable0, mintable1);
3045
+ }
2994
3046
  let required0Native = 0n;
2995
3047
  let required1Native = 0n;
2996
3048
  if (positionDataResult) {
@@ -3039,6 +3091,10 @@ async function getMarginBuffer(params) {
3039
3091
  liquidationDistance,
3040
3092
  lowerLiquidationTick,
3041
3093
  upperLiquidationTick,
3094
+ crossMarginUsageBps,
3095
+ usageBps0,
3096
+ usageBps1,
3097
+ mintableMarginBinding,
3042
3098
  currentTick,
3043
3099
  _meta
3044
3100
  };
@@ -3419,6 +3475,365 @@ async function getAccountBuyingPower(params) {
3419
3475
  };
3420
3476
  }
3421
3477
 
3478
+ //#endregion
3479
+ //#region src/panoptic/v2/simulations/simulateDispatch.ts
3480
+ /**
3481
+ * Simulate a raw dispatch operation.
3482
+ *
3483
+ * Uses PanopticPool.multicall with getAssetsOf-dispatch-getAssetsOf pattern
3484
+ * to measure exact collateral asset movements.
3485
+ *
3486
+ * @param params - Simulation parameters
3487
+ * @returns Simulation result with dispatch data or error
3488
+ */
3489
+ async function simulateDispatch(params) {
3490
+ const { client, poolAddress, account, positionIdList, finalPositionIdList, positionSizes, tickAndSpreadLimits, usePremiaAsCollateral = false, builderCode = 0n, blockNumber, existingPositionIdList } = params;
3491
+ const targetBlockNumber = blockNumber ?? await client.getBlockNumber();
3492
+ const metaPromise = getBlockMeta({
3493
+ client,
3494
+ blockNumber: targetBlockNumber
3495
+ });
3496
+ try {
3497
+ const callData = encodeFunctionData({
3498
+ abi: panopticPoolV2Abi,
3499
+ functionName: "dispatch",
3500
+ args: [
3501
+ positionIdList,
3502
+ finalPositionIdList,
3503
+ positionSizes,
3504
+ tickAndSpreadLimits.map((t) => [
3505
+ Number(t[0]),
3506
+ Number(t[1]),
3507
+ Number(t[2])
3508
+ ]),
3509
+ usePremiaAsCollateral,
3510
+ builderCode
3511
+ ]
3512
+ });
3513
+ const preFullPositionsCallData = existingPositionIdList !== void 0 ? encodeFunctionData({
3514
+ abi: panopticPoolV2Abi,
3515
+ functionName: "getFullPositionsData",
3516
+ args: [
3517
+ account,
3518
+ false,
3519
+ existingPositionIdList
3520
+ ]
3521
+ }) : void 0;
3522
+ const postFullPositionsCallData = encodeFunctionData({
3523
+ abi: panopticPoolV2Abi,
3524
+ functionName: "getFullPositionsData",
3525
+ args: [
3526
+ account,
3527
+ false,
3528
+ finalPositionIdList
3529
+ ]
3530
+ });
3531
+ const flowResult = await simulateWithTokenFlow({
3532
+ client,
3533
+ poolAddress,
3534
+ user: account,
3535
+ callData,
3536
+ blockNumber: targetBlockNumber,
3537
+ preCallData: preFullPositionsCallData ? [preFullPositionsCallData] : void 0,
3538
+ postCallData: [postFullPositionsCallData]
3539
+ });
3540
+ if (!flowResult.success || !flowResult.tokenFlow) throw flowResult.rawError ?? new PanopticError(flowResult.error || "Token flow simulation failed");
3541
+ const tokenFlow = flowResult.tokenFlow;
3542
+ const preSnapshot = existingPositionIdList ?? [];
3543
+ const positionsCreated = finalPositionIdList.filter((id) => !preSnapshot.includes(id));
3544
+ const positionsClosed = preSnapshot.filter((id) => !finalPositionIdList.includes(id));
3545
+ const sumCollateralReq = (data$1) => {
3546
+ if (!data$1) return null;
3547
+ try {
3548
+ const decoded = decodeFunctionResult({
3549
+ abi: panopticPoolV2Abi,
3550
+ functionName: "getFullPositionsData",
3551
+ data: data$1
3552
+ });
3553
+ const reqs = decoded[3];
3554
+ let token0 = 0n;
3555
+ let token1 = 0n;
3556
+ for (const packed of reqs) {
3557
+ const r = decodeLeftRightUnsigned(packed);
3558
+ token0 += r.right;
3559
+ token1 += r.left;
3560
+ }
3561
+ return {
3562
+ token0,
3563
+ token1
3564
+ };
3565
+ } catch {
3566
+ return null;
3567
+ }
3568
+ };
3569
+ const preReq = sumCollateralReq(flowResult.preCallResults?.[0]);
3570
+ const postReq = sumCollateralReq(flowResult.postCallResults?.[0]);
3571
+ const _meta = await metaPromise;
3572
+ const data = {
3573
+ netAmount0: tokenFlow.delta0,
3574
+ netAmount1: tokenFlow.delta1,
3575
+ positionsCreated,
3576
+ positionsClosed,
3577
+ postCollateral0: tokenFlow.balanceAfter0,
3578
+ postCollateral1: tokenFlow.balanceAfter1,
3579
+ preMarginExcess0: preReq ? tokenFlow.balanceBefore0 - preReq.token0 : null,
3580
+ preMarginExcess1: preReq ? tokenFlow.balanceBefore1 - preReq.token1 : null,
3581
+ postMarginExcess0: postReq ? tokenFlow.balanceAfter0 - postReq.token0 : null,
3582
+ postMarginExcess1: postReq ? tokenFlow.balanceAfter1 - postReq.token1 : null
3583
+ };
3584
+ return {
3585
+ success: true,
3586
+ data,
3587
+ gasEstimate: flowResult.gasEstimate,
3588
+ tokenFlow,
3589
+ _meta
3590
+ };
3591
+ } catch (error) {
3592
+ const _meta = await metaPromise;
3593
+ return {
3594
+ success: false,
3595
+ error: error instanceof PanopticError ? error : new PanopticError(error instanceof Error ? error.message : "Simulation failed", error instanceof Error ? error : void 0),
3596
+ _meta
3597
+ };
3598
+ }
3599
+ }
3600
+
3601
+ //#endregion
3602
+ //#region src/panoptic/v2/simulations/tokenShortfallRecovery.ts
3603
+ const BPS_DENOMINATOR = 10000n;
3604
+ const MAX_RECOVERY_QUOTE_ATTEMPTS = 8;
3605
+ /**
3606
+ * Wrap a dispatch with a temporary credit leg that sources the shortfall.
3607
+ *
3608
+ * Exact-output construction: mint the credit with `swapAtMint=true` (paying a
3609
+ * swapped amount of the token the account has), run the user's operations, then
3610
+ * burn it with `swapAtMint=false` to receive exactly the missing token.
3611
+ *
3612
+ * A credit rather than a loan so the recovery is never capped by the shortfall
3613
+ * token's utilization — the case that fails today on a >94% utilized tracker.
3614
+ */
3615
+ function buildTokenShortfallRecoveryDispatch(params) {
3616
+ const { dispatch, creditTokenId, creditPositionSize, tickLimitLow, tickLimitHigh } = params;
3617
+ const low = tickLimitLow <= tickLimitHigh ? tickLimitLow : tickLimitHigh;
3618
+ const high = tickLimitLow <= tickLimitHigh ? tickLimitHigh : tickLimitLow;
3619
+ const mintLimits = [
3620
+ high,
3621
+ low,
3622
+ 0n
3623
+ ];
3624
+ const burnLimits = [
3625
+ low,
3626
+ high,
3627
+ 0n
3628
+ ];
3629
+ return {
3630
+ positionIdList: [
3631
+ creditTokenId,
3632
+ ...dispatch.positionIdList,
3633
+ creditTokenId
3634
+ ],
3635
+ finalPositionIdList: [...dispatch.finalPositionIdList],
3636
+ positionSizes: [
3637
+ creditPositionSize,
3638
+ ...dispatch.positionSizes,
3639
+ 0n
3640
+ ],
3641
+ tickAndSpreadLimits: [
3642
+ mintLimits,
3643
+ ...dispatch.tickAndSpreadLimits,
3644
+ burnLimits
3645
+ ],
3646
+ usePremiaAsCollateral: dispatch.usePremiaAsCollateral,
3647
+ builderCode: dispatch.builderCode
3648
+ };
3649
+ }
3650
+ /**
3651
+ * Extract a fully-decoded `NotEnoughTokens` revert from an arbitrary error.
3652
+ *
3653
+ * Returns `null` when the error is something else, or when only the 4-byte
3654
+ * selector could be matched (the parser's fallback path constructs the error
3655
+ * with undefined args, which is not actionable).
3656
+ */
3657
+ function getNotEnoughTokensError(error) {
3658
+ let candidate = null;
3659
+ if (error instanceof NotEnoughTokensError) candidate = error;
3660
+ else {
3661
+ const parsed = parsePanopticError(error);
3662
+ if (parsed?.error instanceof NotEnoughTokensError) candidate = parsed.error;
3663
+ }
3664
+ if (candidate === null) return null;
3665
+ const args = candidate;
3666
+ if (args.tokenAddress === void 0 || args.assetsRequested === void 0 || args.assetBalance === void 0) return null;
3667
+ return candidate;
3668
+ }
3669
+ function maximumAmountIn(estimatedAmountIn, slippageBps) {
3670
+ if (slippageBps < 0n) throw new PanopticError("slippageBps must be non-negative");
3671
+ return (estimatedAmountIn * (BPS_DENOMINATOR + slippageBps) + BPS_DENOMINATOR - 1n) / BPS_DENOMINATOR;
3672
+ }
3673
+ function getInputAmount(tokenFlow, tokenInIndex) {
3674
+ const delta = tokenInIndex === 0n ? tokenFlow.delta0 : tokenFlow.delta1;
3675
+ return delta < 0n ? -delta : delta;
3676
+ }
3677
+ function getBalanceBefore(tokenFlow, tokenIndex) {
3678
+ return tokenIndex === 0n ? tokenFlow.balanceBefore0 : tokenFlow.balanceBefore1;
3679
+ }
3680
+ function getOutputAmount(tokenFlow, tokenOutIndex) {
3681
+ const delta = tokenOutIndex === 0n ? tokenFlow.delta0 : tokenFlow.delta1;
3682
+ return delta > 0n ? delta : 0n;
3683
+ }
3684
+ async function quoteTokenShortfallRecovery(params) {
3685
+ const shortfallError = getNotEnoughTokensError(params.error);
3686
+ if (shortfallError === null) return {
3687
+ available: false,
3688
+ reason: "not-token-shortfall"
3689
+ };
3690
+ let amountOut = shortfallError.assetsRequested - shortfallError.assetBalance;
3691
+ if (amountOut <= 0n) return {
3692
+ available: false,
3693
+ reason: "invalid-shortfall",
3694
+ detail: `requested=${shortfallError.assetsRequested} <= balance=${shortfallError.assetBalance}`
3695
+ };
3696
+ if (params.slippageBps < 0n || params.slippageBps > BPS_DENOMINATOR) return {
3697
+ available: false,
3698
+ reason: "invalid-slippage",
3699
+ detail: `slippageBps=${params.slippageBps} is outside [0, ${BPS_DENOMINATOR}]`
3700
+ };
3701
+ const tickLimitLow = params.tickLimitLow ?? MIN_TICK;
3702
+ const tickLimitHigh = params.tickLimitHigh ?? MAX_TICK;
3703
+ if (tickLimitLow >= tickLimitHigh) return {
3704
+ available: false,
3705
+ reason: "invalid-tick-limits",
3706
+ detail: `tickLimitLow=${tickLimitLow} >= tickLimitHigh=${tickLimitHigh}`
3707
+ };
3708
+ const targetBlockNumber = params.blockNumber ?? await params.client.getBlockNumber();
3709
+ const pool = await getPool({
3710
+ client: params.client,
3711
+ poolAddress: params.poolAddress,
3712
+ chainId: params.chainId,
3713
+ blockNumber: targetBlockNumber
3714
+ });
3715
+ const token0 = pool.collateralTracker0.token;
3716
+ const token1 = pool.collateralTracker1.token;
3717
+ const normalizedShortfallToken = shortfallError.tokenAddress.toLowerCase();
3718
+ const isToken0Shortfall = normalizedShortfallToken === token0.toLowerCase() || normalizedShortfallToken === pool.collateralTracker0.address.toLowerCase();
3719
+ const isToken1Shortfall = normalizedShortfallToken === token1.toLowerCase() || normalizedShortfallToken === pool.collateralTracker1.address.toLowerCase();
3720
+ const tokenOutIndex = isToken0Shortfall ? 0n : isToken1Shortfall ? 1n : null;
3721
+ if (tokenOutIndex === null) return {
3722
+ available: false,
3723
+ reason: "unsupported-token",
3724
+ detail: `${shortfallError.tokenAddress} is neither collateral token of ${params.poolAddress}`
3725
+ };
3726
+ const tokenInIndex = tokenOutIndex === 0n ? 1n : 0n;
3727
+ const tokenOut = tokenOutIndex === 0n ? token0 : token1;
3728
+ const tokenIn = tokenInIndex === 0n ? token0 : token1;
3729
+ const collisionIds = Array.from(new Set([
3730
+ ...params.existingPositionIds,
3731
+ ...params.dispatch.positionIdList,
3732
+ ...params.dispatch.finalPositionIdList
3733
+ ]));
3734
+ for (let attempt = 0; attempt < MAX_RECOVERY_QUOTE_ATTEMPTS; attempt++) {
3735
+ const credit = buildUniqueCredit(pool.poolId, tokenOutIndex, tokenOutIndex, pool.currentTick, pool.tickSpacing, collisionIds, amountOut);
3736
+ const recoveredDispatch = buildTokenShortfallRecoveryDispatch({
3737
+ dispatch: params.dispatch,
3738
+ creditTokenId: credit.tokenId,
3739
+ creditPositionSize: credit.adjustedSize,
3740
+ tickLimitLow,
3741
+ tickLimitHigh
3742
+ });
3743
+ const swapDispatch = buildTokenShortfallRecoveryDispatch({
3744
+ dispatch: {
3745
+ positionIdList: [],
3746
+ finalPositionIdList: [...params.existingPositionIds],
3747
+ positionSizes: [],
3748
+ tickAndSpreadLimits: [],
3749
+ usePremiaAsCollateral: false,
3750
+ builderCode: 0n
3751
+ },
3752
+ creditTokenId: credit.tokenId,
3753
+ creditPositionSize: credit.adjustedSize,
3754
+ tickLimitLow,
3755
+ tickLimitHigh
3756
+ });
3757
+ const swapSimulation = await simulateDispatch({
3758
+ client: params.client,
3759
+ poolAddress: params.poolAddress,
3760
+ account: params.account,
3761
+ existingPositionIdList: params.existingPositionIds,
3762
+ ...swapDispatch,
3763
+ blockNumber: targetBlockNumber
3764
+ });
3765
+ if (!swapSimulation.success || swapSimulation.tokenFlow === void 0) return {
3766
+ available: false,
3767
+ reason: "swap-unavailable",
3768
+ detail: swapSimulation.success ? "swap-only simulation returned no token flow" : `swap-only simulation reverted: ${swapSimulation.error.message}`,
3769
+ error: swapSimulation.success ? void 0 : swapSimulation.error
3770
+ };
3771
+ const estimatedAmountIn = getInputAmount(swapSimulation.tokenFlow, tokenInIndex);
3772
+ const maxAmountIn = maximumAmountIn(estimatedAmountIn, params.slippageBps);
3773
+ const swapOutput = getOutputAmount(swapSimulation.tokenFlow, tokenOutIndex);
3774
+ const sourceBalance = getBalanceBefore(swapSimulation.tokenFlow, tokenInIndex);
3775
+ if (swapOutput < amountOut || sourceBalance < maxAmountIn) return {
3776
+ available: false,
3777
+ reason: "swap-unavailable",
3778
+ detail: swapOutput < amountOut ? `swap output ${swapOutput} < required ${amountOut}` : `source balance ${sourceBalance} < maximumAmountIn ${maxAmountIn} (estimated ${estimatedAmountIn}, slippageBps ${params.slippageBps})`,
3779
+ error: new PanopticError("Insufficient source collateral for the recovery swap")
3780
+ };
3781
+ const recoverySimulation = await simulateDispatch({
3782
+ client: params.client,
3783
+ poolAddress: params.poolAddress,
3784
+ account: params.account,
3785
+ existingPositionIdList: params.existingPositionIds,
3786
+ ...recoveredDispatch,
3787
+ blockNumber: targetBlockNumber
3788
+ });
3789
+ if (recoverySimulation.success) {
3790
+ if (recoverySimulation.tokenFlow !== void 0) return {
3791
+ available: true,
3792
+ quote: {
3793
+ tokenIn,
3794
+ tokenOut,
3795
+ amountOut,
3796
+ estimatedAmountIn,
3797
+ maximumAmountIn: maxAmountIn,
3798
+ slippageBps: params.slippageBps,
3799
+ netTokenInChange: tokenInIndex === 0n ? recoverySimulation.tokenFlow.delta0 : recoverySimulation.tokenFlow.delta1,
3800
+ netTokenOutChange: tokenOutIndex === 0n ? recoverySimulation.tokenFlow.delta0 : recoverySimulation.tokenFlow.delta1,
3801
+ creditTokenId: credit.tokenId,
3802
+ dispatch: recoveredDispatch,
3803
+ simulation: {
3804
+ ...recoverySimulation,
3805
+ tokenFlow: recoverySimulation.tokenFlow
3806
+ },
3807
+ tokenFlow: recoverySimulation.tokenFlow,
3808
+ _meta: recoverySimulation._meta
3809
+ }
3810
+ };
3811
+ return {
3812
+ available: false,
3813
+ reason: "recovery-unavailable",
3814
+ detail: "wrapped dispatch simulation returned no token flow",
3815
+ error: new PanopticError("Recovery simulation did not return token flow")
3816
+ };
3817
+ }
3818
+ const remainingShortfall = getNotEnoughTokensError(recoverySimulation.error);
3819
+ if (remainingShortfall === null || remainingShortfall.tokenAddress.toLowerCase() !== normalizedShortfallToken) return {
3820
+ available: false,
3821
+ reason: "recovery-unavailable",
3822
+ detail: `wrapped dispatch reverted with a non-shortfall error: ${recoverySimulation.error.message}`,
3823
+ error: recoverySimulation.error
3824
+ };
3825
+ const decodedShortfall = remainingShortfall.assetsRequested - remainingShortfall.assetBalance;
3826
+ const additionalAmountOut = decodedShortfall > 0n ? decodedShortfall : amountOut;
3827
+ amountOut += additionalAmountOut;
3828
+ }
3829
+ return {
3830
+ available: false,
3831
+ reason: "recovery-unavailable",
3832
+ detail: `still short after ${MAX_RECOVERY_QUOTE_ATTEMPTS} sizing attempts (last target ${amountOut})`,
3833
+ error: new PanopticError("Could not cover recovery swap costs within the quote attempt limit")
3834
+ };
3835
+ }
3836
+
3422
3837
  //#endregion
3423
3838
  //#region src/panoptic/v2/reads/openPositionPreview.ts
3424
3839
  /**
@@ -3456,16 +3871,19 @@ async function getOpenPositionPreview(params) {
3456
3871
  blockNumber
3457
3872
  })]);
3458
3873
  let isSolvent = true;
3874
+ let tokenShortfall = null;
3459
3875
  if (!simulation.success) {
3460
3876
  const parsed = parsePanopticError(simulation.error);
3461
3877
  const err = parsed?.error ?? simulation.error;
3462
- isSolvent = !(err instanceof AccountInsolventError || err instanceof NotEnoughTokensError);
3878
+ isSolvent = !(err instanceof AccountInsolventError);
3879
+ tokenShortfall = getNotEnoughTokensError(err);
3463
3880
  }
3464
3881
  const data = simulation.success ? simulation.data : null;
3465
3882
  return {
3466
3883
  currentBuyingPower,
3467
3884
  simulation,
3468
3885
  isSolvent,
3886
+ tokenShortfall,
3469
3887
  amount0Required: data?.amount0Required ?? null,
3470
3888
  amount1Required: data?.amount1Required ?? null,
3471
3889
  postCollateral0: data?.postCollateral0 ?? null,
@@ -4102,6 +4520,7 @@ async function getUniswapV4PoolBasicState(params) {
4102
4520
  poolId,
4103
4521
  sqrtPriceX96: slot0[0],
4104
4522
  currentTick: Number(slot0[1]),
4523
+ protocolFee: BigInt(slot0[2]),
4105
4524
  lpFee: Number(slot0[3]),
4106
4525
  liquidity,
4107
4526
  _meta
@@ -4187,6 +4606,7 @@ async function getUniswapV4PoolInfo(params) {
4187
4606
  hooks: poolKey.hooks,
4188
4607
  currentTick: Number(slot0[1]),
4189
4608
  sqrtPriceX96: slot0[0],
4609
+ protocolFee: BigInt(slot0[2]),
4190
4610
  liquidity,
4191
4611
  _meta
4192
4612
  };
@@ -5214,129 +5634,6 @@ async function getPoolDeploymentBlock(client, poolAddress) {
5214
5634
  return foundBlock;
5215
5635
  }
5216
5636
 
5217
- //#endregion
5218
- //#region src/panoptic/v2/simulations/simulateDispatch.ts
5219
- /**
5220
- * Simulate a raw dispatch operation.
5221
- *
5222
- * Uses PanopticPool.multicall with getAssetsOf-dispatch-getAssetsOf pattern
5223
- * to measure exact collateral asset movements.
5224
- *
5225
- * @param params - Simulation parameters
5226
- * @returns Simulation result with dispatch data or error
5227
- */
5228
- async function simulateDispatch(params) {
5229
- const { client, poolAddress, account, positionIdList, finalPositionIdList, positionSizes, tickAndSpreadLimits, usePremiaAsCollateral = false, builderCode = 0n, blockNumber, existingPositionIdList } = params;
5230
- const targetBlockNumber = blockNumber ?? await client.getBlockNumber();
5231
- const metaPromise = getBlockMeta({
5232
- client,
5233
- blockNumber: targetBlockNumber
5234
- });
5235
- try {
5236
- const callData = encodeFunctionData({
5237
- abi: panopticPoolV2Abi,
5238
- functionName: "dispatch",
5239
- args: [
5240
- positionIdList,
5241
- finalPositionIdList,
5242
- positionSizes,
5243
- tickAndSpreadLimits.map((t) => [
5244
- Number(t[0]),
5245
- Number(t[1]),
5246
- Number(t[2])
5247
- ]),
5248
- usePremiaAsCollateral,
5249
- builderCode
5250
- ]
5251
- });
5252
- const preFullPositionsCallData = existingPositionIdList !== void 0 ? encodeFunctionData({
5253
- abi: panopticPoolV2Abi,
5254
- functionName: "getFullPositionsData",
5255
- args: [
5256
- account,
5257
- false,
5258
- existingPositionIdList
5259
- ]
5260
- }) : void 0;
5261
- const postFullPositionsCallData = encodeFunctionData({
5262
- abi: panopticPoolV2Abi,
5263
- functionName: "getFullPositionsData",
5264
- args: [
5265
- account,
5266
- false,
5267
- finalPositionIdList
5268
- ]
5269
- });
5270
- const flowResult = await simulateWithTokenFlow({
5271
- client,
5272
- poolAddress,
5273
- user: account,
5274
- callData,
5275
- blockNumber: targetBlockNumber,
5276
- preCallData: preFullPositionsCallData ? [preFullPositionsCallData] : void 0,
5277
- postCallData: [postFullPositionsCallData]
5278
- });
5279
- if (!flowResult.success || !flowResult.tokenFlow) throw flowResult.rawError ?? new PanopticError(flowResult.error || "Token flow simulation failed");
5280
- const tokenFlow = flowResult.tokenFlow;
5281
- const preSnapshot = existingPositionIdList ?? [];
5282
- const positionsCreated = finalPositionIdList.filter((id) => !preSnapshot.includes(id));
5283
- const positionsClosed = preSnapshot.filter((id) => !finalPositionIdList.includes(id));
5284
- const sumCollateralReq = (data$1) => {
5285
- if (!data$1) return null;
5286
- try {
5287
- const decoded = decodeFunctionResult({
5288
- abi: panopticPoolV2Abi,
5289
- functionName: "getFullPositionsData",
5290
- data: data$1
5291
- });
5292
- const reqs = decoded[3];
5293
- let token0 = 0n;
5294
- let token1 = 0n;
5295
- for (const packed of reqs) {
5296
- const r = decodeLeftRightUnsigned(packed);
5297
- token0 += r.right;
5298
- token1 += r.left;
5299
- }
5300
- return {
5301
- token0,
5302
- token1
5303
- };
5304
- } catch {
5305
- return null;
5306
- }
5307
- };
5308
- const preReq = sumCollateralReq(flowResult.preCallResults?.[0]);
5309
- const postReq = sumCollateralReq(flowResult.postCallResults?.[0]);
5310
- const _meta = await metaPromise;
5311
- const data = {
5312
- netAmount0: tokenFlow.delta0,
5313
- netAmount1: tokenFlow.delta1,
5314
- positionsCreated,
5315
- positionsClosed,
5316
- postCollateral0: tokenFlow.balanceAfter0,
5317
- postCollateral1: tokenFlow.balanceAfter1,
5318
- preMarginExcess0: preReq ? tokenFlow.balanceBefore0 - preReq.token0 : null,
5319
- preMarginExcess1: preReq ? tokenFlow.balanceBefore1 - preReq.token1 : null,
5320
- postMarginExcess0: postReq ? tokenFlow.balanceAfter0 - postReq.token0 : null,
5321
- postMarginExcess1: postReq ? tokenFlow.balanceAfter1 - postReq.token1 : null
5322
- };
5323
- return {
5324
- success: true,
5325
- data,
5326
- gasEstimate: flowResult.gasEstimate,
5327
- tokenFlow,
5328
- _meta
5329
- };
5330
- } catch (error) {
5331
- const _meta = await metaPromise;
5332
- return {
5333
- success: false,
5334
- error: error instanceof PanopticError ? error : new PanopticError(error instanceof Error ? error.message : "Simulation failed", error instanceof Error ? error : void 0),
5335
- _meta
5336
- };
5337
- }
5338
- }
5339
-
5340
5637
  //#endregion
5341
5638
  //#region src/panoptic/v2/simulations/simulateBatchDispatch.ts
5342
5639
  /**
@@ -6103,47 +6400,19 @@ async function simulateSFPMBurn(params) {
6103
6400
  //#endregion
6104
6401
  //#region src/panoptic/v2/simulations/simulateSwap.ts
6105
6402
  /**
6106
- * Resolve token index, throwing SwapTokenMismatchError on mismatch.
6107
- */
6108
- function resolveTokenIndex(tokenAddress, token0, token1) {
6109
- const lower = tokenAddress.toLowerCase();
6110
- if (lower === token0.toLowerCase()) return 0n;
6111
- if (lower === token1.toLowerCase()) return 1n;
6112
- throw new SwapTokenMismatchError(tokenAddress, token0, token1);
6113
- }
6114
- /**
6115
- * Build a unique loan tokenId.
6116
- */
6117
- function buildUniqueLoan(poolId, asset, tokenType, currentTick, tickSpacing, existingPositionIds) {
6118
- const mod = currentTick % tickSpacing;
6119
- let strike = currentTick - (mod + tickSpacing) % tickSpacing;
6120
- const step = tickSpacing;
6121
- const existingSet = new Set(existingPositionIds);
6122
- for (let attempt = 0; attempt < 1e3; attempt++) {
6123
- const tokenId = createTokenIdBuilder(poolId).addLoan({
6124
- asset,
6125
- tokenType,
6126
- strike
6127
- }).build();
6128
- if (!existingSet.has(tokenId)) return tokenId;
6129
- strike += step;
6130
- }
6131
- throw new PanopticError("Could not build unique loan tokenId after 1000 attempts");
6132
- }
6133
- /**
6134
6403
  * Build dispatch calldata for swap simulation.
6135
6404
  */
6136
- function buildSwapCallData(loanTokenId, existingPositionIds, amount, mintTickLimits, burnTickLimits) {
6405
+ function buildSwapCallData(creditTokenId, existingPositionIds, amount, mintTickLimits, burnTickLimits, builderCode) {
6137
6406
  return encodeFunctionData({
6138
6407
  abi: panopticPoolV2Abi,
6139
6408
  functionName: "dispatch",
6140
6409
  args: [
6141
- [loanTokenId, loanTokenId],
6410
+ [creditTokenId, creditTokenId],
6142
6411
  [...existingPositionIds],
6143
6412
  [amount, 0n],
6144
6413
  [mintTickLimits, burnTickLimits],
6145
6414
  false,
6146
- 0n
6415
+ builderCode
6147
6416
  ]
6148
6417
  });
6149
6418
  }
@@ -6171,7 +6440,7 @@ function buildSwapResult(tokenFlow, tokenOutIndex) {
6171
6440
  * @returns Simulation result with swap data or error
6172
6441
  */
6173
6442
  async function simulateSwapExactOut(params) {
6174
- const { client, poolAddress, account, chainId, tokenOut, amountOut, slippageBps, existingPositionIds, blockNumber } = params;
6443
+ const { client, poolAddress, account, chainId, tokenOut, amountOut, slippageBps, existingPositionIds, builderCode = 0n, blockNumber } = params;
6175
6444
  try {
6176
6445
  const targetBlockNumber = blockNumber ?? await client.getBlockNumber();
6177
6446
  const metaPromise = getBlockMeta({
@@ -6187,9 +6456,9 @@ async function simulateSwapExactOut(params) {
6187
6456
  const token0 = pool.collateralTracker0.token;
6188
6457
  const token1 = pool.collateralTracker1.token;
6189
6458
  const tokenOutIndex = resolveTokenIndex(tokenOut, token0, token1);
6190
- const tokenType = tokenOutIndex === 0n ? 1n : 0n;
6459
+ const tokenType = tokenOutIndex;
6191
6460
  const { low: tickLimitLow, high: tickLimitHigh } = tickLimits(pool.currentTick, slippageBps);
6192
- const loanTokenId = buildUniqueLoan(pool.poolId, tokenOutIndex, tokenType, pool.currentTick, pool.tickSpacing, existingPositionIds);
6461
+ const { tokenId: creditTokenId, adjustedSize } = buildUniqueCredit(pool.poolId, tokenOutIndex, tokenType, pool.currentTick, pool.tickSpacing, existingPositionIds, amountOut);
6193
6462
  const mintTickLimits = [
6194
6463
  Number(tickLimitHigh),
6195
6464
  Number(tickLimitLow),
@@ -6200,7 +6469,7 @@ async function simulateSwapExactOut(params) {
6200
6469
  Number(tickLimitHigh),
6201
6470
  0
6202
6471
  ];
6203
- const callData = buildSwapCallData(loanTokenId, existingPositionIds, amountOut, mintTickLimits, burnTickLimits);
6472
+ const callData = buildSwapCallData(creditTokenId, existingPositionIds, adjustedSize, mintTickLimits, burnTickLimits, builderCode);
6204
6473
  const flowResult = await simulateWithTokenFlow({
6205
6474
  client,
6206
6475
  poolAddress,
@@ -6238,7 +6507,7 @@ async function simulateSwapExactOut(params) {
6238
6507
  * @returns Simulation result with swap data or error
6239
6508
  */
6240
6509
  async function simulateSwapExactIn(params) {
6241
- const { client, poolAddress, account, chainId, tokenIn, amountIn, slippageBps, existingPositionIds, blockNumber } = params;
6510
+ const { client, poolAddress, account, chainId, tokenIn, amountIn, slippageBps, existingPositionIds, builderCode = 0n, blockNumber } = params;
6242
6511
  try {
6243
6512
  const targetBlockNumber = blockNumber ?? await client.getBlockNumber();
6244
6513
  const metaPromise = getBlockMeta({
@@ -6256,7 +6525,7 @@ async function simulateSwapExactIn(params) {
6256
6525
  const tokenInIndex = resolveTokenIndex(tokenIn, token0, token1);
6257
6526
  const tokenType = tokenInIndex;
6258
6527
  const { low: tickLimitLow, high: tickLimitHigh } = tickLimits(pool.currentTick, slippageBps);
6259
- const loanTokenId = buildUniqueLoan(pool.poolId, tokenInIndex, tokenType, pool.currentTick, pool.tickSpacing, existingPositionIds);
6528
+ const { tokenId: creditTokenId, adjustedSize } = buildUniqueCredit(pool.poolId, tokenInIndex, tokenType, pool.currentTick, pool.tickSpacing, existingPositionIds, amountIn);
6260
6529
  const mintTickLimits = [
6261
6530
  Number(tickLimitLow),
6262
6531
  Number(tickLimitHigh),
@@ -6268,7 +6537,7 @@ async function simulateSwapExactIn(params) {
6268
6537
  0
6269
6538
  ];
6270
6539
  const tokenOutIndex = tokenInIndex === 0n ? 1n : 0n;
6271
- const callData = buildSwapCallData(loanTokenId, existingPositionIds, amountIn, mintTickLimits, burnTickLimits);
6540
+ const callData = buildSwapCallData(creditTokenId, existingPositionIds, adjustedSize, mintTickLimits, burnTickLimits, builderCode);
6272
6541
  const flowResult = await simulateWithTokenFlow({
6273
6542
  client,
6274
6543
  poolAddress,
@@ -7434,5 +7703,5 @@ function createEventPoller(params) {
7434
7703
  }
7435
7704
 
7436
7705
  //#endregion
7437
- export { DEFAULT_RECONNECT_CONFIG, REQUIRED_BASE_ERROR_SENTINEL, addPendingPosition, addTrackedChunks, calculateAccountGreeksPure, calculateSpreadWad, checkCollateralAcrossTicks, cleanupStalePendingPositions, clearPendingPositions, clearTrackedChunks, clearTradeHistory, computeV4PoolId, confirmPendingPosition, convertToAssets, convertToShares, createEventPoller, createEventSubscription, createFlowNeutralTokenId, createPoolFormatters, decodePanopticTokenURI, encodePoolKeyBytes, encodeV3PoolKeyBytes, estimateBlockNumbers, estimateCollateralRequired, failPendingPosition, formatBlockNumber, formatBps, formatCompact, formatDatetime, formatDuration, formatDurationSeconds, formatFeeTier, formatGas, formatGwei, formatPoolIdHex, formatRatioPercent, formatTimestamp, formatTimestampLocale, formatTokenIdHex, formatTokenIdShort, formatTxHash, formatUtilization, formatWei, getAccountBuyingPower, getAccountGreeks, getAccountHistory, getAccountPremia, getChunkLiquidities, getChunkSpreads, getClosedPositions, getCollateralSharePrices, getCollateralTotalAssetsBatch, getDeltaHedgeParams, getEnforcedTickLimits, getFactoryConstructMetadata, getFactoryOwnerOf, getFactoryTokenURI, getGuardianUnlockState, getItmAmounts, getMarginBuffer, getMaxPositionSize, getMaxWithdrawable, getNativeTokenPrice, getOpenPositionPreview, getPanopticPoolAddress, getPanopticPoolFromPoolId, getPendingPositions, getPoolDeploymentBlock, getPoolDisplayId, getPoolLiquidities, getPortfolioValue, getPositionChunkData, getPositionEnrichmentData, getPositionsWithPremia, getPriceHistory, getRealizedPnL, getRequiredCreditForITM, getSafeMode, getStreamiaHistory, getSyncStatus, getTokenListId, getTrackedChunks, getTradeHistory, getUniswapFeeHistory, getUniswapV3PoolFromId, getUniswapV3PoolInfo, getUniswapV3PoolLiquidities, getUniswapV4PoolBasicState, getUniswapV4PoolInfo, getUniswapV4PoolKeyFromId, getUniswapV4PoolLiquidities, interpolateBlocks, minePoolAddress, minePoolAddressLocalAsync, multicallRead, optimizeTokenIdRiskPartners, parseBps, parseCollateralLog, parsePoolLog, parseTokenListId, previewDeposit, previewMint, previewRedeem, previewWithdraw, reconstructFromEvents, removeTrackedChunks, resolveBlockNumbers, resolvePanopticPoolFromPoolId, resolveUniswapV4PoolKey, saveClosedPosition, scanChunks, simulateBatchDispatch, simulateClosePosition, simulateDeployNewPool, simulateDeposit, simulateDispatch, simulateForceExercise, simulateLiquidate, simulateSFPMBurn, simulateSFPMMint, simulateSettle, simulateSwapExactIn, simulateSwapExactOut, simulateWithdraw, truncateAddress, watchEvents };
7438
- //# sourceMappingURL=v2-BSV35bpu.js.map
7706
+ export { DEFAULT_RECONNECT_CONFIG, REQUIRED_BASE_ERROR_SENTINEL, addPendingPosition, addTrackedChunks, buildTokenShortfallRecoveryDispatch, calculateAccountGreeksPure, calculateSpreadWad, checkCollateralAcrossTicks, cleanupStalePendingPositions, clearPendingPositions, clearTrackedChunks, clearTradeHistory, computeV4PoolId, confirmPendingPosition, convertToAssets, convertToShares, createEventPoller, createEventSubscription, createFlowNeutralTokenId, createPoolFormatters, decodePanopticTokenURI, encodePoolKeyBytes, encodeV3PoolKeyBytes, estimateBlockNumbers, estimateCollateralRequired, failPendingPosition, formatBlockNumber, formatBps, formatCompact, formatDatetime, formatDuration, formatDurationSeconds, formatFeeTier, formatGas, formatGwei, formatPoolIdHex, formatRatioPercent, formatTimestamp, formatTimestampLocale, formatTokenIdHex, formatTokenIdShort, formatTxHash, formatUtilization, formatWei, getAccountBuyingPower, getAccountGreeks, getAccountHistory, getAccountPremia, getChunkLiquidities, getChunkSpreads, getClosedPositions, getCollateralSharePrices, getCollateralTotalAssetsBatch, getDeltaHedgeParams, getEnforcedTickLimits, getFactoryConstructMetadata, getFactoryOwnerOf, getFactoryTokenURI, getGuardianUnlockState, getItmAmounts, getMarginBuffer, getMaxPositionSize, getMaxWithdrawable, getNativeTokenPrice, getNotEnoughTokensError, getOpenPositionPreview, getPanopticPoolAddress, getPanopticPoolFromPoolId, getPendingPositions, getPoolDeploymentBlock, getPoolDisplayId, getPoolLiquidities, getPortfolioValue, getPositionChunkData, getPositionEnrichmentData, getPositionsWithPremia, getPriceHistory, getRealizedPnL, getRequiredCreditForITM, getSafeMode, getStreamiaHistory, getSyncStatus, getTokenListId, getTrackedChunks, getTradeHistory, getUniswapFeeHistory, getUniswapV3PoolFromId, getUniswapV3PoolInfo, getUniswapV3PoolLiquidities, getUniswapV4PoolBasicState, getUniswapV4PoolInfo, getUniswapV4PoolKeyFromId, getUniswapV4PoolLiquidities, interpolateBlocks, minePoolAddress, minePoolAddressLocalAsync, multicallRead, optimizeTokenIdRiskPartners, parseBps, parseCollateralLog, parsePoolLog, parseTokenListId, previewDeposit, previewMint, previewRedeem, previewWithdraw, quoteTokenShortfallRecovery, reconstructFromEvents, removeTrackedChunks, resolveBlockNumbers, resolvePanopticPoolFromPoolId, resolveUniswapV4PoolKey, saveClosedPosition, scanChunks, simulateBatchDispatch, simulateClosePosition, simulateDeployNewPool, simulateDeposit, simulateDispatch, simulateForceExercise, simulateLiquidate, simulateSFPMBurn, simulateSFPMMint, simulateSettle, simulateSwapExactIn, simulateSwapExactOut, simulateWithdraw, truncateAddress, watchEvents };
7707
+ //# sourceMappingURL=v2-D3B5BKml.js.map