@panoptic-eng/sdk 1.0.70 → 1.0.72

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.
@@ -12877,69 +12877,6 @@ async function submitWriteRequest(params) {
12877
12877
  return createTxResult(client, hash);
12878
12878
  }
12879
12879
 
12880
- //#endregion
12881
- //#region src/panoptic/v2/reads/mintBuffer.ts
12882
- /**
12883
- * `RiskEngine.BP_DECREASE_BUFFER` — the numerator of the mint-time buffer.
12884
- *
12885
- * Exported so callers can display the constant; prefer {@link applyMintBuffer}
12886
- * over multiplying by it directly, which is how the rounding bug reappears.
12887
- */
12888
- const MINT_BUFFER = 10750000n;
12889
- /** `RiskEngine.DECIMALS` — the denominator {@link MINT_BUFFER} is taken over. */
12890
- const MINT_BUFFER_DENOMINATOR = 10000000n;
12891
- /** The compiled-in default, matching the deployed RiskEngine. */
12892
- const DEFAULT_MINT_BUFFER = {
12893
- numerator: MINT_BUFFER,
12894
- denominator: MINT_BUFFER_DENOMINATOR
12895
- };
12896
- /**
12897
- * Apply the mint buffer to ONE token's NATIVE requirement, rounding up exactly
12898
- * as `Math.mulDivRoundingUp` does on-chain.
12899
- *
12900
- * Call this on the native token0/token1 requirement, never on a quote-converted
12901
- * total — see the module docstring for why the order matters.
12902
- *
12903
- * @param required - Maintenance requirement in that token's own units
12904
- * @param buffer - Optional live on-chain ratio; defaults to {@link DEFAULT_MINT_BUFFER}
12905
- * @returns The mint-time requirement the solvency check enforces
12906
- */
12907
- function applyMintBuffer(required, buffer = DEFAULT_MINT_BUFFER) {
12908
- const { numerator, denominator } = buffer;
12909
- if (denominator <= 0n) throw new PanopticValidationError("applyMintBuffer: buffer denominator must be positive");
12910
- if (required <= 0n) return 0n;
12911
- return (required * numerator + denominator - 1n) / denominator;
12912
- }
12913
- /**
12914
- * Apply the mint buffer to both tokens' NATIVE requirements, independently.
12915
- *
12916
- * This is the shape the solvency check itself uses: two separate per-side
12917
- * comparisons, never a pooled total.
12918
- *
12919
- * @param required0 - Maintenance requirement in token0 units
12920
- * @param required1 - Maintenance requirement in token1 units
12921
- * @param buffer - Optional live on-chain ratio
12922
- * @returns `[buffered0, buffered1]`
12923
- */
12924
- function applyMintBufferPerToken(required0, required1, buffer = DEFAULT_MINT_BUFFER) {
12925
- return [applyMintBuffer(required0, buffer), applyMintBuffer(required1, buffer)];
12926
- }
12927
- /**
12928
- * Collateral still deployable on one side before the mint solvency check fails:
12929
- * `balance - bufferedRequired`, floored at zero.
12930
- *
12931
- * Both arguments must be in the SAME token's units.
12932
- *
12933
- * @param balance - That side's collateral balance
12934
- * @param required - That side's maintenance requirement (unbuffered)
12935
- * @param buffer - Optional live on-chain ratio
12936
- * @returns Mintable headroom, never negative
12937
- */
12938
- function mintableAfterBuffer(balance, required, buffer = DEFAULT_MINT_BUFFER) {
12939
- const requiredAtMint = applyMintBuffer(required, buffer);
12940
- return balance > requiredAtMint ? balance - requiredAtMint : 0n;
12941
- }
12942
-
12943
12880
  //#endregion
12944
12881
  //#region src/abis/multicall3.ts
12945
12882
  const Multicall3Abi = [
@@ -13366,10 +13303,248 @@ async function readBlockAndAggregate({ client, calls, blockNumber }) {
13366
13303
  };
13367
13304
  }
13368
13305
 
13306
+ //#endregion
13307
+ //#region src/panoptic/v2/reads/buyingPower.ts
13308
+ const Q128$3 = 1n << 128n;
13309
+ /** Immutable collateral tracker addresses, suitable for a pool-scoped cache. */
13310
+ async function getPoolCollateralAddresses(params) {
13311
+ const [collateralToken0, collateralToken1] = await multicall(params.client, {
13312
+ contracts: [{
13313
+ address: params.poolAddress,
13314
+ abi: panopticPoolV2Abi,
13315
+ functionName: "collateralToken0"
13316
+ }, {
13317
+ address: params.poolAddress,
13318
+ abi: panopticPoolV2Abi,
13319
+ functionName: "collateralToken1"
13320
+ }],
13321
+ blockNumber: params.blockNumber,
13322
+ allowFailure: false
13323
+ });
13324
+ return {
13325
+ collateralToken0,
13326
+ collateralToken1
13327
+ };
13328
+ }
13329
+ /**
13330
+ * Apply owed interest to one token's collateral the way `RiskEngine._getMargin`
13331
+ * does. Interest the balance can pay is deducted from the balance; interest it
13332
+ * cannot pay zeroes the balance and the uncovered remainder becomes additional
13333
+ * requirement in the same token, where cross-collateral conversion lets the
13334
+ * other token cover it.
13335
+ */
13336
+ function applyOwedInterest(assets, interestOwed) {
13337
+ if (interestOwed > assets) return {
13338
+ balance: 0n,
13339
+ requirementExtra: interestOwed - assets
13340
+ };
13341
+ return {
13342
+ balance: assets - interestOwed,
13343
+ requirementExtra: 0n
13344
+ };
13345
+ }
13346
+ function convert0to1$2(amount, sqrtPriceX96) {
13347
+ if (sqrtPriceX96 < Q128$3) return amount * sqrtPriceX96 * sqrtPriceX96 >> 192n;
13348
+ const sp2Hi = sqrtPriceX96 * sqrtPriceX96 >> 64n;
13349
+ return amount * sp2Hi >> 128n;
13350
+ }
13351
+ function convert1to0$2(amount, sqrtPriceX96) {
13352
+ if (sqrtPriceX96 < Q128$3) {
13353
+ const denom = sqrtPriceX96 * sqrtPriceX96;
13354
+ return amount * (1n << 192n) / denom;
13355
+ }
13356
+ const sp2Hi = sqrtPriceX96 * sqrtPriceX96 >> 64n;
13357
+ return amount * (1n << 128n) / sp2Hi;
13358
+ }
13359
+ /**
13360
+ * Get account-level buying power.
13361
+ *
13362
+ * Uses `CollateralTracker.assetsAndInterest` for collateral and owed interest
13363
+ * and `PanopticPool.getFullPositionsData.collateralRequirements[]` for the
13364
+ * per-position required margin — so loan tokenIds (width=0 shorts) contribute
13365
+ * to the requirement instead of being netted out of the balance, and owed
13366
+ * interest reduces headroom exactly as the RiskEngine solvency check does.
13367
+ *
13368
+ * Accepts a plain viem `Client` (not just `PublicClient`) so it works with wagmi's
13369
+ * `useClient()` without needing a cast.
13370
+ *
13371
+ * @param params - The parameters
13372
+ * @returns Account buying power data with optional block metadata
13373
+ */
13374
+ async function getAccountBuyingPower(params) {
13375
+ const { client, poolAddress, account, tokenIds } = params;
13376
+ const blockNumber = params.blockNumber ?? params._meta?.blockNumber;
13377
+ let collateralToken0;
13378
+ let collateralToken1;
13379
+ if (params.collateralAddresses) {
13380
+ collateralToken0 = params.collateralAddresses.collateralToken0;
13381
+ collateralToken1 = params.collateralAddresses.collateralToken1;
13382
+ } else {
13383
+ const addresses = await getPoolCollateralAddresses({
13384
+ client,
13385
+ poolAddress,
13386
+ blockNumber
13387
+ });
13388
+ collateralToken0 = addresses.collateralToken0;
13389
+ collateralToken1 = addresses.collateralToken1;
13390
+ }
13391
+ const calls = [
13392
+ {
13393
+ target: poolAddress,
13394
+ callData: encodeFunctionData({
13395
+ abi: panopticPoolV2Abi,
13396
+ functionName: "getCurrentTick"
13397
+ })
13398
+ },
13399
+ {
13400
+ target: collateralToken0,
13401
+ callData: encodeFunctionData({
13402
+ abi: collateralTrackerV2Abi,
13403
+ functionName: "assetsAndInterest",
13404
+ args: [account]
13405
+ })
13406
+ },
13407
+ {
13408
+ target: collateralToken1,
13409
+ callData: encodeFunctionData({
13410
+ abi: collateralTrackerV2Abi,
13411
+ functionName: "assetsAndInterest",
13412
+ args: [account]
13413
+ })
13414
+ }
13415
+ ];
13416
+ const positionDataIndex = tokenIds.length > 0 ? calls.length : null;
13417
+ if (positionDataIndex !== null) calls.push({
13418
+ target: poolAddress,
13419
+ callData: encodeFunctionData({
13420
+ abi: panopticPoolV2Abi,
13421
+ functionName: "getFullPositionsData",
13422
+ args: [
13423
+ account,
13424
+ true,
13425
+ tokenIds
13426
+ ]
13427
+ })
13428
+ });
13429
+ const { _meta, results } = await readBlockAndAggregate({
13430
+ client,
13431
+ calls,
13432
+ blockNumber
13433
+ });
13434
+ const currentTickResult = decodeFunctionResult({
13435
+ abi: panopticPoolV2Abi,
13436
+ functionName: "getCurrentTick",
13437
+ data: requireReturnData(results, 0, "PanopticPool.getCurrentTick")
13438
+ });
13439
+ const [rawAssets0, interest0] = decodeFunctionResult({
13440
+ abi: collateralTrackerV2Abi,
13441
+ functionName: "assetsAndInterest",
13442
+ data: requireReturnData(results, 1, "CollateralTracker.assetsAndInterest token0")
13443
+ });
13444
+ const [rawAssets1, interest1] = decodeFunctionResult({
13445
+ abi: collateralTrackerV2Abi,
13446
+ functionName: "assetsAndInterest",
13447
+ data: requireReturnData(results, 2, "CollateralTracker.assetsAndInterest token1")
13448
+ });
13449
+ const { balance: assets0, requirementExtra: interestDue0 } = applyOwedInterest(rawAssets0, interest0);
13450
+ const { balance: assets1, requirementExtra: interestDue1 } = applyOwedInterest(rawAssets1, interest1);
13451
+ const currentTick = BigInt(currentTickResult);
13452
+ const positionDataResult = positionDataIndex === null ? null : decodeFunctionResult({
13453
+ abi: panopticPoolV2Abi,
13454
+ functionName: "getFullPositionsData",
13455
+ data: requireReturnData(results, positionDataIndex, "PanopticPool.getFullPositionsData")
13456
+ });
13457
+ let required0Native = interestDue0;
13458
+ let required1Native = interestDue1;
13459
+ if (positionDataResult) {
13460
+ const collateralRequirements = positionDataResult[3];
13461
+ for (const packed of collateralRequirements) {
13462
+ const decoded = decodeLeftRightUnsigned(packed);
13463
+ required0Native += decoded.right;
13464
+ required1Native += decoded.left;
13465
+ }
13466
+ }
13467
+ const sqrtPriceX96 = tickToSqrtPriceX96(currentTick);
13468
+ const collateralBalance0 = assets0 + convert1to0$2(assets1, sqrtPriceX96);
13469
+ const requiredCollateral0 = required0Native + convert1to0$2(required1Native, sqrtPriceX96);
13470
+ const collateralBalance1 = assets1 + convert0to1$2(assets0, sqrtPriceX96);
13471
+ const requiredCollateral1 = required1Native + convert0to1$2(required0Native, sqrtPriceX96);
13472
+ return {
13473
+ collateralBalance0,
13474
+ requiredCollateral0,
13475
+ collateralBalance1,
13476
+ requiredCollateral1,
13477
+ _meta
13478
+ };
13479
+ }
13480
+
13481
+ //#endregion
13482
+ //#region src/panoptic/v2/reads/mintBuffer.ts
13483
+ /**
13484
+ * `RiskEngine.BP_DECREASE_BUFFER` — the numerator of the mint-time buffer.
13485
+ *
13486
+ * Exported so callers can display the constant; prefer {@link applyMintBuffer}
13487
+ * over multiplying by it directly, which is how the rounding bug reappears.
13488
+ */
13489
+ const MINT_BUFFER = 10750000n;
13490
+ /** `RiskEngine.DECIMALS` — the denominator {@link MINT_BUFFER} is taken over. */
13491
+ const MINT_BUFFER_DENOMINATOR = 10000000n;
13492
+ /** The compiled-in default, matching the deployed RiskEngine. */
13493
+ const DEFAULT_MINT_BUFFER = {
13494
+ numerator: MINT_BUFFER,
13495
+ denominator: MINT_BUFFER_DENOMINATOR
13496
+ };
13497
+ /**
13498
+ * Apply the mint buffer to ONE token's NATIVE requirement, rounding up exactly
13499
+ * as `Math.mulDivRoundingUp` does on-chain.
13500
+ *
13501
+ * Call this on the native token0/token1 requirement, never on a quote-converted
13502
+ * total — see the module docstring for why the order matters.
13503
+ *
13504
+ * @param required - Maintenance requirement in that token's own units
13505
+ * @param buffer - Optional live on-chain ratio; defaults to {@link DEFAULT_MINT_BUFFER}
13506
+ * @returns The mint-time requirement the solvency check enforces
13507
+ */
13508
+ function applyMintBuffer(required, buffer = DEFAULT_MINT_BUFFER) {
13509
+ const { numerator, denominator } = buffer;
13510
+ if (denominator <= 0n) throw new PanopticValidationError("applyMintBuffer: buffer denominator must be positive");
13511
+ if (required <= 0n) return 0n;
13512
+ return (required * numerator + denominator - 1n) / denominator;
13513
+ }
13514
+ /**
13515
+ * Apply the mint buffer to both tokens' NATIVE requirements, independently.
13516
+ *
13517
+ * This is the shape the solvency check itself uses: two separate per-side
13518
+ * comparisons, never a pooled total.
13519
+ *
13520
+ * @param required0 - Maintenance requirement in token0 units
13521
+ * @param required1 - Maintenance requirement in token1 units
13522
+ * @param buffer - Optional live on-chain ratio
13523
+ * @returns `[buffered0, buffered1]`
13524
+ */
13525
+ function applyMintBufferPerToken(required0, required1, buffer = DEFAULT_MINT_BUFFER) {
13526
+ return [applyMintBuffer(required0, buffer), applyMintBuffer(required1, buffer)];
13527
+ }
13528
+ /**
13529
+ * Collateral still deployable on one side before the mint solvency check fails:
13530
+ * `balance - bufferedRequired`, floored at zero.
13531
+ *
13532
+ * Both arguments must be in the SAME token's units.
13533
+ *
13534
+ * @param balance - That side's collateral balance
13535
+ * @param required - That side's maintenance requirement (unbuffered)
13536
+ * @param buffer - Optional live on-chain ratio
13537
+ * @returns Mintable headroom, never negative
13538
+ */
13539
+ function mintableAfterBuffer(balance, required, buffer = DEFAULT_MINT_BUFFER) {
13540
+ const requiredAtMint = applyMintBuffer(required, buffer);
13541
+ return balance > requiredAtMint ? balance - requiredAtMint : 0n;
13542
+ }
13543
+
13369
13544
  //#endregion
13370
13545
  //#region src/panoptic/v2/reads/margin.ts
13371
13546
  const FP96$2 = 1n << 96n;
13372
- const Q128$3 = 1n << 128n;
13547
+ const Q128$2 = 1n << 128n;
13373
13548
  /** Cap for a usage ratio with no collateral behind it. */
13374
13549
  const MAX_USAGE_BPS = 1000000n;
13375
13550
  const bigintMax = (a, b) => a > b ? a : b;
@@ -13380,16 +13555,16 @@ const bigintMin = (a, b) => a < b ? a : b;
13380
13555
  * Matches the on-chain `PanopticMath.convert0to1` truncation, with an
13381
13556
  * overflow-safe branch when `sqrtPriceX96^2` would not fit in uint256.
13382
13557
  */
13383
- function convert0to1$2(amount, sqrtPriceX96) {
13384
- if (sqrtPriceX96 < Q128$3) return amount * sqrtPriceX96 * sqrtPriceX96 >> 192n;
13558
+ function convert0to1$1(amount, sqrtPriceX96) {
13559
+ if (sqrtPriceX96 < Q128$2) return amount * sqrtPriceX96 * sqrtPriceX96 >> 192n;
13385
13560
  const sp2Hi = sqrtPriceX96 * sqrtPriceX96 >> 64n;
13386
13561
  return amount * sp2Hi >> 128n;
13387
13562
  }
13388
13563
  /**
13389
13564
  * Convert a token1 amount to its token0-equivalent at the given sqrtPriceX96.
13390
13565
  */
13391
- function convert1to0$2(amount, sqrtPriceX96) {
13392
- if (sqrtPriceX96 < Q128$3) {
13566
+ function convert1to0$1(amount, sqrtPriceX96) {
13567
+ if (sqrtPriceX96 < Q128$2) {
13393
13568
  const denom = sqrtPriceX96 * sqrtPriceX96;
13394
13569
  return amount * (1n << 192n) / denom;
13395
13570
  }
@@ -13402,7 +13577,7 @@ function convert1to0$2(amount, sqrtPriceX96) {
13402
13577
  * Reads, all pinned to the same block:
13403
13578
  * - `getCurrentTick` (sequencing dependency for sqrtPrice conversion)
13404
13579
  * - `getFullPositionsData(account, true, tokenIds)` → collateralRequirements
13405
- * - `CollateralTracker.assetsOf(account)` on both trackers → gross collateral
13580
+ * - `CollateralTracker.assetsAndInterest(account)` on both trackers → collateral and owed interest
13406
13581
  * - `PanopticQuery.getLiquidationPrices(...)` → liquidation boundaries
13407
13582
  *
13408
13583
  * @param params - The parameters
@@ -13483,6 +13658,14 @@ function requireMulticallResult(results, index, label) {
13483
13658
  if (result.status === "failure") throw result.error;
13484
13659
  return result.result;
13485
13660
  }
13661
+ function requireAssetsAndInterestResult(results, index, label) {
13662
+ const result = requireMulticallResult(results, index, label);
13663
+ if (!Array.isArray(result) || result.length < 2 || typeof result[0] !== "bigint" || typeof result[1] !== "bigint") throw new PanopticError(`${label} returned an invalid value`);
13664
+ return {
13665
+ assets: result[0],
13666
+ interest: result[1]
13667
+ };
13668
+ }
13486
13669
  function requireBigIntResult(results, index, label) {
13487
13670
  const result = requireMulticallResult(results, index, label);
13488
13671
  if (typeof result !== "bigint" && typeof result !== "number") throw new PanopticError(`${label} returned an invalid value`);
@@ -13499,13 +13682,13 @@ function prepareMarginBufferRead({ poolAddress, account, tokenIds, queryAddress,
13499
13682
  {
13500
13683
  address: collateralAddresses.collateralToken0,
13501
13684
  abi: collateralTrackerV2Abi,
13502
- functionName: "assetsOf",
13685
+ functionName: "assetsAndInterest",
13503
13686
  args: [account]
13504
13687
  },
13505
13688
  {
13506
13689
  address: collateralAddresses.collateralToken1,
13507
13690
  abi: collateralTrackerV2Abi,
13508
- functionName: "assetsOf",
13691
+ functionName: "assetsAndInterest",
13509
13692
  args: [account]
13510
13693
  }
13511
13694
  ];
@@ -13556,8 +13739,10 @@ function prepareMarginBufferRead({ poolAddress, account, tokenIds, queryAddress,
13556
13739
  }
13557
13740
  function decodeMarginBufferResults({ results, _meta, positionDataIndex, liqPricesIndex, checkCollateralIndex, mintBuffer }) {
13558
13741
  const currentTick = requireBigIntResult(results, 0, "PanopticPool.getCurrentTick");
13559
- const assets0 = requireBigIntResult(results, 1, "CollateralTracker.assetsOf token0");
13560
- const assets1 = requireBigIntResult(results, 2, "CollateralTracker.assetsOf token1");
13742
+ const tracker0 = requireAssetsAndInterestResult(results, 1, "CollateralTracker.assetsAndInterest token0");
13743
+ const tracker1 = requireAssetsAndInterestResult(results, 2, "CollateralTracker.assetsAndInterest token1");
13744
+ const { balance: assets0, requirementExtra: interestDue0 } = applyOwedInterest(tracker0.assets, tracker0.interest);
13745
+ const { balance: assets1, requirementExtra: interestDue1 } = applyOwedInterest(tracker1.assets, tracker1.interest);
13561
13746
  const positionDataResult = positionDataIndex === null ? null : requireMulticallResult(results, positionDataIndex, "PanopticPool.getFullPositionsData");
13562
13747
  const liqPricesResult = liqPricesIndex === null ? null : requireMulticallResult(results, liqPricesIndex, "PanopticQuery.getLiquidationPrices");
13563
13748
  const checkCollateralResult = checkCollateralIndex === null ? null : requireMulticallResult(results, checkCollateralIndex, "PanopticQuery.checkCollateral");
@@ -13580,8 +13765,8 @@ function decodeMarginBufferResults({ results, _meta, positionDataIndex, liqPrice
13580
13765
  const mintable1 = mintable(balances1[0], requireds1[0]);
13581
13766
  if (mintable0 !== null || mintable1 !== null) mintableMarginBinding = mintable0 === null ? mintable1 : mintable1 === null ? mintable0 : bigintMin(mintable0, mintable1);
13582
13767
  }
13583
- let required0Native = 0n;
13584
- let required1Native = 0n;
13768
+ let required0Native = interestDue0;
13769
+ let required1Native = interestDue1;
13585
13770
  if (positionDataResult) {
13586
13771
  const collateralRequirements = positionDataResult[3];
13587
13772
  for (const packed of collateralRequirements) {
@@ -13592,10 +13777,10 @@ function decodeMarginBufferResults({ results, _meta, positionDataIndex, liqPrice
13592
13777
  }
13593
13778
  const sqrtPriceX96 = tickToSqrtPriceX96(currentTick);
13594
13779
  const denominatedInToken = sqrtPriceX96 < FP96$2 ? 0 : 1;
13595
- const currentMargin0 = assets0 + convert1to0$2(assets1, sqrtPriceX96);
13596
- const requiredMargin0 = required0Native + convert1to0$2(required1Native, sqrtPriceX96);
13597
- const currentMargin1 = assets1 + convert0to1$2(assets0, sqrtPriceX96);
13598
- const requiredMargin1 = required1Native + convert0to1$2(required0Native, sqrtPriceX96);
13780
+ const currentMargin0 = assets0 + convert1to0$1(assets1, sqrtPriceX96);
13781
+ const requiredMargin0 = required0Native + convert1to0$1(required1Native, sqrtPriceX96);
13782
+ const currentMargin1 = assets1 + convert0to1$1(assets0, sqrtPriceX96);
13783
+ const requiredMargin1 = required1Native + convert0to1$1(required0Native, sqrtPriceX96);
13599
13784
  const buffer0 = currentMargin0 - requiredMargin0;
13600
13785
  const buffer1 = currentMargin1 - requiredMargin1;
13601
13786
  const bufferPercent0 = requiredMargin0 === 0n ? null : buffer0 * 10000n / requiredMargin0;
@@ -19495,14 +19680,14 @@ async function getForfeitablePremium(params) {
19495
19680
  //#endregion
19496
19681
  //#region src/panoptic/v2/reads/checks.ts
19497
19682
  const FP96$1 = 1n << 96n;
19498
- const Q128$2 = 1n << 128n;
19499
- function convert0to1$1(amount, sqrtPriceX96) {
19500
- if (sqrtPriceX96 < Q128$2) return amount * sqrtPriceX96 * sqrtPriceX96 >> 192n;
19683
+ const Q128$1 = 1n << 128n;
19684
+ function convert0to1(amount, sqrtPriceX96) {
19685
+ if (sqrtPriceX96 < Q128$1) return amount * sqrtPriceX96 * sqrtPriceX96 >> 192n;
19501
19686
  const sp2Hi = sqrtPriceX96 * sqrtPriceX96 >> 64n;
19502
19687
  return amount * sp2Hi >> 128n;
19503
19688
  }
19504
- function convert1to0$1(amount, sqrtPriceX96) {
19505
- if (sqrtPriceX96 < Q128$2) {
19689
+ function convert1to0(amount, sqrtPriceX96) {
19690
+ if (sqrtPriceX96 < Q128$1) {
19506
19691
  const denom = sqrtPriceX96 * sqrtPriceX96;
19507
19692
  return amount * (1n << 192n) / denom;
19508
19693
  }
@@ -19512,7 +19697,7 @@ function convert1to0$1(amount, sqrtPriceX96) {
19512
19697
  /**
19513
19698
  * Check if an account is liquidatable with detailed margin breakdown.
19514
19699
  *
19515
- * Sources gross collateral from `CollateralTracker.assetsOf` and per-position
19700
+ * Sources collateral and owed interest from `CollateralTracker.assetsAndInterest` and per-position
19516
19701
  * required margin from `PanopticPool.getFullPositionsData.collateralRequirements[]`,
19517
19702
  * cross-converted to each token denomination at `atTick`. Loan tokenIds
19518
19703
  * (width=0 shorts) contribute correctly to required margin.
@@ -19573,7 +19758,7 @@ async function isLiquidatable(params) {
19573
19758
  target: collateralToken0,
19574
19759
  callData: encodeFunctionData({
19575
19760
  abi: collateralTrackerV2Abi,
19576
- functionName: "assetsOf",
19761
+ functionName: "assetsAndInterest",
19577
19762
  args: [account]
19578
19763
  })
19579
19764
  });
@@ -19582,7 +19767,7 @@ async function isLiquidatable(params) {
19582
19767
  target: collateralToken1,
19583
19768
  callData: encodeFunctionData({
19584
19769
  abi: collateralTrackerV2Abi,
19585
- functionName: "assetsOf",
19770
+ functionName: "assetsAndInterest",
19586
19771
  args: [account]
19587
19772
  })
19588
19773
  });
@@ -19613,23 +19798,25 @@ async function isLiquidatable(params) {
19613
19798
  data: requireReturnData(results, currentTickIndex, "PanopticPool.getCurrentTick")
19614
19799
  }));
19615
19800
  }
19616
- const assets0 = decodeFunctionResult({
19801
+ const [rawAssets0, interest0] = decodeFunctionResult({
19617
19802
  abi: collateralTrackerV2Abi,
19618
- functionName: "assetsOf",
19619
- data: requireReturnData(results, assets0Index, "CollateralTracker.assetsOf token0")
19803
+ functionName: "assetsAndInterest",
19804
+ data: requireReturnData(results, assets0Index, "CollateralTracker.assetsAndInterest token0")
19620
19805
  });
19621
- const assets1 = decodeFunctionResult({
19806
+ const [rawAssets1, interest1] = decodeFunctionResult({
19622
19807
  abi: collateralTrackerV2Abi,
19623
- functionName: "assetsOf",
19624
- data: requireReturnData(results, assets1Index, "CollateralTracker.assetsOf token1")
19808
+ functionName: "assetsAndInterest",
19809
+ data: requireReturnData(results, assets1Index, "CollateralTracker.assetsAndInterest token1")
19625
19810
  });
19811
+ const { balance: assets0, requirementExtra: interestDue0 } = applyOwedInterest(rawAssets0, interest0);
19812
+ const { balance: assets1, requirementExtra: interestDue1 } = applyOwedInterest(rawAssets1, interest1);
19626
19813
  const positionDataResult = positionDataIndex === null ? null : decodeFunctionResult({
19627
19814
  abi: panopticPoolV2Abi,
19628
19815
  functionName: "getFullPositionsData",
19629
19816
  data: requireReturnData(results, positionDataIndex, "PanopticPool.getFullPositionsData")
19630
19817
  });
19631
- let required0Native = 0n;
19632
- let required1Native = 0n;
19818
+ let required0Native = interestDue0;
19819
+ let required1Native = interestDue1;
19633
19820
  if (positionDataResult) {
19634
19821
  const collateralRequirements = positionDataResult[3];
19635
19822
  for (const packed of collateralRequirements) {
@@ -19639,10 +19826,10 @@ async function isLiquidatable(params) {
19639
19826
  }
19640
19827
  }
19641
19828
  const sqrtPriceX96 = tickToSqrtPriceX96(effectiveTick);
19642
- const currentMargin0 = assets0 + convert1to0$1(assets1, sqrtPriceX96);
19643
- const requiredMargin0 = required0Native + convert1to0$1(required1Native, sqrtPriceX96);
19644
- const currentMargin1 = assets1 + convert0to1$1(assets0, sqrtPriceX96);
19645
- const requiredMargin1 = required1Native + convert0to1$1(required0Native, sqrtPriceX96);
19829
+ const currentMargin0 = assets0 + convert1to0(assets1, sqrtPriceX96);
19830
+ const requiredMargin0 = required0Native + convert1to0(required1Native, sqrtPriceX96);
19831
+ const currentMargin1 = assets1 + convert0to1(assets0, sqrtPriceX96);
19832
+ const requiredMargin1 = required1Native + convert0to1(required0Native, sqrtPriceX96);
19646
19833
  const marginShortfall0 = requiredMargin0 - currentMargin0;
19647
19834
  const marginShortfall1 = requiredMargin1 - currentMargin1;
19648
19835
  const denominatedInToken = sqrtPriceX96 < FP96$1 ? 0n : 1n;
@@ -22619,161 +22806,6 @@ async function getCollateralTotalAssetsBatch(client, collateralTrackerAddresses,
22619
22806
  }
22620
22807
  }
22621
22808
 
22622
- //#endregion
22623
- //#region src/panoptic/v2/reads/buyingPower.ts
22624
- const Q128$1 = 1n << 128n;
22625
- /** Immutable collateral tracker addresses, suitable for a pool-scoped cache. */
22626
- async function getPoolCollateralAddresses(params) {
22627
- const [collateralToken0, collateralToken1] = await multicall(params.client, {
22628
- contracts: [{
22629
- address: params.poolAddress,
22630
- abi: panopticPoolV2Abi,
22631
- functionName: "collateralToken0"
22632
- }, {
22633
- address: params.poolAddress,
22634
- abi: panopticPoolV2Abi,
22635
- functionName: "collateralToken1"
22636
- }],
22637
- blockNumber: params.blockNumber,
22638
- allowFailure: false
22639
- });
22640
- return {
22641
- collateralToken0,
22642
- collateralToken1
22643
- };
22644
- }
22645
- function convert0to1(amount, sqrtPriceX96) {
22646
- if (sqrtPriceX96 < Q128$1) return amount * sqrtPriceX96 * sqrtPriceX96 >> 192n;
22647
- const sp2Hi = sqrtPriceX96 * sqrtPriceX96 >> 64n;
22648
- return amount * sp2Hi >> 128n;
22649
- }
22650
- function convert1to0(amount, sqrtPriceX96) {
22651
- if (sqrtPriceX96 < Q128$1) {
22652
- const denom = sqrtPriceX96 * sqrtPriceX96;
22653
- return amount * (1n << 192n) / denom;
22654
- }
22655
- const sp2Hi = sqrtPriceX96 * sqrtPriceX96 >> 64n;
22656
- return amount * (1n << 128n) / sp2Hi;
22657
- }
22658
- /**
22659
- * Get account-level buying power.
22660
- *
22661
- * Uses {@link https://github.com/panoptic-xyz CollateralTracker.assetsOf} for
22662
- * gross collateral and `PanopticPool.getFullPositionsData.collateralRequirements[]`
22663
- * for the per-position required margin — so loan tokenIds (width=0 shorts)
22664
- * contribute to the requirement instead of being netted out of the balance.
22665
- *
22666
- * Accepts a plain viem `Client` (not just `PublicClient`) so it works with wagmi's
22667
- * `useClient()` without needing a cast.
22668
- *
22669
- * @param params - The parameters
22670
- * @returns Account buying power data with optional block metadata
22671
- */
22672
- async function getAccountBuyingPower(params) {
22673
- const { client, poolAddress, account, tokenIds } = params;
22674
- const blockNumber = params.blockNumber ?? params._meta?.blockNumber;
22675
- let collateralToken0;
22676
- let collateralToken1;
22677
- if (params.collateralAddresses) {
22678
- collateralToken0 = params.collateralAddresses.collateralToken0;
22679
- collateralToken1 = params.collateralAddresses.collateralToken1;
22680
- } else {
22681
- const addresses = await getPoolCollateralAddresses({
22682
- client,
22683
- poolAddress,
22684
- blockNumber
22685
- });
22686
- collateralToken0 = addresses.collateralToken0;
22687
- collateralToken1 = addresses.collateralToken1;
22688
- }
22689
- const calls = [
22690
- {
22691
- target: poolAddress,
22692
- callData: encodeFunctionData({
22693
- abi: panopticPoolV2Abi,
22694
- functionName: "getCurrentTick"
22695
- })
22696
- },
22697
- {
22698
- target: collateralToken0,
22699
- callData: encodeFunctionData({
22700
- abi: collateralTrackerV2Abi,
22701
- functionName: "assetsOf",
22702
- args: [account]
22703
- })
22704
- },
22705
- {
22706
- target: collateralToken1,
22707
- callData: encodeFunctionData({
22708
- abi: collateralTrackerV2Abi,
22709
- functionName: "assetsOf",
22710
- args: [account]
22711
- })
22712
- }
22713
- ];
22714
- const positionDataIndex = tokenIds.length > 0 ? calls.length : null;
22715
- if (positionDataIndex !== null) calls.push({
22716
- target: poolAddress,
22717
- callData: encodeFunctionData({
22718
- abi: panopticPoolV2Abi,
22719
- functionName: "getFullPositionsData",
22720
- args: [
22721
- account,
22722
- true,
22723
- tokenIds
22724
- ]
22725
- })
22726
- });
22727
- const { _meta, results } = await readBlockAndAggregate({
22728
- client,
22729
- calls,
22730
- blockNumber
22731
- });
22732
- const currentTickResult = decodeFunctionResult({
22733
- abi: panopticPoolV2Abi,
22734
- functionName: "getCurrentTick",
22735
- data: requireReturnData(results, 0, "PanopticPool.getCurrentTick")
22736
- });
22737
- const assets0 = decodeFunctionResult({
22738
- abi: collateralTrackerV2Abi,
22739
- functionName: "assetsOf",
22740
- data: requireReturnData(results, 1, "CollateralTracker.assetsOf token0")
22741
- });
22742
- const assets1 = decodeFunctionResult({
22743
- abi: collateralTrackerV2Abi,
22744
- functionName: "assetsOf",
22745
- data: requireReturnData(results, 2, "CollateralTracker.assetsOf token1")
22746
- });
22747
- const currentTick = BigInt(currentTickResult);
22748
- const positionDataResult = positionDataIndex === null ? null : decodeFunctionResult({
22749
- abi: panopticPoolV2Abi,
22750
- functionName: "getFullPositionsData",
22751
- data: requireReturnData(results, positionDataIndex, "PanopticPool.getFullPositionsData")
22752
- });
22753
- let required0Native = 0n;
22754
- let required1Native = 0n;
22755
- if (positionDataResult) {
22756
- const collateralRequirements = positionDataResult[3];
22757
- for (const packed of collateralRequirements) {
22758
- const decoded = decodeLeftRightUnsigned(packed);
22759
- required0Native += decoded.right;
22760
- required1Native += decoded.left;
22761
- }
22762
- }
22763
- const sqrtPriceX96 = tickToSqrtPriceX96(currentTick);
22764
- const collateralBalance0 = assets0 + convert1to0(assets1, sqrtPriceX96);
22765
- const requiredCollateral0 = required0Native + convert1to0(required1Native, sqrtPriceX96);
22766
- const collateralBalance1 = assets1 + convert0to1(assets0, sqrtPriceX96);
22767
- const requiredCollateral1 = required1Native + convert0to1(required0Native, sqrtPriceX96);
22768
- return {
22769
- collateralBalance0,
22770
- requiredCollateral0,
22771
- collateralBalance1,
22772
- requiredCollateral1,
22773
- _meta
22774
- };
22775
- }
22776
-
22777
22809
  //#endregion
22778
22810
  //#region src/panoptic/v2/simulations/simulateOpenPosition.ts
22779
22811
  /**
@@ -34677,5 +34709,5 @@ async function getPositionVolatilityHistory({ client, poolAddress, account, toke
34677
34709
  }
34678
34710
 
34679
34711
  //#endregion
34680
- 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, 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, 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, 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, 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, utilizationBpsToWad, utilizationPctToWad, validateBatch, validateBuilderCode, validatePoolId, valuePositionAccrual, verifyBlockContinuity, watchEvents, watchPoolSwaps, wethWrapAbi, withdraw, withdrawAndWait, withdrawWithPositions, withdrawWithPositionsAndWait, wrapEth, wrapEthAndWait, wrapXstock, wrapXstockAndWait, xstockWrapperAbi };
34712
+ 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, 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, getLegLiquidityRange, getLegNetValueWidth0, getLegTokenInventory, 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, 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, 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, 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, utilizationBpsToWad, utilizationPctToWad, validateBatch, validateBuilderCode, validatePoolId, valuePositionAccrual, verifyBlockContinuity, watchEvents, watchPoolSwaps, wethWrapAbi, withdraw, withdrawAndWait, withdrawWithPositions, withdrawWithPositionsAndWait, wrapEth, wrapEthAndWait, wrapXstock, wrapXstockAndWait, xstockWrapperAbi };
34681
34713
  //# sourceMappingURL=index.js.map