@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, erc20Abi, getAbiItem, getAddress, hexToString, keccak256, parseAbi, toFunctionSelector, toHex, trim, zeroAddress } from "viem";
|
|
1
|
+
import { BaseError, ContractFunctionExecutionError, ContractFunctionRevertedError, ExecutionRevertedError, decodeAbiParameters, decodeErrorResult, decodeEventLog, decodeFunctionData, decodeFunctionResult, encodeAbiParameters, encodeFunctionData, erc20Abi, getAbiItem, getAddress, hexToString, keccak256, parseAbi, parseEventLogs, toFunctionSelector, toHex, trim, zeroAddress } from "viem";
|
|
2
2
|
import { call, multicall } from "viem/actions";
|
|
3
3
|
import Decimal from "decimal.js";
|
|
4
4
|
|
|
@@ -9397,6 +9397,10 @@ function extractErrorData(error) {
|
|
|
9397
9397
|
error.walk((e) => {
|
|
9398
9398
|
if (foundData) return false;
|
|
9399
9399
|
const node = e;
|
|
9400
|
+
if (typeof node.raw === "string" && node.raw.startsWith("0x") && node.raw.length > 10) {
|
|
9401
|
+
foundData = node.raw;
|
|
9402
|
+
return true;
|
|
9403
|
+
}
|
|
9400
9404
|
if (node.data && typeof node.data === "string" && node.data.startsWith("0x")) {
|
|
9401
9405
|
foundData = node.data;
|
|
9402
9406
|
return true;
|
|
@@ -9425,6 +9429,7 @@ function extractErrorData(error) {
|
|
|
9425
9429
|
let current = error;
|
|
9426
9430
|
const maxDepth = 10;
|
|
9427
9431
|
for (let i = 0; i < maxDepth && current; i++) {
|
|
9432
|
+
if (typeof current.raw === "string" && current.raw.startsWith("0x") && current.raw.length > 10) return current.raw;
|
|
9428
9433
|
if (current.data && typeof current.data === "string" && current.data.startsWith("0x")) return current.data;
|
|
9429
9434
|
if (current.data && typeof current.data === "object") {
|
|
9430
9435
|
const nested = current.data;
|
|
@@ -9438,7 +9443,7 @@ function extractErrorData(error) {
|
|
|
9438
9443
|
}
|
|
9439
9444
|
const obj = error;
|
|
9440
9445
|
if (obj.message && typeof obj.message === "string") {
|
|
9441
|
-
const signatureMatch = obj.message.match(/signature
|
|
9446
|
+
const signatureMatch = obj.message.match(/signature:?\s*["']?(0x[a-fA-F0-9]{8,})/i);
|
|
9442
9447
|
if (signatureMatch) return signatureMatch[1];
|
|
9443
9448
|
}
|
|
9444
9449
|
return null;
|
|
@@ -11109,12 +11114,12 @@ function generateOverlappingTokenIds(params) {
|
|
|
11109
11114
|
//#region src/panoptic/v2/tokenId/split.ts
|
|
11110
11115
|
const POOL_ID_MASK$3 = (1n << TOKEN_ID_BITS.POOL_ID_SIZE) - 1n;
|
|
11111
11116
|
const MAX_UINT128$3 = (1n << 128n) - 1n;
|
|
11112
|
-
const MAX_UINT256$
|
|
11117
|
+
const MAX_UINT256$2 = (1n << 256n) - 1n;
|
|
11113
11118
|
function invalid(message) {
|
|
11114
11119
|
throw new PanopticValidationError(`splitTokenIdByTimescale: ${message}`);
|
|
11115
11120
|
}
|
|
11116
11121
|
function validateInput(tokenId, positionSize) {
|
|
11117
|
-
if (tokenId < 0n || tokenId > MAX_UINT256$
|
|
11122
|
+
if (tokenId < 0n || tokenId > MAX_UINT256$2) invalid("tokenId must fit in uint256");
|
|
11118
11123
|
if (positionSize <= 0n || positionSize > MAX_UINT128$3) invalid("positionSize must be between 1 and uint128.max");
|
|
11119
11124
|
const legs = decodeAllLegs(tokenId);
|
|
11120
11125
|
if (legs.length === 0) invalid("tokenId must contain at least one active leg");
|
|
@@ -11269,7 +11274,7 @@ function splitTokenIdByTimescale(tokenId, positionSize, targetTimescale) {
|
|
|
11269
11274
|
|
|
11270
11275
|
//#endregion
|
|
11271
11276
|
//#region src/uniswap/lpDeposit.ts
|
|
11272
|
-
const Q96$
|
|
11277
|
+
const Q96$3 = 1n << 96n;
|
|
11273
11278
|
const ceilDiv$4 = (n, d) => (n + d - 1n) / d;
|
|
11274
11279
|
/** Principal and separately identified funding headroom, in native token units. */
|
|
11275
11280
|
function getLpDepositBreakdown(ranges, sqrtPriceX96) {
|
|
@@ -11281,8 +11286,8 @@ function getLpDepositBreakdown(ranges, sqrtPriceX96) {
|
|
|
11281
11286
|
const lower = tickToSqrtPriceX96(BigInt(tickLower));
|
|
11282
11287
|
const upper = tickToSqrtPriceX96(BigInt(tickUpper));
|
|
11283
11288
|
const price = sqrtPriceX96 < lower ? lower : sqrtPriceX96 > upper ? upper : sqrtPriceX96;
|
|
11284
|
-
amount0 += ceilDiv$4(liquidity * Q96$
|
|
11285
|
-
amount1 += ceilDiv$4(liquidity * (price - lower), Q96$
|
|
11289
|
+
amount0 += ceilDiv$4(liquidity * Q96$3 * (upper - price), upper * price);
|
|
11290
|
+
amount1 += ceilDiv$4(liquidity * (price - lower), Q96$3);
|
|
11286
11291
|
}
|
|
11287
11292
|
const buffer = {
|
|
11288
11293
|
amount0: ceilDiv$4(amount0 * 5n, 100n),
|
|
@@ -11310,7 +11315,7 @@ function getUnhedgedLpRanges({ tokenId, positionSize, tickSpacing }) {
|
|
|
11310
11315
|
const lower = tickToSqrtPriceX96(tickLower);
|
|
11311
11316
|
const upper = tickToSqrtPriceX96(tickUpper);
|
|
11312
11317
|
const amount = positionSize * leg.optionRatio;
|
|
11313
|
-
const liquidity = leg.asset === 0n ? amount * (lower * upper / Q96$
|
|
11318
|
+
const liquidity = leg.asset === 0n ? amount * (lower * upper / Q96$3) / (upper - lower) : amount * Q96$3 / (upper - lower);
|
|
11314
11319
|
return liquidity <= 0n ? [] : [{
|
|
11315
11320
|
tickLower: Number(tickLower),
|
|
11316
11321
|
tickUpper: Number(tickUpper),
|
|
@@ -11331,7 +11336,7 @@ function getLpPositionFunding(params) {
|
|
|
11331
11336
|
});
|
|
11332
11337
|
const breakdown = getLpDepositBreakdown(ranges, sqrtPriceX96);
|
|
11333
11338
|
const priceSquared = valuationSqrtPriceX96 * valuationSqrtPriceX96;
|
|
11334
|
-
const value = ({ amount0, amount1 }) => quoteTokenIndex === 0 ? amount0 + ceilDiv$4(amount1 * Q96$
|
|
11339
|
+
const value = ({ amount0, amount1 }) => quoteTokenIndex === 0 ? amount0 + ceilDiv$4(amount1 * Q96$3 * Q96$3, priceSquared) : amount1 + ceilDiv$4(amount0 * priceSquared, Q96$3 * Q96$3);
|
|
11335
11340
|
const principalInQuote = value(breakdown.principal);
|
|
11336
11341
|
const totalInQuote = value(breakdown.total);
|
|
11337
11342
|
return {
|
|
@@ -12737,6 +12742,17 @@ function createTxResult(client, hash) {
|
|
|
12737
12742
|
* @returns TxResult
|
|
12738
12743
|
*/
|
|
12739
12744
|
async function submitWrite(params) {
|
|
12745
|
+
try {
|
|
12746
|
+
return await submitWriteRequest({
|
|
12747
|
+
...params,
|
|
12748
|
+
abi: [...params.abi, ...panopticErrorsAbi]
|
|
12749
|
+
});
|
|
12750
|
+
} catch (error) {
|
|
12751
|
+
if (error instanceof PanopticError) throw error;
|
|
12752
|
+
throw parsePanopticError(error)?.error ?? error;
|
|
12753
|
+
}
|
|
12754
|
+
}
|
|
12755
|
+
async function submitWriteRequest(params) {
|
|
12740
12756
|
const { client, walletClient, account, address, abi: abi$1, functionName, args, value, txOverrides } = params;
|
|
12741
12757
|
const broadcaster = txOverrides?.broadcaster;
|
|
12742
12758
|
if (broadcaster) {
|
|
@@ -14464,7 +14480,7 @@ async function assertLpPositionFunded(params) {
|
|
|
14464
14480
|
//#endregion
|
|
14465
14481
|
//#region src/panoptic/v2/greeks/index.ts
|
|
14466
14482
|
/** Fixed-point scale constants for sqrtPriceX96 arithmetic */
|
|
14467
|
-
const Q96$
|
|
14483
|
+
const Q96$2 = 1n << 96n;
|
|
14468
14484
|
const Q192$3 = 1n << 192n;
|
|
14469
14485
|
/**
|
|
14470
14486
|
* Convert tick to quote-denominated tick based on asset direction.
|
|
@@ -14612,7 +14628,7 @@ function computeOptionItm(m, qStrikeTick, qMintTick, halfWidthTick, isPut) {
|
|
|
14612
14628
|
const sqrtK = tickToSqrtPriceX96(qStrikeTick);
|
|
14613
14629
|
const sqrtPm = tickToSqrtPriceX96(qMintTick);
|
|
14614
14630
|
const rX192 = sqrtR * sqrtR;
|
|
14615
|
-
const sqrtKPmX96 = divTrunc(sqrtK * Q96$
|
|
14631
|
+
const sqrtKPmX96 = divTrunc(sqrtK * Q96$2, sqrtPm);
|
|
14616
14632
|
const diff = sqrtR - sqrtKPmX96;
|
|
14617
14633
|
const diffSqX192 = diff * diff;
|
|
14618
14634
|
return divTrunc(m * diffSqX192, rX192 - Q192$3);
|
|
@@ -14684,7 +14700,7 @@ function getLegValue(leg, currentTick, mintTick, positionSize, poolTickSpacing,
|
|
|
14684
14700
|
const PX192 = sqrtP * sqrtP;
|
|
14685
14701
|
const KX192 = sqrtK * sqrtK;
|
|
14686
14702
|
const rX192 = sqrtR * sqrtR;
|
|
14687
|
-
const numerator = m * (2n * sqrtPKR * Q96$
|
|
14703
|
+
const numerator = m * (2n * sqrtPKR * Q96$2 - PX192 - KX192);
|
|
14688
14704
|
const denominator = rX192 - Q192$3;
|
|
14689
14705
|
v = divTrunc(numerator, denominator);
|
|
14690
14706
|
}
|
|
@@ -14792,7 +14808,7 @@ function getLegDelta(leg, currentTick, positionSize, poolTickSpacing, mintTick,
|
|
|
14792
14808
|
const sqrtK = tickToSqrtPriceX96(qStrikeTick);
|
|
14793
14809
|
const sqrtPm = tickToSqrtPriceX96(qMintTick);
|
|
14794
14810
|
const rX192 = sqrtR * sqrtR;
|
|
14795
|
-
const sqrtKPmX96 = sqrtK * Q96$
|
|
14811
|
+
const sqrtKPmX96 = sqrtK * Q96$2 / sqrtPm;
|
|
14796
14812
|
const diff = sqrtR - sqrtKPmX96;
|
|
14797
14813
|
const diffSqX192 = diff * diff;
|
|
14798
14814
|
return divTrunc(m * diffSqX192, rX192 - Q192$3);
|
|
@@ -14851,7 +14867,7 @@ function getLegGamma(leg, currentTick, positionSize, poolTickSpacing, assetIndex
|
|
|
14851
14867
|
const sqrtKPR = tickToSqrtPriceX96(qStrikeTick + qCurrentTick + halfWidthTick);
|
|
14852
14868
|
const sqrtR = tickToSqrtPriceX96(halfWidthTick);
|
|
14853
14869
|
const rX192 = sqrtR * sqrtR;
|
|
14854
|
-
const numerator = m * sqrtKPR * Q96$
|
|
14870
|
+
const numerator = m * sqrtKPR * Q96$2;
|
|
14855
14871
|
const denominator = 2n * (rX192 - Q192$3);
|
|
14856
14872
|
return divTrunc(numerator, denominator);
|
|
14857
14873
|
}
|
|
@@ -21640,6 +21656,73 @@ async function optimizeTokenIdRiskPartners(params) {
|
|
|
21640
21656
|
return optimizedTokenId;
|
|
21641
21657
|
}
|
|
21642
21658
|
|
|
21659
|
+
//#endregion
|
|
21660
|
+
//#region src/panoptic/v2/reads/tickNetWindows.ts
|
|
21661
|
+
/**
|
|
21662
|
+
* Wide liquidity distributions from several adjacent `getTickNets*` windows.
|
|
21663
|
+
*
|
|
21664
|
+
* @module v2/reads/tickNetWindows
|
|
21665
|
+
*/
|
|
21666
|
+
/** Absolute Uniswap V3/V4 tick bounds. */
|
|
21667
|
+
const TICK_MIN$1 = -887272;
|
|
21668
|
+
const TICK_MAX$1 = 887272;
|
|
21669
|
+
/**
|
|
21670
|
+
* Join ascending, edge-sharing windows into one distribution anchored to `windows[mainIndex]`.
|
|
21671
|
+
*
|
|
21672
|
+
* Each `getTickNets*` window is a running sum of liquidityNet from its own first tick (only the
|
|
21673
|
+
* window holding the current tick is rescaled to the pool's liquidity), so a neighbour's values
|
|
21674
|
+
* are off by a constant. Adjacent windows share their edge tick; the offset that makes that tick
|
|
21675
|
+
* agree is applied to the whole neighbour. Stitching stops at the first window that does not share
|
|
21676
|
+
* an edge with the one before it.
|
|
21677
|
+
*/
|
|
21678
|
+
function stitchTickNetWindows(windows, mainIndex) {
|
|
21679
|
+
const main = windows[mainIndex];
|
|
21680
|
+
if (!main) return {
|
|
21681
|
+
ticks: [],
|
|
21682
|
+
liquidityNets: []
|
|
21683
|
+
};
|
|
21684
|
+
const ticks = [...main.ticks];
|
|
21685
|
+
const nets = [...main.liquidityNets];
|
|
21686
|
+
for (let i = mainIndex + 1; i < windows.length; i++) {
|
|
21687
|
+
const window = windows[i];
|
|
21688
|
+
const edge = ticks.length - 1;
|
|
21689
|
+
if (!window.ticks.length || window.ticks[0] !== ticks[edge]) break;
|
|
21690
|
+
const offset = nets[edge] - window.liquidityNets[0];
|
|
21691
|
+
ticks.push(...window.ticks.slice(1));
|
|
21692
|
+
nets.push(...window.liquidityNets.slice(1).map((value) => value + offset));
|
|
21693
|
+
}
|
|
21694
|
+
for (let i = mainIndex - 1; i >= 0; i--) {
|
|
21695
|
+
const window = windows[i];
|
|
21696
|
+
const last = window.ticks.length - 1;
|
|
21697
|
+
if (last < 0 || window.ticks[last] !== ticks[0]) break;
|
|
21698
|
+
const offset = nets[0] - window.liquidityNets[last];
|
|
21699
|
+
ticks.unshift(...window.ticks.slice(0, last));
|
|
21700
|
+
nets.unshift(...window.liquidityNets.slice(0, last).map((value) => value + offset));
|
|
21701
|
+
}
|
|
21702
|
+
return {
|
|
21703
|
+
ticks,
|
|
21704
|
+
liquidityNets: nets
|
|
21705
|
+
};
|
|
21706
|
+
}
|
|
21707
|
+
/**
|
|
21708
|
+
* Read the main window around `startTick` plus up to `windowsPerSide` windows of `nTicks` on each
|
|
21709
|
+
* side, in parallel, and stitch them. Side windows that would cross the tick bounds are skipped.
|
|
21710
|
+
*/
|
|
21711
|
+
async function readTickNetWindows({ startTick, mainNTicks, nTicks, tickSpacing, windowsPerSide, read }) {
|
|
21712
|
+
const center = Math.trunc(startTick / tickSpacing) * tickSpacing;
|
|
21713
|
+
const half = Number(nTicks) * tickSpacing;
|
|
21714
|
+
const mainHalf = Number(mainNTicks) * tickSpacing;
|
|
21715
|
+
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);
|
|
21716
|
+
const below = sideCenters(-1).reverse();
|
|
21717
|
+
const above = sideCenters(1);
|
|
21718
|
+
const windows = await Promise.all([
|
|
21719
|
+
...below.map((side) => read(side, nTicks)),
|
|
21720
|
+
read(startTick, mainNTicks),
|
|
21721
|
+
...above.map((side) => read(side, nTicks))
|
|
21722
|
+
]);
|
|
21723
|
+
return stitchTickNetWindows(windows, below.length);
|
|
21724
|
+
}
|
|
21725
|
+
|
|
21643
21726
|
//#endregion
|
|
21644
21727
|
//#region src/panoptic/v2/reads/liquidity.ts
|
|
21645
21728
|
/**
|
|
@@ -21657,24 +21740,35 @@ async function optimizeTokenIdRiskPartners(params) {
|
|
|
21657
21740
|
async function getPoolLiquidities(params) {
|
|
21658
21741
|
const { client, poolAddress, queryAddress, startTick, nTicks, blockNumber } = params;
|
|
21659
21742
|
const targetBlockNumber = blockNumber ?? params._meta?.blockNumber ?? await client.getBlockNumber();
|
|
21660
|
-
const
|
|
21661
|
-
|
|
21662
|
-
|
|
21663
|
-
|
|
21664
|
-
|
|
21665
|
-
|
|
21666
|
-
|
|
21667
|
-
|
|
21668
|
-
|
|
21669
|
-
|
|
21743
|
+
const windowsPerSide = params.windowsPerSide ?? 0;
|
|
21744
|
+
if (windowsPerSide > 0 && params.tickSpacing === void 0) throw new PanopticValidationError("getPoolLiquidities: tickSpacing is required with windowsPerSide");
|
|
21745
|
+
const [{ ticks, liquidityNets }, _meta] = await Promise.all([readTickNetWindows({
|
|
21746
|
+
startTick: Number(startTick),
|
|
21747
|
+
mainNTicks: nTicks,
|
|
21748
|
+
nTicks,
|
|
21749
|
+
tickSpacing: params.tickSpacing ?? 1,
|
|
21750
|
+
windowsPerSide,
|
|
21751
|
+
read: (centerTick, windowTicks) => client.readContract({
|
|
21752
|
+
address: queryAddress,
|
|
21753
|
+
abi: panopticQueryAbi$1,
|
|
21754
|
+
functionName: "getTickNets",
|
|
21755
|
+
args: [
|
|
21756
|
+
poolAddress,
|
|
21757
|
+
centerTick,
|
|
21758
|
+
windowTicks
|
|
21759
|
+
],
|
|
21760
|
+
blockNumber: targetBlockNumber
|
|
21761
|
+
}).then(([tickData, nets]) => ({
|
|
21762
|
+
ticks: tickData,
|
|
21763
|
+
liquidityNets: nets
|
|
21764
|
+
}))
|
|
21670
21765
|
}), params._meta ?? getBlockMeta({
|
|
21671
21766
|
client,
|
|
21672
21767
|
blockNumber: targetBlockNumber
|
|
21673
21768
|
})]);
|
|
21674
|
-
const [tickData, liquidityNets] = result;
|
|
21675
21769
|
return {
|
|
21676
|
-
ticks
|
|
21677
|
-
liquidityNets
|
|
21770
|
+
ticks,
|
|
21771
|
+
liquidityNets,
|
|
21678
21772
|
_meta
|
|
21679
21773
|
};
|
|
21680
21774
|
}
|
|
@@ -22753,6 +22847,32 @@ function computeUniswapFeesForBlock(blockData, legs) {
|
|
|
22753
22847
|
total1
|
|
22754
22848
|
};
|
|
22755
22849
|
}
|
|
22850
|
+
const MAX_UINT256$1 = 2n ** 256n - 1n;
|
|
22851
|
+
/**
|
|
22852
|
+
* Fee growth per unit of liquidity inside `[lowerTick, upperTick)` at one block,
|
|
22853
|
+
* wrapped to uint256 as the pool computes it. Diff two snapshots with
|
|
22854
|
+
* `feesFromFeeGrowthDelta` to get the fees a constant liquidity earned between them.
|
|
22855
|
+
*/
|
|
22856
|
+
function feeGrowthInsideX128(blockData, lowerTick, upperTick) {
|
|
22857
|
+
const lower = blockData.tickData.get(lowerTick);
|
|
22858
|
+
const upper = blockData.tickData.get(upperTick);
|
|
22859
|
+
if (!lower || !upper) return null;
|
|
22860
|
+
const { currentTick } = blockData;
|
|
22861
|
+
const inside = (global, lowerOutside, upperOutside) => {
|
|
22862
|
+
const below = currentTick >= lowerTick ? lowerOutside : global - lowerOutside;
|
|
22863
|
+
const above = currentTick < upperTick ? upperOutside : global - upperOutside;
|
|
22864
|
+
return global - below - above & MAX_UINT256$1;
|
|
22865
|
+
};
|
|
22866
|
+
return {
|
|
22867
|
+
feeGrowthInside0X128: inside(blockData.feeGrowthGlobal0, lower.feeGrowthOutside0, upper.feeGrowthOutside0),
|
|
22868
|
+
feeGrowthInside1X128: inside(blockData.feeGrowthGlobal1, lower.feeGrowthOutside1, upper.feeGrowthOutside1)
|
|
22869
|
+
};
|
|
22870
|
+
}
|
|
22871
|
+
/** Blocks before the chain's Multicall3 deployment need viem's deployless multicall. */
|
|
22872
|
+
function predatesMulticall3(client, blockNumber) {
|
|
22873
|
+
const deployedAt = client.chain?.contracts?.multicall3?.blockCreated;
|
|
22874
|
+
return blockNumber != null && deployedAt != null && blockNumber < BigInt(deployedAt);
|
|
22875
|
+
}
|
|
22756
22876
|
async function fetchUniswapBlockSnapshot(client, blockNumber, uniqueTicks, poolConfig) {
|
|
22757
22877
|
if (poolConfig.version === "v3") return fetchV3BlockSnapshot(client, poolConfig.poolAddress, blockNumber, uniqueTicks);
|
|
22758
22878
|
else return fetchV4BlockSnapshot(client, poolConfig.stateViewAddress, poolConfig.poolId, blockNumber, uniqueTicks);
|
|
@@ -22784,7 +22904,8 @@ async function fetchV3BlockSnapshot(client, poolAddress, blockNumber, uniqueTick
|
|
|
22784
22904
|
const results = await client.multicall({
|
|
22785
22905
|
contracts,
|
|
22786
22906
|
blockNumber,
|
|
22787
|
-
allowFailure: false
|
|
22907
|
+
allowFailure: false,
|
|
22908
|
+
deployless: predatesMulticall3(client, blockNumber)
|
|
22788
22909
|
});
|
|
22789
22910
|
const slot0Result = results[0];
|
|
22790
22911
|
const feeGrowthGlobal0 = results[1];
|
|
@@ -22793,6 +22914,7 @@ async function fetchV3BlockSnapshot(client, poolAddress, blockNumber, uniqueTick
|
|
|
22793
22914
|
for (let i = 0; i < uniqueTicks.length; i++) {
|
|
22794
22915
|
const tickResult = results[3 + i];
|
|
22795
22916
|
tickData.set(uniqueTicks[i], {
|
|
22917
|
+
liquidityGross: tickResult[0],
|
|
22796
22918
|
feeGrowthOutside0: tickResult[2],
|
|
22797
22919
|
feeGrowthOutside1: tickResult[3]
|
|
22798
22920
|
});
|
|
@@ -22829,7 +22951,8 @@ async function fetchV4BlockSnapshot(client, stateViewAddress, poolId, blockNumbe
|
|
|
22829
22951
|
const results = await client.multicall({
|
|
22830
22952
|
contracts,
|
|
22831
22953
|
blockNumber,
|
|
22832
|
-
allowFailure: false
|
|
22954
|
+
allowFailure: false,
|
|
22955
|
+
deployless: predatesMulticall3(client, blockNumber)
|
|
22833
22956
|
});
|
|
22834
22957
|
const slot0Result = results[0];
|
|
22835
22958
|
const feeGrowthResult = results[1];
|
|
@@ -22837,6 +22960,7 @@ async function fetchV4BlockSnapshot(client, stateViewAddress, poolId, blockNumbe
|
|
|
22837
22960
|
for (let i = 0; i < uniqueTicks.length; i++) {
|
|
22838
22961
|
const tickResult = results[2 + i];
|
|
22839
22962
|
tickData.set(uniqueTicks[i], {
|
|
22963
|
+
liquidityGross: tickResult[0],
|
|
22840
22964
|
feeGrowthOutside0: tickResult[2],
|
|
22841
22965
|
feeGrowthOutside1: tickResult[3]
|
|
22842
22966
|
});
|
|
@@ -23139,23 +23263,34 @@ function clampNTicks(startTick, tickSpacing, nTicks) {
|
|
|
23139
23263
|
* for the pool — only a deployed PanopticQuery on the chain.
|
|
23140
23264
|
*/
|
|
23141
23265
|
async function getUniswapV3PoolLiquidities(params) {
|
|
23142
|
-
const { client, poolAddress, queryAddress, startTick, nTicks } = params;
|
|
23143
|
-
|
|
23266
|
+
const { client, poolAddress, queryAddress, startTick, nTicks, windowsPerSide = 0 } = params;
|
|
23267
|
+
if (windowsPerSide > 0 && params.tickSpacing === void 0) throw new PanopticValidationError("getUniswapV3PoolLiquidities: tickSpacing is required with windowsPerSide");
|
|
23268
|
+
const safeN = clampNTicks(startTick, params.tickSpacing ?? 1, nTicks);
|
|
23144
23269
|
const _meta = await getBlockMeta({ client });
|
|
23145
|
-
const
|
|
23146
|
-
|
|
23147
|
-
|
|
23148
|
-
|
|
23149
|
-
|
|
23150
|
-
|
|
23151
|
-
|
|
23152
|
-
|
|
23153
|
-
|
|
23154
|
-
|
|
23270
|
+
const { ticks, liquidityNets } = await readTickNetWindows({
|
|
23271
|
+
startTick,
|
|
23272
|
+
mainNTicks: safeN,
|
|
23273
|
+
nTicks,
|
|
23274
|
+
tickSpacing: params.tickSpacing ?? 1,
|
|
23275
|
+
windowsPerSide,
|
|
23276
|
+
read: (centerTick, windowTicks) => client.readContract({
|
|
23277
|
+
address: queryAddress,
|
|
23278
|
+
abi: panopticQueryAbi$1,
|
|
23279
|
+
functionName: "getTickNetsV3",
|
|
23280
|
+
args: [
|
|
23281
|
+
poolAddress,
|
|
23282
|
+
centerTick,
|
|
23283
|
+
windowTicks
|
|
23284
|
+
],
|
|
23285
|
+
blockNumber: _meta.blockNumber
|
|
23286
|
+
}).then(([windowTickData, windowNets]) => ({
|
|
23287
|
+
ticks: windowTickData,
|
|
23288
|
+
liquidityNets: windowNets
|
|
23289
|
+
}))
|
|
23155
23290
|
});
|
|
23156
23291
|
return {
|
|
23157
|
-
ticks
|
|
23158
|
-
liquidityNets
|
|
23292
|
+
ticks,
|
|
23293
|
+
liquidityNets,
|
|
23159
23294
|
_meta
|
|
23160
23295
|
};
|
|
23161
23296
|
}
|
|
@@ -23328,22 +23463,32 @@ async function getUniswapV4PoolLiquidities(params) {
|
|
|
23328
23463
|
const { client, queryAddress, poolManager, poolId, tickSpacing, startTick, nTicks } = params;
|
|
23329
23464
|
const safeN = clampNTicks(startTick, tickSpacing, nTicks);
|
|
23330
23465
|
const _meta = await getBlockMeta({ client });
|
|
23331
|
-
const
|
|
23332
|
-
|
|
23333
|
-
|
|
23334
|
-
|
|
23335
|
-
|
|
23336
|
-
|
|
23337
|
-
|
|
23338
|
-
|
|
23339
|
-
|
|
23340
|
-
|
|
23341
|
-
|
|
23342
|
-
|
|
23466
|
+
const { ticks, liquidityNets } = await readTickNetWindows({
|
|
23467
|
+
startTick,
|
|
23468
|
+
mainNTicks: safeN,
|
|
23469
|
+
nTicks,
|
|
23470
|
+
tickSpacing,
|
|
23471
|
+
windowsPerSide: params.windowsPerSide ?? 0,
|
|
23472
|
+
read: (centerTick, windowTicks) => client.readContract({
|
|
23473
|
+
address: queryAddress,
|
|
23474
|
+
abi: panopticQueryAbi$1,
|
|
23475
|
+
functionName: "getTickNetsV4",
|
|
23476
|
+
args: [
|
|
23477
|
+
poolManager,
|
|
23478
|
+
poolId,
|
|
23479
|
+
tickSpacing,
|
|
23480
|
+
centerTick,
|
|
23481
|
+
windowTicks
|
|
23482
|
+
],
|
|
23483
|
+
blockNumber: _meta.blockNumber
|
|
23484
|
+
}).then(([windowTickData, windowNets]) => ({
|
|
23485
|
+
ticks: windowTickData,
|
|
23486
|
+
liquidityNets: windowNets
|
|
23487
|
+
}))
|
|
23343
23488
|
});
|
|
23344
23489
|
return {
|
|
23345
|
-
ticks
|
|
23346
|
-
liquidityNets
|
|
23490
|
+
ticks,
|
|
23491
|
+
liquidityNets,
|
|
23347
23492
|
_meta
|
|
23348
23493
|
};
|
|
23349
23494
|
}
|
|
@@ -26070,7 +26215,7 @@ async function forceExerciseAndWait(params) {
|
|
|
26070
26215
|
//#endregion
|
|
26071
26216
|
//#region src/panoptic/v2/writes/protectedSettle.ts
|
|
26072
26217
|
const POOL_ID_MASK = (1n << 64n) - 1n;
|
|
26073
|
-
const Q96 = 1n << 96n;
|
|
26218
|
+
const Q96$1 = 1n << 96n;
|
|
26074
26219
|
const MAX_UINT128$1 = (1n << 128n) - 1n;
|
|
26075
26220
|
const SETTLE_LIMITS = [
|
|
26076
26221
|
-887272n,
|
|
@@ -26090,7 +26235,7 @@ function minimumPokeSize(legs, tickSpacing) {
|
|
|
26090
26235
|
const sqrtLower = tickToSqrtPriceX96(lowerTick);
|
|
26091
26236
|
const sqrtUpper = tickToSqrtPriceX96(upperTick);
|
|
26092
26237
|
const delta = sqrtUpper - sqrtLower;
|
|
26093
|
-
const liquidityFactor = leg.asset === 0n ? sqrtLower * sqrtUpper / Q96 : Q96;
|
|
26238
|
+
const liquidityFactor = leg.asset === 0n ? sqrtLower * sqrtUpper / Q96$1 : Q96$1;
|
|
26094
26239
|
if (liquidityFactor === 0n) return void 0;
|
|
26095
26240
|
const requiredAmount = ceilDiv$1(delta, liquidityFactor);
|
|
26096
26241
|
const legSize = ceilDiv$1(requiredAmount, leg.optionRatio);
|
|
@@ -27866,6 +28011,62 @@ async function getLoanPositionsForToken(client, poolAddress, account, existingPo
|
|
|
27866
28011
|
};
|
|
27867
28012
|
});
|
|
27868
28013
|
}
|
|
28014
|
+
async function buildRepayDispatch(params) {
|
|
28015
|
+
const { client, account, poolAddress, chainId, token, amount, slippageBps, existingPositionIds, builderCode = 0n } = params;
|
|
28016
|
+
if (amount <= 0n) throw new Error("Repayment amount must be positive");
|
|
28017
|
+
const pool = await getPool({
|
|
28018
|
+
client,
|
|
28019
|
+
poolAddress,
|
|
28020
|
+
chainId
|
|
28021
|
+
});
|
|
28022
|
+
const tokenIndex = resolveTokenIndex(token, pool.collateralTracker0.token, pool.collateralTracker1.token);
|
|
28023
|
+
const loans = await getLoanPositionsForToken(client, poolAddress, account, existingPositionIds, tokenIndex);
|
|
28024
|
+
if (loans.length === 0) throw new NoLoanPositionsError(token);
|
|
28025
|
+
const totalDebt = loans.reduce((sum$1, l) => sum$1 + l.tokenAmount, 0n);
|
|
28026
|
+
const loanIds = loans.map((l) => l.tokenId);
|
|
28027
|
+
const remainder = totalDebt > amount ? totalDebt - amount : 0n;
|
|
28028
|
+
const { low: tickLimitLow, high: tickLimitHigh } = tickLimits(pool.currentTick, slippageBps);
|
|
28029
|
+
const ascendingLimits = [
|
|
28030
|
+
tickLimitLow,
|
|
28031
|
+
tickLimitHigh,
|
|
28032
|
+
0n
|
|
28033
|
+
];
|
|
28034
|
+
const nonLoanIds = existingPositionIds.filter((id) => !loanIds.includes(id));
|
|
28035
|
+
const opsPositionIds = [...loanIds];
|
|
28036
|
+
const opsSizes = loanIds.map(() => 0n);
|
|
28037
|
+
const opsLimits = loanIds.map(() => ascendingLimits);
|
|
28038
|
+
let finalPositionIdList;
|
|
28039
|
+
if (remainder > 0n) {
|
|
28040
|
+
const { tokenId: newLoanId, adjustedSize } = buildUniqueLoan(pool.poolId, tokenIndex, tokenIndex, pool.currentTick, pool.tickSpacing, nonLoanIds, remainder);
|
|
28041
|
+
opsPositionIds.push(newLoanId);
|
|
28042
|
+
opsSizes.push(adjustedSize);
|
|
28043
|
+
opsLimits.push(ascendingLimits);
|
|
28044
|
+
finalPositionIdList = [...nonLoanIds, newLoanId];
|
|
28045
|
+
} else finalPositionIdList = nonLoanIds;
|
|
28046
|
+
return {
|
|
28047
|
+
positionIdList: opsPositionIds,
|
|
28048
|
+
finalPositionIdList,
|
|
28049
|
+
positionSizes: opsSizes,
|
|
28050
|
+
tickAndSpreadLimits: opsLimits,
|
|
28051
|
+
usePremiaAsCollateral: false,
|
|
28052
|
+
builderCode
|
|
28053
|
+
};
|
|
28054
|
+
}
|
|
28055
|
+
/** Preview the same full or partial repayment dispatch used by smartRepay. */
|
|
28056
|
+
async function previewRepay(params) {
|
|
28057
|
+
const dispatch$1 = await buildRepayDispatch(params);
|
|
28058
|
+
const simulation = await simulateDispatch({
|
|
28059
|
+
client: params.client,
|
|
28060
|
+
account: params.account,
|
|
28061
|
+
poolAddress: params.poolAddress,
|
|
28062
|
+
existingPositionIdList: params.existingPositionIds,
|
|
28063
|
+
...dispatch$1
|
|
28064
|
+
});
|
|
28065
|
+
return {
|
|
28066
|
+
dispatch: dispatch$1,
|
|
28067
|
+
simulation
|
|
28068
|
+
};
|
|
28069
|
+
}
|
|
27869
28070
|
/**
|
|
27870
28071
|
* Smart repay: burns all loan positions for a token and optionally re-opens a smaller one.
|
|
27871
28072
|
*
|
|
@@ -27879,37 +28080,9 @@ async function getLoanPositionsForToken(client, poolAddress, account, existingPo
|
|
|
27879
28080
|
* @returns TxResult
|
|
27880
28081
|
*/
|
|
27881
28082
|
async function smartRepay(params) {
|
|
27882
|
-
const { client, walletClient, account, poolAddress,
|
|
28083
|
+
const { client, walletClient, account, poolAddress, txOverrides } = params;
|
|
27883
28084
|
for (let attempt = 0; attempt < MAX_RETRIES; attempt++) {
|
|
27884
|
-
const
|
|
27885
|
-
client,
|
|
27886
|
-
poolAddress,
|
|
27887
|
-
chainId
|
|
27888
|
-
});
|
|
27889
|
-
const tokenIndex = resolveTokenIndex(token, pool.collateralTracker0.token, pool.collateralTracker1.token);
|
|
27890
|
-
const loans = await getLoanPositionsForToken(client, poolAddress, account, existingPositionIds, tokenIndex);
|
|
27891
|
-
if (loans.length === 0) throw new NoLoanPositionsError(token);
|
|
27892
|
-
const totalDebt = loans.reduce((sum$1, l) => sum$1 + l.tokenAmount, 0n);
|
|
27893
|
-
const loanIds = loans.map((l) => l.tokenId);
|
|
27894
|
-
const remainder = totalDebt > amount ? totalDebt - amount : 0n;
|
|
27895
|
-
const { low: tickLimitLow, high: tickLimitHigh } = tickLimits(pool.currentTick, slippageBps);
|
|
27896
|
-
const ascendingLimits = [
|
|
27897
|
-
Number(tickLimitLow),
|
|
27898
|
-
Number(tickLimitHigh),
|
|
27899
|
-
0
|
|
27900
|
-
];
|
|
27901
|
-
const nonLoanIds = existingPositionIds.filter((id) => !loanIds.includes(id));
|
|
27902
|
-
const opsPositionIds = [...loanIds];
|
|
27903
|
-
const opsSizes = loanIds.map(() => 0n);
|
|
27904
|
-
const opsLimits = loanIds.map(() => ascendingLimits);
|
|
27905
|
-
let finalPositionIdList;
|
|
27906
|
-
if (remainder > 0n) {
|
|
27907
|
-
const { tokenId: newLoanId, adjustedSize } = buildUniqueLoan(pool.poolId, tokenIndex, tokenIndex, pool.currentTick, pool.tickSpacing, nonLoanIds, remainder);
|
|
27908
|
-
opsPositionIds.push(newLoanId);
|
|
27909
|
-
opsSizes.push(adjustedSize);
|
|
27910
|
-
opsLimits.push(ascendingLimits);
|
|
27911
|
-
finalPositionIdList = [...nonLoanIds, newLoanId];
|
|
27912
|
-
} else finalPositionIdList = nonLoanIds;
|
|
28085
|
+
const intent = await buildRepayDispatch(params);
|
|
27913
28086
|
try {
|
|
27914
28087
|
return await submitWrite({
|
|
27915
28088
|
client,
|
|
@@ -27919,12 +28092,12 @@ async function smartRepay(params) {
|
|
|
27919
28092
|
abi: panopticPoolV2Abi,
|
|
27920
28093
|
functionName: "dispatch",
|
|
27921
28094
|
args: [
|
|
27922
|
-
|
|
27923
|
-
finalPositionIdList,
|
|
27924
|
-
|
|
27925
|
-
|
|
27926
|
-
|
|
27927
|
-
builderCode
|
|
28095
|
+
intent.positionIdList,
|
|
28096
|
+
intent.finalPositionIdList,
|
|
28097
|
+
intent.positionSizes,
|
|
28098
|
+
intent.tickAndSpreadLimits.map((limits) => limits.map(Number)),
|
|
28099
|
+
intent.usePremiaAsCollateral,
|
|
28100
|
+
intent.builderCode
|
|
27928
28101
|
],
|
|
27929
28102
|
txOverrides
|
|
27930
28103
|
});
|
|
@@ -31350,15 +31523,29 @@ var _4663 = {
|
|
|
31350
31523
|
"panoptic": {
|
|
31351
31524
|
"pool": {
|
|
31352
31525
|
"version": "v4",
|
|
31353
|
-
"panopticPool": "
|
|
31354
|
-
"collateralTracker0": "
|
|
31355
|
-
"collateralTracker1": "
|
|
31526
|
+
"panopticPool": "0x000000000c21b38c54AcA7c7145Df01ff09d69Bb",
|
|
31527
|
+
"collateralTracker0": "0xDc508622CD7e3850c8240e88c10361Cf493465b6",
|
|
31528
|
+
"collateralTracker1": "0x9212d804953bAf89C24ceFa6545aA293bA08a876"
|
|
31529
|
+
},
|
|
31530
|
+
"additionalPools": {
|
|
31531
|
+
"spyUsdg30bpsV4": {
|
|
31532
|
+
"version": "v4",
|
|
31533
|
+
"panopticPool": "0x00000000989bcb6f24af4a1Ab2A6d6a31c98A58E",
|
|
31534
|
+
"collateralTracker0": "0x49eaAC32A7CD4B8fB2209a12859a95E0b20aB0e5",
|
|
31535
|
+
"collateralTracker1": "0x670C44a0FC35dbC410498e47A6290a1C3196d191"
|
|
31536
|
+
},
|
|
31537
|
+
"spyUsdg5bpsV4": {
|
|
31538
|
+
"version": "v4",
|
|
31539
|
+
"panopticPool": "0x000000000c21b38c54AcA7c7145Df01ff09d69Bb",
|
|
31540
|
+
"collateralTracker0": "0xDc508622CD7e3850c8240e88c10361Cf493465b6",
|
|
31541
|
+
"collateralTracker1": "0x9212d804953bAf89C24ceFa6545aA293bA08a876"
|
|
31542
|
+
}
|
|
31356
31543
|
},
|
|
31357
31544
|
"v2": {
|
|
31358
31545
|
"semiFungiblePositionManagerV4": "0x00000000000005C3287f136Ef5AF56c68Ea6849f",
|
|
31359
31546
|
"semiFungiblePositionManagerV3": "0x00000000000005E4693aDc8Ec0f12D686f728198",
|
|
31360
31547
|
"builderFactory": "0x0000000000000a3D22E158417AA639D7F71b0FF7",
|
|
31361
|
-
"riskEngine": "
|
|
31548
|
+
"riskEngine": "0x0000000000000fE1E261f66ce2F44def4F5Ae0CB",
|
|
31362
31549
|
"panopticPoolImplementation": "0x000000000000135429F0DaCaB61639Bf6a63EbbC",
|
|
31363
31550
|
"collateralTrackerImplementation": "0x0000000000001d9c38CA405A2e04420865A08A33",
|
|
31364
31551
|
"panopticFactoryV4": "0x0000000000000c51d0f8cf4bd9adE7191372a625",
|
|
@@ -31374,13 +31561,29 @@ var _4663 = {
|
|
|
31374
31561
|
"0x0000000000000fe1e261f66ce2f44def4f5ae0cb",
|
|
31375
31562
|
"0x0000000000000f3fb82469581A74776178E76Ca4"
|
|
31376
31563
|
],
|
|
31377
|
-
"markets": {
|
|
31378
|
-
"
|
|
31379
|
-
|
|
31380
|
-
|
|
31381
|
-
|
|
31382
|
-
|
|
31383
|
-
|
|
31564
|
+
"markets": {
|
|
31565
|
+
"spyUsdg": {
|
|
31566
|
+
"currency0": "0x117cc2133c37B721F49dE2A7a74833232B3B4C0C",
|
|
31567
|
+
"currency1": "0x5fc5360D0400a0Fd4f2af552ADD042D716F1d168",
|
|
31568
|
+
"fee": 500,
|
|
31569
|
+
"tickSpacing": 5,
|
|
31570
|
+
"poolId": "0xe5923c8a8be481ec89a2ca784a2bbfa4235de6d88f92260fd66b660c4babf907"
|
|
31571
|
+
},
|
|
31572
|
+
"spyUsdg30bps": {
|
|
31573
|
+
"currency0": "0x117cc2133c37B721F49dE2A7a74833232B3B4C0C",
|
|
31574
|
+
"currency1": "0x5fc5360D0400a0Fd4f2af552ADD042D716F1d168",
|
|
31575
|
+
"fee": 3e3,
|
|
31576
|
+
"tickSpacing": 60,
|
|
31577
|
+
"poolId": "0xfe2a80bb5618fd14984b92ca6d45bf5ba67443ddb1435e28b2e48df2fc1526cd"
|
|
31578
|
+
},
|
|
31579
|
+
"spyUsdg5bps": {
|
|
31580
|
+
"currency0": "0x117cc2133c37B721F49dE2A7a74833232B3B4C0C",
|
|
31581
|
+
"currency1": "0x5fc5360D0400a0Fd4f2af552ADD042D716F1d168",
|
|
31582
|
+
"fee": 500,
|
|
31583
|
+
"tickSpacing": 5,
|
|
31584
|
+
"poolId": "0xe5923c8a8be481ec89a2ca784a2bbfa4235de6d88f92260fd66b660c4babf907"
|
|
31585
|
+
}
|
|
31586
|
+
},
|
|
31384
31587
|
"subgraphs": {
|
|
31385
31588
|
"hypovault": "https://api.goldsky.com/api/public/project_cl9gc21q105380hxuh8ks53k3/subgraphs/hypovault-subgraph-robinhood/prod/gn",
|
|
31386
31589
|
"panoptic": "https://api.goldsky.com/api/public/project_cl9gc21q105380hxuh8ks53k3/subgraphs/panoptic-subgraph-robinhood/v2_prod/gn"
|
|
@@ -31548,6 +31751,10 @@ function getSpyUsdgMarket(deployment) {
|
|
|
31548
31751
|
if (market === void 0) throw new Error(`Missing SPY/USDG market for chainId ${deployment.chainId}`);
|
|
31549
31752
|
return market;
|
|
31550
31753
|
}
|
|
31754
|
+
function requireDeploymentValue(value, label) {
|
|
31755
|
+
if (value === void 0) throw new Error(`Missing deployment value: ${label}`);
|
|
31756
|
+
return value;
|
|
31757
|
+
}
|
|
31551
31758
|
const MAINNET_DEPLOYMENT = CHAIN_DEPLOYMENTS[MAINNET_CHAIN_ID];
|
|
31552
31759
|
const MAINNET_ETH_USDC_5BPS_V3_PANOPTIC_POOL_ADDRESSES = MAINNET_DEPLOYMENT.panoptic.additionalPools?.ethUsdc5bpsV3;
|
|
31553
31760
|
const MAINNET_PANOPTIC_V2_ADDRESSES = MAINNET_DEPLOYMENT.panoptic.v2;
|
|
@@ -31576,9 +31783,13 @@ const ROBINHOOD_HYPOVAULT_ADDRESSES = ROBINHOOD_DEPLOYMENT.hypovault.vaults;
|
|
|
31576
31783
|
const ROBINHOOD_HYPOVAULT_MANAGER_ADDRESSES = ROBINHOOD_DEPLOYMENT.hypovault.managers;
|
|
31577
31784
|
const ROBINHOOD_HYPOVAULT_MANAGER_TURNKEY_SIGNERS = ROBINHOOD_DEPLOYMENT.hypovault.turnkeySigners;
|
|
31578
31785
|
const ROBINHOOD_PANOPTIC_POOL_ADDRESSES = ROBINHOOD_DEPLOYMENT.panoptic.pool;
|
|
31786
|
+
const ROBINHOOD_SPY_USDG_30BPS_PANOPTIC_POOL_ADDRESSES = requireDeploymentValue(ROBINHOOD_DEPLOYMENT.panoptic.additionalPools?.spyUsdg30bpsV4, "Robinhood SPY/USDG 30bps Panoptic pool");
|
|
31787
|
+
const ROBINHOOD_SPY_USDG_5BPS_PANOPTIC_POOL_ADDRESSES = requireDeploymentValue(ROBINHOOD_DEPLOYMENT.panoptic.additionalPools?.spyUsdg5bpsV4, "Robinhood SPY/USDG 5bps Panoptic pool");
|
|
31579
31788
|
const ROBINHOOD_PANOPTIC_V2_ADDRESSES = ROBINHOOD_DEPLOYMENT.panoptic.v2;
|
|
31580
31789
|
const ROBINHOOD_RISK_ENGINES = ROBINHOOD_DEPLOYMENT.riskEngines;
|
|
31581
31790
|
const ROBINHOOD_SPY_USDG_MARKET = getSpyUsdgMarket(ROBINHOOD_DEPLOYMENT);
|
|
31791
|
+
const ROBINHOOD_SPY_USDG_30BPS_MARKET = requireDeploymentValue(ROBINHOOD_DEPLOYMENT.markets.spyUsdg30bps, "Robinhood SPY/USDG 30bps market");
|
|
31792
|
+
const ROBINHOOD_SPY_USDG_5BPS_MARKET = requireDeploymentValue(ROBINHOOD_DEPLOYMENT.markets.spyUsdg5bps, "Robinhood SPY/USDG 5bps market");
|
|
31582
31793
|
|
|
31583
31794
|
//#endregion
|
|
31584
31795
|
//#region ../deployments/src/vaultDisplayNames.js
|
|
@@ -31669,6 +31880,131 @@ function marketRiskFromValues({ lower, current, upper }) {
|
|
|
31669
31880
|
};
|
|
31670
31881
|
}
|
|
31671
31882
|
|
|
31883
|
+
//#endregion
|
|
31884
|
+
//#region src/panoptic/v2/greeks/positionVolatility.ts
|
|
31885
|
+
const Precision = Decimal.clone({ precision: 80 });
|
|
31886
|
+
const Q96 = 1n << 96n;
|
|
31887
|
+
const YEAR_SECONDS = new Precision(31536e3);
|
|
31888
|
+
/** The premium-free position curve, expressed in one quote token's human units. */
|
|
31889
|
+
function preparePositionGamma({ tokenId, positionSize, quoteIsToken0, quoteDecimals }) {
|
|
31890
|
+
if (positionSize <= 0n || positionSize >= 1n << 128n) throw new RangeError("Invalid position size");
|
|
31891
|
+
if (!Number.isInteger(quoteDecimals) || quoteDecimals < 0 || quoteDecimals > 255) throw new RangeError("Invalid quote decimals");
|
|
31892
|
+
const decoded = decodeTokenId(tokenId);
|
|
31893
|
+
const chunks = decoded.legs.flatMap((leg) => {
|
|
31894
|
+
if (leg.width === 0n) return [];
|
|
31895
|
+
const width = leg.width * decoded.tickSpacing;
|
|
31896
|
+
const lowerTick = leg.strike - width / 2n;
|
|
31897
|
+
const upperTick = leg.strike + (width + 1n) / 2n;
|
|
31898
|
+
if (lowerTick < -887272n || upperTick > 887272n || lowerTick >= upperTick) throw new RangeError("Invalid position range");
|
|
31899
|
+
const lower = tickToSqrtPriceX96(lowerTick);
|
|
31900
|
+
const upper = tickToSqrtPriceX96(upperTick);
|
|
31901
|
+
const amount = positionSize * leg.optionRatio;
|
|
31902
|
+
const liquidity = leg.asset === 0n ? amount * (lower * upper / Q96) / (upper - lower) : amount * Q96 / (upper - lower);
|
|
31903
|
+
if (liquidity >= 1n << 128n) throw new RangeError("Liquidity exceeds uint128");
|
|
31904
|
+
return [{
|
|
31905
|
+
lowerTick: Number(lowerTick),
|
|
31906
|
+
upperTick: Number(upperTick),
|
|
31907
|
+
liquidity,
|
|
31908
|
+
isLong: leg.isLong
|
|
31909
|
+
}];
|
|
31910
|
+
});
|
|
31911
|
+
const scale = new Precision(10).pow(quoteDecimals);
|
|
31912
|
+
const atTick = (tick) => {
|
|
31913
|
+
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);
|
|
31914
|
+
const sqrt = new Precision(tickToSqrtPriceX96(tick).toString()).div(Q96.toString());
|
|
31915
|
+
const gamma = new Precision(netLiquidity.toString()).neg().div(2).div(scale);
|
|
31916
|
+
return quoteIsToken0 ? gamma.div(sqrt) : gamma.mul(sqrt);
|
|
31917
|
+
};
|
|
31918
|
+
const inRange = (low, high) => {
|
|
31919
|
+
if (low > high) throw new RangeError("Invalid candle range");
|
|
31920
|
+
const ticks = new Set([low, high]);
|
|
31921
|
+
for (const chunk of chunks) for (const boundary of [BigInt(chunk.lowerTick), BigInt(chunk.upperTick)]) {
|
|
31922
|
+
if (boundary >= low && boundary <= high) ticks.add(boundary);
|
|
31923
|
+
if (boundary - 1n >= low && boundary - 1n <= high) ticks.add(boundary - 1n);
|
|
31924
|
+
}
|
|
31925
|
+
return [...ticks].map(atTick);
|
|
31926
|
+
};
|
|
31927
|
+
return {
|
|
31928
|
+
chunks,
|
|
31929
|
+
atTick,
|
|
31930
|
+
inRange
|
|
31931
|
+
};
|
|
31932
|
+
}
|
|
31933
|
+
/** Historical whole-position diagnostics, with signs retained independently of eligibility. */
|
|
31934
|
+
function calculatePositionVolatilityMetrics({ observations, netPremium, baseFees, quoteDecimals }) {
|
|
31935
|
+
if (observations.length < 2) throw new RangeError("At least two price observations are required");
|
|
31936
|
+
if (!Number.isInteger(quoteDecimals) || quoteDecimals < 0 || quoteDecimals > 255) throw new RangeError("Invalid quote decimals");
|
|
31937
|
+
const points = observations.map((point) => ({
|
|
31938
|
+
...point,
|
|
31939
|
+
price: new Precision(point.price),
|
|
31940
|
+
gamma: new Precision(point.gamma),
|
|
31941
|
+
rangeGammas: (point.rangeGammas ?? []).map((gamma) => new Precision(gamma))
|
|
31942
|
+
}));
|
|
31943
|
+
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");
|
|
31944
|
+
const quantum = new Precision(10).pow(-quoteDecimals);
|
|
31945
|
+
const gammas = points.flatMap((point) => [point.gamma, ...point.rangeGammas]);
|
|
31946
|
+
const peak = gammas.reduce((max, gamma) => Precision.max(max, gamma.abs()), new Precision(0));
|
|
31947
|
+
const tolerance = Precision.max(quantum, peak.mul("1e-12"));
|
|
31948
|
+
const positive = gammas.some((gamma) => gamma.gt(tolerance));
|
|
31949
|
+
const negative = gammas.some((gamma) => gamma.lt(tolerance.neg()));
|
|
31950
|
+
const gammaSign = positive && negative ? "changing" : positive ? "positive" : negative ? "negative" : "zero";
|
|
31951
|
+
let exposure = new Precision(0);
|
|
31952
|
+
let signedConvexity = new Precision(0);
|
|
31953
|
+
let absoluteConvexity = new Precision(0);
|
|
31954
|
+
let years = new Precision(0);
|
|
31955
|
+
for (let i = 1; i < points.length; i++) {
|
|
31956
|
+
const previous = points[i - 1];
|
|
31957
|
+
const point = points[i];
|
|
31958
|
+
const seconds = point.timestamp - previous.timestamp;
|
|
31959
|
+
if (seconds <= 0n) throw new RangeError("Observations must have increasing timestamps");
|
|
31960
|
+
const elapsed = new Precision(seconds.toString()).div(YEAR_SECONDS);
|
|
31961
|
+
const squaredReturn = point.price.div(previous.price).ln().pow(2);
|
|
31962
|
+
exposure = exposure.plus(previous.gamma.abs().mul(elapsed));
|
|
31963
|
+
signedConvexity = signedConvexity.plus(previous.gamma.mul(squaredReturn).div(2));
|
|
31964
|
+
absoluteConvexity = absoluteConvexity.plus(previous.gamma.abs().mul(squaredReturn).div(2));
|
|
31965
|
+
years = years.plus(elapsed);
|
|
31966
|
+
}
|
|
31967
|
+
const sufficientExposure = exposure.gt(tolerance.mul(years).mul(100));
|
|
31968
|
+
const premium = netPremium === null ? null : new Precision(netPremium);
|
|
31969
|
+
const fees = baseFees == null ? null : new Precision(baseFees);
|
|
31970
|
+
if (premium !== null && !premium.isFinite() || fees !== null && !fees.isFinite()) throw new RangeError("Invalid accounting amount");
|
|
31971
|
+
const consistent = (amount) => gammaSign === "positive" ? amount.lte(quantum) : gammaSign === "negative" && amount.gte(quantum.neg());
|
|
31972
|
+
const reason = !sufficientExposure ? "insufficient-exposure" : gammaSign === "changing" ? "changing-sign" : premium === null ? "premium-unavailable" : !consistent(premium) ? "inconsistent-premium-direction" : null;
|
|
31973
|
+
const equivalent = (amount) => amount.abs().mul(2).div(exposure).sqrt().toString();
|
|
31974
|
+
const coverage = (amount) => absoluteConvexity.gt(quantum) ? amount.abs().div(absoluteConvexity).toString() : null;
|
|
31975
|
+
const eligibleFees = sufficientExposure && fees !== null && consistent(fees);
|
|
31976
|
+
return {
|
|
31977
|
+
gammaSign,
|
|
31978
|
+
exposure: exposure.toString(),
|
|
31979
|
+
signedConvexity: signedConvexity.toString(),
|
|
31980
|
+
absoluteConvexity: absoluteConvexity.toString(),
|
|
31981
|
+
netPremium: premium?.toString() ?? null,
|
|
31982
|
+
estimatedHedgedResult: premium?.plus(signedConvexity).toString() ?? null,
|
|
31983
|
+
weightedRealizedVolatility: sufficientExposure ? equivalent(absoluteConvexity) : null,
|
|
31984
|
+
premiumEquivalentVolatility: reason === null && premium !== null ? equivalent(premium) : null,
|
|
31985
|
+
premiumToConvexity: reason === null && premium !== null ? coverage(premium) : null,
|
|
31986
|
+
baseFees: fees?.toString() ?? null,
|
|
31987
|
+
feeEquivalentVolatility: eligibleFees ? equivalent(fees) : null,
|
|
31988
|
+
feeToConvexity: eligibleFees ? coverage(fees) : null,
|
|
31989
|
+
comparisonReason: reason
|
|
31990
|
+
};
|
|
31991
|
+
}
|
|
31992
|
+
/** Quote-value signed cumulative token increments, excluding revaluation of previous accrual. */
|
|
31993
|
+
function valuePositionAccrual({ snapshots, quoteIsToken0, quoteDecimals }) {
|
|
31994
|
+
let previous0 = 0n;
|
|
31995
|
+
let previous1 = 0n;
|
|
31996
|
+
let total = new Precision(0);
|
|
31997
|
+
for (const snapshot of snapshots) {
|
|
31998
|
+
const amount0 = new Precision((snapshot.token0 - previous0).toString());
|
|
31999
|
+
const amount1 = new Precision((snapshot.token1 - previous1).toString());
|
|
32000
|
+
const price = new Precision("1.0001").pow(snapshot.tick.toString());
|
|
32001
|
+
total = total.plus(quoteIsToken0 ? amount0.plus(amount1.div(price)) : amount1.plus(amount0.mul(price)));
|
|
32002
|
+
previous0 = snapshot.token0;
|
|
32003
|
+
previous1 = snapshot.token1;
|
|
32004
|
+
}
|
|
32005
|
+
return total.div(new Precision(10).pow(quoteDecimals));
|
|
32006
|
+
}
|
|
32007
|
+
|
|
31672
32008
|
//#endregion
|
|
31673
32009
|
//#region src/panoptic/v2/reads/collateralCurve.ts
|
|
31674
32010
|
/** Native-token margin inputs, independent of the tick used to display the curve. */
|
|
@@ -31862,5 +32198,220 @@ function preparePositionValueCurve(curve) {
|
|
|
31862
32198
|
}
|
|
31863
32199
|
|
|
31864
32200
|
//#endregion
|
|
31865
|
-
export { AccountInsolventError, AlreadyInitializedError, BORROW_INDEX_BITS, BPS_DENOMINATOR, BPS_SCALE, BatchValidationError, BelowMinimumRedemptionError, CastingError, ChunkHasZeroLiquidityError, ChunkLimitError, CrossPoolError, DEFAULT_MAX_SPREAD, DEFAULT_MINT_BUFFER, DEFAULT_MIN_SWAP_RATIO_BPS, DEFAULT_RECONNECT_CONFIG, DEFAULT_VEGOID, DepositTooLargeError, DuplicateTokenIdError, EffectiveLiquidityAboveThresholdError, ExceedsMaximumRedemptionError, InputListFailError, InsufficientCreditLiquidityError, InvalidBuilderCodeError, InvalidHistoryRangeError, InvalidTickBoundError, InvalidTickError, InvalidTokenIdParameterError, InvalidUniswapCallbackError, LEG_BITS, LEG_LIMITS, LEG_MASKS, LengthMismatchError, LiquidityTooHighError, LoanSlotExhaustedError, MARKET_EPOCH_BITS, MARKET_EPOCH_SHIFT, MARKET_INDICATOR_PERIODS, MAX_TICK, MAX_TRACKED_CHUNKS, MINT_BUFFER, MINT_BUFFER_DENOMINATOR, MIN_TICK, MaxRetriesExceededError, MissingPositionIdsError, NO_LOWER_LIQUIDATION_TICK, NO_UPPER_LIQUIDATION_TICK, NetLiquidityZeroError, NetworkMismatchError, NoLegsExercisableError, NotALongLegError, NotBuilderError, NotEnoughLiquidityInChunkError, NotEnoughTokensError, NotGuardianError, NotMarginCalledError, NotPanopticPoolError, ORACLE_EPOCH_SECONDS, OracleRateLimitedError, PanopticError, PanopticHelperNotDeployedError, PanopticValidationError, PoolNotInitializedError, PositionCountNotZeroError, PositionNotOwnedError, PositionSnapshotNotFoundError, PositionTooLargeError, PriceBoundFailError, PriceImpactTooLargeError, ProviderLagError, RATE_AT_TARGET_BITS, REORG_DEPTH, REQUIRED_BASE_ERROR_SENTINEL, ReentrancyError, RpcError, RpcResponseError, SCHEMA_VERSION, SECONDS_PER_YEAR, STANDARD_TICK_WIDTHS, STORAGE_PREFIX, STRIKE_LADDER_TARGET_STRIKES, SafeModeError, StaleDataError, StaleOracleError, SwapTokenMismatchError, SyncTimeoutError, TOKEN_ID_BITS, TokenIdHasZeroLegsError, TooManyLegsOpenError, TransferFailedError, UNREALIZED_INTEREST_BITS, UTILIZATION_DENOMINATOR, UnauthorizedUniswapCallbackError, UnderOverFlowError, UnhealthyPoolError, UnsafePremiumSettlementError, VARIANCE_RATIO_LAG, WAD, WrongPoolIdError, WrongUniswapPoolError, ZERO_COLLATERAL, ZERO_VALUATION, ZeroAddressError, ZeroCollateralRequirementError, addLegToTokenId, addPendingPosition, addTrackedChunks, annualizePerSecondRateWad, applyMintBuffer, applyMintBufferPerToken, apportion, approve, approveAndWait, approvePool, assertCanBurn, assertCanForceExercise, assertCanLiquidate, assertCanMint, assertFresh, assertHealthy, assertLpPositionFunded, assertTradeable, borrow, borrowAndWait, buildBatchDispatchArgs, buildCreditSwapCall, buildCreditWrappedDispatch, buildOpenPositionCalldata, buildProtectedSettleDispatch, buildProtectedSettlePlan, buildSettleSequenceCalls, buildSfpmSwapCalldata, buildSfpmSwapPlan, buildTemporaryLoanRecoveryDispatch, buildTokenShortfallRecoveryDispatch, buildUniqueCredit, buildUniqueLoan, buildUniqueWidthZeroLeg, calculateAccountGreeksPure, calculateMarketIndicator, calculatePortfolioDelta, calculatePortfolioGamma, calculatePortfolioGreeks, calculatePortfolioValue, calculatePositionDelta, calculatePositionDeltaDebtOnly, calculatePositionDeltaWithSwap, calculatePositionGamma, calculatePositionGreeks, calculatePositionValue, calculatePositionValues, 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, isCredit, isCreditLeg, isDefinedRisk, isGasError, isInputListFailError, isLiquidatable, isLoan, isLoanLeg, isNonceError, isPanopticErrorType, isPositionTracked, isRetryableRpcError, isShortOnly, isSpread, isSupportedChain, isolateGroupTokenId, jsonSerializer, ladderStrikeSequence, liquidate, liquidateAndWait, loadCheckpoint, logReturns, marketPnlInQuote, marketRiskFromValues, marketScenario, minePoolAddress, mint, mintAndWait, mintableAfterBuffer, multicallRead, netLiquidationValueInQuote, openPosition, openPositionAndWait, optimizeTokenIdRiskPartners, oracleEpochAt, orderListForSettle, packMarketState, panopticLiquidatorAbi, panopticPoolV2Abi, panopticQueryAbi, parseBps, parseCollateralLog, parsePanopticError, parsePoolLog, parseTokenAmount, parseTokenListId, parseWad, planDeriveStrategy, pokeOracle, pokeOracleAndWait, positionValueKey, positionValueTicks, prepareIndicatorCandles, preparePositionValue, preparePositionValueCurve, previewBorrow, previewDeposit, previewMint, previewRedeem, previewUnwrap, previewWithdraw, previewWrap, priceToTick, publicBroadcaster, 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, utilizationBpsToWad, utilizationPctToWad, validateBatch, validateBuilderCode, validatePoolId, verifyBlockContinuity, watchEvents, wethWrapAbi, withdraw, withdrawAndWait, withdrawWithPositions, withdrawWithPositionsAndWait, wrapEth, wrapEthAndWait, wrapXstock, wrapXstockAndWait, xstockWrapperAbi };
|
|
32201
|
+
//#region src/panoptic/v2/reads/positionVolatilityHistory.ts
|
|
32202
|
+
const signedSlot = (value) => BigInt.asIntN(128, value);
|
|
32203
|
+
const unpack = (value) => ({
|
|
32204
|
+
token0: signedSlot(value),
|
|
32205
|
+
token1: signedSlot(value >> 128n)
|
|
32206
|
+
});
|
|
32207
|
+
/** RPC accounting for exactly one mint lifecycle; candle prices are supplied by the application. */
|
|
32208
|
+
async function getPositionVolatilityHistory({ client, poolAddress, account, tokenId, mintBlock, endBlock, poolConfig, includeBaseFees = false }) {
|
|
32209
|
+
if (mintBlock <= 0n || endBlock <= mintBlock) throw new RangeError("Insufficient lifecycle history");
|
|
32210
|
+
const [mints, burns] = await Promise.all([client.getContractEvents({
|
|
32211
|
+
address: poolAddress,
|
|
32212
|
+
abi: panopticPoolV2Abi,
|
|
32213
|
+
eventName: "OptionMinted",
|
|
32214
|
+
args: {
|
|
32215
|
+
recipient: account,
|
|
32216
|
+
tokenId
|
|
32217
|
+
},
|
|
32218
|
+
fromBlock: mintBlock,
|
|
32219
|
+
toBlock: mintBlock,
|
|
32220
|
+
strict: true
|
|
32221
|
+
}), client.getContractEvents({
|
|
32222
|
+
address: poolAddress,
|
|
32223
|
+
abi: panopticPoolV2Abi,
|
|
32224
|
+
eventName: "OptionBurnt",
|
|
32225
|
+
args: {
|
|
32226
|
+
recipient: account,
|
|
32227
|
+
tokenId
|
|
32228
|
+
},
|
|
32229
|
+
fromBlock: mintBlock,
|
|
32230
|
+
toBlock: endBlock,
|
|
32231
|
+
strict: true
|
|
32232
|
+
})]);
|
|
32233
|
+
const mint$1 = mints[0];
|
|
32234
|
+
if (mints.length !== 1 || !mint$1) throw new Error("Opening event is missing or ambiguous");
|
|
32235
|
+
const balance = decodePositionBalance$1(mint$1.args.balanceData);
|
|
32236
|
+
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];
|
|
32237
|
+
const finalBlock = close?.blockNumber ?? endBlock;
|
|
32238
|
+
if (finalBlock <= mintBlock) throw new Error("Intrablock lifecycle cannot be reconstructed");
|
|
32239
|
+
if (close && close.args.positionSize !== balance.positionSize) throw new Error("Position size changed");
|
|
32240
|
+
const [start, end, boundaryPrices] = await Promise.all([
|
|
32241
|
+
getBlockMeta({
|
|
32242
|
+
client,
|
|
32243
|
+
blockNumber: mintBlock
|
|
32244
|
+
}),
|
|
32245
|
+
getBlockMeta({
|
|
32246
|
+
client,
|
|
32247
|
+
blockNumber: finalBlock
|
|
32248
|
+
}),
|
|
32249
|
+
getPriceHistory({
|
|
32250
|
+
client,
|
|
32251
|
+
poolConfig,
|
|
32252
|
+
blockNumbers: [mintBlock, finalBlock]
|
|
32253
|
+
})
|
|
32254
|
+
]);
|
|
32255
|
+
const openingPrice = boundaryPrices.snapshots[0];
|
|
32256
|
+
const endingPrice = boundaryPrices.snapshots[1];
|
|
32257
|
+
if (!openingPrice || !endingPrice) throw new Error("Boundary prices unavailable");
|
|
32258
|
+
const pointCount = Math.min(200, Math.max(2, Number((end.blockTimestamp - start.blockTimestamp) / 900n) + 2));
|
|
32259
|
+
const blockNumbers = [...new Set(interpolateBlocks(mintBlock, finalBlock, pointCount))];
|
|
32260
|
+
const metadata = [];
|
|
32261
|
+
for (let i = 0; i < blockNumbers.length; i += 16) metadata.push(...await Promise.all(blockNumbers.slice(i, i + 16).map((blockNumber) => getBlockMeta({
|
|
32262
|
+
client,
|
|
32263
|
+
blockNumber
|
|
32264
|
+
}))));
|
|
32265
|
+
const timestamps = new Map(metadata.map((meta) => [meta.blockNumber, meta.blockTimestamp]));
|
|
32266
|
+
const chunks = preparePositionGamma({
|
|
32267
|
+
tokenId,
|
|
32268
|
+
positionSize: balance.positionSize,
|
|
32269
|
+
quoteIsToken0: false,
|
|
32270
|
+
quoteDecimals: 0
|
|
32271
|
+
}).chunks.filter((chunk) => chunk.liquidity > 0n);
|
|
32272
|
+
let premiumError = null;
|
|
32273
|
+
let feeError = includeBaseFees ? null : "Base fee history was not requested";
|
|
32274
|
+
let premium = null;
|
|
32275
|
+
let fees = null;
|
|
32276
|
+
try {
|
|
32277
|
+
const settlementLogs = await client.getContractEvents({
|
|
32278
|
+
address: poolAddress,
|
|
32279
|
+
abi: panopticPoolV2Abi,
|
|
32280
|
+
eventName: "PremiumSettled",
|
|
32281
|
+
args: {
|
|
32282
|
+
user: account,
|
|
32283
|
+
tokenId
|
|
32284
|
+
},
|
|
32285
|
+
fromBlock: mintBlock,
|
|
32286
|
+
toBlock: finalBlock,
|
|
32287
|
+
strict: true
|
|
32288
|
+
});
|
|
32289
|
+
const settled = [];
|
|
32290
|
+
const seen = new Set();
|
|
32291
|
+
for (const log of settlementLogs) {
|
|
32292
|
+
if (log.blockNumber === mintBlock && log.logIndex <= mint$1.logIndex) continue;
|
|
32293
|
+
if (close && log.blockNumber === finalBlock && log.logIndex >= close.logIndex) continue;
|
|
32294
|
+
const key = `${log.transactionHash}:${log.logIndex}`;
|
|
32295
|
+
if (seen.has(key)) continue;
|
|
32296
|
+
seen.add(key);
|
|
32297
|
+
const amounts = unpack(log.args.settledAmounts);
|
|
32298
|
+
settled.push({
|
|
32299
|
+
blockNumber: log.blockNumber,
|
|
32300
|
+
settled0: amounts.token0,
|
|
32301
|
+
settled1: amounts.token1
|
|
32302
|
+
});
|
|
32303
|
+
}
|
|
32304
|
+
if (close) {
|
|
32305
|
+
const receipt = await client.getTransactionReceipt({ hash: close.transactionHash });
|
|
32306
|
+
const liquidations = parseEventLogs({
|
|
32307
|
+
abi: panopticPoolV2Abi,
|
|
32308
|
+
logs: receipt.logs.filter((log) => log.address.toLowerCase() === poolAddress.toLowerCase()),
|
|
32309
|
+
eventName: "AccountLiquidated"
|
|
32310
|
+
});
|
|
32311
|
+
if (liquidations.some((event) => event.args.liquidatee.toLowerCase() === account.toLowerCase())) throw new Error("Liquidation premium requires haircut reconciliation");
|
|
32312
|
+
for (const packed of close.args.premiaByLeg) {
|
|
32313
|
+
const amounts = unpack(packed);
|
|
32314
|
+
settled.push({
|
|
32315
|
+
blockNumber: finalBlock,
|
|
32316
|
+
settled0: amounts.token0,
|
|
32317
|
+
settled1: amounts.token1
|
|
32318
|
+
});
|
|
32319
|
+
}
|
|
32320
|
+
}
|
|
32321
|
+
const readableBlocks = close ? blockNumbers.filter((block) => block < finalBlock) : blockNumbers;
|
|
32322
|
+
premium = [];
|
|
32323
|
+
for (let i = 0; i < readableBlocks.length; i += 16) {
|
|
32324
|
+
const history = await getStreamiaHistory({
|
|
32325
|
+
client,
|
|
32326
|
+
panopticPoolAddress: poolAddress,
|
|
32327
|
+
account,
|
|
32328
|
+
tokenId,
|
|
32329
|
+
blockNumbers: readableBlocks.slice(i, i + 16),
|
|
32330
|
+
legs: [],
|
|
32331
|
+
poolConfig,
|
|
32332
|
+
includeUniswapFees: false,
|
|
32333
|
+
settledEvents: settled,
|
|
32334
|
+
_meta: end
|
|
32335
|
+
});
|
|
32336
|
+
for (const snapshot of history.snapshots) {
|
|
32337
|
+
const timestamp = snapshot.blockNumber === void 0 ? void 0 : timestamps.get(snapshot.blockNumber);
|
|
32338
|
+
if (timestamp === void 0) throw new Error("Accounting timestamp missing");
|
|
32339
|
+
premium.push({
|
|
32340
|
+
timestamp,
|
|
32341
|
+
...snapshot.cumulativePanopticPremia
|
|
32342
|
+
});
|
|
32343
|
+
}
|
|
32344
|
+
}
|
|
32345
|
+
if (close) premium.push({
|
|
32346
|
+
timestamp: end.blockTimestamp,
|
|
32347
|
+
...settled.reduce((sum$1, event) => ({
|
|
32348
|
+
token0: sum$1.token0 + event.settled0,
|
|
32349
|
+
token1: sum$1.token1 + event.settled1
|
|
32350
|
+
}), {
|
|
32351
|
+
token0: 0n,
|
|
32352
|
+
token1: 0n
|
|
32353
|
+
})
|
|
32354
|
+
});
|
|
32355
|
+
const openingAccrual = premium[0];
|
|
32356
|
+
if (!openingAccrual || openingAccrual.timestamp !== start.blockTimestamp) throw new Error("Opening premium snapshot missing");
|
|
32357
|
+
premium = premium.map((snapshot) => ({
|
|
32358
|
+
timestamp: snapshot.timestamp,
|
|
32359
|
+
token0: snapshot.token0 - openingAccrual.token0,
|
|
32360
|
+
token1: snapshot.token1 - openingAccrual.token1
|
|
32361
|
+
}));
|
|
32362
|
+
} catch (error) {
|
|
32363
|
+
premium = null;
|
|
32364
|
+
premiumError = error instanceof Error ? error.message : "Premium history unavailable";
|
|
32365
|
+
}
|
|
32366
|
+
if (includeBaseFees) try {
|
|
32367
|
+
const feeBlocks = close ? blockNumbers.filter((block) => block < finalBlock) : blockNumbers;
|
|
32368
|
+
const data = [];
|
|
32369
|
+
for (let i = 0; i < feeBlocks.length; i += 16) data.push(...await fetchUniswapFeeData(client, feeBlocks.slice(i, i + 16), chunks, poolConfig));
|
|
32370
|
+
let total0 = 0n;
|
|
32371
|
+
let total1 = 0n;
|
|
32372
|
+
fees = [];
|
|
32373
|
+
for (let i = 0; i < data.length; i++) {
|
|
32374
|
+
const current = data[i];
|
|
32375
|
+
for (const chunk of chunks) {
|
|
32376
|
+
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");
|
|
32377
|
+
if (i === 0) continue;
|
|
32378
|
+
const previous = feeGrowthInsideX128(data[i - 1], chunk.lowerTick, chunk.upperTick);
|
|
32379
|
+
const next = feeGrowthInsideX128(current, chunk.lowerTick, chunk.upperTick);
|
|
32380
|
+
if (!previous || !next) throw new Error("Range fee growth missing");
|
|
32381
|
+
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");
|
|
32382
|
+
const sign = chunk.isLong ? -1n : 1n;
|
|
32383
|
+
total0 += sign * feesFromFeeGrowthDelta(next.feeGrowthInside0X128, previous.feeGrowthInside0X128, chunk.liquidity);
|
|
32384
|
+
total1 += sign * feesFromFeeGrowthDelta(next.feeGrowthInside1X128, previous.feeGrowthInside1X128, chunk.liquidity);
|
|
32385
|
+
}
|
|
32386
|
+
fees.push({
|
|
32387
|
+
timestamp: metadata[i].blockTimestamp,
|
|
32388
|
+
token0: total0,
|
|
32389
|
+
token1: total1
|
|
32390
|
+
});
|
|
32391
|
+
}
|
|
32392
|
+
} catch (error) {
|
|
32393
|
+
fees = null;
|
|
32394
|
+
feeError = error instanceof Error ? error.message : "Base fee history unavailable";
|
|
32395
|
+
}
|
|
32396
|
+
return {
|
|
32397
|
+
start,
|
|
32398
|
+
end,
|
|
32399
|
+
positionSize: balance.positionSize,
|
|
32400
|
+
closed: close !== void 0,
|
|
32401
|
+
openingTick: BigInt(openingPrice.tick),
|
|
32402
|
+
endingTick: BigInt(endingPrice.tick),
|
|
32403
|
+
premium,
|
|
32404
|
+
fees,
|
|
32405
|
+
premiumError,
|
|
32406
|
+
feeError,
|
|
32407
|
+
accountingSamples: blockNumbers.length,
|
|
32408
|
+
maxAccountingIntervalSeconds: metadata.slice(1).reduce((maximum, meta, index) => {
|
|
32409
|
+
const interval = meta.blockTimestamp - metadata[index].blockTimestamp;
|
|
32410
|
+
return interval > maximum ? interval : maximum;
|
|
32411
|
+
}, 0n)
|
|
32412
|
+
};
|
|
32413
|
+
}
|
|
32414
|
+
|
|
32415
|
+
//#endregion
|
|
32416
|
+
export { AccountInsolventError, AlreadyInitializedError, BORROW_INDEX_BITS, BPS_DENOMINATOR, BPS_SCALE, BatchValidationError, BelowMinimumRedemptionError, CastingError, ChunkHasZeroLiquidityError, ChunkLimitError, CrossPoolError, DEFAULT_MAX_SPREAD, DEFAULT_MINT_BUFFER, DEFAULT_MIN_SWAP_RATIO_BPS, DEFAULT_RECONNECT_CONFIG, DEFAULT_VEGOID, DepositTooLargeError, DuplicateTokenIdError, EffectiveLiquidityAboveThresholdError, ExceedsMaximumRedemptionError, InputListFailError, InsufficientCreditLiquidityError, InvalidBuilderCodeError, InvalidHistoryRangeError, InvalidTickBoundError, InvalidTickError, InvalidTokenIdParameterError, InvalidUniswapCallbackError, LEG_BITS, LEG_LIMITS, LEG_MASKS, LengthMismatchError, LiquidityTooHighError, LoanSlotExhaustedError, MARKET_EPOCH_BITS, MARKET_EPOCH_SHIFT, MARKET_INDICATOR_PERIODS, MAX_TICK, MAX_TRACKED_CHUNKS, MINT_BUFFER, MINT_BUFFER_DENOMINATOR, MIN_TICK, MaxRetriesExceededError, MissingPositionIdsError, NO_LOWER_LIQUIDATION_TICK, NO_UPPER_LIQUIDATION_TICK, NetLiquidityZeroError, NetworkMismatchError, NoLegsExercisableError, NotALongLegError, NotBuilderError, NotEnoughLiquidityInChunkError, NotEnoughTokensError, NotGuardianError, NotMarginCalledError, NotPanopticPoolError, ORACLE_EPOCH_SECONDS, OracleRateLimitedError, PanopticError, PanopticHelperNotDeployedError, PanopticValidationError, PoolNotInitializedError, PositionCountNotZeroError, PositionNotOwnedError, PositionSnapshotNotFoundError, PositionTooLargeError, PriceBoundFailError, PriceImpactTooLargeError, ProviderLagError, RATE_AT_TARGET_BITS, REORG_DEPTH, REQUIRED_BASE_ERROR_SENTINEL, ReentrancyError, RpcError, RpcResponseError, SCHEMA_VERSION, SECONDS_PER_YEAR, STANDARD_TICK_WIDTHS, STORAGE_PREFIX, STRIKE_LADDER_TARGET_STRIKES, SafeModeError, StaleDataError, StaleOracleError, SwapTokenMismatchError, SyncTimeoutError, TOKEN_ID_BITS, TokenIdHasZeroLegsError, TooManyLegsOpenError, TransferFailedError, UNREALIZED_INTEREST_BITS, UTILIZATION_DENOMINATOR, UnauthorizedUniswapCallbackError, UnderOverFlowError, UnhealthyPoolError, UnsafePremiumSettlementError, VARIANCE_RATIO_LAG, WAD, WrongPoolIdError, WrongUniswapPoolError, ZERO_COLLATERAL, ZERO_VALUATION, ZeroAddressError, ZeroCollateralRequirementError, addLegToTokenId, addPendingPosition, addTrackedChunks, annualizePerSecondRateWad, applyMintBuffer, applyMintBufferPerToken, apportion, approve, approveAndWait, approvePool, assertCanBurn, assertCanForceExercise, assertCanLiquidate, assertCanMint, assertFresh, assertHealthy, assertLpPositionFunded, assertTradeable, borrow, borrowAndWait, buildBatchDispatchArgs, buildCreditSwapCall, buildCreditWrappedDispatch, buildOpenPositionCalldata, buildProtectedSettleDispatch, buildProtectedSettlePlan, buildSettleSequenceCalls, buildSfpmSwapCalldata, buildSfpmSwapPlan, buildTemporaryLoanRecoveryDispatch, buildTokenShortfallRecoveryDispatch, buildUniqueCredit, buildUniqueLoan, buildUniqueWidthZeroLeg, calculateAccountGreeksPure, calculateMarketIndicator, calculatePortfolioDelta, calculatePortfolioGamma, calculatePortfolioGreeks, calculatePortfolioValue, calculatePositionDelta, calculatePositionDeltaDebtOnly, calculatePositionDeltaWithSwap, calculatePositionGamma, calculatePositionGreeks, calculatePositionValue, calculatePositionValues, calculatePositionVolatilityMetrics, calculateResyncBlock, calculateSpreadWad, calculateVarianceProfile, cancelTransaction, checkApproval, checkCollateralAcrossTicks, classifyStrategyGroups, classifyStrike, cleanupStalePendingPositions, clearCheckpoint, clearPendingPositions, clearTrackedChunks, clearTrackedPositions, clearTradeHistory, closePosition, closePositionAndWait, collateralCurveTicks, collateralRuleKindFor, collateralTrackerV2Abi, computeV4PoolId, confirmPendingPosition, convertToAssets, convertToShares, countLegs, createEventPoller, createEventSubscription, createFileStorage, createFlowNeutralTokenId, createMemoryStorage, createNonceManager, createPoolFormatters, createTokenIdBuilder, decodeAllDispatchCalldata, decodeAllLegs, decodeDispatchCalldata, decodeLeftRightSigned, decodeLeftRightUnsigned, decodeLeg, decodeOraclePack, decodeOracleRiskParameters, decodeOracleTiming, decodePanopticTokenURI, decodePoolId, decodeTickSpacing, decodeTokenId, decodeVegoid, deployNewPool, deployNewPoolAndWait, deposit, depositAndWait, deriveSupplyRatePerSecWad, deriveUniqueTokenId, detectReorg, diagnoseOracleSafeMode, dispatch, dispatchAndWait, emptyLiquidateParams, encodeLeg, encodePoolId, encodePoolKeyBytes, encodeV3PoolKeyBytes, encodeV4PoolId, ensureSfpmV3PoolInitialized, estimateBlockNumbers, 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, isCredit, isCreditLeg, isDefinedRisk, isGasError, isInputListFailError, isLiquidatable, isLoan, isLoanLeg, isNonceError, isPanopticErrorType, isPositionTracked, isRetryableRpcError, isShortOnly, isSpread, isSupportedChain, isolateGroupTokenId, jsonSerializer, ladderStrikeSequence, liquidate, liquidateAndWait, loadCheckpoint, logReturns, marketPnlInQuote, marketRiskFromValues, marketScenario, minePoolAddress, mint, mintAndWait, mintableAfterBuffer, multicallRead, netLiquidationValueInQuote, openPosition, openPositionAndWait, optimizeTokenIdRiskPartners, oracleEpochAt, orderListForSettle, packMarketState, panopticLiquidatorAbi, panopticPoolV2Abi, panopticQueryAbi, parseBps, parseCollateralLog, parsePanopticError, parsePoolLog, parseTokenAmount, parseTokenListId, parseWad, planDeriveStrategy, pokeOracle, pokeOracleAndWait, positionValueKey, positionValueTicks, prepareIndicatorCandles, preparePositionGamma, preparePositionValue, preparePositionValueCurve, previewBorrow, previewDeposit, previewMint, previewRedeem, previewRepay, previewUnwrap, previewWithdraw, previewWrap, priceToTick, publicBroadcaster, 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, utilizationBpsToWad, utilizationPctToWad, validateBatch, validateBuilderCode, validatePoolId, valuePositionAccrual, verifyBlockContinuity, watchEvents, wethWrapAbi, withdraw, withdrawAndWait, withdrawWithPositions, withdrawWithPositionsAndWait, wrapEth, wrapEthAndWait, wrapXstock, wrapXstockAndWait, xstockWrapperAbi };
|
|
31866
32417
|
//# sourceMappingURL=index.js.map
|