@panoptic-eng/sdk 1.0.59 → 1.0.61

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.
@@ -1,8 +1,8 @@
1
- import { StateViewAbi, getAccountCollateral, panopticQueryAbi, readBlockAndAggregate, requireReturnData } from "./irm-BIaLQ-0n.js";
2
- import { AccountInsolventError, ChunkLimitError, DEFAULT_VEGOID, InvalidHistoryRangeError, MulticallResultMissingError, NotEnoughTokensError, PanopticError, PanopticValidationError, SafeModeError, StaleDataError, StorageDataNotFoundError, UnhealthyPoolError, WrongUniswapPoolError, applyMintBufferPerToken, availableToBorrow, collateralTrackerV2Abi, decodeLeftRightSigned, decodeLeftRightUnsigned, decodePositionBalance, getBlockMeta, getClosedPositionsKey, getPendingPositionsKey, getPool, getPoolMetaKey, getPoolMetadata, getPositionMetaKey, getPositionsKey, getTrackedChunksKey, getTrackedPositionIds, isPanopticErrorType, jsonSerializer, mintableAfterBuffer, panopticFactoryV3Abi, panopticFactoryV4Abi, panopticGuardianAbi, panopticLiquidatorAbi, panopticPoolV2Abi, panopticQueryAbi$1, parsePanopticError, riskEngineAbi, semiFungiblePositionManagerV3Abi, semiFungiblePositionManagerV4Abi, stateViewAbi, uniswapV3PoolAbi } from "./rates-COAJpKRd.js";
1
+ import { StateViewAbi, getAccountCollateral, panopticQueryAbi$1 as panopticQueryAbi, readBlockAndAggregate, requireReturnData } from "./irm-BEug2-TH.js";
2
+ import { AccountInsolventError, ChunkLimitError, DEFAULT_VEGOID, InvalidHistoryRangeError, MulticallResultMissingError, NotEnoughTokensError, PanopticError, PanopticValidationError, SafeModeError, StaleDataError, StorageDataNotFoundError, UnhealthyPoolError, WrongUniswapPoolError, applyMintBufferPerToken, availableToBorrow, collateralTrackerV2Abi, decodeLeftRightSigned, decodeLeftRightUnsigned, decodePositionBalance, getBlockMeta, getClosedPositionsKey, getPendingPositionsKey, getPool, getPoolMetaKey, getPoolMetadata, getPositionMetaKey, getPositionsKey, getTrackedChunksKey, getTrackedPositionIds, isPanopticErrorType, jsonSerializer, mintableAfterBuffer, panopticFactoryV3Abi, panopticFactoryV4Abi, panopticGuardianAbi, panopticLiquidatorAbi, panopticPoolV2Abi, panopticQueryAbi as panopticQueryAbi$1, parsePanopticError, riskEngineAbi, semiFungiblePositionManagerV3Abi, semiFungiblePositionManagerV4Abi, stateViewAbi, uniswapV3PoolAbi } from "./rates-CPHxWqpT.js";
3
3
  import { MAX_TICK, MAX_TRACKED_CHUNKS, MIN_TICK, NO_LOWER_LIQUIDATION_TICK, NO_UPPER_LIQUIDATION_TICK, WAD, calculatePositionDelta, calculatePositionDeltaDebtOnly, calculatePositionGamma, calculatePositionValue, priceToTick, sqrtPriceX96ToTick, tickLimits, tickToPriceDecimalScaled, tickToSqrtPriceX96, toVaultFrameAtTick } from "./greeks-CNi1-cnp.js";
4
- import { addLegToTokenId, buildBatchDispatchArgs, buildSettleSequenceCalls, buildUniqueCredit, buildUniqueLoan, countLegs, createTokenIdBuilder, decodeAllLegs, decodeTokenId, getPoolTokensForSimulation, loadCheckpoint, resolveTokenIndex, simulateOpenPosition, simulateWithTokenFlow } from "./writes-CllMRkmo.js";
5
- import { getLpPositionFunding, getMaxLpPositionSize } from "./router-DiVbG7km.js";
4
+ import { addLegToTokenId, buildBatchDispatchArgs, buildUniqueCredit, buildUniqueLoan, countLegs, createTokenIdBuilder, decodeAllLegs, decodeTokenId, getPoolTokensForSimulation, loadCheckpoint, resolveTokenIndex, simulateDispatch, simulateOpenPosition, simulateWithTokenFlow } from "./writes-gs0k0uoN.js";
5
+ import { getLpPositionFunding, getMaxLpPositionSize } from "./router-BZGHjEcU.js";
6
6
  import { BaseError, ContractFunctionExecutionError, ContractFunctionRevertedError, ExecutionRevertedError, decodeFunctionResult, encodeAbiParameters, encodeFunctionData, getAddress, hexToString, keccak256, parseAbi, toHex, trim, zeroAddress } from "viem";
7
7
  import { multicall } from "viem/actions";
8
8
  import Decimal from "decimal.js";
@@ -539,159 +539,6 @@ async function assertLpPositionFunded(params) {
539
539
  return funding;
540
540
  }
541
541
 
542
- //#endregion
543
- //#region src/panoptic/v2/simulations/simulateDispatch.ts
544
- /**
545
- * Simulate a raw dispatch operation.
546
- *
547
- * Uses PanopticPool.multicall with getAssetsOf-dispatch-getAssetsOf pattern
548
- * to measure exact collateral asset movements.
549
- *
550
- * @param params - Simulation parameters
551
- * @returns Simulation result with dispatch data or error
552
- */
553
- async function simulateDispatch(params) {
554
- const { client, poolAddress, account, positionIdList, finalPositionIdList, positionSizes, tickAndSpreadLimits, usePremiaAsCollateral = false, builderCode = 0n, blockNumber, existingPositionIdList, measurePremia = false } = params;
555
- const targetBlockNumber = blockNumber ?? await client.getBlockNumber();
556
- const metaPromise = getBlockMeta({
557
- client,
558
- blockNumber: targetBlockNumber
559
- });
560
- try {
561
- const callData = encodeFunctionData({
562
- abi: panopticPoolV2Abi,
563
- functionName: "dispatch",
564
- args: [
565
- positionIdList,
566
- finalPositionIdList,
567
- positionSizes,
568
- tickAndSpreadLimits.map((t) => [
569
- Number(t[0]),
570
- Number(t[1]),
571
- Number(t[2])
572
- ]),
573
- usePremiaAsCollateral,
574
- builderCode
575
- ]
576
- });
577
- const preFullPositionsCallData = existingPositionIdList !== void 0 ? encodeFunctionData({
578
- abi: panopticPoolV2Abi,
579
- functionName: "getFullPositionsData",
580
- args: [
581
- account,
582
- false,
583
- existingPositionIdList
584
- ]
585
- }) : void 0;
586
- const prePremiaCallData = measurePremia && existingPositionIdList !== void 0 ? encodeFunctionData({
587
- abi: panopticPoolV2Abi,
588
- functionName: "getFullPositionsData",
589
- args: [
590
- account,
591
- true,
592
- existingPositionIdList
593
- ]
594
- }) : void 0;
595
- const postFullPositionsCallData = encodeFunctionData({
596
- abi: panopticPoolV2Abi,
597
- functionName: "getFullPositionsData",
598
- args: [
599
- account,
600
- false,
601
- finalPositionIdList
602
- ]
603
- });
604
- const postPremiaCallData = measurePremia ? encodeFunctionData({
605
- abi: panopticPoolV2Abi,
606
- functionName: "getFullPositionsData",
607
- args: [
608
- account,
609
- true,
610
- finalPositionIdList
611
- ]
612
- }) : void 0;
613
- const flowResult = await simulateWithTokenFlow({
614
- client,
615
- poolAddress,
616
- user: account,
617
- callData: params.settleSequence?.targets.length ? encodeFunctionData({
618
- abi: panopticPoolV2Abi,
619
- functionName: "multicall",
620
- args: [[...buildSettleSequenceCalls(params.settleSequence), callData]]
621
- }) : callData,
622
- blockNumber: targetBlockNumber,
623
- preCallData: preFullPositionsCallData ? [preFullPositionsCallData, ...prePremiaCallData ? [prePremiaCallData] : []] : void 0,
624
- postCallData: [postFullPositionsCallData, ...postPremiaCallData ? [postPremiaCallData] : []]
625
- });
626
- if (!flowResult.success || !flowResult.tokenFlow) throw flowResult.rawError ?? new PanopticError(flowResult.error || "Token flow simulation failed");
627
- const tokenFlow = flowResult.tokenFlow;
628
- const preSnapshot = existingPositionIdList ?? [];
629
- const positionsCreated = finalPositionIdList.filter((id) => !preSnapshot.includes(id));
630
- const positionsClosed = preSnapshot.filter((id) => !finalPositionIdList.includes(id));
631
- const decodeFullPositions = (data$1) => {
632
- if (!data$1) return null;
633
- try {
634
- const decoded = decodeFunctionResult({
635
- abi: panopticPoolV2Abi,
636
- functionName: "getFullPositionsData",
637
- data: data$1
638
- });
639
- const shortPremium = decodeLeftRightUnsigned(decoded[0]);
640
- const longPremium = decodeLeftRightUnsigned(decoded[1]);
641
- const reqs = decoded[3];
642
- let collateralRequirements0 = 0n;
643
- let collateralRequirements1 = 0n;
644
- for (const packed of reqs) {
645
- const r = decodeLeftRightUnsigned(packed);
646
- collateralRequirements0 += r.right;
647
- collateralRequirements1 += r.left;
648
- }
649
- return {
650
- collateralRequirements0,
651
- collateralRequirements1,
652
- netPremia0: shortPremium.right - longPremium.right,
653
- netPremia1: shortPremium.left - longPremium.left
654
- };
655
- } catch {
656
- return null;
657
- }
658
- };
659
- const prePositions = decodeFullPositions(flowResult.preCallResults?.[0]);
660
- const postPositions = decodeFullPositions(flowResult.postCallResults?.[0]);
661
- const prePremia = decodeFullPositions(flowResult.preCallResults?.[1]);
662
- const postPremia = decodeFullPositions(flowResult.postCallResults?.[1]);
663
- const _meta = await metaPromise;
664
- const data = {
665
- netAmount0: tokenFlow.delta0,
666
- netAmount1: tokenFlow.delta1,
667
- premiaReceived0: prePremia !== null && postPremia !== null ? prePremia.netPremia0 - postPremia.netPremia0 : null,
668
- premiaReceived1: prePremia !== null && postPremia !== null ? prePremia.netPremia1 - postPremia.netPremia1 : null,
669
- positionsCreated,
670
- positionsClosed,
671
- postCollateral0: tokenFlow.balanceAfter0,
672
- postCollateral1: tokenFlow.balanceAfter1,
673
- preMarginExcess0: prePositions === null ? null : tokenFlow.balanceBefore0 - prePositions.collateralRequirements0,
674
- preMarginExcess1: prePositions === null ? null : tokenFlow.balanceBefore1 - prePositions.collateralRequirements1,
675
- postMarginExcess0: postPositions === null ? null : tokenFlow.balanceAfter0 - postPositions.collateralRequirements0,
676
- postMarginExcess1: postPositions === null ? null : tokenFlow.balanceAfter1 - postPositions.collateralRequirements1
677
- };
678
- return {
679
- success: true,
680
- data,
681
- gasEstimate: flowResult.gasEstimate,
682
- tokenFlow,
683
- _meta
684
- };
685
- } catch (error) {
686
- const _meta = await metaPromise;
687
- return {
688
- success: false,
689
- error: error instanceof PanopticError ? error : new PanopticError(error instanceof Error ? error.message : "Simulation failed", error instanceof Error ? error : void 0),
690
- _meta
691
- };
692
- }
693
- }
694
-
695
542
  //#endregion
696
543
  //#region src/panoptic/v2/simulations/creditWrap.ts
697
544
  /**
@@ -3549,6 +3396,73 @@ async function optimizeTokenIdRiskPartners(params) {
3549
3396
  return optimizedTokenId;
3550
3397
  }
3551
3398
 
3399
+ //#endregion
3400
+ //#region src/panoptic/v2/reads/tickNetWindows.ts
3401
+ /**
3402
+ * Wide liquidity distributions from several adjacent `getTickNets*` windows.
3403
+ *
3404
+ * @module v2/reads/tickNetWindows
3405
+ */
3406
+ /** Absolute Uniswap V3/V4 tick bounds. */
3407
+ const TICK_MIN$1 = -887272;
3408
+ const TICK_MAX$1 = 887272;
3409
+ /**
3410
+ * Join ascending, edge-sharing windows into one distribution anchored to `windows[mainIndex]`.
3411
+ *
3412
+ * Each `getTickNets*` window is a running sum of liquidityNet from its own first tick (only the
3413
+ * window holding the current tick is rescaled to the pool's liquidity), so a neighbour's values
3414
+ * are off by a constant. Adjacent windows share their edge tick; the offset that makes that tick
3415
+ * agree is applied to the whole neighbour. Stitching stops at the first window that does not share
3416
+ * an edge with the one before it.
3417
+ */
3418
+ function stitchTickNetWindows(windows, mainIndex) {
3419
+ const main = windows[mainIndex];
3420
+ if (!main) return {
3421
+ ticks: [],
3422
+ liquidityNets: []
3423
+ };
3424
+ const ticks = [...main.ticks];
3425
+ const nets = [...main.liquidityNets];
3426
+ for (let i = mainIndex + 1; i < windows.length; i++) {
3427
+ const window = windows[i];
3428
+ const edge = ticks.length - 1;
3429
+ if (!window.ticks.length || window.ticks[0] !== ticks[edge]) break;
3430
+ const offset = nets[edge] - window.liquidityNets[0];
3431
+ ticks.push(...window.ticks.slice(1));
3432
+ nets.push(...window.liquidityNets.slice(1).map((value) => value + offset));
3433
+ }
3434
+ for (let i = mainIndex - 1; i >= 0; i--) {
3435
+ const window = windows[i];
3436
+ const last = window.ticks.length - 1;
3437
+ if (last < 0 || window.ticks[last] !== ticks[0]) break;
3438
+ const offset = nets[0] - window.liquidityNets[last];
3439
+ ticks.unshift(...window.ticks.slice(0, last));
3440
+ nets.unshift(...window.liquidityNets.slice(0, last).map((value) => value + offset));
3441
+ }
3442
+ return {
3443
+ ticks,
3444
+ liquidityNets: nets
3445
+ };
3446
+ }
3447
+ /**
3448
+ * Read the main window around `startTick` plus up to `windowsPerSide` windows of `nTicks` on each
3449
+ * side, in parallel, and stitch them. Side windows that would cross the tick bounds are skipped.
3450
+ */
3451
+ async function readTickNetWindows({ startTick, mainNTicks, nTicks, tickSpacing, windowsPerSide, read }) {
3452
+ const center = Math.trunc(startTick / tickSpacing) * tickSpacing;
3453
+ const half = Number(nTicks) * tickSpacing;
3454
+ const mainHalf = Number(mainNTicks) * tickSpacing;
3455
+ const sideCenters = (direction) => Array.from({ length: windowsPerSide }, (_, k) => center + direction * (mainHalf + half + 2 * half * k)).filter((side) => side - half >= TICK_MIN$1 && side + half <= TICK_MAX$1);
3456
+ const below = sideCenters(-1).reverse();
3457
+ const above = sideCenters(1);
3458
+ const windows = await Promise.all([
3459
+ ...below.map((side) => read(side, nTicks)),
3460
+ read(startTick, mainNTicks),
3461
+ ...above.map((side) => read(side, nTicks))
3462
+ ]);
3463
+ return stitchTickNetWindows(windows, below.length);
3464
+ }
3465
+
3552
3466
  //#endregion
3553
3467
  //#region src/panoptic/v2/reads/liquidity.ts
3554
3468
  /**
@@ -3566,24 +3480,35 @@ async function optimizeTokenIdRiskPartners(params) {
3566
3480
  async function getPoolLiquidities(params) {
3567
3481
  const { client, poolAddress, queryAddress, startTick, nTicks, blockNumber } = params;
3568
3482
  const targetBlockNumber = blockNumber ?? params._meta?.blockNumber ?? await client.getBlockNumber();
3569
- const [result, _meta] = await Promise.all([client.readContract({
3570
- address: queryAddress,
3571
- abi: panopticQueryAbi,
3572
- functionName: "getTickNets",
3573
- args: [
3574
- poolAddress,
3575
- Number(startTick),
3576
- nTicks
3577
- ],
3578
- blockNumber: targetBlockNumber
3483
+ const windowsPerSide = params.windowsPerSide ?? 0;
3484
+ if (windowsPerSide > 0 && params.tickSpacing === void 0) throw new PanopticValidationError("getPoolLiquidities: tickSpacing is required with windowsPerSide");
3485
+ const [{ ticks, liquidityNets }, _meta] = await Promise.all([readTickNetWindows({
3486
+ startTick: Number(startTick),
3487
+ mainNTicks: nTicks,
3488
+ nTicks,
3489
+ tickSpacing: params.tickSpacing ?? 1,
3490
+ windowsPerSide,
3491
+ read: (centerTick, windowTicks) => client.readContract({
3492
+ address: queryAddress,
3493
+ abi: panopticQueryAbi,
3494
+ functionName: "getTickNets",
3495
+ args: [
3496
+ poolAddress,
3497
+ centerTick,
3498
+ windowTicks
3499
+ ],
3500
+ blockNumber: targetBlockNumber
3501
+ }).then(([tickData, nets]) => ({
3502
+ ticks: tickData,
3503
+ liquidityNets: nets
3504
+ }))
3579
3505
  }), params._meta ?? getBlockMeta({
3580
3506
  client,
3581
3507
  blockNumber: targetBlockNumber
3582
3508
  })]);
3583
- const [tickData, liquidityNets] = result;
3584
3509
  return {
3585
- ticks: [...tickData],
3586
- liquidityNets: [...liquidityNets],
3510
+ ticks,
3511
+ liquidityNets,
3587
3512
  _meta
3588
3513
  };
3589
3514
  }
@@ -4475,6 +4400,32 @@ function computeUniswapFeesForBlock(blockData, legs) {
4475
4400
  total1
4476
4401
  };
4477
4402
  }
4403
+ const MAX_UINT256$1 = 2n ** 256n - 1n;
4404
+ /**
4405
+ * Fee growth per unit of liquidity inside `[lowerTick, upperTick)` at one block,
4406
+ * wrapped to uint256 as the pool computes it. Diff two snapshots with
4407
+ * `feesFromFeeGrowthDelta` to get the fees a constant liquidity earned between them.
4408
+ */
4409
+ function feeGrowthInsideX128(blockData, lowerTick, upperTick) {
4410
+ const lower = blockData.tickData.get(lowerTick);
4411
+ const upper = blockData.tickData.get(upperTick);
4412
+ if (!lower || !upper) return null;
4413
+ const { currentTick } = blockData;
4414
+ const inside = (global, lowerOutside, upperOutside) => {
4415
+ const below = currentTick >= lowerTick ? lowerOutside : global - lowerOutside;
4416
+ const above = currentTick < upperTick ? upperOutside : global - upperOutside;
4417
+ return global - below - above & MAX_UINT256$1;
4418
+ };
4419
+ return {
4420
+ feeGrowthInside0X128: inside(blockData.feeGrowthGlobal0, lower.feeGrowthOutside0, upper.feeGrowthOutside0),
4421
+ feeGrowthInside1X128: inside(blockData.feeGrowthGlobal1, lower.feeGrowthOutside1, upper.feeGrowthOutside1)
4422
+ };
4423
+ }
4424
+ /** Blocks before the chain's Multicall3 deployment need viem's deployless multicall. */
4425
+ function predatesMulticall3(client, blockNumber) {
4426
+ const deployedAt = client.chain?.contracts?.multicall3?.blockCreated;
4427
+ return blockNumber != null && deployedAt != null && blockNumber < BigInt(deployedAt);
4428
+ }
4478
4429
  async function fetchUniswapBlockSnapshot(client, blockNumber, uniqueTicks, poolConfig) {
4479
4430
  if (poolConfig.version === "v3") return fetchV3BlockSnapshot(client, poolConfig.poolAddress, blockNumber, uniqueTicks);
4480
4431
  else return fetchV4BlockSnapshot(client, poolConfig.stateViewAddress, poolConfig.poolId, blockNumber, uniqueTicks);
@@ -4506,7 +4457,8 @@ async function fetchV3BlockSnapshot(client, poolAddress, blockNumber, uniqueTick
4506
4457
  const results = await client.multicall({
4507
4458
  contracts,
4508
4459
  blockNumber,
4509
- allowFailure: false
4460
+ allowFailure: false,
4461
+ deployless: predatesMulticall3(client, blockNumber)
4510
4462
  });
4511
4463
  const slot0Result = results[0];
4512
4464
  const feeGrowthGlobal0 = results[1];
@@ -4551,7 +4503,8 @@ async function fetchV4BlockSnapshot(client, stateViewAddress, poolId, blockNumbe
4551
4503
  const results = await client.multicall({
4552
4504
  contracts,
4553
4505
  blockNumber,
4554
- allowFailure: false
4506
+ allowFailure: false,
4507
+ deployless: predatesMulticall3(client, blockNumber)
4555
4508
  });
4556
4509
  const slot0Result = results[0];
4557
4510
  const feeGrowthResult = results[1];
@@ -4861,23 +4814,34 @@ function clampNTicks(startTick, tickSpacing, nTicks) {
4861
4814
  * for the pool — only a deployed PanopticQuery on the chain.
4862
4815
  */
4863
4816
  async function getUniswapV3PoolLiquidities(params) {
4864
- const { client, poolAddress, queryAddress, startTick, nTicks } = params;
4865
- const safeN = clampNTicks(startTick, 1, nTicks);
4817
+ const { client, poolAddress, queryAddress, startTick, nTicks, windowsPerSide = 0 } = params;
4818
+ if (windowsPerSide > 0 && params.tickSpacing === void 0) throw new PanopticValidationError("getUniswapV3PoolLiquidities: tickSpacing is required with windowsPerSide");
4819
+ const safeN = clampNTicks(startTick, params.tickSpacing ?? 1, nTicks);
4866
4820
  const _meta = await getBlockMeta({ client });
4867
- const [ticks, liquidityNets] = await client.readContract({
4868
- address: queryAddress,
4869
- abi: panopticQueryAbi,
4870
- functionName: "getTickNetsV3",
4871
- args: [
4872
- poolAddress,
4873
- startTick,
4874
- safeN
4875
- ],
4876
- blockNumber: _meta.blockNumber
4821
+ const { ticks, liquidityNets } = await readTickNetWindows({
4822
+ startTick,
4823
+ mainNTicks: safeN,
4824
+ nTicks,
4825
+ tickSpacing: params.tickSpacing ?? 1,
4826
+ windowsPerSide,
4827
+ read: (centerTick, windowTicks) => client.readContract({
4828
+ address: queryAddress,
4829
+ abi: panopticQueryAbi,
4830
+ functionName: "getTickNetsV3",
4831
+ args: [
4832
+ poolAddress,
4833
+ centerTick,
4834
+ windowTicks
4835
+ ],
4836
+ blockNumber: _meta.blockNumber
4837
+ }).then(([windowTickData, windowNets]) => ({
4838
+ ticks: windowTickData,
4839
+ liquidityNets: windowNets
4840
+ }))
4877
4841
  });
4878
4842
  return {
4879
- ticks: [...ticks],
4880
- liquidityNets: [...liquidityNets],
4843
+ ticks,
4844
+ liquidityNets,
4881
4845
  _meta
4882
4846
  };
4883
4847
  }
@@ -5050,22 +5014,32 @@ async function getUniswapV4PoolLiquidities(params) {
5050
5014
  const { client, queryAddress, poolManager, poolId, tickSpacing, startTick, nTicks } = params;
5051
5015
  const safeN = clampNTicks(startTick, tickSpacing, nTicks);
5052
5016
  const _meta = await getBlockMeta({ client });
5053
- const [ticks, liquidityNets] = await client.readContract({
5054
- address: queryAddress,
5055
- abi: panopticQueryAbi,
5056
- functionName: "getTickNetsV4",
5057
- args: [
5058
- poolManager,
5059
- poolId,
5060
- tickSpacing,
5061
- startTick,
5062
- safeN
5063
- ],
5064
- blockNumber: _meta.blockNumber
5017
+ const { ticks, liquidityNets } = await readTickNetWindows({
5018
+ startTick,
5019
+ mainNTicks: safeN,
5020
+ nTicks,
5021
+ tickSpacing,
5022
+ windowsPerSide: params.windowsPerSide ?? 0,
5023
+ read: (centerTick, windowTicks) => client.readContract({
5024
+ address: queryAddress,
5025
+ abi: panopticQueryAbi,
5026
+ functionName: "getTickNetsV4",
5027
+ args: [
5028
+ poolManager,
5029
+ poolId,
5030
+ tickSpacing,
5031
+ centerTick,
5032
+ windowTicks
5033
+ ],
5034
+ blockNumber: _meta.blockNumber
5035
+ }).then(([windowTickData, windowNets]) => ({
5036
+ ticks: windowTickData,
5037
+ liquidityNets: windowNets
5038
+ }))
5065
5039
  });
5066
5040
  return {
5067
- ticks: [...ticks],
5068
- liquidityNets: [...liquidityNets],
5041
+ ticks,
5042
+ liquidityNets,
5069
5043
  _meta
5070
5044
  };
5071
5045
  }
@@ -7527,6 +7501,15 @@ async function quoteOneTokenFlow(params) {
7527
7501
  detail: recovery.detail,
7528
7502
  error: recovery.error
7529
7503
  };
7504
+ if (minSwapRatioBps > 0n) {
7505
+ const residualInTargetTerms = convertToTokenIndex(abs(recovery.quote.netTokenOutChange), otherTokenIndex, targetTokenIndex, pool.sqrtPriceX96);
7506
+ const settledInTargetTerms = abs(recovery.quote.netTokenInChange) + residualInTargetTerms;
7507
+ if (residualInTargetTerms * BPS_DENOMINATOR$1 >= minSwapRatioBps * settledInTargetTerms) return {
7508
+ available: false,
7509
+ reason: "residual-not-single-token",
7510
+ detail: `covering the shortfall leaves ${recovery.quote.netTokenOutChange} of the other token (${residualInTargetTerms} in target token terms) against a target flow of ${recovery.quote.netTokenInChange}`
7511
+ };
7512
+ }
7530
7513
  return {
7531
7514
  available: true,
7532
7515
  quote: {
@@ -10111,4 +10094,4 @@ function preparePositionValueCurve(curve) {
10111
10094
  }
10112
10095
 
10113
10096
  //#endregion
10114
- export { DEFAULT_MIN_SWAP_RATIO_BPS, DEFAULT_RECONNECT_CONFIG, MARKET_INDICATOR_PERIODS, REQUIRED_BASE_ERROR_SENTINEL, STRIKE_LADDER_TARGET_STRIKES, VARIANCE_RATIO_LAG, addPendingPosition, addTrackedChunks, apportion, assertCanBurn, assertCanForceExercise, assertCanLiquidate, assertCanMint, assertFresh, assertHealthy, assertLpPositionFunded, assertTradeable, buildCreditWrappedDispatch, buildSfpmSwapCalldata, buildSfpmSwapPlan, buildTemporaryLoanRecoveryDispatch, buildTokenShortfallRecoveryDispatch, calculateAccountGreeksPure, calculateMarketIndicator, calculateSpreadWad, calculateVarianceProfile, checkCollateralAcrossTicks, classifyStrategyGroups, classifyStrike, cleanupStalePendingPositions, clearPendingPositions, clearTrackedChunks, clearTradeHistory, collateralCurveTicks, collateralRuleKindFor, computeV4PoolId, confirmPendingPosition, convertToAssets, convertToShares, createEventPoller, createEventSubscription, createFlowNeutralTokenId, decodePanopticTokenURI, emptyLiquidateParams, encodePoolKeyBytes, encodeV3PoolKeyBytes, ensureSfpmV3PoolInitialized, estimateBlockNumbers, estimateCollateralBreakdown, estimateCollateralRequired, failPendingPosition, feesFromFeeGrowthDelta, fetchSfpmV3PoolId, getAccountBuyingPower, getAccountGreeks, getAccountHistory, getChunkLiquidities, getChunkSpreads, getClosedPositions, getCollateralCurve, getCollateralCurveInputs, getCollateralRequiredBase, getCollateralSharePrices, getCollateralTotalAssetsBatch, getDeltaHedgeParams, getEnforcedTickLimits, getExecutableLpMaxSize, getFactoryConstructMetadata, getFactoryOwnerOf, getFactoryTokenURI, getGuardianUnlockState, getHedgeLimits, getItmAmounts, getMarginBuffer, getMaxPositionSize, getMaxRedeem, getMaxWithdrawable, getNativeTokenPrice, getNotEnoughTokensError, getOpenPositionPreview, getPanopticPoolAddress, getPanopticPoolFromPoolId, getPendingPositions, getPoolCollateralAddresses, getPoolLiquidities, getPortfolioValue, getPositionChunkData, getPositionEnrichmentData, getPositionValueCurve, getPriceHistory, getRealizedPnL, getRequiredCreditForITM, getSafeMode, getStreamiaHistory, getSyncStatus, getTrackedChunks, getTradeHistory, getUniswapFeeHistory, getUniswapV3LpPositionState, getUniswapV3PoolFromId, getUniswapV3PoolInfo, getUniswapV3PoolLiquidities, getUniswapV4LpPositionState, getUniswapV4PoolBasicState, getUniswapV4PoolInfo, getUniswapV4PoolKeyFromId, getUniswapV4PoolLiquidities, interpolateBlocks, isGasError, isNonceError, isRetryableRpcError, isolateGroupTokenId, ladderStrikeSequence, logReturns, marketPnlInQuote, marketRiskFromValues, marketScenario, minePoolAddress, minePoolAddressLocalAsync, multicallRead, netLiquidationValueInQuote, optimizeTokenIdRiskPartners, parseCollateralLog, parsePoolLog, positionValueKey, positionValueTicks, prepareIndicatorCandles, preparePositionValueCurve, previewDeposit, previewMint, previewRedeem, previewWithdraw, quoteLiquidation, quoteOneTokenFlow, quoteSfpmSwap, quoteTemporaryLoanRecovery, quoteTokenShortfallRecovery, realizedBeta, removeTrackedChunks, resolveBlockNumbers, resolveLadderStrike, resolvePanopticPoolFromPoolId, resolveUniswapV4PoolKey, saveClosedPosition, scaleCollateralRequired, scanChunks, screenAccountExact, simulateBatchDispatch, simulateClosePosition, simulateDeployNewPool, simulateDeposit, simulateDispatch, simulateForceExercise, simulateLiquidate, simulateSFPMBurn, simulateSFPMMint, simulateSwapExactIn, simulateSwapExactOut, simulateWithdraw, slippageBpsToTickDistance, watchEvents };
10097
+ export { DEFAULT_MIN_SWAP_RATIO_BPS, DEFAULT_RECONNECT_CONFIG, MARKET_INDICATOR_PERIODS, REQUIRED_BASE_ERROR_SENTINEL, STRIKE_LADDER_TARGET_STRIKES, VARIANCE_RATIO_LAG, addPendingPosition, addTrackedChunks, apportion, assertCanBurn, assertCanForceExercise, assertCanLiquidate, assertCanMint, assertFresh, assertHealthy, assertLpPositionFunded, assertTradeable, buildCreditWrappedDispatch, buildSfpmSwapCalldata, buildSfpmSwapPlan, buildTemporaryLoanRecoveryDispatch, buildTokenShortfallRecoveryDispatch, calculateAccountGreeksPure, calculateMarketIndicator, calculateSpreadWad, calculateVarianceProfile, checkCollateralAcrossTicks, classifyStrategyGroups, classifyStrike, cleanupStalePendingPositions, clearPendingPositions, clearTrackedChunks, clearTradeHistory, collateralCurveTicks, collateralRuleKindFor, computeV4PoolId, confirmPendingPosition, convertToAssets, convertToShares, createEventPoller, createEventSubscription, createFlowNeutralTokenId, decodePanopticTokenURI, emptyLiquidateParams, encodePoolKeyBytes, encodeV3PoolKeyBytes, ensureSfpmV3PoolInitialized, estimateBlockNumbers, estimateCollateralBreakdown, estimateCollateralRequired, failPendingPosition, feeGrowthInsideX128, feesFromFeeGrowthDelta, fetchSfpmV3PoolId, fetchUniswapFeeData, getAccountBuyingPower, getAccountGreeks, getAccountHistory, getChunkLiquidities, getChunkSpreads, getClosedPositions, getCollateralCurve, getCollateralCurveInputs, getCollateralRequiredBase, getCollateralSharePrices, getCollateralTotalAssetsBatch, getDeltaHedgeParams, getEnforcedTickLimits, getExecutableLpMaxSize, getFactoryConstructMetadata, getFactoryOwnerOf, getFactoryTokenURI, getGuardianUnlockState, getHedgeLimits, getItmAmounts, getMarginBuffer, getMaxPositionSize, getMaxRedeem, getMaxWithdrawable, getNativeTokenPrice, getNotEnoughTokensError, getOpenPositionPreview, getPanopticPoolAddress, getPanopticPoolFromPoolId, getPendingPositions, getPoolCollateralAddresses, getPoolLiquidities, getPortfolioValue, getPositionChunkData, getPositionEnrichmentData, getPositionValueCurve, getPriceHistory, getRealizedPnL, getRequiredCreditForITM, getSafeMode, getStreamiaHistory, getSyncStatus, getTrackedChunks, getTradeHistory, getUniswapFeeHistory, getUniswapV3LpPositionState, getUniswapV3PoolFromId, getUniswapV3PoolInfo, getUniswapV3PoolLiquidities, getUniswapV4LpPositionState, getUniswapV4PoolBasicState, getUniswapV4PoolInfo, getUniswapV4PoolKeyFromId, getUniswapV4PoolLiquidities, interpolateBlocks, isGasError, isNonceError, isRetryableRpcError, isolateGroupTokenId, ladderStrikeSequence, logReturns, marketPnlInQuote, marketRiskFromValues, marketScenario, minePoolAddress, minePoolAddressLocalAsync, multicallRead, netLiquidationValueInQuote, optimizeTokenIdRiskPartners, parseCollateralLog, parsePoolLog, positionValueKey, positionValueTicks, prepareIndicatorCandles, preparePositionValueCurve, previewDeposit, previewMint, previewRedeem, previewWithdraw, quoteLiquidation, quoteOneTokenFlow, quoteSfpmSwap, quoteTemporaryLoanRecovery, quoteTokenShortfallRecovery, realizedBeta, removeTrackedChunks, resolveBlockNumbers, resolveLadderStrike, resolvePanopticPoolFromPoolId, resolveUniswapV4PoolKey, saveClosedPosition, scaleCollateralRequired, scanChunks, screenAccountExact, simulateBatchDispatch, simulateClosePosition, simulateDeployNewPool, simulateDeposit, simulateForceExercise, simulateLiquidate, simulateSFPMBurn, simulateSFPMMint, simulateSwapExactIn, simulateSwapExactOut, simulateWithdraw, slippageBpsToTickDistance, watchEvents };
@@ -6,6 +6,7 @@ declare const MAX_VAULT_PRIORITY_FEE_PER_GAS = 3000000000n;
6
6
  declare const MAX_STALE_DELTA_HEDGE_PRIORITY_FEE_PER_GAS = 8000000000n;
7
7
  declare const MAX_VAULT_TRANSACTION_GAS_COST = 15000000000000000n;
8
8
  type VaultTransactionFeeQuote = {
9
+ currentBaseFeePerGas?: bigint;
9
10
  maxFeePerGas: bigint;
10
11
  maxPriorityFeePerGas: bigint;
11
12
  minimumMaxFeePerGas: bigint;
@@ -1 +1 @@
1
- {"version":3,"file":"vault-transaction-fees.d.ts","names":["Chain","Client","Transport","MIN_VAULT_PRIORITY_FEE_PER_GAS","MAX_VAULT_PRIORITY_FEE_PER_GAS","MAX_STALE_DELTA_HEDGE_PRIORITY_FEE_PER_GAS","MAX_VAULT_TRANSACTION_GAS_COST","VaultTransactionFeeQuote","VaultDeltaHedgeFeeQuote","VaultSignedTransactionFeeCaps","VaultSignedTransactionFeeValidationResult","VaultTransactionFeeEstimationError","feeHistoryError","fallbackError","Error","VaultTransactionGasCostLimitError","gasLimit","maximumAffordableFeePerGas","minimumRequiredFeePerGas","VaultTransactionReplacementLimitError","code","requiredMaxFeePerGas","requiredMaxPriorityFeePerGas","FeeHistorySnapshot","FallbackFeeEstimate","getChainPriorityFeeFloor","clampPriorityFee","resolveFeeHistoryQuote","baseFeePerGas","reward","minimumPriorityFeePerGas","resolveDeltaHedgeFeeHistoryQuote","resolveRpcPriorityFeeQuote","rawPriorityFeePerGas","getVaultTransactionReplacementFeeQuote","originalQuote","historicalQuote","finalReplacement","staleBoundsReplacement","Pick","resolveFallbackQuote","estimatedMaxFeePerGas","estimatedPriorityFeePerGas","applyVaultTransactionGasCostLimit","bufferVaultTransactionGasEstimate","validateVaultSignedTransactionFeeCaps","resolveVaultTransactionFeeQuote","readFeeHistory","readFallbackEstimate","Promise","getVaultTransactionFeeQuote","chain","getVaultDeltaHedgeHistoricalFeeQuote","resolveVaultDeltaHedgeInitialFeeQuote","readRpcQuote","readHistoricalQuote","getVaultDeltaHedgeInitialFeeQuote","__transactionFeeTestUtils"],"sources":["../src/hypoVault/transactionFees.d.ts"],"sourcesContent":null,"mappings":"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"}
1
+ {"version":3,"file":"vault-transaction-fees.d.ts","names":["Chain","Client","Transport","MIN_VAULT_PRIORITY_FEE_PER_GAS","MAX_VAULT_PRIORITY_FEE_PER_GAS","MAX_STALE_DELTA_HEDGE_PRIORITY_FEE_PER_GAS","MAX_VAULT_TRANSACTION_GAS_COST","VaultTransactionFeeQuote","VaultDeltaHedgeFeeQuote","VaultSignedTransactionFeeCaps","VaultSignedTransactionFeeValidationResult","VaultTransactionFeeEstimationError","feeHistoryError","fallbackError","Error","VaultTransactionGasCostLimitError","gasLimit","maximumAffordableFeePerGas","minimumRequiredFeePerGas","VaultTransactionReplacementLimitError","code","requiredMaxFeePerGas","requiredMaxPriorityFeePerGas","FeeHistorySnapshot","FallbackFeeEstimate","getChainPriorityFeeFloor","clampPriorityFee","resolveFeeHistoryQuote","baseFeePerGas","reward","minimumPriorityFeePerGas","resolveDeltaHedgeFeeHistoryQuote","resolveRpcPriorityFeeQuote","rawPriorityFeePerGas","getVaultTransactionReplacementFeeQuote","originalQuote","historicalQuote","finalReplacement","staleBoundsReplacement","Pick","resolveFallbackQuote","estimatedMaxFeePerGas","estimatedPriorityFeePerGas","applyVaultTransactionGasCostLimit","bufferVaultTransactionGasEstimate","validateVaultSignedTransactionFeeCaps","resolveVaultTransactionFeeQuote","readFeeHistory","readFallbackEstimate","Promise","getVaultTransactionFeeQuote","chain","getVaultDeltaHedgeHistoricalFeeQuote","resolveVaultDeltaHedgeInitialFeeQuote","readRpcQuote","readHistoricalQuote","getVaultDeltaHedgeInitialFeeQuote","__transactionFeeTestUtils"],"sources":["../src/hypoVault/transactionFees.d.ts"],"sourcesContent":null,"mappings":"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"}
@@ -479,6 +479,7 @@ function resolveFeeHistoryQuote({ baseFeePerGas, reward, minimumPriorityFeePerGa
479
479
  const maxPriorityFeePerGas = clampPriorityFee(sampledPriorityFee, effectivePriorityFeeFloor);
480
480
  const bufferedBaseFee = ceilMultiplyFraction(baseFeePerGas[latestBaseFeeIndex], BASE_FEE_BUFFER_NUMERATOR, BASE_FEE_BUFFER_DENOMINATOR);
481
481
  return {
482
+ currentBaseFeePerGas: baseFeePerGas[latestBaseFeeIndex],
482
483
  maxFeePerGas: bufferedBaseFee + maxPriorityFeePerGas,
483
484
  maxPriorityFeePerGas,
484
485
  minimumMaxFeePerGas: bufferedBaseFee + effectivePriorityFeeFloor,
@@ -613,11 +614,15 @@ function validateVaultSignedTransactionFeeCaps(feeCaps, quote) {
613
614
  code: "GasCostTooHigh",
614
615
  reason: `Signed transaction maximum gas cost (${(gasLimit * maxFeePerGas).toString()} wei) must not exceed ${MAX_VAULT_TRANSACTION_GAS_COST.toString()} wei (0.015 ETH).`
615
616
  };
616
- if (quote !== void 0 && maxFeePerGas < quote.minimumMaxFeePerGas) return {
617
- valid: false,
618
- code: "MaxFeeTooLow",
619
- reason: `Signed transaction maxFeePerGas (${maxFeePerGas.toString()} wei) must be at least ${quote.minimumMaxFeePerGas.toString()} wei for the buffered next-block base fee and configured minimum priority fee.`
620
- };
617
+ if (quote !== void 0) {
618
+ const feeRequirementDescription = quote.currentBaseFeePerGas === void 0 ? "buffered next-block base fee" : "current base fee";
619
+ const minimumBroadcastMaxFeePerGas = quote.currentBaseFeePerGas === void 0 ? quote.minimumMaxFeePerGas : quote.currentBaseFeePerGas + minimumPriorityFeePerGas;
620
+ if (maxFeePerGas < minimumBroadcastMaxFeePerGas) return {
621
+ valid: false,
622
+ code: "MaxFeeTooLow",
623
+ reason: `Signed transaction maxFeePerGas (${maxFeePerGas.toString()} wei) must be at least ${minimumBroadcastMaxFeePerGas.toString()} wei for the ${feeRequirementDescription} and configured minimum priority fee.`
624
+ };
625
+ }
621
626
  return { valid: true };
622
627
  }
623
628
  async function resolveVaultTransactionFeeQuote({ readFeeHistory, readFallbackEstimate, minimumPriorityFeePerGas }) {