@panoptic-eng/sdk 1.0.71 → 1.0.73

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.
@@ -12880,69 +12880,6 @@ async function submitWriteRequest(params) {
12880
12880
  return createTxResult(client, hash);
12881
12881
  }
12882
12882
 
12883
- //#endregion
12884
- //#region src/panoptic/v2/reads/mintBuffer.ts
12885
- /**
12886
- * `RiskEngine.BP_DECREASE_BUFFER` — the numerator of the mint-time buffer.
12887
- *
12888
- * Exported so callers can display the constant; prefer {@link applyMintBuffer}
12889
- * over multiplying by it directly, which is how the rounding bug reappears.
12890
- */
12891
- const MINT_BUFFER = 10750000n;
12892
- /** `RiskEngine.DECIMALS` — the denominator {@link MINT_BUFFER} is taken over. */
12893
- const MINT_BUFFER_DENOMINATOR = 10000000n;
12894
- /** The compiled-in default, matching the deployed RiskEngine. */
12895
- const DEFAULT_MINT_BUFFER = {
12896
- numerator: MINT_BUFFER,
12897
- denominator: MINT_BUFFER_DENOMINATOR
12898
- };
12899
- /**
12900
- * Apply the mint buffer to ONE token's NATIVE requirement, rounding up exactly
12901
- * as `Math.mulDivRoundingUp` does on-chain.
12902
- *
12903
- * Call this on the native token0/token1 requirement, never on a quote-converted
12904
- * total — see the module docstring for why the order matters.
12905
- *
12906
- * @param required - Maintenance requirement in that token's own units
12907
- * @param buffer - Optional live on-chain ratio; defaults to {@link DEFAULT_MINT_BUFFER}
12908
- * @returns The mint-time requirement the solvency check enforces
12909
- */
12910
- function applyMintBuffer(required, buffer = DEFAULT_MINT_BUFFER) {
12911
- const { numerator, denominator } = buffer;
12912
- if (denominator <= 0n) throw new PanopticValidationError("applyMintBuffer: buffer denominator must be positive");
12913
- if (required <= 0n) return 0n;
12914
- return (required * numerator + denominator - 1n) / denominator;
12915
- }
12916
- /**
12917
- * Apply the mint buffer to both tokens' NATIVE requirements, independently.
12918
- *
12919
- * This is the shape the solvency check itself uses: two separate per-side
12920
- * comparisons, never a pooled total.
12921
- *
12922
- * @param required0 - Maintenance requirement in token0 units
12923
- * @param required1 - Maintenance requirement in token1 units
12924
- * @param buffer - Optional live on-chain ratio
12925
- * @returns `[buffered0, buffered1]`
12926
- */
12927
- function applyMintBufferPerToken(required0, required1, buffer = DEFAULT_MINT_BUFFER) {
12928
- return [applyMintBuffer(required0, buffer), applyMintBuffer(required1, buffer)];
12929
- }
12930
- /**
12931
- * Collateral still deployable on one side before the mint solvency check fails:
12932
- * `balance - bufferedRequired`, floored at zero.
12933
- *
12934
- * Both arguments must be in the SAME token's units.
12935
- *
12936
- * @param balance - That side's collateral balance
12937
- * @param required - That side's maintenance requirement (unbuffered)
12938
- * @param buffer - Optional live on-chain ratio
12939
- * @returns Mintable headroom, never negative
12940
- */
12941
- function mintableAfterBuffer(balance, required, buffer = DEFAULT_MINT_BUFFER) {
12942
- const requiredAtMint = applyMintBuffer(required, buffer);
12943
- return balance > requiredAtMint ? balance - requiredAtMint : 0n;
12944
- }
12945
-
12946
12883
  //#endregion
12947
12884
  //#region src/abis/multicall3.ts
12948
12885
  const Multicall3Abi = [
@@ -13369,10 +13306,248 @@ async function readBlockAndAggregate({ client, calls, blockNumber }) {
13369
13306
  };
13370
13307
  }
13371
13308
 
13309
+ //#endregion
13310
+ //#region src/panoptic/v2/reads/buyingPower.ts
13311
+ const Q128$3 = 1n << 128n;
13312
+ /** Immutable collateral tracker addresses, suitable for a pool-scoped cache. */
13313
+ async function getPoolCollateralAddresses(params) {
13314
+ const [collateralToken0, collateralToken1] = await multicall(params.client, {
13315
+ contracts: [{
13316
+ address: params.poolAddress,
13317
+ abi: panopticPoolV2Abi,
13318
+ functionName: "collateralToken0"
13319
+ }, {
13320
+ address: params.poolAddress,
13321
+ abi: panopticPoolV2Abi,
13322
+ functionName: "collateralToken1"
13323
+ }],
13324
+ blockNumber: params.blockNumber,
13325
+ allowFailure: false
13326
+ });
13327
+ return {
13328
+ collateralToken0,
13329
+ collateralToken1
13330
+ };
13331
+ }
13332
+ /**
13333
+ * Apply owed interest to one token's collateral the way `RiskEngine._getMargin`
13334
+ * does. Interest the balance can pay is deducted from the balance; interest it
13335
+ * cannot pay zeroes the balance and the uncovered remainder becomes additional
13336
+ * requirement in the same token, where cross-collateral conversion lets the
13337
+ * other token cover it.
13338
+ */
13339
+ function applyOwedInterest(assets, interestOwed) {
13340
+ if (interestOwed > assets) return {
13341
+ balance: 0n,
13342
+ requirementExtra: interestOwed - assets
13343
+ };
13344
+ return {
13345
+ balance: assets - interestOwed,
13346
+ requirementExtra: 0n
13347
+ };
13348
+ }
13349
+ function convert0to1$2(amount, sqrtPriceX96) {
13350
+ if (sqrtPriceX96 < Q128$3) return amount * sqrtPriceX96 * sqrtPriceX96 >> 192n;
13351
+ const sp2Hi = sqrtPriceX96 * sqrtPriceX96 >> 64n;
13352
+ return amount * sp2Hi >> 128n;
13353
+ }
13354
+ function convert1to0$2(amount, sqrtPriceX96) {
13355
+ if (sqrtPriceX96 < Q128$3) {
13356
+ const denom = sqrtPriceX96 * sqrtPriceX96;
13357
+ return amount * (1n << 192n) / denom;
13358
+ }
13359
+ const sp2Hi = sqrtPriceX96 * sqrtPriceX96 >> 64n;
13360
+ return amount * (1n << 128n) / sp2Hi;
13361
+ }
13362
+ /**
13363
+ * Get account-level buying power.
13364
+ *
13365
+ * Uses `CollateralTracker.assetsAndInterest` for collateral and owed interest
13366
+ * and `PanopticPool.getFullPositionsData.collateralRequirements[]` for the
13367
+ * per-position required margin — so loan tokenIds (width=0 shorts) contribute
13368
+ * to the requirement instead of being netted out of the balance, and owed
13369
+ * interest reduces headroom exactly as the RiskEngine solvency check does.
13370
+ *
13371
+ * Accepts a plain viem `Client` (not just `PublicClient`) so it works with wagmi's
13372
+ * `useClient()` without needing a cast.
13373
+ *
13374
+ * @param params - The parameters
13375
+ * @returns Account buying power data with optional block metadata
13376
+ */
13377
+ async function getAccountBuyingPower(params) {
13378
+ const { client, poolAddress, account, tokenIds } = params;
13379
+ const blockNumber = params.blockNumber ?? params._meta?.blockNumber;
13380
+ let collateralToken0;
13381
+ let collateralToken1;
13382
+ if (params.collateralAddresses) {
13383
+ collateralToken0 = params.collateralAddresses.collateralToken0;
13384
+ collateralToken1 = params.collateralAddresses.collateralToken1;
13385
+ } else {
13386
+ const addresses = await getPoolCollateralAddresses({
13387
+ client,
13388
+ poolAddress,
13389
+ blockNumber
13390
+ });
13391
+ collateralToken0 = addresses.collateralToken0;
13392
+ collateralToken1 = addresses.collateralToken1;
13393
+ }
13394
+ const calls = [
13395
+ {
13396
+ target: poolAddress,
13397
+ callData: encodeFunctionData({
13398
+ abi: panopticPoolV2Abi,
13399
+ functionName: "getCurrentTick"
13400
+ })
13401
+ },
13402
+ {
13403
+ target: collateralToken0,
13404
+ callData: encodeFunctionData({
13405
+ abi: collateralTrackerV2Abi,
13406
+ functionName: "assetsAndInterest",
13407
+ args: [account]
13408
+ })
13409
+ },
13410
+ {
13411
+ target: collateralToken1,
13412
+ callData: encodeFunctionData({
13413
+ abi: collateralTrackerV2Abi,
13414
+ functionName: "assetsAndInterest",
13415
+ args: [account]
13416
+ })
13417
+ }
13418
+ ];
13419
+ const positionDataIndex = tokenIds.length > 0 ? calls.length : null;
13420
+ if (positionDataIndex !== null) calls.push({
13421
+ target: poolAddress,
13422
+ callData: encodeFunctionData({
13423
+ abi: panopticPoolV2Abi,
13424
+ functionName: "getFullPositionsData",
13425
+ args: [
13426
+ account,
13427
+ true,
13428
+ tokenIds
13429
+ ]
13430
+ })
13431
+ });
13432
+ const { _meta, results } = await readBlockAndAggregate({
13433
+ client,
13434
+ calls,
13435
+ blockNumber
13436
+ });
13437
+ const currentTickResult = decodeFunctionResult({
13438
+ abi: panopticPoolV2Abi,
13439
+ functionName: "getCurrentTick",
13440
+ data: requireReturnData(results, 0, "PanopticPool.getCurrentTick")
13441
+ });
13442
+ const [rawAssets0, interest0] = decodeFunctionResult({
13443
+ abi: collateralTrackerV2Abi,
13444
+ functionName: "assetsAndInterest",
13445
+ data: requireReturnData(results, 1, "CollateralTracker.assetsAndInterest token0")
13446
+ });
13447
+ const [rawAssets1, interest1] = decodeFunctionResult({
13448
+ abi: collateralTrackerV2Abi,
13449
+ functionName: "assetsAndInterest",
13450
+ data: requireReturnData(results, 2, "CollateralTracker.assetsAndInterest token1")
13451
+ });
13452
+ const { balance: assets0, requirementExtra: interestDue0 } = applyOwedInterest(rawAssets0, interest0);
13453
+ const { balance: assets1, requirementExtra: interestDue1 } = applyOwedInterest(rawAssets1, interest1);
13454
+ const currentTick = BigInt(currentTickResult);
13455
+ const positionDataResult = positionDataIndex === null ? null : decodeFunctionResult({
13456
+ abi: panopticPoolV2Abi,
13457
+ functionName: "getFullPositionsData",
13458
+ data: requireReturnData(results, positionDataIndex, "PanopticPool.getFullPositionsData")
13459
+ });
13460
+ let required0Native = interestDue0;
13461
+ let required1Native = interestDue1;
13462
+ if (positionDataResult) {
13463
+ const collateralRequirements = positionDataResult[3];
13464
+ for (const packed of collateralRequirements) {
13465
+ const decoded = decodeLeftRightUnsigned(packed);
13466
+ required0Native += decoded.right;
13467
+ required1Native += decoded.left;
13468
+ }
13469
+ }
13470
+ const sqrtPriceX96 = tickToSqrtPriceX96(currentTick);
13471
+ const collateralBalance0 = assets0 + convert1to0$2(assets1, sqrtPriceX96);
13472
+ const requiredCollateral0 = required0Native + convert1to0$2(required1Native, sqrtPriceX96);
13473
+ const collateralBalance1 = assets1 + convert0to1$2(assets0, sqrtPriceX96);
13474
+ const requiredCollateral1 = required1Native + convert0to1$2(required0Native, sqrtPriceX96);
13475
+ return {
13476
+ collateralBalance0,
13477
+ requiredCollateral0,
13478
+ collateralBalance1,
13479
+ requiredCollateral1,
13480
+ _meta
13481
+ };
13482
+ }
13483
+
13484
+ //#endregion
13485
+ //#region src/panoptic/v2/reads/mintBuffer.ts
13486
+ /**
13487
+ * `RiskEngine.BP_DECREASE_BUFFER` — the numerator of the mint-time buffer.
13488
+ *
13489
+ * Exported so callers can display the constant; prefer {@link applyMintBuffer}
13490
+ * over multiplying by it directly, which is how the rounding bug reappears.
13491
+ */
13492
+ const MINT_BUFFER = 10750000n;
13493
+ /** `RiskEngine.DECIMALS` — the denominator {@link MINT_BUFFER} is taken over. */
13494
+ const MINT_BUFFER_DENOMINATOR = 10000000n;
13495
+ /** The compiled-in default, matching the deployed RiskEngine. */
13496
+ const DEFAULT_MINT_BUFFER = {
13497
+ numerator: MINT_BUFFER,
13498
+ denominator: MINT_BUFFER_DENOMINATOR
13499
+ };
13500
+ /**
13501
+ * Apply the mint buffer to ONE token's NATIVE requirement, rounding up exactly
13502
+ * as `Math.mulDivRoundingUp` does on-chain.
13503
+ *
13504
+ * Call this on the native token0/token1 requirement, never on a quote-converted
13505
+ * total — see the module docstring for why the order matters.
13506
+ *
13507
+ * @param required - Maintenance requirement in that token's own units
13508
+ * @param buffer - Optional live on-chain ratio; defaults to {@link DEFAULT_MINT_BUFFER}
13509
+ * @returns The mint-time requirement the solvency check enforces
13510
+ */
13511
+ function applyMintBuffer(required, buffer = DEFAULT_MINT_BUFFER) {
13512
+ const { numerator, denominator } = buffer;
13513
+ if (denominator <= 0n) throw new PanopticValidationError("applyMintBuffer: buffer denominator must be positive");
13514
+ if (required <= 0n) return 0n;
13515
+ return (required * numerator + denominator - 1n) / denominator;
13516
+ }
13517
+ /**
13518
+ * Apply the mint buffer to both tokens' NATIVE requirements, independently.
13519
+ *
13520
+ * This is the shape the solvency check itself uses: two separate per-side
13521
+ * comparisons, never a pooled total.
13522
+ *
13523
+ * @param required0 - Maintenance requirement in token0 units
13524
+ * @param required1 - Maintenance requirement in token1 units
13525
+ * @param buffer - Optional live on-chain ratio
13526
+ * @returns `[buffered0, buffered1]`
13527
+ */
13528
+ function applyMintBufferPerToken(required0, required1, buffer = DEFAULT_MINT_BUFFER) {
13529
+ return [applyMintBuffer(required0, buffer), applyMintBuffer(required1, buffer)];
13530
+ }
13531
+ /**
13532
+ * Collateral still deployable on one side before the mint solvency check fails:
13533
+ * `balance - bufferedRequired`, floored at zero.
13534
+ *
13535
+ * Both arguments must be in the SAME token's units.
13536
+ *
13537
+ * @param balance - That side's collateral balance
13538
+ * @param required - That side's maintenance requirement (unbuffered)
13539
+ * @param buffer - Optional live on-chain ratio
13540
+ * @returns Mintable headroom, never negative
13541
+ */
13542
+ function mintableAfterBuffer(balance, required, buffer = DEFAULT_MINT_BUFFER) {
13543
+ const requiredAtMint = applyMintBuffer(required, buffer);
13544
+ return balance > requiredAtMint ? balance - requiredAtMint : 0n;
13545
+ }
13546
+
13372
13547
  //#endregion
13373
13548
  //#region src/panoptic/v2/reads/margin.ts
13374
13549
  const FP96$2 = 1n << 96n;
13375
- const Q128$3 = 1n << 128n;
13550
+ const Q128$2 = 1n << 128n;
13376
13551
  /** Cap for a usage ratio with no collateral behind it. */
13377
13552
  const MAX_USAGE_BPS = 1000000n;
13378
13553
  const bigintMax = (a, b) => a > b ? a : b;
@@ -13383,16 +13558,16 @@ const bigintMin = (a, b) => a < b ? a : b;
13383
13558
  * Matches the on-chain `PanopticMath.convert0to1` truncation, with an
13384
13559
  * overflow-safe branch when `sqrtPriceX96^2` would not fit in uint256.
13385
13560
  */
13386
- function convert0to1$2(amount, sqrtPriceX96) {
13387
- if (sqrtPriceX96 < Q128$3) return amount * sqrtPriceX96 * sqrtPriceX96 >> 192n;
13561
+ function convert0to1$1(amount, sqrtPriceX96) {
13562
+ if (sqrtPriceX96 < Q128$2) return amount * sqrtPriceX96 * sqrtPriceX96 >> 192n;
13388
13563
  const sp2Hi = sqrtPriceX96 * sqrtPriceX96 >> 64n;
13389
13564
  return amount * sp2Hi >> 128n;
13390
13565
  }
13391
13566
  /**
13392
13567
  * Convert a token1 amount to its token0-equivalent at the given sqrtPriceX96.
13393
13568
  */
13394
- function convert1to0$2(amount, sqrtPriceX96) {
13395
- if (sqrtPriceX96 < Q128$3) {
13569
+ function convert1to0$1(amount, sqrtPriceX96) {
13570
+ if (sqrtPriceX96 < Q128$2) {
13396
13571
  const denom = sqrtPriceX96 * sqrtPriceX96;
13397
13572
  return amount * (1n << 192n) / denom;
13398
13573
  }
@@ -13405,7 +13580,7 @@ function convert1to0$2(amount, sqrtPriceX96) {
13405
13580
  * Reads, all pinned to the same block:
13406
13581
  * - `getCurrentTick` (sequencing dependency for sqrtPrice conversion)
13407
13582
  * - `getFullPositionsData(account, true, tokenIds)` → collateralRequirements
13408
- * - `CollateralTracker.assetsOf(account)` on both trackers → gross collateral
13583
+ * - `CollateralTracker.assetsAndInterest(account)` on both trackers → collateral and owed interest
13409
13584
  * - `PanopticQuery.getLiquidationPrices(...)` → liquidation boundaries
13410
13585
  *
13411
13586
  * @param params - The parameters
@@ -13486,6 +13661,14 @@ function requireMulticallResult(results, index, label) {
13486
13661
  if (result.status === "failure") throw result.error;
13487
13662
  return result.result;
13488
13663
  }
13664
+ function requireAssetsAndInterestResult(results, index, label) {
13665
+ const result = requireMulticallResult(results, index, label);
13666
+ if (!Array.isArray(result) || result.length < 2 || typeof result[0] !== "bigint" || typeof result[1] !== "bigint") throw new PanopticError(`${label} returned an invalid value`);
13667
+ return {
13668
+ assets: result[0],
13669
+ interest: result[1]
13670
+ };
13671
+ }
13489
13672
  function requireBigIntResult(results, index, label) {
13490
13673
  const result = requireMulticallResult(results, index, label);
13491
13674
  if (typeof result !== "bigint" && typeof result !== "number") throw new PanopticError(`${label} returned an invalid value`);
@@ -13502,13 +13685,13 @@ function prepareMarginBufferRead({ poolAddress, account, tokenIds, queryAddress,
13502
13685
  {
13503
13686
  address: collateralAddresses.collateralToken0,
13504
13687
  abi: collateralTrackerV2Abi,
13505
- functionName: "assetsOf",
13688
+ functionName: "assetsAndInterest",
13506
13689
  args: [account]
13507
13690
  },
13508
13691
  {
13509
13692
  address: collateralAddresses.collateralToken1,
13510
13693
  abi: collateralTrackerV2Abi,
13511
- functionName: "assetsOf",
13694
+ functionName: "assetsAndInterest",
13512
13695
  args: [account]
13513
13696
  }
13514
13697
  ];
@@ -13559,8 +13742,10 @@ function prepareMarginBufferRead({ poolAddress, account, tokenIds, queryAddress,
13559
13742
  }
13560
13743
  function decodeMarginBufferResults({ results, _meta, positionDataIndex, liqPricesIndex, checkCollateralIndex, mintBuffer }) {
13561
13744
  const currentTick = requireBigIntResult(results, 0, "PanopticPool.getCurrentTick");
13562
- const assets0 = requireBigIntResult(results, 1, "CollateralTracker.assetsOf token0");
13563
- const assets1 = requireBigIntResult(results, 2, "CollateralTracker.assetsOf token1");
13745
+ const tracker0 = requireAssetsAndInterestResult(results, 1, "CollateralTracker.assetsAndInterest token0");
13746
+ const tracker1 = requireAssetsAndInterestResult(results, 2, "CollateralTracker.assetsAndInterest token1");
13747
+ const { balance: assets0, requirementExtra: interestDue0 } = applyOwedInterest(tracker0.assets, tracker0.interest);
13748
+ const { balance: assets1, requirementExtra: interestDue1 } = applyOwedInterest(tracker1.assets, tracker1.interest);
13564
13749
  const positionDataResult = positionDataIndex === null ? null : requireMulticallResult(results, positionDataIndex, "PanopticPool.getFullPositionsData");
13565
13750
  const liqPricesResult = liqPricesIndex === null ? null : requireMulticallResult(results, liqPricesIndex, "PanopticQuery.getLiquidationPrices");
13566
13751
  const checkCollateralResult = checkCollateralIndex === null ? null : requireMulticallResult(results, checkCollateralIndex, "PanopticQuery.checkCollateral");
@@ -13583,8 +13768,8 @@ function decodeMarginBufferResults({ results, _meta, positionDataIndex, liqPrice
13583
13768
  const mintable1 = mintable(balances1[0], requireds1[0]);
13584
13769
  if (mintable0 !== null || mintable1 !== null) mintableMarginBinding = mintable0 === null ? mintable1 : mintable1 === null ? mintable0 : bigintMin(mintable0, mintable1);
13585
13770
  }
13586
- let required0Native = 0n;
13587
- let required1Native = 0n;
13771
+ let required0Native = interestDue0;
13772
+ let required1Native = interestDue1;
13588
13773
  if (positionDataResult) {
13589
13774
  const collateralRequirements = positionDataResult[3];
13590
13775
  for (const packed of collateralRequirements) {
@@ -13595,10 +13780,10 @@ function decodeMarginBufferResults({ results, _meta, positionDataIndex, liqPrice
13595
13780
  }
13596
13781
  const sqrtPriceX96 = tickToSqrtPriceX96(currentTick);
13597
13782
  const denominatedInToken = sqrtPriceX96 < FP96$2 ? 0 : 1;
13598
- const currentMargin0 = assets0 + convert1to0$2(assets1, sqrtPriceX96);
13599
- const requiredMargin0 = required0Native + convert1to0$2(required1Native, sqrtPriceX96);
13600
- const currentMargin1 = assets1 + convert0to1$2(assets0, sqrtPriceX96);
13601
- const requiredMargin1 = required1Native + convert0to1$2(required0Native, sqrtPriceX96);
13783
+ const currentMargin0 = assets0 + convert1to0$1(assets1, sqrtPriceX96);
13784
+ const requiredMargin0 = required0Native + convert1to0$1(required1Native, sqrtPriceX96);
13785
+ const currentMargin1 = assets1 + convert0to1$1(assets0, sqrtPriceX96);
13786
+ const requiredMargin1 = required1Native + convert0to1$1(required0Native, sqrtPriceX96);
13602
13787
  const buffer0 = currentMargin0 - requiredMargin0;
13603
13788
  const buffer1 = currentMargin1 - requiredMargin1;
13604
13789
  const bufferPercent0 = requiredMargin0 === 0n ? null : buffer0 * 10000n / requiredMargin0;
@@ -19995,14 +20180,14 @@ async function getForfeitablePremium(params) {
19995
20180
  //#endregion
19996
20181
  //#region src/panoptic/v2/reads/checks.ts
19997
20182
  const FP96$1 = 1n << 96n;
19998
- const Q128$2 = 1n << 128n;
19999
- function convert0to1$1(amount, sqrtPriceX96) {
20000
- if (sqrtPriceX96 < Q128$2) return amount * sqrtPriceX96 * sqrtPriceX96 >> 192n;
20183
+ const Q128$1 = 1n << 128n;
20184
+ function convert0to1(amount, sqrtPriceX96) {
20185
+ if (sqrtPriceX96 < Q128$1) return amount * sqrtPriceX96 * sqrtPriceX96 >> 192n;
20001
20186
  const sp2Hi = sqrtPriceX96 * sqrtPriceX96 >> 64n;
20002
20187
  return amount * sp2Hi >> 128n;
20003
20188
  }
20004
- function convert1to0$1(amount, sqrtPriceX96) {
20005
- if (sqrtPriceX96 < Q128$2) {
20189
+ function convert1to0(amount, sqrtPriceX96) {
20190
+ if (sqrtPriceX96 < Q128$1) {
20006
20191
  const denom = sqrtPriceX96 * sqrtPriceX96;
20007
20192
  return amount * (1n << 192n) / denom;
20008
20193
  }
@@ -20012,7 +20197,7 @@ function convert1to0$1(amount, sqrtPriceX96) {
20012
20197
  /**
20013
20198
  * Check if an account is liquidatable with detailed margin breakdown.
20014
20199
  *
20015
- * Sources gross collateral from `CollateralTracker.assetsOf` and per-position
20200
+ * Sources collateral and owed interest from `CollateralTracker.assetsAndInterest` and per-position
20016
20201
  * required margin from `PanopticPool.getFullPositionsData.collateralRequirements[]`,
20017
20202
  * cross-converted to each token denomination at `atTick`. Loan tokenIds
20018
20203
  * (width=0 shorts) contribute correctly to required margin.
@@ -20073,7 +20258,7 @@ async function isLiquidatable(params) {
20073
20258
  target: collateralToken0,
20074
20259
  callData: encodeFunctionData({
20075
20260
  abi: collateralTrackerV2Abi,
20076
- functionName: "assetsOf",
20261
+ functionName: "assetsAndInterest",
20077
20262
  args: [account]
20078
20263
  })
20079
20264
  });
@@ -20082,7 +20267,7 @@ async function isLiquidatable(params) {
20082
20267
  target: collateralToken1,
20083
20268
  callData: encodeFunctionData({
20084
20269
  abi: collateralTrackerV2Abi,
20085
- functionName: "assetsOf",
20270
+ functionName: "assetsAndInterest",
20086
20271
  args: [account]
20087
20272
  })
20088
20273
  });
@@ -20113,23 +20298,25 @@ async function isLiquidatable(params) {
20113
20298
  data: requireReturnData(results, currentTickIndex, "PanopticPool.getCurrentTick")
20114
20299
  }));
20115
20300
  }
20116
- const assets0 = decodeFunctionResult({
20301
+ const [rawAssets0, interest0] = decodeFunctionResult({
20117
20302
  abi: collateralTrackerV2Abi,
20118
- functionName: "assetsOf",
20119
- data: requireReturnData(results, assets0Index, "CollateralTracker.assetsOf token0")
20303
+ functionName: "assetsAndInterest",
20304
+ data: requireReturnData(results, assets0Index, "CollateralTracker.assetsAndInterest token0")
20120
20305
  });
20121
- const assets1 = decodeFunctionResult({
20306
+ const [rawAssets1, interest1] = decodeFunctionResult({
20122
20307
  abi: collateralTrackerV2Abi,
20123
- functionName: "assetsOf",
20124
- data: requireReturnData(results, assets1Index, "CollateralTracker.assetsOf token1")
20308
+ functionName: "assetsAndInterest",
20309
+ data: requireReturnData(results, assets1Index, "CollateralTracker.assetsAndInterest token1")
20125
20310
  });
20311
+ const { balance: assets0, requirementExtra: interestDue0 } = applyOwedInterest(rawAssets0, interest0);
20312
+ const { balance: assets1, requirementExtra: interestDue1 } = applyOwedInterest(rawAssets1, interest1);
20126
20313
  const positionDataResult = positionDataIndex === null ? null : decodeFunctionResult({
20127
20314
  abi: panopticPoolV2Abi,
20128
20315
  functionName: "getFullPositionsData",
20129
20316
  data: requireReturnData(results, positionDataIndex, "PanopticPool.getFullPositionsData")
20130
20317
  });
20131
- let required0Native = 0n;
20132
- let required1Native = 0n;
20318
+ let required0Native = interestDue0;
20319
+ let required1Native = interestDue1;
20133
20320
  if (positionDataResult) {
20134
20321
  const collateralRequirements = positionDataResult[3];
20135
20322
  for (const packed of collateralRequirements) {
@@ -20139,10 +20326,10 @@ async function isLiquidatable(params) {
20139
20326
  }
20140
20327
  }
20141
20328
  const sqrtPriceX96 = tickToSqrtPriceX96(effectiveTick);
20142
- const currentMargin0 = assets0 + convert1to0$1(assets1, sqrtPriceX96);
20143
- const requiredMargin0 = required0Native + convert1to0$1(required1Native, sqrtPriceX96);
20144
- const currentMargin1 = assets1 + convert0to1$1(assets0, sqrtPriceX96);
20145
- const requiredMargin1 = required1Native + convert0to1$1(required0Native, sqrtPriceX96);
20329
+ const currentMargin0 = assets0 + convert1to0(assets1, sqrtPriceX96);
20330
+ const requiredMargin0 = required0Native + convert1to0(required1Native, sqrtPriceX96);
20331
+ const currentMargin1 = assets1 + convert0to1(assets0, sqrtPriceX96);
20332
+ const requiredMargin1 = required1Native + convert0to1(required0Native, sqrtPriceX96);
20146
20333
  const marginShortfall0 = requiredMargin0 - currentMargin0;
20147
20334
  const marginShortfall1 = requiredMargin1 - currentMargin1;
20148
20335
  const denominatedInToken = sqrtPriceX96 < FP96$1 ? 0n : 1n;
@@ -23119,161 +23306,6 @@ async function getCollateralTotalAssetsBatch(client, collateralTrackerAddresses,
23119
23306
  }
23120
23307
  }
23121
23308
 
23122
- //#endregion
23123
- //#region src/panoptic/v2/reads/buyingPower.ts
23124
- const Q128$1 = 1n << 128n;
23125
- /** Immutable collateral tracker addresses, suitable for a pool-scoped cache. */
23126
- async function getPoolCollateralAddresses(params) {
23127
- const [collateralToken0, collateralToken1] = await multicall(params.client, {
23128
- contracts: [{
23129
- address: params.poolAddress,
23130
- abi: panopticPoolV2Abi,
23131
- functionName: "collateralToken0"
23132
- }, {
23133
- address: params.poolAddress,
23134
- abi: panopticPoolV2Abi,
23135
- functionName: "collateralToken1"
23136
- }],
23137
- blockNumber: params.blockNumber,
23138
- allowFailure: false
23139
- });
23140
- return {
23141
- collateralToken0,
23142
- collateralToken1
23143
- };
23144
- }
23145
- function convert0to1(amount, sqrtPriceX96) {
23146
- if (sqrtPriceX96 < Q128$1) return amount * sqrtPriceX96 * sqrtPriceX96 >> 192n;
23147
- const sp2Hi = sqrtPriceX96 * sqrtPriceX96 >> 64n;
23148
- return amount * sp2Hi >> 128n;
23149
- }
23150
- function convert1to0(amount, sqrtPriceX96) {
23151
- if (sqrtPriceX96 < Q128$1) {
23152
- const denom = sqrtPriceX96 * sqrtPriceX96;
23153
- return amount * (1n << 192n) / denom;
23154
- }
23155
- const sp2Hi = sqrtPriceX96 * sqrtPriceX96 >> 64n;
23156
- return amount * (1n << 128n) / sp2Hi;
23157
- }
23158
- /**
23159
- * Get account-level buying power.
23160
- *
23161
- * Uses {@link https://github.com/panoptic-xyz CollateralTracker.assetsOf} for
23162
- * gross collateral and `PanopticPool.getFullPositionsData.collateralRequirements[]`
23163
- * for the per-position required margin — so loan tokenIds (width=0 shorts)
23164
- * contribute to the requirement instead of being netted out of the balance.
23165
- *
23166
- * Accepts a plain viem `Client` (not just `PublicClient`) so it works with wagmi's
23167
- * `useClient()` without needing a cast.
23168
- *
23169
- * @param params - The parameters
23170
- * @returns Account buying power data with optional block metadata
23171
- */
23172
- async function getAccountBuyingPower(params) {
23173
- const { client, poolAddress, account, tokenIds } = params;
23174
- const blockNumber = params.blockNumber ?? params._meta?.blockNumber;
23175
- let collateralToken0;
23176
- let collateralToken1;
23177
- if (params.collateralAddresses) {
23178
- collateralToken0 = params.collateralAddresses.collateralToken0;
23179
- collateralToken1 = params.collateralAddresses.collateralToken1;
23180
- } else {
23181
- const addresses = await getPoolCollateralAddresses({
23182
- client,
23183
- poolAddress,
23184
- blockNumber
23185
- });
23186
- collateralToken0 = addresses.collateralToken0;
23187
- collateralToken1 = addresses.collateralToken1;
23188
- }
23189
- const calls = [
23190
- {
23191
- target: poolAddress,
23192
- callData: encodeFunctionData({
23193
- abi: panopticPoolV2Abi,
23194
- functionName: "getCurrentTick"
23195
- })
23196
- },
23197
- {
23198
- target: collateralToken0,
23199
- callData: encodeFunctionData({
23200
- abi: collateralTrackerV2Abi,
23201
- functionName: "assetsOf",
23202
- args: [account]
23203
- })
23204
- },
23205
- {
23206
- target: collateralToken1,
23207
- callData: encodeFunctionData({
23208
- abi: collateralTrackerV2Abi,
23209
- functionName: "assetsOf",
23210
- args: [account]
23211
- })
23212
- }
23213
- ];
23214
- const positionDataIndex = tokenIds.length > 0 ? calls.length : null;
23215
- if (positionDataIndex !== null) calls.push({
23216
- target: poolAddress,
23217
- callData: encodeFunctionData({
23218
- abi: panopticPoolV2Abi,
23219
- functionName: "getFullPositionsData",
23220
- args: [
23221
- account,
23222
- true,
23223
- tokenIds
23224
- ]
23225
- })
23226
- });
23227
- const { _meta, results } = await readBlockAndAggregate({
23228
- client,
23229
- calls,
23230
- blockNumber
23231
- });
23232
- const currentTickResult = decodeFunctionResult({
23233
- abi: panopticPoolV2Abi,
23234
- functionName: "getCurrentTick",
23235
- data: requireReturnData(results, 0, "PanopticPool.getCurrentTick")
23236
- });
23237
- const assets0 = decodeFunctionResult({
23238
- abi: collateralTrackerV2Abi,
23239
- functionName: "assetsOf",
23240
- data: requireReturnData(results, 1, "CollateralTracker.assetsOf token0")
23241
- });
23242
- const assets1 = decodeFunctionResult({
23243
- abi: collateralTrackerV2Abi,
23244
- functionName: "assetsOf",
23245
- data: requireReturnData(results, 2, "CollateralTracker.assetsOf token1")
23246
- });
23247
- const currentTick = BigInt(currentTickResult);
23248
- const positionDataResult = positionDataIndex === null ? null : decodeFunctionResult({
23249
- abi: panopticPoolV2Abi,
23250
- functionName: "getFullPositionsData",
23251
- data: requireReturnData(results, positionDataIndex, "PanopticPool.getFullPositionsData")
23252
- });
23253
- let required0Native = 0n;
23254
- let required1Native = 0n;
23255
- if (positionDataResult) {
23256
- const collateralRequirements = positionDataResult[3];
23257
- for (const packed of collateralRequirements) {
23258
- const decoded = decodeLeftRightUnsigned(packed);
23259
- required0Native += decoded.right;
23260
- required1Native += decoded.left;
23261
- }
23262
- }
23263
- const sqrtPriceX96 = tickToSqrtPriceX96(currentTick);
23264
- const collateralBalance0 = assets0 + convert1to0(assets1, sqrtPriceX96);
23265
- const requiredCollateral0 = required0Native + convert1to0(required1Native, sqrtPriceX96);
23266
- const collateralBalance1 = assets1 + convert0to1(assets0, sqrtPriceX96);
23267
- const requiredCollateral1 = required1Native + convert0to1(required0Native, sqrtPriceX96);
23268
- return {
23269
- collateralBalance0,
23270
- requiredCollateral0,
23271
- collateralBalance1,
23272
- requiredCollateral1,
23273
- _meta
23274
- };
23275
- }
23276
-
23277
23309
  //#endregion
23278
23310
  //#region src/panoptic/v2/simulations/simulateOpenPosition.ts
23279
23311
  /**
@@ -40496,5 +40528,5 @@ function usePoolSwaps(params) {
40496
40528
  }
40497
40529
 
40498
40530
  //#endregion
40499
- export { AccountInsolventError, AlreadyInitializedError, BORROW_INDEX_BITS, BPS_DENOMINATOR, BPS_SCALE, BatchValidationError, BelowMinimumRedemptionError, CastingError, ChunkHasZeroLiquidityError, ChunkLimitError, CrossPoolError, DEFAULT_MAX_SPREAD, DEFAULT_MINT_BUFFER, DEFAULT_MIN_SWAP_RATIO_BPS, DEFAULT_RECONNECT_CONFIG, DEFAULT_VEGOID, DepositTooLargeError, DuplicateTokenIdError, EffectiveLiquidityAboveThresholdError, ExceedsMaximumRedemptionError, InputListFailError, InsufficientCreditLiquidityError, InvalidBuilderCodeError, InvalidHistoryRangeError, InvalidTickBoundError, InvalidTickError, InvalidTokenIdParameterError, InvalidUniswapCallbackError, LEG_BITS, LEG_LIMITS, LEG_MASKS, LengthMismatchError, LiquidityTooHighError, LoanSlotExhaustedError, MARKET_EPOCH_BITS, MARKET_EPOCH_SHIFT, MARKET_INDICATOR_PERIODS, MAX_TICK, MAX_TRACKED_CHUNKS, MINT_BUFFER, MINT_BUFFER_DENOMINATOR, MIN_TICK, MaxRetriesExceededError, MissingPositionIdsError, NO_LOWER_LIQUIDATION_TICK, NO_UPPER_LIQUIDATION_TICK, NetLiquidityZeroError, NetworkMismatchError, NoLegsExercisableError, NotALongLegError, NotBuilderError, NotEnoughLiquidityInChunkError, NotEnoughTokensError, NotGuardianError, NotMarginCalledError, NotPanopticPoolError, ORACLE_EPOCH_SECONDS, OracleRateLimitedError, PanopticError, PanopticHelperNotDeployedError, PanopticProvider, PanopticValidationError, PoolNotInitializedError, PositionCountNotZeroError, PositionNotOwnedError, PositionSnapshotNotFoundError, PositionTooLargeError, PriceBoundFailError, PriceImpactTooLargeError, ProviderLagError, RATE_AT_TARGET_BITS, REORG_DEPTH, REQUIRED_BASE_ERROR_SENTINEL, ReentrancyError, RpcError, RpcResponseError, SCHEMA_VERSION, SECONDS_PER_YEAR, STANDARD_TICK_WIDTHS, STORAGE_PREFIX, STRIKE_LADDER_TARGET_STRIKES, SafeModeError, StaleDataError, StaleOracleError, SwapTokenMismatchError, SyncTimeoutError, TOKEN_ID_BITS, TokenIdHasZeroLegsError, TooManyLegsOpenError, TransferFailedError, UNREALIZED_INTEREST_BITS, UTILIZATION_DENOMINATOR, UnauthorizedUniswapCallbackError, UnderOverFlowError, UnhealthyPoolError, UnsafePremiumSettlementError, VARIANCE_RATIO_LAG, WAD, WrongPoolIdError, WrongUniswapPoolError, ZERO_COLLATERAL, ZERO_VALUATION, ZeroAddressError, ZeroCollateralRequirementError, addLegToTokenId, addPendingPosition, addTrackedChunks, annualizePerSecondRateWad, applyMintBuffer, applyMintBufferPerToken, apportion, approve, approveAndWait, approvePool, assertCanBurn, assertCanForceExercise, assertCanLiquidate, assertCanMint, assertFresh, assertHealthy, assertLpPositionFunded, assertTradeable, borrow, borrowAndWait, buildBatchDispatchArgs, buildCreditSwapCall, buildCreditWrappedDispatch, buildOpenPositionCalldata, buildProtectedSettleDispatch, buildProtectedSettlePlan, buildSettleSequenceCalls, buildSfpmSwapCalldata, buildSfpmSwapPlan, buildTemporaryLoanRecoveryDispatch, buildTokenShortfallRecoveryDispatch, buildUniqueCredit, buildUniqueLoan, buildUniqueWidthZeroLeg, calculateAccountGreeksPure, calculateMarketIndicator, calculatePortfolioDelta, calculatePortfolioGamma, calculatePortfolioGreeks, calculatePortfolioValue, calculatePositionDelta, calculatePositionDeltaDebtOnly, calculatePositionDeltaWithSwap, calculatePositionGamma, calculatePositionGreeks, calculatePositionValue, calculatePositionValues, calculatePositionVolatilityMetrics, calculateResyncBlock, calculateSpreadWad, calculateVarianceProfile, cancelTransaction, checkApproval, checkCollateralAcrossTicks, classifyStrategyGroups, classifyStrike, cleanupStalePendingPositions, clearCheckpoint, clearPendingPositions, clearTrackedChunks, clearTrackedPositions, clearTradeHistory, closePosition, closePositionAndWait, collateralCurveTicks, collateralRuleKindFor, collateralTrackerV2Abi, computeV4PoolId, confirmPendingPosition, convertToAssets, convertToShares, countLegs, createEventPoller, createEventSubscription, createFileStorage, createFlowNeutralTokenId, createMemoryStorage, createNonceManager, createPoolFormatters, createTokenIdBuilder, decodeAllDispatchCalldata, decodeAllLegs, decodeDispatchCalldata, decodeLeftRightSigned, decodeLeftRightUnsigned, decodeLeg, decodeOraclePack, decodeOracleRiskParameters, decodeOracleTiming, decodePanopticTokenURI, decodePoolId, decodeTickSpacing, decodeTokenId, decodeVegoid, deployNewPool, deployNewPoolAndWait, deposit, depositAndWait, deriveSupplyRatePerSecWad, deriveUniqueTokenId, detectReorg, diagnoseOracleSafeMode, dispatch, dispatchAndWait, emptyLiquidateParams, encodeLeg, encodePoolId, encodePoolKeyBytes, encodeV3PoolKeyBytes, encodeV4PoolId, ensureSfpmV3PoolInitialized, estimateBlockNumbers, estimateCloseZapSwap, estimateCollateralBreakdown, estimateCollateralRequired, executeBatchDispatch, executeBatchDispatchAndWait, executeSettleSequence, executeSettleSequenceAndWait, failPendingPosition, feeGrowthInsideX128, feesFromFeeGrowthDelta, fetchPoolId, fetchPoolSwaps, fetchSfpmV3PoolId, fetchUniswapFeeData, forceExercise, forceExerciseAndWait, formatBlockNumber, formatBps, formatCompact, formatDatetime, formatDuration, formatDurationSeconds, formatFeeTier, formatGas, formatGwei, formatPerSecondRateWadAsAprPct, formatPerSecondRateWadAsApyPct, formatPoolIdHex, formatPriceRange, formatRateWad, formatRatioPercent, formatTick, formatTickRange, formatTimestamp, formatTimestampLocale, formatTokenAmount, formatTokenAmountSigned, formatTokenDelta, formatTokenFlow, formatTokenIdHex, formatTokenIdShort, formatTxHash, formatUtilization, formatWad, formatWadPercent, formatWadSigned, formatWei, generateOverlappingTokenIds, getAccountBuyingPower, getAccountCollateral, getAccountGreeks, getAccountHistory, getAccountPremia, getAccountSummaryBasic, getAccountSummaryRisk, getAssetIndex, getBlockMeta, getChainDeployment, getChunkLiquidities, getChunkSpreads, getClosePositionTransferEstimate, getClosedPositions, getClosedPositionsKey, getCollateralAddresses, getCollateralCurve, getCollateralCurveInputs, getCollateralData, getCollateralRequiredBase, getCollateralSharePrices, getCollateralTotalAssetsBatch, getCurrentRates, getDeltaHedgeParams, getEnforcedTickLimits, getExecutableLpMaxSize, getFactoryConstructMetadata, getFactoryOwnerOf, getFactoryTokenURI, getForfeitablePremium, getGuardianUnlockState, getHedgeLimits, getInterestState, getIrmCurrent, getIrmCurve, getItmAmounts, getLegDelta, getLegDeltaInVaultFrame, getLegGamma, getLegNetValueWidth0, getLegValue, getLiquidationPrices, getMarginBuffer, getMaxPositionSize, getMaxRedeem, getMaxWithdrawable, getNativeTokenPrice, getNetLiquidationValue, getNetLiquidationValues, getNotEnoughTokensError, getOpenPositionIds, getOpenPositionPreview, getOracleRiskParameters, getOracleState, getPanopticPoolAddress, getPanopticPoolFromPoolId, getPendingPositions, getPendingPositionsKey, getPool, getPoolCurrentTick, getPoolDeploymentBlock, getPoolDisplayId, getPoolLiquidities, getPoolMetaKey, getPoolMetadata, getPoolPrefix, getPortfolioValue, getPosition, getPositionChunkData, getPositionDeltaMetrics, getPositionEnrichmentData, getPositionGreeks, getPositionMetaKey, getPositionMintFunding, getPositionValueCurve, getPositionVolatilityHistory, getPositions, getPositionsKey, getPositionsWithPremia, getPriceHistory, getPricesAtTick, getRealizedPnL, getRequiredCreditForITM, getRiskParameters, getSafeMode, getSchemaVersionKey, getSimpleLoanTokenIndex, getStreamiaHistory, getSyncCheckpointKey, getSyncStatus, getTickSpacing, getTokenIdValidationError, getTokenListId, getTrackedChunks, getTrackedChunksKey, getTrackedPositionIds, getTradeHistory, getUniswapFeeHistory, getUniswapV3LpPositionState, getUniswapV3PoolFromId, getUniswapV3PoolInfo, getUniswapV3PoolLiquidities, getUniswapV4LpPositionState, getUniswapV4PoolBasicState, getUniswapV4PoolInfo, getUniswapV4PoolKeyFromId, getUniswapV4PoolLiquidities, getUtilization, hasLoanOrCredit, hasLongLeg, interpolateBlocks, isCall, isCowSupportedChain, isCredit, isCreditLeg, isDefinedRisk, isGasError, isInputListFailError, isLiquidatable, isLoan, isLoanLeg, isNonceError, isPanopticErrorType, isPositionTracked, isRetryableRpcError, isShortOnly, isSpread, isSupportedChain, isolateGroupTokenId, jsonSerializer, ladderStrikeSequence, liquidate, liquidateAndWait, loadCheckpoint, logReturns, marketPnlInQuote, marketRiskFromValues, marketScenario, minePoolAddress, mint, mintAndWait, mintableAfterBuffer, multicallRead, mutationEffects, netLiquidationValueInQuote, openPosition, openPositionAndWait, optimizeTokenIdRiskPartners, oracleEpochAt, orderListForSettle, packMarketState, panopticLiquidatorAbi, panopticPoolV2Abi, panopticQueryAbi, parseBps, parseCollateralLog, parsePanopticError, parsePoolLog, parseStreamedKey, parseStreamedSwap, parseSwapLog, parseTokenAmount, parseTokenListId, parseWad, planDeriveStrategy, pokeOracle, pokeOracleAndWait, positionValueKey, positionValueTicks, prepareIndicatorCandles, prepareLiquidityGamma, preparePositionGamma, preparePositionValue, preparePositionValueCurve, previewBorrow, previewDeposit, previewMint, previewRedeem, previewRepay, previewUnwrap, previewWithdraw, previewWrap, priceToTick, publicBroadcaster, queryKeys, quoteLiquidation, quoteOneTokenFlow, quoteSfpmSwap, quoteTemporaryLoanRecovery, quoteTokenShortfallRecovery, quoteTokenShortfallSwap, quoteV3ExactIn, ratePerSecWadToAprPct, realizedBeta, reconstructFromEvents, recoverSnapshot, recoverSnapshotFromTx, redeem, redeemAndWait, removeTrackedChunks, repay, repayAndWait, requireChainDeployment, resolveBlockNumbers, resolveLadderStrike, resolvePanopticPoolFromPoolId, resolveTokenIndex, resolveUniswapV4PoolKey, riskEngineAbi, rollPosition, rollPositionAndWait, roundToTickSpacing, saveCheckpoint, saveClosedPosition, scaleCollateralRequired, scanChunks, screenAccountExact, selectDispatchForAccount, settleAccumulatedPremia, settleAccumulatedPremiaAndWait, settlePremiumFrom, settlePremiumFromAndWait, simulateBatchDispatch, simulateClosePosition, simulateClosePremiumProtection, simulateDeployNewPool, simulateDeposit, simulateDispatch, simulateForceExercise, simulateLiquidate, simulateOpenPosition, simulateSFPMBurn, simulateSFPMMint, simulateSettle, simulateSettlePremiumBatch, simulateSettlePremiumFrom, simulateSettleSequence, simulateSwapExactIn, simulateSwapExactOut, simulateWithTokenFlow, simulateWithdraw, slippageBpsToTickDistance, smartRepay, smartRepayAndWait, speedUpTransaction, splitTokenIdByTimescale, sqrtPriceX96ToPriceDecimalScaled, sqrtPriceX96ToTick, streamPoolSwaps, subscribePoolSwaps, supply, supplyAndWait, swapExactIn, swapExactInAndWait, swapExactOut, swapExactOutAndWait, syncPositions, tickLimits, tickToPrice, tickToPriceDecimalScaled, tickToSqrtPriceX96, toVaultFrameAtTick, truncateAddress, unsupply, unsupplyAndWait, unwrapWeth, unwrapWethAndWait, unwrapXstock, unwrapXstockAndWait, useAccountCollateral, useAccountGreeks, useAccountPremia, useAccountSummaryBasic, useAccountSummaryRisk, useAddPendingPosition, useApprove, useApproveErc20ForCow, useApproveErc20ForPermit2, useApprovePool, useApproveRouterViaPermit2, useBatchDispatch as useBatchDispatchHook, useBorrow as useBorrowHook, useCancelCowOrder, useCheckCowApproval, useCheckRouterApproval, useChunkSpreads, useClearTrackedPositions, useClosePosition as useClosePositionHook, useClosedPositions, useCollateralBreakdown, useCollateralData, useConfirmPendingPosition, useCowOrderStatus, useCurrentRates, useDeployNewPool as useDeployNewPoolHook, useDeposit as useDepositHook, useDispatch as useDispatchHook, useEstimateCollateralRequired, useEventPoller, useEventSubscription, useExecuteSettleSequence, useFactoryConstructMetadata, useFactoryOwnerOf, useFactoryTokenURI, useFailPendingPosition, useFlowNeutralTokenId, useForceExercise as useForceExerciseHook, useForfeitablePremium, useGuardianUnlockState, useInterestState, useIsLiquidatable, useLiquidate as useLiquidateHook, useLiquidationPrices, useMarginBuffer, useMaxPositionSize, useMaxRedeem, useMaxWithdrawable, useMinePoolAddress as useMinePoolAddressHook, useMintShares, useNativeTokenPrice, useNetLiquidationValue, useNetLiquidationValues, useOpenPosition as useOpenPositionHook, useOpenPositionPreview, useOptimizeRiskPartners, useOracleState, usePanopticContext, usePanopticPoolAddress, usePokeOracle as usePokeOracleHook, usePool, usePoolLiquidities, usePoolSwaps, usePoolVersion, usePosition, usePositionGreeks, usePositions, usePositionsWithPremia, usePreviewBorrow, usePreviewDeposit, usePreviewMint, usePreviewRedeem, usePreviewWithdraw, usePriceHistory, useQuoteCowSwap, useQuoteSwapExactInViaRouter, useQuoteSwapExactOutViaRouter, useRealizedPnL, useRedeem as useRedeemHook, useRepay as useRepayHook, useResolveUniswapV4PoolKey, useRiskParameters, useRollPosition as useRollPositionHook, useSafeMode, useSettleAccumulatedPremia as useSettleAccumulatedPremiaHook, useSettlePremiumFrom as useSettlePremiumFromHook, useSimulateBatchDispatch, useSimulateClosePosition, useSimulateDeployNewPool, useSimulateDeposit, useSimulateDispatch, useSimulateForceExercise, useSimulateLiquidate, useSimulateOpenPosition, useSimulateSFPMBurn, useSimulateSFPMMint, useSimulateSettle, useSimulateSettlePremiumBatch, useSimulateSettlePremiumFrom, useSimulateSettleSequence, useSimulateSwapExactIn, useSimulateSwapExactOut, useSimulateWithdraw, useSmartRepay as useSmartRepayHook, useStreamiaHistory, useSubmitCowOrder, useSupply as useSupplyHook, useSwapExactIn, useSwapExactInViaRouter, useSwapExactOut, useSwapExactOutViaRouter, useSyncPositions, useSyncStatus, useTrackedPositionIds, useTradeHistory, useTxEventConfirmation, useUniswapFeeHistory, useUniswapV3PoolInfo, useUniswapV3PoolLiquidities, useUniswapV4PoolBasicState, useUniswapV4PoolInfo, useUniswapV4PoolLiquidities, useUnsupply as useUnsupplyHook, useUnwrapWeth, useUnwrapXstock, useUtilization, useValidateBuilderCode, useWatchEvents, useWithdraw as useWithdrawHook, useWithdrawWithPositions as useWithdrawWithPositionsHook, useWrapEth, useWrapXstock, utilizationBpsToWad, utilizationPctToWad, validateBatch, validateBuilderCode, validatePoolId, valuePositionAccrual, verifyBlockContinuity, watchEvents, watchPoolSwaps, wethWrapAbi, withdraw, withdrawAndWait, withdrawWithPositions, withdrawWithPositionsAndWait, wrapEth, wrapEthAndWait, wrapXstock, wrapXstockAndWait, xstockWrapperAbi };
40531
+ export { AccountInsolventError, AlreadyInitializedError, BORROW_INDEX_BITS, BPS_DENOMINATOR, BPS_SCALE, BatchValidationError, BelowMinimumRedemptionError, CastingError, ChunkHasZeroLiquidityError, ChunkLimitError, CrossPoolError, DEFAULT_MAX_SPREAD, DEFAULT_MINT_BUFFER, DEFAULT_MIN_SWAP_RATIO_BPS, DEFAULT_RECONNECT_CONFIG, DEFAULT_VEGOID, DepositTooLargeError, DuplicateTokenIdError, EffectiveLiquidityAboveThresholdError, ExceedsMaximumRedemptionError, InputListFailError, InsufficientCreditLiquidityError, InvalidBuilderCodeError, InvalidHistoryRangeError, InvalidTickBoundError, InvalidTickError, InvalidTokenIdParameterError, InvalidUniswapCallbackError, LEG_BITS, LEG_LIMITS, LEG_MASKS, LengthMismatchError, LiquidityTooHighError, LoanSlotExhaustedError, MARKET_EPOCH_BITS, MARKET_EPOCH_SHIFT, MARKET_INDICATOR_PERIODS, MAX_TICK, MAX_TRACKED_CHUNKS, MINT_BUFFER, MINT_BUFFER_DENOMINATOR, MIN_TICK, MaxRetriesExceededError, MissingPositionIdsError, NO_LOWER_LIQUIDATION_TICK, NO_UPPER_LIQUIDATION_TICK, NetLiquidityZeroError, NetworkMismatchError, NoLegsExercisableError, NotALongLegError, NotBuilderError, NotEnoughLiquidityInChunkError, NotEnoughTokensError, NotGuardianError, NotMarginCalledError, NotPanopticPoolError, ORACLE_EPOCH_SECONDS, OracleRateLimitedError, PanopticError, PanopticHelperNotDeployedError, PanopticProvider, PanopticValidationError, PoolNotInitializedError, PositionCountNotZeroError, PositionNotOwnedError, PositionSnapshotNotFoundError, PositionTooLargeError, PriceBoundFailError, PriceImpactTooLargeError, ProviderLagError, RATE_AT_TARGET_BITS, REORG_DEPTH, REQUIRED_BASE_ERROR_SENTINEL, ReentrancyError, RpcError, RpcResponseError, SCHEMA_VERSION, SECONDS_PER_YEAR, STANDARD_TICK_WIDTHS, STORAGE_PREFIX, STRIKE_LADDER_TARGET_STRIKES, SafeModeError, StaleDataError, StaleOracleError, SwapTokenMismatchError, SyncTimeoutError, TOKEN_ID_BITS, TokenIdHasZeroLegsError, TooManyLegsOpenError, TransferFailedError, UNREALIZED_INTEREST_BITS, UTILIZATION_DENOMINATOR, UnauthorizedUniswapCallbackError, UnderOverFlowError, UnhealthyPoolError, UnsafePremiumSettlementError, VARIANCE_RATIO_LAG, WAD, WrongPoolIdError, WrongUniswapPoolError, ZERO_COLLATERAL, ZERO_VALUATION, ZeroAddressError, ZeroCollateralRequirementError, addLegToTokenId, addPendingPosition, addTrackedChunks, annualizePerSecondRateWad, applyMintBuffer, applyMintBufferPerToken, apportion, approve, approveAndWait, approvePool, assertCanBurn, assertCanForceExercise, assertCanLiquidate, assertCanMint, assertFresh, assertHealthy, assertLpPositionFunded, assertTradeable, borrow, borrowAndWait, buildBatchDispatchArgs, buildCreditSwapCall, buildCreditWrappedDispatch, buildOpenPositionCalldata, buildProtectedSettleDispatch, buildProtectedSettlePlan, buildSettleSequenceCalls, buildSfpmSwapCalldata, buildSfpmSwapPlan, buildTemporaryLoanRecoveryDispatch, buildTokenShortfallRecoveryDispatch, buildUniqueCredit, buildUniqueLoan, buildUniqueWidthZeroLeg, calculateAccountGreeksPure, calculateMarketIndicator, calculatePortfolioDelta, calculatePortfolioGamma, calculatePortfolioGreeks, calculatePortfolioValue, calculatePositionDelta, calculatePositionDeltaDebtOnly, calculatePositionDeltaWithSwap, calculatePositionGamma, calculatePositionGreeks, calculatePositionValue, calculatePositionValues, calculatePositionVolatilityMetrics, calculateResyncBlock, calculateSpreadWad, calculateVarianceProfile, cancelTransaction, checkApproval, checkCollateralAcrossTicks, classifyStrategyGroups, classifyStrike, cleanupStalePendingPositions, clearCheckpoint, clearPendingPositions, clearTrackedChunks, clearTrackedPositions, clearTradeHistory, closePosition, closePositionAndWait, collateralCurveTicks, collateralRuleKindFor, collateralTrackerV2Abi, computeV4PoolId, confirmPendingPosition, convertToAssets, convertToShares, countLegs, createEventPoller, createEventSubscription, createFileStorage, createFlowNeutralTokenId, createMemoryStorage, createNonceManager, createPoolFormatters, createTokenIdBuilder, decodeAllDispatchCalldata, decodeAllLegs, decodeDispatchCalldata, decodeLeftRightSigned, decodeLeftRightUnsigned, decodeLeg, decodeOraclePack, decodeOracleRiskParameters, decodeOracleTiming, decodePanopticTokenURI, decodePoolId, decodeTickSpacing, decodeTokenId, decodeVegoid, deployNewPool, deployNewPoolAndWait, deposit, depositAndWait, deriveSupplyRatePerSecWad, deriveUniqueTokenId, detectReorg, diagnoseOracleSafeMode, dispatch, dispatchAndWait, emptyLiquidateParams, encodeLeg, encodePoolId, encodePoolKeyBytes, encodeV3PoolKeyBytes, encodeV4PoolId, ensureSfpmV3PoolInitialized, estimateBlockNumbers, estimateCloseZapSwap, estimateCollateralBreakdown, estimateCollateralRequired, executeBatchDispatch, executeBatchDispatchAndWait, executeSettleSequence, executeSettleSequenceAndWait, failPendingPosition, feeGrowthInsideX128, feesFromFeeGrowthDelta, fetchPoolId, fetchPoolSwaps, fetchSfpmV3PoolId, fetchUniswapFeeData, forceExercise, forceExerciseAndWait, formatBlockNumber, formatBps, formatCompact, formatDatetime, formatDuration, formatDurationSeconds, formatFeeTier, formatGas, formatGwei, formatPerSecondRateWadAsAprPct, formatPerSecondRateWadAsApyPct, formatPoolIdHex, formatPriceRange, formatRateWad, formatRatioPercent, formatTick, formatTickRange, formatTimestamp, formatTimestampLocale, formatTokenAmount, formatTokenAmountSigned, formatTokenDelta, formatTokenFlow, formatTokenIdHex, formatTokenIdShort, formatTxHash, formatUtilization, formatWad, formatWadPercent, formatWadSigned, formatWei, generateOverlappingTokenIds, getAccountBuyingPower, getAccountCollateral, getAccountGreeks, getAccountHistory, getAccountPremia, getAccountSummaryBasic, getAccountSummaryRisk, getAssetIndex, getBlockMeta, getChainDeployment, getChunkLiquidities, getChunkSpreads, getClosePositionTransferEstimate, getClosedPositions, getClosedPositionsKey, getCollateralAddresses, getCollateralCurve, getCollateralCurveInputs, getCollateralData, getCollateralRequiredBase, getCollateralSharePrices, getCollateralTotalAssetsBatch, getCurrentRates, getDeltaHedgeParams, getEnforcedTickLimits, getExecutableLpMaxSize, getFactoryConstructMetadata, getFactoryOwnerOf, getFactoryTokenURI, getForfeitablePremium, getGuardianUnlockState, getHedgeLimits, getInterestState, getIrmCurrent, getIrmCurve, getItmAmounts, getLegDelta, getLegDeltaInVaultFrame, getLegGamma, 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, isCowSupportedChain, isCredit, isCreditLeg, isDefinedRisk, isGasError, isInputListFailError, isLiquidatable, isLoan, isLoanLeg, isNonceError, isPanopticErrorType, isPositionTracked, isRetryableRpcError, isShortOnly, isSpread, isSupportedChain, isolateGroupTokenId, jsonSerializer, ladderStrikeSequence, liquidate, liquidateAndWait, loadCheckpoint, logReturns, marketPnlInQuote, marketRiskFromValues, marketScenario, minePoolAddress, mint, mintAndWait, mintableAfterBuffer, multicallRead, mutationEffects, netLiquidationValueInQuote, openPosition, openPositionAndWait, optimizeTokenIdRiskPartners, oracleEpochAt, orderListForSettle, packMarketState, panopticLiquidatorAbi, panopticPoolV2Abi, panopticQueryAbi, parseBps, parseCollateralLog, parsePanopticError, parsePoolLog, parseStreamedKey, parseStreamedSwap, parseSwapLog, parseTokenAmount, parseTokenListId, parseWad, planDeriveStrategy, pokeOracle, pokeOracleAndWait, positionValueKey, positionValueTicks, prepareIndicatorCandles, prepareLiquidityGamma, preparePositionGamma, preparePositionValue, preparePositionValueCurve, previewBorrow, previewDeposit, previewMint, previewRedeem, previewRepay, previewUnwrap, previewWithdraw, previewWrap, priceToTick, publicBroadcaster, queryKeys, quoteLiquidation, quoteOneTokenFlow, quoteSfpmSwap, quoteTemporaryLoanRecovery, quoteTokenShortfallRecovery, quoteTokenShortfallSwap, quoteV3ExactIn, ratePerSecWadToAprPct, realizedBeta, reconstructFromEvents, recoverSnapshot, recoverSnapshotFromTx, redeem, redeemAndWait, removeTrackedChunks, repay, repayAndWait, requireChainDeployment, resolveBlockNumbers, resolveLadderStrike, resolvePanopticPoolFromPoolId, resolveTokenIndex, resolveUniswapV4PoolKey, riskEngineAbi, rollPosition, rollPositionAndWait, roundToTickSpacing, saveCheckpoint, saveClosedPosition, scaleCollateralRequired, scanChunks, screenAccountExact, selectDispatchForAccount, settleAccumulatedPremia, settleAccumulatedPremiaAndWait, settlePremiumFrom, settlePremiumFromAndWait, simulateBatchDispatch, simulateClosePosition, simulateClosePremiumProtection, simulateDeployNewPool, simulateDeposit, simulateDispatch, simulateForceExercise, simulateLiquidate, simulateOpenPosition, simulateSFPMBurn, simulateSFPMMint, simulateSettle, simulateSettlePremiumBatch, simulateSettlePremiumFrom, simulateSettleSequence, simulateSwapExactIn, simulateSwapExactOut, simulateWithTokenFlow, simulateWithdraw, slippageBpsToTickDistance, smartRepay, smartRepayAndWait, speedUpTransaction, splitTokenIdByTimescale, sqrtPriceX96ToPriceDecimalScaled, sqrtPriceX96ToTick, streamPoolSwaps, subscribePoolSwaps, supply, supplyAndWait, swapExactIn, swapExactInAndWait, swapExactOut, swapExactOutAndWait, syncPositions, tickLimits, tickToPrice, tickToPriceDecimalScaled, tickToSqrtPriceX96, toVaultFrameAtTick, truncateAddress, unsupply, unsupplyAndWait, unwrapWeth, unwrapWethAndWait, unwrapXstock, unwrapXstockAndWait, useAccountCollateral, useAccountGreeks, useAccountPremia, useAccountSummaryBasic, useAccountSummaryRisk, useAddPendingPosition, useApprove, useApproveErc20ForCow, useApproveErc20ForPermit2, useApprovePool, useApproveRouterViaPermit2, useBatchDispatch as useBatchDispatchHook, useBorrow as useBorrowHook, useCancelCowOrder, useCheckCowApproval, useCheckRouterApproval, useChunkSpreads, useClearTrackedPositions, useClosePosition as useClosePositionHook, useClosedPositions, useCollateralBreakdown, useCollateralData, useConfirmPendingPosition, useCowOrderStatus, useCurrentRates, useDeployNewPool as useDeployNewPoolHook, useDeposit as useDepositHook, useDispatch as useDispatchHook, useEstimateCollateralRequired, useEventPoller, useEventSubscription, useExecuteSettleSequence, useFactoryConstructMetadata, useFactoryOwnerOf, useFactoryTokenURI, useFailPendingPosition, useFlowNeutralTokenId, useForceExercise as useForceExerciseHook, useForfeitablePremium, useGuardianUnlockState, useInterestState, useIsLiquidatable, useLiquidate as useLiquidateHook, useLiquidationPrices, useMarginBuffer, useMaxPositionSize, useMaxRedeem, useMaxWithdrawable, useMinePoolAddress as useMinePoolAddressHook, useMintShares, useNativeTokenPrice, useNetLiquidationValue, useNetLiquidationValues, useOpenPosition as useOpenPositionHook, useOpenPositionPreview, useOptimizeRiskPartners, useOracleState, usePanopticContext, usePanopticPoolAddress, usePokeOracle as usePokeOracleHook, usePool, usePoolLiquidities, usePoolSwaps, usePoolVersion, usePosition, usePositionGreeks, usePositions, usePositionsWithPremia, usePreviewBorrow, usePreviewDeposit, usePreviewMint, usePreviewRedeem, usePreviewWithdraw, usePriceHistory, useQuoteCowSwap, useQuoteSwapExactInViaRouter, useQuoteSwapExactOutViaRouter, useRealizedPnL, useRedeem as useRedeemHook, useRepay as useRepayHook, useResolveUniswapV4PoolKey, useRiskParameters, useRollPosition as useRollPositionHook, useSafeMode, useSettleAccumulatedPremia as useSettleAccumulatedPremiaHook, useSettlePremiumFrom as useSettlePremiumFromHook, useSimulateBatchDispatch, useSimulateClosePosition, useSimulateDeployNewPool, useSimulateDeposit, useSimulateDispatch, useSimulateForceExercise, useSimulateLiquidate, useSimulateOpenPosition, useSimulateSFPMBurn, useSimulateSFPMMint, useSimulateSettle, useSimulateSettlePremiumBatch, useSimulateSettlePremiumFrom, useSimulateSettleSequence, useSimulateSwapExactIn, useSimulateSwapExactOut, useSimulateWithdraw, useSmartRepay as useSmartRepayHook, useStreamiaHistory, useSubmitCowOrder, useSupply as useSupplyHook, useSwapExactIn, useSwapExactInViaRouter, useSwapExactOut, useSwapExactOutViaRouter, useSyncPositions, useSyncStatus, useTrackedPositionIds, useTradeHistory, useTxEventConfirmation, useUniswapFeeHistory, useUniswapV3PoolInfo, useUniswapV3PoolLiquidities, useUniswapV4PoolBasicState, useUniswapV4PoolInfo, useUniswapV4PoolLiquidities, useUnsupply as useUnsupplyHook, useUnwrapWeth, useUnwrapXstock, useUtilization, useValidateBuilderCode, useWatchEvents, useWithdraw as useWithdrawHook, useWithdrawWithPositions as useWithdrawWithPositionsHook, useWrapEth, useWrapXstock, utilizationBpsToWad, utilizationPctToWad, validateBatch, validateBuilderCode, validatePoolId, valuePositionAccrual, verifyBlockContinuity, watchEvents, watchPoolSwaps, wethWrapAbi, withdraw, withdrawAndWait, withdrawWithPositions, withdrawWithPositionsAndWait, wrapEth, wrapEthAndWait, wrapXstock, wrapXstockAndWait, xstockWrapperAbi };
40500
40532
  //# sourceMappingURL=react-public.js.map