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