@panoptic-eng/sdk 1.0.72 → 1.0.74

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.
@@ -1,11 +1,11 @@
1
- import { UniswapV3PoolAbi, applyOwedInterest, getAccountBuyingPower, getAccountCollateral, getNetLiquidationValue, panopticQueryAbi$1 as panopticQueryAbi, readBlockAndAggregate, requireReturnData } from "./irm-BI9so_9s.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, riskEngineMulticall, semiFungiblePositionManagerV3Abi, semiFungiblePositionManagerV4Abi, stateViewAbi, uniswapV3PoolAbi } from "./rates-BOGkyjVy.js";
1
+ import { UniswapV3PoolAbi, applyOwedInterest, getAccountBuyingPower, getAccountCollateral, getNetLiquidationValue, panopticQueryAbi, readBlockAndAggregate, requireReturnData } from "./irm-BwOG1LRv.js";
2
+ import { AccountInsolventError, ChunkLimitError, DEFAULT_VEGOID, InvalidHistoryRangeError, MulticallResultMissingError, NotEnoughTokensError, PanopticError, PanopticValidationError, SafeModeError, StaleDataError, StorageDataNotFoundError, UnhealthyPoolError, WrongUniswapPoolError, addLegToTokenId, applyMintBufferPerToken, availableToBorrow, collateralTrackerV2Abi, countLegs, decodeAllLegs, decodeLeftRightSigned, decodeLeftRightUnsigned, decodePositionBalance, decodeTokenId, getBlockMeta, getClosedPositionsKey, getPendingPositionsKey, getPool, getPoolMetaKey, getPoolMetadata, getPositionMetaKey, getPositionsKey, getTrackedChunksKey, getTrackedPositionIds, isPanopticErrorType, jsonSerializer, mintableAfterBuffer, panopticFactoryV3Abi, panopticFactoryV4Abi, panopticGuardianAbi, panopticLiquidatorAbi, panopticPoolV2Abi, panopticQueryAbi$1, parsePanopticError, riskEngineAbi, riskEngineMulticall, semiFungiblePositionManagerV3Abi, semiFungiblePositionManagerV4Abi, stateViewAbi, uniswapV3PoolAbi } from "./rates-B9HaWnEM.js";
3
3
  import { MAX_TICK, MAX_TRACKED_CHUNKS, MIN_TICK, NO_LOWER_LIQUIDATION_TICK, NO_UPPER_LIQUIDATION_TICK, WAD, calculatePositionDelta, calculatePositionDeltaDebtOnly, calculatePositionGamma, calculatePositionValue, getLegLiquidityRange, priceToTick, sqrtPriceX96ToTick, tickLimits, tickToPriceDecimalScaled, tickToSqrtPriceX96, toVaultFrameAtTick } from "./greeks-CEv-Uex1.js";
4
- import { addLegToTokenId, buildBatchDispatchArgs, buildProtectedSettlePlan, buildSettleSequenceCalls, buildUniqueCredit, buildUniqueLoan, countLegs, createTokenIdBuilder, decodeAllLegs, decodeTokenId, getCurrentPositionSizes, getPoolTokensForSimulation, loadCheckpoint, resolveTokenIndex, simulateDispatch, simulateOpenPosition, simulateWithTokenFlow } from "./writes-BNNd0vjF.js";
5
- import { feesFromFeeGrowthDelta, getLpPositionFunding, getMaxLpPositionSize, getPriceHistory, preparePositionGamma, quoteSwapExactOutViaRouter, quoteSwapExactOutViaV3Router } from "./router-CL6snZVH.js";
6
- import { ContractFunctionExecutionError, decodeFunctionResult, encodeAbiParameters, encodeFunctionData, getAddress, hexToString, isAddress, isAddressEqual, isHex, keccak256, parseAbi, parseEventLogs, trim, zeroAddress } from "viem";
7
- import { multicall } from "viem/actions";
4
+ import { buildBatchDispatchArgs, buildProtectedSettlePlan, buildSettleSequenceCalls, buildUniqueCredit, buildUniqueLoan, createTokenIdBuilder, ensureUniqueTokenId, getCurrentPositionSizes, getPoolTokensForSimulation, loadCheckpoint, resolveTokenIndex, simulateDispatch, simulateOpenPosition, simulateWithTokenFlow } from "./writes-CeRXSZwj.js";
5
+ import { feesFromFeeGrowthDelta, getLpPositionFunding, getMaxLpPositionSize, getPriceHistory, preparePositionGamma, quoteSwapExactOutViaRouter, quoteSwapExactOutViaV3Router } from "./router-KwjvMN_z.js";
6
+ import { ContractFunctionExecutionError, decodeFunctionResult, encodeAbiParameters, encodeFunctionData, getAddress, hexToString, isAddress, isAddressEqual, isHex, keccak256, parseEventLogs, trim, zeroAddress } from "viem";
8
7
  import Decimal from "decimal.js";
8
+ import { multicall } from "viem/actions";
9
9
 
10
10
  //#region src/panoptic/v2/clients/blocksByTimestamp.ts
11
11
  /**
@@ -1464,10 +1464,10 @@ async function getChunkLiquidities(params) {
1464
1464
  */
1465
1465
  async function getFactoryTokenURI(params) {
1466
1466
  const { client, factoryAddress, version, tokenId } = params;
1467
- const abi$1 = version === "v3" ? panopticFactoryV3Abi : panopticFactoryV4Abi;
1467
+ const abi = version === "v3" ? panopticFactoryV3Abi : panopticFactoryV4Abi;
1468
1468
  return client.readContract({
1469
1469
  address: factoryAddress,
1470
- abi: abi$1,
1470
+ abi,
1471
1471
  functionName: "tokenURI",
1472
1472
  args: [tokenId]
1473
1473
  });
@@ -1477,10 +1477,10 @@ async function getFactoryTokenURI(params) {
1477
1477
  */
1478
1478
  async function getFactoryOwnerOf(params) {
1479
1479
  const { client, factoryAddress, version, tokenId } = params;
1480
- const abi$1 = version === "v3" ? panopticFactoryV3Abi : panopticFactoryV4Abi;
1480
+ const abi = version === "v3" ? panopticFactoryV3Abi : panopticFactoryV4Abi;
1481
1481
  return client.readContract({
1482
1482
  address: factoryAddress,
1483
- abi: abi$1,
1483
+ abi,
1484
1484
  functionName: "ownerOf",
1485
1485
  args: [tokenId]
1486
1486
  });
@@ -1490,10 +1490,10 @@ async function getFactoryOwnerOf(params) {
1490
1490
  */
1491
1491
  async function getFactoryConstructMetadata(params) {
1492
1492
  const { client, factoryAddress, version, panopticPoolAddress, symbol0, symbol1, fee } = params;
1493
- const abi$1 = version === "v3" ? panopticFactoryV3Abi : panopticFactoryV4Abi;
1493
+ const abi = version === "v3" ? panopticFactoryV3Abi : panopticFactoryV4Abi;
1494
1494
  return client.readContract({
1495
1495
  address: factoryAddress,
1496
- abi: abi$1,
1496
+ abi,
1497
1497
  functionName: "constructMetadata",
1498
1498
  args: [
1499
1499
  panopticPoolAddress,
@@ -2416,14 +2416,21 @@ function assembleNeutralTokenId(poolId, baseTokenId, neutralLegs, prepend) {
2416
2416
  * is unavailable, or a neutralizing strike falls outside the valid tick range.
2417
2417
  */
2418
2418
  async function createFlowNeutralTokenId(params) {
2419
- const { client, poolAddress, account, tokenId, positionSize, existingPositionIds, swapAtMint = true, referenceSize, queryAddress, blockNumber } = params;
2419
+ const { client, poolAddress, account, tokenId: requestedTokenId, positionSize, existingPositionIds, swapAtMint = true, referenceSize, queryAddress, blockNumber } = params;
2420
2420
  if (positionSize <= 0n) throw new PanopticError("positionSize must be positive to create flow-neutral position");
2421
2421
  const measureSize = referenceSize !== void 0 && referenceSize > 0n && referenceSize < positionSize ? referenceSize : positionSize;
2422
- const legCount = countLegs(tokenId);
2422
+ const legCount = countLegs(requestedTokenId);
2423
2423
  if (legCount >= 4n) throw new PanopticError("Cannot append neutralizing leg: tokenId already has 4 legs");
2424
- const poolId = tokenId & POOL_ID_MASK$1;
2425
- const baseLegs = decodeAllLegs(tokenId);
2424
+ const poolId = requestedTokenId & POOL_ID_MASK$1;
2425
+ const ensureUnmintedOrThrow = (candidate) => {
2426
+ const unique = ensureUniqueTokenId(candidate, existingPositionIds ?? [], measureSize);
2427
+ if (unique === void 0) throw new PanopticError("Cannot create flow-neutral position: this position is already held");
2428
+ return unique;
2429
+ };
2430
+ const tokenId = ensureUnmintedOrThrow(requestedTokenId);
2431
+ const baseLegs = decodeAllLegs(requestedTokenId);
2426
2432
  const prependNeutral = baseLegs.length === 1 && baseLegs[0].tokenType === baseLegs[0].asset;
2433
+ const assembleUnique = (neutralLegs$1) => ensureUnmintedOrThrow(assembleNeutralTokenId(poolId, requestedTokenId, neutralLegs$1, prependNeutral));
2427
2434
  let credit;
2428
2435
  try {
2429
2436
  credit = await getRequiredCreditForITM({
@@ -2483,7 +2490,7 @@ async function createFlowNeutralTokenId(params) {
2483
2490
  const activeIndices = [0n, 1n].filter((index) => targets[Number(index)] !== 0n);
2484
2491
  if (legCount + BigInt(activeIndices.length) > 4n) throw new PanopticError(`Cannot add ${activeIndices.length} neutralizing leg(s): tokenId would exceed 4 legs`);
2485
2492
  const neutralLegs$1 = activeIndices.map((index) => buildNeutralLeg(index, targets[Number(index)], measureSize));
2486
- const combined$1 = assembleNeutralTokenId(poolId, tokenId, neutralLegs$1, prependNeutral);
2493
+ const combined$1 = assembleUnique(neutralLegs$1);
2487
2494
  if (combined$1 === previousTokenId) break;
2488
2495
  previousTokenId = combined$1;
2489
2496
  let residual$1;
@@ -2587,7 +2594,7 @@ async function createFlowNeutralTokenId(params) {
2587
2594
  const indices = swapAtMint ? [valueAbs(0n, credit.creditAmount0) >= valueAbs(1n, credit.creditAmount1) ? 0n : 1n] : [0n, 1n].filter((i) => valueAbs(i, flowFor(i)) > FLOW_NEUTRAL_DUST_THRESHOLD);
2588
2595
  if (legCount + BigInt(indices.length) > 4n) throw new PanopticError(`Cannot add ${indices.length} neutralizing leg(s): tokenId would exceed 4 legs`);
2589
2596
  const neutralLegs = indices.map((i) => buildNeutralLeg(i, flowFor(i), measureSize));
2590
- const combined = assembleNeutralTokenId(poolId, tokenId, neutralLegs, prependNeutral);
2597
+ const combined = assembleUnique(neutralLegs);
2591
2598
  const pinnedBlock = blockNumber ?? credit._meta.blockNumber;
2592
2599
  let residual;
2593
2600
  try {
@@ -10303,84 +10310,6 @@ async function getCollateralCurve({ client, poolAddress, account, queryAddress,
10303
10310
  };
10304
10311
  }
10305
10312
 
10306
- //#endregion
10307
- //#region src/panoptic/v2/reads/positionValueCurve.ts
10308
- const abi = parseAbi(["function computeNetLiquidationValue(uint256[] positionIdList, uint256 shortPremium, uint256 longPremium, uint256[] positionBalanceArray, int24[] atTicks) pure returns (int256[] value0, int256[] value1)"]);
10309
- /** Stable identity for a position-dependent curve; streamia and spot are separate inputs. */
10310
- function positionValueKey(positions) {
10311
- return [...positions].sort((a, b) => a.tokenId < b.tokenId ? -1 : a.tokenId > b.tokenId ? 1 : 0).map(({ tokenId, positionSize }) => `${tokenId}:${positionSize}`).join(",");
10312
- }
10313
- /** All changes in the curve's active liquidity, independent of the current market tick. */
10314
- function positionValueTicks(positions) {
10315
- const ticks = new Set([-887272n, 887272n]);
10316
- for (const { tokenId, positionSize } of positions) {
10317
- if (tokenId < 0n || tokenId >= 1n << 256n || positionSize <= 0n || positionSize >= 1n << 128n) throw new RangeError("Invalid position id or size");
10318
- const { legs, tickSpacing } = decodeTokenId(tokenId);
10319
- for (const leg of legs) {
10320
- if (leg.width === 0n) continue;
10321
- const width = leg.width * tickSpacing;
10322
- const lower = leg.strike - width / 2n;
10323
- const upper = leg.strike + (width + 1n) / 2n;
10324
- if (lower < -887272n || upper > 887272n || lower >= upper) throw new RangeError("Invalid position range");
10325
- ticks.add(lower);
10326
- ticks.add(upper);
10327
- }
10328
- }
10329
- return [...ticks].sort((a, b) => a < b ? -1 : a > b ? 1 : 0);
10330
- }
10331
- /** Read the immutable, premium-free part of NLV from the deployed pure calculation. */
10332
- async function getPositionValueCurve({ client, queryAddress, positions }) {
10333
- const ticks = positionValueTicks(positions);
10334
- const [values0, values1] = await client.readContract({
10335
- address: queryAddress,
10336
- abi,
10337
- functionName: "computeNetLiquidationValue",
10338
- args: [
10339
- positions.map((p) => p.tokenId),
10340
- 0n,
10341
- 0n,
10342
- positions.map((p) => p.positionSize),
10343
- ticks.map(Number)
10344
- ]
10345
- });
10346
- return ticks.map((tick, i) => ({
10347
- tick,
10348
- value0: values0[i],
10349
- value1: values1[i]
10350
- }));
10351
- }
10352
- /**
10353
- * Between leg boundaries, token0 is affine in inverse sqrt price and token1 in sqrt price.
10354
- * Endpoint interpolation differs from contract integer rounding by at most a few wei per leg.
10355
- */
10356
- function preparePositionValueCurve(curve) {
10357
- if (curve.length < 2) throw new RangeError("Incomplete position value curve");
10358
- for (let i = 0; i < curve.length; i++) if (curve[i].tick < -887272n || curve[i].tick > 887272n || i > 0 && curve[i].tick <= curve[i - 1].tick) throw new RangeError("Invalid position value curve ticks");
10359
- const points = curve.map((point) => ({
10360
- ...point,
10361
- sqrt: tickToSqrtPriceX96(point.tick)
10362
- }));
10363
- return (tick) => {
10364
- if (tick < points[0].tick || tick > points[points.length - 1].tick) throw new RangeError("Tick outside position value curve");
10365
- let lo = 0;
10366
- let hi = points.length - 1;
10367
- while (hi - lo > 1) {
10368
- const mid = Math.floor((lo + hi) / 2);
10369
- if (points[mid].tick <= tick) lo = mid;
10370
- else hi = mid;
10371
- }
10372
- const left = points[lo];
10373
- const right = points[hi];
10374
- const sqrt = tickToSqrtPriceX96(tick);
10375
- const numerator = sqrt - left.sqrt;
10376
- const denominator = right.sqrt - left.sqrt;
10377
- return {
10378
- value0: left.value0 + (right.value0 - left.value0) * numerator * right.sqrt / (denominator * sqrt),
10379
- value1: left.value1 + (right.value1 - left.value1) * numerator / denominator
10380
- };
10381
- };
10382
- }
10383
-
10384
10313
  //#endregion
10385
10314
  //#region src/panoptic/v2/reads/positionVolatilityHistory.ts
10386
10315
  const signedSlot = (value) => BigInt.asIntN(128, value);
@@ -10597,4 +10526,4 @@ async function getPositionVolatilityHistory({ client, poolAddress, account, toke
10597
10526
  }
10598
10527
 
10599
10528
  //#endregion
10600
- 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, estimateCloseZapSwap, estimateCollateralBreakdown, estimateCollateralRequired, failPendingPosition, feeGrowthInsideX128, fetchPoolSwaps, fetchSfpmV3PoolId, fetchUniswapFeeData, getAccountGreeks, getAccountHistory, getChunkLiquidities, getChunkSpreads, getClosePositionTransferEstimate, 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, getPoolLiquidities, getPortfolioValue, getPositionChunkData, getPositionEnrichmentData, getPositionMintFunding, getPositionValueCurve, getPositionVolatilityHistory, getRealizedPnL, getRequiredCreditForITM, getSafeMode, getStreamiaHistory, getSyncStatus, getTrackedChunks, getTradeHistory, getUniswapFeeHistory, getUniswapV3PoolFromId, getUniswapV3PoolInfo, getUniswapV3PoolLiquidities, getUniswapV4PoolBasicState, getUniswapV4PoolInfo, getUniswapV4PoolKeyFromId, getUniswapV4PoolLiquidities, interpolateBlocks, isGasError, isNonceError, isRetryableRpcError, isolateGroupTokenId, ladderStrikeSequence, logReturns, marketPnlInQuote, marketRiskFromValues, marketScenario, minePoolAddress, minePoolAddressLocalAsync, multicallRead, netLiquidationValueInQuote, optimizeTokenIdRiskPartners, parseCollateralLog, parsePoolLog, parseStreamedKey, parseStreamedSwap, parseSwapLog, positionValueKey, positionValueTicks, prepareIndicatorCandles, preparePositionValueCurve, previewDeposit, previewMint, previewRedeem, previewWithdraw, quoteLiquidation, quoteOneTokenFlow, quoteSfpmSwap, quoteTemporaryLoanRecovery, quoteTokenShortfallRecovery, quoteTokenShortfallSwap, realizedBeta, removeTrackedChunks, resolveBlockNumbers, resolveLadderStrike, resolvePanopticPoolFromPoolId, resolveUniswapV4PoolKey, saveClosedPosition, scaleCollateralRequired, scanChunks, screenAccountExact, simulateBatchDispatch, simulateClosePosition, simulateClosePremiumProtection, simulateDeployNewPool, simulateDeposit, simulateForceExercise, simulateLiquidate, simulateSFPMBurn, simulateSFPMMint, simulateSwapExactIn, simulateSwapExactOut, simulateWithdraw, slippageBpsToTickDistance, streamPoolSwaps, subscribePoolSwaps, watchEvents, watchPoolSwaps };
10529
+ 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, estimateCloseZapSwap, estimateCollateralBreakdown, estimateCollateralRequired, failPendingPosition, feeGrowthInsideX128, fetchPoolSwaps, fetchSfpmV3PoolId, fetchUniswapFeeData, getAccountGreeks, getAccountHistory, getChunkLiquidities, getChunkSpreads, getClosePositionTransferEstimate, 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, getPoolLiquidities, getPortfolioValue, getPositionChunkData, getPositionEnrichmentData, getPositionMintFunding, getPositionVolatilityHistory, getRealizedPnL, getRequiredCreditForITM, getSafeMode, getStreamiaHistory, getSyncStatus, getTrackedChunks, getTradeHistory, getUniswapFeeHistory, getUniswapV3PoolFromId, getUniswapV3PoolInfo, getUniswapV3PoolLiquidities, getUniswapV4PoolBasicState, getUniswapV4PoolInfo, getUniswapV4PoolKeyFromId, getUniswapV4PoolLiquidities, interpolateBlocks, isGasError, isNonceError, isRetryableRpcError, isolateGroupTokenId, ladderStrikeSequence, logReturns, marketPnlInQuote, marketRiskFromValues, marketScenario, minePoolAddress, minePoolAddressLocalAsync, multicallRead, netLiquidationValueInQuote, optimizeTokenIdRiskPartners, parseCollateralLog, parsePoolLog, parseStreamedKey, parseStreamedSwap, parseSwapLog, prepareIndicatorCandles, previewDeposit, previewMint, previewRedeem, previewWithdraw, quoteLiquidation, quoteOneTokenFlow, quoteSfpmSwap, quoteTemporaryLoanRecovery, quoteTokenShortfallRecovery, quoteTokenShortfallSwap, realizedBeta, removeTrackedChunks, resolveBlockNumbers, resolveLadderStrike, resolvePanopticPoolFromPoolId, resolveUniswapV4PoolKey, saveClosedPosition, scaleCollateralRequired, scanChunks, screenAccountExact, simulateBatchDispatch, simulateClosePosition, simulateClosePremiumProtection, simulateDeployNewPool, simulateDeposit, simulateForceExercise, simulateLiquidate, simulateSFPMBurn, simulateSFPMMint, simulateSwapExactIn, simulateSwapExactOut, simulateWithdraw, slippageBpsToTickDistance, streamPoolSwaps, subscribePoolSwaps, watchEvents, watchPoolSwaps };
@@ -420,37 +420,37 @@ const robinhoodUsdgVault = robinhoodDeployment.hypovault.vaults.usdgPlpVault;
420
420
  if (robinhoodUsdgVault === void 0) throw new Error("Missing Robinhood USDG PLP vault address");
421
421
  const VAULT_DISPLAY_NAMES_PER_CHAIN = {
422
422
  [MAINNET_CHAIN_ID]: {
423
- [mainnetVaults.wethPlpVault.toLowerCase()]: "PLP Vault",
424
- [mainnetVaults.usdcPlpVault.toLowerCase()]: "Unicorn Vault",
425
- [legacyMainnetVaults.wethPlpVault.toLowerCase()]: "PLP Vault",
426
- [legacyMainnetVaults.usdcPlpVault.toLowerCase()]: "Unicorn Vault"
423
+ [mainnetVaults.wethPlpVault.toLowerCase()]: "ETH Yield Vault",
424
+ [mainnetVaults.usdcPlpVault.toLowerCase()]: "volUSDC Vault",
425
+ [legacyMainnetVaults.wethPlpVault.toLowerCase()]: "ETH Yield Vault",
426
+ [legacyMainnetVaults.usdcPlpVault.toLowerCase()]: "volUSDC Vault"
427
427
  },
428
428
  [BASE_CHAIN_ID]: {
429
- [baseVaults.wethPlpVault.toLowerCase()]: "PLP Vault",
430
- [baseVaults.usdcPlpVault.toLowerCase()]: "Unicorn Vault"
429
+ [baseVaults.wethPlpVault.toLowerCase()]: "ETH Yield Vault",
430
+ [baseVaults.usdcPlpVault.toLowerCase()]: "volUSDC Vault"
431
431
  },
432
432
  [SEPOLIA_CHAIN_ID]: {
433
- [sepoliaVaults.wethPlpVault.toLowerCase()]: "PLP Vault",
434
- [sepoliaVaults.usdcPlpVault.toLowerCase()]: "Unicorn Vault"
433
+ [sepoliaVaults.wethPlpVault.toLowerCase()]: "ETH Yield Vault",
434
+ [sepoliaVaults.usdcPlpVault.toLowerCase()]: "volUSDC Vault"
435
435
  },
436
- [ROBINHOOD_CHAIN_ID]: { [robinhoodUsdgVault.toLowerCase()]: "0DTE +67∆ Vault" }
436
+ [ROBINHOOD_CHAIN_ID]: { [robinhoodUsdgVault.toLowerCase()]: "0DTE +67∆ Covered Call Vault" }
437
437
  };
438
438
  const VAULT_DISPLAY_NAME_RESOLVERS_PER_CHAIN = {
439
439
  [MAINNET_CHAIN_ID]: {
440
- [mainnetVaults.wethPlpVault.toLowerCase()]: () => "PLP Vault",
441
- [mainnetVaults.usdcPlpVault.toLowerCase()]: () => "Unicorn Vault",
442
- [legacyMainnetVaults.wethPlpVault.toLowerCase()]: () => "PLP Vault",
443
- [legacyMainnetVaults.usdcPlpVault.toLowerCase()]: () => "Unicorn Vault"
440
+ [mainnetVaults.wethPlpVault.toLowerCase()]: () => "ETH Yield Vault",
441
+ [mainnetVaults.usdcPlpVault.toLowerCase()]: () => "volUSDC Vault",
442
+ [legacyMainnetVaults.wethPlpVault.toLowerCase()]: () => "ETH Yield Vault",
443
+ [legacyMainnetVaults.usdcPlpVault.toLowerCase()]: () => "volUSDC Vault"
444
444
  },
445
445
  [BASE_CHAIN_ID]: {
446
- [baseVaults.wethPlpVault.toLowerCase()]: () => "PLP Vault",
447
- [baseVaults.usdcPlpVault.toLowerCase()]: () => "Unicorn Vault"
446
+ [baseVaults.wethPlpVault.toLowerCase()]: () => "ETH Yield Vault",
447
+ [baseVaults.usdcPlpVault.toLowerCase()]: () => "volUSDC Vault"
448
448
  },
449
449
  [SEPOLIA_CHAIN_ID]: {
450
- [sepoliaVaults.wethPlpVault.toLowerCase()]: () => "PLP Vault",
451
- [sepoliaVaults.usdcPlpVault.toLowerCase()]: () => "Unicorn Vault"
450
+ [sepoliaVaults.wethPlpVault.toLowerCase()]: () => "ETH Yield Vault",
451
+ [sepoliaVaults.usdcPlpVault.toLowerCase()]: () => "volUSDC Vault"
452
452
  },
453
- [ROBINHOOD_CHAIN_ID]: { [robinhoodUsdgVault.toLowerCase()]: () => "0DTE +67∆ Vault" }
453
+ [ROBINHOOD_CHAIN_ID]: { [robinhoodUsdgVault.toLowerCase()]: () => "0DTE +67∆ Covered Call Vault" }
454
454
  };
455
455
 
456
456
  //#endregion
@@ -1 +1 @@
1
- {"version":3,"file":"vault-transaction-fees.js","names":["chainDeploymentsData","value: bigint","numerator: bigint","denominator: bigint","values: readonly bigint[]","chainId: number | undefined","priorityFee: bigint","quote: VaultTransactionFeeQuote","gasLimit: bigint","gasEstimate: bigint","feeCaps: VaultSignedTransactionFeeCaps","quote?: VaultTransactionFeeQuote","feeHistoryError: unknown","client: Client<Transport, chain>"],"sources":["../../deployments/src/chainDeployments.data.json","../../deployments/src/chainDeployments.js","../../deployments/src/vaultDisplayNames.js","../src/hypoVault/transactionFees.ts"],"sourcesContent":["{\n \"1\": {\n \"chainId\": 1,\n \"infrastructure\": {\n \"uniswapV3Factory\": \"0x1F98431c8aD98523631AE4a59f267346ea31F984\",\n \"poolManager\": \"0x000000000004444c5dc75cB358380D2e3dE08A90\",\n \"stateView\": \"0x7ffe42c4a5deea5b0fec41c94c136cf115597227\"\n },\n \"hypovault\": {\n \"core\": {\n \"hypoVaultImplementation\": \"0xF16714665955DBd0361D997eFc50fe391D96E8D0\",\n \"factory\": \"0xd5049B2647de57141dE7F65E5124707B99A452A3\",\n \"accountant\": \"0x65aA902AE3135658587FFC36ED51B61c927114e1\",\n \"rolesAuthority\": \"0xb952D345c413Ddb7850173422bAe4968e0330598\",\n \"collateralTrackerDecoderAndSanitizer\": \"0xC87c45d2dbE5acb56013e2591427ECC84Fa251E6\"\n },\n \"vaults\": {\n \"wethPlpVault\": \"0xd4e2c720a760049cc4151bcf61e3a9348db9cd92\",\n \"usdcPlpVault\": \"0x236d0558f06cd60780b232d4Ec4c92d2cb7e4D18\"\n },\n \"managers\": {\n \"wethPlpVaultManager\": \"0xB6Fc48e658C9B1a7dbdFA51A5E153ab60BB2e04d\",\n \"usdcPlpVaultManager\": \"0x2ce65016366ef7320078e0758D58Cf1038bc7C4e\"\n },\n \"turnkeySigners\": {\n \"wethPlpVaultManager\": \"0x8FfA6DAB99f8afc64F61BeF83F0966eD6362f24F\",\n \"usdcPlpVaultManager\": \"0x3c1c79d0cfc316Ba959194c89696a8382d7d283b\"\n }\n },\n \"panoptic\": {\n \"pool\": {\n \"version\": \"v4\",\n \"panopticPool\": \"0x00000000563b70d704f4c6675a5f6ac989fbae13\",\n \"collateralTracker0\": \"0x1e46b0289B7E0F710E2Db8Ab87800dd782D624f7\",\n \"collateralTracker1\": \"0x12bF31955522BAC337D93e1bC0a39F68D8BDa216\"\n },\n \"additionalPools\": {\n \"ethUsdc5bpsV3\": {\n \"version\": \"v3\",\n \"panopticPool\": \"0x00000000009C7B687e833559e34503f64d7ed7c4\",\n \"collateralTracker0\": \"0x3CCdA7d5E841d6543D90BcEc20b36a724C184DE9\",\n \"collateralTracker1\": \"0x69E9f9e44E5F52237493b980dd7306198C64A4E4\"\n },\n \"ethUsdc5bpsV3Replacement\": {\n \"version\": \"v3\",\n \"panopticPool\": \"0x00000000000E98f6c5aE16835bAdF2f7cC0d49D7\",\n \"collateralTracker0\": \"0x3E24E4Ab1e097F35C910eb9242a8C1530ee9C482\",\n \"collateralTracker1\": \"0xE1e01ac7E6b2671b82Aea4Db812a5c444523a039\",\n \"riskEngine\": \"0x000000000000ffE5eFdB5AE76b9200263C58b4c0\",\n \"deploymentBlock\": \"26173664\"\n }\n },\n \"v2\": {\n \"semiFungiblePositionManagerV4\": \"0x00000000000005C3287f136Ef5AF56c68Ea6849f\",\n \"semiFungiblePositionManagerV3\": \"0x00000000000005E4693aDc8Ec0f12D686f728198\",\n \"builderFactory\": \"0x0000000000000a3D22E158417AA639D7F71b0FF7\",\n \"riskEngine\": \"0x000000000000ffE5eFdB5AE76b9200263C58b4c0\",\n \"panopticPoolImplementation\": \"0x000000000000135429F0DaCaB61639Bf6a63EbbC\",\n \"collateralTrackerImplementation\": \"0x0000000000001d9c38CA405A2e04420865A08A33\",\n \"panopticFactoryV4\": \"0x0000000000000c51d0f8cf4bd9adE7191372a625\",\n \"panopticFactoryV3\": \"0x0000000000000aDC9A108591e718F2aee963a2a7\",\n \"panopticHelper\": \"0x0000000000000000000000000000000000000000\",\n \"panopticMath\": \"0x000000000000334bbd65C195581cf59ECf315932\",\n \"panopticQuery\": \"0x0000000000000e1aE9c66C1c3B0A547D23389C93\",\n \"interactionHelper\": \"0x00000000000041fe14Ce3c2392337CE501aE8328\"\n }\n },\n \"riskEngines\": [\n \"0x000000000000ffE5eFdB5AE76b9200263C58b4c0\",\n \"0x000000000000FfADa7c641E2aD6B13b51b50Cc94\"\n ],\n \"markets\": {\n \"ethUsdc30bps\": {\n \"currency0\": \"0x0000000000000000000000000000000000000000\",\n \"currency1\": \"0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48\",\n \"fee\": 3000,\n \"tickSpacing\": 60,\n \"poolId\": \"0x3C08AE4977F78D\"\n }\n },\n \"subgraphs\": {\n \"hypovault\": \"https://api.goldsky.com/api/public/project_cl9gc21q105380hxuh8ks53k3/subgraphs/hypovault-subgraph-mainnet/prod/gn\",\n \"panoptic\": \"https://api.goldsky.com/api/public/project_cl9gc21q105380hxuh8ks53k3/subgraphs/panoptic-subgraph-mainnet/v2_prod/gn\"\n },\n \"sfpmSwap\": {\n \"version\": \"v3\",\n \"sfpm\": \"0x00000000000005E4693aDc8Ec0f12D686f728198\",\n \"poolAddress\": \"0x88e6A0c2dDD26FEEb64F039a2c41296FcB3f5640\",\n \"poolId\": \"2824133844976349\",\n \"fee\": 500,\n \"weth\": \"0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2\"\n },\n \"deprecatedRiskEngines\": [\n \"0x0000000000000e673aECBDB5f5fE5DFAf4a8e9Ac\",\n \"0x0000000000000E65545005B26207D7edFd031260\",\n \"0x000000000000075e29cdaa9cb640a69e148ca7da\",\n \"0x0000000000000fe1e261f66ce2f44def4f5ae0cb\"\n ]\n },\n \"4663\": {\n \"chainId\": 4663,\n \"infrastructure\": {\n \"uniswapV3Factory\": \"0x1f7d7550b1b028f7571e69a784071f0205fd2efa\",\n \"poolManager\": \"0x8366a39cc670b4001a1121b8f6a443a643e40951\",\n \"stateView\": \"0xf3334192d15450cdd385c8b70e03f9a6bd9e673b\"\n },\n \"hypovault\": {\n \"core\": {\n \"hypoVaultImplementation\": \"0xF16714665955DBd0361D997eFc50fe391D96E8D0\",\n \"factory\": \"0xd5049B2647de57141dE7F65E5124707B99A452A3\",\n \"accountant\": \"0x9e345d862c41010F87D8E5A279e8D320D2831D36\",\n \"rolesAuthority\": \"0xb952D345c413Ddb7850173422bAe4968e0330598\",\n \"collateralTrackerDecoderAndSanitizer\": \"0xC87c45d2dbE5acb56013e2591427ECC84Fa251E6\"\n },\n \"vaults\": {\n \"wethPlpVault\": \"0x0000000000000000000000000000000000000000\",\n \"usdcPlpVault\": \"0x0000000000000000000000000000000000000000\",\n \"usdgPlpVault\": \"0x08B24123252Bd9c4DD473b6573D4cF67196FFC4B\"\n },\n \"managers\": {\n \"wethPlpVaultManager\": \"0x0000000000000000000000000000000000000000\",\n \"usdcPlpVaultManager\": \"0x0000000000000000000000000000000000000000\",\n \"usdgPlpVaultManager\": \"0x67Edb096585efe88a9A1ee16c5857AB74Fc8EA87\"\n },\n \"turnkeySigners\": {\n \"wethPlpVaultManager\": \"0x0000000000000000000000000000000000000000\",\n \"usdcPlpVaultManager\": \"0x0000000000000000000000000000000000000000\",\n \"usdgPlpVaultManager\": \"0x8FfA6DAB99f8afc64F61BeF83F0966eD6362f24F\"\n }\n },\n \"panoptic\": {\n \"pool\": {\n \"version\": \"v4\",\n \"panopticPool\": \"0x000000000c21b38c54AcA7c7145Df01ff09d69Bb\",\n \"collateralTracker0\": \"0xDc508622CD7e3850c8240e88c10361Cf493465b6\",\n \"collateralTracker1\": \"0x9212d804953bAf89C24ceFa6545aA293bA08a876\"\n },\n \"additionalPools\": {\n \"spyUsdg30bpsV4\": {\n \"version\": \"v4\",\n \"panopticPool\": \"0x00000000989bcb6f24af4a1Ab2A6d6a31c98A58E\",\n \"collateralTracker0\": \"0x49eaAC32A7CD4B8fB2209a12859a95E0b20aB0e5\",\n \"collateralTracker1\": \"0x670C44a0FC35dbC410498e47A6290a1C3196d191\"\n },\n \"spyUsdg5bpsV4\": {\n \"version\": \"v4\",\n \"panopticPool\": \"0x000000000c21b38c54AcA7c7145Df01ff09d69Bb\",\n \"collateralTracker0\": \"0xDc508622CD7e3850c8240e88c10361Cf493465b6\",\n \"collateralTracker1\": \"0x9212d804953bAf89C24ceFa6545aA293bA08a876\"\n },\n \"spyUsdg5bpsV4Replacement\": {\n \"version\": \"v4\",\n \"panopticPool\": \"0x000000000056475506823b2BedBD89f55232DA40\",\n \"collateralTracker0\": \"0xAd345C2088BF0B6140aa78ABB7fE8336e328686a\",\n \"collateralTracker1\": \"0xC9c3802aF99A6E9B9c3E7F5F8c5093e048Fac1Ca\",\n \"riskEngine\": \"0x000000000000FfADa7c641E2aD6B13b51b50Cc94\",\n \"deploymentBlock\": \"86379946\"\n }\n },\n \"v2\": {\n \"semiFungiblePositionManagerV4\": \"0x00000000000005C3287f136Ef5AF56c68Ea6849f\",\n \"semiFungiblePositionManagerV3\": \"0x00000000000005E4693aDc8Ec0f12D686f728198\",\n \"builderFactory\": \"0x0000000000000a3D22E158417AA639D7F71b0FF7\",\n \"riskEngine\": \"0x000000000000FfADa7c641E2aD6B13b51b50Cc94\",\n \"panopticPoolImplementation\": \"0x000000000000135429F0DaCaB61639Bf6a63EbbC\",\n \"collateralTrackerImplementation\": \"0x0000000000001d9c38CA405A2e04420865A08A33\",\n \"panopticFactoryV4\": \"0x0000000000000c51d0f8cf4bd9adE7191372a625\",\n \"panopticFactoryV3\": \"0x0000000000000aDC9A108591e718F2aee963a2a7\",\n \"panopticHelper\": \"0x0000000000000000000000000000000000000000\",\n \"panopticMath\": \"0x000000000000334bbd65C195581cf59ECf315932\",\n \"panopticQuery\": \"0x0000000000000e1aE9c66C1c3B0A547D23389C93\",\n \"interactionHelper\": \"0x00000000000041fe14Ce3c2392337CE501aE8328\"\n }\n },\n \"riskEngines\": [\n \"0x000000000000ffE5eFdB5AE76b9200263C58b4c0\",\n \"0x000000000000FfADa7c641E2aD6B13b51b50Cc94\"\n ],\n \"markets\": {\n \"spyUsdg\": {\n \"currency0\": \"0x117cc2133c37B721F49dE2A7a74833232B3B4C0C\",\n \"currency1\": \"0x5fc5360D0400a0Fd4f2af552ADD042D716F1d168\",\n \"fee\": 500,\n \"tickSpacing\": 5,\n \"poolId\": \"0xe5923c8a8be481ec89a2ca784a2bbfa4235de6d88f92260fd66b660c4babf907\"\n },\n \"spyUsdg30bps\": {\n \"currency0\": \"0x117cc2133c37B721F49dE2A7a74833232B3B4C0C\",\n \"currency1\": \"0x5fc5360D0400a0Fd4f2af552ADD042D716F1d168\",\n \"fee\": 3000,\n \"tickSpacing\": 60,\n \"poolId\": \"0xfe2a80bb5618fd14984b92ca6d45bf5ba67443ddb1435e28b2e48df2fc1526cd\"\n },\n \"spyUsdg5bps\": {\n \"currency0\": \"0x117cc2133c37B721F49dE2A7a74833232B3B4C0C\",\n \"currency1\": \"0x5fc5360D0400a0Fd4f2af552ADD042D716F1d168\",\n \"fee\": 500,\n \"tickSpacing\": 5,\n \"poolId\": \"0xe5923c8a8be481ec89a2ca784a2bbfa4235de6d88f92260fd66b660c4babf907\"\n }\n },\n \"subgraphs\": {\n \"hypovault\": \"https://api.goldsky.com/api/public/project_cl9gc21q105380hxuh8ks53k3/subgraphs/hypovault-subgraph-robinhood/prod/gn\",\n \"panoptic\": \"https://api.goldsky.com/api/public/project_cl9gc21q105380hxuh8ks53k3/subgraphs/panoptic-subgraph-robinhood/v2_prod/gn\"\n },\n \"deprecatedRiskEngines\": [\n \"0x0000000000000E65545005B26207D7edFd031260\",\n \"0x000000000000075e29cdaa9cb640a69e148ca7da\",\n \"0x0000000000000fe1e261f66ce2f44def4f5ae0cb\",\n \"0x0000000000000f3fb82469581A74776178E76Ca4\"\n ]\n },\n \"8453\": {\n \"chainId\": 8453,\n \"infrastructure\": {\n \"uniswapV3Factory\": \"0x33128a8fC17869897dcE68Ed026d694621f6FDfD\",\n \"poolManager\": \"0x498581fF718922c3f8e6A244956aF099B2652b2b\",\n \"stateView\": \"0xA3c0c9b65baD0b08107Aa264b0f3dB444b867A71\"\n },\n \"hypovault\": {\n \"core\": {\n \"hypoVaultImplementation\": \"0xec311aE06486ad44Ba782133b502A34aCE0f479E\",\n \"factory\": \"0x9bE53b169a41030f1710A9B82e9eA6413f14D12E\",\n \"accountant\": \"0x345cA3407942f9d175c9eA8B90e83A36F570f852\",\n \"rolesAuthority\": \"0x278D37CaBFFB4B72D2866E30fEFE08aef773E0B6\",\n \"collateralTrackerDecoderAndSanitizer\": \"0x4A290b3EC46cF320421Bb2aaee96d445de31CF0b\"\n },\n \"vaults\": {\n \"wethPlpVault\": \"0x41b7D0515d709A4Fd2CF27f9d141D0c2F8713D04\",\n \"usdcPlpVault\": \"0xb452af299c565D04B05E601efF2840e000C922f1\"\n },\n \"managers\": {\n \"wethPlpVaultManager\": \"0x2a4923456c79E9ebD10F5Bf5305a5C742bBc1D7C\",\n \"usdcPlpVaultManager\": \"0xdd6E2406a044582463CFE9F0C774870eAf4A310B\"\n },\n \"turnkeySigners\": {\n \"wethPlpVaultManager\": \"0x8FfA6DAB99f8afc64F61BeF83F0966eD6362f24F\",\n \"usdcPlpVaultManager\": \"0x3c1c79d0cfc316Ba959194c89696a8382d7d283b\"\n }\n },\n \"panoptic\": {\n \"pool\": {\n \"version\": \"v4\",\n \"panopticPool\": \"0xB50e8bb68f5855DA742f4579274902a20454174a\",\n \"collateralTracker0\": \"0x0d82b189c96EbB1f44A7207e6A9cfB1e490f2869\",\n \"collateralTracker1\": \"0x9ba1082Ab3cb9edEA988697A14BBe543A3dABEd2\"\n },\n \"v2\": {\n \"semiFungiblePositionManagerV4\": \"0x8dcAa08cF298F8b4830FAf56d47930981AdE33af\",\n \"semiFungiblePositionManagerV3\": \"0xFB1c06B491305d618bb8a7a368C6e50c001C153A\",\n \"builderFactory\": \"0x6d26E916a18d522f7DdA2a26d9E1645564ccDcA5\",\n \"riskEngine\": \"0x8bbce8b1eb64118cfe6c1eab0afe13b80ea41481\",\n \"panopticPoolImplementation\": \"0x5BA68a018fF149c38ec52D181Dd24aBabE9a07DB\",\n \"collateralTrackerImplementation\": \"0x34B3a4e4F14f292575ECe3EF67886C4598af459f\",\n \"panopticFactoryV4\": \"0x9ac0317fcd124aff0b5429beb8de17020bc45f9a\",\n \"panopticFactoryV3\": \"0x687f616d68c483a7223e6922f59aef7452e26c1d\",\n \"panopticHelper\": \"0x0000000000000000000000000000000000000000\",\n \"panopticMath\": \"0x6d21699192f5aF112C87e53b32ff846782afF407\",\n \"panopticQuery\": \"0xd2586E1bbdd1169F597F3A370117EdF7372A7350\",\n \"interactionHelper\": \"0x643d8DD5372FD6c71f8fAbCce4Eb8857704F3E15\"\n }\n },\n \"riskEngines\": [\n \"0x8bbce8b1eb64118cfe6c1eab0afe13b80ea41481\"\n ],\n \"markets\": {\n \"ethUsdc5bps\": {\n \"currency0\": \"0x0000000000000000000000000000000000000000\",\n \"currency1\": \"0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913\",\n \"fee\": 500,\n \"tickSpacing\": 10,\n \"poolId\": \"0x96d4b53a38337a5733179751781178a2613306063c511b78cd02684739288c0a\"\n }\n },\n \"subgraphs\": {\n \"hypovault\": \"https://api.goldsky.com/api/public/project_cl9gc21q105380hxuh8ks53k3/subgraphs/hypovault-subgraph-base/prod/gn\",\n \"panoptic\": \"https://api.goldsky.com/api/public/project_cl9gc21q105380hxuh8ks53k3/subgraphs/panoptic-subgraph-base/v2_prod/gn\"\n }\n },\n \"11155111\": {\n \"chainId\": 11155111,\n \"infrastructure\": {\n \"uniswapV3Factory\": \"0x0227628f3F023bb0B980b67D528571c95c6DaC1c\",\n \"poolManager\": \"0xE03A1074c86CFeDd5C142C4F04F1a1536e203543\",\n \"stateView\": \"0xE1Dd9c3fA50EDB962E442f60DfBc432e24537E4C\"\n },\n \"hypovault\": {\n \"core\": {\n \"hypoVaultImplementation\": \"0xC5b415Db4087228Af817893769DC3a205160160B\",\n \"factory\": \"0x363a9d605ca45cBfF3b597350DeADb53cdC292c7\",\n \"accountant\": \"0x25BBef1DF262c24aa1AACD1F7eCeEcc1a7AD08ab\",\n \"rolesAuthority\": \"0x673BfafB4e2712215B422347c1571421B83E8A3d\",\n \"collateralTrackerDecoderAndSanitizer\": \"0xb899BE50BAF25BBB3A3ca3403256B3c703E5AB5d\"\n },\n \"vaults\": {\n \"wethPlpVault\": \"0xD58C4F9AEe5bBfcf28dC9a8d3D57b323fA6521b1\",\n \"usdcPlpVault\": \"0xdd7a8d6c6975488e801129bC84302d74e2361208\"\n },\n \"managers\": {\n \"wethPlpVaultManager\": \"0x95eC124FAAB70D7aE147c3BE0336E01a828AE2d5\",\n \"usdcPlpVaultManager\": \"0xFB5aa3e0b46F3859D90B14b52ffd287013b5Ec53\"\n },\n \"turnkeySigners\": {\n \"wethPlpVaultManager\": \"0x8FfA6DAB99f8afc64F61BeF83F0966eD6362f24F\",\n \"usdcPlpVaultManager\": \"0x3c1c79d0cfc316Ba959194c89696a8382d7d283b\"\n }\n },\n \"panoptic\": {\n \"pool\": {\n \"version\": \"v4\",\n \"panopticPool\": \"0x872b98C46b2062F663BEb2CC9D4cE046Da2a2918\",\n \"collateralTracker0\": \"0x09a60b78d06a03e5148faedd3bfee6f58b22012f\",\n \"collateralTracker1\": \"0x7365664c8101ff7e9422ae2b203822253c31e69c\"\n },\n \"v2\": {\n \"semiFungiblePositionManagerV3\": \"0x9DaD2C40107Db4B29a5450401BB7A28e6eA00e43\",\n \"semiFungiblePositionManagerV4\": \"0xD2615995A71644E122cC2FD7FeC2392b971220DE\",\n \"builderFactory\": \"0x55f3D2d9D065AA5Fcc11D94c55a6085849e8b6C3\",\n \"riskEngine\": \"0x1376aF5ca426B6B9fad6a712c21f6Cf58a94b93c\",\n \"panopticPoolImplementation\": \"0x969235B5830f13b58BB699305d9c70A8Cd3BD97C\",\n \"collateralTrackerImplementation\": \"0xafcd5F651Ae0403Ff668bb2dAc38BEa907a35Dba\",\n \"panopticFactoryV3\": \"0xd9FFCa53C0A6155001Ce8cbcAEfe89DB204690F1\",\n \"panopticFactoryV4\": \"0x8FCBb59b05779818D9BAD2686cc44B705603ce03\",\n \"panopticHelper\": \"0xfFEbB3A4ab793cB244209d4dA0Cb3e6B07133bd0\",\n \"panopticMath\": \"0x6d21699192f5aF112C87e53b32ff846782afF407\",\n \"panopticQuery\": \"0x74057945467Fb4eAE9193B46A60ae66a53f06A5b\",\n \"interactionHelper\": \"0x643d8DD5372FD6c71f8fAbCce4Eb8857704F3E15\"\n }\n },\n \"riskEngines\": [\n \"0x1376aF5ca426B6B9fad6a712c21f6Cf58a94b93c\"\n ],\n \"markets\": {\n \"ethUsdc5bps\": {\n \"currency0\": \"0x0000000000000000000000000000000000000000\",\n \"currency1\": \"0xFFFeD8254566B7F800f6D8CDb843ec75AE49B07A\",\n \"fee\": 500,\n \"tickSpacing\": 10,\n \"poolId\": \"0xba6673bcb27568a73a93dd23b20c8174fa16193cd90905be859144e8f13097a5\"\n }\n },\n \"subgraphs\": {\n \"hypovault\": \"https://api.goldsky.com/api/public/project_cl9gc21q105380hxuh8ks53k3/subgraphs/hypovault-subgraph-sepolia/prod/gn\",\n \"panoptic\": \"https://api.goldsky.com/api/public/project_cl9gc21q105380hxuh8ks53k3/subgraphs/panoptic-subgraph-sepolia/v2_prod/gn\"\n }\n }\n}\n","import chainDeploymentsData from './chainDeployments.data.json' with { type: 'json' }\n\nexport const MAINNET_CHAIN_ID = 1\nexport const SEPOLIA_CHAIN_ID = 11155111\nexport const BASE_CHAIN_ID = 8453\nexport const ROBINHOOD_CHAIN_ID = 4663\n\nexport const CHAIN_DEPLOYMENTS = chainDeploymentsData\n\nexport function getChainDeployment(chainId) {\n return CHAIN_DEPLOYMENTS[chainId]\n}\n\nexport function requireChainDeployment(chainId) {\n const deployment = getChainDeployment(chainId)\n if (deployment === undefined) {\n throw new Error(`Unsupported chain deployment for chainId ${chainId}`)\n }\n return deployment\n}\n\nexport function isSupportedChain(chainId) {\n return getChainDeployment(chainId) !== undefined\n}\n\nexport function getEthUsdcMarket(deployment) {\n const market = deployment.markets.ethUsdc5bps ?? deployment.markets.ethUsdc30bps\n if (market === undefined) {\n throw new Error(`Missing ETH/USDC market for chainId ${deployment.chainId}`)\n }\n return market\n}\n\nexport function getSpyUsdgMarket(deployment) {\n const market = deployment.markets.spyUsdg\n if (market === undefined) {\n throw new Error(`Missing SPY/USDG market for chainId ${deployment.chainId}`)\n }\n return market\n}\n\nfunction requireDeploymentValue(value, label) {\n if (value === undefined) {\n throw new Error(`Missing deployment value: ${label}`)\n }\n return value\n}\n\nexport const MAINNET_DEPLOYMENT = CHAIN_DEPLOYMENTS[MAINNET_CHAIN_ID]\nexport const MAINNET_ETH_USDC_5BPS_V3_PANOPTIC_POOL_ADDRESSES =\n MAINNET_DEPLOYMENT.panoptic.additionalPools?.ethUsdc5bpsV3\nexport const MAINNET_PANOPTIC_V2_ADDRESSES = MAINNET_DEPLOYMENT.panoptic.v2\nexport const SEPOLIA_DEPLOYMENT = CHAIN_DEPLOYMENTS[SEPOLIA_CHAIN_ID]\nexport const SEPOLIA_HYPOVAULT_CORE_ADDRESSES = SEPOLIA_DEPLOYMENT.hypovault.core\nexport const SEPOLIA_HYPOVAULT_ADDRESSES = SEPOLIA_DEPLOYMENT.hypovault.vaults\nexport const SEPOLIA_HYPOVAULT_MANAGER_ADDRESSES = SEPOLIA_DEPLOYMENT.hypovault.managers\nexport const SEPOLIA_HYPOVAULT_MANAGER_TURNKEY_SIGNERS = SEPOLIA_DEPLOYMENT.hypovault.turnkeySigners\nexport const SEPOLIA_PANOPTIC_POOL_ADDRESSES = SEPOLIA_DEPLOYMENT.panoptic.pool\nexport const SEPOLIA_PANOPTIC_V2_ADDRESSES = SEPOLIA_DEPLOYMENT.panoptic.v2\nexport const BASE_DEPLOYMENT = CHAIN_DEPLOYMENTS[BASE_CHAIN_ID]\nexport const BASE_HYPOVAULT_CORE_ADDRESSES = BASE_DEPLOYMENT.hypovault.core\nexport const BASE_HYPOVAULT_ADDRESSES = BASE_DEPLOYMENT.hypovault.vaults\nexport const BASE_HYPOVAULT_MANAGER_ADDRESSES = BASE_DEPLOYMENT.hypovault.managers\nexport const BASE_HYPOVAULT_MANAGER_TURNKEY_SIGNERS = BASE_DEPLOYMENT.hypovault.turnkeySigners\nexport const BASE_PANOPTIC_POOL_ADDRESSES = BASE_DEPLOYMENT.panoptic.pool\nexport const BASE_PANOPTIC_V2_ADDRESSES = BASE_DEPLOYMENT.panoptic.v2\nexport const BASE_ETH_USDC_5BPS_MARKET = getEthUsdcMarket(BASE_DEPLOYMENT)\nexport const SEPOLIA_ETH_USDC_5BPS_MARKET = getEthUsdcMarket(SEPOLIA_DEPLOYMENT)\n\nexport const MAINNET_RISK_ENGINES = MAINNET_DEPLOYMENT.riskEngines\nexport const BASE_RISK_ENGINES = BASE_DEPLOYMENT.riskEngines\nexport const SEPOLIA_RISK_ENGINES = SEPOLIA_DEPLOYMENT.riskEngines\n\nexport const ROBINHOOD_DEPLOYMENT = CHAIN_DEPLOYMENTS[ROBINHOOD_CHAIN_ID]\nexport const ROBINHOOD_HYPOVAULT_CORE_ADDRESSES = ROBINHOOD_DEPLOYMENT.hypovault.core\nexport const ROBINHOOD_HYPOVAULT_ADDRESSES = ROBINHOOD_DEPLOYMENT.hypovault.vaults\nexport const ROBINHOOD_HYPOVAULT_MANAGER_ADDRESSES = ROBINHOOD_DEPLOYMENT.hypovault.managers\nexport const ROBINHOOD_HYPOVAULT_MANAGER_TURNKEY_SIGNERS =\n ROBINHOOD_DEPLOYMENT.hypovault.turnkeySigners\nexport const ROBINHOOD_PANOPTIC_POOL_ADDRESSES = ROBINHOOD_DEPLOYMENT.panoptic.pool\nexport const ROBINHOOD_SPY_USDG_30BPS_PANOPTIC_POOL_ADDRESSES = requireDeploymentValue(\n ROBINHOOD_DEPLOYMENT.panoptic.additionalPools?.spyUsdg30bpsV4,\n 'Robinhood SPY/USDG 30bps Panoptic pool',\n)\nexport const ROBINHOOD_SPY_USDG_5BPS_PANOPTIC_POOL_ADDRESSES = requireDeploymentValue(\n ROBINHOOD_DEPLOYMENT.panoptic.additionalPools?.spyUsdg5bpsV4,\n 'Robinhood SPY/USDG 5bps Panoptic pool',\n)\nexport const ROBINHOOD_PANOPTIC_V2_ADDRESSES = ROBINHOOD_DEPLOYMENT.panoptic.v2\nexport const ROBINHOOD_RISK_ENGINES = ROBINHOOD_DEPLOYMENT.riskEngines\nexport const ROBINHOOD_SPY_USDG_MARKET = getSpyUsdgMarket(ROBINHOOD_DEPLOYMENT)\nexport const ROBINHOOD_SPY_USDG_30BPS_MARKET = requireDeploymentValue(\n ROBINHOOD_DEPLOYMENT.markets.spyUsdg30bps,\n 'Robinhood SPY/USDG 30bps market',\n)\nexport const ROBINHOOD_SPY_USDG_5BPS_MARKET = requireDeploymentValue(\n ROBINHOOD_DEPLOYMENT.markets.spyUsdg5bps,\n 'Robinhood SPY/USDG 5bps market',\n)\n","import {\n BASE_CHAIN_ID,\n MAINNET_CHAIN_ID,\n requireChainDeployment,\n ROBINHOOD_CHAIN_ID,\n SEPOLIA_CHAIN_ID,\n} from './chainDeployments.js'\n\nconst mainnetDeployment = requireChainDeployment(MAINNET_CHAIN_ID)\nconst mainnetVaults = mainnetDeployment.hypovault.vaults\nconst legacyMainnetVaults = {\n wethPlpVault: '0x779a2aa634A004b3a3f3b322083744869BBC6D66',\n usdcPlpVault: '0x963Fe9c93bc353602656ee4051A75114bA74d6c5',\n}\nconst sepoliaDeployment = requireChainDeployment(SEPOLIA_CHAIN_ID)\nconst sepoliaVaults = sepoliaDeployment.hypovault.vaults\nconst baseDeployment = requireChainDeployment(BASE_CHAIN_ID)\nconst baseVaults = baseDeployment.hypovault.vaults\nconst robinhoodDeployment = requireChainDeployment(ROBINHOOD_CHAIN_ID)\nconst robinhoodUsdgVault = robinhoodDeployment.hypovault.vaults.usdgPlpVault\n\nif (robinhoodUsdgVault === undefined) {\n throw new Error('Missing Robinhood USDG PLP vault address')\n}\n\nexport const VAULT_DISPLAY_NAMES_PER_CHAIN = {\n [MAINNET_CHAIN_ID]: {\n [mainnetVaults.wethPlpVault.toLowerCase()]: 'PLP Vault',\n [mainnetVaults.usdcPlpVault.toLowerCase()]: 'Unicorn Vault',\n [legacyMainnetVaults.wethPlpVault.toLowerCase()]: 'PLP Vault',\n [legacyMainnetVaults.usdcPlpVault.toLowerCase()]: 'Unicorn Vault',\n },\n [BASE_CHAIN_ID]: {\n [baseVaults.wethPlpVault.toLowerCase()]: 'PLP Vault',\n [baseVaults.usdcPlpVault.toLowerCase()]: 'Unicorn Vault',\n },\n [SEPOLIA_CHAIN_ID]: {\n [sepoliaVaults.wethPlpVault.toLowerCase()]: 'PLP Vault',\n [sepoliaVaults.usdcPlpVault.toLowerCase()]: 'Unicorn Vault',\n },\n [ROBINHOOD_CHAIN_ID]: {\n [robinhoodUsdgVault.toLowerCase()]: '0DTE +67∆ Vault',\n },\n}\n\nexport const VAULT_DISPLAY_NAME_RESOLVERS_PER_CHAIN = {\n [MAINNET_CHAIN_ID]: {\n [mainnetVaults.wethPlpVault.toLowerCase()]: () => 'PLP Vault',\n [mainnetVaults.usdcPlpVault.toLowerCase()]: () => 'Unicorn Vault',\n [legacyMainnetVaults.wethPlpVault.toLowerCase()]: () => 'PLP Vault',\n [legacyMainnetVaults.usdcPlpVault.toLowerCase()]: () => 'Unicorn Vault',\n },\n [BASE_CHAIN_ID]: {\n [baseVaults.wethPlpVault.toLowerCase()]: () => 'PLP Vault',\n [baseVaults.usdcPlpVault.toLowerCase()]: () => 'Unicorn Vault',\n },\n [SEPOLIA_CHAIN_ID]: {\n [sepoliaVaults.wethPlpVault.toLowerCase()]: () => 'PLP Vault',\n [sepoliaVaults.usdcPlpVault.toLowerCase()]: () => 'Unicorn Vault',\n },\n [ROBINHOOD_CHAIN_ID]: {\n [robinhoodUsdgVault.toLowerCase()]: () => '0DTE +67∆ Vault',\n },\n}\n\nexport function resolveVaultDisplayName({ chainId, vaultAddress, underlyingSymbol, fallbackName }) {\n const vaultAddressLower = vaultAddress.toLowerCase()\n const resolver = VAULT_DISPLAY_NAME_RESOLVERS_PER_CHAIN[chainId]?.[vaultAddressLower]\n if (resolver !== undefined) {\n return resolver({\n chainId,\n vaultAddress: vaultAddressLower,\n underlyingSymbol,\n fallbackName,\n })\n }\n\n const staticName = VAULT_DISPLAY_NAMES_PER_CHAIN[chainId]?.[vaultAddressLower]\n if (staticName !== undefined) {\n return staticName\n }\n\n if (fallbackName !== undefined && fallbackName !== null) {\n return fallbackName\n }\n\n return 'Vault'\n}\n","import type { Chain, Client, Transport } from 'viem'\nimport { hexToBigInt } from 'viem'\nimport { estimateFeesPerGas, getBlock, getFeeHistory } from 'viem/actions'\n\nimport { ROBINHOOD_CHAIN_ID } from './chainDeployments'\n\nexport const MIN_VAULT_PRIORITY_FEE_PER_GAS = 100_000_000n // 0.1 gwei\nexport const MAX_VAULT_PRIORITY_FEE_PER_GAS = 3_000_000_000n // 3 gwei\nexport const MAX_STALE_DELTA_HEDGE_PRIORITY_FEE_PER_GAS = 8_000_000_000n // 8 gwei\nexport const MAX_VAULT_TRANSACTION_GAS_COST = 15_000_000_000_000_000n // 0.015 ETH\n\nconst FEE_HISTORY_BLOCK_COUNT = 20\nconst FEE_HISTORY_REWARD_PERCENTILES = [90]\nconst DELTA_HEDGE_FEE_HISTORY_REWARD_PERCENTILES = [25]\nconst BASE_FEE_BUFFER_NUMERATOR = 1_125n\nconst BASE_FEE_BUFFER_DENOMINATOR = 1_000n\nconst REPLACEMENT_FEE_BUMP_NUMERATOR = 1_125n\nconst REPLACEMENT_FEE_BUMP_DENOMINATOR = 1_000n\nconst DELTA_HEDGE_PRIORITY_FEE_BUMP_NUMERATOR = 1_300n\nconst DELTA_HEDGE_PRIORITY_FEE_BUMP_DENOMINATOR = 1_000n\n// Leave the mandatory 12.5% replacement headroom for a final 3 gwei replacement.\nconst MAX_DELTA_HEDGE_PRIORITY_FEE_PER_GAS =\n (MAX_VAULT_PRIORITY_FEE_PER_GAS * REPLACEMENT_FEE_BUMP_DENOMINATOR) /\n REPLACEMENT_FEE_BUMP_NUMERATOR\nconst GAS_ESTIMATE_BUFFER_NUMERATOR = 3n\nconst GAS_ESTIMATE_BUFFER_DENOMINATOR = 2n\n\nexport type VaultTransactionFeeQuote = {\n currentBaseFeePerGas?: bigint\n maxFeePerGas: bigint\n maxPriorityFeePerGas: bigint\n minimumMaxFeePerGas: bigint\n minimumPriorityFeePerGas?: bigint\n source: 'fee_history' | 'viem_fallback' | 'rpc_priority_fee' | 'fee_history_p25'\n}\n\nexport type VaultDeltaHedgeFeeQuote = VaultTransactionFeeQuote & {\n rawPriorityFeePerGas: bigint\n}\n\nexport type VaultSignedTransactionFeeCaps = {\n chainId?: number\n gasLimit?: bigint | null\n maxFeePerGas: bigint | null\n maxPriorityFeePerGas: bigint | null\n}\n\nexport type VaultSignedTransactionFeeValidationResult =\n | { valid: true }\n | {\n valid: false\n code:\n | 'MissingEip1559Fees'\n | 'InvalidFeeCaps'\n | 'PriorityFeeTooLow'\n | 'PriorityFeeTooHigh'\n | 'MaxFeeTooLow'\n | 'GasCostTooHigh'\n reason: string\n }\n\nexport class VaultTransactionFeeEstimationError extends Error {\n readonly feeHistoryError: unknown\n readonly fallbackError: unknown\n\n constructor({\n feeHistoryError,\n fallbackError,\n }: {\n feeHistoryError: unknown\n fallbackError: unknown\n }) {\n super('Unable to estimate EIP-1559 fees for vault transaction')\n this.name = 'VaultTransactionFeeEstimationError'\n this.feeHistoryError = feeHistoryError\n this.fallbackError = fallbackError\n }\n}\n\nexport class VaultTransactionGasCostLimitError extends Error {\n readonly gasLimit: bigint\n readonly maximumAffordableFeePerGas: bigint\n readonly minimumRequiredFeePerGas: bigint\n\n constructor({\n gasLimit,\n maximumAffordableFeePerGas,\n minimumRequiredFeePerGas,\n }: {\n gasLimit: bigint\n maximumAffordableFeePerGas: bigint\n minimumRequiredFeePerGas: bigint\n }) {\n super(\n `Vault transaction cannot fit the ${MAX_VAULT_TRANSACTION_GAS_COST.toString()} wei gas-cost limit: ` +\n `gasLimit=${gasLimit.toString()}, maximumAffordableFeePerGas=${maximumAffordableFeePerGas.toString()}, ` +\n `minimumRequiredFeePerGas=${minimumRequiredFeePerGas.toString()}`,\n )\n this.name = 'VaultTransactionGasCostLimitError'\n this.gasLimit = gasLimit\n this.maximumAffordableFeePerGas = maximumAffordableFeePerGas\n this.minimumRequiredFeePerGas = minimumRequiredFeePerGas\n }\n}\n\nexport class VaultTransactionReplacementLimitError extends Error {\n readonly code: 'GasCostCapExceeded' | 'PriorityFeeCapExceeded'\n readonly requiredMaxFeePerGas: bigint\n readonly requiredMaxPriorityFeePerGas: bigint\n readonly maximumAffordableFeePerGas: bigint\n\n constructor({\n code,\n gasLimit,\n requiredMaxFeePerGas,\n requiredMaxPriorityFeePerGas,\n maximumAffordableFeePerGas,\n }: {\n code: 'GasCostCapExceeded' | 'PriorityFeeCapExceeded'\n gasLimit: bigint\n requiredMaxFeePerGas: bigint\n requiredMaxPriorityFeePerGas: bigint\n maximumAffordableFeePerGas: bigint\n }) {\n super(\n `Vault transaction replacement blocked by ${code}: gasLimit=${gasLimit.toString()}, ` +\n `requiredMaxFeePerGas=${requiredMaxFeePerGas.toString()}, ` +\n `requiredMaxPriorityFeePerGas=${requiredMaxPriorityFeePerGas.toString()}, ` +\n `maximumAffordableFeePerGas=${maximumAffordableFeePerGas.toString()}`,\n )\n this.name = 'VaultTransactionReplacementLimitError'\n this.code = code\n this.requiredMaxFeePerGas = requiredMaxFeePerGas\n this.requiredMaxPriorityFeePerGas = requiredMaxPriorityFeePerGas\n this.maximumAffordableFeePerGas = maximumAffordableFeePerGas\n }\n}\n\ntype FeeHistorySnapshot = {\n baseFeePerGas: readonly bigint[]\n reward?: readonly (readonly bigint[])[] | undefined\n minimumPriorityFeePerGas?: bigint\n}\n\ntype FallbackFeeEstimate = {\n maxFeePerGas: bigint\n maxPriorityFeePerGas: bigint\n}\n\nfunction ceilMultiplyFraction(value: bigint, numerator: bigint, denominator: bigint): bigint {\n return (value * numerator + denominator - 1n) / denominator\n}\n\nfunction medianBigInt(values: readonly bigint[]): bigint | undefined {\n if (values.length === 0) return undefined\n const sorted = [...values].sort((left, right) => (left < right ? -1 : left > right ? 1 : 0))\n const upperMiddleIndex = Math.floor(sorted.length / 2)\n const upperMiddle = sorted[upperMiddleIndex]\n if (upperMiddle === undefined) return undefined\n if (sorted.length % 2 === 1) return upperMiddle\n const lowerMiddle = sorted[upperMiddleIndex - 1]\n return lowerMiddle === undefined ? undefined : (lowerMiddle + upperMiddle) / 2n\n}\n\nfunction getChainPriorityFeeFloor(chainId: number | undefined): bigint | undefined {\n return chainId === ROBINHOOD_CHAIN_ID ? 0n : undefined\n}\n\nfunction clampPriorityFee(\n priorityFee: bigint,\n minimumPriorityFeePerGas = MIN_VAULT_PRIORITY_FEE_PER_GAS,\n): bigint {\n if (priorityFee < minimumPriorityFeePerGas) return minimumPriorityFeePerGas\n if (priorityFee > MAX_VAULT_PRIORITY_FEE_PER_GAS) return MAX_VAULT_PRIORITY_FEE_PER_GAS\n return priorityFee\n}\n\nfunction resolveFeeHistoryQuote({\n baseFeePerGas,\n reward,\n minimumPriorityFeePerGas,\n}: {\n baseFeePerGas: readonly bigint[]\n reward?: readonly (readonly bigint[])[] | undefined\n minimumPriorityFeePerGas?: bigint\n}): VaultTransactionFeeQuote | null {\n // feeHistory includes one additional base fee for the next block. The\n // second-to-last entry is therefore the latest mined block's base fee.\n const latestBaseFeeIndex = baseFeePerGas.length - 2\n if (latestBaseFeeIndex < 0 || reward === undefined || reward.length === 0) return null\n\n const p90Rewards = reward.flatMap((blockRewards) => {\n const p90 = blockRewards[0]\n return p90 === undefined ? [] : [p90]\n })\n const sampledPriorityFee = medianBigInt(p90Rewards)\n if (sampledPriorityFee === undefined) return null\n\n const effectivePriorityFeeFloor = minimumPriorityFeePerGas ?? MIN_VAULT_PRIORITY_FEE_PER_GAS\n const maxPriorityFeePerGas = clampPriorityFee(sampledPriorityFee, effectivePriorityFeeFloor)\n const bufferedBaseFee = ceilMultiplyFraction(\n baseFeePerGas[latestBaseFeeIndex],\n BASE_FEE_BUFFER_NUMERATOR,\n BASE_FEE_BUFFER_DENOMINATOR,\n )\n\n return {\n currentBaseFeePerGas: baseFeePerGas[latestBaseFeeIndex],\n maxFeePerGas: bufferedBaseFee + maxPriorityFeePerGas,\n maxPriorityFeePerGas,\n minimumMaxFeePerGas: bufferedBaseFee + effectivePriorityFeeFloor,\n ...(minimumPriorityFeePerGas === undefined ? {} : { minimumPriorityFeePerGas }),\n source: 'fee_history',\n }\n}\n\nfunction resolveDeltaHedgeFeeHistoryQuote({\n baseFeePerGas,\n reward,\n minimumPriorityFeePerGas,\n}: FeeHistorySnapshot): VaultDeltaHedgeFeeQuote | null {\n const latestBaseFeeIndex = baseFeePerGas.length - 2\n if (latestBaseFeeIndex < 0 || reward === undefined || reward.length === 0) return null\n\n const p25Rewards = reward.flatMap((blockRewards) => {\n const p25 = blockRewards[0]\n return p25 === undefined ? [] : [p25]\n })\n const rawPriorityFeePerGas = medianBigInt(p25Rewards)\n if (rawPriorityFeePerGas === undefined) return null\n\n const effectivePriorityFeeFloor = minimumPriorityFeePerGas ?? MIN_VAULT_PRIORITY_FEE_PER_GAS\n const maxPriorityFeePerGas = clampPriorityFee(rawPriorityFeePerGas, effectivePriorityFeeFloor)\n const bufferedBaseFee = ceilMultiplyFraction(\n baseFeePerGas[latestBaseFeeIndex],\n BASE_FEE_BUFFER_NUMERATOR,\n BASE_FEE_BUFFER_DENOMINATOR,\n )\n return {\n maxFeePerGas: bufferedBaseFee + maxPriorityFeePerGas,\n maxPriorityFeePerGas,\n minimumMaxFeePerGas: bufferedBaseFee + effectivePriorityFeeFloor,\n ...(minimumPriorityFeePerGas === undefined ? {} : { minimumPriorityFeePerGas }),\n rawPriorityFeePerGas,\n source: 'fee_history_p25',\n }\n}\n\nfunction resolveRpcPriorityFeeQuote({\n baseFeePerGas,\n rawPriorityFeePerGas,\n minimumPriorityFeePerGas,\n}: {\n baseFeePerGas: bigint\n rawPriorityFeePerGas: bigint\n minimumPriorityFeePerGas?: bigint\n}): VaultDeltaHedgeFeeQuote {\n const bufferedBaseFee = ceilMultiplyFraction(\n baseFeePerGas,\n BASE_FEE_BUFFER_NUMERATOR,\n BASE_FEE_BUFFER_DENOMINATOR,\n )\n return {\n maxFeePerGas: bufferedBaseFee + rawPriorityFeePerGas,\n maxPriorityFeePerGas: rawPriorityFeePerGas,\n minimumMaxFeePerGas: bufferedBaseFee + (minimumPriorityFeePerGas ?? rawPriorityFeePerGas),\n ...(minimumPriorityFeePerGas === undefined ? {} : { minimumPriorityFeePerGas }),\n rawPriorityFeePerGas,\n source: 'rpc_priority_fee',\n }\n}\n\nexport function getVaultTransactionReplacementFeeQuote({\n originalQuote,\n historicalQuote,\n gasLimit,\n finalReplacement = false,\n staleBoundsReplacement = false,\n}: {\n originalQuote: Pick<VaultTransactionFeeQuote, 'maxFeePerGas' | 'maxPriorityFeePerGas'>\n historicalQuote: VaultDeltaHedgeFeeQuote\n gasLimit: bigint\n finalReplacement?: boolean\n staleBoundsReplacement?: boolean\n}): VaultDeltaHedgeFeeQuote {\n if (gasLimit <= 0n) {\n throw new Error(`Vault transaction gas limit must be positive, received ${gasLimit.toString()}`)\n }\n\n const bumpedPriorityFee = staleBoundsReplacement\n ? ceilMultiplyFraction(\n originalQuote.maxPriorityFeePerGas,\n REPLACEMENT_FEE_BUMP_NUMERATOR,\n REPLACEMENT_FEE_BUMP_DENOMINATOR,\n )\n : ceilMultiplyFraction(\n originalQuote.maxPriorityFeePerGas,\n DELTA_HEDGE_PRIORITY_FEE_BUMP_NUMERATOR,\n DELTA_HEDGE_PRIORITY_FEE_BUMP_DENOMINATOR,\n )\n const bumpedMaxFee = ceilMultiplyFraction(\n originalQuote.maxFeePerGas,\n REPLACEMENT_FEE_BUMP_NUMERATOR,\n REPLACEMENT_FEE_BUMP_DENOMINATOR,\n )\n const escalatingPriorityFee =\n historicalQuote.maxPriorityFeePerGas > bumpedPriorityFee\n ? historicalQuote.maxPriorityFeePerGas\n : bumpedPriorityFee\n const priorityFeeLimit = staleBoundsReplacement\n ? MAX_STALE_DELTA_HEDGE_PRIORITY_FEE_PER_GAS\n : finalReplacement\n ? MAX_VAULT_PRIORITY_FEE_PER_GAS\n : MAX_DELTA_HEDGE_PRIORITY_FEE_PER_GAS\n const desiredMaxPriorityFeePerGas = finalReplacement\n ? MAX_VAULT_PRIORITY_FEE_PER_GAS\n : staleBoundsReplacement\n ? bumpedPriorityFee\n : escalatingPriorityFee\n const requiredReplacementPriorityFee = ceilMultiplyFraction(\n originalQuote.maxPriorityFeePerGas,\n REPLACEMENT_FEE_BUMP_NUMERATOR,\n REPLACEMENT_FEE_BUMP_DENOMINATOR,\n )\n const requiredMaxPriorityFeePerGas =\n desiredMaxPriorityFeePerGas < priorityFeeLimit ? desiredMaxPriorityFeePerGas : priorityFeeLimit\n if (requiredMaxPriorityFeePerGas < requiredReplacementPriorityFee) {\n throw new VaultTransactionReplacementLimitError({\n code: 'PriorityFeeCapExceeded',\n gasLimit,\n requiredMaxFeePerGas: originalQuote.maxFeePerGas,\n requiredMaxPriorityFeePerGas: requiredReplacementPriorityFee,\n maximumAffordableFeePerGas: MAX_VAULT_TRANSACTION_GAS_COST / gasLimit,\n })\n }\n const bufferedBaseFee =\n historicalQuote.minimumMaxFeePerGas -\n (historicalQuote.minimumPriorityFeePerGas ?? MIN_VAULT_PRIORITY_FEE_PER_GAS)\n const currentMarketMaxFee = bufferedBaseFee + requiredMaxPriorityFeePerGas\n const desiredMaxFeePerGas =\n currentMarketMaxFee > bumpedMaxFee ? currentMarketMaxFee : bumpedMaxFee\n const maximumAffordableFeePerGas = MAX_VAULT_TRANSACTION_GAS_COST / gasLimit\n\n if (\n bumpedMaxFee > maximumAffordableFeePerGas ||\n requiredMaxPriorityFeePerGas > maximumAffordableFeePerGas\n ) {\n throw new VaultTransactionReplacementLimitError({\n code: 'GasCostCapExceeded',\n gasLimit,\n requiredMaxFeePerGas: bumpedMaxFee,\n requiredMaxPriorityFeePerGas,\n maximumAffordableFeePerGas,\n })\n }\n const maxFeePerGas =\n desiredMaxFeePerGas < maximumAffordableFeePerGas\n ? desiredMaxFeePerGas\n : maximumAffordableFeePerGas\n\n return {\n ...historicalQuote,\n maxFeePerGas,\n maxPriorityFeePerGas: requiredMaxPriorityFeePerGas,\n }\n}\n\nfunction resolveFallbackQuote({\n maxFeePerGas: estimatedMaxFeePerGas,\n maxPriorityFeePerGas: estimatedPriorityFeePerGas,\n minimumPriorityFeePerGas,\n}: {\n maxFeePerGas: bigint\n maxPriorityFeePerGas: bigint\n minimumPriorityFeePerGas?: bigint\n}): VaultTransactionFeeQuote {\n const effectivePriorityFeeFloor = minimumPriorityFeePerGas ?? MIN_VAULT_PRIORITY_FEE_PER_GAS\n const maxPriorityFeePerGas = clampPriorityFee(\n estimatedPriorityFeePerGas,\n effectivePriorityFeeFloor,\n )\n const estimatedBaseFeeAllowance =\n estimatedMaxFeePerGas > estimatedPriorityFeePerGas\n ? estimatedMaxFeePerGas - estimatedPriorityFeePerGas\n : 0n\n\n return {\n maxFeePerGas: estimatedBaseFeeAllowance + maxPriorityFeePerGas,\n maxPriorityFeePerGas,\n minimumMaxFeePerGas: estimatedBaseFeeAllowance + effectivePriorityFeeFloor,\n ...(minimumPriorityFeePerGas === undefined ? {} : { minimumPriorityFeePerGas }),\n source: 'viem_fallback',\n }\n}\n\nexport function applyVaultTransactionGasCostLimit(\n quote: VaultTransactionFeeQuote,\n gasLimit: bigint,\n): VaultTransactionFeeQuote {\n if (gasLimit <= 0n) {\n throw new Error(`Vault transaction gas limit must be positive, received ${gasLimit.toString()}`)\n }\n\n const maximumAffordableFeePerGas = MAX_VAULT_TRANSACTION_GAS_COST / gasLimit\n if (maximumAffordableFeePerGas < quote.minimumMaxFeePerGas) {\n throw new VaultTransactionGasCostLimitError({\n gasLimit,\n maximumAffordableFeePerGas,\n minimumRequiredFeePerGas: quote.minimumMaxFeePerGas,\n })\n }\n\n if (quote.maxFeePerGas <= maximumAffordableFeePerGas) return quote\n\n const bufferedBaseFee =\n quote.minimumMaxFeePerGas - (quote.minimumPriorityFeePerGas ?? MIN_VAULT_PRIORITY_FEE_PER_GAS)\n const affordablePriorityFee = maximumAffordableFeePerGas - bufferedBaseFee\n return {\n ...quote,\n maxFeePerGas: maximumAffordableFeePerGas,\n maxPriorityFeePerGas:\n quote.maxPriorityFeePerGas < affordablePriorityFee\n ? quote.maxPriorityFeePerGas\n : affordablePriorityFee,\n }\n}\n\nexport function bufferVaultTransactionGasEstimate(gasEstimate: bigint): bigint {\n if (gasEstimate <= 0n) {\n throw new Error(\n `Vault transaction gas estimate must be positive, received ${gasEstimate.toString()}`,\n )\n }\n return ceilMultiplyFraction(\n gasEstimate,\n GAS_ESTIMATE_BUFFER_NUMERATOR,\n GAS_ESTIMATE_BUFFER_DENOMINATOR,\n )\n}\n\nexport function validateVaultSignedTransactionFeeCaps(\n feeCaps: VaultSignedTransactionFeeCaps,\n quote?: VaultTransactionFeeQuote,\n): VaultSignedTransactionFeeValidationResult {\n const { chainId, gasLimit, maxFeePerGas, maxPriorityFeePerGas } = feeCaps\n const minimumPriorityFeePerGas =\n quote?.minimumPriorityFeePerGas ??\n getChainPriorityFeeFloor(chainId) ??\n MIN_VAULT_PRIORITY_FEE_PER_GAS\n if (maxFeePerGas === null || maxPriorityFeePerGas === null) {\n return {\n valid: false,\n code: 'MissingEip1559Fees',\n reason: 'Signed transaction must include EIP-1559 max fee and priority fee caps.',\n }\n }\n if (maxPriorityFeePerGas > maxFeePerGas) {\n return {\n valid: false,\n code: 'InvalidFeeCaps',\n reason:\n `Signed transaction maxPriorityFeePerGas (${maxPriorityFeePerGas.toString()} wei) ` +\n `cannot exceed maxFeePerGas (${maxFeePerGas.toString()} wei).`,\n }\n }\n if (maxPriorityFeePerGas < minimumPriorityFeePerGas) {\n return {\n valid: false,\n code: 'PriorityFeeTooLow',\n reason:\n `Signed transaction maxPriorityFeePerGas (${maxPriorityFeePerGas.toString()} wei) ` +\n `must be at least ${minimumPriorityFeePerGas.toString()} wei.`,\n }\n }\n if (maxPriorityFeePerGas > MAX_VAULT_PRIORITY_FEE_PER_GAS) {\n return {\n valid: false,\n code: 'PriorityFeeTooHigh',\n reason:\n `Signed transaction maxPriorityFeePerGas (${maxPriorityFeePerGas.toString()} wei) ` +\n `must not exceed ${MAX_VAULT_PRIORITY_FEE_PER_GAS.toString()} wei (3 gwei).`,\n }\n }\n if (\n gasLimit !== undefined &&\n gasLimit !== null &&\n gasLimit * maxFeePerGas > MAX_VAULT_TRANSACTION_GAS_COST\n ) {\n return {\n valid: false,\n code: 'GasCostTooHigh',\n reason:\n `Signed transaction maximum gas cost (${(gasLimit * maxFeePerGas).toString()} wei) ` +\n `must not exceed ${MAX_VAULT_TRANSACTION_GAS_COST.toString()} wei (0.015 ETH).`,\n }\n }\n if (quote !== undefined) {\n const feeRequirementDescription =\n quote.currentBaseFeePerGas === undefined ? 'buffered next-block base fee' : 'current base fee'\n const minimumBroadcastMaxFeePerGas =\n quote.currentBaseFeePerGas === undefined\n ? quote.minimumMaxFeePerGas\n : quote.currentBaseFeePerGas + minimumPriorityFeePerGas\n if (maxFeePerGas < minimumBroadcastMaxFeePerGas) {\n return {\n valid: false,\n code: 'MaxFeeTooLow',\n reason:\n `Signed transaction maxFeePerGas (${maxFeePerGas.toString()} wei) must be at least ` +\n `${minimumBroadcastMaxFeePerGas.toString()} wei for the ${feeRequirementDescription} ` +\n 'and configured minimum priority fee.',\n }\n }\n }\n return { valid: true }\n}\n\nasync function resolveVaultTransactionFeeQuote({\n readFeeHistory,\n readFallbackEstimate,\n minimumPriorityFeePerGas,\n}: {\n readFeeHistory: () => Promise<FeeHistorySnapshot>\n readFallbackEstimate: () => Promise<FallbackFeeEstimate>\n minimumPriorityFeePerGas?: bigint\n}): Promise<VaultTransactionFeeQuote> {\n let feeHistoryError: unknown\n try {\n const quote = resolveFeeHistoryQuote({\n ...(await readFeeHistory()),\n minimumPriorityFeePerGas,\n })\n if (quote !== null) return quote\n feeHistoryError = new Error('eth_feeHistory returned incomplete base fee or reward data')\n } catch (error) {\n feeHistoryError = error\n }\n\n try {\n return resolveFallbackQuote({\n ...(await readFallbackEstimate()),\n minimumPriorityFeePerGas,\n })\n } catch (fallbackError) {\n throw new VaultTransactionFeeEstimationError({ feeHistoryError, fallbackError })\n }\n}\n\n/**\n * Resolve explicit EIP-1559 fees for operator-controlled vault transactions.\n *\n * The normal path follows the median p90 priority fee from the last 20 blocks,\n * with a 3 gwei ceiling and a 0.1 gwei floor except on chains that do not use\n * tips for ordering. If fee history is unavailable, Viem's estimate is used\n * while preserving those bounds and its original base-fee allowance.\n */\nexport async function getVaultTransactionFeeQuote<chain extends Chain | undefined>(\n client: Client<Transport, chain>,\n): Promise<VaultTransactionFeeQuote> {\n return resolveVaultTransactionFeeQuote({\n minimumPriorityFeePerGas: getChainPriorityFeeFloor(client.chain?.id),\n readFeeHistory: () =>\n getFeeHistory(client, {\n blockCount: FEE_HISTORY_BLOCK_COUNT,\n blockTag: 'latest',\n rewardPercentiles: FEE_HISTORY_REWARD_PERCENTILES,\n }),\n readFallbackEstimate: () => estimateFeesPerGas(client),\n })\n}\n\nexport async function getVaultDeltaHedgeHistoricalFeeQuote<chain extends Chain | undefined>(\n client: Client<Transport, chain>,\n): Promise<VaultDeltaHedgeFeeQuote> {\n const feeHistory = await getFeeHistory(client, {\n blockCount: FEE_HISTORY_BLOCK_COUNT,\n blockTag: 'latest',\n rewardPercentiles: DELTA_HEDGE_FEE_HISTORY_REWARD_PERCENTILES,\n })\n const quote = resolveDeltaHedgeFeeHistoryQuote({\n ...feeHistory,\n minimumPriorityFeePerGas: getChainPriorityFeeFloor(client.chain?.id),\n })\n if (quote === null) {\n throw new Error('eth_feeHistory returned incomplete p25 base fee or reward data')\n }\n return quote\n}\n\nasync function resolveVaultDeltaHedgeInitialFeeQuote({\n readRpcQuote,\n readHistoricalQuote,\n minimumPriorityFeePerGas,\n}: {\n readRpcQuote: () => Promise<{ baseFeePerGas: bigint; rawPriorityFeePerGas: bigint }>\n readHistoricalQuote: () => Promise<VaultDeltaHedgeFeeQuote>\n minimumPriorityFeePerGas?: bigint\n}): Promise<VaultDeltaHedgeFeeQuote> {\n try {\n return resolveRpcPriorityFeeQuote({\n ...(await readRpcQuote()),\n minimumPriorityFeePerGas,\n })\n } catch {\n return readHistoricalQuote()\n }\n}\n\n/**\n * Resolve the first fee quote for a delta hedge from the connected RPC's\n * eth_maxPriorityFeePerGas recommendation. A failed RPC recommendation falls\n * back immediately to the rolling historical p25 quote.\n */\nexport async function getVaultDeltaHedgeInitialFeeQuote<chain extends Chain | undefined>(\n client: Client<Transport, chain>,\n): Promise<VaultDeltaHedgeFeeQuote> {\n return resolveVaultDeltaHedgeInitialFeeQuote({\n minimumPriorityFeePerGas: getChainPriorityFeeFloor(client.chain?.id),\n readRpcQuote: async () => {\n const [rawPriorityFee, latestBlock] = await Promise.all([\n client.request({ method: 'eth_maxPriorityFeePerGas' }),\n getBlock(client, { blockTag: 'latest' }),\n ])\n if (latestBlock.baseFeePerGas === null) {\n throw new Error('Latest block does not include an EIP-1559 base fee')\n }\n return {\n baseFeePerGas: latestBlock.baseFeePerGas,\n rawPriorityFeePerGas: hexToBigInt(rawPriorityFee),\n }\n },\n readHistoricalQuote: () => getVaultDeltaHedgeHistoricalFeeQuote(client),\n })\n}\n\nexport const __transactionFeeTestUtils = {\n clampPriorityFee,\n getChainPriorityFeeFloor,\n resolveDeltaHedgeFeeHistoryQuote,\n resolveFallbackQuote,\n resolveFeeHistoryQuote,\n resolveRpcPriorityFeeQuote,\n resolveVaultDeltaHedgeInitialFeeQuote,\n resolveVaultTransactionFeeQuote,\n}\n"],"mappings":";;;;SACO;CACH,WAAW;CACX,kBAAkB;EAChB,oBAAoB;EACpB,eAAe;EACf,aAAa;CACd;CACD,aAAa;EACX,QAAQ;GACN,2BAA2B;GAC3B,WAAW;GACX,cAAc;GACd,kBAAkB;GAClB,wCAAwC;EACzC;EACD,UAAU;GACR,gBAAgB;GAChB,gBAAgB;EACjB;EACD,YAAY;GACV,uBAAuB;GACvB,uBAAuB;EACxB;EACD,kBAAkB;GAChB,uBAAuB;GACvB,uBAAuB;EACxB;CACF;CACD,YAAY;EACV,QAAQ;GACN,WAAW;GACX,gBAAgB;GAChB,sBAAsB;GACtB,sBAAsB;EACvB;EACD,mBAAmB;GACjB,iBAAiB;IACf,WAAW;IACX,gBAAgB;IAChB,sBAAsB;IACtB,sBAAsB;GACvB;GACD,4BAA4B;IAC1B,WAAW;IACX,gBAAgB;IAChB,sBAAsB;IACtB,sBAAsB;IACtB,cAAc;IACd,mBAAmB;GACpB;EACF;EACD,MAAM;GACJ,iCAAiC;GACjC,iCAAiC;GACjC,kBAAkB;GAClB,cAAc;GACd,8BAA8B;GAC9B,mCAAmC;GACnC,qBAAqB;GACrB,qBAAqB;GACrB,kBAAkB;GAClB,gBAAgB;GAChB,iBAAiB;GACjB,qBAAqB;EACtB;CACF;CACD,eAAe,CACb,8CACA,4CACD;CACD,WAAW,EACT,gBAAgB;EACd,aAAa;EACb,aAAa;EACb,OAAO;EACP,eAAe;EACf,UAAU;CACX,EACF;CACD,aAAa;EACX,aAAa;EACb,YAAY;CACb;CACD,YAAY;EACV,WAAW;EACX,QAAQ;EACR,eAAe;EACf,UAAU;EACV,OAAO;EACP,QAAQ;CACT;CACD,yBAAyB;EACvB;EACA;EACA;EACA;CACD;AACF;YACO;CACN,WAAW;CACX,kBAAkB;EAChB,oBAAoB;EACpB,eAAe;EACf,aAAa;CACd;CACD,aAAa;EACX,QAAQ;GACN,2BAA2B;GAC3B,WAAW;GACX,cAAc;GACd,kBAAkB;GAClB,wCAAwC;EACzC;EACD,UAAU;GACR,gBAAgB;GAChB,gBAAgB;GAChB,gBAAgB;EACjB;EACD,YAAY;GACV,uBAAuB;GACvB,uBAAuB;GACvB,uBAAuB;EACxB;EACD,kBAAkB;GAChB,uBAAuB;GACvB,uBAAuB;GACvB,uBAAuB;EACxB;CACF;CACD,YAAY;EACV,QAAQ;GACN,WAAW;GACX,gBAAgB;GAChB,sBAAsB;GACtB,sBAAsB;EACvB;EACD,mBAAmB;GACjB,kBAAkB;IAChB,WAAW;IACX,gBAAgB;IAChB,sBAAsB;IACtB,sBAAsB;GACvB;GACD,iBAAiB;IACf,WAAW;IACX,gBAAgB;IAChB,sBAAsB;IACtB,sBAAsB;GACvB;GACD,4BAA4B;IAC1B,WAAW;IACX,gBAAgB;IAChB,sBAAsB;IACtB,sBAAsB;IACtB,cAAc;IACd,mBAAmB;GACpB;EACF;EACD,MAAM;GACJ,iCAAiC;GACjC,iCAAiC;GACjC,kBAAkB;GAClB,cAAc;GACd,8BAA8B;GAC9B,mCAAmC;GACnC,qBAAqB;GACrB,qBAAqB;GACrB,kBAAkB;GAClB,gBAAgB;GAChB,iBAAiB;GACjB,qBAAqB;EACtB;CACF;CACD,eAAe,CACb,8CACA,4CACD;CACD,WAAW;EACT,WAAW;GACT,aAAa;GACb,aAAa;GACb,OAAO;GACP,eAAe;GACf,UAAU;EACX;EACD,gBAAgB;GACd,aAAa;GACb,aAAa;GACb,OAAO;GACP,eAAe;GACf,UAAU;EACX;EACD,eAAe;GACb,aAAa;GACb,aAAa;GACb,OAAO;GACP,eAAe;GACf,UAAU;EACX;CACF;CACD,aAAa;EACX,aAAa;EACb,YAAY;CACb;CACD,yBAAyB;EACvB;EACA;EACA;EACA;CACD;AACF;YACO;CACN,WAAW;CACX,kBAAkB;EAChB,oBAAoB;EACpB,eAAe;EACf,aAAa;CACd;CACD,aAAa;EACX,QAAQ;GACN,2BAA2B;GAC3B,WAAW;GACX,cAAc;GACd,kBAAkB;GAClB,wCAAwC;EACzC;EACD,UAAU;GACR,gBAAgB;GAChB,gBAAgB;EACjB;EACD,YAAY;GACV,uBAAuB;GACvB,uBAAuB;EACxB;EACD,kBAAkB;GAChB,uBAAuB;GACvB,uBAAuB;EACxB;CACF;CACD,YAAY;EACV,QAAQ;GACN,WAAW;GACX,gBAAgB;GAChB,sBAAsB;GACtB,sBAAsB;EACvB;EACD,MAAM;GACJ,iCAAiC;GACjC,iCAAiC;GACjC,kBAAkB;GAClB,cAAc;GACd,8BAA8B;GAC9B,mCAAmC;GACnC,qBAAqB;GACrB,qBAAqB;GACrB,kBAAkB;GAClB,gBAAgB;GAChB,iBAAiB;GACjB,qBAAqB;EACtB;CACF;CACD,eAAe,CACb,4CACD;CACD,WAAW,EACT,eAAe;EACb,aAAa;EACb,aAAa;EACb,OAAO;EACP,eAAe;EACf,UAAU;CACX,EACF;CACD,aAAa;EACX,aAAa;EACb,YAAY;CACb;AACF;gBACW;CACV,WAAW;CACX,kBAAkB;EAChB,oBAAoB;EACpB,eAAe;EACf,aAAa;CACd;CACD,aAAa;EACX,QAAQ;GACN,2BAA2B;GAC3B,WAAW;GACX,cAAc;GACd,kBAAkB;GAClB,wCAAwC;EACzC;EACD,UAAU;GACR,gBAAgB;GAChB,gBAAgB;EACjB;EACD,YAAY;GACV,uBAAuB;GACvB,uBAAuB;EACxB;EACD,kBAAkB;GAChB,uBAA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O,sCAAsC;EAC3C,0BAA0B,yBAAyB,OAAO,OAAO,GAAG;EACpE,cAAc,YAAY;GACxB,MAAM,CAAC,gBAAgB,YAAY,GAAG,MAAM,QAAQ,IAAI,CACtD,OAAO,QAAQ,EAAE,QAAQ,2BAA4B,EAAC,EACtD,SAAS,QAAQ,EAAE,UAAU,SAAU,EAAC,AACzC,EAAC;AACF,OAAI,YAAY,kBAAkB,KAChC,OAAM,IAAI,MAAM;AAElB,UAAO;IACL,eAAe,YAAY;IAC3B,sBAAsB,YAAY,eAAe;GAClD;EACF;EACD,qBAAqB,MAAM,qCAAqC,OAAO;CACxE,EAAC;AACH"}
1
+ {"version":3,"file":"vault-transaction-fees.js","names":["chainDeploymentsData","value: bigint","numerator: bigint","denominator: bigint","values: readonly bigint[]","chainId: number | undefined","priorityFee: bigint","quote: VaultTransactionFeeQuote","gasLimit: bigint","gasEstimate: bigint","feeCaps: VaultSignedTransactionFeeCaps","quote?: VaultTransactionFeeQuote","feeHistoryError: unknown","client: Client<Transport, chain>"],"sources":["../../deployments/src/chainDeployments.data.json","../../deployments/src/chainDeployments.js","../../deployments/src/vaultDisplayNames.js","../src/hypoVault/transactionFees.ts"],"sourcesContent":["{\n \"1\": {\n \"chainId\": 1,\n \"infrastructure\": {\n \"uniswapV3Factory\": \"0x1F98431c8aD98523631AE4a59f267346ea31F984\",\n \"poolManager\": \"0x000000000004444c5dc75cB358380D2e3dE08A90\",\n \"stateView\": \"0x7ffe42c4a5deea5b0fec41c94c136cf115597227\"\n },\n \"hypovault\": {\n \"core\": {\n \"hypoVaultImplementation\": \"0xF16714665955DBd0361D997eFc50fe391D96E8D0\",\n \"factory\": \"0xd5049B2647de57141dE7F65E5124707B99A452A3\",\n \"accountant\": \"0x65aA902AE3135658587FFC36ED51B61c927114e1\",\n \"rolesAuthority\": \"0xb952D345c413Ddb7850173422bAe4968e0330598\",\n \"collateralTrackerDecoderAndSanitizer\": \"0xC87c45d2dbE5acb56013e2591427ECC84Fa251E6\"\n },\n \"vaults\": {\n \"wethPlpVault\": \"0xd4e2c720a760049cc4151bcf61e3a9348db9cd92\",\n \"usdcPlpVault\": \"0x236d0558f06cd60780b232d4Ec4c92d2cb7e4D18\"\n },\n \"managers\": {\n \"wethPlpVaultManager\": \"0xB6Fc48e658C9B1a7dbdFA51A5E153ab60BB2e04d\",\n \"usdcPlpVaultManager\": \"0x2ce65016366ef7320078e0758D58Cf1038bc7C4e\"\n },\n \"turnkeySigners\": {\n \"wethPlpVaultManager\": \"0x8FfA6DAB99f8afc64F61BeF83F0966eD6362f24F\",\n \"usdcPlpVaultManager\": \"0x3c1c79d0cfc316Ba959194c89696a8382d7d283b\"\n }\n },\n \"panoptic\": {\n \"pool\": {\n \"version\": \"v4\",\n \"panopticPool\": \"0x00000000563b70d704f4c6675a5f6ac989fbae13\",\n \"collateralTracker0\": \"0x1e46b0289B7E0F710E2Db8Ab87800dd782D624f7\",\n \"collateralTracker1\": \"0x12bF31955522BAC337D93e1bC0a39F68D8BDa216\"\n },\n \"additionalPools\": {\n \"ethUsdc5bpsV3\": {\n \"version\": \"v3\",\n \"panopticPool\": \"0x00000000009C7B687e833559e34503f64d7ed7c4\",\n \"collateralTracker0\": \"0x3CCdA7d5E841d6543D90BcEc20b36a724C184DE9\",\n \"collateralTracker1\": \"0x69E9f9e44E5F52237493b980dd7306198C64A4E4\"\n },\n \"ethUsdc5bpsV3Replacement\": {\n \"version\": \"v3\",\n \"panopticPool\": \"0x00000000000E98f6c5aE16835bAdF2f7cC0d49D7\",\n \"collateralTracker0\": \"0x3E24E4Ab1e097F35C910eb9242a8C1530ee9C482\",\n \"collateralTracker1\": \"0xE1e01ac7E6b2671b82Aea4Db812a5c444523a039\",\n \"riskEngine\": \"0x000000000000ffE5eFdB5AE76b9200263C58b4c0\",\n \"deploymentBlock\": \"26173664\"\n }\n },\n \"v2\": {\n \"semiFungiblePositionManagerV4\": \"0x00000000000005C3287f136Ef5AF56c68Ea6849f\",\n \"semiFungiblePositionManagerV3\": \"0x00000000000005E4693aDc8Ec0f12D686f728198\",\n \"builderFactory\": \"0x0000000000000a3D22E158417AA639D7F71b0FF7\",\n \"riskEngine\": \"0x000000000000ffE5eFdB5AE76b9200263C58b4c0\",\n \"panopticPoolImplementation\": \"0x000000000000135429F0DaCaB61639Bf6a63EbbC\",\n \"collateralTrackerImplementation\": \"0x0000000000001d9c38CA405A2e04420865A08A33\",\n \"panopticFactoryV4\": \"0x0000000000000c51d0f8cf4bd9adE7191372a625\",\n \"panopticFactoryV3\": \"0x0000000000000aDC9A108591e718F2aee963a2a7\",\n \"panopticHelper\": \"0x0000000000000000000000000000000000000000\",\n \"panopticMath\": \"0x000000000000334bbd65C195581cf59ECf315932\",\n \"panopticQuery\": \"0x0000000000000e1aE9c66C1c3B0A547D23389C93\",\n \"interactionHelper\": \"0x00000000000041fe14Ce3c2392337CE501aE8328\"\n }\n },\n \"riskEngines\": [\n \"0x000000000000ffE5eFdB5AE76b9200263C58b4c0\",\n \"0x000000000000FfADa7c641E2aD6B13b51b50Cc94\"\n ],\n \"markets\": {\n \"ethUsdc30bps\": {\n \"currency0\": \"0x0000000000000000000000000000000000000000\",\n \"currency1\": \"0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48\",\n \"fee\": 3000,\n \"tickSpacing\": 60,\n \"poolId\": \"0x3C08AE4977F78D\"\n }\n },\n \"subgraphs\": {\n \"hypovault\": \"https://api.goldsky.com/api/public/project_cl9gc21q105380hxuh8ks53k3/subgraphs/hypovault-subgraph-mainnet/prod/gn\",\n \"panoptic\": \"https://api.goldsky.com/api/public/project_cl9gc21q105380hxuh8ks53k3/subgraphs/panoptic-subgraph-mainnet/v2_prod/gn\"\n },\n \"sfpmSwap\": {\n \"version\": \"v3\",\n \"sfpm\": \"0x00000000000005E4693aDc8Ec0f12D686f728198\",\n \"poolAddress\": \"0x88e6A0c2dDD26FEEb64F039a2c41296FcB3f5640\",\n \"poolId\": \"2824133844976349\",\n \"fee\": 500,\n \"weth\": \"0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2\"\n },\n \"deprecatedRiskEngines\": [\n \"0x0000000000000e673aECBDB5f5fE5DFAf4a8e9Ac\",\n \"0x0000000000000E65545005B26207D7edFd031260\",\n \"0x000000000000075e29cdaa9cb640a69e148ca7da\",\n \"0x0000000000000fe1e261f66ce2f44def4f5ae0cb\"\n ]\n },\n \"4663\": {\n \"chainId\": 4663,\n \"infrastructure\": {\n \"uniswapV3Factory\": \"0x1f7d7550b1b028f7571e69a784071f0205fd2efa\",\n \"poolManager\": \"0x8366a39cc670b4001a1121b8f6a443a643e40951\",\n \"stateView\": \"0xf3334192d15450cdd385c8b70e03f9a6bd9e673b\"\n },\n \"hypovault\": {\n \"core\": {\n \"hypoVaultImplementation\": \"0xF16714665955DBd0361D997eFc50fe391D96E8D0\",\n \"factory\": \"0xd5049B2647de57141dE7F65E5124707B99A452A3\",\n \"accountant\": \"0x9e345d862c41010F87D8E5A279e8D320D2831D36\",\n \"rolesAuthority\": \"0xb952D345c413Ddb7850173422bAe4968e0330598\",\n \"collateralTrackerDecoderAndSanitizer\": \"0xC87c45d2dbE5acb56013e2591427ECC84Fa251E6\"\n },\n \"vaults\": {\n \"wethPlpVault\": \"0x0000000000000000000000000000000000000000\",\n \"usdcPlpVault\": \"0x0000000000000000000000000000000000000000\",\n \"usdgPlpVault\": \"0x08B24123252Bd9c4DD473b6573D4cF67196FFC4B\"\n },\n \"managers\": {\n \"wethPlpVaultManager\": \"0x0000000000000000000000000000000000000000\",\n \"usdcPlpVaultManager\": \"0x0000000000000000000000000000000000000000\",\n \"usdgPlpVaultManager\": \"0x67Edb096585efe88a9A1ee16c5857AB74Fc8EA87\"\n },\n \"turnkeySigners\": {\n \"wethPlpVaultManager\": \"0x0000000000000000000000000000000000000000\",\n \"usdcPlpVaultManager\": \"0x0000000000000000000000000000000000000000\",\n \"usdgPlpVaultManager\": \"0x8FfA6DAB99f8afc64F61BeF83F0966eD6362f24F\"\n }\n },\n \"panoptic\": {\n \"pool\": {\n \"version\": \"v4\",\n \"panopticPool\": \"0x000000000c21b38c54AcA7c7145Df01ff09d69Bb\",\n \"collateralTracker0\": \"0xDc508622CD7e3850c8240e88c10361Cf493465b6\",\n \"collateralTracker1\": \"0x9212d804953bAf89C24ceFa6545aA293bA08a876\"\n },\n \"additionalPools\": {\n \"spyUsdg30bpsV4\": {\n \"version\": \"v4\",\n \"panopticPool\": \"0x00000000989bcb6f24af4a1Ab2A6d6a31c98A58E\",\n \"collateralTracker0\": \"0x49eaAC32A7CD4B8fB2209a12859a95E0b20aB0e5\",\n \"collateralTracker1\": \"0x670C44a0FC35dbC410498e47A6290a1C3196d191\"\n },\n \"spyUsdg5bpsV4\": {\n \"version\": \"v4\",\n \"panopticPool\": \"0x000000000c21b38c54AcA7c7145Df01ff09d69Bb\",\n \"collateralTracker0\": \"0xDc508622CD7e3850c8240e88c10361Cf493465b6\",\n \"collateralTracker1\": \"0x9212d804953bAf89C24ceFa6545aA293bA08a876\"\n },\n \"spyUsdg5bpsV4Replacement\": {\n \"version\": \"v4\",\n \"panopticPool\": \"0x000000000056475506823b2BedBD89f55232DA40\",\n \"collateralTracker0\": \"0xAd345C2088BF0B6140aa78ABB7fE8336e328686a\",\n \"collateralTracker1\": \"0xC9c3802aF99A6E9B9c3E7F5F8c5093e048Fac1Ca\",\n \"riskEngine\": \"0x000000000000FfADa7c641E2aD6B13b51b50Cc94\",\n \"deploymentBlock\": \"86379946\"\n }\n },\n \"v2\": {\n \"semiFungiblePositionManagerV4\": \"0x00000000000005C3287f136Ef5AF56c68Ea6849f\",\n \"semiFungiblePositionManagerV3\": \"0x00000000000005E4693aDc8Ec0f12D686f728198\",\n \"builderFactory\": \"0x0000000000000a3D22E158417AA639D7F71b0FF7\",\n \"riskEngine\": \"0x000000000000FfADa7c641E2aD6B13b51b50Cc94\",\n \"panopticPoolImplementation\": \"0x000000000000135429F0DaCaB61639Bf6a63EbbC\",\n \"collateralTrackerImplementation\": \"0x0000000000001d9c38CA405A2e04420865A08A33\",\n \"panopticFactoryV4\": \"0x0000000000000c51d0f8cf4bd9adE7191372a625\",\n \"panopticFactoryV3\": \"0x0000000000000aDC9A108591e718F2aee963a2a7\",\n \"panopticHelper\": \"0x0000000000000000000000000000000000000000\",\n \"panopticMath\": \"0x000000000000334bbd65C195581cf59ECf315932\",\n \"panopticQuery\": \"0x0000000000000e1aE9c66C1c3B0A547D23389C93\",\n \"interactionHelper\": \"0x00000000000041fe14Ce3c2392337CE501aE8328\"\n }\n },\n \"riskEngines\": [\n \"0x000000000000ffE5eFdB5AE76b9200263C58b4c0\",\n \"0x000000000000FfADa7c641E2aD6B13b51b50Cc94\"\n ],\n \"markets\": {\n \"spyUsdg\": {\n \"currency0\": \"0x117cc2133c37B721F49dE2A7a74833232B3B4C0C\",\n \"currency1\": \"0x5fc5360D0400a0Fd4f2af552ADD042D716F1d168\",\n \"fee\": 500,\n \"tickSpacing\": 5,\n \"poolId\": \"0xe5923c8a8be481ec89a2ca784a2bbfa4235de6d88f92260fd66b660c4babf907\"\n },\n \"spyUsdg30bps\": {\n \"currency0\": \"0x117cc2133c37B721F49dE2A7a74833232B3B4C0C\",\n \"currency1\": \"0x5fc5360D0400a0Fd4f2af552ADD042D716F1d168\",\n \"fee\": 3000,\n \"tickSpacing\": 60,\n \"poolId\": \"0xfe2a80bb5618fd14984b92ca6d45bf5ba67443ddb1435e28b2e48df2fc1526cd\"\n },\n \"spyUsdg5bps\": {\n \"currency0\": \"0x117cc2133c37B721F49dE2A7a74833232B3B4C0C\",\n \"currency1\": \"0x5fc5360D0400a0Fd4f2af552ADD042D716F1d168\",\n \"fee\": 500,\n \"tickSpacing\": 5,\n \"poolId\": \"0xe5923c8a8be481ec89a2ca784a2bbfa4235de6d88f92260fd66b660c4babf907\"\n }\n },\n \"subgraphs\": {\n \"hypovault\": \"https://api.goldsky.com/api/public/project_cl9gc21q105380hxuh8ks53k3/subgraphs/hypovault-subgraph-robinhood/prod/gn\",\n \"panoptic\": \"https://api.goldsky.com/api/public/project_cl9gc21q105380hxuh8ks53k3/subgraphs/panoptic-subgraph-robinhood/v2_prod/gn\"\n },\n \"deprecatedRiskEngines\": [\n \"0x0000000000000E65545005B26207D7edFd031260\",\n \"0x000000000000075e29cdaa9cb640a69e148ca7da\",\n \"0x0000000000000fe1e261f66ce2f44def4f5ae0cb\",\n \"0x0000000000000f3fb82469581A74776178E76Ca4\"\n ]\n },\n \"8453\": {\n \"chainId\": 8453,\n \"infrastructure\": {\n \"uniswapV3Factory\": \"0x33128a8fC17869897dcE68Ed026d694621f6FDfD\",\n \"poolManager\": \"0x498581fF718922c3f8e6A244956aF099B2652b2b\",\n \"stateView\": \"0xA3c0c9b65baD0b08107Aa264b0f3dB444b867A71\"\n },\n \"hypovault\": {\n \"core\": {\n \"hypoVaultImplementation\": \"0xec311aE06486ad44Ba782133b502A34aCE0f479E\",\n \"factory\": \"0x9bE53b169a41030f1710A9B82e9eA6413f14D12E\",\n \"accountant\": \"0x345cA3407942f9d175c9eA8B90e83A36F570f852\",\n \"rolesAuthority\": \"0x278D37CaBFFB4B72D2866E30fEFE08aef773E0B6\",\n \"collateralTrackerDecoderAndSanitizer\": \"0x4A290b3EC46cF320421Bb2aaee96d445de31CF0b\"\n },\n \"vaults\": {\n \"wethPlpVault\": \"0x41b7D0515d709A4Fd2CF27f9d141D0c2F8713D04\",\n \"usdcPlpVault\": \"0xb452af299c565D04B05E601efF2840e000C922f1\"\n },\n \"managers\": {\n \"wethPlpVaultManager\": \"0x2a4923456c79E9ebD10F5Bf5305a5C742bBc1D7C\",\n \"usdcPlpVaultManager\": \"0xdd6E2406a044582463CFE9F0C774870eAf4A310B\"\n },\n \"turnkeySigners\": {\n \"wethPlpVaultManager\": \"0x8FfA6DAB99f8afc64F61BeF83F0966eD6362f24F\",\n \"usdcPlpVaultManager\": \"0x3c1c79d0cfc316Ba959194c89696a8382d7d283b\"\n }\n },\n \"panoptic\": {\n \"pool\": {\n \"version\": \"v4\",\n \"panopticPool\": \"0xB50e8bb68f5855DA742f4579274902a20454174a\",\n \"collateralTracker0\": \"0x0d82b189c96EbB1f44A7207e6A9cfB1e490f2869\",\n \"collateralTracker1\": \"0x9ba1082Ab3cb9edEA988697A14BBe543A3dABEd2\"\n },\n \"v2\": {\n \"semiFungiblePositionManagerV4\": \"0x8dcAa08cF298F8b4830FAf56d47930981AdE33af\",\n \"semiFungiblePositionManagerV3\": \"0xFB1c06B491305d618bb8a7a368C6e50c001C153A\",\n \"builderFactory\": \"0x6d26E916a18d522f7DdA2a26d9E1645564ccDcA5\",\n \"riskEngine\": \"0x8bbce8b1eb64118cfe6c1eab0afe13b80ea41481\",\n \"panopticPoolImplementation\": \"0x5BA68a018fF149c38ec52D181Dd24aBabE9a07DB\",\n \"collateralTrackerImplementation\": \"0x34B3a4e4F14f292575ECe3EF67886C4598af459f\",\n \"panopticFactoryV4\": \"0x9ac0317fcd124aff0b5429beb8de17020bc45f9a\",\n \"panopticFactoryV3\": \"0x687f616d68c483a7223e6922f59aef7452e26c1d\",\n \"panopticHelper\": \"0x0000000000000000000000000000000000000000\",\n \"panopticMath\": \"0x6d21699192f5aF112C87e53b32ff846782afF407\",\n \"panopticQuery\": \"0xd2586E1bbdd1169F597F3A370117EdF7372A7350\",\n \"interactionHelper\": \"0x643d8DD5372FD6c71f8fAbCce4Eb8857704F3E15\"\n }\n },\n \"riskEngines\": [\n \"0x8bbce8b1eb64118cfe6c1eab0afe13b80ea41481\"\n ],\n \"markets\": {\n \"ethUsdc5bps\": {\n \"currency0\": \"0x0000000000000000000000000000000000000000\",\n \"currency1\": \"0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913\",\n \"fee\": 500,\n \"tickSpacing\": 10,\n \"poolId\": \"0x96d4b53a38337a5733179751781178a2613306063c511b78cd02684739288c0a\"\n }\n },\n \"subgraphs\": {\n \"hypovault\": \"https://api.goldsky.com/api/public/project_cl9gc21q105380hxuh8ks53k3/subgraphs/hypovault-subgraph-base/prod/gn\",\n \"panoptic\": \"https://api.goldsky.com/api/public/project_cl9gc21q105380hxuh8ks53k3/subgraphs/panoptic-subgraph-base/v2_prod/gn\"\n }\n },\n \"11155111\": {\n \"chainId\": 11155111,\n \"infrastructure\": {\n \"uniswapV3Factory\": \"0x0227628f3F023bb0B980b67D528571c95c6DaC1c\",\n \"poolManager\": \"0xE03A1074c86CFeDd5C142C4F04F1a1536e203543\",\n \"stateView\": \"0xE1Dd9c3fA50EDB962E442f60DfBc432e24537E4C\"\n },\n \"hypovault\": {\n \"core\": {\n \"hypoVaultImplementation\": \"0xC5b415Db4087228Af817893769DC3a205160160B\",\n \"factory\": \"0x363a9d605ca45cBfF3b597350DeADb53cdC292c7\",\n \"accountant\": \"0x25BBef1DF262c24aa1AACD1F7eCeEcc1a7AD08ab\",\n \"rolesAuthority\": \"0x673BfafB4e2712215B422347c1571421B83E8A3d\",\n \"collateralTrackerDecoderAndSanitizer\": \"0xb899BE50BAF25BBB3A3ca3403256B3c703E5AB5d\"\n },\n \"vaults\": {\n \"wethPlpVault\": \"0xD58C4F9AEe5bBfcf28dC9a8d3D57b323fA6521b1\",\n \"usdcPlpVault\": \"0xdd7a8d6c6975488e801129bC84302d74e2361208\"\n },\n \"managers\": {\n \"wethPlpVaultManager\": \"0x95eC124FAAB70D7aE147c3BE0336E01a828AE2d5\",\n \"usdcPlpVaultManager\": \"0xFB5aa3e0b46F3859D90B14b52ffd287013b5Ec53\"\n },\n \"turnkeySigners\": {\n \"wethPlpVaultManager\": \"0x8FfA6DAB99f8afc64F61BeF83F0966eD6362f24F\",\n \"usdcPlpVaultManager\": \"0x3c1c79d0cfc316Ba959194c89696a8382d7d283b\"\n }\n },\n \"panoptic\": {\n \"pool\": {\n \"version\": \"v4\",\n \"panopticPool\": \"0x872b98C46b2062F663BEb2CC9D4cE046Da2a2918\",\n \"collateralTracker0\": \"0x09a60b78d06a03e5148faedd3bfee6f58b22012f\",\n \"collateralTracker1\": \"0x7365664c8101ff7e9422ae2b203822253c31e69c\"\n },\n \"v2\": {\n \"semiFungiblePositionManagerV3\": \"0x9DaD2C40107Db4B29a5450401BB7A28e6eA00e43\",\n \"semiFungiblePositionManagerV4\": \"0xD2615995A71644E122cC2FD7FeC2392b971220DE\",\n \"builderFactory\": \"0x55f3D2d9D065AA5Fcc11D94c55a6085849e8b6C3\",\n \"riskEngine\": \"0x1376aF5ca426B6B9fad6a712c21f6Cf58a94b93c\",\n \"panopticPoolImplementation\": \"0x969235B5830f13b58BB699305d9c70A8Cd3BD97C\",\n \"collateralTrackerImplementation\": \"0xafcd5F651Ae0403Ff668bb2dAc38BEa907a35Dba\",\n \"panopticFactoryV3\": \"0xd9FFCa53C0A6155001Ce8cbcAEfe89DB204690F1\",\n \"panopticFactoryV4\": \"0x8FCBb59b05779818D9BAD2686cc44B705603ce03\",\n \"panopticHelper\": \"0xfFEbB3A4ab793cB244209d4dA0Cb3e6B07133bd0\",\n \"panopticMath\": \"0x6d21699192f5aF112C87e53b32ff846782afF407\",\n \"panopticQuery\": \"0x74057945467Fb4eAE9193B46A60ae66a53f06A5b\",\n \"interactionHelper\": \"0x643d8DD5372FD6c71f8fAbCce4Eb8857704F3E15\"\n }\n },\n \"riskEngines\": [\n \"0x1376aF5ca426B6B9fad6a712c21f6Cf58a94b93c\"\n ],\n \"markets\": {\n \"ethUsdc5bps\": {\n \"currency0\": \"0x0000000000000000000000000000000000000000\",\n \"currency1\": \"0xFFFeD8254566B7F800f6D8CDb843ec75AE49B07A\",\n \"fee\": 500,\n \"tickSpacing\": 10,\n \"poolId\": \"0xba6673bcb27568a73a93dd23b20c8174fa16193cd90905be859144e8f13097a5\"\n }\n },\n \"subgraphs\": {\n \"hypovault\": \"https://api.goldsky.com/api/public/project_cl9gc21q105380hxuh8ks53k3/subgraphs/hypovault-subgraph-sepolia/prod/gn\",\n \"panoptic\": \"https://api.goldsky.com/api/public/project_cl9gc21q105380hxuh8ks53k3/subgraphs/panoptic-subgraph-sepolia/v2_prod/gn\"\n }\n }\n}\n","import chainDeploymentsData from './chainDeployments.data.json' with { type: 'json' }\n\nexport const MAINNET_CHAIN_ID = 1\nexport const SEPOLIA_CHAIN_ID = 11155111\nexport const BASE_CHAIN_ID = 8453\nexport const ROBINHOOD_CHAIN_ID = 4663\n\nexport const CHAIN_DEPLOYMENTS = chainDeploymentsData\n\nexport function getChainDeployment(chainId) {\n return CHAIN_DEPLOYMENTS[chainId]\n}\n\nexport function requireChainDeployment(chainId) {\n const deployment = getChainDeployment(chainId)\n if (deployment === undefined) {\n throw new Error(`Unsupported chain deployment for chainId ${chainId}`)\n }\n return deployment\n}\n\nexport function isSupportedChain(chainId) {\n return getChainDeployment(chainId) !== undefined\n}\n\nexport function getEthUsdcMarket(deployment) {\n const market = deployment.markets.ethUsdc5bps ?? deployment.markets.ethUsdc30bps\n if (market === undefined) {\n throw new Error(`Missing ETH/USDC market for chainId ${deployment.chainId}`)\n }\n return market\n}\n\nexport function getSpyUsdgMarket(deployment) {\n const market = deployment.markets.spyUsdg\n if (market === undefined) {\n throw new Error(`Missing SPY/USDG market for chainId ${deployment.chainId}`)\n }\n return market\n}\n\nfunction requireDeploymentValue(value, label) {\n if (value === undefined) {\n throw new Error(`Missing deployment value: ${label}`)\n }\n return value\n}\n\nexport const MAINNET_DEPLOYMENT = CHAIN_DEPLOYMENTS[MAINNET_CHAIN_ID]\nexport const MAINNET_ETH_USDC_5BPS_V3_PANOPTIC_POOL_ADDRESSES =\n MAINNET_DEPLOYMENT.panoptic.additionalPools?.ethUsdc5bpsV3\nexport const MAINNET_PANOPTIC_V2_ADDRESSES = MAINNET_DEPLOYMENT.panoptic.v2\nexport const SEPOLIA_DEPLOYMENT = CHAIN_DEPLOYMENTS[SEPOLIA_CHAIN_ID]\nexport const SEPOLIA_HYPOVAULT_CORE_ADDRESSES = SEPOLIA_DEPLOYMENT.hypovault.core\nexport const SEPOLIA_HYPOVAULT_ADDRESSES = SEPOLIA_DEPLOYMENT.hypovault.vaults\nexport const SEPOLIA_HYPOVAULT_MANAGER_ADDRESSES = SEPOLIA_DEPLOYMENT.hypovault.managers\nexport const SEPOLIA_HYPOVAULT_MANAGER_TURNKEY_SIGNERS = SEPOLIA_DEPLOYMENT.hypovault.turnkeySigners\nexport const SEPOLIA_PANOPTIC_POOL_ADDRESSES = SEPOLIA_DEPLOYMENT.panoptic.pool\nexport const SEPOLIA_PANOPTIC_V2_ADDRESSES = SEPOLIA_DEPLOYMENT.panoptic.v2\nexport const BASE_DEPLOYMENT = CHAIN_DEPLOYMENTS[BASE_CHAIN_ID]\nexport const BASE_HYPOVAULT_CORE_ADDRESSES = BASE_DEPLOYMENT.hypovault.core\nexport const BASE_HYPOVAULT_ADDRESSES = BASE_DEPLOYMENT.hypovault.vaults\nexport const BASE_HYPOVAULT_MANAGER_ADDRESSES = BASE_DEPLOYMENT.hypovault.managers\nexport const BASE_HYPOVAULT_MANAGER_TURNKEY_SIGNERS = BASE_DEPLOYMENT.hypovault.turnkeySigners\nexport const BASE_PANOPTIC_POOL_ADDRESSES = BASE_DEPLOYMENT.panoptic.pool\nexport const BASE_PANOPTIC_V2_ADDRESSES = BASE_DEPLOYMENT.panoptic.v2\nexport const BASE_ETH_USDC_5BPS_MARKET = getEthUsdcMarket(BASE_DEPLOYMENT)\nexport const SEPOLIA_ETH_USDC_5BPS_MARKET = getEthUsdcMarket(SEPOLIA_DEPLOYMENT)\n\nexport const MAINNET_RISK_ENGINES = MAINNET_DEPLOYMENT.riskEngines\nexport const BASE_RISK_ENGINES = BASE_DEPLOYMENT.riskEngines\nexport const SEPOLIA_RISK_ENGINES = SEPOLIA_DEPLOYMENT.riskEngines\n\nexport const ROBINHOOD_DEPLOYMENT = CHAIN_DEPLOYMENTS[ROBINHOOD_CHAIN_ID]\nexport const ROBINHOOD_HYPOVAULT_CORE_ADDRESSES = ROBINHOOD_DEPLOYMENT.hypovault.core\nexport const ROBINHOOD_HYPOVAULT_ADDRESSES = ROBINHOOD_DEPLOYMENT.hypovault.vaults\nexport const ROBINHOOD_HYPOVAULT_MANAGER_ADDRESSES = ROBINHOOD_DEPLOYMENT.hypovault.managers\nexport const ROBINHOOD_HYPOVAULT_MANAGER_TURNKEY_SIGNERS =\n ROBINHOOD_DEPLOYMENT.hypovault.turnkeySigners\nexport const ROBINHOOD_PANOPTIC_POOL_ADDRESSES = ROBINHOOD_DEPLOYMENT.panoptic.pool\nexport const ROBINHOOD_SPY_USDG_30BPS_PANOPTIC_POOL_ADDRESSES = requireDeploymentValue(\n ROBINHOOD_DEPLOYMENT.panoptic.additionalPools?.spyUsdg30bpsV4,\n 'Robinhood SPY/USDG 30bps Panoptic pool',\n)\nexport const ROBINHOOD_SPY_USDG_5BPS_PANOPTIC_POOL_ADDRESSES = requireDeploymentValue(\n ROBINHOOD_DEPLOYMENT.panoptic.additionalPools?.spyUsdg5bpsV4,\n 'Robinhood SPY/USDG 5bps Panoptic pool',\n)\nexport const ROBINHOOD_PANOPTIC_V2_ADDRESSES = ROBINHOOD_DEPLOYMENT.panoptic.v2\nexport const ROBINHOOD_RISK_ENGINES = ROBINHOOD_DEPLOYMENT.riskEngines\nexport const ROBINHOOD_SPY_USDG_MARKET = getSpyUsdgMarket(ROBINHOOD_DEPLOYMENT)\nexport const ROBINHOOD_SPY_USDG_30BPS_MARKET = requireDeploymentValue(\n ROBINHOOD_DEPLOYMENT.markets.spyUsdg30bps,\n 'Robinhood SPY/USDG 30bps market',\n)\nexport const ROBINHOOD_SPY_USDG_5BPS_MARKET = requireDeploymentValue(\n ROBINHOOD_DEPLOYMENT.markets.spyUsdg5bps,\n 'Robinhood SPY/USDG 5bps market',\n)\n","import {\n BASE_CHAIN_ID,\n MAINNET_CHAIN_ID,\n requireChainDeployment,\n ROBINHOOD_CHAIN_ID,\n SEPOLIA_CHAIN_ID,\n} from './chainDeployments.js'\n\nconst mainnetDeployment = requireChainDeployment(MAINNET_CHAIN_ID)\nconst mainnetVaults = mainnetDeployment.hypovault.vaults\nconst legacyMainnetVaults = {\n wethPlpVault: '0x779a2aa634A004b3a3f3b322083744869BBC6D66',\n usdcPlpVault: '0x963Fe9c93bc353602656ee4051A75114bA74d6c5',\n}\nconst sepoliaDeployment = requireChainDeployment(SEPOLIA_CHAIN_ID)\nconst sepoliaVaults = sepoliaDeployment.hypovault.vaults\nconst baseDeployment = requireChainDeployment(BASE_CHAIN_ID)\nconst baseVaults = baseDeployment.hypovault.vaults\nconst robinhoodDeployment = requireChainDeployment(ROBINHOOD_CHAIN_ID)\nconst robinhoodUsdgVault = robinhoodDeployment.hypovault.vaults.usdgPlpVault\n\nif (robinhoodUsdgVault === undefined) {\n throw new Error('Missing Robinhood USDG PLP vault address')\n}\n\nexport const VAULT_DISPLAY_NAMES_PER_CHAIN = {\n [MAINNET_CHAIN_ID]: {\n [mainnetVaults.wethPlpVault.toLowerCase()]: 'ETH Yield Vault',\n [mainnetVaults.usdcPlpVault.toLowerCase()]: 'volUSDC Vault',\n [legacyMainnetVaults.wethPlpVault.toLowerCase()]: 'ETH Yield Vault',\n [legacyMainnetVaults.usdcPlpVault.toLowerCase()]: 'volUSDC Vault',\n },\n [BASE_CHAIN_ID]: {\n [baseVaults.wethPlpVault.toLowerCase()]: 'ETH Yield Vault',\n [baseVaults.usdcPlpVault.toLowerCase()]: 'volUSDC Vault',\n },\n [SEPOLIA_CHAIN_ID]: {\n [sepoliaVaults.wethPlpVault.toLowerCase()]: 'ETH Yield Vault',\n [sepoliaVaults.usdcPlpVault.toLowerCase()]: 'volUSDC Vault',\n },\n [ROBINHOOD_CHAIN_ID]: {\n [robinhoodUsdgVault.toLowerCase()]: '0DTE +67∆ Covered Call Vault',\n },\n}\n\nexport const VAULT_DISPLAY_NAME_RESOLVERS_PER_CHAIN = {\n [MAINNET_CHAIN_ID]: {\n [mainnetVaults.wethPlpVault.toLowerCase()]: () => 'ETH Yield Vault',\n [mainnetVaults.usdcPlpVault.toLowerCase()]: () => 'volUSDC Vault',\n [legacyMainnetVaults.wethPlpVault.toLowerCase()]: () => 'ETH Yield Vault',\n [legacyMainnetVaults.usdcPlpVault.toLowerCase()]: () => 'volUSDC Vault',\n },\n [BASE_CHAIN_ID]: {\n [baseVaults.wethPlpVault.toLowerCase()]: () => 'ETH Yield Vault',\n [baseVaults.usdcPlpVault.toLowerCase()]: () => 'volUSDC Vault',\n },\n [SEPOLIA_CHAIN_ID]: {\n [sepoliaVaults.wethPlpVault.toLowerCase()]: () => 'ETH Yield Vault',\n [sepoliaVaults.usdcPlpVault.toLowerCase()]: () => 'volUSDC Vault',\n },\n [ROBINHOOD_CHAIN_ID]: {\n [robinhoodUsdgVault.toLowerCase()]: () => '0DTE +67∆ Covered Call Vault',\n },\n}\n\nexport function resolveVaultDisplayName({ chainId, vaultAddress, underlyingSymbol, fallbackName }) {\n const vaultAddressLower = vaultAddress.toLowerCase()\n const resolver = VAULT_DISPLAY_NAME_RESOLVERS_PER_CHAIN[chainId]?.[vaultAddressLower]\n if (resolver !== undefined) {\n return resolver({\n chainId,\n vaultAddress: vaultAddressLower,\n underlyingSymbol,\n fallbackName,\n })\n }\n\n const staticName = VAULT_DISPLAY_NAMES_PER_CHAIN[chainId]?.[vaultAddressLower]\n if (staticName !== undefined) {\n return staticName\n }\n\n if (fallbackName !== undefined && fallbackName !== null) {\n return fallbackName\n }\n\n return 'Vault'\n}\n","import type { Chain, Client, Transport } from 'viem'\nimport { hexToBigInt } from 'viem'\nimport { estimateFeesPerGas, getBlock, getFeeHistory } from 'viem/actions'\n\nimport { ROBINHOOD_CHAIN_ID } from './chainDeployments'\n\nexport const MIN_VAULT_PRIORITY_FEE_PER_GAS = 100_000_000n // 0.1 gwei\nexport const MAX_VAULT_PRIORITY_FEE_PER_GAS = 3_000_000_000n // 3 gwei\nexport const MAX_STALE_DELTA_HEDGE_PRIORITY_FEE_PER_GAS = 8_000_000_000n // 8 gwei\nexport const MAX_VAULT_TRANSACTION_GAS_COST = 15_000_000_000_000_000n // 0.015 ETH\n\nconst FEE_HISTORY_BLOCK_COUNT = 20\nconst FEE_HISTORY_REWARD_PERCENTILES = [90]\nconst DELTA_HEDGE_FEE_HISTORY_REWARD_PERCENTILES = [25]\nconst BASE_FEE_BUFFER_NUMERATOR = 1_125n\nconst BASE_FEE_BUFFER_DENOMINATOR = 1_000n\nconst REPLACEMENT_FEE_BUMP_NUMERATOR = 1_125n\nconst REPLACEMENT_FEE_BUMP_DENOMINATOR = 1_000n\nconst DELTA_HEDGE_PRIORITY_FEE_BUMP_NUMERATOR = 1_300n\nconst DELTA_HEDGE_PRIORITY_FEE_BUMP_DENOMINATOR = 1_000n\n// Leave the mandatory 12.5% replacement headroom for a final 3 gwei replacement.\nconst MAX_DELTA_HEDGE_PRIORITY_FEE_PER_GAS =\n (MAX_VAULT_PRIORITY_FEE_PER_GAS * REPLACEMENT_FEE_BUMP_DENOMINATOR) /\n REPLACEMENT_FEE_BUMP_NUMERATOR\nconst GAS_ESTIMATE_BUFFER_NUMERATOR = 3n\nconst GAS_ESTIMATE_BUFFER_DENOMINATOR = 2n\n\nexport type VaultTransactionFeeQuote = {\n currentBaseFeePerGas?: bigint\n maxFeePerGas: bigint\n maxPriorityFeePerGas: bigint\n minimumMaxFeePerGas: bigint\n minimumPriorityFeePerGas?: bigint\n source: 'fee_history' | 'viem_fallback' | 'rpc_priority_fee' | 'fee_history_p25'\n}\n\nexport type VaultDeltaHedgeFeeQuote = VaultTransactionFeeQuote & {\n rawPriorityFeePerGas: bigint\n}\n\nexport type VaultSignedTransactionFeeCaps = {\n chainId?: number\n gasLimit?: bigint | null\n maxFeePerGas: bigint | null\n maxPriorityFeePerGas: bigint | null\n}\n\nexport type VaultSignedTransactionFeeValidationResult =\n | { valid: true }\n | {\n valid: false\n code:\n | 'MissingEip1559Fees'\n | 'InvalidFeeCaps'\n | 'PriorityFeeTooLow'\n | 'PriorityFeeTooHigh'\n | 'MaxFeeTooLow'\n | 'GasCostTooHigh'\n reason: string\n }\n\nexport class VaultTransactionFeeEstimationError extends Error {\n readonly feeHistoryError: unknown\n readonly fallbackError: unknown\n\n constructor({\n feeHistoryError,\n fallbackError,\n }: {\n feeHistoryError: unknown\n fallbackError: unknown\n }) {\n super('Unable to estimate EIP-1559 fees for vault transaction')\n this.name = 'VaultTransactionFeeEstimationError'\n this.feeHistoryError = feeHistoryError\n this.fallbackError = fallbackError\n }\n}\n\nexport class VaultTransactionGasCostLimitError extends Error {\n readonly gasLimit: bigint\n readonly maximumAffordableFeePerGas: bigint\n readonly minimumRequiredFeePerGas: bigint\n\n constructor({\n gasLimit,\n maximumAffordableFeePerGas,\n minimumRequiredFeePerGas,\n }: {\n gasLimit: bigint\n maximumAffordableFeePerGas: bigint\n minimumRequiredFeePerGas: bigint\n }) {\n super(\n `Vault transaction cannot fit the ${MAX_VAULT_TRANSACTION_GAS_COST.toString()} wei gas-cost limit: ` +\n `gasLimit=${gasLimit.toString()}, maximumAffordableFeePerGas=${maximumAffordableFeePerGas.toString()}, ` +\n `minimumRequiredFeePerGas=${minimumRequiredFeePerGas.toString()}`,\n )\n this.name = 'VaultTransactionGasCostLimitError'\n this.gasLimit = gasLimit\n this.maximumAffordableFeePerGas = maximumAffordableFeePerGas\n this.minimumRequiredFeePerGas = minimumRequiredFeePerGas\n }\n}\n\nexport class VaultTransactionReplacementLimitError extends Error {\n readonly code: 'GasCostCapExceeded' | 'PriorityFeeCapExceeded'\n readonly requiredMaxFeePerGas: bigint\n readonly requiredMaxPriorityFeePerGas: bigint\n readonly maximumAffordableFeePerGas: bigint\n\n constructor({\n code,\n gasLimit,\n requiredMaxFeePerGas,\n requiredMaxPriorityFeePerGas,\n maximumAffordableFeePerGas,\n }: {\n code: 'GasCostCapExceeded' | 'PriorityFeeCapExceeded'\n gasLimit: bigint\n requiredMaxFeePerGas: bigint\n requiredMaxPriorityFeePerGas: bigint\n maximumAffordableFeePerGas: bigint\n }) {\n super(\n `Vault transaction replacement blocked by ${code}: gasLimit=${gasLimit.toString()}, ` +\n `requiredMaxFeePerGas=${requiredMaxFeePerGas.toString()}, ` +\n `requiredMaxPriorityFeePerGas=${requiredMaxPriorityFeePerGas.toString()}, ` +\n `maximumAffordableFeePerGas=${maximumAffordableFeePerGas.toString()}`,\n )\n this.name = 'VaultTransactionReplacementLimitError'\n this.code = code\n this.requiredMaxFeePerGas = requiredMaxFeePerGas\n this.requiredMaxPriorityFeePerGas = requiredMaxPriorityFeePerGas\n this.maximumAffordableFeePerGas = maximumAffordableFeePerGas\n }\n}\n\ntype FeeHistorySnapshot = {\n baseFeePerGas: readonly bigint[]\n reward?: readonly (readonly bigint[])[] | undefined\n minimumPriorityFeePerGas?: bigint\n}\n\ntype FallbackFeeEstimate = {\n maxFeePerGas: bigint\n maxPriorityFeePerGas: bigint\n}\n\nfunction ceilMultiplyFraction(value: bigint, numerator: bigint, denominator: bigint): bigint {\n return (value * numerator + denominator - 1n) / denominator\n}\n\nfunction medianBigInt(values: readonly bigint[]): bigint | undefined {\n if (values.length === 0) return undefined\n const sorted = [...values].sort((left, right) => (left < right ? -1 : left > right ? 1 : 0))\n const upperMiddleIndex = Math.floor(sorted.length / 2)\n const upperMiddle = sorted[upperMiddleIndex]\n if (upperMiddle === undefined) return undefined\n if (sorted.length % 2 === 1) return upperMiddle\n const lowerMiddle = sorted[upperMiddleIndex - 1]\n return lowerMiddle === undefined ? undefined : (lowerMiddle + upperMiddle) / 2n\n}\n\nfunction getChainPriorityFeeFloor(chainId: number | undefined): bigint | undefined {\n return chainId === ROBINHOOD_CHAIN_ID ? 0n : undefined\n}\n\nfunction clampPriorityFee(\n priorityFee: bigint,\n minimumPriorityFeePerGas = MIN_VAULT_PRIORITY_FEE_PER_GAS,\n): bigint {\n if (priorityFee < minimumPriorityFeePerGas) return minimumPriorityFeePerGas\n if (priorityFee > MAX_VAULT_PRIORITY_FEE_PER_GAS) return MAX_VAULT_PRIORITY_FEE_PER_GAS\n return priorityFee\n}\n\nfunction resolveFeeHistoryQuote({\n baseFeePerGas,\n reward,\n minimumPriorityFeePerGas,\n}: {\n baseFeePerGas: readonly bigint[]\n reward?: readonly (readonly bigint[])[] | undefined\n minimumPriorityFeePerGas?: bigint\n}): VaultTransactionFeeQuote | null {\n // feeHistory includes one additional base fee for the next block. The\n // second-to-last entry is therefore the latest mined block's base fee.\n const latestBaseFeeIndex = baseFeePerGas.length - 2\n if (latestBaseFeeIndex < 0 || reward === undefined || reward.length === 0) return null\n\n const p90Rewards = reward.flatMap((blockRewards) => {\n const p90 = blockRewards[0]\n return p90 === undefined ? [] : [p90]\n })\n const sampledPriorityFee = medianBigInt(p90Rewards)\n if (sampledPriorityFee === undefined) return null\n\n const effectivePriorityFeeFloor = minimumPriorityFeePerGas ?? MIN_VAULT_PRIORITY_FEE_PER_GAS\n const maxPriorityFeePerGas = clampPriorityFee(sampledPriorityFee, effectivePriorityFeeFloor)\n const bufferedBaseFee = ceilMultiplyFraction(\n baseFeePerGas[latestBaseFeeIndex],\n BASE_FEE_BUFFER_NUMERATOR,\n BASE_FEE_BUFFER_DENOMINATOR,\n )\n\n return {\n currentBaseFeePerGas: baseFeePerGas[latestBaseFeeIndex],\n maxFeePerGas: bufferedBaseFee + maxPriorityFeePerGas,\n maxPriorityFeePerGas,\n minimumMaxFeePerGas: bufferedBaseFee + effectivePriorityFeeFloor,\n ...(minimumPriorityFeePerGas === undefined ? {} : { minimumPriorityFeePerGas }),\n source: 'fee_history',\n }\n}\n\nfunction resolveDeltaHedgeFeeHistoryQuote({\n baseFeePerGas,\n reward,\n minimumPriorityFeePerGas,\n}: FeeHistorySnapshot): VaultDeltaHedgeFeeQuote | null {\n const latestBaseFeeIndex = baseFeePerGas.length - 2\n if (latestBaseFeeIndex < 0 || reward === undefined || reward.length === 0) return null\n\n const p25Rewards = reward.flatMap((blockRewards) => {\n const p25 = blockRewards[0]\n return p25 === undefined ? [] : [p25]\n })\n const rawPriorityFeePerGas = medianBigInt(p25Rewards)\n if (rawPriorityFeePerGas === undefined) return null\n\n const effectivePriorityFeeFloor = minimumPriorityFeePerGas ?? MIN_VAULT_PRIORITY_FEE_PER_GAS\n const maxPriorityFeePerGas = clampPriorityFee(rawPriorityFeePerGas, effectivePriorityFeeFloor)\n const bufferedBaseFee = ceilMultiplyFraction(\n baseFeePerGas[latestBaseFeeIndex],\n BASE_FEE_BUFFER_NUMERATOR,\n BASE_FEE_BUFFER_DENOMINATOR,\n )\n return {\n maxFeePerGas: bufferedBaseFee + maxPriorityFeePerGas,\n maxPriorityFeePerGas,\n minimumMaxFeePerGas: bufferedBaseFee + effectivePriorityFeeFloor,\n ...(minimumPriorityFeePerGas === undefined ? {} : { minimumPriorityFeePerGas }),\n rawPriorityFeePerGas,\n source: 'fee_history_p25',\n }\n}\n\nfunction resolveRpcPriorityFeeQuote({\n baseFeePerGas,\n rawPriorityFeePerGas,\n minimumPriorityFeePerGas,\n}: {\n baseFeePerGas: bigint\n rawPriorityFeePerGas: bigint\n minimumPriorityFeePerGas?: bigint\n}): VaultDeltaHedgeFeeQuote {\n const bufferedBaseFee = ceilMultiplyFraction(\n baseFeePerGas,\n BASE_FEE_BUFFER_NUMERATOR,\n BASE_FEE_BUFFER_DENOMINATOR,\n )\n return {\n maxFeePerGas: bufferedBaseFee + rawPriorityFeePerGas,\n maxPriorityFeePerGas: rawPriorityFeePerGas,\n minimumMaxFeePerGas: bufferedBaseFee + (minimumPriorityFeePerGas ?? rawPriorityFeePerGas),\n ...(minimumPriorityFeePerGas === undefined ? {} : { minimumPriorityFeePerGas }),\n rawPriorityFeePerGas,\n source: 'rpc_priority_fee',\n }\n}\n\nexport function getVaultTransactionReplacementFeeQuote({\n originalQuote,\n historicalQuote,\n gasLimit,\n finalReplacement = false,\n staleBoundsReplacement = false,\n}: {\n originalQuote: Pick<VaultTransactionFeeQuote, 'maxFeePerGas' | 'maxPriorityFeePerGas'>\n historicalQuote: VaultDeltaHedgeFeeQuote\n gasLimit: bigint\n finalReplacement?: boolean\n staleBoundsReplacement?: boolean\n}): VaultDeltaHedgeFeeQuote {\n if (gasLimit <= 0n) {\n throw new Error(`Vault transaction gas limit must be positive, received ${gasLimit.toString()}`)\n }\n\n const bumpedPriorityFee = staleBoundsReplacement\n ? ceilMultiplyFraction(\n originalQuote.maxPriorityFeePerGas,\n REPLACEMENT_FEE_BUMP_NUMERATOR,\n REPLACEMENT_FEE_BUMP_DENOMINATOR,\n )\n : ceilMultiplyFraction(\n originalQuote.maxPriorityFeePerGas,\n DELTA_HEDGE_PRIORITY_FEE_BUMP_NUMERATOR,\n DELTA_HEDGE_PRIORITY_FEE_BUMP_DENOMINATOR,\n )\n const bumpedMaxFee = ceilMultiplyFraction(\n originalQuote.maxFeePerGas,\n REPLACEMENT_FEE_BUMP_NUMERATOR,\n REPLACEMENT_FEE_BUMP_DENOMINATOR,\n )\n const escalatingPriorityFee =\n historicalQuote.maxPriorityFeePerGas > bumpedPriorityFee\n ? historicalQuote.maxPriorityFeePerGas\n : bumpedPriorityFee\n const priorityFeeLimit = staleBoundsReplacement\n ? MAX_STALE_DELTA_HEDGE_PRIORITY_FEE_PER_GAS\n : finalReplacement\n ? MAX_VAULT_PRIORITY_FEE_PER_GAS\n : MAX_DELTA_HEDGE_PRIORITY_FEE_PER_GAS\n const desiredMaxPriorityFeePerGas = finalReplacement\n ? MAX_VAULT_PRIORITY_FEE_PER_GAS\n : staleBoundsReplacement\n ? bumpedPriorityFee\n : escalatingPriorityFee\n const requiredReplacementPriorityFee = ceilMultiplyFraction(\n originalQuote.maxPriorityFeePerGas,\n REPLACEMENT_FEE_BUMP_NUMERATOR,\n REPLACEMENT_FEE_BUMP_DENOMINATOR,\n )\n const requiredMaxPriorityFeePerGas =\n desiredMaxPriorityFeePerGas < priorityFeeLimit ? desiredMaxPriorityFeePerGas : priorityFeeLimit\n if (requiredMaxPriorityFeePerGas < requiredReplacementPriorityFee) {\n throw new VaultTransactionReplacementLimitError({\n code: 'PriorityFeeCapExceeded',\n gasLimit,\n requiredMaxFeePerGas: originalQuote.maxFeePerGas,\n requiredMaxPriorityFeePerGas: requiredReplacementPriorityFee,\n maximumAffordableFeePerGas: MAX_VAULT_TRANSACTION_GAS_COST / gasLimit,\n })\n }\n const bufferedBaseFee =\n historicalQuote.minimumMaxFeePerGas -\n (historicalQuote.minimumPriorityFeePerGas ?? MIN_VAULT_PRIORITY_FEE_PER_GAS)\n const currentMarketMaxFee = bufferedBaseFee + requiredMaxPriorityFeePerGas\n const desiredMaxFeePerGas =\n currentMarketMaxFee > bumpedMaxFee ? currentMarketMaxFee : bumpedMaxFee\n const maximumAffordableFeePerGas = MAX_VAULT_TRANSACTION_GAS_COST / gasLimit\n\n if (\n bumpedMaxFee > maximumAffordableFeePerGas ||\n requiredMaxPriorityFeePerGas > maximumAffordableFeePerGas\n ) {\n throw new VaultTransactionReplacementLimitError({\n code: 'GasCostCapExceeded',\n gasLimit,\n requiredMaxFeePerGas: bumpedMaxFee,\n requiredMaxPriorityFeePerGas,\n maximumAffordableFeePerGas,\n })\n }\n const maxFeePerGas =\n desiredMaxFeePerGas < maximumAffordableFeePerGas\n ? desiredMaxFeePerGas\n : maximumAffordableFeePerGas\n\n return {\n ...historicalQuote,\n maxFeePerGas,\n maxPriorityFeePerGas: requiredMaxPriorityFeePerGas,\n }\n}\n\nfunction resolveFallbackQuote({\n maxFeePerGas: estimatedMaxFeePerGas,\n maxPriorityFeePerGas: estimatedPriorityFeePerGas,\n minimumPriorityFeePerGas,\n}: {\n maxFeePerGas: bigint\n maxPriorityFeePerGas: bigint\n minimumPriorityFeePerGas?: bigint\n}): VaultTransactionFeeQuote {\n const effectivePriorityFeeFloor = minimumPriorityFeePerGas ?? MIN_VAULT_PRIORITY_FEE_PER_GAS\n const maxPriorityFeePerGas = clampPriorityFee(\n estimatedPriorityFeePerGas,\n effectivePriorityFeeFloor,\n )\n const estimatedBaseFeeAllowance =\n estimatedMaxFeePerGas > estimatedPriorityFeePerGas\n ? estimatedMaxFeePerGas - estimatedPriorityFeePerGas\n : 0n\n\n return {\n maxFeePerGas: estimatedBaseFeeAllowance + maxPriorityFeePerGas,\n maxPriorityFeePerGas,\n minimumMaxFeePerGas: estimatedBaseFeeAllowance + effectivePriorityFeeFloor,\n ...(minimumPriorityFeePerGas === undefined ? {} : { minimumPriorityFeePerGas }),\n source: 'viem_fallback',\n }\n}\n\nexport function applyVaultTransactionGasCostLimit(\n quote: VaultTransactionFeeQuote,\n gasLimit: bigint,\n): VaultTransactionFeeQuote {\n if (gasLimit <= 0n) {\n throw new Error(`Vault transaction gas limit must be positive, received ${gasLimit.toString()}`)\n }\n\n const maximumAffordableFeePerGas = MAX_VAULT_TRANSACTION_GAS_COST / gasLimit\n if (maximumAffordableFeePerGas < quote.minimumMaxFeePerGas) {\n throw new VaultTransactionGasCostLimitError({\n gasLimit,\n maximumAffordableFeePerGas,\n minimumRequiredFeePerGas: quote.minimumMaxFeePerGas,\n })\n }\n\n if (quote.maxFeePerGas <= maximumAffordableFeePerGas) return quote\n\n const bufferedBaseFee =\n quote.minimumMaxFeePerGas - (quote.minimumPriorityFeePerGas ?? MIN_VAULT_PRIORITY_FEE_PER_GAS)\n const affordablePriorityFee = maximumAffordableFeePerGas - bufferedBaseFee\n return {\n ...quote,\n maxFeePerGas: maximumAffordableFeePerGas,\n maxPriorityFeePerGas:\n quote.maxPriorityFeePerGas < affordablePriorityFee\n ? quote.maxPriorityFeePerGas\n : affordablePriorityFee,\n }\n}\n\nexport function bufferVaultTransactionGasEstimate(gasEstimate: bigint): bigint {\n if (gasEstimate <= 0n) {\n throw new Error(\n `Vault transaction gas estimate must be positive, received ${gasEstimate.toString()}`,\n )\n }\n return ceilMultiplyFraction(\n gasEstimate,\n GAS_ESTIMATE_BUFFER_NUMERATOR,\n GAS_ESTIMATE_BUFFER_DENOMINATOR,\n )\n}\n\nexport function validateVaultSignedTransactionFeeCaps(\n feeCaps: VaultSignedTransactionFeeCaps,\n quote?: VaultTransactionFeeQuote,\n): VaultSignedTransactionFeeValidationResult {\n const { chainId, gasLimit, maxFeePerGas, maxPriorityFeePerGas } = feeCaps\n const minimumPriorityFeePerGas =\n quote?.minimumPriorityFeePerGas ??\n getChainPriorityFeeFloor(chainId) ??\n MIN_VAULT_PRIORITY_FEE_PER_GAS\n if (maxFeePerGas === null || maxPriorityFeePerGas === null) {\n return {\n valid: false,\n code: 'MissingEip1559Fees',\n reason: 'Signed transaction must include EIP-1559 max fee and priority fee caps.',\n }\n }\n if (maxPriorityFeePerGas > maxFeePerGas) {\n return {\n valid: false,\n code: 'InvalidFeeCaps',\n reason:\n `Signed transaction maxPriorityFeePerGas (${maxPriorityFeePerGas.toString()} wei) ` +\n `cannot exceed maxFeePerGas (${maxFeePerGas.toString()} wei).`,\n }\n }\n if (maxPriorityFeePerGas < minimumPriorityFeePerGas) {\n return {\n valid: false,\n code: 'PriorityFeeTooLow',\n reason:\n `Signed transaction maxPriorityFeePerGas (${maxPriorityFeePerGas.toString()} wei) ` +\n `must be at least ${minimumPriorityFeePerGas.toString()} wei.`,\n }\n }\n if (maxPriorityFeePerGas > MAX_VAULT_PRIORITY_FEE_PER_GAS) {\n return {\n valid: false,\n code: 'PriorityFeeTooHigh',\n reason:\n `Signed transaction maxPriorityFeePerGas (${maxPriorityFeePerGas.toString()} wei) ` +\n `must not exceed ${MAX_VAULT_PRIORITY_FEE_PER_GAS.toString()} wei (3 gwei).`,\n }\n }\n if (\n gasLimit !== undefined &&\n gasLimit !== null &&\n gasLimit * maxFeePerGas > MAX_VAULT_TRANSACTION_GAS_COST\n ) {\n return {\n valid: false,\n code: 'GasCostTooHigh',\n reason:\n `Signed transaction maximum gas cost (${(gasLimit * maxFeePerGas).toString()} wei) ` +\n `must not exceed ${MAX_VAULT_TRANSACTION_GAS_COST.toString()} wei (0.015 ETH).`,\n }\n }\n if (quote !== undefined) {\n const feeRequirementDescription =\n quote.currentBaseFeePerGas === undefined ? 'buffered next-block base fee' : 'current base fee'\n const minimumBroadcastMaxFeePerGas =\n quote.currentBaseFeePerGas === undefined\n ? quote.minimumMaxFeePerGas\n : quote.currentBaseFeePerGas + minimumPriorityFeePerGas\n if (maxFeePerGas < minimumBroadcastMaxFeePerGas) {\n return {\n valid: false,\n code: 'MaxFeeTooLow',\n reason:\n `Signed transaction maxFeePerGas (${maxFeePerGas.toString()} wei) must be at least ` +\n `${minimumBroadcastMaxFeePerGas.toString()} wei for the ${feeRequirementDescription} ` +\n 'and configured minimum priority fee.',\n }\n }\n }\n return { valid: true }\n}\n\nasync function resolveVaultTransactionFeeQuote({\n readFeeHistory,\n readFallbackEstimate,\n minimumPriorityFeePerGas,\n}: {\n readFeeHistory: () => Promise<FeeHistorySnapshot>\n readFallbackEstimate: () => Promise<FallbackFeeEstimate>\n minimumPriorityFeePerGas?: bigint\n}): Promise<VaultTransactionFeeQuote> {\n let feeHistoryError: unknown\n try {\n const quote = resolveFeeHistoryQuote({\n ...(await readFeeHistory()),\n minimumPriorityFeePerGas,\n })\n if (quote !== null) return quote\n feeHistoryError = new Error('eth_feeHistory returned incomplete base fee or reward data')\n } catch (error) {\n feeHistoryError = error\n }\n\n try {\n return resolveFallbackQuote({\n ...(await readFallbackEstimate()),\n minimumPriorityFeePerGas,\n })\n } catch (fallbackError) {\n throw new VaultTransactionFeeEstimationError({ feeHistoryError, fallbackError })\n }\n}\n\n/**\n * Resolve explicit EIP-1559 fees for operator-controlled vault transactions.\n *\n * The normal path follows the median p90 priority fee from the last 20 blocks,\n * with a 3 gwei ceiling and a 0.1 gwei floor except on chains that do not use\n * tips for ordering. If fee history is unavailable, Viem's estimate is used\n * while preserving those bounds and its original base-fee allowance.\n */\nexport async function getVaultTransactionFeeQuote<chain extends Chain | undefined>(\n client: Client<Transport, chain>,\n): Promise<VaultTransactionFeeQuote> {\n return resolveVaultTransactionFeeQuote({\n minimumPriorityFeePerGas: getChainPriorityFeeFloor(client.chain?.id),\n readFeeHistory: () =>\n getFeeHistory(client, {\n blockCount: FEE_HISTORY_BLOCK_COUNT,\n blockTag: 'latest',\n rewardPercentiles: FEE_HISTORY_REWARD_PERCENTILES,\n }),\n readFallbackEstimate: () => estimateFeesPerGas(client),\n })\n}\n\nexport async function getVaultDeltaHedgeHistoricalFeeQuote<chain extends Chain | undefined>(\n client: Client<Transport, chain>,\n): Promise<VaultDeltaHedgeFeeQuote> {\n const feeHistory = await getFeeHistory(client, {\n blockCount: FEE_HISTORY_BLOCK_COUNT,\n blockTag: 'latest',\n rewardPercentiles: DELTA_HEDGE_FEE_HISTORY_REWARD_PERCENTILES,\n })\n const quote = resolveDeltaHedgeFeeHistoryQuote({\n ...feeHistory,\n minimumPriorityFeePerGas: getChainPriorityFeeFloor(client.chain?.id),\n })\n if (quote === null) {\n throw new Error('eth_feeHistory returned incomplete p25 base fee or reward data')\n }\n return quote\n}\n\nasync function resolveVaultDeltaHedgeInitialFeeQuote({\n readRpcQuote,\n readHistoricalQuote,\n minimumPriorityFeePerGas,\n}: {\n readRpcQuote: () => Promise<{ baseFeePerGas: bigint; rawPriorityFeePerGas: bigint }>\n readHistoricalQuote: () => Promise<VaultDeltaHedgeFeeQuote>\n minimumPriorityFeePerGas?: bigint\n}): Promise<VaultDeltaHedgeFeeQuote> {\n try {\n return resolveRpcPriorityFeeQuote({\n ...(await readRpcQuote()),\n minimumPriorityFeePerGas,\n })\n } catch {\n return readHistoricalQuote()\n }\n}\n\n/**\n * Resolve the first fee quote for a delta hedge from the connected RPC's\n * eth_maxPriorityFeePerGas recommendation. A failed RPC recommendation falls\n * back immediately to the rolling historical p25 quote.\n */\nexport async function getVaultDeltaHedgeInitialFeeQuote<chain extends Chain | undefined>(\n client: Client<Transport, chain>,\n): Promise<VaultDeltaHedgeFeeQuote> {\n return resolveVaultDeltaHedgeInitialFeeQuote({\n minimumPriorityFeePerGas: getChainPriorityFeeFloor(client.chain?.id),\n readRpcQuote: async () => {\n const [rawPriorityFee, latestBlock] = await Promise.all([\n client.request({ method: 'eth_maxPriorityFeePerGas' }),\n getBlock(client, { blockTag: 'latest' }),\n ])\n if (latestBlock.baseFeePerGas === null) {\n throw new Error('Latest block does not include an EIP-1559 base fee')\n }\n return {\n baseFeePerGas: latestBlock.baseFeePerGas,\n rawPriorityFeePerGas: hexToBigInt(rawPriorityFee),\n }\n },\n readHistoricalQuote: () => getVaultDeltaHedgeHistoricalFeeQuote(client),\n })\n}\n\nexport const __transactionFeeTestUtils = {\n clampPriorityFee,\n getChainPriorityFeeFloor,\n resolveDeltaHedgeFeeHistoryQuote,\n resolveFallbackQuote,\n resolveFeeHistoryQuote,\n resolveRpcPriorityFeeQuote,\n resolveVaultDeltaHedgeInitialFeeQuote,\n resolveVaultTransactionFeeQuote,\n}\n"],"mappings":";;;;SACO;CACH,WAAW;CACX,kBAAkB;EAChB,oBAAoB;EACpB,eAAe;EACf,aAAa;CACd;CACD,aAAa;EACX,QAAQ;GACN,2BAA2B;GAC3B,WAAW;GACX,cAAc;GACd,kBAAkB;GAClB,wCAAwC;EACzC;EACD,UAAU;GACR,gBAAgB;GAChB,gBAAgB;EACjB;EACD,YAAY;GACV,uBAAuB;GACvB,uBAAuB;EACxB;EACD,kBAAkB;GAChB,uBAAuB;GACvB,uBAAuB;EACxB;CACF;CACD,YAAY;EACV,QAAQ;GACN,WAAW;GACX,gBAAgB;GAChB,sBAAsB;GACtB,sBAAsB;EACvB;EACD,mBAAmB;GACjB,iBAAiB;IACf,WAAW;IACX,gBAAgB;IAChB,sBAAsB;IACtB,sBAAsB;GACvB;GACD,4BAA4B;IAC1B,WAAW;IACX,gBAAgB;IAChB,sBAAsB;IACtB,sBAAsB;IACtB,cAAc;IACd,mBAAmB;GACpB;EACF;EACD,MAAM;GACJ,iCAAiC;GACjC,iCAAiC;GACjC,kBAAkB;GAClB,cAAc;GACd,8BAA8B;GAC9B,mCAAmC;GACnC,qBAAqB;GACrB,qBAAqB;GACrB,kBAAkB;GAClB,gBAAgB;GAChB,iBAAiB;GACjB,qBAAqB;EACtB;CACF;CACD,eAAe,CACb,8CACA,4CACD;CACD,WAAW,EACT,gBAAgB;EACd,aAAa;EACb,aAAa;EACb,OAAO;EACP,eAAe;EACf,UAAU;CACX,EACF;CACD,aAAa;EACX,aAAa;EACb,YAAY;CACb;CACD,YAAY;EACV,WAAW;EACX,QAAQ;EACR,eAAe;EACf,UAAU;EACV,OAAO;EACP,QAAQ;CACT;CACD,yBAAyB;EACvB;EACA;EACA;EACA;CACD;AACF;YACO;CACN,WAAW;CACX,kBAAkB;EAChB,oBAAoB;EACpB,eAAe;EACf,aAAa;CACd;CACD,aAAa;EACX,QAAQ;GACN,2BAA2B;GAC3B,WAAW;GACX,cAAc;GACd,kBAAkB;GAClB,wCAAwC;EACzC;EACD,UAAU;GACR,gBAAgB;GAChB,gBAAgB;GAChB,gBAAgB;EACjB;EACD,YAAY;GACV,uBAAuB;GACvB,uBAAuB;GACvB,uBAAuB;EACxB;EACD,kBAAkB;GAChB,uBAAuB;GACvB,uBAAuB;GACvB,uBAAuB;EACxB;CACF;CACD,YAAY;EACV,QAAQ;GACN,WAAW;GACX,gBAAgB;GAChB,sBAAsB;GACtB,sBAAsB;EACvB;EACD,mBAAmB;GACjB,kBAAkB;IAChB,WAAW;IACX,gBAAgB;IAChB,sBAAsB;IACtB,sBAAsB;GACvB;GACD,iBAAiB;IACf,WAAW;IACX,gBAAgB;IAChB,sBAAsB;IACtB,sBAAsB;GACvB;GACD,4BAA4B;IAC1B,WAAW;IACX,gBAAgB;IAChB,sBAAsB;IACtB,sBAAsB;IACtB,cAAc;IACd,mBAAmB;GACpB;EACF;EACD,MAAM;GACJ,iCAAiC;GACjC,iCAAiC;GACjC,kBAAkB;GAClB,cAAc;GACd,8BAA8B;GAC9B,mCAAmC;GACnC,qBAAqB;GACrB,qBAAqB;GACrB,kBAAkB;GAClB,gBAAgB;GAChB,iBAAiB;GACjB,qBAAqB;EACtB;CACF;CACD,eAAe,CACb,8CACA,4CACD;CACD,WAAW;EACT,WAAW;GACT,aAAa;GACb,aAAa;GACb,OAAO;GACP,eAAe;GACf,UAAU;EACX;EACD,gBAAgB;GACd,aAAa;GACb,aAAa;GACb,OAAO;GACP,eAAe;GACf,UAAU;EACX;EACD,eAAe;GACb,aAAa;GACb,aAAa;GACb,OAAO;GACP,eAAe;GACf,UAAU;EACX;CACF;CACD,aAAa;EACX,aAAa;EACb,YAAY;CACb;CACD,yBAAyB;EACvB;EACA;EACA;EACA;CACD;AACF;YACO;CACN,WAAW;CACX,kBAAkB;EAChB,oBAAoB;EACpB,eAAe;EACf,aAAa;CACd;CACD,aAAa;EACX,QAAQ;GACN,2BAA2B;GAC3B,WAAW;GACX,cAAc;GACd,kBAAkB;GAClB,wCAAwC;EACzC;EACD,UAAU;GACR,gBAAgB;GAChB,gBAAgB;EACjB;EACD,YAAY;GACV,uBAAuB;GACvB,uBAAuB;EACxB;EACD,kBAAkB;GAChB,uBAAuB;GACvB,uBAAuB;EACxB;CACF;CACD,YAAY;EACV,QAAQ;GACN,WAAW;GACX,gBAAgB;GAChB,sBAAsB;GACtB,sBAAsB;EACvB;EACD,MAAM;GACJ,iCAAiC;GACjC,iCAAiC;GACjC,kBAAkB;GAClB,cAAc;GACd,8BAA8B;GAC9B,mCAAmC;GACnC,qBAAqB;GACrB,qBAAqB;GACrB,kBAAkB;GAClB,gBAAgB;GAChB,iBAAiB;GACjB,qBAAqB;EACtB;CACF;CACD,eAAe,CACb,4CACD;CACD,WAAW,EACT,eAAe;EACb,aAAa;EACb,aAAa;EACb,OAAO;EACP,eAAe;EACf,UAAU;CACX,EACF;CACD,aAAa;EACX,aAAa;EACb,YAAY;CACb;AACF;gBACW;CACV,WAAW;CACX,kBAAkB;EAChB,oBAAoB;EACpB,eAAe;EACf,aAAa;CACd;CACD,aAAa;EACX,QAAQ;GACN,2BAA2B;GAC3B,WAAW;GACX,cAAc;GACd,kBAAkB;GAClB,wCAAwC;EACzC;EACD,UAAU;GACR,gBAAgB;GAChB,gBAAgB;EACjB;EACD,YAAY;GACV,uBAAuB;GACvB,uBAAuB;EACxB;EACD,kBAAkB;GAChB,uBAAuB;GACvB,uBAAuB;EACxB;CACF;CACD,YAAY;EACV,QAAQ;GACN,WAAW;GACX,gBAAgB;GAChB,sBAAsB;GACtB,sBAAsB;EACvB;EACD,MAA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