@panoptic-eng/sdk 1.0.60 → 1.0.62
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.
- package/dist/{chainDeployments-CmDzAmZ3.js → chainDeployments-BhXMBZ4B.js} +50 -12
- package/dist/cow/index.js +1207 -484
- package/dist/cow/index.js.map +1 -1
- package/dist/{cow-CHb343la.js → cow-DTi3GjQz.js} +1 -1
- package/dist/deployments.d.ts +9 -1
- package/dist/deployments.d.ts.map +1 -1
- package/dist/deployments.js +50 -12
- package/dist/deployments.js.map +1 -1
- package/dist/index.d.ts +587 -75
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +577 -357
- package/dist/index.js.map +1 -1
- package/dist/{irm-BIaLQ-0n.js → irm-BDlcUNgJ.js} +2 -2
- package/dist/panoptic/v2/index.d.ts +169 -3
- package/dist/panoptic/v2/index.d.ts.map +1 -1
- package/dist/panoptic/v2/index.js +658 -107
- package/dist/panoptic/v2/index.js.map +1 -1
- package/dist/panoptic/v2/react-public.d.ts +177 -3
- package/dist/panoptic/v2/react-public.d.ts.map +1 -1
- package/dist/panoptic/v2/react-public.js +674 -113
- package/dist/panoptic/v2/react-public.js.map +1 -1
- package/dist/{rates-COAJpKRd.js → rates-BwZnK0tG.js} +498 -482
- package/dist/{router-B2fj4_X7.js → router-Y1OxL9Nt.js} +2 -2
- package/dist/{router-DliBF9FK.js → router-jMP7fVno.js} +2 -2
- package/dist/{transactionFees-CNbjAigT.js → transactionFees-aXQlx-lq.js} +11 -6
- package/dist/uniswap/index.js +724 -1
- package/dist/uniswap/index.js.map +1 -1
- package/dist/{v2-C3n8n1_i.js → v2-B27ILZl4.js} +518 -202
- package/dist/vault-transaction-fees.d.ts +1 -0
- package/dist/vault-transaction-fees.d.ts.map +1 -1
- package/dist/vault-transaction-fees.js +59 -16
- package/dist/vault-transaction-fees.js.map +1 -1
- package/dist/{writes-BTkqc_rn.js → writes-B8NGXzUG.js} +219 -38
- package/package.json +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { BaseError, ContractFunctionExecutionError, ContractFunctionRevertedError, ExecutionRevertedError, decodeAbiParameters, decodeErrorResult, decodeEventLog, decodeFunctionData, decodeFunctionResult, encodeAbiParameters, encodeFunctionData, encodePacked, erc20Abi, getAbiItem, getAddress, hexToString, isAddressEqual, keccak256, maxUint256, parseAbi, stringToHex, toFunctionSelector, toHex, trim, zeroAddress } from "viem";
|
|
1
|
+
import { BaseError, ContractFunctionExecutionError, ContractFunctionRevertedError, ExecutionRevertedError, decodeAbiParameters, decodeErrorResult, decodeEventLog, decodeFunctionData, decodeFunctionResult, encodeAbiParameters, encodeFunctionData, encodePacked, erc20Abi, getAbiItem, getAddress, hexToString, isAddressEqual, keccak256, maxUint256, parseAbi, parseEventLogs, stringToHex, toFunctionSelector, toHex, trim, zeroAddress } from "viem";
|
|
2
2
|
import { call, multicall } from "viem/actions";
|
|
3
3
|
import Decimal from "decimal.js";
|
|
4
4
|
import { keepPreviousData, useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
|
|
@@ -9400,6 +9400,10 @@ function extractErrorData(error) {
|
|
|
9400
9400
|
error.walk((e) => {
|
|
9401
9401
|
if (foundData) return false;
|
|
9402
9402
|
const node = e;
|
|
9403
|
+
if (typeof node.raw === "string" && node.raw.startsWith("0x") && node.raw.length > 10) {
|
|
9404
|
+
foundData = node.raw;
|
|
9405
|
+
return true;
|
|
9406
|
+
}
|
|
9403
9407
|
if (node.data && typeof node.data === "string" && node.data.startsWith("0x")) {
|
|
9404
9408
|
foundData = node.data;
|
|
9405
9409
|
return true;
|
|
@@ -9428,6 +9432,7 @@ function extractErrorData(error) {
|
|
|
9428
9432
|
let current = error;
|
|
9429
9433
|
const maxDepth = 10;
|
|
9430
9434
|
for (let i = 0; i < maxDepth && current; i++) {
|
|
9435
|
+
if (typeof current.raw === "string" && current.raw.startsWith("0x") && current.raw.length > 10) return current.raw;
|
|
9431
9436
|
if (current.data && typeof current.data === "string" && current.data.startsWith("0x")) return current.data;
|
|
9432
9437
|
if (current.data && typeof current.data === "object") {
|
|
9433
9438
|
const nested = current.data;
|
|
@@ -9441,7 +9446,7 @@ function extractErrorData(error) {
|
|
|
9441
9446
|
}
|
|
9442
9447
|
const obj = error;
|
|
9443
9448
|
if (obj.message && typeof obj.message === "string") {
|
|
9444
|
-
const signatureMatch = obj.message.match(/signature
|
|
9449
|
+
const signatureMatch = obj.message.match(/signature:?\s*["']?(0x[a-fA-F0-9]{8,})/i);
|
|
9445
9450
|
if (signatureMatch) return signatureMatch[1];
|
|
9446
9451
|
}
|
|
9447
9452
|
return null;
|
|
@@ -11112,12 +11117,12 @@ function generateOverlappingTokenIds(params) {
|
|
|
11112
11117
|
//#region src/panoptic/v2/tokenId/split.ts
|
|
11113
11118
|
const POOL_ID_MASK$3 = (1n << TOKEN_ID_BITS.POOL_ID_SIZE) - 1n;
|
|
11114
11119
|
const MAX_UINT128$3 = (1n << 128n) - 1n;
|
|
11115
|
-
const MAX_UINT256$
|
|
11120
|
+
const MAX_UINT256$2 = (1n << 256n) - 1n;
|
|
11116
11121
|
function invalid(message) {
|
|
11117
11122
|
throw new PanopticValidationError(`splitTokenIdByTimescale: ${message}`);
|
|
11118
11123
|
}
|
|
11119
11124
|
function validateInput(tokenId, positionSize) {
|
|
11120
|
-
if (tokenId < 0n || tokenId > MAX_UINT256$
|
|
11125
|
+
if (tokenId < 0n || tokenId > MAX_UINT256$2) invalid("tokenId must fit in uint256");
|
|
11121
11126
|
if (positionSize <= 0n || positionSize > MAX_UINT128$3) invalid("positionSize must be between 1 and uint128.max");
|
|
11122
11127
|
const legs = decodeAllLegs(tokenId);
|
|
11123
11128
|
if (legs.length === 0) invalid("tokenId must contain at least one active leg");
|
|
@@ -11272,7 +11277,7 @@ function splitTokenIdByTimescale(tokenId, positionSize, targetTimescale) {
|
|
|
11272
11277
|
|
|
11273
11278
|
//#endregion
|
|
11274
11279
|
//#region src/uniswap/lpDeposit.ts
|
|
11275
|
-
const Q96$
|
|
11280
|
+
const Q96$3 = 1n << 96n;
|
|
11276
11281
|
const ceilDiv$4 = (n, d) => (n + d - 1n) / d;
|
|
11277
11282
|
/** Principal and separately identified funding headroom, in native token units. */
|
|
11278
11283
|
function getLpDepositBreakdown(ranges, sqrtPriceX96) {
|
|
@@ -11284,8 +11289,8 @@ function getLpDepositBreakdown(ranges, sqrtPriceX96) {
|
|
|
11284
11289
|
const lower = tickToSqrtPriceX96(BigInt(tickLower));
|
|
11285
11290
|
const upper = tickToSqrtPriceX96(BigInt(tickUpper));
|
|
11286
11291
|
const price = sqrtPriceX96 < lower ? lower : sqrtPriceX96 > upper ? upper : sqrtPriceX96;
|
|
11287
|
-
amount0 += ceilDiv$4(liquidity * Q96$
|
|
11288
|
-
amount1 += ceilDiv$4(liquidity * (price - lower), Q96$
|
|
11292
|
+
amount0 += ceilDiv$4(liquidity * Q96$3 * (upper - price), upper * price);
|
|
11293
|
+
amount1 += ceilDiv$4(liquidity * (price - lower), Q96$3);
|
|
11289
11294
|
}
|
|
11290
11295
|
const buffer = {
|
|
11291
11296
|
amount0: ceilDiv$4(amount0 * 5n, 100n),
|
|
@@ -11313,7 +11318,7 @@ function getUnhedgedLpRanges({ tokenId, positionSize, tickSpacing }) {
|
|
|
11313
11318
|
const lower = tickToSqrtPriceX96(tickLower);
|
|
11314
11319
|
const upper = tickToSqrtPriceX96(tickUpper);
|
|
11315
11320
|
const amount = positionSize * leg.optionRatio;
|
|
11316
|
-
const liquidity = leg.asset === 0n ? amount * (lower * upper / Q96$
|
|
11321
|
+
const liquidity = leg.asset === 0n ? amount * (lower * upper / Q96$3) / (upper - lower) : amount * Q96$3 / (upper - lower);
|
|
11317
11322
|
return liquidity <= 0n ? [] : [{
|
|
11318
11323
|
tickLower: Number(tickLower),
|
|
11319
11324
|
tickUpper: Number(tickUpper),
|
|
@@ -11334,7 +11339,7 @@ function getLpPositionFunding(params) {
|
|
|
11334
11339
|
});
|
|
11335
11340
|
const breakdown = getLpDepositBreakdown(ranges, sqrtPriceX96);
|
|
11336
11341
|
const priceSquared = valuationSqrtPriceX96 * valuationSqrtPriceX96;
|
|
11337
|
-
const value = ({ amount0, amount1 }) => quoteTokenIndex === 0 ? amount0 + ceilDiv$4(amount1 * Q96$
|
|
11342
|
+
const value = ({ amount0, amount1 }) => quoteTokenIndex === 0 ? amount0 + ceilDiv$4(amount1 * Q96$3 * Q96$3, priceSquared) : amount1 + ceilDiv$4(amount0 * priceSquared, Q96$3 * Q96$3);
|
|
11338
11343
|
const principalInQuote = value(breakdown.principal);
|
|
11339
11344
|
const totalInQuote = value(breakdown.total);
|
|
11340
11345
|
return {
|
|
@@ -12740,6 +12745,17 @@ function createTxResult(client, hash) {
|
|
|
12740
12745
|
* @returns TxResult
|
|
12741
12746
|
*/
|
|
12742
12747
|
async function submitWrite(params) {
|
|
12748
|
+
try {
|
|
12749
|
+
return await submitWriteRequest({
|
|
12750
|
+
...params,
|
|
12751
|
+
abi: [...params.abi, ...panopticErrorsAbi]
|
|
12752
|
+
});
|
|
12753
|
+
} catch (error) {
|
|
12754
|
+
if (error instanceof PanopticError) throw error;
|
|
12755
|
+
throw parsePanopticError(error)?.error ?? error;
|
|
12756
|
+
}
|
|
12757
|
+
}
|
|
12758
|
+
async function submitWriteRequest(params) {
|
|
12743
12759
|
const { client, walletClient, account, address, abi: abi$1, functionName, args, value, txOverrides } = params;
|
|
12744
12760
|
const broadcaster = txOverrides?.broadcaster;
|
|
12745
12761
|
if (broadcaster) {
|
|
@@ -14467,7 +14483,7 @@ async function assertLpPositionFunded(params) {
|
|
|
14467
14483
|
//#endregion
|
|
14468
14484
|
//#region src/panoptic/v2/greeks/index.ts
|
|
14469
14485
|
/** Fixed-point scale constants for sqrtPriceX96 arithmetic */
|
|
14470
|
-
const Q96$
|
|
14486
|
+
const Q96$2 = 1n << 96n;
|
|
14471
14487
|
const Q192$3 = 1n << 192n;
|
|
14472
14488
|
/**
|
|
14473
14489
|
* Convert tick to quote-denominated tick based on asset direction.
|
|
@@ -14615,7 +14631,7 @@ function computeOptionItm(m, qStrikeTick, qMintTick, halfWidthTick, isPut) {
|
|
|
14615
14631
|
const sqrtK = tickToSqrtPriceX96(qStrikeTick);
|
|
14616
14632
|
const sqrtPm = tickToSqrtPriceX96(qMintTick);
|
|
14617
14633
|
const rX192 = sqrtR * sqrtR;
|
|
14618
|
-
const sqrtKPmX96 = divTrunc(sqrtK * Q96$
|
|
14634
|
+
const sqrtKPmX96 = divTrunc(sqrtK * Q96$2, sqrtPm);
|
|
14619
14635
|
const diff = sqrtR - sqrtKPmX96;
|
|
14620
14636
|
const diffSqX192 = diff * diff;
|
|
14621
14637
|
return divTrunc(m * diffSqX192, rX192 - Q192$3);
|
|
@@ -14687,7 +14703,7 @@ function getLegValue(leg, currentTick, mintTick, positionSize, poolTickSpacing,
|
|
|
14687
14703
|
const PX192 = sqrtP * sqrtP;
|
|
14688
14704
|
const KX192 = sqrtK * sqrtK;
|
|
14689
14705
|
const rX192 = sqrtR * sqrtR;
|
|
14690
|
-
const numerator = m * (2n * sqrtPKR * Q96$
|
|
14706
|
+
const numerator = m * (2n * sqrtPKR * Q96$2 - PX192 - KX192);
|
|
14691
14707
|
const denominator = rX192 - Q192$3;
|
|
14692
14708
|
v = divTrunc(numerator, denominator);
|
|
14693
14709
|
}
|
|
@@ -14795,7 +14811,7 @@ function getLegDelta(leg, currentTick, positionSize, poolTickSpacing, mintTick,
|
|
|
14795
14811
|
const sqrtK = tickToSqrtPriceX96(qStrikeTick);
|
|
14796
14812
|
const sqrtPm = tickToSqrtPriceX96(qMintTick);
|
|
14797
14813
|
const rX192 = sqrtR * sqrtR;
|
|
14798
|
-
const sqrtKPmX96 = sqrtK * Q96$
|
|
14814
|
+
const sqrtKPmX96 = sqrtK * Q96$2 / sqrtPm;
|
|
14799
14815
|
const diff = sqrtR - sqrtKPmX96;
|
|
14800
14816
|
const diffSqX192 = diff * diff;
|
|
14801
14817
|
return divTrunc(m * diffSqX192, rX192 - Q192$3);
|
|
@@ -14854,7 +14870,7 @@ function getLegGamma(leg, currentTick, positionSize, poolTickSpacing, assetIndex
|
|
|
14854
14870
|
const sqrtKPR = tickToSqrtPriceX96(qStrikeTick + qCurrentTick + halfWidthTick);
|
|
14855
14871
|
const sqrtR = tickToSqrtPriceX96(halfWidthTick);
|
|
14856
14872
|
const rX192 = sqrtR * sqrtR;
|
|
14857
|
-
const numerator = m * sqrtKPR * Q96$
|
|
14873
|
+
const numerator = m * sqrtKPR * Q96$2;
|
|
14858
14874
|
const denominator = 2n * (rX192 - Q192$3);
|
|
14859
14875
|
return divTrunc(numerator, denominator);
|
|
14860
14876
|
}
|
|
@@ -22321,6 +22337,73 @@ async function optimizeTokenIdRiskPartners(params) {
|
|
|
22321
22337
|
return optimizedTokenId;
|
|
22322
22338
|
}
|
|
22323
22339
|
|
|
22340
|
+
//#endregion
|
|
22341
|
+
//#region src/panoptic/v2/reads/tickNetWindows.ts
|
|
22342
|
+
/**
|
|
22343
|
+
* Wide liquidity distributions from several adjacent `getTickNets*` windows.
|
|
22344
|
+
*
|
|
22345
|
+
* @module v2/reads/tickNetWindows
|
|
22346
|
+
*/
|
|
22347
|
+
/** Absolute Uniswap V3/V4 tick bounds. */
|
|
22348
|
+
const TICK_MIN$1 = -887272;
|
|
22349
|
+
const TICK_MAX$1 = 887272;
|
|
22350
|
+
/**
|
|
22351
|
+
* Join ascending, edge-sharing windows into one distribution anchored to `windows[mainIndex]`.
|
|
22352
|
+
*
|
|
22353
|
+
* Each `getTickNets*` window is a running sum of liquidityNet from its own first tick (only the
|
|
22354
|
+
* window holding the current tick is rescaled to the pool's liquidity), so a neighbour's values
|
|
22355
|
+
* are off by a constant. Adjacent windows share their edge tick; the offset that makes that tick
|
|
22356
|
+
* agree is applied to the whole neighbour. Stitching stops at the first window that does not share
|
|
22357
|
+
* an edge with the one before it.
|
|
22358
|
+
*/
|
|
22359
|
+
function stitchTickNetWindows(windows, mainIndex) {
|
|
22360
|
+
const main = windows[mainIndex];
|
|
22361
|
+
if (!main) return {
|
|
22362
|
+
ticks: [],
|
|
22363
|
+
liquidityNets: []
|
|
22364
|
+
};
|
|
22365
|
+
const ticks = [...main.ticks];
|
|
22366
|
+
const nets = [...main.liquidityNets];
|
|
22367
|
+
for (let i = mainIndex + 1; i < windows.length; i++) {
|
|
22368
|
+
const window = windows[i];
|
|
22369
|
+
const edge = ticks.length - 1;
|
|
22370
|
+
if (!window.ticks.length || window.ticks[0] !== ticks[edge]) break;
|
|
22371
|
+
const offset = nets[edge] - window.liquidityNets[0];
|
|
22372
|
+
ticks.push(...window.ticks.slice(1));
|
|
22373
|
+
nets.push(...window.liquidityNets.slice(1).map((value) => value + offset));
|
|
22374
|
+
}
|
|
22375
|
+
for (let i = mainIndex - 1; i >= 0; i--) {
|
|
22376
|
+
const window = windows[i];
|
|
22377
|
+
const last = window.ticks.length - 1;
|
|
22378
|
+
if (last < 0 || window.ticks[last] !== ticks[0]) break;
|
|
22379
|
+
const offset = nets[0] - window.liquidityNets[last];
|
|
22380
|
+
ticks.unshift(...window.ticks.slice(0, last));
|
|
22381
|
+
nets.unshift(...window.liquidityNets.slice(0, last).map((value) => value + offset));
|
|
22382
|
+
}
|
|
22383
|
+
return {
|
|
22384
|
+
ticks,
|
|
22385
|
+
liquidityNets: nets
|
|
22386
|
+
};
|
|
22387
|
+
}
|
|
22388
|
+
/**
|
|
22389
|
+
* Read the main window around `startTick` plus up to `windowsPerSide` windows of `nTicks` on each
|
|
22390
|
+
* side, in parallel, and stitch them. Side windows that would cross the tick bounds are skipped.
|
|
22391
|
+
*/
|
|
22392
|
+
async function readTickNetWindows({ startTick, mainNTicks, nTicks, tickSpacing, windowsPerSide, read }) {
|
|
22393
|
+
const center = Math.trunc(startTick / tickSpacing) * tickSpacing;
|
|
22394
|
+
const half = Number(nTicks) * tickSpacing;
|
|
22395
|
+
const mainHalf = Number(mainNTicks) * tickSpacing;
|
|
22396
|
+
const sideCenters = (direction) => Array.from({ length: windowsPerSide }, (_, k) => center + direction * (mainHalf + half + 2 * half * k)).filter((side) => side - half >= TICK_MIN$1 && side + half <= TICK_MAX$1);
|
|
22397
|
+
const below = sideCenters(-1).reverse();
|
|
22398
|
+
const above = sideCenters(1);
|
|
22399
|
+
const windows = await Promise.all([
|
|
22400
|
+
...below.map((side) => read(side, nTicks)),
|
|
22401
|
+
read(startTick, mainNTicks),
|
|
22402
|
+
...above.map((side) => read(side, nTicks))
|
|
22403
|
+
]);
|
|
22404
|
+
return stitchTickNetWindows(windows, below.length);
|
|
22405
|
+
}
|
|
22406
|
+
|
|
22324
22407
|
//#endregion
|
|
22325
22408
|
//#region src/panoptic/v2/reads/liquidity.ts
|
|
22326
22409
|
/**
|
|
@@ -22338,24 +22421,35 @@ async function optimizeTokenIdRiskPartners(params) {
|
|
|
22338
22421
|
async function getPoolLiquidities(params) {
|
|
22339
22422
|
const { client, poolAddress, queryAddress, startTick, nTicks, blockNumber } = params;
|
|
22340
22423
|
const targetBlockNumber = blockNumber ?? params._meta?.blockNumber ?? await client.getBlockNumber();
|
|
22341
|
-
const
|
|
22342
|
-
|
|
22343
|
-
|
|
22344
|
-
|
|
22345
|
-
|
|
22346
|
-
|
|
22347
|
-
|
|
22348
|
-
|
|
22349
|
-
|
|
22350
|
-
|
|
22424
|
+
const windowsPerSide = params.windowsPerSide ?? 0;
|
|
22425
|
+
if (windowsPerSide > 0 && params.tickSpacing === void 0) throw new PanopticValidationError("getPoolLiquidities: tickSpacing is required with windowsPerSide");
|
|
22426
|
+
const [{ ticks, liquidityNets }, _meta] = await Promise.all([readTickNetWindows({
|
|
22427
|
+
startTick: Number(startTick),
|
|
22428
|
+
mainNTicks: nTicks,
|
|
22429
|
+
nTicks,
|
|
22430
|
+
tickSpacing: params.tickSpacing ?? 1,
|
|
22431
|
+
windowsPerSide,
|
|
22432
|
+
read: (centerTick, windowTicks) => client.readContract({
|
|
22433
|
+
address: queryAddress,
|
|
22434
|
+
abi: panopticQueryAbi$1,
|
|
22435
|
+
functionName: "getTickNets",
|
|
22436
|
+
args: [
|
|
22437
|
+
poolAddress,
|
|
22438
|
+
centerTick,
|
|
22439
|
+
windowTicks
|
|
22440
|
+
],
|
|
22441
|
+
blockNumber: targetBlockNumber
|
|
22442
|
+
}).then(([tickData, nets]) => ({
|
|
22443
|
+
ticks: tickData,
|
|
22444
|
+
liquidityNets: nets
|
|
22445
|
+
}))
|
|
22351
22446
|
}), params._meta ?? getBlockMeta({
|
|
22352
22447
|
client,
|
|
22353
22448
|
blockNumber: targetBlockNumber
|
|
22354
22449
|
})]);
|
|
22355
|
-
const [tickData, liquidityNets] = result;
|
|
22356
22450
|
return {
|
|
22357
|
-
ticks
|
|
22358
|
-
liquidityNets
|
|
22451
|
+
ticks,
|
|
22452
|
+
liquidityNets,
|
|
22359
22453
|
_meta
|
|
22360
22454
|
};
|
|
22361
22455
|
}
|
|
@@ -23434,6 +23528,32 @@ function computeUniswapFeesForBlock(blockData, legs) {
|
|
|
23434
23528
|
total1
|
|
23435
23529
|
};
|
|
23436
23530
|
}
|
|
23531
|
+
const MAX_UINT256$1 = 2n ** 256n - 1n;
|
|
23532
|
+
/**
|
|
23533
|
+
* Fee growth per unit of liquidity inside `[lowerTick, upperTick)` at one block,
|
|
23534
|
+
* wrapped to uint256 as the pool computes it. Diff two snapshots with
|
|
23535
|
+
* `feesFromFeeGrowthDelta` to get the fees a constant liquidity earned between them.
|
|
23536
|
+
*/
|
|
23537
|
+
function feeGrowthInsideX128(blockData, lowerTick, upperTick) {
|
|
23538
|
+
const lower = blockData.tickData.get(lowerTick);
|
|
23539
|
+
const upper = blockData.tickData.get(upperTick);
|
|
23540
|
+
if (!lower || !upper) return null;
|
|
23541
|
+
const { currentTick } = blockData;
|
|
23542
|
+
const inside = (global, lowerOutside, upperOutside) => {
|
|
23543
|
+
const below = currentTick >= lowerTick ? lowerOutside : global - lowerOutside;
|
|
23544
|
+
const above = currentTick < upperTick ? upperOutside : global - upperOutside;
|
|
23545
|
+
return global - below - above & MAX_UINT256$1;
|
|
23546
|
+
};
|
|
23547
|
+
return {
|
|
23548
|
+
feeGrowthInside0X128: inside(blockData.feeGrowthGlobal0, lower.feeGrowthOutside0, upper.feeGrowthOutside0),
|
|
23549
|
+
feeGrowthInside1X128: inside(blockData.feeGrowthGlobal1, lower.feeGrowthOutside1, upper.feeGrowthOutside1)
|
|
23550
|
+
};
|
|
23551
|
+
}
|
|
23552
|
+
/** Blocks before the chain's Multicall3 deployment need viem's deployless multicall. */
|
|
23553
|
+
function predatesMulticall3(client, blockNumber) {
|
|
23554
|
+
const deployedAt = client.chain?.contracts?.multicall3?.blockCreated;
|
|
23555
|
+
return blockNumber != null && deployedAt != null && blockNumber < BigInt(deployedAt);
|
|
23556
|
+
}
|
|
23437
23557
|
async function fetchUniswapBlockSnapshot(client, blockNumber, uniqueTicks, poolConfig) {
|
|
23438
23558
|
if (poolConfig.version === "v3") return fetchV3BlockSnapshot(client, poolConfig.poolAddress, blockNumber, uniqueTicks);
|
|
23439
23559
|
else return fetchV4BlockSnapshot(client, poolConfig.stateViewAddress, poolConfig.poolId, blockNumber, uniqueTicks);
|
|
@@ -23465,7 +23585,8 @@ async function fetchV3BlockSnapshot(client, poolAddress, blockNumber, uniqueTick
|
|
|
23465
23585
|
const results = await client.multicall({
|
|
23466
23586
|
contracts,
|
|
23467
23587
|
blockNumber,
|
|
23468
|
-
allowFailure: false
|
|
23588
|
+
allowFailure: false,
|
|
23589
|
+
deployless: predatesMulticall3(client, blockNumber)
|
|
23469
23590
|
});
|
|
23470
23591
|
const slot0Result = results[0];
|
|
23471
23592
|
const feeGrowthGlobal0 = results[1];
|
|
@@ -23474,6 +23595,7 @@ async function fetchV3BlockSnapshot(client, poolAddress, blockNumber, uniqueTick
|
|
|
23474
23595
|
for (let i = 0; i < uniqueTicks.length; i++) {
|
|
23475
23596
|
const tickResult = results[3 + i];
|
|
23476
23597
|
tickData.set(uniqueTicks[i], {
|
|
23598
|
+
liquidityGross: tickResult[0],
|
|
23477
23599
|
feeGrowthOutside0: tickResult[2],
|
|
23478
23600
|
feeGrowthOutside1: tickResult[3]
|
|
23479
23601
|
});
|
|
@@ -23510,7 +23632,8 @@ async function fetchV4BlockSnapshot(client, stateViewAddress, poolId, blockNumbe
|
|
|
23510
23632
|
const results = await client.multicall({
|
|
23511
23633
|
contracts,
|
|
23512
23634
|
blockNumber,
|
|
23513
|
-
allowFailure: false
|
|
23635
|
+
allowFailure: false,
|
|
23636
|
+
deployless: predatesMulticall3(client, blockNumber)
|
|
23514
23637
|
});
|
|
23515
23638
|
const slot0Result = results[0];
|
|
23516
23639
|
const feeGrowthResult = results[1];
|
|
@@ -23518,6 +23641,7 @@ async function fetchV4BlockSnapshot(client, stateViewAddress, poolId, blockNumbe
|
|
|
23518
23641
|
for (let i = 0; i < uniqueTicks.length; i++) {
|
|
23519
23642
|
const tickResult = results[2 + i];
|
|
23520
23643
|
tickData.set(uniqueTicks[i], {
|
|
23644
|
+
liquidityGross: tickResult[0],
|
|
23521
23645
|
feeGrowthOutside0: tickResult[2],
|
|
23522
23646
|
feeGrowthOutside1: tickResult[3]
|
|
23523
23647
|
});
|
|
@@ -23820,23 +23944,34 @@ function clampNTicks(startTick, tickSpacing, nTicks) {
|
|
|
23820
23944
|
* for the pool — only a deployed PanopticQuery on the chain.
|
|
23821
23945
|
*/
|
|
23822
23946
|
async function getUniswapV3PoolLiquidities(params) {
|
|
23823
|
-
const { client, poolAddress, queryAddress, startTick, nTicks } = params;
|
|
23824
|
-
|
|
23947
|
+
const { client, poolAddress, queryAddress, startTick, nTicks, windowsPerSide = 0 } = params;
|
|
23948
|
+
if (windowsPerSide > 0 && params.tickSpacing === void 0) throw new PanopticValidationError("getUniswapV3PoolLiquidities: tickSpacing is required with windowsPerSide");
|
|
23949
|
+
const safeN = clampNTicks(startTick, params.tickSpacing ?? 1, nTicks);
|
|
23825
23950
|
const _meta = await getBlockMeta({ client });
|
|
23826
|
-
const
|
|
23827
|
-
|
|
23828
|
-
|
|
23829
|
-
|
|
23830
|
-
|
|
23831
|
-
|
|
23832
|
-
|
|
23833
|
-
|
|
23834
|
-
|
|
23835
|
-
|
|
23951
|
+
const { ticks, liquidityNets } = await readTickNetWindows({
|
|
23952
|
+
startTick,
|
|
23953
|
+
mainNTicks: safeN,
|
|
23954
|
+
nTicks,
|
|
23955
|
+
tickSpacing: params.tickSpacing ?? 1,
|
|
23956
|
+
windowsPerSide,
|
|
23957
|
+
read: (centerTick, windowTicks) => client.readContract({
|
|
23958
|
+
address: queryAddress,
|
|
23959
|
+
abi: panopticQueryAbi$1,
|
|
23960
|
+
functionName: "getTickNetsV3",
|
|
23961
|
+
args: [
|
|
23962
|
+
poolAddress,
|
|
23963
|
+
centerTick,
|
|
23964
|
+
windowTicks
|
|
23965
|
+
],
|
|
23966
|
+
blockNumber: _meta.blockNumber
|
|
23967
|
+
}).then(([windowTickData, windowNets]) => ({
|
|
23968
|
+
ticks: windowTickData,
|
|
23969
|
+
liquidityNets: windowNets
|
|
23970
|
+
}))
|
|
23836
23971
|
});
|
|
23837
23972
|
return {
|
|
23838
|
-
ticks
|
|
23839
|
-
liquidityNets
|
|
23973
|
+
ticks,
|
|
23974
|
+
liquidityNets,
|
|
23840
23975
|
_meta
|
|
23841
23976
|
};
|
|
23842
23977
|
}
|
|
@@ -24009,22 +24144,32 @@ async function getUniswapV4PoolLiquidities(params) {
|
|
|
24009
24144
|
const { client, queryAddress, poolManager, poolId, tickSpacing, startTick, nTicks } = params;
|
|
24010
24145
|
const safeN = clampNTicks(startTick, tickSpacing, nTicks);
|
|
24011
24146
|
const _meta = await getBlockMeta({ client });
|
|
24012
|
-
const
|
|
24013
|
-
|
|
24014
|
-
|
|
24015
|
-
|
|
24016
|
-
|
|
24017
|
-
|
|
24018
|
-
|
|
24019
|
-
|
|
24020
|
-
|
|
24021
|
-
|
|
24022
|
-
|
|
24023
|
-
|
|
24147
|
+
const { ticks, liquidityNets } = await readTickNetWindows({
|
|
24148
|
+
startTick,
|
|
24149
|
+
mainNTicks: safeN,
|
|
24150
|
+
nTicks,
|
|
24151
|
+
tickSpacing,
|
|
24152
|
+
windowsPerSide: params.windowsPerSide ?? 0,
|
|
24153
|
+
read: (centerTick, windowTicks) => client.readContract({
|
|
24154
|
+
address: queryAddress,
|
|
24155
|
+
abi: panopticQueryAbi$1,
|
|
24156
|
+
functionName: "getTickNetsV4",
|
|
24157
|
+
args: [
|
|
24158
|
+
poolManager,
|
|
24159
|
+
poolId,
|
|
24160
|
+
tickSpacing,
|
|
24161
|
+
centerTick,
|
|
24162
|
+
windowTicks
|
|
24163
|
+
],
|
|
24164
|
+
blockNumber: _meta.blockNumber
|
|
24165
|
+
}).then(([windowTickData, windowNets]) => ({
|
|
24166
|
+
ticks: windowTickData,
|
|
24167
|
+
liquidityNets: windowNets
|
|
24168
|
+
}))
|
|
24024
24169
|
});
|
|
24025
24170
|
return {
|
|
24026
|
-
ticks
|
|
24027
|
-
liquidityNets
|
|
24171
|
+
ticks,
|
|
24172
|
+
liquidityNets,
|
|
24028
24173
|
_meta
|
|
24029
24174
|
};
|
|
24030
24175
|
}
|
|
@@ -26751,7 +26896,7 @@ async function forceExerciseAndWait(params) {
|
|
|
26751
26896
|
//#endregion
|
|
26752
26897
|
//#region src/panoptic/v2/writes/protectedSettle.ts
|
|
26753
26898
|
const POOL_ID_MASK = (1n << 64n) - 1n;
|
|
26754
|
-
const Q96 = 1n << 96n;
|
|
26899
|
+
const Q96$1 = 1n << 96n;
|
|
26755
26900
|
const MAX_UINT128$1 = (1n << 128n) - 1n;
|
|
26756
26901
|
const SETTLE_LIMITS = [
|
|
26757
26902
|
-887272n,
|
|
@@ -26771,7 +26916,7 @@ function minimumPokeSize(legs, tickSpacing) {
|
|
|
26771
26916
|
const sqrtLower = tickToSqrtPriceX96(lowerTick);
|
|
26772
26917
|
const sqrtUpper = tickToSqrtPriceX96(upperTick);
|
|
26773
26918
|
const delta = sqrtUpper - sqrtLower;
|
|
26774
|
-
const liquidityFactor = leg.asset === 0n ? sqrtLower * sqrtUpper / Q96 : Q96;
|
|
26919
|
+
const liquidityFactor = leg.asset === 0n ? sqrtLower * sqrtUpper / Q96$1 : Q96$1;
|
|
26775
26920
|
if (liquidityFactor === 0n) return void 0;
|
|
26776
26921
|
const requiredAmount = ceilDiv$1(delta, liquidityFactor);
|
|
26777
26922
|
const legSize = ceilDiv$1(requiredAmount, leg.optionRatio);
|
|
@@ -28547,6 +28692,62 @@ async function getLoanPositionsForToken(client, poolAddress, account, existingPo
|
|
|
28547
28692
|
};
|
|
28548
28693
|
});
|
|
28549
28694
|
}
|
|
28695
|
+
async function buildRepayDispatch(params) {
|
|
28696
|
+
const { client, account, poolAddress, chainId, token, amount, slippageBps, existingPositionIds, builderCode = 0n } = params;
|
|
28697
|
+
if (amount <= 0n) throw new Error("Repayment amount must be positive");
|
|
28698
|
+
const pool = await getPool({
|
|
28699
|
+
client,
|
|
28700
|
+
poolAddress,
|
|
28701
|
+
chainId
|
|
28702
|
+
});
|
|
28703
|
+
const tokenIndex = resolveTokenIndex(token, pool.collateralTracker0.token, pool.collateralTracker1.token);
|
|
28704
|
+
const loans = await getLoanPositionsForToken(client, poolAddress, account, existingPositionIds, tokenIndex);
|
|
28705
|
+
if (loans.length === 0) throw new NoLoanPositionsError(token);
|
|
28706
|
+
const totalDebt = loans.reduce((sum$1, l) => sum$1 + l.tokenAmount, 0n);
|
|
28707
|
+
const loanIds = loans.map((l) => l.tokenId);
|
|
28708
|
+
const remainder = totalDebt > amount ? totalDebt - amount : 0n;
|
|
28709
|
+
const { low: tickLimitLow, high: tickLimitHigh } = tickLimits(pool.currentTick, slippageBps);
|
|
28710
|
+
const ascendingLimits = [
|
|
28711
|
+
tickLimitLow,
|
|
28712
|
+
tickLimitHigh,
|
|
28713
|
+
0n
|
|
28714
|
+
];
|
|
28715
|
+
const nonLoanIds = existingPositionIds.filter((id) => !loanIds.includes(id));
|
|
28716
|
+
const opsPositionIds = [...loanIds];
|
|
28717
|
+
const opsSizes = loanIds.map(() => 0n);
|
|
28718
|
+
const opsLimits = loanIds.map(() => ascendingLimits);
|
|
28719
|
+
let finalPositionIdList;
|
|
28720
|
+
if (remainder > 0n) {
|
|
28721
|
+
const { tokenId: newLoanId, adjustedSize } = buildUniqueLoan(pool.poolId, tokenIndex, tokenIndex, pool.currentTick, pool.tickSpacing, nonLoanIds, remainder);
|
|
28722
|
+
opsPositionIds.push(newLoanId);
|
|
28723
|
+
opsSizes.push(adjustedSize);
|
|
28724
|
+
opsLimits.push(ascendingLimits);
|
|
28725
|
+
finalPositionIdList = [...nonLoanIds, newLoanId];
|
|
28726
|
+
} else finalPositionIdList = nonLoanIds;
|
|
28727
|
+
return {
|
|
28728
|
+
positionIdList: opsPositionIds,
|
|
28729
|
+
finalPositionIdList,
|
|
28730
|
+
positionSizes: opsSizes,
|
|
28731
|
+
tickAndSpreadLimits: opsLimits,
|
|
28732
|
+
usePremiaAsCollateral: false,
|
|
28733
|
+
builderCode
|
|
28734
|
+
};
|
|
28735
|
+
}
|
|
28736
|
+
/** Preview the same full or partial repayment dispatch used by smartRepay. */
|
|
28737
|
+
async function previewRepay(params) {
|
|
28738
|
+
const dispatch$1 = await buildRepayDispatch(params);
|
|
28739
|
+
const simulation = await simulateDispatch({
|
|
28740
|
+
client: params.client,
|
|
28741
|
+
account: params.account,
|
|
28742
|
+
poolAddress: params.poolAddress,
|
|
28743
|
+
existingPositionIdList: params.existingPositionIds,
|
|
28744
|
+
...dispatch$1
|
|
28745
|
+
});
|
|
28746
|
+
return {
|
|
28747
|
+
dispatch: dispatch$1,
|
|
28748
|
+
simulation
|
|
28749
|
+
};
|
|
28750
|
+
}
|
|
28550
28751
|
/**
|
|
28551
28752
|
* Smart repay: burns all loan positions for a token and optionally re-opens a smaller one.
|
|
28552
28753
|
*
|
|
@@ -28560,37 +28761,9 @@ async function getLoanPositionsForToken(client, poolAddress, account, existingPo
|
|
|
28560
28761
|
* @returns TxResult
|
|
28561
28762
|
*/
|
|
28562
28763
|
async function smartRepay(params) {
|
|
28563
|
-
const { client, walletClient, account, poolAddress,
|
|
28764
|
+
const { client, walletClient, account, poolAddress, txOverrides } = params;
|
|
28564
28765
|
for (let attempt = 0; attempt < MAX_RETRIES; attempt++) {
|
|
28565
|
-
const
|
|
28566
|
-
client,
|
|
28567
|
-
poolAddress,
|
|
28568
|
-
chainId
|
|
28569
|
-
});
|
|
28570
|
-
const tokenIndex = resolveTokenIndex(token, pool.collateralTracker0.token, pool.collateralTracker1.token);
|
|
28571
|
-
const loans = await getLoanPositionsForToken(client, poolAddress, account, existingPositionIds, tokenIndex);
|
|
28572
|
-
if (loans.length === 0) throw new NoLoanPositionsError(token);
|
|
28573
|
-
const totalDebt = loans.reduce((sum$1, l) => sum$1 + l.tokenAmount, 0n);
|
|
28574
|
-
const loanIds = loans.map((l) => l.tokenId);
|
|
28575
|
-
const remainder = totalDebt > amount ? totalDebt - amount : 0n;
|
|
28576
|
-
const { low: tickLimitLow, high: tickLimitHigh } = tickLimits(pool.currentTick, slippageBps);
|
|
28577
|
-
const ascendingLimits = [
|
|
28578
|
-
Number(tickLimitLow),
|
|
28579
|
-
Number(tickLimitHigh),
|
|
28580
|
-
0
|
|
28581
|
-
];
|
|
28582
|
-
const nonLoanIds = existingPositionIds.filter((id) => !loanIds.includes(id));
|
|
28583
|
-
const opsPositionIds = [...loanIds];
|
|
28584
|
-
const opsSizes = loanIds.map(() => 0n);
|
|
28585
|
-
const opsLimits = loanIds.map(() => ascendingLimits);
|
|
28586
|
-
let finalPositionIdList;
|
|
28587
|
-
if (remainder > 0n) {
|
|
28588
|
-
const { tokenId: newLoanId, adjustedSize } = buildUniqueLoan(pool.poolId, tokenIndex, tokenIndex, pool.currentTick, pool.tickSpacing, nonLoanIds, remainder);
|
|
28589
|
-
opsPositionIds.push(newLoanId);
|
|
28590
|
-
opsSizes.push(adjustedSize);
|
|
28591
|
-
opsLimits.push(ascendingLimits);
|
|
28592
|
-
finalPositionIdList = [...nonLoanIds, newLoanId];
|
|
28593
|
-
} else finalPositionIdList = nonLoanIds;
|
|
28766
|
+
const intent = await buildRepayDispatch(params);
|
|
28594
28767
|
try {
|
|
28595
28768
|
return await submitWrite({
|
|
28596
28769
|
client,
|
|
@@ -28600,12 +28773,12 @@ async function smartRepay(params) {
|
|
|
28600
28773
|
abi: panopticPoolV2Abi,
|
|
28601
28774
|
functionName: "dispatch",
|
|
28602
28775
|
args: [
|
|
28603
|
-
|
|
28604
|
-
finalPositionIdList,
|
|
28605
|
-
|
|
28606
|
-
|
|
28607
|
-
|
|
28608
|
-
builderCode
|
|
28776
|
+
intent.positionIdList,
|
|
28777
|
+
intent.finalPositionIdList,
|
|
28778
|
+
intent.positionSizes,
|
|
28779
|
+
intent.tickAndSpreadLimits.map((limits) => limits.map(Number)),
|
|
28780
|
+
intent.usePremiaAsCollateral,
|
|
28781
|
+
intent.builderCode
|
|
28609
28782
|
],
|
|
28610
28783
|
txOverrides
|
|
28611
28784
|
});
|
|
@@ -32031,15 +32204,29 @@ var _4663 = {
|
|
|
32031
32204
|
"panoptic": {
|
|
32032
32205
|
"pool": {
|
|
32033
32206
|
"version": "v4",
|
|
32034
|
-
"panopticPool": "
|
|
32035
|
-
"collateralTracker0": "
|
|
32036
|
-
"collateralTracker1": "
|
|
32207
|
+
"panopticPool": "0x000000000c21b38c54AcA7c7145Df01ff09d69Bb",
|
|
32208
|
+
"collateralTracker0": "0xDc508622CD7e3850c8240e88c10361Cf493465b6",
|
|
32209
|
+
"collateralTracker1": "0x9212d804953bAf89C24ceFa6545aA293bA08a876"
|
|
32210
|
+
},
|
|
32211
|
+
"additionalPools": {
|
|
32212
|
+
"spyUsdg30bpsV4": {
|
|
32213
|
+
"version": "v4",
|
|
32214
|
+
"panopticPool": "0x00000000989bcb6f24af4a1Ab2A6d6a31c98A58E",
|
|
32215
|
+
"collateralTracker0": "0x49eaAC32A7CD4B8fB2209a12859a95E0b20aB0e5",
|
|
32216
|
+
"collateralTracker1": "0x670C44a0FC35dbC410498e47A6290a1C3196d191"
|
|
32217
|
+
},
|
|
32218
|
+
"spyUsdg5bpsV4": {
|
|
32219
|
+
"version": "v4",
|
|
32220
|
+
"panopticPool": "0x000000000c21b38c54AcA7c7145Df01ff09d69Bb",
|
|
32221
|
+
"collateralTracker0": "0xDc508622CD7e3850c8240e88c10361Cf493465b6",
|
|
32222
|
+
"collateralTracker1": "0x9212d804953bAf89C24ceFa6545aA293bA08a876"
|
|
32223
|
+
}
|
|
32037
32224
|
},
|
|
32038
32225
|
"v2": {
|
|
32039
32226
|
"semiFungiblePositionManagerV4": "0x00000000000005C3287f136Ef5AF56c68Ea6849f",
|
|
32040
32227
|
"semiFungiblePositionManagerV3": "0x00000000000005E4693aDc8Ec0f12D686f728198",
|
|
32041
32228
|
"builderFactory": "0x0000000000000a3D22E158417AA639D7F71b0FF7",
|
|
32042
|
-
"riskEngine": "
|
|
32229
|
+
"riskEngine": "0x0000000000000fE1E261f66ce2F44def4F5Ae0CB",
|
|
32043
32230
|
"panopticPoolImplementation": "0x000000000000135429F0DaCaB61639Bf6a63EbbC",
|
|
32044
32231
|
"collateralTrackerImplementation": "0x0000000000001d9c38CA405A2e04420865A08A33",
|
|
32045
32232
|
"panopticFactoryV4": "0x0000000000000c51d0f8cf4bd9adE7191372a625",
|
|
@@ -32055,13 +32242,29 @@ var _4663 = {
|
|
|
32055
32242
|
"0x0000000000000fe1e261f66ce2f44def4f5ae0cb",
|
|
32056
32243
|
"0x0000000000000f3fb82469581A74776178E76Ca4"
|
|
32057
32244
|
],
|
|
32058
|
-
"markets": {
|
|
32059
|
-
"
|
|
32060
|
-
|
|
32061
|
-
|
|
32062
|
-
|
|
32063
|
-
|
|
32064
|
-
|
|
32245
|
+
"markets": {
|
|
32246
|
+
"spyUsdg": {
|
|
32247
|
+
"currency0": "0x117cc2133c37B721F49dE2A7a74833232B3B4C0C",
|
|
32248
|
+
"currency1": "0x5fc5360D0400a0Fd4f2af552ADD042D716F1d168",
|
|
32249
|
+
"fee": 500,
|
|
32250
|
+
"tickSpacing": 5,
|
|
32251
|
+
"poolId": "0xe5923c8a8be481ec89a2ca784a2bbfa4235de6d88f92260fd66b660c4babf907"
|
|
32252
|
+
},
|
|
32253
|
+
"spyUsdg30bps": {
|
|
32254
|
+
"currency0": "0x117cc2133c37B721F49dE2A7a74833232B3B4C0C",
|
|
32255
|
+
"currency1": "0x5fc5360D0400a0Fd4f2af552ADD042D716F1d168",
|
|
32256
|
+
"fee": 3e3,
|
|
32257
|
+
"tickSpacing": 60,
|
|
32258
|
+
"poolId": "0xfe2a80bb5618fd14984b92ca6d45bf5ba67443ddb1435e28b2e48df2fc1526cd"
|
|
32259
|
+
},
|
|
32260
|
+
"spyUsdg5bps": {
|
|
32261
|
+
"currency0": "0x117cc2133c37B721F49dE2A7a74833232B3B4C0C",
|
|
32262
|
+
"currency1": "0x5fc5360D0400a0Fd4f2af552ADD042D716F1d168",
|
|
32263
|
+
"fee": 500,
|
|
32264
|
+
"tickSpacing": 5,
|
|
32265
|
+
"poolId": "0xe5923c8a8be481ec89a2ca784a2bbfa4235de6d88f92260fd66b660c4babf907"
|
|
32266
|
+
}
|
|
32267
|
+
},
|
|
32065
32268
|
"subgraphs": {
|
|
32066
32269
|
"hypovault": "https://api.goldsky.com/api/public/project_cl9gc21q105380hxuh8ks53k3/subgraphs/hypovault-subgraph-robinhood/prod/gn",
|
|
32067
32270
|
"panoptic": "https://api.goldsky.com/api/public/project_cl9gc21q105380hxuh8ks53k3/subgraphs/panoptic-subgraph-robinhood/v2_prod/gn"
|
|
@@ -32229,6 +32432,10 @@ function getSpyUsdgMarket(deployment) {
|
|
|
32229
32432
|
if (market === void 0) throw new Error(`Missing SPY/USDG market for chainId ${deployment.chainId}`);
|
|
32230
32433
|
return market;
|
|
32231
32434
|
}
|
|
32435
|
+
function requireDeploymentValue(value, label) {
|
|
32436
|
+
if (value === void 0) throw new Error(`Missing deployment value: ${label}`);
|
|
32437
|
+
return value;
|
|
32438
|
+
}
|
|
32232
32439
|
const MAINNET_DEPLOYMENT = CHAIN_DEPLOYMENTS[MAINNET_CHAIN_ID];
|
|
32233
32440
|
const MAINNET_ETH_USDC_5BPS_V3_PANOPTIC_POOL_ADDRESSES = MAINNET_DEPLOYMENT.panoptic.additionalPools?.ethUsdc5bpsV3;
|
|
32234
32441
|
const MAINNET_PANOPTIC_V2_ADDRESSES = MAINNET_DEPLOYMENT.panoptic.v2;
|
|
@@ -32257,9 +32464,13 @@ const ROBINHOOD_HYPOVAULT_ADDRESSES = ROBINHOOD_DEPLOYMENT.hypovault.vaults;
|
|
|
32257
32464
|
const ROBINHOOD_HYPOVAULT_MANAGER_ADDRESSES = ROBINHOOD_DEPLOYMENT.hypovault.managers;
|
|
32258
32465
|
const ROBINHOOD_HYPOVAULT_MANAGER_TURNKEY_SIGNERS = ROBINHOOD_DEPLOYMENT.hypovault.turnkeySigners;
|
|
32259
32466
|
const ROBINHOOD_PANOPTIC_POOL_ADDRESSES = ROBINHOOD_DEPLOYMENT.panoptic.pool;
|
|
32467
|
+
const ROBINHOOD_SPY_USDG_30BPS_PANOPTIC_POOL_ADDRESSES = requireDeploymentValue(ROBINHOOD_DEPLOYMENT.panoptic.additionalPools?.spyUsdg30bpsV4, "Robinhood SPY/USDG 30bps Panoptic pool");
|
|
32468
|
+
const ROBINHOOD_SPY_USDG_5BPS_PANOPTIC_POOL_ADDRESSES = requireDeploymentValue(ROBINHOOD_DEPLOYMENT.panoptic.additionalPools?.spyUsdg5bpsV4, "Robinhood SPY/USDG 5bps Panoptic pool");
|
|
32260
32469
|
const ROBINHOOD_PANOPTIC_V2_ADDRESSES = ROBINHOOD_DEPLOYMENT.panoptic.v2;
|
|
32261
32470
|
const ROBINHOOD_RISK_ENGINES = ROBINHOOD_DEPLOYMENT.riskEngines;
|
|
32262
32471
|
const ROBINHOOD_SPY_USDG_MARKET = getSpyUsdgMarket(ROBINHOOD_DEPLOYMENT);
|
|
32472
|
+
const ROBINHOOD_SPY_USDG_30BPS_MARKET = requireDeploymentValue(ROBINHOOD_DEPLOYMENT.markets.spyUsdg30bps, "Robinhood SPY/USDG 30bps market");
|
|
32473
|
+
const ROBINHOOD_SPY_USDG_5BPS_MARKET = requireDeploymentValue(ROBINHOOD_DEPLOYMENT.markets.spyUsdg5bps, "Robinhood SPY/USDG 5bps market");
|
|
32263
32474
|
|
|
32264
32475
|
//#endregion
|
|
32265
32476
|
//#region ../deployments/src/vaultDisplayNames.js
|
|
@@ -32350,6 +32561,131 @@ function marketRiskFromValues({ lower, current, upper }) {
|
|
|
32350
32561
|
};
|
|
32351
32562
|
}
|
|
32352
32563
|
|
|
32564
|
+
//#endregion
|
|
32565
|
+
//#region src/panoptic/v2/greeks/positionVolatility.ts
|
|
32566
|
+
const Precision = Decimal.clone({ precision: 80 });
|
|
32567
|
+
const Q96 = 1n << 96n;
|
|
32568
|
+
const YEAR_SECONDS = new Precision(31536e3);
|
|
32569
|
+
/** The premium-free position curve, expressed in one quote token's human units. */
|
|
32570
|
+
function preparePositionGamma({ tokenId, positionSize, quoteIsToken0, quoteDecimals }) {
|
|
32571
|
+
if (positionSize <= 0n || positionSize >= 1n << 128n) throw new RangeError("Invalid position size");
|
|
32572
|
+
if (!Number.isInteger(quoteDecimals) || quoteDecimals < 0 || quoteDecimals > 255) throw new RangeError("Invalid quote decimals");
|
|
32573
|
+
const decoded = decodeTokenId(tokenId);
|
|
32574
|
+
const chunks = decoded.legs.flatMap((leg) => {
|
|
32575
|
+
if (leg.width === 0n) return [];
|
|
32576
|
+
const width = leg.width * decoded.tickSpacing;
|
|
32577
|
+
const lowerTick = leg.strike - width / 2n;
|
|
32578
|
+
const upperTick = leg.strike + (width + 1n) / 2n;
|
|
32579
|
+
if (lowerTick < -887272n || upperTick > 887272n || lowerTick >= upperTick) throw new RangeError("Invalid position range");
|
|
32580
|
+
const lower = tickToSqrtPriceX96(lowerTick);
|
|
32581
|
+
const upper = tickToSqrtPriceX96(upperTick);
|
|
32582
|
+
const amount = positionSize * leg.optionRatio;
|
|
32583
|
+
const liquidity = leg.asset === 0n ? amount * (lower * upper / Q96) / (upper - lower) : amount * Q96 / (upper - lower);
|
|
32584
|
+
if (liquidity >= 1n << 128n) throw new RangeError("Liquidity exceeds uint128");
|
|
32585
|
+
return [{
|
|
32586
|
+
lowerTick: Number(lowerTick),
|
|
32587
|
+
upperTick: Number(upperTick),
|
|
32588
|
+
liquidity,
|
|
32589
|
+
isLong: leg.isLong
|
|
32590
|
+
}];
|
|
32591
|
+
});
|
|
32592
|
+
const scale = new Precision(10).pow(quoteDecimals);
|
|
32593
|
+
const atTick = (tick) => {
|
|
32594
|
+
const netLiquidity = chunks.reduce((sum$1, chunk) => tick >= BigInt(chunk.lowerTick) && tick < BigInt(chunk.upperTick) ? sum$1 + (chunk.isLong ? -chunk.liquidity : chunk.liquidity) : sum$1, 0n);
|
|
32595
|
+
const sqrt = new Precision(tickToSqrtPriceX96(tick).toString()).div(Q96.toString());
|
|
32596
|
+
const gamma = new Precision(netLiquidity.toString()).neg().div(2).div(scale);
|
|
32597
|
+
return quoteIsToken0 ? gamma.div(sqrt) : gamma.mul(sqrt);
|
|
32598
|
+
};
|
|
32599
|
+
const inRange = (low, high) => {
|
|
32600
|
+
if (low > high) throw new RangeError("Invalid candle range");
|
|
32601
|
+
const ticks = new Set([low, high]);
|
|
32602
|
+
for (const chunk of chunks) for (const boundary of [BigInt(chunk.lowerTick), BigInt(chunk.upperTick)]) {
|
|
32603
|
+
if (boundary >= low && boundary <= high) ticks.add(boundary);
|
|
32604
|
+
if (boundary - 1n >= low && boundary - 1n <= high) ticks.add(boundary - 1n);
|
|
32605
|
+
}
|
|
32606
|
+
return [...ticks].map(atTick);
|
|
32607
|
+
};
|
|
32608
|
+
return {
|
|
32609
|
+
chunks,
|
|
32610
|
+
atTick,
|
|
32611
|
+
inRange
|
|
32612
|
+
};
|
|
32613
|
+
}
|
|
32614
|
+
/** Historical whole-position diagnostics, with signs retained independently of eligibility. */
|
|
32615
|
+
function calculatePositionVolatilityMetrics({ observations, netPremium, baseFees, quoteDecimals }) {
|
|
32616
|
+
if (observations.length < 2) throw new RangeError("At least two price observations are required");
|
|
32617
|
+
if (!Number.isInteger(quoteDecimals) || quoteDecimals < 0 || quoteDecimals > 255) throw new RangeError("Invalid quote decimals");
|
|
32618
|
+
const points = observations.map((point) => ({
|
|
32619
|
+
...point,
|
|
32620
|
+
price: new Precision(point.price),
|
|
32621
|
+
gamma: new Precision(point.gamma),
|
|
32622
|
+
rangeGammas: (point.rangeGammas ?? []).map((gamma) => new Precision(gamma))
|
|
32623
|
+
}));
|
|
32624
|
+
for (const point of points) if (!point.price.isFinite() || point.price.lte(0) || !point.gamma.isFinite() || point.rangeGammas.some((gamma) => !gamma.isFinite())) throw new RangeError("Invalid price or gamma observation");
|
|
32625
|
+
const quantum = new Precision(10).pow(-quoteDecimals);
|
|
32626
|
+
const gammas = points.flatMap((point) => [point.gamma, ...point.rangeGammas]);
|
|
32627
|
+
const peak = gammas.reduce((max, gamma) => Precision.max(max, gamma.abs()), new Precision(0));
|
|
32628
|
+
const tolerance = Precision.max(quantum, peak.mul("1e-12"));
|
|
32629
|
+
const positive = gammas.some((gamma) => gamma.gt(tolerance));
|
|
32630
|
+
const negative = gammas.some((gamma) => gamma.lt(tolerance.neg()));
|
|
32631
|
+
const gammaSign = positive && negative ? "changing" : positive ? "positive" : negative ? "negative" : "zero";
|
|
32632
|
+
let exposure = new Precision(0);
|
|
32633
|
+
let signedConvexity = new Precision(0);
|
|
32634
|
+
let absoluteConvexity = new Precision(0);
|
|
32635
|
+
let years = new Precision(0);
|
|
32636
|
+
for (let i = 1; i < points.length; i++) {
|
|
32637
|
+
const previous = points[i - 1];
|
|
32638
|
+
const point = points[i];
|
|
32639
|
+
const seconds = point.timestamp - previous.timestamp;
|
|
32640
|
+
if (seconds <= 0n) throw new RangeError("Observations must have increasing timestamps");
|
|
32641
|
+
const elapsed = new Precision(seconds.toString()).div(YEAR_SECONDS);
|
|
32642
|
+
const squaredReturn = point.price.div(previous.price).ln().pow(2);
|
|
32643
|
+
exposure = exposure.plus(previous.gamma.abs().mul(elapsed));
|
|
32644
|
+
signedConvexity = signedConvexity.plus(previous.gamma.mul(squaredReturn).div(2));
|
|
32645
|
+
absoluteConvexity = absoluteConvexity.plus(previous.gamma.abs().mul(squaredReturn).div(2));
|
|
32646
|
+
years = years.plus(elapsed);
|
|
32647
|
+
}
|
|
32648
|
+
const sufficientExposure = exposure.gt(tolerance.mul(years).mul(100));
|
|
32649
|
+
const premium = netPremium === null ? null : new Precision(netPremium);
|
|
32650
|
+
const fees = baseFees == null ? null : new Precision(baseFees);
|
|
32651
|
+
if (premium !== null && !premium.isFinite() || fees !== null && !fees.isFinite()) throw new RangeError("Invalid accounting amount");
|
|
32652
|
+
const consistent = (amount) => gammaSign === "positive" ? amount.lte(quantum) : gammaSign === "negative" && amount.gte(quantum.neg());
|
|
32653
|
+
const reason = !sufficientExposure ? "insufficient-exposure" : gammaSign === "changing" ? "changing-sign" : premium === null ? "premium-unavailable" : !consistent(premium) ? "inconsistent-premium-direction" : null;
|
|
32654
|
+
const equivalent = (amount) => amount.abs().mul(2).div(exposure).sqrt().toString();
|
|
32655
|
+
const coverage = (amount) => absoluteConvexity.gt(quantum) ? amount.abs().div(absoluteConvexity).toString() : null;
|
|
32656
|
+
const eligibleFees = sufficientExposure && fees !== null && consistent(fees);
|
|
32657
|
+
return {
|
|
32658
|
+
gammaSign,
|
|
32659
|
+
exposure: exposure.toString(),
|
|
32660
|
+
signedConvexity: signedConvexity.toString(),
|
|
32661
|
+
absoluteConvexity: absoluteConvexity.toString(),
|
|
32662
|
+
netPremium: premium?.toString() ?? null,
|
|
32663
|
+
estimatedHedgedResult: premium?.plus(signedConvexity).toString() ?? null,
|
|
32664
|
+
weightedRealizedVolatility: sufficientExposure ? equivalent(absoluteConvexity) : null,
|
|
32665
|
+
premiumEquivalentVolatility: reason === null && premium !== null ? equivalent(premium) : null,
|
|
32666
|
+
premiumToConvexity: reason === null && premium !== null ? coverage(premium) : null,
|
|
32667
|
+
baseFees: fees?.toString() ?? null,
|
|
32668
|
+
feeEquivalentVolatility: eligibleFees ? equivalent(fees) : null,
|
|
32669
|
+
feeToConvexity: eligibleFees ? coverage(fees) : null,
|
|
32670
|
+
comparisonReason: reason
|
|
32671
|
+
};
|
|
32672
|
+
}
|
|
32673
|
+
/** Quote-value signed cumulative token increments, excluding revaluation of previous accrual. */
|
|
32674
|
+
function valuePositionAccrual({ snapshots, quoteIsToken0, quoteDecimals }) {
|
|
32675
|
+
let previous0 = 0n;
|
|
32676
|
+
let previous1 = 0n;
|
|
32677
|
+
let total = new Precision(0);
|
|
32678
|
+
for (const snapshot of snapshots) {
|
|
32679
|
+
const amount0 = new Precision((snapshot.token0 - previous0).toString());
|
|
32680
|
+
const amount1 = new Precision((snapshot.token1 - previous1).toString());
|
|
32681
|
+
const price = new Precision("1.0001").pow(snapshot.tick.toString());
|
|
32682
|
+
total = total.plus(quoteIsToken0 ? amount0.plus(amount1.div(price)) : amount1.plus(amount0.mul(price)));
|
|
32683
|
+
previous0 = snapshot.token0;
|
|
32684
|
+
previous1 = snapshot.token1;
|
|
32685
|
+
}
|
|
32686
|
+
return total.div(new Precision(10).pow(quoteDecimals));
|
|
32687
|
+
}
|
|
32688
|
+
|
|
32353
32689
|
//#endregion
|
|
32354
32690
|
//#region src/panoptic/v2/reads/collateralCurve.ts
|
|
32355
32691
|
/** Native-token margin inputs, independent of the tick used to display the curve. */
|
|
@@ -32542,6 +32878,221 @@ function preparePositionValueCurve(curve) {
|
|
|
32542
32878
|
};
|
|
32543
32879
|
}
|
|
32544
32880
|
|
|
32881
|
+
//#endregion
|
|
32882
|
+
//#region src/panoptic/v2/reads/positionVolatilityHistory.ts
|
|
32883
|
+
const signedSlot = (value) => BigInt.asIntN(128, value);
|
|
32884
|
+
const unpack = (value) => ({
|
|
32885
|
+
token0: signedSlot(value),
|
|
32886
|
+
token1: signedSlot(value >> 128n)
|
|
32887
|
+
});
|
|
32888
|
+
/** RPC accounting for exactly one mint lifecycle; candle prices are supplied by the application. */
|
|
32889
|
+
async function getPositionVolatilityHistory({ client, poolAddress, account, tokenId, mintBlock, endBlock, poolConfig, includeBaseFees = false }) {
|
|
32890
|
+
if (mintBlock <= 0n || endBlock <= mintBlock) throw new RangeError("Insufficient lifecycle history");
|
|
32891
|
+
const [mints, burns] = await Promise.all([client.getContractEvents({
|
|
32892
|
+
address: poolAddress,
|
|
32893
|
+
abi: panopticPoolV2Abi,
|
|
32894
|
+
eventName: "OptionMinted",
|
|
32895
|
+
args: {
|
|
32896
|
+
recipient: account,
|
|
32897
|
+
tokenId
|
|
32898
|
+
},
|
|
32899
|
+
fromBlock: mintBlock,
|
|
32900
|
+
toBlock: mintBlock,
|
|
32901
|
+
strict: true
|
|
32902
|
+
}), client.getContractEvents({
|
|
32903
|
+
address: poolAddress,
|
|
32904
|
+
abi: panopticPoolV2Abi,
|
|
32905
|
+
eventName: "OptionBurnt",
|
|
32906
|
+
args: {
|
|
32907
|
+
recipient: account,
|
|
32908
|
+
tokenId
|
|
32909
|
+
},
|
|
32910
|
+
fromBlock: mintBlock,
|
|
32911
|
+
toBlock: endBlock,
|
|
32912
|
+
strict: true
|
|
32913
|
+
})]);
|
|
32914
|
+
const mint$1 = mints[0];
|
|
32915
|
+
if (mints.length !== 1 || !mint$1) throw new Error("Opening event is missing or ambiguous");
|
|
32916
|
+
const balance = decodePositionBalance$1(mint$1.args.balanceData);
|
|
32917
|
+
const close = burns.filter((burn) => burn.blockNumber > mintBlock || burn.logIndex > mint$1.logIndex).sort((a, b) => a.blockNumber === b.blockNumber ? a.logIndex - b.logIndex : a.blockNumber < b.blockNumber ? -1 : 1)[0];
|
|
32918
|
+
const finalBlock = close?.blockNumber ?? endBlock;
|
|
32919
|
+
if (finalBlock <= mintBlock) throw new Error("Intrablock lifecycle cannot be reconstructed");
|
|
32920
|
+
if (close && close.args.positionSize !== balance.positionSize) throw new Error("Position size changed");
|
|
32921
|
+
const [start, end, boundaryPrices] = await Promise.all([
|
|
32922
|
+
getBlockMeta({
|
|
32923
|
+
client,
|
|
32924
|
+
blockNumber: mintBlock
|
|
32925
|
+
}),
|
|
32926
|
+
getBlockMeta({
|
|
32927
|
+
client,
|
|
32928
|
+
blockNumber: finalBlock
|
|
32929
|
+
}),
|
|
32930
|
+
getPriceHistory({
|
|
32931
|
+
client,
|
|
32932
|
+
poolConfig,
|
|
32933
|
+
blockNumbers: [mintBlock, finalBlock]
|
|
32934
|
+
})
|
|
32935
|
+
]);
|
|
32936
|
+
const openingPrice = boundaryPrices.snapshots[0];
|
|
32937
|
+
const endingPrice = boundaryPrices.snapshots[1];
|
|
32938
|
+
if (!openingPrice || !endingPrice) throw new Error("Boundary prices unavailable");
|
|
32939
|
+
const pointCount = Math.min(200, Math.max(2, Number((end.blockTimestamp - start.blockTimestamp) / 900n) + 2));
|
|
32940
|
+
const blockNumbers = [...new Set(interpolateBlocks(mintBlock, finalBlock, pointCount))];
|
|
32941
|
+
const metadata = [];
|
|
32942
|
+
for (let i = 0; i < blockNumbers.length; i += 16) metadata.push(...await Promise.all(blockNumbers.slice(i, i + 16).map((blockNumber) => getBlockMeta({
|
|
32943
|
+
client,
|
|
32944
|
+
blockNumber
|
|
32945
|
+
}))));
|
|
32946
|
+
const timestamps = new Map(metadata.map((meta) => [meta.blockNumber, meta.blockTimestamp]));
|
|
32947
|
+
const chunks = preparePositionGamma({
|
|
32948
|
+
tokenId,
|
|
32949
|
+
positionSize: balance.positionSize,
|
|
32950
|
+
quoteIsToken0: false,
|
|
32951
|
+
quoteDecimals: 0
|
|
32952
|
+
}).chunks.filter((chunk) => chunk.liquidity > 0n);
|
|
32953
|
+
let premiumError = null;
|
|
32954
|
+
let feeError = includeBaseFees ? null : "Base fee history was not requested";
|
|
32955
|
+
let premium = null;
|
|
32956
|
+
let fees = null;
|
|
32957
|
+
try {
|
|
32958
|
+
const settlementLogs = await client.getContractEvents({
|
|
32959
|
+
address: poolAddress,
|
|
32960
|
+
abi: panopticPoolV2Abi,
|
|
32961
|
+
eventName: "PremiumSettled",
|
|
32962
|
+
args: {
|
|
32963
|
+
user: account,
|
|
32964
|
+
tokenId
|
|
32965
|
+
},
|
|
32966
|
+
fromBlock: mintBlock,
|
|
32967
|
+
toBlock: finalBlock,
|
|
32968
|
+
strict: true
|
|
32969
|
+
});
|
|
32970
|
+
const settled = [];
|
|
32971
|
+
const seen = new Set();
|
|
32972
|
+
for (const log of settlementLogs) {
|
|
32973
|
+
if (log.blockNumber === mintBlock && log.logIndex <= mint$1.logIndex) continue;
|
|
32974
|
+
if (close && log.blockNumber === finalBlock && log.logIndex >= close.logIndex) continue;
|
|
32975
|
+
const key = `${log.transactionHash}:${log.logIndex}`;
|
|
32976
|
+
if (seen.has(key)) continue;
|
|
32977
|
+
seen.add(key);
|
|
32978
|
+
const amounts = unpack(log.args.settledAmounts);
|
|
32979
|
+
settled.push({
|
|
32980
|
+
blockNumber: log.blockNumber,
|
|
32981
|
+
settled0: amounts.token0,
|
|
32982
|
+
settled1: amounts.token1
|
|
32983
|
+
});
|
|
32984
|
+
}
|
|
32985
|
+
if (close) {
|
|
32986
|
+
const receipt = await client.getTransactionReceipt({ hash: close.transactionHash });
|
|
32987
|
+
const liquidations = parseEventLogs({
|
|
32988
|
+
abi: panopticPoolV2Abi,
|
|
32989
|
+
logs: receipt.logs.filter((log) => log.address.toLowerCase() === poolAddress.toLowerCase()),
|
|
32990
|
+
eventName: "AccountLiquidated"
|
|
32991
|
+
});
|
|
32992
|
+
if (liquidations.some((event) => event.args.liquidatee.toLowerCase() === account.toLowerCase())) throw new Error("Liquidation premium requires haircut reconciliation");
|
|
32993
|
+
for (const packed of close.args.premiaByLeg) {
|
|
32994
|
+
const amounts = unpack(packed);
|
|
32995
|
+
settled.push({
|
|
32996
|
+
blockNumber: finalBlock,
|
|
32997
|
+
settled0: amounts.token0,
|
|
32998
|
+
settled1: amounts.token1
|
|
32999
|
+
});
|
|
33000
|
+
}
|
|
33001
|
+
}
|
|
33002
|
+
const readableBlocks = close ? blockNumbers.filter((block) => block < finalBlock) : blockNumbers;
|
|
33003
|
+
premium = [];
|
|
33004
|
+
for (let i = 0; i < readableBlocks.length; i += 16) {
|
|
33005
|
+
const history = await getStreamiaHistory({
|
|
33006
|
+
client,
|
|
33007
|
+
panopticPoolAddress: poolAddress,
|
|
33008
|
+
account,
|
|
33009
|
+
tokenId,
|
|
33010
|
+
blockNumbers: readableBlocks.slice(i, i + 16),
|
|
33011
|
+
legs: [],
|
|
33012
|
+
poolConfig,
|
|
33013
|
+
includeUniswapFees: false,
|
|
33014
|
+
settledEvents: settled,
|
|
33015
|
+
_meta: end
|
|
33016
|
+
});
|
|
33017
|
+
for (const snapshot of history.snapshots) {
|
|
33018
|
+
const timestamp = snapshot.blockNumber === void 0 ? void 0 : timestamps.get(snapshot.blockNumber);
|
|
33019
|
+
if (timestamp === void 0) throw new Error("Accounting timestamp missing");
|
|
33020
|
+
premium.push({
|
|
33021
|
+
timestamp,
|
|
33022
|
+
...snapshot.cumulativePanopticPremia
|
|
33023
|
+
});
|
|
33024
|
+
}
|
|
33025
|
+
}
|
|
33026
|
+
if (close) premium.push({
|
|
33027
|
+
timestamp: end.blockTimestamp,
|
|
33028
|
+
...settled.reduce((sum$1, event) => ({
|
|
33029
|
+
token0: sum$1.token0 + event.settled0,
|
|
33030
|
+
token1: sum$1.token1 + event.settled1
|
|
33031
|
+
}), {
|
|
33032
|
+
token0: 0n,
|
|
33033
|
+
token1: 0n
|
|
33034
|
+
})
|
|
33035
|
+
});
|
|
33036
|
+
const openingAccrual = premium[0];
|
|
33037
|
+
if (!openingAccrual || openingAccrual.timestamp !== start.blockTimestamp) throw new Error("Opening premium snapshot missing");
|
|
33038
|
+
premium = premium.map((snapshot) => ({
|
|
33039
|
+
timestamp: snapshot.timestamp,
|
|
33040
|
+
token0: snapshot.token0 - openingAccrual.token0,
|
|
33041
|
+
token1: snapshot.token1 - openingAccrual.token1
|
|
33042
|
+
}));
|
|
33043
|
+
} catch (error) {
|
|
33044
|
+
premium = null;
|
|
33045
|
+
premiumError = error instanceof Error ? error.message : "Premium history unavailable";
|
|
33046
|
+
}
|
|
33047
|
+
if (includeBaseFees) try {
|
|
33048
|
+
const feeBlocks = close ? blockNumbers.filter((block) => block < finalBlock) : blockNumbers;
|
|
33049
|
+
const data = [];
|
|
33050
|
+
for (let i = 0; i < feeBlocks.length; i += 16) data.push(...await fetchUniswapFeeData(client, feeBlocks.slice(i, i + 16), chunks, poolConfig));
|
|
33051
|
+
let total0 = 0n;
|
|
33052
|
+
let total1 = 0n;
|
|
33053
|
+
fees = [];
|
|
33054
|
+
for (let i = 0; i < data.length; i++) {
|
|
33055
|
+
const current = data[i];
|
|
33056
|
+
for (const chunk of chunks) {
|
|
33057
|
+
if ((current.tickData.get(chunk.lowerTick)?.liquidityGross ?? 0n) === 0n || (current.tickData.get(chunk.upperTick)?.liquidityGross ?? 0n) === 0n) throw new Error("LP range was uninitialized; complete base fee history is unavailable");
|
|
33058
|
+
if (i === 0) continue;
|
|
33059
|
+
const previous = feeGrowthInsideX128(data[i - 1], chunk.lowerTick, chunk.upperTick);
|
|
33060
|
+
const next = feeGrowthInsideX128(current, chunk.lowerTick, chunk.upperTick);
|
|
33061
|
+
if (!previous || !next) throw new Error("Range fee growth missing");
|
|
33062
|
+
if (BigInt.asUintN(256, next.feeGrowthInside0X128 - previous.feeGrowthInside0X128) > BigInt.asUintN(256, current.feeGrowthGlobal0 - data[i - 1].feeGrowthGlobal0) || BigInt.asUintN(256, next.feeGrowthInside1X128 - previous.feeGrowthInside1X128) > BigInt.asUintN(256, current.feeGrowthGlobal1 - data[i - 1].feeGrowthGlobal1)) throw new Error("Range fee growth is inconsistent with pool fee growth");
|
|
33063
|
+
const sign = chunk.isLong ? -1n : 1n;
|
|
33064
|
+
total0 += sign * feesFromFeeGrowthDelta(next.feeGrowthInside0X128, previous.feeGrowthInside0X128, chunk.liquidity);
|
|
33065
|
+
total1 += sign * feesFromFeeGrowthDelta(next.feeGrowthInside1X128, previous.feeGrowthInside1X128, chunk.liquidity);
|
|
33066
|
+
}
|
|
33067
|
+
fees.push({
|
|
33068
|
+
timestamp: metadata[i].blockTimestamp,
|
|
33069
|
+
token0: total0,
|
|
33070
|
+
token1: total1
|
|
33071
|
+
});
|
|
33072
|
+
}
|
|
33073
|
+
} catch (error) {
|
|
33074
|
+
fees = null;
|
|
33075
|
+
feeError = error instanceof Error ? error.message : "Base fee history unavailable";
|
|
33076
|
+
}
|
|
33077
|
+
return {
|
|
33078
|
+
start,
|
|
33079
|
+
end,
|
|
33080
|
+
positionSize: balance.positionSize,
|
|
33081
|
+
closed: close !== void 0,
|
|
33082
|
+
openingTick: BigInt(openingPrice.tick),
|
|
33083
|
+
endingTick: BigInt(endingPrice.tick),
|
|
33084
|
+
premium,
|
|
33085
|
+
fees,
|
|
33086
|
+
premiumError,
|
|
33087
|
+
feeError,
|
|
33088
|
+
accountingSamples: blockNumbers.length,
|
|
33089
|
+
maxAccountingIntervalSeconds: metadata.slice(1).reduce((maximum, meta, index) => {
|
|
33090
|
+
const interval = meta.blockTimestamp - metadata[index].blockTimestamp;
|
|
33091
|
+
return interval > maximum ? interval : maximum;
|
|
33092
|
+
}, 0n)
|
|
33093
|
+
};
|
|
33094
|
+
}
|
|
33095
|
+
|
|
32545
33096
|
//#endregion
|
|
32546
33097
|
//#region src/panoptic/v2/react/cacheScopes.ts
|
|
32547
33098
|
/**
|
|
@@ -33094,14 +33645,18 @@ function usePoolLiquidities(poolAddress, params, options) {
|
|
|
33094
33645
|
getClientCacheScopeKey(publicClient, clientScope),
|
|
33095
33646
|
params.queryAddress,
|
|
33096
33647
|
params.startTick,
|
|
33097
|
-
params.nTicks
|
|
33648
|
+
params.nTicks,
|
|
33649
|
+
params.windowsPerSide ?? 0,
|
|
33650
|
+
params.tickSpacing
|
|
33098
33651
|
],
|
|
33099
33652
|
queryFn: () => getPoolLiquidities({
|
|
33100
33653
|
client: publicClient,
|
|
33101
33654
|
poolAddress,
|
|
33102
33655
|
queryAddress: params.queryAddress,
|
|
33103
33656
|
startTick: params.startTick,
|
|
33104
|
-
nTicks: params.nTicks
|
|
33657
|
+
nTicks: params.nTicks,
|
|
33658
|
+
windowsPerSide: params.windowsPerSide,
|
|
33659
|
+
tickSpacing: params.tickSpacing
|
|
33105
33660
|
}),
|
|
33106
33661
|
enabled: options?.enabled,
|
|
33107
33662
|
refetchInterval: options?.refetchInterval,
|
|
@@ -34352,17 +34907,21 @@ function useUniswapV3PoolLiquidities(poolAddress, queryAddress, args, options) {
|
|
|
34352
34907
|
queryAddress,
|
|
34353
34908
|
args?.startTick,
|
|
34354
34909
|
args?.nTicks,
|
|
34910
|
+
args?.windowsPerSide ?? 0,
|
|
34911
|
+
args?.tickSpacing,
|
|
34355
34912
|
getClientCacheScopeKey(publicClient, clientScope)
|
|
34356
34913
|
],
|
|
34357
34914
|
queryFn: () => {
|
|
34358
34915
|
if (!poolAddress || !queryAddress || queryAddress === zeroAddress || !args) throw new PanopticValidationError("useUniswapV3PoolLiquidities: missing required args");
|
|
34359
|
-
const { startTick, nTicks } = args;
|
|
34916
|
+
const { startTick, nTicks, windowsPerSide, tickSpacing } = args;
|
|
34360
34917
|
return getUniswapV3PoolLiquidities({
|
|
34361
34918
|
client: publicClient,
|
|
34362
34919
|
poolAddress,
|
|
34363
34920
|
queryAddress,
|
|
34364
34921
|
startTick,
|
|
34365
|
-
nTicks
|
|
34922
|
+
nTicks,
|
|
34923
|
+
windowsPerSide,
|
|
34924
|
+
tickSpacing
|
|
34366
34925
|
});
|
|
34367
34926
|
},
|
|
34368
34927
|
enabled: (options?.enabled ?? true) && !!poolAddress && !!queryAddress && queryAddress !== zeroAddress && !!args,
|
|
@@ -34490,11 +35049,12 @@ function useUniswapV4PoolLiquidities(queryAddress, poolManager, poolId, args, op
|
|
|
34490
35049
|
args?.tickSpacing,
|
|
34491
35050
|
args?.startTick,
|
|
34492
35051
|
args?.nTicks,
|
|
35052
|
+
args?.windowsPerSide ?? 0,
|
|
34493
35053
|
getClientCacheScopeKey(publicClient, clientScope)
|
|
34494
35054
|
],
|
|
34495
35055
|
queryFn: () => {
|
|
34496
35056
|
if (!queryAddress || !poolManager || !poolId || !args) throw new PanopticValidationError("useUniswapV4PoolLiquidities: missing required args");
|
|
34497
|
-
const { tickSpacing, startTick, nTicks } = args;
|
|
35057
|
+
const { tickSpacing, startTick, nTicks, windowsPerSide } = args;
|
|
34498
35058
|
return getUniswapV4PoolLiquidities({
|
|
34499
35059
|
client: publicClient,
|
|
34500
35060
|
queryAddress,
|
|
@@ -34502,7 +35062,8 @@ function useUniswapV4PoolLiquidities(queryAddress, poolManager, poolId, args, op
|
|
|
34502
35062
|
poolId,
|
|
34503
35063
|
tickSpacing,
|
|
34504
35064
|
startTick,
|
|
34505
|
-
nTicks
|
|
35065
|
+
nTicks,
|
|
35066
|
+
windowsPerSide
|
|
34506
35067
|
});
|
|
34507
35068
|
},
|
|
34508
35069
|
enabled: (options?.enabled ?? true) && !!queryAddress && !!poolManager && !!poolId && !!args,
|
|
@@ -38015,5 +38576,5 @@ function useTxEventConfirmation({ txHash, poolAddress = zeroAddress, collateralT
|
|
|
38015
38576
|
}
|
|
38016
38577
|
|
|
38017
38578
|
//#endregion
|
|
38018
|
-
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, 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, estimateCollateralBreakdown, estimateCollateralRequired, executeBatchDispatch, executeBatchDispatchAndWait, executeSettleSequence, executeSettleSequenceAndWait, failPendingPosition, feesFromFeeGrowthDelta, fetchPoolId, fetchSfpmV3PoolId, 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, getClosedPositions, getClosedPositionsKey, getCollateralAddresses, getCollateralCurve, getCollateralCurveInputs, getCollateralData, getCollateralRequiredBase, getCollateralSharePrices, getCollateralTotalAssetsBatch, getCurrentRates, getDeltaHedgeParams, getEnforcedTickLimits, getExecutableLpMaxSize, getFactoryConstructMetadata, getFactoryOwnerOf, getFactoryTokenURI, getForfeitablePremium, getGuardianUnlockState, getHedgeLimits, getInterestState, getIrmCurrent, getIrmCurve, getItmAmounts, getLegDelta, getLegDeltaInVaultFrame, getLegGamma, getLegNetValueWidth0, getLegValue, getLiquidationPrices, getMarginBuffer, getMaxPositionSize, getMaxRedeem, getMaxWithdrawable, getNativeTokenPrice, getNetLiquidationValue, getNetLiquidationValues, getNotEnoughTokensError, getOpenPositionIds, getOpenPositionPreview, getOracleRiskParameters, getOracleState, getPanopticPoolAddress, getPanopticPoolFromPoolId, getPendingPositions, getPendingPositionsKey, getPool, getPoolCurrentTick, getPoolDeploymentBlock, getPoolDisplayId, getPoolLiquidities, getPoolMetaKey, getPoolMetadata, getPoolPrefix, getPortfolioValue, getPosition, getPositionChunkData, getPositionDeltaMetrics, getPositionEnrichmentData, getPositionGreeks, getPositionMetaKey, getPositionValueCurve, getPositions, getPositionsKey, getPositionsWithPremia, getPriceHistory, getPricesAtTick, getRealizedPnL, getRequiredCreditForITM, getRiskParameters, getSafeMode, getSchemaVersionKey, getSimpleLoanTokenIndex, getStreamiaHistory, getSyncCheckpointKey, getSyncStatus, getTickSpacing, getTokenListId, getTrackedChunks, getTrackedChunksKey, getTrackedPositionIds, getTradeHistory, getUniswapFeeHistory, getUniswapV3LpPositionState, getUniswapV3PoolFromId, getUniswapV3PoolInfo, getUniswapV3PoolLiquidities, getUniswapV4LpPositionState, getUniswapV4PoolBasicState, getUniswapV4PoolInfo, getUniswapV4PoolKeyFromId, getUniswapV4PoolLiquidities, getUtilization, hasLoanOrCredit, hasLongLeg, interpolateBlocks, isCall, isCowSupportedChain, isCredit, isCreditLeg, isDefinedRisk, isGasError, isInputListFailError, isLiquidatable, isLoan, isLoanLeg, isNonceError, isPanopticErrorType, isPositionTracked, isRetryableRpcError, isShortOnly, isSpread, isSupportedChain, isolateGroupTokenId, jsonSerializer, ladderStrikeSequence, liquidate, liquidateAndWait, loadCheckpoint, logReturns, marketPnlInQuote, marketRiskFromValues, marketScenario, minePoolAddress, mint, mintAndWait, mintableAfterBuffer, multicallRead, mutationEffects, netLiquidationValueInQuote, openPosition, openPositionAndWait, optimizeTokenIdRiskPartners, oracleEpochAt, orderListForSettle, packMarketState, panopticLiquidatorAbi, panopticPoolV2Abi, panopticQueryAbi, parseBps, parseCollateralLog, parsePanopticError, parsePoolLog, parseTokenAmount, parseTokenListId, parseWad, planDeriveStrategy, pokeOracle, pokeOracleAndWait, positionValueKey, positionValueTicks, prepareIndicatorCandles, preparePositionValue, preparePositionValueCurve, previewBorrow, previewDeposit, previewMint, previewRedeem, previewUnwrap, previewWithdraw, previewWrap, priceToTick, publicBroadcaster, queryKeys, quoteLiquidation, quoteOneTokenFlow, quoteSfpmSwap, quoteTemporaryLoanRecovery, quoteTokenShortfallRecovery, 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, simulateDeployNewPool, simulateDeposit, simulateDispatch, simulateForceExercise, simulateLiquidate, simulateOpenPosition, simulateSFPMBurn, simulateSFPMMint, simulateSettle, simulateSettlePremiumBatch, simulateSettlePremiumFrom, simulateSettleSequence, simulateSwapExactIn, simulateSwapExactOut, simulateWithTokenFlow, simulateWithdraw, slippageBpsToTickDistance, smartRepay, smartRepayAndWait, speedUpTransaction, splitTokenIdByTimescale, sqrtPriceX96ToPriceDecimalScaled, sqrtPriceX96ToTick, supply, supplyAndWait, swapExactIn, swapExactInAndWait, swapExactOut, swapExactOutAndWait, syncPositions, tickLimits, tickToPrice, tickToPriceDecimalScaled, tickToSqrtPriceX96, toVaultFrameAtTick, truncateAddress, unsupply, unsupplyAndWait, unwrapWeth, unwrapWethAndWait, unwrapXstock, unwrapXstockAndWait, useAccountCollateral, useAccountGreeks, useAccountPremia, useAccountSummaryBasic, useAccountSummaryRisk, useAddPendingPosition, useApprove, useApproveErc20ForCow, useApproveErc20ForPermit2, useApprovePool, useApproveRouterViaPermit2, useBatchDispatch as useBatchDispatchHook, useBorrow as useBorrowHook, useCancelCowOrder, useCheckCowApproval, useCheckRouterApproval, useChunkSpreads, useClearTrackedPositions, useClosePosition as useClosePositionHook, useClosedPositions, useCollateralBreakdown, useCollateralData, useConfirmPendingPosition, useCowOrderStatus, useCurrentRates, useDeployNewPool as useDeployNewPoolHook, useDeposit as useDepositHook, useDispatch as useDispatchHook, useEstimateCollateralRequired, useEventPoller, useEventSubscription, useExecuteSettleSequence, useFactoryConstructMetadata, useFactoryOwnerOf, useFactoryTokenURI, useFailPendingPosition, useFlowNeutralTokenId, useForceExercise as useForceExerciseHook, useForfeitablePremium, useGuardianUnlockState, useInterestState, useIsLiquidatable, useLiquidate as useLiquidateHook, useLiquidationPrices, useMarginBuffer, useMaxPositionSize, useMaxRedeem, useMaxWithdrawable, useMinePoolAddress as useMinePoolAddressHook, useMintShares, useNativeTokenPrice, useNetLiquidationValue, useNetLiquidationValues, useOpenPosition as useOpenPositionHook, useOpenPositionPreview, useOptimizeRiskPartners, useOracleState, usePanopticContext, usePanopticPoolAddress, usePokeOracle as usePokeOracleHook, usePool, usePoolLiquidities, usePoolVersion, usePosition, usePositionGreeks, usePositions, usePositionsWithPremia, usePreviewBorrow, usePreviewDeposit, usePreviewMint, usePreviewRedeem, usePreviewWithdraw, usePriceHistory, useQuoteCowSwap, useQuoteSwapExactInViaRouter, useQuoteSwapExactOutViaRouter, useRealizedPnL, useRedeem as useRedeemHook, useRepay as useRepayHook, useResolveUniswapV4PoolKey, useRiskParameters, useRollPosition as useRollPositionHook, useSafeMode, useSettleAccumulatedPremia as useSettleAccumulatedPremiaHook, useSettlePremiumFrom as useSettlePremiumFromHook, useSimulateBatchDispatch, useSimulateClosePosition, useSimulateDeployNewPool, useSimulateDeposit, useSimulateDispatch, useSimulateForceExercise, useSimulateLiquidate, useSimulateOpenPosition, useSimulateSFPMBurn, useSimulateSFPMMint, useSimulateSettle, useSimulateSettlePremiumBatch, useSimulateSettlePremiumFrom, useSimulateSettleSequence, useSimulateSwapExactIn, useSimulateSwapExactOut, useSimulateWithdraw, useSmartRepay as useSmartRepayHook, useStreamiaHistory, useSubmitCowOrder, useSupply as useSupplyHook, useSwapExactIn, useSwapExactInViaRouter, useSwapExactOut, useSwapExactOutViaRouter, useSyncPositions, useSyncStatus, useTrackedPositionIds, useTradeHistory, useTxEventConfirmation, useUniswapFeeHistory, useUniswapV3PoolInfo, useUniswapV3PoolLiquidities, useUniswapV4PoolBasicState, useUniswapV4PoolInfo, useUniswapV4PoolLiquidities, useUnsupply as useUnsupplyHook, useUnwrapWeth, useUnwrapXstock, useUtilization, useValidateBuilderCode, useWatchEvents, useWithdraw as useWithdrawHook, useWithdrawWithPositions as useWithdrawWithPositionsHook, useWrapEth, useWrapXstock, utilizationBpsToWad, utilizationPctToWad, validateBatch, validateBuilderCode, validatePoolId, verifyBlockContinuity, watchEvents, wethWrapAbi, withdraw, withdrawAndWait, withdrawWithPositions, withdrawWithPositionsAndWait, wrapEth, wrapEthAndWait, wrapXstock, wrapXstockAndWait, xstockWrapperAbi };
|
|
38579
|
+
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, estimateCollateralBreakdown, estimateCollateralRequired, executeBatchDispatch, executeBatchDispatchAndWait, executeSettleSequence, executeSettleSequenceAndWait, failPendingPosition, feeGrowthInsideX128, feesFromFeeGrowthDelta, fetchPoolId, fetchSfpmV3PoolId, fetchUniswapFeeData, forceExercise, forceExerciseAndWait, formatBlockNumber, formatBps, formatCompact, formatDatetime, formatDuration, formatDurationSeconds, formatFeeTier, formatGas, formatGwei, formatPerSecondRateWadAsAprPct, formatPerSecondRateWadAsApyPct, formatPoolIdHex, formatPriceRange, formatRateWad, formatRatioPercent, formatTick, formatTickRange, formatTimestamp, formatTimestampLocale, formatTokenAmount, formatTokenAmountSigned, formatTokenDelta, formatTokenFlow, formatTokenIdHex, formatTokenIdShort, formatTxHash, formatUtilization, formatWad, formatWadPercent, formatWadSigned, formatWei, generateOverlappingTokenIds, getAccountBuyingPower, getAccountCollateral, getAccountGreeks, getAccountHistory, getAccountPremia, getAccountSummaryBasic, getAccountSummaryRisk, getAssetIndex, getBlockMeta, getChainDeployment, getChunkLiquidities, getChunkSpreads, getClosedPositions, getClosedPositionsKey, getCollateralAddresses, getCollateralCurve, getCollateralCurveInputs, getCollateralData, getCollateralRequiredBase, getCollateralSharePrices, getCollateralTotalAssetsBatch, getCurrentRates, getDeltaHedgeParams, getEnforcedTickLimits, getExecutableLpMaxSize, getFactoryConstructMetadata, getFactoryOwnerOf, getFactoryTokenURI, getForfeitablePremium, getGuardianUnlockState, getHedgeLimits, getInterestState, getIrmCurrent, getIrmCurve, getItmAmounts, getLegDelta, getLegDeltaInVaultFrame, getLegGamma, getLegNetValueWidth0, getLegValue, getLiquidationPrices, getMarginBuffer, getMaxPositionSize, getMaxRedeem, getMaxWithdrawable, getNativeTokenPrice, getNetLiquidationValue, getNetLiquidationValues, getNotEnoughTokensError, getOpenPositionIds, getOpenPositionPreview, getOracleRiskParameters, getOracleState, getPanopticPoolAddress, getPanopticPoolFromPoolId, getPendingPositions, getPendingPositionsKey, getPool, getPoolCurrentTick, getPoolDeploymentBlock, getPoolDisplayId, getPoolLiquidities, getPoolMetaKey, getPoolMetadata, getPoolPrefix, getPortfolioValue, getPosition, getPositionChunkData, getPositionDeltaMetrics, getPositionEnrichmentData, getPositionGreeks, getPositionMetaKey, getPositionValueCurve, getPositionVolatilityHistory, getPositions, getPositionsKey, getPositionsWithPremia, getPriceHistory, getPricesAtTick, getRealizedPnL, getRequiredCreditForITM, getRiskParameters, getSafeMode, getSchemaVersionKey, getSimpleLoanTokenIndex, getStreamiaHistory, getSyncCheckpointKey, getSyncStatus, getTickSpacing, getTokenListId, getTrackedChunks, getTrackedChunksKey, getTrackedPositionIds, getTradeHistory, getUniswapFeeHistory, getUniswapV3LpPositionState, getUniswapV3PoolFromId, getUniswapV3PoolInfo, getUniswapV3PoolLiquidities, getUniswapV4LpPositionState, getUniswapV4PoolBasicState, getUniswapV4PoolInfo, getUniswapV4PoolKeyFromId, getUniswapV4PoolLiquidities, getUtilization, hasLoanOrCredit, hasLongLeg, interpolateBlocks, isCall, isCowSupportedChain, isCredit, isCreditLeg, isDefinedRisk, isGasError, isInputListFailError, isLiquidatable, isLoan, isLoanLeg, isNonceError, isPanopticErrorType, isPositionTracked, isRetryableRpcError, isShortOnly, isSpread, isSupportedChain, isolateGroupTokenId, jsonSerializer, ladderStrikeSequence, liquidate, liquidateAndWait, loadCheckpoint, logReturns, marketPnlInQuote, marketRiskFromValues, marketScenario, minePoolAddress, mint, mintAndWait, mintableAfterBuffer, multicallRead, mutationEffects, netLiquidationValueInQuote, openPosition, openPositionAndWait, optimizeTokenIdRiskPartners, oracleEpochAt, orderListForSettle, packMarketState, panopticLiquidatorAbi, panopticPoolV2Abi, panopticQueryAbi, parseBps, parseCollateralLog, parsePanopticError, parsePoolLog, parseTokenAmount, parseTokenListId, parseWad, planDeriveStrategy, pokeOracle, pokeOracleAndWait, positionValueKey, positionValueTicks, prepareIndicatorCandles, preparePositionGamma, preparePositionValue, preparePositionValueCurve, previewBorrow, previewDeposit, previewMint, previewRedeem, previewRepay, previewUnwrap, previewWithdraw, previewWrap, priceToTick, publicBroadcaster, queryKeys, quoteLiquidation, quoteOneTokenFlow, quoteSfpmSwap, quoteTemporaryLoanRecovery, quoteTokenShortfallRecovery, 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, simulateDeployNewPool, simulateDeposit, simulateDispatch, simulateForceExercise, simulateLiquidate, simulateOpenPosition, simulateSFPMBurn, simulateSFPMMint, simulateSettle, simulateSettlePremiumBatch, simulateSettlePremiumFrom, simulateSettleSequence, simulateSwapExactIn, simulateSwapExactOut, simulateWithTokenFlow, simulateWithdraw, slippageBpsToTickDistance, smartRepay, smartRepayAndWait, speedUpTransaction, splitTokenIdByTimescale, sqrtPriceX96ToPriceDecimalScaled, sqrtPriceX96ToTick, supply, supplyAndWait, swapExactIn, swapExactInAndWait, swapExactOut, swapExactOutAndWait, syncPositions, tickLimits, tickToPrice, tickToPriceDecimalScaled, tickToSqrtPriceX96, toVaultFrameAtTick, truncateAddress, unsupply, unsupplyAndWait, unwrapWeth, unwrapWethAndWait, unwrapXstock, unwrapXstockAndWait, useAccountCollateral, useAccountGreeks, useAccountPremia, useAccountSummaryBasic, useAccountSummaryRisk, useAddPendingPosition, useApprove, useApproveErc20ForCow, useApproveErc20ForPermit2, useApprovePool, useApproveRouterViaPermit2, useBatchDispatch as useBatchDispatchHook, useBorrow as useBorrowHook, useCancelCowOrder, useCheckCowApproval, useCheckRouterApproval, useChunkSpreads, useClearTrackedPositions, useClosePosition as useClosePositionHook, useClosedPositions, useCollateralBreakdown, useCollateralData, useConfirmPendingPosition, useCowOrderStatus, useCurrentRates, useDeployNewPool as useDeployNewPoolHook, useDeposit as useDepositHook, useDispatch as useDispatchHook, useEstimateCollateralRequired, useEventPoller, useEventSubscription, useExecuteSettleSequence, useFactoryConstructMetadata, useFactoryOwnerOf, useFactoryTokenURI, useFailPendingPosition, useFlowNeutralTokenId, useForceExercise as useForceExerciseHook, useForfeitablePremium, useGuardianUnlockState, useInterestState, useIsLiquidatable, useLiquidate as useLiquidateHook, useLiquidationPrices, useMarginBuffer, useMaxPositionSize, useMaxRedeem, useMaxWithdrawable, useMinePoolAddress as useMinePoolAddressHook, useMintShares, useNativeTokenPrice, useNetLiquidationValue, useNetLiquidationValues, useOpenPosition as useOpenPositionHook, useOpenPositionPreview, useOptimizeRiskPartners, useOracleState, usePanopticContext, usePanopticPoolAddress, usePokeOracle as usePokeOracleHook, usePool, usePoolLiquidities, usePoolVersion, usePosition, usePositionGreeks, usePositions, usePositionsWithPremia, usePreviewBorrow, usePreviewDeposit, usePreviewMint, usePreviewRedeem, usePreviewWithdraw, usePriceHistory, useQuoteCowSwap, useQuoteSwapExactInViaRouter, useQuoteSwapExactOutViaRouter, useRealizedPnL, useRedeem as useRedeemHook, useRepay as useRepayHook, useResolveUniswapV4PoolKey, useRiskParameters, useRollPosition as useRollPositionHook, useSafeMode, useSettleAccumulatedPremia as useSettleAccumulatedPremiaHook, useSettlePremiumFrom as useSettlePremiumFromHook, useSimulateBatchDispatch, useSimulateClosePosition, useSimulateDeployNewPool, useSimulateDeposit, useSimulateDispatch, useSimulateForceExercise, useSimulateLiquidate, useSimulateOpenPosition, useSimulateSFPMBurn, useSimulateSFPMMint, useSimulateSettle, useSimulateSettlePremiumBatch, useSimulateSettlePremiumFrom, useSimulateSettleSequence, useSimulateSwapExactIn, useSimulateSwapExactOut, useSimulateWithdraw, useSmartRepay as useSmartRepayHook, useStreamiaHistory, useSubmitCowOrder, useSupply as useSupplyHook, useSwapExactIn, useSwapExactInViaRouter, useSwapExactOut, useSwapExactOutViaRouter, useSyncPositions, useSyncStatus, useTrackedPositionIds, useTradeHistory, useTxEventConfirmation, useUniswapFeeHistory, useUniswapV3PoolInfo, useUniswapV3PoolLiquidities, useUniswapV4PoolBasicState, useUniswapV4PoolInfo, useUniswapV4PoolLiquidities, useUnsupply as useUnsupplyHook, useUnwrapWeth, useUnwrapXstock, useUtilization, useValidateBuilderCode, useWatchEvents, useWithdraw as useWithdrawHook, useWithdrawWithPositions as useWithdrawWithPositionsHook, useWrapEth, useWrapXstock, utilizationBpsToWad, utilizationPctToWad, validateBatch, validateBuilderCode, validatePoolId, valuePositionAccrual, verifyBlockContinuity, watchEvents, wethWrapAbi, withdraw, withdrawAndWait, withdrawWithPositions, withdrawWithPositionsAndWait, wrapEth, wrapEthAndWait, wrapXstock, wrapXstockAndWait, xstockWrapperAbi };
|
|
38019
38580
|
//# sourceMappingURL=react-public.js.map
|