@panoptic-eng/sdk 1.0.34 → 1.0.36

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -15191,11 +15191,11 @@ const UsdcPlpVaultBaseProdConfig = {
15191
15191
 
15192
15192
  //#endregion
15193
15193
  //#region src/hypoVault/hypoVaultManagerConfigs/usdcPlpVaultMainnetProdConfig.ts
15194
- const MAINNET_DEPLOYMENT$5 = requireChainDeployment(MAINNET_CHAIN_ID);
15195
- const MAINNET_ETH_USDC_MARKET = getEthUsdcMarket(MAINNET_DEPLOYMENT$5);
15196
- const MAINNET_HYPOVAULT_ADDRESSES$1 = MAINNET_DEPLOYMENT$5.hypovault.vaults;
15197
- const MAINNET_HYPOVAULT_MANAGER_ADDRESSES$1 = MAINNET_DEPLOYMENT$5.hypovault.managers;
15198
- const MAINNET_PANOPTIC_POOL_ADDRESSES$1 = MAINNET_DEPLOYMENT$5.panoptic.pool;
15194
+ const MAINNET_DEPLOYMENT$6 = requireChainDeployment(MAINNET_CHAIN_ID);
15195
+ const MAINNET_ETH_USDC_MARKET = getEthUsdcMarket(MAINNET_DEPLOYMENT$6);
15196
+ const MAINNET_HYPOVAULT_ADDRESSES$1 = MAINNET_DEPLOYMENT$6.hypovault.vaults;
15197
+ const MAINNET_HYPOVAULT_MANAGER_ADDRESSES$1 = MAINNET_DEPLOYMENT$6.hypovault.managers;
15198
+ const MAINNET_PANOPTIC_POOL_ADDRESSES$1 = MAINNET_DEPLOYMENT$6.panoptic.pool;
15199
15199
  const MAINNET_LEGACY_PANOPTIC_POOL_ADDRESSES$1 = {
15200
15200
  panopticPool: "0x000000007588B488d180899cDEa2080a886D2441",
15201
15201
  collateralTracker0: "0x6cd0186Fb4c32B6fD23279bBE0022506958216f9",
@@ -15353,10 +15353,10 @@ const WethPlpVaultBaseProdConfig = {
15353
15353
 
15354
15354
  //#endregion
15355
15355
  //#region src/hypoVault/hypoVaultManagerConfigs/wethPlpVaultMainnetProdConfig.ts
15356
- const MAINNET_DEPLOYMENT$4 = requireChainDeployment(MAINNET_CHAIN_ID);
15357
- const MAINNET_HYPOVAULT_ADDRESSES = MAINNET_DEPLOYMENT$4.hypovault.vaults;
15358
- const MAINNET_HYPOVAULT_MANAGER_ADDRESSES = MAINNET_DEPLOYMENT$4.hypovault.managers;
15359
- const MAINNET_PANOPTIC_POOL_ADDRESSES = MAINNET_DEPLOYMENT$4.panoptic.pool;
15356
+ const MAINNET_DEPLOYMENT$5 = requireChainDeployment(MAINNET_CHAIN_ID);
15357
+ const MAINNET_HYPOVAULT_ADDRESSES = MAINNET_DEPLOYMENT$5.hypovault.vaults;
15358
+ const MAINNET_HYPOVAULT_MANAGER_ADDRESSES = MAINNET_DEPLOYMENT$5.hypovault.managers;
15359
+ const MAINNET_PANOPTIC_POOL_ADDRESSES = MAINNET_DEPLOYMENT$5.panoptic.pool;
15360
15360
  const MAINNET_LEGACY_PANOPTIC_POOL_ADDRESSES = {
15361
15361
  panopticPool: "0x000000007588B488d180899cDEa2080a886D2441",
15362
15362
  collateralTracker0: "0x6cd0186Fb4c32B6fD23279bBE0022506958216f9",
@@ -15503,11 +15503,11 @@ function getHypoVaultConfigForVault(vaultAddress, chainId, options) {
15503
15503
  //#region src/hypoVault/hypoVaultManagerArtifacts/poolInfosConfig.ts
15504
15504
  const SEPOLIA_DEPLOYMENT$1 = requireChainDeployment(SEPOLIA_CHAIN_ID);
15505
15505
  const BASE_DEPLOYMENT$1 = requireChainDeployment(BASE_CHAIN_ID);
15506
- const MAINNET_DEPLOYMENT$3 = requireChainDeployment(MAINNET_CHAIN_ID);
15506
+ const MAINNET_DEPLOYMENT$4 = requireChainDeployment(MAINNET_CHAIN_ID);
15507
15507
  const MAX_PRICE_DEVIATION = 100;
15508
15508
  const WSPCXX_USDC_MAX_PRICE_DEVIATION = 1e4;
15509
15509
  const DEFAULT_TRIGGER_TICK = 150;
15510
- const MAINNET_ETH_USDC_5BPS_V3_POOL = MAINNET_DEPLOYMENT$3.panoptic.additionalPools?.ethUsdc5bpsV3;
15510
+ const MAINNET_ETH_USDC_5BPS_V3_POOL = MAINNET_DEPLOYMENT$4.panoptic.additionalPools?.ethUsdc5bpsV3;
15511
15511
  if (MAINNET_ETH_USDC_5BPS_V3_POOL === void 0) throw new Error("Missing mainnet ETH/USDC 5bps v3 Panoptic pool deployment");
15512
15512
  const MAINNET_ETH_USDC_5BPS_V3_POOL_INFO = {
15513
15513
  maxPriceDeviation: MAX_PRICE_DEVIATION,
@@ -15531,9 +15531,9 @@ const BASE_DEFAULT_POOL_INFOS = [{
15531
15531
  const BASE_VAULT_ADDRESSES = BASE_DEPLOYMENT$1.hypovault.vaults;
15532
15532
  const MAINNET_DEFAULT_POOL_INFOS = [{
15533
15533
  maxPriceDeviation: MAX_PRICE_DEVIATION,
15534
- pool: MAINNET_DEPLOYMENT$3.panoptic.pool.panopticPool,
15535
- token0: getEthUsdcMarket(MAINNET_DEPLOYMENT$3).currency0,
15536
- token1: getEthUsdcMarket(MAINNET_DEPLOYMENT$3).currency1
15534
+ pool: MAINNET_DEPLOYMENT$4.panoptic.pool.panopticPool,
15535
+ token0: getEthUsdcMarket(MAINNET_DEPLOYMENT$4).currency0,
15536
+ token1: getEthUsdcMarket(MAINNET_DEPLOYMENT$4).currency1
15537
15537
  }, MAINNET_ETH_USDC_5BPS_V3_POOL_INFO];
15538
15538
  const MAINNET_USDC_PLP_POOL_INFOS = [
15539
15539
  MAINNET_DEFAULT_POOL_INFOS[0],
@@ -15548,10 +15548,10 @@ const MAINNET_USDC_PLP_POOL_INFOS = [
15548
15548
  const MAINNET_LEGACY_DEFAULT_POOL_INFOS = [{
15549
15549
  maxPriceDeviation: MAX_PRICE_DEVIATION,
15550
15550
  pool: "0x000000007588B488d180899cDEa2080a886D2441",
15551
- token0: getEthUsdcMarket(MAINNET_DEPLOYMENT$3).currency0,
15552
- token1: getEthUsdcMarket(MAINNET_DEPLOYMENT$3).currency1
15551
+ token0: getEthUsdcMarket(MAINNET_DEPLOYMENT$4).currency0,
15552
+ token1: getEthUsdcMarket(MAINNET_DEPLOYMENT$4).currency1
15553
15553
  }];
15554
- const MAINNET_VAULT_ADDRESSES = MAINNET_DEPLOYMENT$3.hypovault.vaults;
15554
+ const MAINNET_VAULT_ADDRESSES = MAINNET_DEPLOYMENT$4.hypovault.vaults;
15555
15555
  const MAINNET_LEGACY_VAULT_ADDRESSES = {
15556
15556
  wethPlpVault: "0x779a2aa634A004b3a3f3b322083744869BBC6D66",
15557
15557
  usdcPlpVault: "0x963Fe9c93bc353602656ee4051A75114bA74d6c5"
@@ -15589,7 +15589,7 @@ const MainnetUSDCPLPVaultPoolInfos = {
15589
15589
  /** Production accountant input before the ETH/USDC 5bps v3 pool authorization executes. */
15590
15590
  const MainnetUSDCPLPPreviousVaultPoolInfos = {
15591
15591
  vaultAddress: MAINNET_VAULT_ADDRESSES.usdcPlpVault,
15592
- poolInfos: MAINNET_USDC_PLP_POOL_INFOS.slice(0, 2).map((poolInfo) => ({
15592
+ poolInfos: MAINNET_USDC_PLP_POOL_INFOS.filter((poolInfo) => poolInfo.pool !== MAINNET_ETH_USDC_5BPS_V3_POOL_INFO.pool).map((poolInfo) => ({
15593
15593
  ...poolInfo,
15594
15594
  triggerTick: DEFAULT_TRIGGER_TICK
15595
15595
  }))
@@ -15648,735 +15648,250 @@ const SepoliaWETHPLPVaultPoolInfos = {
15648
15648
  };
15649
15649
 
15650
15650
  //#endregion
15651
- //#region src/hypoVault/hypoVaultManagerArtifacts/createStrategistLeavesArtifact.ts
15652
- const DIGEST_COMPOSITION = [
15653
- "Bytes20(DECODER_AND_SANITIZER_ADDRESS)",
15654
- "Bytes20(TARGET_ADDRESS)",
15655
- "Bytes1(CAN_SEND_VALUE)",
15656
- "Bytes4(TARGET_FUNCTION_SELECTOR)",
15657
- "Bytes{N*20}(ADDRESS_ARGUMENT_0,...,ADDRESS_ARGUMENT_N)"
15658
- ];
15659
- const EMPTY_DEFINITION = {
15660
- description: "",
15661
- target: zeroAddress,
15662
- functionSignature: "",
15663
- addressArguments: [],
15664
- canSendValue: false
15651
+ //#region src/hypoVault/mainnetVaultPoolHistory.ts
15652
+ const MAINNET_DEPLOYMENT$3 = requireChainDeployment(MAINNET_CHAIN_ID);
15653
+ const POOL_INFO_ARRAY_ABI$1 = {
15654
+ type: "tuple[]",
15655
+ components: [
15656
+ {
15657
+ name: "pool",
15658
+ type: "address"
15659
+ },
15660
+ {
15661
+ name: "token0",
15662
+ type: "address"
15663
+ },
15664
+ {
15665
+ name: "token1",
15666
+ type: "address"
15667
+ },
15668
+ {
15669
+ name: "maxPriceDeviation",
15670
+ type: "int24"
15671
+ }
15672
+ ]
15665
15673
  };
15666
- function efficientHash$1(a, b) {
15667
- return keccak256(encodePacked(["bytes32", "bytes32"], a < b ? [a, b] : [b, a]));
15668
- }
15669
- function nextPowerOfTwo(value) {
15670
- let capacity = 1;
15671
- while (capacity < value) capacity *= 2;
15672
- return capacity;
15673
- }
15674
- function functionSelector(signature) {
15675
- return keccak256(toBytes(signature)).slice(0, 10);
15674
+ function hashPoolInfos$1(poolInfos) {
15675
+ return keccak256(encodeAbiParameters([POOL_INFO_ARRAY_ABI$1], [poolInfos.map((poolInfo) => ({
15676
+ pool: getAddress(poolInfo.pool),
15677
+ token0: getAddress(poolInfo.token0),
15678
+ token1: getAddress(poolInfo.token1),
15679
+ maxPriceDeviation: poolInfo.maxPriceDeviation
15680
+ }))]));
15676
15681
  }
15677
- function buildLeaf(definition, decoderAndSanitizerAddress) {
15678
- const selector = functionSelector(definition.functionSignature);
15679
- const packedArgumentAddresses = definition.addressArguments.length === 0 ? "0x" : concat(definition.addressArguments.map((address) => getAddress(address)));
15680
- const rawDigest = concat([encodePacked([
15681
- "address",
15682
- "address",
15683
- "bool",
15684
- "bytes4"
15685
- ], [
15686
- getAddress(decoderAndSanitizerAddress),
15687
- getAddress(definition.target),
15688
- definition.canSendValue,
15689
- selector
15690
- ]), packedArgumentAddresses]);
15682
+ function poolConfiguration(activationBlockNumber, transactionHash, poolInfos) {
15691
15683
  return {
15692
- AddressArguments: definition.addressArguments,
15693
- CanSendValue: definition.canSendValue,
15694
- DecoderAndSanitizerAddress: getAddress(decoderAndSanitizerAddress),
15695
- Description: definition.description,
15696
- FunctionSelector: selector,
15697
- FunctionSignature: definition.functionSignature,
15698
- LeafDigest: keccak256(rawDigest),
15699
- PackedArgumentAddresses: packedArgumentAddresses,
15700
- TargetAddress: getAddress(definition.target)
15684
+ activationBlockNumber,
15685
+ transactionHash,
15686
+ poolInfos,
15687
+ poolHash: hashPoolInfos$1(poolInfos)
15701
15688
  };
15702
15689
  }
15703
- function buildMerkleTree(leafDigests) {
15704
- if (leafDigests.length === 0) throw new Error("Strategist Merkle tree requires at least one leaf digest");
15705
- const layersFromLeaves = [[...leafDigests]];
15706
- while (layersFromLeaves[layersFromLeaves.length - 1]?.length !== 1) {
15707
- const currentLayer = layersFromLeaves[layersFromLeaves.length - 1];
15708
- if (currentLayer === void 0 || currentLayer.length % 2 !== 0) throw new Error("Strategist Merkle tree layers must contain an even number of nodes");
15709
- const parentLayer = [];
15710
- for (let index = 0; index < currentLayer.length; index += 2) {
15711
- const left = currentLayer[index];
15712
- const right = currentLayer[index + 1];
15713
- if (left === void 0 || right === void 0) throw new Error("Strategist Merkle tree contains an incomplete pair");
15714
- parentLayer.push(efficientHash$1(left, right));
15690
+ const wethInitialPoolInfos = MainnetWETHPLPPreviousVaultPoolInfos.poolInfos;
15691
+ const usdcInitialPoolInfos = MainnetUSDCPLPPreviousVaultPoolInfos.poolInfos.slice(0, 1);
15692
+ const usdcTwoPoolInitialDeviation = MainnetUSDCPLPPreviousVaultPoolInfos.poolInfos.map((poolInfo, index) => index === 1 ? {
15693
+ ...poolInfo,
15694
+ maxPriceDeviation: 100
15695
+ } : poolInfo);
15696
+ /**
15697
+ * Mainnet production vault authorization history reconstructed from:
15698
+ * - every `updateHashes` call into the accountant (transaction traces), and
15699
+ * - every `ManageRootUpdated` event for each production strategist.
15700
+ *
15701
+ * Manager roots are retained as audit metadata. `computeNAV` only consumes the
15702
+ * accountant pool configuration, so share-price reconstruction deliberately
15703
+ * does not require historical Merkle leaves.
15704
+ */
15705
+ const MAINNET_VAULT_HISTORIES = [{
15706
+ vaultAddress: MAINNET_DEPLOYMENT$3.hypovault.vaults.wethPlpVault,
15707
+ poolConfigurations: [poolConfiguration(25296753n, "0xdb7ed1d63d3f3b158fca070bdbf8d0268ed8e5c398cae772a1facb40987a838e", wethInitialPoolInfos), poolConfiguration(25704951n, "0xb6d62abb10728655c4c9b612abcd82af9e93c5906357eb6be41cabb224b32118", MainnetWETHPLPVaultPoolInfos.poolInfos)],
15708
+ managerRootTransitions: [
15709
+ {
15710
+ activationBlockNumber: 25296743n,
15711
+ transactionHash: "0xe809d2b0d67da62888967ba15b75168154b1dfe3036f9d7801ce4c2589091226",
15712
+ manageRoot: "0xcd0defea21f2f5625ba2d231bce9500ad31a12181821c3e44a9eab8091726ef9"
15713
+ },
15714
+ {
15715
+ activationBlockNumber: 25303785n,
15716
+ transactionHash: "0xa4deca842f0ce6ed3f95eecc07820869466349df2af78f5d4d9a3b5fac2867b1",
15717
+ manageRoot: "0x14c4c96cc3730452ce71a447bdde6132f81acec862098a9ddd5e086805046a07"
15718
+ },
15719
+ {
15720
+ activationBlockNumber: 25704951n,
15721
+ transactionHash: "0xb6d62abb10728655c4c9b612abcd82af9e93c5906357eb6be41cabb224b32118",
15722
+ manageRoot: "0x4d2fb008ac93d2a363881e31e65f31bacbefef39efb44cf2f95b65cf49c65c7d"
15715
15723
  }
15716
- layersFromLeaves.push(parentLayer);
15717
- }
15718
- return Object.fromEntries([...layersFromLeaves].reverse().map((layer, index) => [String(index), layer]));
15724
+ ]
15725
+ }, {
15726
+ vaultAddress: MAINNET_DEPLOYMENT$3.hypovault.vaults.usdcPlpVault,
15727
+ poolConfigurations: [
15728
+ poolConfiguration(25296798n, "0x37f7ea4ec78c071b6301576745b22f411ac729363fab4202213c7191d89f48c6", usdcInitialPoolInfos),
15729
+ poolConfiguration(25332015n, "0xbe29b782e3aab5cb28476248ff4f5ea67cb6adc16bb5488ec7a1a27f07e59752", usdcTwoPoolInitialDeviation),
15730
+ poolConfiguration(25332931n, "0xb0cc8525abcf3c507eb46e8654250cc67e500886f031adec8cfb5b0baf7c2028", MainnetUSDCPLPPreviousVaultPoolInfos.poolInfos),
15731
+ poolConfiguration(25704951n, "0xb6d62abb10728655c4c9b612abcd82af9e93c5906357eb6be41cabb224b32118", MainnetUSDCPLPVaultPoolInfos.poolInfos)
15732
+ ],
15733
+ managerRootTransitions: [
15734
+ {
15735
+ activationBlockNumber: 25296786n,
15736
+ transactionHash: "0x76ffd4204aa7ce84195d22254d0450f1438656d1da034d54ac267c2636b0a06d",
15737
+ manageRoot: "0xe00ec1dbc941e12239b487765793e966350d795b11092d1cfbcb894be46c40d4"
15738
+ },
15739
+ {
15740
+ activationBlockNumber: 25303784n,
15741
+ transactionHash: "0xea67b8b3ab2cdee17ec79f7d59268468dd7b91774d318f219e5b405246617293",
15742
+ manageRoot: "0x215542d18c9cf442c62bc3a06dbe8d8d9bc893e5d97e70b675e5c8b1721c6e29"
15743
+ },
15744
+ {
15745
+ activationBlockNumber: 25332022n,
15746
+ transactionHash: "0xec02bfbfaa10325189ca751d2cf2412b6004910e65f43d40418bd0e12e7c40d1",
15747
+ manageRoot: "0xed7d4ae055fd62c6edc93bd676456748f52fe4f4b78f60ab3ef6394bacc31b5d"
15748
+ },
15749
+ {
15750
+ activationBlockNumber: 25704951n,
15751
+ transactionHash: "0xb6d62abb10728655c4c9b612abcd82af9e93c5906357eb6be41cabb224b32118",
15752
+ manageRoot: "0x3223880461fe3e61dc96d9d81579ae943507ec95f17cba100b462cec53967e14"
15753
+ }
15754
+ ]
15755
+ }];
15756
+ function copyPoolConfiguration(configuration) {
15757
+ return {
15758
+ ...configuration,
15759
+ poolInfos: configuration.poolInfos.map((poolInfo) => ({ ...poolInfo }))
15760
+ };
15719
15761
  }
15720
- function createStrategistLeavesArtifact(metadata, definitions) {
15721
- if (definitions.length === 0) throw new Error("Strategist artifact requires at least one permission leaf");
15722
- const treeCapacity = nextPowerOfTwo(definitions.length);
15723
- const leafs = definitions.map((definition) => buildLeaf(definition, metadata.decoderAndSanitizerAddress));
15724
- const emptyLeaf = buildLeaf(EMPTY_DEFINITION, zeroAddress);
15725
- while (leafs.length < treeCapacity) leafs.push(emptyLeaf);
15726
- const merkleTree = buildMerkleTree(leafs.map((leaf) => leaf.LeafDigest));
15727
- const root = merkleTree["0"]?.[0];
15728
- if (root === void 0) throw new Error("Strategist Merkle tree root was not generated");
15762
+ function copyManagerRootTransition(transition) {
15763
+ return { ...transition };
15764
+ }
15765
+ function copyHistory(history) {
15729
15766
  return {
15730
- metadata: {
15731
- AccountantAddress: getAddress(metadata.accountantAddress),
15732
- BoringVaultAddress: getAddress(metadata.boringVaultAddress),
15733
- DecoderAndSanitizerAddress: getAddress(metadata.decoderAndSanitizerAddress),
15734
- DigestComposition: DIGEST_COMPOSITION,
15735
- LeafCount: definitions.length,
15736
- ManageRoot: root,
15737
- ManagerAddress: getAddress(metadata.managerAddress),
15738
- TreeCapacity: treeCapacity
15739
- },
15740
- leafs,
15741
- MerkleTree: merkleTree
15767
+ ...history,
15768
+ poolConfigurations: history.poolConfigurations.map(copyPoolConfiguration),
15769
+ managerRootTransitions: history.managerRootTransitions.map(copyManagerRootTransition)
15742
15770
  };
15743
15771
  }
15772
+ function findHistory(chainId, vaultAddress) {
15773
+ if (chainId !== MAINNET_CHAIN_ID) return null;
15774
+ const normalizedVault = vaultAddress.toLowerCase();
15775
+ const history = MAINNET_VAULT_HISTORIES.find((candidate) => candidate.vaultAddress.toLowerCase() === normalizedVault);
15776
+ return history === void 0 ? null : copyHistory(history);
15777
+ }
15778
+ function latestAtBlock(values, blockNumber) {
15779
+ for (let index = values.length - 1; index >= 0; index -= 1) {
15780
+ const value = values[index];
15781
+ if (value !== void 0 && blockNumber >= value.activationBlockNumber) return { ...value };
15782
+ }
15783
+ return null;
15784
+ }
15785
+ function getMainnetVaultPoolConfigurationAtBlock({ chainId, vaultAddress, blockNumber }) {
15786
+ const history = findHistory(chainId, vaultAddress);
15787
+ return history === null ? null : latestAtBlock(history.poolConfigurations, blockNumber);
15788
+ }
15789
+ function getMainnetVaultManagerRootAtBlock({ chainId, vaultAddress, blockNumber }) {
15790
+ const history = findHistory(chainId, vaultAddress);
15791
+ return history === null ? null : latestAtBlock(history.managerRootTransitions, blockNumber);
15792
+ }
15793
+ function getMainnetVaultPoolConfigurationHistory({ chainId, vaultAddress }) {
15794
+ return findHistory(chainId, vaultAddress)?.poolConfigurations ?? null;
15795
+ }
15796
+ function getMainnetVaultManagerRootHistory({ chainId, vaultAddress }) {
15797
+ return findHistory(chainId, vaultAddress)?.managerRootTransitions ?? null;
15798
+ }
15744
15799
 
15745
15800
  //#endregion
15746
- //#region src/hypoVault/hypoVaultManagerArtifacts/MainnetUSDCPLPStrategistLeaves.ts
15747
- const VAULT$1 = "0x236d0558f06cd60780b232d4Ec4c92d2cb7e4D18";
15748
- const DECODER$1 = "0xC87c45d2dbE5acb56013e2591427ECC84Fa251E6";
15749
- const USDC$1 = "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48";
15750
- const CURRENT_POOL$1 = "0x00000000563b70d704f4c6675a5f6ac989fbae13";
15751
- const CURRENT_PO_ETH$1 = "0x1e46b0289B7E0F710E2Db8Ab87800dd782D624f7";
15752
- const CURRENT_PO_USDC$1 = "0x12bF31955522BAC337D93e1bC0a39F68D8BDa216";
15753
- const WSPCXX_PO_USDC = "0x141cc517a6276542B59732Fd85C1A2C536eF7aCA";
15754
- const NEW_POOL$1 = "0x00000000009C7B687e833559e34503f64d7ed7c4";
15755
- const NEW_PO_USDC$1 = "0x3CCdA7d5E841d6543D90BcEc20b36a724C184DE9";
15756
- const NEW_PO_WETH$1 = "0x69E9f9e44E5F52237493b980dd7306198C64A4E4";
15757
- const WETH$1 = "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2";
15758
- const DISPATCH_SIGNATURE$1 = "dispatch(uint256[],uint256[],uint128[],int24[3][],bool,uint256)";
15759
- const MAINNET_USDC_PLP_STRATEGIST_LEAF_DEFINITIONS = [
15760
- {
15761
- description: "Approve poUSDC to spend USDC",
15762
- target: USDC$1,
15763
- functionSignature: "approve(address,uint256)",
15764
- addressArguments: [CURRENT_PO_USDC$1],
15765
- canSendValue: false
15766
- },
15767
- {
15768
- description: "Deposit USDC for poUSDC",
15769
- target: CURRENT_PO_USDC$1,
15770
- functionSignature: "deposit(uint256,address)",
15771
- addressArguments: [VAULT$1],
15772
- canSendValue: false
15773
- },
15774
- {
15775
- description: "Withdraw USDC from poUSDC",
15776
- target: CURRENT_PO_USDC$1,
15777
- functionSignature: "withdraw(uint256,address,address)",
15778
- addressArguments: [VAULT$1, VAULT$1],
15779
- canSendValue: false
15780
- },
15781
- {
15782
- description: "Withdraw USDC from poUSDC (with open positions)",
15783
- target: CURRENT_PO_USDC$1,
15784
- functionSignature: "withdraw(uint256,address,address,uint256[],bool)",
15785
- addressArguments: [VAULT$1, VAULT$1],
15786
- canSendValue: false
15787
- },
15788
- {
15789
- description: "Mint poUSDC using USDC",
15790
- target: CURRENT_PO_USDC$1,
15791
- functionSignature: "mint(uint256,address)",
15792
- addressArguments: [VAULT$1],
15793
- canSendValue: false
15794
- },
15795
- {
15796
- description: "Redeem poUSDC for USDC",
15797
- target: CURRENT_PO_USDC$1,
15798
- functionSignature: "redeem(uint256,address,address)",
15799
- addressArguments: [VAULT$1, VAULT$1],
15800
- canSendValue: false
15801
- },
15802
- {
15803
- description: "Dispatch mint/burn options on PanopticPool",
15804
- target: CURRENT_POOL$1,
15805
- functionSignature: DISPATCH_SIGNATURE$1,
15806
- addressArguments: [],
15807
- canSendValue: false
15808
- },
15809
- {
15810
- description: "Withdraw ETH from poETH",
15811
- target: CURRENT_PO_ETH$1,
15812
- functionSignature: "withdraw(uint256,address,address)",
15813
- addressArguments: [VAULT$1, VAULT$1],
15814
- canSendValue: false
15815
- },
15816
- {
15817
- description: "Withdraw ETH from poETH (with open positions)",
15818
- target: CURRENT_PO_ETH$1,
15819
- functionSignature: "withdraw(uint256,address,address,uint256[],bool)",
15820
- addressArguments: [VAULT$1, VAULT$1],
15821
- canSendValue: false
15822
- },
15823
- {
15824
- description: "Approve wSPCXx poUSDC to spend USDC",
15825
- target: USDC$1,
15826
- functionSignature: "approve(address,uint256)",
15827
- addressArguments: [WSPCXX_PO_USDC],
15828
- canSendValue: false
15829
- },
15830
- {
15831
- description: "Deposit USDC for wSPCXx poUSDC",
15832
- target: WSPCXX_PO_USDC,
15833
- functionSignature: "deposit(uint256,address)",
15834
- addressArguments: [VAULT$1],
15835
- canSendValue: false
15836
- },
15837
- {
15838
- description: "Withdraw USDC from wSPCXx poUSDC",
15839
- target: WSPCXX_PO_USDC,
15840
- functionSignature: "withdraw(uint256,address,address)",
15841
- addressArguments: [VAULT$1, VAULT$1],
15842
- canSendValue: false
15843
- },
15844
- {
15845
- description: "Deposit ETH for poETH (payable)",
15846
- target: CURRENT_PO_ETH$1,
15847
- functionSignature: "deposit(uint256,address)",
15848
- addressArguments: [VAULT$1],
15849
- canSendValue: true
15850
- },
15851
- {
15852
- description: "Mint poETH using ETH (payable)",
15853
- target: CURRENT_PO_ETH$1,
15854
- functionSignature: "mint(uint256,address)",
15855
- addressArguments: [VAULT$1],
15856
- canSendValue: true
15857
- },
15858
- {
15859
- description: "Redeem poETH for ETH",
15860
- target: CURRENT_PO_ETH$1,
15861
- functionSignature: "redeem(uint256,address,address)",
15862
- addressArguments: [VAULT$1, VAULT$1],
15863
- canSendValue: false
15864
- },
15865
- {
15866
- description: "Approve poUSDC v3 to spend USDC",
15867
- target: USDC$1,
15868
- functionSignature: "approve(address,uint256)",
15869
- addressArguments: [NEW_PO_USDC$1],
15870
- canSendValue: false
15871
- },
15872
- {
15873
- description: "Deposit USDC for poUSDC v3",
15874
- target: NEW_PO_USDC$1,
15875
- functionSignature: "deposit(uint256,address)",
15876
- addressArguments: [VAULT$1],
15877
- canSendValue: false
15878
- },
15879
- {
15880
- description: "Withdraw USDC from poUSDC v3",
15881
- target: NEW_PO_USDC$1,
15882
- functionSignature: "withdraw(uint256,address,address)",
15883
- addressArguments: [VAULT$1, VAULT$1],
15884
- canSendValue: false
15885
- },
15886
- {
15887
- description: "Withdraw USDC from poUSDC v3 (with open positions)",
15888
- target: NEW_PO_USDC$1,
15889
- functionSignature: "withdraw(uint256,address,address,uint256[],bool)",
15890
- addressArguments: [VAULT$1, VAULT$1],
15891
- canSendValue: false
15892
- },
15893
- {
15894
- description: "Mint poUSDC v3 using USDC",
15895
- target: NEW_PO_USDC$1,
15896
- functionSignature: "mint(uint256,address)",
15897
- addressArguments: [VAULT$1],
15898
- canSendValue: false
15899
- },
15900
- {
15901
- description: "Redeem poUSDC v3 for USDC",
15902
- target: NEW_PO_USDC$1,
15903
- functionSignature: "redeem(uint256,address,address)",
15904
- addressArguments: [VAULT$1, VAULT$1],
15905
- canSendValue: false
15906
- },
15907
- {
15908
- description: "Dispatch mint/burn options on PanopticPool",
15909
- target: NEW_POOL$1,
15910
- functionSignature: DISPATCH_SIGNATURE$1,
15911
- addressArguments: [],
15912
- canSendValue: false
15913
- },
15914
- {
15915
- description: "Approve poWETH v3 to spend WETH",
15916
- target: WETH$1,
15917
- functionSignature: "approve(address,uint256)",
15918
- addressArguments: [NEW_PO_WETH$1],
15919
- canSendValue: false
15920
- },
15921
- {
15922
- description: "Deposit WETH for poWETH v3",
15923
- target: NEW_PO_WETH$1,
15924
- functionSignature: "deposit(uint256,address)",
15925
- addressArguments: [VAULT$1],
15926
- canSendValue: false
15927
- },
15928
- {
15929
- description: "Withdraw WETH from poWETH v3",
15930
- target: NEW_PO_WETH$1,
15931
- functionSignature: "withdraw(uint256,address,address)",
15932
- addressArguments: [VAULT$1, VAULT$1],
15933
- canSendValue: false
15934
- },
15935
- {
15936
- description: "Withdraw WETH from poWETH v3 (with open positions)",
15937
- target: NEW_PO_WETH$1,
15938
- functionSignature: "withdraw(uint256,address,address,uint256[],bool)",
15939
- addressArguments: [VAULT$1, VAULT$1],
15940
- canSendValue: false
15941
- },
15942
- {
15943
- description: "Mint poWETH v3 using WETH",
15944
- target: NEW_PO_WETH$1,
15945
- functionSignature: "mint(uint256,address)",
15946
- addressArguments: [VAULT$1],
15947
- canSendValue: false
15948
- },
15949
- {
15950
- description: "Redeem poWETH v3 for WETH",
15951
- target: NEW_PO_WETH$1,
15952
- functionSignature: "redeem(uint256,address,address)",
15953
- addressArguments: [VAULT$1, VAULT$1],
15954
- canSendValue: false
15955
- }
15956
- ];
15957
- const MAINNET_USDC_PLP_STRATEGIST_ARTIFACT_METADATA = {
15958
- accountantAddress: "0x65aA902AE3135658587FFC36ED51B61c927114e1",
15959
- boringVaultAddress: VAULT$1,
15960
- decoderAndSanitizerAddress: DECODER$1,
15961
- managerAddress: "0x2ce65016366ef7320078e0758D58Cf1038bc7C4e"
15962
- };
15963
- /** Production permissions before the ETH/USDC 5bps v3 pool authorization executes. */
15964
- const MainnetUSDCPLPPreviousStrategistLeaves = createStrategistLeavesArtifact(MAINNET_USDC_PLP_STRATEGIST_ARTIFACT_METADATA, MAINNET_USDC_PLP_STRATEGIST_LEAF_DEFINITIONS.slice(0, 12));
15965
- /** Production permissions after the ETH/USDC 5bps v3 pool authorization executes. */
15966
- const MainnetUSDCPLPStrategistLeaves = createStrategistLeavesArtifact(MAINNET_USDC_PLP_STRATEGIST_ARTIFACT_METADATA, MAINNET_USDC_PLP_STRATEGIST_LEAF_DEFINITIONS);
15801
+ //#region src/hypoVault/utils/buildManagerInput.ts
15802
+ const NATIVE_ZERO_ADDRESS = "0x0000000000000000000000000000000000000000";
15803
+ const NATIVE_ETH_ALIAS_ADDRESS = "0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee";
15804
+ function isUnderlyingEquivalentToken({ token, underlyingToken, wethAddress }) {
15805
+ const tokenLower = token.toLowerCase();
15806
+ const underlyingLower = underlyingToken.toLowerCase();
15807
+ if (tokenLower === underlyingLower) return true;
15808
+ if (wethAddress === void 0) return false;
15809
+ const wethLower = wethAddress.toLowerCase();
15810
+ const tokenIsNativeAlias = tokenLower === NATIVE_ZERO_ADDRESS || tokenLower === NATIVE_ETH_ALIAS_ADDRESS;
15811
+ return tokenIsNativeAlias && underlyingLower === wethLower;
15812
+ }
15813
+ /**
15814
+ * Builds the encoded managerInput for HypoVault operations like fulfillDeposits and fulfillWithdrawals.
15815
+ *
15816
+ * Supports the full input space of computeNAV by:
15817
+ * - Fetching TWAP ticks from each pool in poolInfos
15818
+ * - Setting token prices based on whether each token matches the underlyingToken address
15819
+ *
15820
+ * @param params.viemClient - Viem client with account for RPC calls
15821
+ * @param params.poolInfos - Array of pool info objects containing pool and token configuration
15822
+ * @param params.tokenIds - 2D array of tokenIds for each pool
15823
+ * @param params.underlyingToken - Address of the vault's underlying token
15824
+ * @param params.erc4626Vaults - Optional list of ERC4626 vaults considered by accountant NAV
15825
+ * @returns Encoded managerInput as Hex
15826
+ */
15827
+ async function buildManagerInput({ viemClient, poolInfos, tokenIds, underlyingToken, wethAddress, erc4626Vaults = [] }) {
15828
+ if (tokenIds.length !== poolInfos.length) throw new Error(`Invalid managerInput tokenIds length: expected ${poolInfos.length}, received ${tokenIds.length}`);
15829
+ const twapTicks = await Promise.all(poolInfos.map((poolInfo) => readContract(viemClient, {
15830
+ address: poolInfo.pool,
15831
+ abi: parseAbi(["function getTWAP() view returns (int24)"]),
15832
+ functionName: "getTWAP"
15833
+ })));
15834
+ const managerPrices = poolInfos.map((poolInfo, i) => {
15835
+ const twapTick = Number(twapTicks[i]);
15836
+ const token0IsUnderlying = isUnderlyingEquivalentToken({
15837
+ token: poolInfo.token0,
15838
+ underlyingToken,
15839
+ wethAddress
15840
+ });
15841
+ const token1IsUnderlying = isUnderlyingEquivalentToken({
15842
+ token: poolInfo.token1,
15843
+ underlyingToken,
15844
+ wethAddress
15845
+ });
15846
+ return {
15847
+ poolPrice: twapTick,
15848
+ token0Price: token0IsUnderlying ? 0 : twapTick,
15849
+ token1Price: token1IsUnderlying ? 0 : twapTick
15850
+ };
15851
+ });
15852
+ if (managerPrices.length !== poolInfos.length) throw new Error(`Invalid managerInput managerPrices length: expected ${poolInfos.length}, received ${managerPrices.length}`);
15853
+ return encodeAbiParameters(PanopticVaultAccountantManagerInputAbi, [
15854
+ managerPrices,
15855
+ poolInfos.map((poolInfo) => ({
15856
+ pool: poolInfo.pool,
15857
+ token0: poolInfo.token0,
15858
+ token1: poolInfo.token1,
15859
+ maxPriceDeviation: poolInfo.maxPriceDeviation
15860
+ })),
15861
+ tokenIds,
15862
+ erc4626Vaults
15863
+ ]);
15864
+ }
15967
15865
 
15968
15866
  //#endregion
15969
- //#region src/hypoVault/hypoVaultManagerArtifacts/MainnetWETHPLPStrategistLeaves.ts
15970
- const MAINNET_DEPLOYMENT$2 = requireChainDeployment(MAINNET_CHAIN_ID);
15971
- const NEW_POOL_DEPLOYMENT = MAINNET_DEPLOYMENT$2.panoptic.additionalPools?.ethUsdc5bpsV3;
15972
- if (NEW_POOL_DEPLOYMENT === void 0) throw new Error("Missing mainnet ETH/USDC 5bps v3 Panoptic pool deployment");
15973
- const VAULT = MAINNET_DEPLOYMENT$2.hypovault.vaults.wethPlpVault;
15974
- const DECODER = MAINNET_DEPLOYMENT$2.hypovault.core.collateralTrackerDecoderAndSanitizer;
15975
- const CURRENT_POOL = MAINNET_DEPLOYMENT$2.panoptic.pool.panopticPool;
15976
- const CURRENT_PO_ETH = MAINNET_DEPLOYMENT$2.panoptic.pool.collateralTracker0;
15977
- const CURRENT_PO_USDC = MAINNET_DEPLOYMENT$2.panoptic.pool.collateralTracker1;
15978
- const NEW_POOL = NEW_POOL_DEPLOYMENT.panopticPool;
15979
- const NEW_PO_USDC = NEW_POOL_DEPLOYMENT.collateralTracker0;
15980
- const NEW_PO_WETH = NEW_POOL_DEPLOYMENT.collateralTracker1;
15981
- const USDC = "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48";
15982
- const WETH = "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2";
15983
- const DISPATCH_SIGNATURE = "dispatch(uint256[],uint256[],uint128[],int24[3][],bool,uint256)";
15984
- const MAINNET_WETH_PLP_STRATEGIST_LEAF_DEFINITIONS = [
15985
- {
15986
- description: "Deposit ETH for poETH (payable)",
15987
- target: CURRENT_PO_ETH,
15988
- functionSignature: "deposit(uint256,address)",
15989
- addressArguments: [VAULT],
15990
- canSendValue: true
15991
- },
15992
- {
15993
- description: "Withdraw ETH from poETH",
15994
- target: CURRENT_PO_ETH,
15995
- functionSignature: "withdraw(uint256,address,address)",
15996
- addressArguments: [VAULT, VAULT],
15997
- canSendValue: false
15998
- },
15999
- {
16000
- description: "Withdraw ETH from poETH (with open positions)",
16001
- target: CURRENT_PO_ETH,
16002
- functionSignature: "withdraw(uint256,address,address,uint256[],bool)",
16003
- addressArguments: [VAULT, VAULT],
16004
- canSendValue: false
16005
- },
16006
- {
16007
- description: "Mint poETH using ETH (payable)",
16008
- target: CURRENT_PO_ETH,
16009
- functionSignature: "mint(uint256,address)",
16010
- addressArguments: [VAULT],
16011
- canSendValue: true
16012
- },
16013
- {
16014
- description: "Redeem poETH for ETH",
16015
- target: CURRENT_PO_ETH,
16016
- functionSignature: "redeem(uint256,address,address)",
16017
- addressArguments: [VAULT, VAULT],
16018
- canSendValue: false
16019
- },
16020
- {
16021
- description: "Dispatch mint/burn options on PanopticPool",
16022
- target: CURRENT_POOL,
16023
- functionSignature: DISPATCH_SIGNATURE,
16024
- addressArguments: [],
16025
- canSendValue: false
16026
- },
16027
- {
16028
- description: "Wrap ETH to WETH",
16029
- target: WETH,
16030
- functionSignature: "deposit()",
16031
- addressArguments: [],
16032
- canSendValue: true
16033
- },
16034
- {
16035
- description: "Unwrap WETH to ETH",
16036
- target: WETH,
16037
- functionSignature: "withdraw(uint256)",
16038
- addressArguments: [],
16039
- canSendValue: false
16040
- },
16041
- {
16042
- description: "Withdraw USDC from poUSDC",
16043
- target: CURRENT_PO_USDC,
16044
- functionSignature: "withdraw(uint256,address,address)",
16045
- addressArguments: [VAULT, VAULT],
16046
- canSendValue: false
16047
- },
16048
- {
16049
- description: "Withdraw USDC from poUSDC (with open positions)",
16050
- target: CURRENT_PO_USDC,
16051
- functionSignature: "withdraw(uint256,address,address,uint256[],bool)",
16052
- addressArguments: [VAULT, VAULT],
16053
- canSendValue: false
16054
- },
16055
- {
16056
- description: "Approve poUSDC to spend USDC",
16057
- target: USDC,
16058
- functionSignature: "approve(address,uint256)",
16059
- addressArguments: [CURRENT_PO_USDC],
16060
- canSendValue: false
16061
- },
16062
- {
16063
- description: "Deposit USDC for poUSDC",
16064
- target: CURRENT_PO_USDC,
16065
- functionSignature: "deposit(uint256,address)",
16066
- addressArguments: [VAULT],
16067
- canSendValue: false
16068
- },
16069
- {
16070
- description: "Mint poUSDC using USDC",
16071
- target: CURRENT_PO_USDC,
16072
- functionSignature: "mint(uint256,address)",
16073
- addressArguments: [VAULT],
16074
- canSendValue: false
16075
- },
16076
- {
16077
- description: "Redeem poUSDC for USDC",
16078
- target: CURRENT_PO_USDC,
16079
- functionSignature: "redeem(uint256,address,address)",
16080
- addressArguments: [VAULT, VAULT],
16081
- canSendValue: false
16082
- },
16083
- {
16084
- description: "Approve poWETH v3 to spend WETH",
16085
- target: WETH,
16086
- functionSignature: "approve(address,uint256)",
16087
- addressArguments: [NEW_PO_WETH],
16088
- canSendValue: false
16089
- },
16090
- {
16091
- description: "Deposit WETH for poWETH v3",
16092
- target: NEW_PO_WETH,
16093
- functionSignature: "deposit(uint256,address)",
16094
- addressArguments: [VAULT],
16095
- canSendValue: false
16096
- },
16097
- {
16098
- description: "Withdraw WETH from poWETH v3",
16099
- target: NEW_PO_WETH,
16100
- functionSignature: "withdraw(uint256,address,address)",
16101
- addressArguments: [VAULT, VAULT],
16102
- canSendValue: false
16103
- },
16104
- {
16105
- description: "Withdraw WETH from poWETH v3 (with open positions)",
16106
- target: NEW_PO_WETH,
16107
- functionSignature: "withdraw(uint256,address,address,uint256[],bool)",
16108
- addressArguments: [VAULT, VAULT],
16109
- canSendValue: false
16110
- },
16111
- {
16112
- description: "Mint poWETH v3 using WETH",
16113
- target: NEW_PO_WETH,
16114
- functionSignature: "mint(uint256,address)",
16115
- addressArguments: [VAULT],
16116
- canSendValue: false
16117
- },
16118
- {
16119
- description: "Redeem poWETH v3 for WETH",
16120
- target: NEW_PO_WETH,
16121
- functionSignature: "redeem(uint256,address,address)",
16122
- addressArguments: [VAULT, VAULT],
16123
- canSendValue: false
16124
- },
16125
- {
16126
- description: "Dispatch mint/burn options on PanopticPool",
16127
- target: NEW_POOL,
16128
- functionSignature: DISPATCH_SIGNATURE,
16129
- addressArguments: [],
16130
- canSendValue: false
16131
- },
16132
- {
16133
- description: "Approve poUSDC v3 to spend USDC",
16134
- target: USDC,
16135
- functionSignature: "approve(address,uint256)",
16136
- addressArguments: [NEW_PO_USDC],
16137
- canSendValue: false
16138
- },
16139
- {
16140
- description: "Deposit USDC for poUSDC v3",
16141
- target: NEW_PO_USDC,
16142
- functionSignature: "deposit(uint256,address)",
16143
- addressArguments: [VAULT],
16144
- canSendValue: false
16145
- },
16146
- {
16147
- description: "Withdraw USDC from poUSDC v3",
16148
- target: NEW_PO_USDC,
16149
- functionSignature: "withdraw(uint256,address,address)",
16150
- addressArguments: [VAULT, VAULT],
16151
- canSendValue: false
16152
- },
16153
- {
16154
- description: "Withdraw USDC from poUSDC v3 (with open positions)",
16155
- target: NEW_PO_USDC,
16156
- functionSignature: "withdraw(uint256,address,address,uint256[],bool)",
16157
- addressArguments: [VAULT, VAULT],
16158
- canSendValue: false
16159
- },
16160
- {
16161
- description: "Mint poUSDC v3 using USDC",
16162
- target: NEW_PO_USDC,
16163
- functionSignature: "mint(uint256,address)",
16164
- addressArguments: [VAULT],
16165
- canSendValue: false
16166
- },
16167
- {
16168
- description: "Redeem poUSDC v3 for USDC",
16169
- target: NEW_PO_USDC,
16170
- functionSignature: "redeem(uint256,address,address)",
16171
- addressArguments: [VAULT, VAULT],
16172
- canSendValue: false
16173
- }
16174
- ];
16175
- const MAINNET_WETH_PLP_STRATEGIST_ARTIFACT_METADATA = {
16176
- accountantAddress: MAINNET_DEPLOYMENT$2.hypovault.core.accountant,
16177
- boringVaultAddress: VAULT,
16178
- decoderAndSanitizerAddress: DECODER,
16179
- managerAddress: MAINNET_DEPLOYMENT$2.hypovault.managers.wethPlpVaultManager
16180
- };
16181
- /** Production permissions before the ETH/USDC 5bps v3 pool authorization executes. */
16182
- const MainnetWETHPLPPreviousStrategistLeaves = createStrategistLeavesArtifact(MAINNET_WETH_PLP_STRATEGIST_ARTIFACT_METADATA, MAINNET_WETH_PLP_STRATEGIST_LEAF_DEFINITIONS.slice(0, 10));
16183
- /** Production permissions after the ETH/USDC 5bps v3 pool authorization executes. */
16184
- const MainnetWETHPLPStrategistLeaves = createStrategistLeavesArtifact(MAINNET_WETH_PLP_STRATEGIST_ARTIFACT_METADATA, MAINNET_WETH_PLP_STRATEGIST_LEAF_DEFINITIONS);
16185
-
16186
- //#endregion
16187
- //#region src/hypoVault/mainnetV3Authorization.ts
16188
- const MAINNET_DEPLOYMENT$1 = requireChainDeployment(MAINNET_CHAIN_ID);
16189
- const POOL_INFO_ARRAY_ABI = {
16190
- type: "tuple[]",
16191
- components: [
16192
- {
16193
- name: "pool",
16194
- type: "address"
16195
- },
16196
- {
16197
- name: "token0",
16198
- type: "address"
16199
- },
16200
- {
16201
- name: "token1",
16202
- type: "address"
16203
- },
16204
- {
16205
- name: "maxPriceDeviation",
16206
- type: "int24"
16207
- }
16208
- ]
16209
- };
16210
- function hashPoolInfos(poolInfos) {
16211
- return keccak256(encodeAbiParameters([POOL_INFO_ARRAY_ABI], [poolInfos.map((poolInfo) => ({
16212
- pool: getAddress(poolInfo.pool),
16213
- token0: getAddress(poolInfo.token0),
16214
- token1: getAddress(poolInfo.token1),
16215
- maxPriceDeviation: poolInfo.maxPriceDeviation
16216
- }))]));
16217
- }
16218
- function generation(poolInfos, strategistLeaves) {
16219
- return {
16220
- poolInfos,
16221
- strategistLeaves,
16222
- poolHash: hashPoolInfos(poolInfos),
16223
- manageRoot: strategistLeaves.metadata.ManageRoot
16224
- };
16225
- }
16226
- const MAINNET_V3_AUTHORIZATION_TRANSITIONS = [{
16227
- vaultAddress: MAINNET_DEPLOYMENT$1.hypovault.vaults.wethPlpVault,
16228
- managerAddress: MAINNET_DEPLOYMENT$1.hypovault.managers.wethPlpVaultManager,
16229
- strategistAddress: MAINNET_DEPLOYMENT$1.hypovault.turnkeySigners.wethPlpVaultManager,
16230
- previous: generation(MainnetWETHPLPPreviousVaultPoolInfos.poolInfos, MainnetWETHPLPPreviousStrategistLeaves),
16231
- next: generation(MainnetWETHPLPVaultPoolInfos.poolInfos, MainnetWETHPLPStrategistLeaves)
16232
- }, {
16233
- vaultAddress: MAINNET_DEPLOYMENT$1.hypovault.vaults.usdcPlpVault,
16234
- managerAddress: MAINNET_DEPLOYMENT$1.hypovault.managers.usdcPlpVaultManager,
16235
- strategistAddress: MAINNET_DEPLOYMENT$1.hypovault.turnkeySigners.usdcPlpVaultManager,
16236
- previous: generation(MainnetUSDCPLPPreviousVaultPoolInfos.poolInfos, MainnetUSDCPLPPreviousStrategistLeaves),
16237
- next: generation(MainnetUSDCPLPVaultPoolInfos.poolInfos, MainnetUSDCPLPStrategistLeaves)
16238
- }];
16239
- function findTransition(chainId, vaultAddress) {
16240
- if (chainId !== MAINNET_CHAIN_ID) return null;
16241
- const normalizedVault = vaultAddress.toLowerCase();
16242
- return MAINNET_V3_AUTHORIZATION_TRANSITIONS.find((transition) => transition.vaultAddress.toLowerCase() === normalizedVault) ?? null;
16243
- }
16244
- /** Returns both known generations without reading chain state. */
16245
- function getMainnetV3AuthorizationGenerations({ chainId, vaultAddress }) {
16246
- const transition = findTransition(chainId, vaultAddress);
16247
- return transition === null ? null : {
16248
- previous: transition.previous,
16249
- next: transition.next
16250
- };
16251
- }
15867
+ //#region src/hypoVault/utils/buildManagerInputAtBlock.ts
16252
15868
  /**
16253
- * Selects the exact artifact generation authorized by both the accountant and manager.
16254
- * A mixed or unknown state is rejected: using only one side of the transition would
16255
- * make either NAV calculation or strategist proof verification fail.
15869
+ * Builds encoded managerInput for HypoVault accountant reads at a specific block.
16256
15870
  */
16257
- async function resolveMainnetV3AuthorizationArtifacts({ viemClient, chainId, vaultAddress, blockNumber }) {
16258
- const transition = findTransition(chainId, vaultAddress);
16259
- if (transition === null) return null;
16260
- const resolvedBlockNumber = blockNumber ?? await getBlockNumber(viemClient);
16261
- const [poolHash, manageRoot] = await Promise.all([readContract(viemClient, {
16262
- address: MAINNET_DEPLOYMENT$1.hypovault.core.accountant,
16263
- abi: PanopticVaultAccountantAbi,
16264
- functionName: "vaultHashes",
16265
- args: [transition.vaultAddress, 0n],
16266
- blockNumber: resolvedBlockNumber
16267
- }), readContract(viemClient, {
16268
- address: transition.managerAddress,
16269
- abi: HypoVaultManagerWithMerkleVerificationAbi,
16270
- functionName: "manageRoot",
16271
- args: [transition.strategistAddress],
16272
- blockNumber: resolvedBlockNumber
16273
- })]);
16274
- for (const version of ["next", "previous"]) {
16275
- const candidate = transition[version];
16276
- if (poolHash === candidate.poolHash && manageRoot === candidate.manageRoot) return {
16277
- version,
16278
- blockNumber: resolvedBlockNumber,
16279
- ...candidate
16280
- };
16281
- }
16282
- throw new Error(`Unsupported or inconsistent mainnet v3 authorization state for vault ${transition.vaultAddress}: accountant pool hash ${poolHash}, manager root ${manageRoot}`);
16283
- }
16284
-
16285
- //#endregion
16286
- //#region src/hypoVault/utils/buildManagerInput.ts
16287
- const NATIVE_ZERO_ADDRESS = "0x0000000000000000000000000000000000000000";
16288
- const NATIVE_ETH_ALIAS_ADDRESS = "0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee";
16289
- function isUnderlyingEquivalentToken({ token, underlyingToken, wethAddress }) {
16290
- const tokenLower = token.toLowerCase();
16291
- const underlyingLower = underlyingToken.toLowerCase();
16292
- if (tokenLower === underlyingLower) return true;
16293
- if (wethAddress === void 0) return false;
16294
- const wethLower = wethAddress.toLowerCase();
16295
- const tokenIsNativeAlias = tokenLower === NATIVE_ZERO_ADDRESS || tokenLower === NATIVE_ETH_ALIAS_ADDRESS;
16296
- return tokenIsNativeAlias && underlyingLower === wethLower;
16297
- }
16298
- /**
16299
- * Builds the encoded managerInput for HypoVault operations like fulfillDeposits and fulfillWithdrawals.
16300
- *
16301
- * Supports the full input space of computeNAV by:
16302
- * - Fetching TWAP ticks from each pool in poolInfos
16303
- * - Setting token prices based on whether each token matches the underlyingToken address
16304
- *
16305
- * @param params.viemClient - Viem client with account for RPC calls
16306
- * @param params.poolInfos - Array of pool info objects containing pool and token configuration
16307
- * @param params.tokenIds - 2D array of tokenIds for each pool
16308
- * @param params.underlyingToken - Address of the vault's underlying token
16309
- * @param params.erc4626Vaults - Optional list of ERC4626 vaults considered by accountant NAV
16310
- * @returns Encoded managerInput as Hex
16311
- */
16312
- async function buildManagerInput({ viemClient, poolInfos, tokenIds, underlyingToken, wethAddress, erc4626Vaults = [] }) {
16313
- if (tokenIds.length !== poolInfos.length) throw new Error(`Invalid managerInput tokenIds length: expected ${poolInfos.length}, received ${tokenIds.length}`);
16314
- const twapTicks = await Promise.all(poolInfos.map((poolInfo) => readContract(viemClient, {
16315
- address: poolInfo.pool,
16316
- abi: parseAbi(["function getTWAP() view returns (int24)"]),
16317
- functionName: "getTWAP"
16318
- })));
16319
- const managerPrices = poolInfos.map((poolInfo, i) => {
16320
- const twapTick = Number(twapTicks[i]);
16321
- const token0IsUnderlying = isUnderlyingEquivalentToken({
16322
- token: poolInfo.token0,
16323
- underlyingToken,
16324
- wethAddress
16325
- });
16326
- const token1IsUnderlying = isUnderlyingEquivalentToken({
16327
- token: poolInfo.token1,
16328
- underlyingToken,
16329
- wethAddress
16330
- });
16331
- return {
16332
- poolPrice: twapTick,
16333
- token0Price: token0IsUnderlying ? 0 : twapTick,
16334
- token1Price: token1IsUnderlying ? 0 : twapTick
16335
- };
16336
- });
16337
- if (managerPrices.length !== poolInfos.length) throw new Error(`Invalid managerInput managerPrices length: expected ${poolInfos.length}, received ${managerPrices.length}`);
16338
- return encodeAbiParameters(PanopticVaultAccountantManagerInputAbi, [
16339
- managerPrices,
16340
- poolInfos.map((poolInfo) => ({
16341
- pool: poolInfo.pool,
16342
- token0: poolInfo.token0,
16343
- token1: poolInfo.token1,
16344
- maxPriceDeviation: poolInfo.maxPriceDeviation
16345
- })),
16346
- tokenIds,
16347
- erc4626Vaults
16348
- ]);
16349
- }
16350
-
16351
- //#endregion
16352
- //#region src/hypoVault/utils/buildManagerInputAtBlock.ts
16353
- /**
16354
- * Builds encoded managerInput for HypoVault accountant reads at a specific block.
16355
- */
16356
- async function buildManagerInputAtBlock({ viemClient, poolInfos, tokenIds, underlyingToken, wethAddress, blockNumber, erc4626Vaults = [] }) {
16357
- if (tokenIds.length !== poolInfos.length) throw new Error(`Invalid managerInput tokenIds length: expected ${poolInfos.length}, received ${tokenIds.length}`);
16358
- const twapTicks = await Promise.all(poolInfos.map((poolInfo) => readContract(viemClient, {
16359
- address: poolInfo.pool,
16360
- abi: parseAbi(["function getTWAP() view returns (int24)"]),
16361
- functionName: "getTWAP",
16362
- blockNumber
16363
- })));
16364
- const managerPrices = poolInfos.map((poolInfo, i) => {
16365
- const twapTick = Number(twapTicks[i]);
16366
- const token0IsUnderlying = isUnderlyingEquivalentToken({
16367
- token: poolInfo.token0,
16368
- underlyingToken,
16369
- wethAddress
16370
- });
16371
- const token1IsUnderlying = isUnderlyingEquivalentToken({
16372
- token: poolInfo.token1,
16373
- underlyingToken,
16374
- wethAddress
16375
- });
16376
- return {
16377
- poolPrice: twapTick,
16378
- token0Price: token0IsUnderlying ? 0 : twapTick,
16379
- token1Price: token1IsUnderlying ? 0 : twapTick
15871
+ async function buildManagerInputAtBlock({ viemClient, poolInfos, tokenIds, underlyingToken, wethAddress, blockNumber, erc4626Vaults = [] }) {
15872
+ if (tokenIds.length !== poolInfos.length) throw new Error(`Invalid managerInput tokenIds length: expected ${poolInfos.length}, received ${tokenIds.length}`);
15873
+ const twapTicks = await Promise.all(poolInfos.map((poolInfo) => readContract(viemClient, {
15874
+ address: poolInfo.pool,
15875
+ abi: parseAbi(["function getTWAP() view returns (int24)"]),
15876
+ functionName: "getTWAP",
15877
+ blockNumber
15878
+ })));
15879
+ const managerPrices = poolInfos.map((poolInfo, i) => {
15880
+ const twapTick = Number(twapTicks[i]);
15881
+ const token0IsUnderlying = isUnderlyingEquivalentToken({
15882
+ token: poolInfo.token0,
15883
+ underlyingToken,
15884
+ wethAddress
15885
+ });
15886
+ const token1IsUnderlying = isUnderlyingEquivalentToken({
15887
+ token: poolInfo.token1,
15888
+ underlyingToken,
15889
+ wethAddress
15890
+ });
15891
+ return {
15892
+ poolPrice: twapTick,
15893
+ token0Price: token0IsUnderlying ? 0 : twapTick,
15894
+ token1Price: token1IsUnderlying ? 0 : twapTick
16380
15895
  };
16381
15896
  });
16382
15897
  if (managerPrices.length !== poolInfos.length) throw new Error(`Invalid managerInput managerPrices length: expected ${poolInfos.length}, received ${managerPrices.length}`);
@@ -16766,37 +16281,25 @@ async function resolveVaultTokenIdsByPool({ viemClient, chainId, vaultAddress, m
16766
16281
  return tokenIdsByPool;
16767
16282
  }
16768
16283
  async function buildVaultManagerInput({ viemClient, chainId, vaultAddress, underlyingToken, managerAddress, panopticSubgraphUrl, fetchFn }) {
16769
- const authorization = await resolveMainnetV3AuthorizationArtifacts({
16770
- viemClient,
16771
- chainId,
16772
- vaultAddress
16773
- });
16774
- const poolInfos = authorization?.poolInfos ?? getVaultPoolInfos(vaultAddress, chainId);
16775
- if (poolInfos.length === 0) return DEFAULT_MANAGER_INPUT$1;
16776
- const tokenIds = await resolveVaultTokenIdsByPool({
16284
+ const blockNumber = await getBlockNumber(viemClient);
16285
+ return buildVaultManagerInputAtBlock({
16777
16286
  viemClient,
16778
16287
  chainId,
16779
16288
  vaultAddress,
16289
+ underlyingToken,
16290
+ blockNumber,
16780
16291
  managerAddress,
16781
- poolInfos,
16782
16292
  panopticSubgraphUrl,
16783
16293
  fetchFn
16784
16294
  });
16785
- return buildManagerInput({
16786
- viemClient,
16787
- poolInfos,
16788
- tokenIds,
16789
- underlyingToken
16790
- });
16791
16295
  }
16792
16296
  async function buildVaultManagerInputAtBlock({ viemClient, chainId, vaultAddress, underlyingToken, blockNumber, managerAddress, panopticSubgraphUrl, fetchFn }) {
16793
- const authorization = await resolveMainnetV3AuthorizationArtifacts({
16794
- viemClient,
16297
+ const historicalPoolConfiguration = getMainnetVaultPoolConfigurationAtBlock({
16795
16298
  chainId,
16796
16299
  vaultAddress,
16797
16300
  blockNumber
16798
16301
  });
16799
- const poolInfos = authorization?.poolInfos ?? getVaultPoolInfos(vaultAddress, chainId);
16302
+ const poolInfos = historicalPoolConfiguration?.poolInfos ?? getVaultPoolInfos(vaultAddress, chainId);
16800
16303
  if (poolInfos.length === 0) return DEFAULT_MANAGER_INPUT$1;
16801
16304
  const tokenIds = await resolveVaultTokenIdsByPool({
16802
16305
  viemClient,
@@ -18751,6 +18254,547 @@ const MainnetLegacyWETHPLPStrategistLeaves = {
18751
18254
  }
18752
18255
  };
18753
18256
 
18257
+ //#endregion
18258
+ //#region src/hypoVault/hypoVaultManagerArtifacts/createStrategistLeavesArtifact.ts
18259
+ const DIGEST_COMPOSITION = [
18260
+ "Bytes20(DECODER_AND_SANITIZER_ADDRESS)",
18261
+ "Bytes20(TARGET_ADDRESS)",
18262
+ "Bytes1(CAN_SEND_VALUE)",
18263
+ "Bytes4(TARGET_FUNCTION_SELECTOR)",
18264
+ "Bytes{N*20}(ADDRESS_ARGUMENT_0,...,ADDRESS_ARGUMENT_N)"
18265
+ ];
18266
+ const EMPTY_DEFINITION = {
18267
+ description: "",
18268
+ target: zeroAddress,
18269
+ functionSignature: "",
18270
+ addressArguments: [],
18271
+ canSendValue: false
18272
+ };
18273
+ function efficientHash$1(a, b) {
18274
+ return keccak256(encodePacked(["bytes32", "bytes32"], a < b ? [a, b] : [b, a]));
18275
+ }
18276
+ function nextPowerOfTwo(value) {
18277
+ let capacity = 1;
18278
+ while (capacity < value) capacity *= 2;
18279
+ return capacity;
18280
+ }
18281
+ function functionSelector(signature) {
18282
+ return keccak256(toBytes(signature)).slice(0, 10);
18283
+ }
18284
+ function buildLeaf(definition, decoderAndSanitizerAddress) {
18285
+ const selector = functionSelector(definition.functionSignature);
18286
+ const packedArgumentAddresses = definition.addressArguments.length === 0 ? "0x" : concat(definition.addressArguments.map((address) => getAddress(address)));
18287
+ const rawDigest = concat([encodePacked([
18288
+ "address",
18289
+ "address",
18290
+ "bool",
18291
+ "bytes4"
18292
+ ], [
18293
+ getAddress(decoderAndSanitizerAddress),
18294
+ getAddress(definition.target),
18295
+ definition.canSendValue,
18296
+ selector
18297
+ ]), packedArgumentAddresses]);
18298
+ return {
18299
+ AddressArguments: definition.addressArguments,
18300
+ CanSendValue: definition.canSendValue,
18301
+ DecoderAndSanitizerAddress: getAddress(decoderAndSanitizerAddress),
18302
+ Description: definition.description,
18303
+ FunctionSelector: selector,
18304
+ FunctionSignature: definition.functionSignature,
18305
+ LeafDigest: keccak256(rawDigest),
18306
+ PackedArgumentAddresses: packedArgumentAddresses,
18307
+ TargetAddress: getAddress(definition.target)
18308
+ };
18309
+ }
18310
+ function buildMerkleTree(leafDigests) {
18311
+ if (leafDigests.length === 0) throw new Error("Strategist Merkle tree requires at least one leaf digest");
18312
+ const layersFromLeaves = [[...leafDigests]];
18313
+ while (layersFromLeaves[layersFromLeaves.length - 1]?.length !== 1) {
18314
+ const currentLayer = layersFromLeaves[layersFromLeaves.length - 1];
18315
+ if (currentLayer === void 0 || currentLayer.length === 0) throw new Error("Strategist Merkle tree produced an empty layer");
18316
+ if (currentLayer.length % 2 !== 0) throw new Error("Strategist Merkle tree layers must contain an even number of nodes");
18317
+ const parentLayer = [];
18318
+ for (let index = 0; index < currentLayer.length; index += 2) {
18319
+ const left = currentLayer[index];
18320
+ const right = currentLayer[index + 1];
18321
+ if (left === void 0 || right === void 0) throw new Error("Strategist Merkle tree contains an incomplete pair");
18322
+ parentLayer.push(efficientHash$1(left, right));
18323
+ }
18324
+ layersFromLeaves.push(parentLayer);
18325
+ }
18326
+ return Object.fromEntries([...layersFromLeaves].reverse().map((layer, index) => [String(index), layer]));
18327
+ }
18328
+ function createStrategistLeavesArtifact(metadata, definitions) {
18329
+ if (definitions.length === 0) throw new Error("Strategist artifact requires at least one permission leaf");
18330
+ const treeCapacity = nextPowerOfTwo(definitions.length);
18331
+ const leafs = definitions.map((definition) => buildLeaf(definition, metadata.decoderAndSanitizerAddress));
18332
+ const emptyLeaf = buildLeaf(EMPTY_DEFINITION, zeroAddress);
18333
+ while (leafs.length < treeCapacity) leafs.push(emptyLeaf);
18334
+ const merkleTree = buildMerkleTree(leafs.map((leaf) => leaf.LeafDigest));
18335
+ const root = merkleTree["0"]?.[0];
18336
+ if (root === void 0) throw new Error("Strategist Merkle tree root was not generated");
18337
+ return {
18338
+ metadata: {
18339
+ AccountantAddress: getAddress(metadata.accountantAddress),
18340
+ BoringVaultAddress: getAddress(metadata.boringVaultAddress),
18341
+ DecoderAndSanitizerAddress: getAddress(metadata.decoderAndSanitizerAddress),
18342
+ DigestComposition: DIGEST_COMPOSITION,
18343
+ LeafCount: definitions.length,
18344
+ ManageRoot: root,
18345
+ ManagerAddress: getAddress(metadata.managerAddress),
18346
+ TreeCapacity: treeCapacity
18347
+ },
18348
+ leafs,
18349
+ MerkleTree: merkleTree
18350
+ };
18351
+ }
18352
+
18353
+ //#endregion
18354
+ //#region src/hypoVault/hypoVaultManagerArtifacts/MainnetUSDCPLPStrategistLeaves.ts
18355
+ const VAULT$1 = "0x236d0558f06cd60780b232d4Ec4c92d2cb7e4D18";
18356
+ const DECODER$1 = "0xC87c45d2dbE5acb56013e2591427ECC84Fa251E6";
18357
+ const USDC$1 = "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48";
18358
+ const CURRENT_POOL$1 = "0x00000000563b70d704f4c6675a5f6ac989fbae13";
18359
+ const CURRENT_PO_ETH$1 = "0x1e46b0289B7E0F710E2Db8Ab87800dd782D624f7";
18360
+ const CURRENT_PO_USDC$1 = "0x12bF31955522BAC337D93e1bC0a39F68D8BDa216";
18361
+ const WSPCXX_PO_USDC = "0x141cc517a6276542B59732Fd85C1A2C536eF7aCA";
18362
+ const NEW_POOL$1 = "0x00000000009C7B687e833559e34503f64d7ed7c4";
18363
+ const NEW_PO_USDC$1 = "0x3CCdA7d5E841d6543D90BcEc20b36a724C184DE9";
18364
+ const NEW_PO_WETH$1 = "0x69E9f9e44E5F52237493b980dd7306198C64A4E4";
18365
+ const WETH$1 = "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2";
18366
+ const DISPATCH_SIGNATURE$1 = "dispatch(uint256[],uint256[],uint128[],int24[3][],bool,uint256)";
18367
+ const MAINNET_USDC_PLP_STRATEGIST_LEAF_DEFINITIONS = [
18368
+ {
18369
+ description: "Approve poUSDC to spend USDC",
18370
+ target: USDC$1,
18371
+ functionSignature: "approve(address,uint256)",
18372
+ addressArguments: [CURRENT_PO_USDC$1],
18373
+ canSendValue: false
18374
+ },
18375
+ {
18376
+ description: "Deposit USDC for poUSDC",
18377
+ target: CURRENT_PO_USDC$1,
18378
+ functionSignature: "deposit(uint256,address)",
18379
+ addressArguments: [VAULT$1],
18380
+ canSendValue: false
18381
+ },
18382
+ {
18383
+ description: "Withdraw USDC from poUSDC",
18384
+ target: CURRENT_PO_USDC$1,
18385
+ functionSignature: "withdraw(uint256,address,address)",
18386
+ addressArguments: [VAULT$1, VAULT$1],
18387
+ canSendValue: false
18388
+ },
18389
+ {
18390
+ description: "Withdraw USDC from poUSDC (with open positions)",
18391
+ target: CURRENT_PO_USDC$1,
18392
+ functionSignature: "withdraw(uint256,address,address,uint256[],bool)",
18393
+ addressArguments: [VAULT$1, VAULT$1],
18394
+ canSendValue: false
18395
+ },
18396
+ {
18397
+ description: "Mint poUSDC using USDC",
18398
+ target: CURRENT_PO_USDC$1,
18399
+ functionSignature: "mint(uint256,address)",
18400
+ addressArguments: [VAULT$1],
18401
+ canSendValue: false
18402
+ },
18403
+ {
18404
+ description: "Redeem poUSDC for USDC",
18405
+ target: CURRENT_PO_USDC$1,
18406
+ functionSignature: "redeem(uint256,address,address)",
18407
+ addressArguments: [VAULT$1, VAULT$1],
18408
+ canSendValue: false
18409
+ },
18410
+ {
18411
+ description: "Dispatch mint/burn options on PanopticPool",
18412
+ target: CURRENT_POOL$1,
18413
+ functionSignature: DISPATCH_SIGNATURE$1,
18414
+ addressArguments: [],
18415
+ canSendValue: false
18416
+ },
18417
+ {
18418
+ description: "Withdraw ETH from poETH",
18419
+ target: CURRENT_PO_ETH$1,
18420
+ functionSignature: "withdraw(uint256,address,address)",
18421
+ addressArguments: [VAULT$1, VAULT$1],
18422
+ canSendValue: false
18423
+ },
18424
+ {
18425
+ description: "Withdraw ETH from poETH (with open positions)",
18426
+ target: CURRENT_PO_ETH$1,
18427
+ functionSignature: "withdraw(uint256,address,address,uint256[],bool)",
18428
+ addressArguments: [VAULT$1, VAULT$1],
18429
+ canSendValue: false
18430
+ },
18431
+ {
18432
+ description: "Approve wSPCXx poUSDC to spend USDC",
18433
+ target: USDC$1,
18434
+ functionSignature: "approve(address,uint256)",
18435
+ addressArguments: [WSPCXX_PO_USDC],
18436
+ canSendValue: false
18437
+ },
18438
+ {
18439
+ description: "Deposit USDC for wSPCXx poUSDC",
18440
+ target: WSPCXX_PO_USDC,
18441
+ functionSignature: "deposit(uint256,address)",
18442
+ addressArguments: [VAULT$1],
18443
+ canSendValue: false
18444
+ },
18445
+ {
18446
+ description: "Withdraw USDC from wSPCXx poUSDC",
18447
+ target: WSPCXX_PO_USDC,
18448
+ functionSignature: "withdraw(uint256,address,address)",
18449
+ addressArguments: [VAULT$1, VAULT$1],
18450
+ canSendValue: false
18451
+ },
18452
+ {
18453
+ description: "Deposit ETH for poETH (payable)",
18454
+ target: CURRENT_PO_ETH$1,
18455
+ functionSignature: "deposit(uint256,address)",
18456
+ addressArguments: [VAULT$1],
18457
+ canSendValue: true
18458
+ },
18459
+ {
18460
+ description: "Mint poETH using ETH (payable)",
18461
+ target: CURRENT_PO_ETH$1,
18462
+ functionSignature: "mint(uint256,address)",
18463
+ addressArguments: [VAULT$1],
18464
+ canSendValue: true
18465
+ },
18466
+ {
18467
+ description: "Redeem poETH for ETH",
18468
+ target: CURRENT_PO_ETH$1,
18469
+ functionSignature: "redeem(uint256,address,address)",
18470
+ addressArguments: [VAULT$1, VAULT$1],
18471
+ canSendValue: false
18472
+ },
18473
+ {
18474
+ description: "Approve poUSDC v3 to spend USDC",
18475
+ target: USDC$1,
18476
+ functionSignature: "approve(address,uint256)",
18477
+ addressArguments: [NEW_PO_USDC$1],
18478
+ canSendValue: false
18479
+ },
18480
+ {
18481
+ description: "Deposit USDC for poUSDC v3",
18482
+ target: NEW_PO_USDC$1,
18483
+ functionSignature: "deposit(uint256,address)",
18484
+ addressArguments: [VAULT$1],
18485
+ canSendValue: false
18486
+ },
18487
+ {
18488
+ description: "Withdraw USDC from poUSDC v3",
18489
+ target: NEW_PO_USDC$1,
18490
+ functionSignature: "withdraw(uint256,address,address)",
18491
+ addressArguments: [VAULT$1, VAULT$1],
18492
+ canSendValue: false
18493
+ },
18494
+ {
18495
+ description: "Withdraw USDC from poUSDC v3 (with open positions)",
18496
+ target: NEW_PO_USDC$1,
18497
+ functionSignature: "withdraw(uint256,address,address,uint256[],bool)",
18498
+ addressArguments: [VAULT$1, VAULT$1],
18499
+ canSendValue: false
18500
+ },
18501
+ {
18502
+ description: "Mint poUSDC v3 using USDC",
18503
+ target: NEW_PO_USDC$1,
18504
+ functionSignature: "mint(uint256,address)",
18505
+ addressArguments: [VAULT$1],
18506
+ canSendValue: false
18507
+ },
18508
+ {
18509
+ description: "Redeem poUSDC v3 for USDC",
18510
+ target: NEW_PO_USDC$1,
18511
+ functionSignature: "redeem(uint256,address,address)",
18512
+ addressArguments: [VAULT$1, VAULT$1],
18513
+ canSendValue: false
18514
+ },
18515
+ {
18516
+ description: "Dispatch mint/burn options on PanopticPool",
18517
+ target: NEW_POOL$1,
18518
+ functionSignature: DISPATCH_SIGNATURE$1,
18519
+ addressArguments: [],
18520
+ canSendValue: false
18521
+ },
18522
+ {
18523
+ description: "Approve poWETH v3 to spend WETH",
18524
+ target: WETH$1,
18525
+ functionSignature: "approve(address,uint256)",
18526
+ addressArguments: [NEW_PO_WETH$1],
18527
+ canSendValue: false
18528
+ },
18529
+ {
18530
+ description: "Deposit WETH for poWETH v3",
18531
+ target: NEW_PO_WETH$1,
18532
+ functionSignature: "deposit(uint256,address)",
18533
+ addressArguments: [VAULT$1],
18534
+ canSendValue: false
18535
+ },
18536
+ {
18537
+ description: "Withdraw WETH from poWETH v3",
18538
+ target: NEW_PO_WETH$1,
18539
+ functionSignature: "withdraw(uint256,address,address)",
18540
+ addressArguments: [VAULT$1, VAULT$1],
18541
+ canSendValue: false
18542
+ },
18543
+ {
18544
+ description: "Withdraw WETH from poWETH v3 (with open positions)",
18545
+ target: NEW_PO_WETH$1,
18546
+ functionSignature: "withdraw(uint256,address,address,uint256[],bool)",
18547
+ addressArguments: [VAULT$1, VAULT$1],
18548
+ canSendValue: false
18549
+ },
18550
+ {
18551
+ description: "Mint poWETH v3 using WETH",
18552
+ target: NEW_PO_WETH$1,
18553
+ functionSignature: "mint(uint256,address)",
18554
+ addressArguments: [VAULT$1],
18555
+ canSendValue: false
18556
+ },
18557
+ {
18558
+ description: "Redeem poWETH v3 for WETH",
18559
+ target: NEW_PO_WETH$1,
18560
+ functionSignature: "redeem(uint256,address,address)",
18561
+ addressArguments: [VAULT$1, VAULT$1],
18562
+ canSendValue: false
18563
+ }
18564
+ ];
18565
+ const MAINNET_USDC_PLP_STRATEGIST_ARTIFACT_METADATA = {
18566
+ accountantAddress: "0x65aA902AE3135658587FFC36ED51B61c927114e1",
18567
+ boringVaultAddress: VAULT$1,
18568
+ decoderAndSanitizerAddress: DECODER$1,
18569
+ managerAddress: "0x2ce65016366ef7320078e0758D58Cf1038bc7C4e"
18570
+ };
18571
+ /** Number of leaf definitions authorized before the V3 pool release. */
18572
+ const PRE_V3_AUTHORIZATION_LEAF_COUNT$1 = 12;
18573
+ /** Production permissions before the ETH/USDC 5bps v3 pool authorization executes. */
18574
+ const MainnetUSDCPLPPreviousStrategistLeaves = createStrategistLeavesArtifact(MAINNET_USDC_PLP_STRATEGIST_ARTIFACT_METADATA, MAINNET_USDC_PLP_STRATEGIST_LEAF_DEFINITIONS.slice(0, PRE_V3_AUTHORIZATION_LEAF_COUNT$1));
18575
+ /** Production permissions after the ETH/USDC 5bps v3 pool authorization executes. */
18576
+ const MainnetUSDCPLPStrategistLeaves = createStrategistLeavesArtifact(MAINNET_USDC_PLP_STRATEGIST_ARTIFACT_METADATA, MAINNET_USDC_PLP_STRATEGIST_LEAF_DEFINITIONS);
18577
+
18578
+ //#endregion
18579
+ //#region src/hypoVault/hypoVaultManagerArtifacts/MainnetWETHPLPStrategistLeaves.ts
18580
+ const MAINNET_DEPLOYMENT$2 = requireChainDeployment(MAINNET_CHAIN_ID);
18581
+ const NEW_POOL_DEPLOYMENT = MAINNET_DEPLOYMENT$2.panoptic.additionalPools?.ethUsdc5bpsV3;
18582
+ if (NEW_POOL_DEPLOYMENT === void 0) throw new Error("Missing mainnet ETH/USDC 5bps v3 Panoptic pool deployment");
18583
+ const VAULT = MAINNET_DEPLOYMENT$2.hypovault.vaults.wethPlpVault;
18584
+ const DECODER = MAINNET_DEPLOYMENT$2.hypovault.core.collateralTrackerDecoderAndSanitizer;
18585
+ const CURRENT_POOL = MAINNET_DEPLOYMENT$2.panoptic.pool.panopticPool;
18586
+ const CURRENT_PO_ETH = MAINNET_DEPLOYMENT$2.panoptic.pool.collateralTracker0;
18587
+ const CURRENT_PO_USDC = MAINNET_DEPLOYMENT$2.panoptic.pool.collateralTracker1;
18588
+ const NEW_POOL = NEW_POOL_DEPLOYMENT.panopticPool;
18589
+ const NEW_PO_USDC = NEW_POOL_DEPLOYMENT.collateralTracker0;
18590
+ const NEW_PO_WETH = NEW_POOL_DEPLOYMENT.collateralTracker1;
18591
+ const USDC = "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48";
18592
+ const WETH = "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2";
18593
+ const DISPATCH_SIGNATURE = "dispatch(uint256[],uint256[],uint128[],int24[3][],bool,uint256)";
18594
+ const MAINNET_WETH_PLP_STRATEGIST_LEAF_DEFINITIONS = [
18595
+ {
18596
+ description: "Deposit ETH for poETH (payable)",
18597
+ target: CURRENT_PO_ETH,
18598
+ functionSignature: "deposit(uint256,address)",
18599
+ addressArguments: [VAULT],
18600
+ canSendValue: true
18601
+ },
18602
+ {
18603
+ description: "Withdraw ETH from poETH",
18604
+ target: CURRENT_PO_ETH,
18605
+ functionSignature: "withdraw(uint256,address,address)",
18606
+ addressArguments: [VAULT, VAULT],
18607
+ canSendValue: false
18608
+ },
18609
+ {
18610
+ description: "Withdraw ETH from poETH (with open positions)",
18611
+ target: CURRENT_PO_ETH,
18612
+ functionSignature: "withdraw(uint256,address,address,uint256[],bool)",
18613
+ addressArguments: [VAULT, VAULT],
18614
+ canSendValue: false
18615
+ },
18616
+ {
18617
+ description: "Mint poETH using ETH (payable)",
18618
+ target: CURRENT_PO_ETH,
18619
+ functionSignature: "mint(uint256,address)",
18620
+ addressArguments: [VAULT],
18621
+ canSendValue: true
18622
+ },
18623
+ {
18624
+ description: "Redeem poETH for ETH",
18625
+ target: CURRENT_PO_ETH,
18626
+ functionSignature: "redeem(uint256,address,address)",
18627
+ addressArguments: [VAULT, VAULT],
18628
+ canSendValue: false
18629
+ },
18630
+ {
18631
+ description: "Dispatch mint/burn options on PanopticPool",
18632
+ target: CURRENT_POOL,
18633
+ functionSignature: DISPATCH_SIGNATURE,
18634
+ addressArguments: [],
18635
+ canSendValue: false
18636
+ },
18637
+ {
18638
+ description: "Wrap ETH to WETH",
18639
+ target: WETH,
18640
+ functionSignature: "deposit()",
18641
+ addressArguments: [],
18642
+ canSendValue: true
18643
+ },
18644
+ {
18645
+ description: "Unwrap WETH to ETH",
18646
+ target: WETH,
18647
+ functionSignature: "withdraw(uint256)",
18648
+ addressArguments: [],
18649
+ canSendValue: false
18650
+ },
18651
+ {
18652
+ description: "Withdraw USDC from poUSDC",
18653
+ target: CURRENT_PO_USDC,
18654
+ functionSignature: "withdraw(uint256,address,address)",
18655
+ addressArguments: [VAULT, VAULT],
18656
+ canSendValue: false
18657
+ },
18658
+ {
18659
+ description: "Withdraw USDC from poUSDC (with open positions)",
18660
+ target: CURRENT_PO_USDC,
18661
+ functionSignature: "withdraw(uint256,address,address,uint256[],bool)",
18662
+ addressArguments: [VAULT, VAULT],
18663
+ canSendValue: false
18664
+ },
18665
+ {
18666
+ description: "Approve poUSDC to spend USDC",
18667
+ target: USDC,
18668
+ functionSignature: "approve(address,uint256)",
18669
+ addressArguments: [CURRENT_PO_USDC],
18670
+ canSendValue: false
18671
+ },
18672
+ {
18673
+ description: "Deposit USDC for poUSDC",
18674
+ target: CURRENT_PO_USDC,
18675
+ functionSignature: "deposit(uint256,address)",
18676
+ addressArguments: [VAULT],
18677
+ canSendValue: false
18678
+ },
18679
+ {
18680
+ description: "Mint poUSDC using USDC",
18681
+ target: CURRENT_PO_USDC,
18682
+ functionSignature: "mint(uint256,address)",
18683
+ addressArguments: [VAULT],
18684
+ canSendValue: false
18685
+ },
18686
+ {
18687
+ description: "Redeem poUSDC for USDC",
18688
+ target: CURRENT_PO_USDC,
18689
+ functionSignature: "redeem(uint256,address,address)",
18690
+ addressArguments: [VAULT, VAULT],
18691
+ canSendValue: false
18692
+ },
18693
+ {
18694
+ description: "Approve poWETH v3 to spend WETH",
18695
+ target: WETH,
18696
+ functionSignature: "approve(address,uint256)",
18697
+ addressArguments: [NEW_PO_WETH],
18698
+ canSendValue: false
18699
+ },
18700
+ {
18701
+ description: "Deposit WETH for poWETH v3",
18702
+ target: NEW_PO_WETH,
18703
+ functionSignature: "deposit(uint256,address)",
18704
+ addressArguments: [VAULT],
18705
+ canSendValue: false
18706
+ },
18707
+ {
18708
+ description: "Withdraw WETH from poWETH v3",
18709
+ target: NEW_PO_WETH,
18710
+ functionSignature: "withdraw(uint256,address,address)",
18711
+ addressArguments: [VAULT, VAULT],
18712
+ canSendValue: false
18713
+ },
18714
+ {
18715
+ description: "Withdraw WETH from poWETH v3 (with open positions)",
18716
+ target: NEW_PO_WETH,
18717
+ functionSignature: "withdraw(uint256,address,address,uint256[],bool)",
18718
+ addressArguments: [VAULT, VAULT],
18719
+ canSendValue: false
18720
+ },
18721
+ {
18722
+ description: "Mint poWETH v3 using WETH",
18723
+ target: NEW_PO_WETH,
18724
+ functionSignature: "mint(uint256,address)",
18725
+ addressArguments: [VAULT],
18726
+ canSendValue: false
18727
+ },
18728
+ {
18729
+ description: "Redeem poWETH v3 for WETH",
18730
+ target: NEW_PO_WETH,
18731
+ functionSignature: "redeem(uint256,address,address)",
18732
+ addressArguments: [VAULT, VAULT],
18733
+ canSendValue: false
18734
+ },
18735
+ {
18736
+ description: "Dispatch mint/burn options on PanopticPool",
18737
+ target: NEW_POOL,
18738
+ functionSignature: DISPATCH_SIGNATURE,
18739
+ addressArguments: [],
18740
+ canSendValue: false
18741
+ },
18742
+ {
18743
+ description: "Approve poUSDC v3 to spend USDC",
18744
+ target: USDC,
18745
+ functionSignature: "approve(address,uint256)",
18746
+ addressArguments: [NEW_PO_USDC],
18747
+ canSendValue: false
18748
+ },
18749
+ {
18750
+ description: "Deposit USDC for poUSDC v3",
18751
+ target: NEW_PO_USDC,
18752
+ functionSignature: "deposit(uint256,address)",
18753
+ addressArguments: [VAULT],
18754
+ canSendValue: false
18755
+ },
18756
+ {
18757
+ description: "Withdraw USDC from poUSDC v3",
18758
+ target: NEW_PO_USDC,
18759
+ functionSignature: "withdraw(uint256,address,address)",
18760
+ addressArguments: [VAULT, VAULT],
18761
+ canSendValue: false
18762
+ },
18763
+ {
18764
+ description: "Withdraw USDC from poUSDC v3 (with open positions)",
18765
+ target: NEW_PO_USDC,
18766
+ functionSignature: "withdraw(uint256,address,address,uint256[],bool)",
18767
+ addressArguments: [VAULT, VAULT],
18768
+ canSendValue: false
18769
+ },
18770
+ {
18771
+ description: "Mint poUSDC v3 using USDC",
18772
+ target: NEW_PO_USDC,
18773
+ functionSignature: "mint(uint256,address)",
18774
+ addressArguments: [VAULT],
18775
+ canSendValue: false
18776
+ },
18777
+ {
18778
+ description: "Redeem poUSDC v3 for USDC",
18779
+ target: NEW_PO_USDC,
18780
+ functionSignature: "redeem(uint256,address,address)",
18781
+ addressArguments: [VAULT, VAULT],
18782
+ canSendValue: false
18783
+ }
18784
+ ];
18785
+ const MAINNET_WETH_PLP_STRATEGIST_ARTIFACT_METADATA = {
18786
+ accountantAddress: MAINNET_DEPLOYMENT$2.hypovault.core.accountant,
18787
+ boringVaultAddress: VAULT,
18788
+ decoderAndSanitizerAddress: DECODER,
18789
+ managerAddress: MAINNET_DEPLOYMENT$2.hypovault.managers.wethPlpVaultManager
18790
+ };
18791
+ /** Number of leaf definitions authorized before the V3 pool release. */
18792
+ const PRE_V3_AUTHORIZATION_LEAF_COUNT = 10;
18793
+ /** Production permissions before the ETH/USDC 5bps v3 pool authorization executes. */
18794
+ const MainnetWETHPLPPreviousStrategistLeaves = createStrategistLeavesArtifact(MAINNET_WETH_PLP_STRATEGIST_ARTIFACT_METADATA, MAINNET_WETH_PLP_STRATEGIST_LEAF_DEFINITIONS.slice(0, PRE_V3_AUTHORIZATION_LEAF_COUNT));
18795
+ /** Production permissions after the ETH/USDC 5bps v3 pool authorization executes. */
18796
+ const MainnetWETHPLPStrategistLeaves = createStrategistLeavesArtifact(MAINNET_WETH_PLP_STRATEGIST_ARTIFACT_METADATA, MAINNET_WETH_PLP_STRATEGIST_LEAF_DEFINITIONS);
18797
+
18754
18798
  //#endregion
18755
18799
  //#region src/hypoVault/hypoVaultManagerArtifacts/SepoliaUSDCPLPStrategistLeaves.ts
18756
18800
  const SepoliaUSDCPLPStrategistLeaves = {
@@ -19087,6 +19131,145 @@ function encodeFulfillWithdrawalsFunctionData({ sharesToFulfill, maxAssetsReceiv
19087
19131
  });
19088
19132
  }
19089
19133
 
19134
+ //#endregion
19135
+ //#region src/hypoVault/mainnetV3Authorization.ts
19136
+ const MAINNET_DEPLOYMENT$1 = requireChainDeployment(MAINNET_CHAIN_ID);
19137
+ /** Block containing the successful V3 accountant-hash and manager-root update. */
19138
+ const MAINNET_V3_AUTHORIZATION_BLOCK = 25704951n;
19139
+ const POOL_INFO_ARRAY_ABI = {
19140
+ type: "tuple[]",
19141
+ components: [
19142
+ {
19143
+ name: "pool",
19144
+ type: "address"
19145
+ },
19146
+ {
19147
+ name: "token0",
19148
+ type: "address"
19149
+ },
19150
+ {
19151
+ name: "token1",
19152
+ type: "address"
19153
+ },
19154
+ {
19155
+ name: "maxPriceDeviation",
19156
+ type: "int24"
19157
+ }
19158
+ ]
19159
+ };
19160
+ function createVaultTransition(transition) {
19161
+ return {
19162
+ ...transition,
19163
+ generations: [{
19164
+ version: "previous",
19165
+ ...transition.previous
19166
+ }, {
19167
+ version: "next",
19168
+ ...transition.next
19169
+ }]
19170
+ };
19171
+ }
19172
+ function hashPoolInfos(poolInfos) {
19173
+ return keccak256(encodeAbiParameters([POOL_INFO_ARRAY_ABI], [poolInfos.map((poolInfo) => ({
19174
+ pool: getAddress(poolInfo.pool),
19175
+ token0: getAddress(poolInfo.token0),
19176
+ token1: getAddress(poolInfo.token1),
19177
+ maxPriceDeviation: poolInfo.maxPriceDeviation
19178
+ }))]));
19179
+ }
19180
+ function generation(poolInfos, strategistLeaves) {
19181
+ return {
19182
+ poolInfos,
19183
+ strategistLeaves,
19184
+ poolHash: hashPoolInfos(poolInfos),
19185
+ manageRoot: strategistLeaves.metadata.ManageRoot
19186
+ };
19187
+ }
19188
+ const MAINNET_V3_AUTHORIZATION_TRANSITIONS = [createVaultTransition({
19189
+ vaultAddress: MAINNET_DEPLOYMENT$1.hypovault.vaults.wethPlpVault,
19190
+ managerAddress: MAINNET_DEPLOYMENT$1.hypovault.managers.wethPlpVaultManager,
19191
+ strategistAddress: MAINNET_DEPLOYMENT$1.hypovault.turnkeySigners.wethPlpVaultManager,
19192
+ activationBlockNumber: MAINNET_V3_AUTHORIZATION_BLOCK,
19193
+ previous: generation(MainnetWETHPLPPreviousVaultPoolInfos.poolInfos, MainnetWETHPLPPreviousStrategistLeaves),
19194
+ next: generation(MainnetWETHPLPVaultPoolInfos.poolInfos, MainnetWETHPLPStrategistLeaves)
19195
+ }), createVaultTransition({
19196
+ vaultAddress: MAINNET_DEPLOYMENT$1.hypovault.vaults.usdcPlpVault,
19197
+ managerAddress: MAINNET_DEPLOYMENT$1.hypovault.managers.usdcPlpVaultManager,
19198
+ strategistAddress: MAINNET_DEPLOYMENT$1.hypovault.turnkeySigners.usdcPlpVaultManager,
19199
+ activationBlockNumber: MAINNET_V3_AUTHORIZATION_BLOCK,
19200
+ previous: generation(MainnetUSDCPLPPreviousVaultPoolInfos.poolInfos, MainnetUSDCPLPPreviousStrategistLeaves),
19201
+ next: generation(MainnetUSDCPLPVaultPoolInfos.poolInfos, MainnetUSDCPLPStrategistLeaves)
19202
+ })];
19203
+ const authorizationCacheByClient = new WeakMap();
19204
+ function findTransition(chainId, vaultAddress) {
19205
+ if (chainId !== MAINNET_CHAIN_ID) return null;
19206
+ const normalizedVault = vaultAddress.toLowerCase();
19207
+ return MAINNET_V3_AUTHORIZATION_TRANSITIONS.find((transition) => transition.vaultAddress.toLowerCase() === normalizedVault) ?? null;
19208
+ }
19209
+ /** Returns both known generations without reading chain state. */
19210
+ function getMainnetV3AuthorizationGenerations({ chainId, vaultAddress }) {
19211
+ const transition = findTransition(chainId, vaultAddress);
19212
+ return transition === null ? null : {
19213
+ previous: transition.previous,
19214
+ next: transition.next
19215
+ };
19216
+ }
19217
+ /**
19218
+ * Selects the mainnet authorization artifacts active at a historical block without RPC reads.
19219
+ * Live callers should use the compiled current artifacts directly; this selector exists for
19220
+ * block-pinned NAV and manager-input reconstruction across the V3 authorization boundary.
19221
+ */
19222
+ function getMainnetV3AuthorizationArtifactsAtBlock({ chainId, vaultAddress, blockNumber }) {
19223
+ const transition = findTransition(chainId, vaultAddress);
19224
+ if (transition === null) return null;
19225
+ const version = blockNumber < transition.activationBlockNumber ? "previous" : "next";
19226
+ return {
19227
+ blockNumber,
19228
+ version,
19229
+ ...transition[version]
19230
+ };
19231
+ }
19232
+ /**
19233
+ * Selects the exact artifact generation authorized by both the accountant and manager.
19234
+ * A mixed or unknown state is rejected: using only one side of the transition would
19235
+ * make either NAV calculation or strategist proof verification fail.
19236
+ * Every authorization release must add its generation to this transition table before
19237
+ * the on-chain hashes change, so startup and release verification keeps recognizing it.
19238
+ */
19239
+ async function resolveMainnetV3AuthorizationArtifacts({ viemClient, chainId, vaultAddress, blockNumber }) {
19240
+ const transition = findTransition(chainId, vaultAddress);
19241
+ if (transition === null) return null;
19242
+ const resolvedBlockNumber = blockNumber ?? await getBlockNumber(viemClient);
19243
+ const cacheKey = `${chainId}:${vaultAddress.toLowerCase()}:${resolvedBlockNumber.toString()}`;
19244
+ const clientCache = authorizationCacheByClient.get(viemClient);
19245
+ const cached = clientCache?.get(cacheKey);
19246
+ if (cached !== void 0) return cached;
19247
+ const [poolHash, manageRoot] = await Promise.all([readContract(viemClient, {
19248
+ address: MAINNET_DEPLOYMENT$1.hypovault.core.accountant,
19249
+ abi: PanopticVaultAccountantAbi,
19250
+ functionName: "vaultHashes",
19251
+ args: [transition.vaultAddress, 0n],
19252
+ blockNumber: resolvedBlockNumber
19253
+ }), readContract(viemClient, {
19254
+ address: transition.managerAddress,
19255
+ abi: HypoVaultManagerWithMerkleVerificationAbi,
19256
+ functionName: "manageRoot",
19257
+ args: [transition.strategistAddress],
19258
+ blockNumber: resolvedBlockNumber
19259
+ })]);
19260
+ for (const candidate of [...transition.generations].reverse()) if (poolHash === candidate.poolHash && manageRoot === candidate.manageRoot) {
19261
+ const resolved = {
19262
+ blockNumber: resolvedBlockNumber,
19263
+ ...candidate
19264
+ };
19265
+ const resolvedClientCache = clientCache ?? new Map();
19266
+ resolvedClientCache.set(cacheKey, resolved);
19267
+ if (clientCache === void 0) authorizationCacheByClient.set(viemClient, resolvedClientCache);
19268
+ return resolved;
19269
+ }
19270
+ throw new Error(`Unsupported or inconsistent mainnet v3 authorization state for vault ${transition.vaultAddress}: accountant pool hash ${poolHash}, manager root ${manageRoot}`);
19271
+ }
19272
+
19090
19273
  //#endregion
19091
19274
  //#region src/hypoVault/requestDeposit/requestDeposit.ts
19092
19275
  const getRequestDepositContractConfig = ({ vaultAddress, assets }) => ({
@@ -20347,13 +20530,12 @@ function createPlpManagerInputStrategy(minBlock) {
20347
20530
  minBlockNumber: minBlock,
20348
20531
  context: `PLP manager input for vault ${vault.id}`
20349
20532
  });
20350
- const authorization = await resolveMainnetV3AuthorizationArtifacts({
20351
- viemClient: client,
20533
+ const historicalPoolConfiguration = getMainnetVaultPoolConfigurationAtBlock({
20352
20534
  chainId,
20353
20535
  vaultAddress,
20354
20536
  blockNumber
20355
20537
  });
20356
- const poolInfos = authorization?.poolInfos ?? getVaultPoolInfos(vaultAddress, chainId);
20538
+ const poolInfos = historicalPoolConfiguration?.poolInfos ?? getVaultPoolInfos(vaultAddress, chainId);
20357
20539
  if (poolInfos.length === 0) return DEFAULT_MANAGER_INPUT;
20358
20540
  const tokenIds = candidates === void 0 ? await resolveVaultTokenIdsByPool({
20359
20541
  viemClient: client,
@@ -20367,9 +20549,10 @@ function createPlpManagerInputStrategy(minBlock) {
20367
20549
  vaultAddress,
20368
20550
  candidatesByPool: poolInfos.map((poolInfo) => {
20369
20551
  const candidate = candidates.find((item) => item.poolAddress.toLowerCase() === poolInfo.pool.toLowerCase());
20552
+ if (candidate === void 0) throw new Error(`Missing token-id candidates for authorized pool ${poolInfo.pool}`);
20370
20553
  return {
20371
20554
  poolAddress: poolInfo.pool,
20372
- candidates: candidate?.candidates ?? []
20555
+ candidates: candidate.candidates
20373
20556
  };
20374
20557
  }),
20375
20558
  blockNumber
@@ -20851,5 +21034,5 @@ function getAlchemyWsRpcUrl(chainId, alchemyApiKey) {
20851
21034
  }
20852
21035
 
20853
21036
  //#endregion
20854
- export { BASE_CHAIN_ID, BASE_DEPLOYMENT, BASE_ETH_USDC_5BPS_MARKET, BASE_HYPOVAULT_ADDRESSES, BASE_HYPOVAULT_CORE_ADDRESSES, BASE_HYPOVAULT_MANAGER_ADDRESSES, BASE_HYPOVAULT_MANAGER_TURNKEY_SIGNERS, BASE_PANOPTIC_POOL_ADDRESSES, BASE_PANOPTIC_V2_ADDRESSES, BORROW_INDEX_BITS, BPS_SCALE, BaseUSDCPLPStrategistLeaves, BaseUSDCPLPVaultPoolInfos, BaseWETHPLPStrategistLeaves, BaseWETHPLPVaultPoolInfos, CHAIN_DEPLOYMENTS, CollateralTrackerAbi, CollateralTrackerV1_1Abi, Erc1155Abi, Erc20Abi, HypoVaultAbi, HypoVaultManagerConfigSchema, HypoVaultManagerWithMerkleVerificationAbi, MAINNET_CHAIN_ID, MAINNET_DEPLOYMENT, MAINNET_ETH_USDC_5BPS_V3_PANOPTIC_POOL_ADDRESSES, MAINNET_PANOPTIC_V2_ADDRESSES, MAINNET_RISK_ENGINES, MARKET_EPOCH_BITS, MARKET_EPOCH_SHIFT, MainnetLegacyUSDCPLPStrategistLeaves, MainnetLegacyWETHPLPStrategistLeaves, MainnetUSDCPLPLegacyVaultPoolInfos, MainnetUSDCPLPPreviousStrategistLeaves, MainnetUSDCPLPPreviousVaultPoolInfos, MainnetUSDCPLPStrategistLeaves, MainnetUSDCPLPVaultPoolInfos, MainnetWETHPLPLegacyVaultPoolInfos, MainnetWETHPLPPreviousStrategistLeaves, MainnetWETHPLPPreviousVaultPoolInfos, MainnetWETHPLPStrategistLeaves, MainnetWETHPLPVaultPoolInfos, Multicall3Abi, NonFungiblePositionManagerAbi, PanopticFactoryV3Abi, PanopticFactoryV4Abi, PanopticHelperAbi, PanopticPoolAbi, PanopticPoolV1_1Abi, PanopticQueryV1_1Abi, PanopticVaultAccountantAbi, PanopticVaultAccountantManagerInputAbi, PoolManagerAbi, RATE_AT_TARGET_BITS, RescueDistributorAbi, SECONDS_PER_YEAR, SEPOLIA_CHAIN_ID, SEPOLIA_DEPLOYMENT, SEPOLIA_ETH_USDC_5BPS_MARKET, SEPOLIA_HYPOVAULT_ADDRESSES, SEPOLIA_HYPOVAULT_CORE_ADDRESSES, SEPOLIA_HYPOVAULT_MANAGER_ADDRESSES, SEPOLIA_HYPOVAULT_MANAGER_TURNKEY_SIGNERS, SEPOLIA_PANOPTIC_POOL_ADDRESSES, SEPOLIA_PANOPTIC_V2_ADDRESSES, SemiFungiblePositionManagerAbi, SemiFungiblePositionManagerV1_1Abi, SepoliaUSDCPLPStrategistLeaves, SepoliaUSDCPLPVaultPoolInfos, SepoliaWETHPLPStrategistLeaves, SepoliaWETHPLPVaultPoolInfos, Simple7702AccountAbi, StateViewAbi, UNREALIZED_INTEREST_BITS, UniswapHelperAbi, UniswapHelperV1_1Abi, UniswapMigratorAbi, UniswapV3FactoryAbi, UniswapV3PoolAbi, UsdcPlpVaultBaseProdConfig, UsdcPlpVaultMainnetLegacyConfig, UsdcPlpVaultMainnetProdConfig, UsdcPlpVaultSepoliaDevConfig, UsdcPlpVaultSepoliaProdConfig, VAULT_DISPLAY_NAMES_PER_CHAIN, VAULT_DISPLAY_NAME_RESOLVERS_PER_CHAIN, VaultApyPreInceptionBlockError, WAD, WETHAbi, WethPlpVaultBaseProdConfig, WethPlpVaultMainnetLegacyConfig, WethPlpVaultMainnetProdConfig, WethPlpVaultSepoliaDevConfig, WethPlpVaultSepoliaProdConfig, adjustUnderlyingIdleBalance, annualizePerSecondRateWad, buildClaimVaultShareCalldatas, buildExecuteDepositCalldatas, buildExecuteWithdrawalCalldatas, buildManageArgs, buildManagerInput, buildManagerInputAtBlock, buildRequestWithdrawalCalldatas, buildVaultManagerInput, buildVaultManagerInputAtBlock, builderFactoryAbi, builderWalletAbi, calculateAnnualizedApyPct, calculateAssetsFromShares, calculateAvailableShares, calculateClaimableAssetsFromQueuedWithdrawals, calculateClaimableSharesFromQueuedDeposits, calculateSharesFromAssets, calculateVaultNetLendingApyPctFromTrackerInputs, calculateVaultNetLendingYieldUnderlyingFromTrackerInputs, cancelDeposit, chainToHypoVaultGraphQlAPI, collateralTrackerV2Abi as collateralTrackerAbi, collateralTrackerV2Abi, computeSharePriceFromNavSnapshot, convertJsonTreeToArray, deriveSupplyRatePerSecWad, deriveVaultApyTimeseriesFromSharePrices, encodeApproveFunctionData, encodeCancelDepositFunctionData, encodeDepositFunctionData, encodeExecuteDepositFunctionData, encodeExecuteWithdrawalFunctionData, encodeExecuteWithdrawalMulticallFunctionData, encodeFulfillDepositsFunctionData, encodeFulfillWithdrawalsFunctionData, encodeRequestDepositFunctionData, encodeRequestWithdrawalFunctionData, encodeRequestWithdrawalMulticallFunctionData, encodeWithdrawFunctionData, executeWithdrawal, executeWithdrawalMulticall, fetchFirstDepositTimestampByVaultId, fetchVaultLendingAllocation, fetchVaultNetLendingApyPct, fetchVaultNetLendingYieldUnderlying, fetchVaultSharePriceSnapshot, findLeaf, findLeafForTarget, formatPerSecondRateWadAsAprPct, formatPerSecondRateWadAsApyPct, generateProof, getAlchemyRpcUrl, getAlchemyWsRpcUrl, getCancelDepositContractConfig, getChainDeployment, getEthUsdcMarket, getExecuteWithdrawalContractConfig, getExecuteWithdrawalMulticallContractConfig, getHypoVaultConfigForVault, getHypoVaultGraphQLClient, getIrmCurrent, getIrmCurve, getLendingAllocationRows, getMainnetV3AuthorizationGenerations, getMinQueuedDepositEpoch, getProofsFromDigests, getProofsUsingTree, getRequestDepositContractConfig, getRequestWithdrawalContractConfig, getRequestWithdrawalMulticallContractConfig, getStaleOracleOverrideBytecodeForAccountant, getStaleOracleStateOverrideForAccountant, getVaultApyErrorMessage, getVaultApyStrategy, getVaultPoolInfos, isExpectedHistoricalReadMiss, isStaleOraclePriceError, isStaleOraclePriceReadError, isSupportedChain, packMarketState, panopticFactoryV4Abi as panopticFactoryAbi, panopticFactoryV3Abi, panopticFactoryV4Abi, panopticPoolV2Abi as panopticPoolAbi, panopticPoolV2Abi, panopticQueryAbi, parseCustomError, ratePerSecWadToAprPct, requestDeposit, requestWithdrawal, requestWithdrawalMulticall, requireChainDeployment, resolveMainnetV3AuthorizationArtifacts, resolveVaultDisplayName, resolveVaultHistoricalCandidatesByPool, resolveVaultTokenIdsByPool, riskEngineAbi, semiFungiblePositionManagerV4Abi as semiFungiblePositionManagerAbi, semiFungiblePositionManagerV3Abi, semiFungiblePositionManagerV4Abi, setVaultApyStrategyOverride, simulateCancelDeposit, simulateExecuteWithdrawal, simulateExecuteWithdrawalMulticall, simulateRequestDeposit, simulateRequestWithdrawal, simulateRequestWithdrawalMulticall, useCancelDeposit, useClaimVaultShares, useExecuteWithdrawal, useRequestDeposit, useRequestWithdrawal, utilizationBpsToWad, utilizationPctToWad, verifyVaultOpenTokenIdsAtBlock };
21037
+ export { BASE_CHAIN_ID, BASE_DEPLOYMENT, BASE_ETH_USDC_5BPS_MARKET, BASE_HYPOVAULT_ADDRESSES, BASE_HYPOVAULT_CORE_ADDRESSES, BASE_HYPOVAULT_MANAGER_ADDRESSES, BASE_HYPOVAULT_MANAGER_TURNKEY_SIGNERS, BASE_PANOPTIC_POOL_ADDRESSES, BASE_PANOPTIC_V2_ADDRESSES, BORROW_INDEX_BITS, BPS_SCALE, BaseUSDCPLPStrategistLeaves, BaseUSDCPLPVaultPoolInfos, BaseWETHPLPStrategistLeaves, BaseWETHPLPVaultPoolInfos, CHAIN_DEPLOYMENTS, CollateralTrackerAbi, CollateralTrackerV1_1Abi, Erc1155Abi, Erc20Abi, HypoVaultAbi, HypoVaultManagerConfigSchema, HypoVaultManagerWithMerkleVerificationAbi, MAINNET_CHAIN_ID, MAINNET_DEPLOYMENT, MAINNET_ETH_USDC_5BPS_V3_PANOPTIC_POOL_ADDRESSES, MAINNET_PANOPTIC_V2_ADDRESSES, MAINNET_RISK_ENGINES, MAINNET_V3_AUTHORIZATION_BLOCK, MARKET_EPOCH_BITS, MARKET_EPOCH_SHIFT, MainnetLegacyUSDCPLPStrategistLeaves, MainnetLegacyWETHPLPStrategistLeaves, MainnetUSDCPLPLegacyVaultPoolInfos, MainnetUSDCPLPPreviousStrategistLeaves, MainnetUSDCPLPPreviousVaultPoolInfos, MainnetUSDCPLPStrategistLeaves, MainnetUSDCPLPVaultPoolInfos, MainnetWETHPLPLegacyVaultPoolInfos, MainnetWETHPLPPreviousStrategistLeaves, MainnetWETHPLPPreviousVaultPoolInfos, MainnetWETHPLPStrategistLeaves, MainnetWETHPLPVaultPoolInfos, Multicall3Abi, NonFungiblePositionManagerAbi, PanopticFactoryV3Abi, PanopticFactoryV4Abi, PanopticHelperAbi, PanopticPoolAbi, PanopticPoolV1_1Abi, PanopticQueryV1_1Abi, PanopticVaultAccountantAbi, PanopticVaultAccountantManagerInputAbi, PoolManagerAbi, RATE_AT_TARGET_BITS, RescueDistributorAbi, SECONDS_PER_YEAR, SEPOLIA_CHAIN_ID, SEPOLIA_DEPLOYMENT, SEPOLIA_ETH_USDC_5BPS_MARKET, SEPOLIA_HYPOVAULT_ADDRESSES, SEPOLIA_HYPOVAULT_CORE_ADDRESSES, SEPOLIA_HYPOVAULT_MANAGER_ADDRESSES, SEPOLIA_HYPOVAULT_MANAGER_TURNKEY_SIGNERS, SEPOLIA_PANOPTIC_POOL_ADDRESSES, SEPOLIA_PANOPTIC_V2_ADDRESSES, SemiFungiblePositionManagerAbi, SemiFungiblePositionManagerV1_1Abi, SepoliaUSDCPLPStrategistLeaves, SepoliaUSDCPLPVaultPoolInfos, SepoliaWETHPLPStrategistLeaves, SepoliaWETHPLPVaultPoolInfos, Simple7702AccountAbi, StateViewAbi, UNREALIZED_INTEREST_BITS, UniswapHelperAbi, UniswapHelperV1_1Abi, UniswapMigratorAbi, UniswapV3FactoryAbi, UniswapV3PoolAbi, UsdcPlpVaultBaseProdConfig, UsdcPlpVaultMainnetLegacyConfig, UsdcPlpVaultMainnetProdConfig, UsdcPlpVaultSepoliaDevConfig, UsdcPlpVaultSepoliaProdConfig, VAULT_DISPLAY_NAMES_PER_CHAIN, VAULT_DISPLAY_NAME_RESOLVERS_PER_CHAIN, VaultApyPreInceptionBlockError, WAD, WETHAbi, WethPlpVaultBaseProdConfig, WethPlpVaultMainnetLegacyConfig, WethPlpVaultMainnetProdConfig, WethPlpVaultSepoliaDevConfig, WethPlpVaultSepoliaProdConfig, adjustUnderlyingIdleBalance, annualizePerSecondRateWad, buildClaimVaultShareCalldatas, buildExecuteDepositCalldatas, buildExecuteWithdrawalCalldatas, buildManageArgs, buildManagerInput, buildManagerInputAtBlock, buildRequestWithdrawalCalldatas, buildVaultManagerInput, buildVaultManagerInputAtBlock, builderFactoryAbi, builderWalletAbi, calculateAnnualizedApyPct, calculateAssetsFromShares, calculateAvailableShares, calculateClaimableAssetsFromQueuedWithdrawals, calculateClaimableSharesFromQueuedDeposits, calculateSharesFromAssets, calculateVaultNetLendingApyPctFromTrackerInputs, calculateVaultNetLendingYieldUnderlyingFromTrackerInputs, cancelDeposit, chainToHypoVaultGraphQlAPI, collateralTrackerV2Abi as collateralTrackerAbi, collateralTrackerV2Abi, computeSharePriceFromNavSnapshot, convertJsonTreeToArray, deriveSupplyRatePerSecWad, deriveVaultApyTimeseriesFromSharePrices, encodeApproveFunctionData, encodeCancelDepositFunctionData, encodeDepositFunctionData, encodeExecuteDepositFunctionData, encodeExecuteWithdrawalFunctionData, encodeExecuteWithdrawalMulticallFunctionData, encodeFulfillDepositsFunctionData, encodeFulfillWithdrawalsFunctionData, encodeRequestDepositFunctionData, encodeRequestWithdrawalFunctionData, encodeRequestWithdrawalMulticallFunctionData, encodeWithdrawFunctionData, executeWithdrawal, executeWithdrawalMulticall, fetchFirstDepositTimestampByVaultId, fetchVaultLendingAllocation, fetchVaultNetLendingApyPct, fetchVaultNetLendingYieldUnderlying, fetchVaultSharePriceSnapshot, findLeaf, findLeafForTarget, formatPerSecondRateWadAsAprPct, formatPerSecondRateWadAsApyPct, generateProof, getAlchemyRpcUrl, getAlchemyWsRpcUrl, getCancelDepositContractConfig, getChainDeployment, getEthUsdcMarket, getExecuteWithdrawalContractConfig, getExecuteWithdrawalMulticallContractConfig, getHypoVaultConfigForVault, getHypoVaultGraphQLClient, getIrmCurrent, getIrmCurve, getLendingAllocationRows, getMainnetV3AuthorizationArtifactsAtBlock, getMainnetV3AuthorizationGenerations, getMainnetVaultManagerRootAtBlock, getMainnetVaultManagerRootHistory, getMainnetVaultPoolConfigurationAtBlock, getMainnetVaultPoolConfigurationHistory, getMinQueuedDepositEpoch, getProofsFromDigests, getProofsUsingTree, getRequestDepositContractConfig, getRequestWithdrawalContractConfig, getRequestWithdrawalMulticallContractConfig, getStaleOracleOverrideBytecodeForAccountant, getStaleOracleStateOverrideForAccountant, getVaultApyErrorMessage, getVaultApyStrategy, getVaultPoolInfos, isExpectedHistoricalReadMiss, isStaleOraclePriceError, isStaleOraclePriceReadError, isSupportedChain, packMarketState, panopticFactoryV4Abi as panopticFactoryAbi, panopticFactoryV3Abi, panopticFactoryV4Abi, panopticPoolV2Abi as panopticPoolAbi, panopticPoolV2Abi, panopticQueryAbi, parseCustomError, ratePerSecWadToAprPct, requestDeposit, requestWithdrawal, requestWithdrawalMulticall, requireChainDeployment, resolveMainnetV3AuthorizationArtifacts, resolveVaultDisplayName, resolveVaultHistoricalCandidatesByPool, resolveVaultTokenIdsByPool, riskEngineAbi, semiFungiblePositionManagerV4Abi as semiFungiblePositionManagerAbi, semiFungiblePositionManagerV3Abi, semiFungiblePositionManagerV4Abi, setVaultApyStrategyOverride, simulateCancelDeposit, simulateExecuteWithdrawal, simulateExecuteWithdrawalMulticall, simulateRequestDeposit, simulateRequestWithdrawal, simulateRequestWithdrawalMulticall, useCancelDeposit, useClaimVaultShares, useExecuteWithdrawal, useRequestDeposit, useRequestWithdrawal, utilizationBpsToWad, utilizationPctToWad, verifyVaultOpenTokenIdsAtBlock };
20855
21038
  //# sourceMappingURL=index.js.map