@panoptic-eng/sdk 1.0.60 → 1.0.61

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- {"version":3,"file":"vault-transaction-fees.js","names":["chainDeploymentsData","value: bigint","numerator: bigint","denominator: bigint","values: readonly bigint[]","chainId: number | undefined","priorityFee: bigint","quote: VaultTransactionFeeQuote","gasLimit: bigint","gasEstimate: bigint","feeCaps: VaultSignedTransactionFeeCaps","quote?: VaultTransactionFeeQuote","feeHistoryError: unknown","client: Client<Transport, chain>"],"sources":["../../deployments/src/chainDeployments.data.json","../../deployments/src/chainDeployments.js","../../deployments/src/vaultDisplayNames.js","../src/hypoVault/transactionFees.ts"],"sourcesContent":["{\n \"1\": {\n \"chainId\": 1,\n \"infrastructure\": {\n \"uniswapV3Factory\": \"0x1F98431c8aD98523631AE4a59f267346ea31F984\",\n \"poolManager\": \"0x000000000004444c5dc75cB358380D2e3dE08A90\",\n \"stateView\": \"0x7ffe42c4a5deea5b0fec41c94c136cf115597227\"\n },\n \"hypovault\": {\n \"core\": {\n \"hypoVaultImplementation\": \"0xF16714665955DBd0361D997eFc50fe391D96E8D0\",\n \"factory\": \"0xd5049B2647de57141dE7F65E5124707B99A452A3\",\n \"accountant\": \"0x65aA902AE3135658587FFC36ED51B61c927114e1\",\n \"rolesAuthority\": \"0xb952D345c413Ddb7850173422bAe4968e0330598\",\n \"collateralTrackerDecoderAndSanitizer\": \"0xC87c45d2dbE5acb56013e2591427ECC84Fa251E6\"\n },\n \"vaults\": {\n \"wethPlpVault\": \"0xd4e2c720a760049cc4151bcf61e3a9348db9cd92\",\n \"usdcPlpVault\": \"0x236d0558f06cd60780b232d4Ec4c92d2cb7e4D18\"\n },\n \"managers\": {\n \"wethPlpVaultManager\": \"0xB6Fc48e658C9B1a7dbdFA51A5E153ab60BB2e04d\",\n \"usdcPlpVaultManager\": \"0x2ce65016366ef7320078e0758D58Cf1038bc7C4e\"\n },\n \"turnkeySigners\": {\n \"wethPlpVaultManager\": \"0x8FfA6DAB99f8afc64F61BeF83F0966eD6362f24F\",\n \"usdcPlpVaultManager\": \"0x3c1c79d0cfc316Ba959194c89696a8382d7d283b\"\n }\n },\n \"panoptic\": {\n \"pool\": {\n \"version\": \"v4\",\n \"panopticPool\": \"0x00000000563b70d704f4c6675a5f6ac989fbae13\",\n \"collateralTracker0\": \"0x1e46b0289B7E0F710E2Db8Ab87800dd782D624f7\",\n \"collateralTracker1\": \"0x12bF31955522BAC337D93e1bC0a39F68D8BDa216\"\n },\n \"additionalPools\": {\n \"ethUsdc5bpsV3\": {\n \"version\": \"v3\",\n \"panopticPool\": \"0x00000000009C7B687e833559e34503f64d7ed7c4\",\n \"collateralTracker0\": \"0x3CCdA7d5E841d6543D90BcEc20b36a724C184DE9\",\n \"collateralTracker1\": \"0x69E9f9e44E5F52237493b980dd7306198C64A4E4\"\n }\n },\n \"v2\": {\n \"semiFungiblePositionManagerV4\": \"0x00000000000005C3287f136Ef5AF56c68Ea6849f\",\n \"semiFungiblePositionManagerV3\": \"0x00000000000005E4693aDc8Ec0f12D686f728198\",\n \"builderFactory\": \"0x0000000000000a3D22E158417AA639D7F71b0FF7\",\n \"riskEngine\": \"0x000000000000075e29cdaa9cb640a69e148ca7da\",\n \"panopticPoolImplementation\": \"0x000000000000135429F0DaCaB61639Bf6a63EbbC\",\n \"collateralTrackerImplementation\": \"0x0000000000001d9c38CA405A2e04420865A08A33\",\n \"panopticFactoryV4\": \"0x0000000000000c51d0f8cf4bd9adE7191372a625\",\n \"panopticFactoryV3\": \"0x0000000000000aDC9A108591e718F2aee963a2a7\",\n \"panopticHelper\": \"0x0000000000000000000000000000000000000000\",\n \"panopticMath\": \"0x000000000000334bbd65C195581cf59ECf315932\",\n \"panopticQuery\": \"0x0000000000000e1aE9c66C1c3B0A547D23389C93\",\n \"interactionHelper\": \"0x00000000000041fe14Ce3c2392337CE501aE8328\"\n }\n },\n \"riskEngines\": [\n \"0x000000000000075e29cdaa9cb640a69e148ca7da\",\n \"0x0000000000000fe1e261f66ce2f44def4f5ae0cb\"\n ],\n \"markets\": {\n \"ethUsdc30bps\": {\n \"currency0\": \"0x0000000000000000000000000000000000000000\",\n \"currency1\": \"0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48\",\n \"fee\": 3000,\n \"tickSpacing\": 60,\n \"poolId\": \"0x3C08AE4977F78D\"\n }\n },\n \"subgraphs\": {\n \"hypovault\": \"https://api.goldsky.com/api/public/project_cl9gc21q105380hxuh8ks53k3/subgraphs/hypovault-subgraph-mainnet/prod/gn\",\n \"panoptic\": \"https://api.goldsky.com/api/public/project_cl9gc21q105380hxuh8ks53k3/subgraphs/panoptic-subgraph-mainnet/v2_prod/gn\"\n },\n \"sfpmSwap\": {\n \"version\": \"v3\",\n \"sfpm\": \"0x00000000000005E4693aDc8Ec0f12D686f728198\",\n \"poolAddress\": \"0x88e6A0c2dDD26FEEb64F039a2c41296FcB3f5640\",\n \"poolId\": \"2824133844976349\",\n \"fee\": 500,\n \"weth\": \"0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2\"\n },\n \"deprecatedRiskEngines\": [\n \"0x0000000000000e673aECBDB5f5fE5DFAf4a8e9Ac\",\n \"0x0000000000000E65545005B26207D7edFd031260\"\n ]\n },\n \"4663\": {\n \"chainId\": 4663,\n \"infrastructure\": {\n \"uniswapV3Factory\": \"0x1f7d7550b1b028f7571e69a784071f0205fd2efa\",\n \"poolManager\": \"0x8366a39cc670b4001a1121b8f6a443a643e40951\",\n \"stateView\": \"0xf3334192d15450cdd385c8b70e03f9a6bd9e673b\"\n },\n \"hypovault\": {\n \"core\": {\n \"hypoVaultImplementation\": \"0xF16714665955DBd0361D997eFc50fe391D96E8D0\",\n \"factory\": \"0xd5049B2647de57141dE7F65E5124707B99A452A3\",\n \"accountant\": \"0x9e345d862c41010F87D8E5A279e8D320D2831D36\",\n \"rolesAuthority\": \"0xb952D345c413Ddb7850173422bAe4968e0330598\",\n \"collateralTrackerDecoderAndSanitizer\": \"0xC87c45d2dbE5acb56013e2591427ECC84Fa251E6\"\n },\n \"vaults\": {\n \"wethPlpVault\": \"0x0000000000000000000000000000000000000000\",\n \"usdcPlpVault\": \"0x0000000000000000000000000000000000000000\",\n \"usdgPlpVault\": \"0x08B24123252Bd9c4DD473b6573D4cF67196FFC4B\"\n },\n \"managers\": {\n \"wethPlpVaultManager\": \"0x0000000000000000000000000000000000000000\",\n \"usdcPlpVaultManager\": \"0x0000000000000000000000000000000000000000\",\n \"usdgPlpVaultManager\": \"0x67Edb096585efe88a9A1ee16c5857AB74Fc8EA87\"\n },\n \"turnkeySigners\": {\n \"wethPlpVaultManager\": \"0x0000000000000000000000000000000000000000\",\n \"usdcPlpVaultManager\": \"0x0000000000000000000000000000000000000000\",\n \"usdgPlpVaultManager\": \"0x8FfA6DAB99f8afc64F61BeF83F0966eD6362f24F\"\n }\n },\n \"panoptic\": {\n \"pool\": {\n \"version\": \"v4\",\n \"panopticPool\": \"0x00000000989bcb6f24af4a1Ab2A6d6a31c98A58E\",\n \"collateralTracker0\": \"0x49eaAC32A7CD4B8fB2209a12859a95E0b20aB0e5\",\n \"collateralTracker1\": \"0x670C44a0FC35dbC410498e47A6290a1C3196d191\"\n },\n \"v2\": {\n \"semiFungiblePositionManagerV4\": \"0x00000000000005C3287f136Ef5AF56c68Ea6849f\",\n \"semiFungiblePositionManagerV3\": \"0x00000000000005E4693aDc8Ec0f12D686f728198\",\n \"builderFactory\": \"0x0000000000000a3D22E158417AA639D7F71b0FF7\",\n \"riskEngine\": \"0x000000000000075e29cdaa9cb640a69e148ca7da\",\n \"panopticPoolImplementation\": \"0x000000000000135429F0DaCaB61639Bf6a63EbbC\",\n \"collateralTrackerImplementation\": \"0x0000000000001d9c38CA405A2e04420865A08A33\",\n \"panopticFactoryV4\": \"0x0000000000000c51d0f8cf4bd9adE7191372a625\",\n \"panopticFactoryV3\": \"0x0000000000000aDC9A108591e718F2aee963a2a7\",\n \"panopticHelper\": \"0x0000000000000000000000000000000000000000\",\n \"panopticMath\": \"0x000000000000334bbd65C195581cf59ECf315932\",\n \"panopticQuery\": \"0x0000000000000e1aE9c66C1c3B0A547D23389C93\",\n \"interactionHelper\": \"0x00000000000041fe14Ce3c2392337CE501aE8328\"\n }\n },\n \"riskEngines\": [\n \"0x000000000000075e29cdaa9cb640a69e148ca7da\",\n \"0x0000000000000fe1e261f66ce2f44def4f5ae0cb\",\n \"0x0000000000000f3fb82469581A74776178E76Ca4\"\n ],\n \"markets\": {\n \"spyUsdg\": {\n \"currency0\": \"0x117cc2133c37B721F49dE2A7a74833232B3B4C0C\",\n \"currency1\": \"0x5fc5360D0400a0Fd4f2af552ADD042D716F1d168\",\n \"fee\": 3000,\n \"tickSpacing\": 60,\n \"poolId\": \"0xfe2a80bb5618fd14984b92ca6d45bf5ba67443ddb1435e28b2e48df2fc1526cd\"\n }\n },\n \"subgraphs\": {\n \"hypovault\": \"https://api.goldsky.com/api/public/project_cl9gc21q105380hxuh8ks53k3/subgraphs/hypovault-subgraph-robinhood/prod/gn\",\n \"panoptic\": \"https://api.goldsky.com/api/public/project_cl9gc21q105380hxuh8ks53k3/subgraphs/panoptic-subgraph-robinhood/v2_prod/gn\"\n },\n \"deprecatedRiskEngines\": [\n \"0x0000000000000E65545005B26207D7edFd031260\"\n ]\n },\n \"8453\": {\n \"chainId\": 8453,\n \"infrastructure\": {\n \"uniswapV3Factory\": \"0x33128a8fC17869897dcE68Ed026d694621f6FDfD\",\n \"poolManager\": \"0x498581fF718922c3f8e6A244956aF099B2652b2b\",\n \"stateView\": \"0xA3c0c9b65baD0b08107Aa264b0f3dB444b867A71\"\n },\n \"hypovault\": {\n \"core\": {\n \"hypoVaultImplementation\": \"0xec311aE06486ad44Ba782133b502A34aCE0f479E\",\n \"factory\": \"0x9bE53b169a41030f1710A9B82e9eA6413f14D12E\",\n \"accountant\": \"0x345cA3407942f9d175c9eA8B90e83A36F570f852\",\n \"rolesAuthority\": \"0x278D37CaBFFB4B72D2866E30fEFE08aef773E0B6\",\n \"collateralTrackerDecoderAndSanitizer\": \"0x4A290b3EC46cF320421Bb2aaee96d445de31CF0b\"\n },\n \"vaults\": {\n \"wethPlpVault\": \"0x41b7D0515d709A4Fd2CF27f9d141D0c2F8713D04\",\n \"usdcPlpVault\": \"0xb452af299c565D04B05E601efF2840e000C922f1\"\n },\n \"managers\": {\n \"wethPlpVaultManager\": \"0x2a4923456c79E9ebD10F5Bf5305a5C742bBc1D7C\",\n \"usdcPlpVaultManager\": \"0xdd6E2406a044582463CFE9F0C774870eAf4A310B\"\n },\n \"turnkeySigners\": {\n \"wethPlpVaultManager\": \"0x8FfA6DAB99f8afc64F61BeF83F0966eD6362f24F\",\n \"usdcPlpVaultManager\": \"0x3c1c79d0cfc316Ba959194c89696a8382d7d283b\"\n }\n },\n \"panoptic\": {\n \"pool\": {\n \"version\": \"v4\",\n \"panopticPool\": \"0xB50e8bb68f5855DA742f4579274902a20454174a\",\n \"collateralTracker0\": \"0x0d82b189c96EbB1f44A7207e6A9cfB1e490f2869\",\n \"collateralTracker1\": \"0x9ba1082Ab3cb9edEA988697A14BBe543A3dABEd2\"\n },\n \"v2\": {\n \"semiFungiblePositionManagerV4\": \"0x8dcAa08cF298F8b4830FAf56d47930981AdE33af\",\n \"semiFungiblePositionManagerV3\": \"0xFB1c06B491305d618bb8a7a368C6e50c001C153A\",\n \"builderFactory\": \"0x6d26E916a18d522f7DdA2a26d9E1645564ccDcA5\",\n \"riskEngine\": \"0x8bbce8b1eb64118cfe6c1eab0afe13b80ea41481\",\n \"panopticPoolImplementation\": \"0x5BA68a018fF149c38ec52D181Dd24aBabE9a07DB\",\n \"collateralTrackerImplementation\": \"0x34B3a4e4F14f292575ECe3EF67886C4598af459f\",\n \"panopticFactoryV4\": \"0x9ac0317fcd124aff0b5429beb8de17020bc45f9a\",\n \"panopticFactoryV3\": \"0x687f616d68c483a7223e6922f59aef7452e26c1d\",\n \"panopticHelper\": \"0x0000000000000000000000000000000000000000\",\n \"panopticMath\": \"0x6d21699192f5aF112C87e53b32ff846782afF407\",\n \"panopticQuery\": \"0xd2586E1bbdd1169F597F3A370117EdF7372A7350\",\n \"interactionHelper\": \"0x643d8DD5372FD6c71f8fAbCce4Eb8857704F3E15\"\n }\n },\n \"riskEngines\": [\n \"0x8bbce8b1eb64118cfe6c1eab0afe13b80ea41481\"\n ],\n \"markets\": {\n \"ethUsdc5bps\": {\n \"currency0\": \"0x0000000000000000000000000000000000000000\",\n \"currency1\": \"0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913\",\n \"fee\": 500,\n \"tickSpacing\": 10,\n \"poolId\": \"0x96d4b53a38337a5733179751781178a2613306063c511b78cd02684739288c0a\"\n }\n },\n \"subgraphs\": {\n \"hypovault\": \"https://api.goldsky.com/api/public/project_cl9gc21q105380hxuh8ks53k3/subgraphs/hypovault-subgraph-base/prod/gn\",\n \"panoptic\": \"https://api.goldsky.com/api/public/project_cl9gc21q105380hxuh8ks53k3/subgraphs/panoptic-subgraph-base/v2_prod/gn\"\n }\n },\n \"11155111\": {\n \"chainId\": 11155111,\n \"infrastructure\": {\n \"uniswapV3Factory\": \"0x0227628f3F023bb0B980b67D528571c95c6DaC1c\",\n \"poolManager\": \"0xE03A1074c86CFeDd5C142C4F04F1a1536e203543\",\n \"stateView\": \"0xE1Dd9c3fA50EDB962E442f60DfBc432e24537E4C\"\n },\n \"hypovault\": {\n \"core\": {\n \"hypoVaultImplementation\": \"0xC5b415Db4087228Af817893769DC3a205160160B\",\n \"factory\": \"0x363a9d605ca45cBfF3b597350DeADb53cdC292c7\",\n \"accountant\": \"0x25BBef1DF262c24aa1AACD1F7eCeEcc1a7AD08ab\",\n \"rolesAuthority\": \"0x673BfafB4e2712215B422347c1571421B83E8A3d\",\n \"collateralTrackerDecoderAndSanitizer\": \"0xb899BE50BAF25BBB3A3ca3403256B3c703E5AB5d\"\n },\n \"vaults\": {\n \"wethPlpVault\": \"0xD58C4F9AEe5bBfcf28dC9a8d3D57b323fA6521b1\",\n \"usdcPlpVault\": \"0xdd7a8d6c6975488e801129bC84302d74e2361208\"\n },\n \"managers\": {\n \"wethPlpVaultManager\": \"0x95eC124FAAB70D7aE147c3BE0336E01a828AE2d5\",\n \"usdcPlpVaultManager\": \"0xFB5aa3e0b46F3859D90B14b52ffd287013b5Ec53\"\n },\n \"turnkeySigners\": {\n \"wethPlpVaultManager\": \"0x8FfA6DAB99f8afc64F61BeF83F0966eD6362f24F\",\n \"usdcPlpVaultManager\": \"0x3c1c79d0cfc316Ba959194c89696a8382d7d283b\"\n }\n },\n \"panoptic\": {\n \"pool\": {\n \"version\": \"v4\",\n \"panopticPool\": \"0x872b98C46b2062F663BEb2CC9D4cE046Da2a2918\",\n \"collateralTracker0\": \"0x09a60b78d06a03e5148faedd3bfee6f58b22012f\",\n \"collateralTracker1\": \"0x7365664c8101ff7e9422ae2b203822253c31e69c\"\n },\n \"v2\": {\n \"semiFungiblePositionManagerV3\": \"0x9DaD2C40107Db4B29a5450401BB7A28e6eA00e43\",\n \"semiFungiblePositionManagerV4\": \"0xD2615995A71644E122cC2FD7FeC2392b971220DE\",\n \"builderFactory\": \"0x55f3D2d9D065AA5Fcc11D94c55a6085849e8b6C3\",\n \"riskEngine\": \"0x1376aF5ca426B6B9fad6a712c21f6Cf58a94b93c\",\n \"panopticPoolImplementation\": \"0x969235B5830f13b58BB699305d9c70A8Cd3BD97C\",\n \"collateralTrackerImplementation\": \"0xafcd5F651Ae0403Ff668bb2dAc38BEa907a35Dba\",\n \"panopticFactoryV3\": \"0xd9FFCa53C0A6155001Ce8cbcAEfe89DB204690F1\",\n \"panopticFactoryV4\": \"0x8FCBb59b05779818D9BAD2686cc44B705603ce03\",\n \"panopticHelper\": \"0xfFEbB3A4ab793cB244209d4dA0Cb3e6B07133bd0\",\n \"panopticMath\": \"0x6d21699192f5aF112C87e53b32ff846782afF407\",\n \"panopticQuery\": \"0x74057945467Fb4eAE9193B46A60ae66a53f06A5b\",\n \"interactionHelper\": \"0x643d8DD5372FD6c71f8fAbCce4Eb8857704F3E15\"\n }\n },\n \"riskEngines\": [\n \"0x1376aF5ca426B6B9fad6a712c21f6Cf58a94b93c\"\n ],\n \"markets\": {\n \"ethUsdc5bps\": {\n \"currency0\": \"0x0000000000000000000000000000000000000000\",\n \"currency1\": \"0xFFFeD8254566B7F800f6D8CDb843ec75AE49B07A\",\n \"fee\": 500,\n \"tickSpacing\": 10,\n \"poolId\": \"0xba6673bcb27568a73a93dd23b20c8174fa16193cd90905be859144e8f13097a5\"\n }\n },\n \"subgraphs\": {\n \"hypovault\": \"https://api.goldsky.com/api/public/project_cl9gc21q105380hxuh8ks53k3/subgraphs/hypovault-subgraph-sepolia/prod/gn\",\n \"panoptic\": \"https://api.goldsky.com/api/public/project_cl9gc21q105380hxuh8ks53k3/subgraphs/panoptic-subgraph-sepolia/v2_prod/gn\"\n }\n }\n}\n","import chainDeploymentsData from './chainDeployments.data.json' with { type: 'json' }\n\nexport const MAINNET_CHAIN_ID = 1\nexport const SEPOLIA_CHAIN_ID = 11155111\nexport const BASE_CHAIN_ID = 8453\nexport const ROBINHOOD_CHAIN_ID = 4663\n\nexport const CHAIN_DEPLOYMENTS = chainDeploymentsData\n\nexport function getChainDeployment(chainId) {\n return CHAIN_DEPLOYMENTS[chainId]\n}\n\nexport function requireChainDeployment(chainId) {\n const deployment = getChainDeployment(chainId)\n if (deployment === undefined) {\n throw new Error(`Unsupported chain deployment for chainId ${chainId}`)\n }\n return deployment\n}\n\nexport function isSupportedChain(chainId) {\n return getChainDeployment(chainId) !== undefined\n}\n\nexport function getEthUsdcMarket(deployment) {\n const market = deployment.markets.ethUsdc5bps ?? deployment.markets.ethUsdc30bps\n if (market === undefined) {\n throw new Error(`Missing ETH/USDC market for chainId ${deployment.chainId}`)\n }\n return market\n}\n\nexport function getSpyUsdgMarket(deployment) {\n const market = deployment.markets.spyUsdg\n if (market === undefined) {\n throw new Error(`Missing SPY/USDG market for chainId ${deployment.chainId}`)\n }\n return market\n}\n\n\nexport const MAINNET_DEPLOYMENT = CHAIN_DEPLOYMENTS[MAINNET_CHAIN_ID]\nexport const MAINNET_ETH_USDC_5BPS_V3_PANOPTIC_POOL_ADDRESSES =\n MAINNET_DEPLOYMENT.panoptic.additionalPools?.ethUsdc5bpsV3\nexport const MAINNET_PANOPTIC_V2_ADDRESSES = MAINNET_DEPLOYMENT.panoptic.v2\nexport const SEPOLIA_DEPLOYMENT = CHAIN_DEPLOYMENTS[SEPOLIA_CHAIN_ID]\nexport const SEPOLIA_HYPOVAULT_CORE_ADDRESSES = SEPOLIA_DEPLOYMENT.hypovault.core\nexport const SEPOLIA_HYPOVAULT_ADDRESSES = SEPOLIA_DEPLOYMENT.hypovault.vaults\nexport const SEPOLIA_HYPOVAULT_MANAGER_ADDRESSES = SEPOLIA_DEPLOYMENT.hypovault.managers\nexport const SEPOLIA_HYPOVAULT_MANAGER_TURNKEY_SIGNERS = SEPOLIA_DEPLOYMENT.hypovault.turnkeySigners\nexport const SEPOLIA_PANOPTIC_POOL_ADDRESSES = SEPOLIA_DEPLOYMENT.panoptic.pool\nexport const SEPOLIA_PANOPTIC_V2_ADDRESSES = SEPOLIA_DEPLOYMENT.panoptic.v2\nexport const BASE_DEPLOYMENT = CHAIN_DEPLOYMENTS[BASE_CHAIN_ID]\nexport const BASE_HYPOVAULT_CORE_ADDRESSES = BASE_DEPLOYMENT.hypovault.core\nexport const BASE_HYPOVAULT_ADDRESSES = BASE_DEPLOYMENT.hypovault.vaults\nexport const BASE_HYPOVAULT_MANAGER_ADDRESSES = BASE_DEPLOYMENT.hypovault.managers\nexport const BASE_HYPOVAULT_MANAGER_TURNKEY_SIGNERS = BASE_DEPLOYMENT.hypovault.turnkeySigners\nexport const BASE_PANOPTIC_POOL_ADDRESSES = BASE_DEPLOYMENT.panoptic.pool\nexport const BASE_PANOPTIC_V2_ADDRESSES = BASE_DEPLOYMENT.panoptic.v2\nexport const BASE_ETH_USDC_5BPS_MARKET = getEthUsdcMarket(BASE_DEPLOYMENT)\nexport const SEPOLIA_ETH_USDC_5BPS_MARKET = getEthUsdcMarket(SEPOLIA_DEPLOYMENT)\n\nexport const MAINNET_RISK_ENGINES = MAINNET_DEPLOYMENT.riskEngines\nexport const BASE_RISK_ENGINES = BASE_DEPLOYMENT.riskEngines\nexport const SEPOLIA_RISK_ENGINES = SEPOLIA_DEPLOYMENT.riskEngines\n\nexport const ROBINHOOD_DEPLOYMENT = CHAIN_DEPLOYMENTS[ROBINHOOD_CHAIN_ID]\nexport const ROBINHOOD_HYPOVAULT_CORE_ADDRESSES = ROBINHOOD_DEPLOYMENT.hypovault.core\nexport const ROBINHOOD_HYPOVAULT_ADDRESSES = ROBINHOOD_DEPLOYMENT.hypovault.vaults\nexport const ROBINHOOD_HYPOVAULT_MANAGER_ADDRESSES = ROBINHOOD_DEPLOYMENT.hypovault.managers\nexport const ROBINHOOD_HYPOVAULT_MANAGER_TURNKEY_SIGNERS = ROBINHOOD_DEPLOYMENT.hypovault.turnkeySigners\nexport const ROBINHOOD_PANOPTIC_POOL_ADDRESSES = ROBINHOOD_DEPLOYMENT.panoptic.pool\nexport const ROBINHOOD_PANOPTIC_V2_ADDRESSES = ROBINHOOD_DEPLOYMENT.panoptic.v2\nexport const ROBINHOOD_RISK_ENGINES = ROBINHOOD_DEPLOYMENT.riskEngines\nexport const ROBINHOOD_SPY_USDG_MARKET = getSpyUsdgMarket(ROBINHOOD_DEPLOYMENT)\n","import {\n BASE_CHAIN_ID,\n MAINNET_CHAIN_ID,\n requireChainDeployment,\n ROBINHOOD_CHAIN_ID,\n SEPOLIA_CHAIN_ID,\n} from './chainDeployments.js'\n\nconst mainnetDeployment = requireChainDeployment(MAINNET_CHAIN_ID)\nconst mainnetVaults = mainnetDeployment.hypovault.vaults\nconst legacyMainnetVaults = {\n wethPlpVault: '0x779a2aa634A004b3a3f3b322083744869BBC6D66',\n usdcPlpVault: '0x963Fe9c93bc353602656ee4051A75114bA74d6c5',\n}\nconst sepoliaDeployment = requireChainDeployment(SEPOLIA_CHAIN_ID)\nconst sepoliaVaults = sepoliaDeployment.hypovault.vaults\nconst baseDeployment = requireChainDeployment(BASE_CHAIN_ID)\nconst baseVaults = baseDeployment.hypovault.vaults\nconst robinhoodDeployment = requireChainDeployment(ROBINHOOD_CHAIN_ID)\nconst robinhoodUsdgVault = robinhoodDeployment.hypovault.vaults.usdgPlpVault\n\nif (robinhoodUsdgVault === undefined) {\n throw new Error('Missing Robinhood USDG PLP vault address')\n}\n\nexport const VAULT_DISPLAY_NAMES_PER_CHAIN = {\n [MAINNET_CHAIN_ID]: {\n [mainnetVaults.wethPlpVault.toLowerCase()]: 'PLP Vault',\n [mainnetVaults.usdcPlpVault.toLowerCase()]: 'Unicorn Vault',\n [legacyMainnetVaults.wethPlpVault.toLowerCase()]: 'PLP Vault',\n [legacyMainnetVaults.usdcPlpVault.toLowerCase()]: 'Unicorn Vault',\n },\n [BASE_CHAIN_ID]: {\n [baseVaults.wethPlpVault.toLowerCase()]: 'PLP Vault',\n [baseVaults.usdcPlpVault.toLowerCase()]: 'Unicorn Vault',\n },\n [SEPOLIA_CHAIN_ID]: {\n [sepoliaVaults.wethPlpVault.toLowerCase()]: 'PLP Vault',\n [sepoliaVaults.usdcPlpVault.toLowerCase()]: 'Unicorn Vault',\n },\n [ROBINHOOD_CHAIN_ID]: {\n [robinhoodUsdgVault.toLowerCase()]: '0DTE +67∆ Vault',\n },\n}\n\nexport const VAULT_DISPLAY_NAME_RESOLVERS_PER_CHAIN = {\n [MAINNET_CHAIN_ID]: {\n [mainnetVaults.wethPlpVault.toLowerCase()]: () => 'PLP Vault',\n [mainnetVaults.usdcPlpVault.toLowerCase()]: () => 'Unicorn Vault',\n [legacyMainnetVaults.wethPlpVault.toLowerCase()]: () => 'PLP Vault',\n [legacyMainnetVaults.usdcPlpVault.toLowerCase()]: () => 'Unicorn Vault',\n },\n [BASE_CHAIN_ID]: {\n [baseVaults.wethPlpVault.toLowerCase()]: () => 'PLP Vault',\n [baseVaults.usdcPlpVault.toLowerCase()]: () => 'Unicorn Vault',\n },\n [SEPOLIA_CHAIN_ID]: {\n [sepoliaVaults.wethPlpVault.toLowerCase()]: () => 'PLP Vault',\n [sepoliaVaults.usdcPlpVault.toLowerCase()]: () => 'Unicorn Vault',\n },\n [ROBINHOOD_CHAIN_ID]: {\n [robinhoodUsdgVault.toLowerCase()]: () => '0DTE +67∆ Vault',\n },\n}\n\nexport function resolveVaultDisplayName({ chainId, vaultAddress, underlyingSymbol, fallbackName }) {\n const vaultAddressLower = vaultAddress.toLowerCase()\n const resolver = VAULT_DISPLAY_NAME_RESOLVERS_PER_CHAIN[chainId]?.[vaultAddressLower]\n if (resolver !== undefined) {\n return resolver({\n chainId,\n vaultAddress: vaultAddressLower,\n underlyingSymbol,\n fallbackName,\n })\n }\n\n const staticName = VAULT_DISPLAY_NAMES_PER_CHAIN[chainId]?.[vaultAddressLower]\n if (staticName !== undefined) {\n return staticName\n }\n\n if (fallbackName !== undefined && fallbackName !== null) {\n return fallbackName\n }\n\n return 'Vault'\n}\n","import type { Chain, Client, Transport } from 'viem'\nimport { hexToBigInt } from 'viem'\nimport { estimateFeesPerGas, getBlock, getFeeHistory } from 'viem/actions'\n\nimport { ROBINHOOD_CHAIN_ID } from './chainDeployments'\n\nexport const MIN_VAULT_PRIORITY_FEE_PER_GAS = 100_000_000n // 0.1 gwei\nexport const MAX_VAULT_PRIORITY_FEE_PER_GAS = 3_000_000_000n // 3 gwei\nexport const MAX_STALE_DELTA_HEDGE_PRIORITY_FEE_PER_GAS = 8_000_000_000n // 8 gwei\nexport const MAX_VAULT_TRANSACTION_GAS_COST = 15_000_000_000_000_000n // 0.015 ETH\n\nconst FEE_HISTORY_BLOCK_COUNT = 20\nconst FEE_HISTORY_REWARD_PERCENTILES = [90]\nconst DELTA_HEDGE_FEE_HISTORY_REWARD_PERCENTILES = [25]\nconst BASE_FEE_BUFFER_NUMERATOR = 1_125n\nconst BASE_FEE_BUFFER_DENOMINATOR = 1_000n\nconst REPLACEMENT_FEE_BUMP_NUMERATOR = 1_125n\nconst REPLACEMENT_FEE_BUMP_DENOMINATOR = 1_000n\nconst DELTA_HEDGE_PRIORITY_FEE_BUMP_NUMERATOR = 1_300n\nconst DELTA_HEDGE_PRIORITY_FEE_BUMP_DENOMINATOR = 1_000n\n// Leave the mandatory 12.5% replacement headroom for a final 3 gwei replacement.\nconst MAX_DELTA_HEDGE_PRIORITY_FEE_PER_GAS =\n (MAX_VAULT_PRIORITY_FEE_PER_GAS * REPLACEMENT_FEE_BUMP_DENOMINATOR) /\n REPLACEMENT_FEE_BUMP_NUMERATOR\nconst GAS_ESTIMATE_BUFFER_NUMERATOR = 3n\nconst GAS_ESTIMATE_BUFFER_DENOMINATOR = 2n\n\nexport type VaultTransactionFeeQuote = {\n maxFeePerGas: bigint\n maxPriorityFeePerGas: bigint\n minimumMaxFeePerGas: bigint\n minimumPriorityFeePerGas?: bigint\n source: 'fee_history' | 'viem_fallback' | 'rpc_priority_fee' | 'fee_history_p25'\n}\n\nexport type VaultDeltaHedgeFeeQuote = VaultTransactionFeeQuote & {\n rawPriorityFeePerGas: bigint\n}\n\nexport type VaultSignedTransactionFeeCaps = {\n chainId?: number\n gasLimit?: bigint | null\n maxFeePerGas: bigint | null\n maxPriorityFeePerGas: bigint | null\n}\n\nexport type VaultSignedTransactionFeeValidationResult =\n | { valid: true }\n | {\n valid: false\n code:\n | 'MissingEip1559Fees'\n | 'InvalidFeeCaps'\n | 'PriorityFeeTooLow'\n | 'PriorityFeeTooHigh'\n | 'MaxFeeTooLow'\n | 'GasCostTooHigh'\n reason: string\n }\n\nexport class VaultTransactionFeeEstimationError extends Error {\n readonly feeHistoryError: unknown\n readonly fallbackError: unknown\n\n constructor({\n feeHistoryError,\n fallbackError,\n }: {\n feeHistoryError: unknown\n fallbackError: unknown\n }) {\n super('Unable to estimate EIP-1559 fees for vault transaction')\n this.name = 'VaultTransactionFeeEstimationError'\n this.feeHistoryError = feeHistoryError\n this.fallbackError = fallbackError\n }\n}\n\nexport class VaultTransactionGasCostLimitError extends Error {\n readonly gasLimit: bigint\n readonly maximumAffordableFeePerGas: bigint\n readonly minimumRequiredFeePerGas: bigint\n\n constructor({\n gasLimit,\n maximumAffordableFeePerGas,\n minimumRequiredFeePerGas,\n }: {\n gasLimit: bigint\n maximumAffordableFeePerGas: bigint\n minimumRequiredFeePerGas: bigint\n }) {\n super(\n `Vault transaction cannot fit the ${MAX_VAULT_TRANSACTION_GAS_COST.toString()} wei gas-cost limit: ` +\n `gasLimit=${gasLimit.toString()}, maximumAffordableFeePerGas=${maximumAffordableFeePerGas.toString()}, ` +\n `minimumRequiredFeePerGas=${minimumRequiredFeePerGas.toString()}`,\n )\n this.name = 'VaultTransactionGasCostLimitError'\n this.gasLimit = gasLimit\n this.maximumAffordableFeePerGas = maximumAffordableFeePerGas\n this.minimumRequiredFeePerGas = minimumRequiredFeePerGas\n }\n}\n\nexport class VaultTransactionReplacementLimitError extends Error {\n readonly code: 'GasCostCapExceeded' | 'PriorityFeeCapExceeded'\n readonly requiredMaxFeePerGas: bigint\n readonly requiredMaxPriorityFeePerGas: bigint\n readonly maximumAffordableFeePerGas: bigint\n\n constructor({\n code,\n gasLimit,\n requiredMaxFeePerGas,\n requiredMaxPriorityFeePerGas,\n maximumAffordableFeePerGas,\n }: {\n code: 'GasCostCapExceeded' | 'PriorityFeeCapExceeded'\n gasLimit: bigint\n requiredMaxFeePerGas: bigint\n requiredMaxPriorityFeePerGas: bigint\n maximumAffordableFeePerGas: bigint\n }) {\n super(\n `Vault transaction replacement blocked by ${code}: gasLimit=${gasLimit.toString()}, ` +\n `requiredMaxFeePerGas=${requiredMaxFeePerGas.toString()}, ` +\n `requiredMaxPriorityFeePerGas=${requiredMaxPriorityFeePerGas.toString()}, ` +\n `maximumAffordableFeePerGas=${maximumAffordableFeePerGas.toString()}`,\n )\n this.name = 'VaultTransactionReplacementLimitError'\n this.code = code\n this.requiredMaxFeePerGas = requiredMaxFeePerGas\n this.requiredMaxPriorityFeePerGas = requiredMaxPriorityFeePerGas\n this.maximumAffordableFeePerGas = maximumAffordableFeePerGas\n }\n}\n\ntype FeeHistorySnapshot = {\n baseFeePerGas: readonly bigint[]\n reward?: readonly (readonly bigint[])[] | undefined\n minimumPriorityFeePerGas?: bigint\n}\n\ntype FallbackFeeEstimate = {\n maxFeePerGas: bigint\n maxPriorityFeePerGas: bigint\n}\n\nfunction ceilMultiplyFraction(value: bigint, numerator: bigint, denominator: bigint): bigint {\n return (value * numerator + denominator - 1n) / denominator\n}\n\nfunction medianBigInt(values: readonly bigint[]): bigint | undefined {\n if (values.length === 0) return undefined\n const sorted = [...values].sort((left, right) => (left < right ? -1 : left > right ? 1 : 0))\n const upperMiddleIndex = Math.floor(sorted.length / 2)\n const upperMiddle = sorted[upperMiddleIndex]\n if (upperMiddle === undefined) return undefined\n if (sorted.length % 2 === 1) return upperMiddle\n const lowerMiddle = sorted[upperMiddleIndex - 1]\n return lowerMiddle === undefined ? undefined : (lowerMiddle + upperMiddle) / 2n\n}\n\nfunction getChainPriorityFeeFloor(chainId: number | undefined): bigint | undefined {\n return chainId === ROBINHOOD_CHAIN_ID ? 0n : undefined\n}\n\nfunction clampPriorityFee(\n priorityFee: bigint,\n minimumPriorityFeePerGas = MIN_VAULT_PRIORITY_FEE_PER_GAS,\n): bigint {\n if (priorityFee < minimumPriorityFeePerGas) return minimumPriorityFeePerGas\n if (priorityFee > MAX_VAULT_PRIORITY_FEE_PER_GAS) return MAX_VAULT_PRIORITY_FEE_PER_GAS\n return priorityFee\n}\n\nfunction resolveFeeHistoryQuote({\n baseFeePerGas,\n reward,\n minimumPriorityFeePerGas,\n}: {\n baseFeePerGas: readonly bigint[]\n reward?: readonly (readonly bigint[])[] | undefined\n minimumPriorityFeePerGas?: bigint\n}): VaultTransactionFeeQuote | null {\n // feeHistory includes one additional base fee for the next block. The\n // second-to-last entry is therefore the latest mined block's base fee.\n const latestBaseFeeIndex = baseFeePerGas.length - 2\n if (latestBaseFeeIndex < 0 || reward === undefined || reward.length === 0) return null\n\n const p90Rewards = reward.flatMap((blockRewards) => {\n const p90 = blockRewards[0]\n return p90 === undefined ? [] : [p90]\n })\n const sampledPriorityFee = medianBigInt(p90Rewards)\n if (sampledPriorityFee === undefined) return null\n\n const effectivePriorityFeeFloor = minimumPriorityFeePerGas ?? MIN_VAULT_PRIORITY_FEE_PER_GAS\n const maxPriorityFeePerGas = clampPriorityFee(sampledPriorityFee, effectivePriorityFeeFloor)\n const bufferedBaseFee = ceilMultiplyFraction(\n baseFeePerGas[latestBaseFeeIndex],\n BASE_FEE_BUFFER_NUMERATOR,\n BASE_FEE_BUFFER_DENOMINATOR,\n )\n\n return {\n maxFeePerGas: bufferedBaseFee + maxPriorityFeePerGas,\n maxPriorityFeePerGas,\n minimumMaxFeePerGas: bufferedBaseFee + effectivePriorityFeeFloor,\n ...(minimumPriorityFeePerGas === undefined ? {} : { minimumPriorityFeePerGas }),\n source: 'fee_history',\n }\n}\n\nfunction resolveDeltaHedgeFeeHistoryQuote({\n baseFeePerGas,\n reward,\n minimumPriorityFeePerGas,\n}: FeeHistorySnapshot): VaultDeltaHedgeFeeQuote | null {\n const latestBaseFeeIndex = baseFeePerGas.length - 2\n if (latestBaseFeeIndex < 0 || reward === undefined || reward.length === 0) return null\n\n const p25Rewards = reward.flatMap((blockRewards) => {\n const p25 = blockRewards[0]\n return p25 === undefined ? [] : [p25]\n })\n const rawPriorityFeePerGas = medianBigInt(p25Rewards)\n if (rawPriorityFeePerGas === undefined) return null\n\n const effectivePriorityFeeFloor = minimumPriorityFeePerGas ?? MIN_VAULT_PRIORITY_FEE_PER_GAS\n const maxPriorityFeePerGas = clampPriorityFee(rawPriorityFeePerGas, effectivePriorityFeeFloor)\n const bufferedBaseFee = ceilMultiplyFraction(\n baseFeePerGas[latestBaseFeeIndex],\n BASE_FEE_BUFFER_NUMERATOR,\n BASE_FEE_BUFFER_DENOMINATOR,\n )\n return {\n maxFeePerGas: bufferedBaseFee + maxPriorityFeePerGas,\n maxPriorityFeePerGas,\n minimumMaxFeePerGas: bufferedBaseFee + effectivePriorityFeeFloor,\n ...(minimumPriorityFeePerGas === undefined ? {} : { minimumPriorityFeePerGas }),\n rawPriorityFeePerGas,\n source: 'fee_history_p25',\n }\n}\n\nfunction resolveRpcPriorityFeeQuote({\n baseFeePerGas,\n rawPriorityFeePerGas,\n minimumPriorityFeePerGas,\n}: {\n baseFeePerGas: bigint\n rawPriorityFeePerGas: bigint\n minimumPriorityFeePerGas?: bigint\n}): VaultDeltaHedgeFeeQuote {\n const bufferedBaseFee = ceilMultiplyFraction(\n baseFeePerGas,\n BASE_FEE_BUFFER_NUMERATOR,\n BASE_FEE_BUFFER_DENOMINATOR,\n )\n return {\n maxFeePerGas: bufferedBaseFee + rawPriorityFeePerGas,\n maxPriorityFeePerGas: rawPriorityFeePerGas,\n minimumMaxFeePerGas: bufferedBaseFee + (minimumPriorityFeePerGas ?? rawPriorityFeePerGas),\n ...(minimumPriorityFeePerGas === undefined ? {} : { minimumPriorityFeePerGas }),\n rawPriorityFeePerGas,\n source: 'rpc_priority_fee',\n }\n}\n\nexport function getVaultTransactionReplacementFeeQuote({\n originalQuote,\n historicalQuote,\n gasLimit,\n finalReplacement = false,\n staleBoundsReplacement = false,\n}: {\n originalQuote: Pick<VaultTransactionFeeQuote, 'maxFeePerGas' | 'maxPriorityFeePerGas'>\n historicalQuote: VaultDeltaHedgeFeeQuote\n gasLimit: bigint\n finalReplacement?: boolean\n staleBoundsReplacement?: boolean\n}): VaultDeltaHedgeFeeQuote {\n if (gasLimit <= 0n) {\n throw new Error(`Vault transaction gas limit must be positive, received ${gasLimit.toString()}`)\n }\n\n const bumpedPriorityFee = staleBoundsReplacement\n ? ceilMultiplyFraction(\n originalQuote.maxPriorityFeePerGas,\n REPLACEMENT_FEE_BUMP_NUMERATOR,\n REPLACEMENT_FEE_BUMP_DENOMINATOR,\n )\n : ceilMultiplyFraction(\n originalQuote.maxPriorityFeePerGas,\n DELTA_HEDGE_PRIORITY_FEE_BUMP_NUMERATOR,\n DELTA_HEDGE_PRIORITY_FEE_BUMP_DENOMINATOR,\n )\n const bumpedMaxFee = ceilMultiplyFraction(\n originalQuote.maxFeePerGas,\n REPLACEMENT_FEE_BUMP_NUMERATOR,\n REPLACEMENT_FEE_BUMP_DENOMINATOR,\n )\n const escalatingPriorityFee =\n historicalQuote.maxPriorityFeePerGas > bumpedPriorityFee\n ? historicalQuote.maxPriorityFeePerGas\n : bumpedPriorityFee\n const priorityFeeLimit = staleBoundsReplacement\n ? MAX_STALE_DELTA_HEDGE_PRIORITY_FEE_PER_GAS\n : finalReplacement\n ? MAX_VAULT_PRIORITY_FEE_PER_GAS\n : MAX_DELTA_HEDGE_PRIORITY_FEE_PER_GAS\n const desiredMaxPriorityFeePerGas = finalReplacement\n ? MAX_VAULT_PRIORITY_FEE_PER_GAS\n : staleBoundsReplacement\n ? bumpedPriorityFee\n : escalatingPriorityFee\n const requiredReplacementPriorityFee = ceilMultiplyFraction(\n originalQuote.maxPriorityFeePerGas,\n REPLACEMENT_FEE_BUMP_NUMERATOR,\n REPLACEMENT_FEE_BUMP_DENOMINATOR,\n )\n const requiredMaxPriorityFeePerGas =\n desiredMaxPriorityFeePerGas < priorityFeeLimit ? desiredMaxPriorityFeePerGas : priorityFeeLimit\n if (requiredMaxPriorityFeePerGas < requiredReplacementPriorityFee) {\n throw new VaultTransactionReplacementLimitError({\n code: 'PriorityFeeCapExceeded',\n gasLimit,\n requiredMaxFeePerGas: originalQuote.maxFeePerGas,\n requiredMaxPriorityFeePerGas: requiredReplacementPriorityFee,\n maximumAffordableFeePerGas: MAX_VAULT_TRANSACTION_GAS_COST / gasLimit,\n })\n }\n const bufferedBaseFee =\n historicalQuote.minimumMaxFeePerGas -\n (historicalQuote.minimumPriorityFeePerGas ?? MIN_VAULT_PRIORITY_FEE_PER_GAS)\n const currentMarketMaxFee = bufferedBaseFee + requiredMaxPriorityFeePerGas\n const desiredMaxFeePerGas =\n currentMarketMaxFee > bumpedMaxFee ? currentMarketMaxFee : bumpedMaxFee\n const maximumAffordableFeePerGas = MAX_VAULT_TRANSACTION_GAS_COST / gasLimit\n\n if (\n bumpedMaxFee > maximumAffordableFeePerGas ||\n requiredMaxPriorityFeePerGas > maximumAffordableFeePerGas\n ) {\n throw new VaultTransactionReplacementLimitError({\n code: 'GasCostCapExceeded',\n gasLimit,\n requiredMaxFeePerGas: bumpedMaxFee,\n requiredMaxPriorityFeePerGas,\n maximumAffordableFeePerGas,\n })\n }\n const maxFeePerGas =\n desiredMaxFeePerGas < maximumAffordableFeePerGas\n ? desiredMaxFeePerGas\n : maximumAffordableFeePerGas\n\n return {\n ...historicalQuote,\n maxFeePerGas,\n maxPriorityFeePerGas: requiredMaxPriorityFeePerGas,\n }\n}\n\nfunction resolveFallbackQuote({\n maxFeePerGas: estimatedMaxFeePerGas,\n maxPriorityFeePerGas: estimatedPriorityFeePerGas,\n minimumPriorityFeePerGas,\n}: {\n maxFeePerGas: bigint\n maxPriorityFeePerGas: bigint\n minimumPriorityFeePerGas?: bigint\n}): VaultTransactionFeeQuote {\n const effectivePriorityFeeFloor = minimumPriorityFeePerGas ?? MIN_VAULT_PRIORITY_FEE_PER_GAS\n const maxPriorityFeePerGas = clampPriorityFee(\n estimatedPriorityFeePerGas,\n effectivePriorityFeeFloor,\n )\n const estimatedBaseFeeAllowance =\n estimatedMaxFeePerGas > estimatedPriorityFeePerGas\n ? estimatedMaxFeePerGas - estimatedPriorityFeePerGas\n : 0n\n\n return {\n maxFeePerGas: estimatedBaseFeeAllowance + maxPriorityFeePerGas,\n maxPriorityFeePerGas,\n minimumMaxFeePerGas: estimatedBaseFeeAllowance + effectivePriorityFeeFloor,\n ...(minimumPriorityFeePerGas === undefined ? {} : { minimumPriorityFeePerGas }),\n source: 'viem_fallback',\n }\n}\n\nexport function applyVaultTransactionGasCostLimit(\n quote: VaultTransactionFeeQuote,\n gasLimit: bigint,\n): VaultTransactionFeeQuote {\n if (gasLimit <= 0n) {\n throw new Error(`Vault transaction gas limit must be positive, received ${gasLimit.toString()}`)\n }\n\n const maximumAffordableFeePerGas = MAX_VAULT_TRANSACTION_GAS_COST / gasLimit\n if (maximumAffordableFeePerGas < quote.minimumMaxFeePerGas) {\n throw new VaultTransactionGasCostLimitError({\n gasLimit,\n maximumAffordableFeePerGas,\n minimumRequiredFeePerGas: quote.minimumMaxFeePerGas,\n })\n }\n\n if (quote.maxFeePerGas <= maximumAffordableFeePerGas) return quote\n\n const bufferedBaseFee =\n quote.minimumMaxFeePerGas - (quote.minimumPriorityFeePerGas ?? MIN_VAULT_PRIORITY_FEE_PER_GAS)\n const affordablePriorityFee = maximumAffordableFeePerGas - bufferedBaseFee\n return {\n ...quote,\n maxFeePerGas: maximumAffordableFeePerGas,\n maxPriorityFeePerGas:\n quote.maxPriorityFeePerGas < affordablePriorityFee\n ? quote.maxPriorityFeePerGas\n : affordablePriorityFee,\n }\n}\n\nexport function bufferVaultTransactionGasEstimate(gasEstimate: bigint): bigint {\n if (gasEstimate <= 0n) {\n throw new Error(\n `Vault transaction gas estimate must be positive, received ${gasEstimate.toString()}`,\n )\n }\n return ceilMultiplyFraction(\n gasEstimate,\n GAS_ESTIMATE_BUFFER_NUMERATOR,\n GAS_ESTIMATE_BUFFER_DENOMINATOR,\n )\n}\n\nexport function validateVaultSignedTransactionFeeCaps(\n feeCaps: VaultSignedTransactionFeeCaps,\n quote?: VaultTransactionFeeQuote,\n): VaultSignedTransactionFeeValidationResult {\n const { chainId, gasLimit, maxFeePerGas, maxPriorityFeePerGas } = feeCaps\n const minimumPriorityFeePerGas =\n quote?.minimumPriorityFeePerGas ??\n getChainPriorityFeeFloor(chainId) ??\n MIN_VAULT_PRIORITY_FEE_PER_GAS\n if (maxFeePerGas === null || maxPriorityFeePerGas === null) {\n return {\n valid: false,\n code: 'MissingEip1559Fees',\n reason: 'Signed transaction must include EIP-1559 max fee and priority fee caps.',\n }\n }\n if (maxPriorityFeePerGas > maxFeePerGas) {\n return {\n valid: false,\n code: 'InvalidFeeCaps',\n reason:\n `Signed transaction maxPriorityFeePerGas (${maxPriorityFeePerGas.toString()} wei) ` +\n `cannot exceed maxFeePerGas (${maxFeePerGas.toString()} wei).`,\n }\n }\n if (maxPriorityFeePerGas < minimumPriorityFeePerGas) {\n return {\n valid: false,\n code: 'PriorityFeeTooLow',\n reason:\n `Signed transaction maxPriorityFeePerGas (${maxPriorityFeePerGas.toString()} wei) ` +\n `must be at least ${minimumPriorityFeePerGas.toString()} wei.`,\n }\n }\n if (maxPriorityFeePerGas > MAX_VAULT_PRIORITY_FEE_PER_GAS) {\n return {\n valid: false,\n code: 'PriorityFeeTooHigh',\n reason:\n `Signed transaction maxPriorityFeePerGas (${maxPriorityFeePerGas.toString()} wei) ` +\n `must not exceed ${MAX_VAULT_PRIORITY_FEE_PER_GAS.toString()} wei (3 gwei).`,\n }\n }\n if (\n gasLimit !== undefined &&\n gasLimit !== null &&\n gasLimit * maxFeePerGas > MAX_VAULT_TRANSACTION_GAS_COST\n ) {\n return {\n valid: false,\n code: 'GasCostTooHigh',\n reason:\n `Signed transaction maximum gas cost (${(gasLimit * maxFeePerGas).toString()} wei) ` +\n `must not exceed ${MAX_VAULT_TRANSACTION_GAS_COST.toString()} wei (0.015 ETH).`,\n }\n }\n if (quote !== undefined && maxFeePerGas < quote.minimumMaxFeePerGas) {\n return {\n valid: false,\n code: 'MaxFeeTooLow',\n reason:\n `Signed transaction maxFeePerGas (${maxFeePerGas.toString()} wei) must be at least ` +\n `${quote.minimumMaxFeePerGas.toString()} wei for the buffered next-block base fee ` +\n 'and configured minimum priority fee.',\n }\n }\n return { valid: true }\n}\n\nasync function resolveVaultTransactionFeeQuote({\n readFeeHistory,\n readFallbackEstimate,\n minimumPriorityFeePerGas,\n}: {\n readFeeHistory: () => Promise<FeeHistorySnapshot>\n readFallbackEstimate: () => Promise<FallbackFeeEstimate>\n minimumPriorityFeePerGas?: bigint\n}): Promise<VaultTransactionFeeQuote> {\n let feeHistoryError: unknown\n try {\n const quote = resolveFeeHistoryQuote({\n ...(await readFeeHistory()),\n minimumPriorityFeePerGas,\n })\n if (quote !== null) return quote\n feeHistoryError = new Error('eth_feeHistory returned incomplete base fee or reward data')\n } catch (error) {\n feeHistoryError = error\n }\n\n try {\n return resolveFallbackQuote({\n ...(await readFallbackEstimate()),\n minimumPriorityFeePerGas,\n })\n } catch (fallbackError) {\n throw new VaultTransactionFeeEstimationError({ feeHistoryError, fallbackError })\n }\n}\n\n/**\n * Resolve explicit EIP-1559 fees for operator-controlled vault transactions.\n *\n * The normal path follows the median p90 priority fee from the last 20 blocks,\n * with a 3 gwei ceiling and a 0.1 gwei floor except on chains that do not use\n * tips for ordering. If fee history is unavailable, Viem's estimate is used\n * while preserving those bounds and its original base-fee allowance.\n */\nexport async function getVaultTransactionFeeQuote<chain extends Chain | undefined>(\n client: Client<Transport, chain>,\n): Promise<VaultTransactionFeeQuote> {\n return resolveVaultTransactionFeeQuote({\n minimumPriorityFeePerGas: getChainPriorityFeeFloor(client.chain?.id),\n readFeeHistory: () =>\n getFeeHistory(client, {\n blockCount: FEE_HISTORY_BLOCK_COUNT,\n blockTag: 'latest',\n rewardPercentiles: FEE_HISTORY_REWARD_PERCENTILES,\n }),\n readFallbackEstimate: () => estimateFeesPerGas(client),\n })\n}\n\nexport async function getVaultDeltaHedgeHistoricalFeeQuote<chain extends Chain | undefined>(\n client: Client<Transport, chain>,\n): Promise<VaultDeltaHedgeFeeQuote> {\n const feeHistory = await getFeeHistory(client, {\n blockCount: FEE_HISTORY_BLOCK_COUNT,\n blockTag: 'latest',\n rewardPercentiles: DELTA_HEDGE_FEE_HISTORY_REWARD_PERCENTILES,\n })\n const quote = resolveDeltaHedgeFeeHistoryQuote({\n ...feeHistory,\n minimumPriorityFeePerGas: getChainPriorityFeeFloor(client.chain?.id),\n })\n if (quote === null) {\n throw new Error('eth_feeHistory returned incomplete p25 base fee or reward data')\n }\n return quote\n}\n\nasync function resolveVaultDeltaHedgeInitialFeeQuote({\n readRpcQuote,\n readHistoricalQuote,\n minimumPriorityFeePerGas,\n}: {\n readRpcQuote: () => Promise<{ baseFeePerGas: bigint; rawPriorityFeePerGas: bigint }>\n readHistoricalQuote: () => Promise<VaultDeltaHedgeFeeQuote>\n minimumPriorityFeePerGas?: bigint\n}): Promise<VaultDeltaHedgeFeeQuote> {\n try {\n return resolveRpcPriorityFeeQuote({\n ...(await readRpcQuote()),\n minimumPriorityFeePerGas,\n })\n } catch {\n return readHistoricalQuote()\n }\n}\n\n/**\n * Resolve the first fee quote for a delta hedge from the connected RPC's\n * eth_maxPriorityFeePerGas recommendation. A failed RPC recommendation falls\n * back immediately to the rolling historical p25 quote.\n */\nexport async function getVaultDeltaHedgeInitialFeeQuote<chain extends Chain | undefined>(\n client: Client<Transport, chain>,\n): Promise<VaultDeltaHedgeFeeQuote> {\n return resolveVaultDeltaHedgeInitialFeeQuote({\n minimumPriorityFeePerGas: getChainPriorityFeeFloor(client.chain?.id),\n readRpcQuote: async () => {\n const [rawPriorityFee, latestBlock] = await Promise.all([\n client.request({ method: 'eth_maxPriorityFeePerGas' }),\n getBlock(client, { blockTag: 'latest' }),\n ])\n if (latestBlock.baseFeePerGas === null) {\n throw new Error('Latest block does not include an EIP-1559 base fee')\n }\n return {\n baseFeePerGas: latestBlock.baseFeePerGas,\n rawPriorityFeePerGas: hexToBigInt(rawPriorityFee),\n }\n },\n readHistoricalQuote: () => getVaultDeltaHedgeHistoricalFeeQuote(client),\n })\n}\n\nexport const __transactionFeeTestUtils = {\n clampPriorityFee,\n getChainPriorityFeeFloor,\n resolveDeltaHedgeFeeHistoryQuote,\n resolveFallbackQuote,\n resolveFeeHistoryQuote,\n resolveRpcPriorityFeeQuote,\n resolveVaultDeltaHedgeInitialFeeQuote,\n resolveVaultTransactionFeeQuote,\n}\n"],"mappings":";;;;SACO;CACH,WAAW;CACX,kBAAkB;EAChB,oBAAoB;EACpB,eAAe;EACf,aAAa;CACd;CACD,aAAa;EACX,QAAQ;GACN,2BAA2B;GAC3B,WAAW;GACX,cAAc;GACd,kBAAkB;GAClB,wCAAwC;EACzC;EACD,UAAU;GACR,gBAAgB;GAChB,gBAAgB;EACjB;EACD,YAAY;GACV,uBAAuB;GACvB,uBAAuB;EACxB;EACD,kBAAkB;GAChB,uBAAuB;GACvB,uBAAuB;EACxB;CACF;CACD,YAAY;EACV,QAAQ;GACN,WAAW;GACX,gBAAgB;GAChB,sBAAsB;GACtB,sBAAsB;EACvB;EACD,mBAAmB,EACjB,iBAAiB;GACf,WAAW;GACX,gBAAgB;GAChB,sBAAsB;GACtB,sBAAsB;EACvB,EACF;EACD,MAAM;GACJ,iCAAiC;GACjC,iCAAiC;GACjC,kBAAkB;GAClB,cAAc;GACd,8BAA8B;GAC9B,mCAAmC;GACnC,qBAAqB;GACrB,qBAAqB;GACrB,kBAAkB;GAClB,gBAAgB;GAChB,iBAAiB;GACjB,qBAAqB;EACtB;CACF;CACD,eAAe,CACb,8CACA,4CACD;CACD,WAAW,EACT,gBAAgB;EACd,aAAa;EACb,aAAa;EACb,OAAO;EACP,eAAe;EACf,UAAU;CACX,EACF;CACD,aAAa;EACX,aAAa;EACb,YAAY;CACb;CACD,YAAY;EACV,WAAW;EACX,QAAQ;EACR,eAAe;EACf,UAAU;EACV,OAAO;EACP,QAAQ;CACT;CACD,yBAAyB,CACvB,8CACA,4CACD;AACF;YACO;CACN,WAAW;CACX,kBAAkB;EAChB,oBAAoB;EACpB,eAAe;EACf,aAAa;CACd;CACD,aAAa;EACX,QAAQ;GACN,2BAA2B;GAC3B,WAAW;GACX,cAAc;GACd,kBAAkB;GAClB,wCAAwC;EACzC;EACD,UAAU;GACR,gBAAgB;GAChB,gBAAgB;GAChB,gBAAgB;EACjB;EACD,YAAY;GACV,uBAAuB;GACvB,uBAAuB;GACvB,uBAAuB;EACxB;EACD,kBAAkB;GAChB,uBAAuB;GACvB,uBAAuB;GACvB,uBAAuB;EACxB;CACF;CACD,YAAY;EACV,QAAQ;GACN,WAAW;GACX,gBAAgB;GAChB,sBAAsB;GACtB,sBAAsB;EACvB;EACD,MAAM;GACJ,iCAAiC;GACjC,iCAAiC;GACjC,kBAAkB;GAClB,cAAc;GACd,8BAA8B;GAC9B,mCAAmC;GACnC,qBAAqB;GACrB,qBAAqB;GACrB,kBAAkB;GAClB,gBAAgB;GAChB,iBAAiB;GACjB,qBAAqB;EACtB;CACF;CACD,eAAe;EACb;EACA;EACA;CACD;CACD,WAAW,EACT,WAAW;EACT,aAAa;EACb,aAAa;EACb,OAAO;EACP,eAAe;EACf,UAAU;CACX,EACF;CACD,aAAa;EACX,aAAa;EACb,YAAY;CACb;CACD,yBAAyB,CACvB,4CACD;AACF;YACO;CACN,WAAW;CACX,kBAAkB;EAChB,oBAAoB;EACpB,eAAe;EACf,aAAa;CACd;CACD,aAAa;EACX,QAAQ;GACN,2BAA2B;GAC3B,WAAW;GACX,cAAc;GACd,kBAAkB;GAClB,wCAAwC;EACzC;EACD,UAAU;GACR,gBAAgB;GAChB,gBAAgB;EACjB;EACD,YAAY;GACV,uBAAuB;GACvB,uBAAuB;EACxB;EACD,kBAAkB;GAChB,uBAAuB;GACvB,uBAAuB;EACxB;CACF;CACD,YAAY;EACV,QAAQ;GACN,WAAW;GACX,gBAAgB;GAChB,sBAAsB;GACtB,sBAAsB;EACvB;EACD,MAAM;GACJ,iCAAiC;GACjC,iCAAiC;GACjC,kBAAkB;GAClB,cAAc;GACd,8BAA8B;GAC9B,mCAAmC;GACnC,qBAAqB;GACrB,qBAAqB;GACrB,kBAAkB;GAClB,gBAAgB;GAChB,iBAAiB;GACjB,qBAAqB;EACtB;CACF;CACD,eAAe,CACb,4CACD;CACD,WAAW,EACT,eAAe;EACb,aAAa;EACb,aAAa;EACb,OAAO;EACP,eAAe;EACf,UAAU;CACX,EACF;CACD,aAAa;EACX,aAAa;EACb,YAAY;CACb;AACF;gBACW;CACV,WAAW;CACX,kBAAkB;EAChB,oBAAoB;EACpB,eAAe;EACf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C,OAAM,IAAI,MAAM;AAElB,UAAO;IACL,eAAe,YAAY;IAC3B,sBAAsB,YAAY,eAAe;GAClD;EACF;EACD,qBAAqB,MAAM,qCAAqC,OAAO;CACxE,EAAC;AACH"}
1
+ {"version":3,"file":"vault-transaction-fees.js","names":["chainDeploymentsData","value: bigint","numerator: bigint","denominator: bigint","values: readonly bigint[]","chainId: number | undefined","priorityFee: bigint","quote: VaultTransactionFeeQuote","gasLimit: bigint","gasEstimate: bigint","feeCaps: VaultSignedTransactionFeeCaps","quote?: VaultTransactionFeeQuote","feeHistoryError: unknown","client: Client<Transport, chain>"],"sources":["../../deployments/src/chainDeployments.data.json","../../deployments/src/chainDeployments.js","../../deployments/src/vaultDisplayNames.js","../src/hypoVault/transactionFees.ts"],"sourcesContent":["{\n \"1\": {\n \"chainId\": 1,\n \"infrastructure\": {\n \"uniswapV3Factory\": \"0x1F98431c8aD98523631AE4a59f267346ea31F984\",\n \"poolManager\": \"0x000000000004444c5dc75cB358380D2e3dE08A90\",\n \"stateView\": \"0x7ffe42c4a5deea5b0fec41c94c136cf115597227\"\n },\n \"hypovault\": {\n \"core\": {\n \"hypoVaultImplementation\": \"0xF16714665955DBd0361D997eFc50fe391D96E8D0\",\n \"factory\": \"0xd5049B2647de57141dE7F65E5124707B99A452A3\",\n \"accountant\": \"0x65aA902AE3135658587FFC36ED51B61c927114e1\",\n \"rolesAuthority\": \"0xb952D345c413Ddb7850173422bAe4968e0330598\",\n \"collateralTrackerDecoderAndSanitizer\": \"0xC87c45d2dbE5acb56013e2591427ECC84Fa251E6\"\n },\n \"vaults\": {\n \"wethPlpVault\": \"0xd4e2c720a760049cc4151bcf61e3a9348db9cd92\",\n \"usdcPlpVault\": \"0x236d0558f06cd60780b232d4Ec4c92d2cb7e4D18\"\n },\n \"managers\": {\n \"wethPlpVaultManager\": \"0xB6Fc48e658C9B1a7dbdFA51A5E153ab60BB2e04d\",\n \"usdcPlpVaultManager\": \"0x2ce65016366ef7320078e0758D58Cf1038bc7C4e\"\n },\n \"turnkeySigners\": {\n \"wethPlpVaultManager\": \"0x8FfA6DAB99f8afc64F61BeF83F0966eD6362f24F\",\n \"usdcPlpVaultManager\": \"0x3c1c79d0cfc316Ba959194c89696a8382d7d283b\"\n }\n },\n \"panoptic\": {\n \"pool\": {\n \"version\": \"v4\",\n \"panopticPool\": \"0x00000000563b70d704f4c6675a5f6ac989fbae13\",\n \"collateralTracker0\": \"0x1e46b0289B7E0F710E2Db8Ab87800dd782D624f7\",\n \"collateralTracker1\": \"0x12bF31955522BAC337D93e1bC0a39F68D8BDa216\"\n },\n \"additionalPools\": {\n \"ethUsdc5bpsV3\": {\n \"version\": \"v3\",\n \"panopticPool\": \"0x00000000009C7B687e833559e34503f64d7ed7c4\",\n \"collateralTracker0\": \"0x3CCdA7d5E841d6543D90BcEc20b36a724C184DE9\",\n \"collateralTracker1\": \"0x69E9f9e44E5F52237493b980dd7306198C64A4E4\"\n }\n },\n \"v2\": {\n \"semiFungiblePositionManagerV4\": \"0x00000000000005C3287f136Ef5AF56c68Ea6849f\",\n \"semiFungiblePositionManagerV3\": \"0x00000000000005E4693aDc8Ec0f12D686f728198\",\n \"builderFactory\": \"0x0000000000000a3D22E158417AA639D7F71b0FF7\",\n \"riskEngine\": \"0x000000000000075e29cdaa9cb640a69e148ca7da\",\n \"panopticPoolImplementation\": \"0x000000000000135429F0DaCaB61639Bf6a63EbbC\",\n \"collateralTrackerImplementation\": \"0x0000000000001d9c38CA405A2e04420865A08A33\",\n \"panopticFactoryV4\": \"0x0000000000000c51d0f8cf4bd9adE7191372a625\",\n \"panopticFactoryV3\": \"0x0000000000000aDC9A108591e718F2aee963a2a7\",\n \"panopticHelper\": \"0x0000000000000000000000000000000000000000\",\n \"panopticMath\": \"0x000000000000334bbd65C195581cf59ECf315932\",\n \"panopticQuery\": \"0x0000000000000e1aE9c66C1c3B0A547D23389C93\",\n \"interactionHelper\": \"0x00000000000041fe14Ce3c2392337CE501aE8328\"\n }\n },\n \"riskEngines\": [\n \"0x000000000000075e29cdaa9cb640a69e148ca7da\",\n \"0x0000000000000fe1e261f66ce2f44def4f5ae0cb\"\n ],\n \"markets\": {\n \"ethUsdc30bps\": {\n \"currency0\": \"0x0000000000000000000000000000000000000000\",\n \"currency1\": \"0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48\",\n \"fee\": 3000,\n \"tickSpacing\": 60,\n \"poolId\": \"0x3C08AE4977F78D\"\n }\n },\n \"subgraphs\": {\n \"hypovault\": \"https://api.goldsky.com/api/public/project_cl9gc21q105380hxuh8ks53k3/subgraphs/hypovault-subgraph-mainnet/prod/gn\",\n \"panoptic\": \"https://api.goldsky.com/api/public/project_cl9gc21q105380hxuh8ks53k3/subgraphs/panoptic-subgraph-mainnet/v2_prod/gn\"\n },\n \"sfpmSwap\": {\n \"version\": \"v3\",\n \"sfpm\": \"0x00000000000005E4693aDc8Ec0f12D686f728198\",\n \"poolAddress\": \"0x88e6A0c2dDD26FEEb64F039a2c41296FcB3f5640\",\n \"poolId\": \"2824133844976349\",\n \"fee\": 500,\n \"weth\": \"0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2\"\n },\n \"deprecatedRiskEngines\": [\n \"0x0000000000000e673aECBDB5f5fE5DFAf4a8e9Ac\",\n \"0x0000000000000E65545005B26207D7edFd031260\"\n ]\n },\n \"4663\": {\n \"chainId\": 4663,\n \"infrastructure\": {\n \"uniswapV3Factory\": \"0x1f7d7550b1b028f7571e69a784071f0205fd2efa\",\n \"poolManager\": \"0x8366a39cc670b4001a1121b8f6a443a643e40951\",\n \"stateView\": \"0xf3334192d15450cdd385c8b70e03f9a6bd9e673b\"\n },\n \"hypovault\": {\n \"core\": {\n \"hypoVaultImplementation\": \"0xF16714665955DBd0361D997eFc50fe391D96E8D0\",\n \"factory\": \"0xd5049B2647de57141dE7F65E5124707B99A452A3\",\n \"accountant\": \"0x9e345d862c41010F87D8E5A279e8D320D2831D36\",\n \"rolesAuthority\": \"0xb952D345c413Ddb7850173422bAe4968e0330598\",\n \"collateralTrackerDecoderAndSanitizer\": \"0xC87c45d2dbE5acb56013e2591427ECC84Fa251E6\"\n },\n \"vaults\": {\n \"wethPlpVault\": \"0x0000000000000000000000000000000000000000\",\n \"usdcPlpVault\": \"0x0000000000000000000000000000000000000000\",\n \"usdgPlpVault\": \"0x08B24123252Bd9c4DD473b6573D4cF67196FFC4B\"\n },\n \"managers\": {\n \"wethPlpVaultManager\": \"0x0000000000000000000000000000000000000000\",\n \"usdcPlpVaultManager\": \"0x0000000000000000000000000000000000000000\",\n \"usdgPlpVaultManager\": \"0x67Edb096585efe88a9A1ee16c5857AB74Fc8EA87\"\n },\n \"turnkeySigners\": {\n \"wethPlpVaultManager\": \"0x0000000000000000000000000000000000000000\",\n \"usdcPlpVaultManager\": \"0x0000000000000000000000000000000000000000\",\n \"usdgPlpVaultManager\": \"0x8FfA6DAB99f8afc64F61BeF83F0966eD6362f24F\"\n }\n },\n \"panoptic\": {\n \"pool\": {\n \"version\": \"v4\",\n \"panopticPool\": \"0x00000000989bcb6f24af4a1Ab2A6d6a31c98A58E\",\n \"collateralTracker0\": \"0x49eaAC32A7CD4B8fB2209a12859a95E0b20aB0e5\",\n \"collateralTracker1\": \"0x670C44a0FC35dbC410498e47A6290a1C3196d191\"\n },\n \"v2\": {\n \"semiFungiblePositionManagerV4\": \"0x00000000000005C3287f136Ef5AF56c68Ea6849f\",\n \"semiFungiblePositionManagerV3\": \"0x00000000000005E4693aDc8Ec0f12D686f728198\",\n \"builderFactory\": \"0x0000000000000a3D22E158417AA639D7F71b0FF7\",\n \"riskEngine\": \"0x000000000000075e29cdaa9cb640a69e148ca7da\",\n \"panopticPoolImplementation\": \"0x000000000000135429F0DaCaB61639Bf6a63EbbC\",\n \"collateralTrackerImplementation\": \"0x0000000000001d9c38CA405A2e04420865A08A33\",\n \"panopticFactoryV4\": \"0x0000000000000c51d0f8cf4bd9adE7191372a625\",\n \"panopticFactoryV3\": \"0x0000000000000aDC9A108591e718F2aee963a2a7\",\n \"panopticHelper\": \"0x0000000000000000000000000000000000000000\",\n \"panopticMath\": \"0x000000000000334bbd65C195581cf59ECf315932\",\n \"panopticQuery\": \"0x0000000000000e1aE9c66C1c3B0A547D23389C93\",\n \"interactionHelper\": \"0x00000000000041fe14Ce3c2392337CE501aE8328\"\n }\n },\n \"riskEngines\": [\n \"0x000000000000075e29cdaa9cb640a69e148ca7da\",\n \"0x0000000000000fe1e261f66ce2f44def4f5ae0cb\",\n \"0x0000000000000f3fb82469581A74776178E76Ca4\"\n ],\n \"markets\": {\n \"spyUsdg\": {\n \"currency0\": \"0x117cc2133c37B721F49dE2A7a74833232B3B4C0C\",\n \"currency1\": \"0x5fc5360D0400a0Fd4f2af552ADD042D716F1d168\",\n \"fee\": 3000,\n \"tickSpacing\": 60,\n \"poolId\": \"0xfe2a80bb5618fd14984b92ca6d45bf5ba67443ddb1435e28b2e48df2fc1526cd\"\n }\n },\n \"subgraphs\": {\n \"hypovault\": \"https://api.goldsky.com/api/public/project_cl9gc21q105380hxuh8ks53k3/subgraphs/hypovault-subgraph-robinhood/prod/gn\",\n \"panoptic\": \"https://api.goldsky.com/api/public/project_cl9gc21q105380hxuh8ks53k3/subgraphs/panoptic-subgraph-robinhood/v2_prod/gn\"\n },\n \"deprecatedRiskEngines\": [\n \"0x0000000000000E65545005B26207D7edFd031260\"\n ]\n },\n \"8453\": {\n \"chainId\": 8453,\n \"infrastructure\": {\n \"uniswapV3Factory\": \"0x33128a8fC17869897dcE68Ed026d694621f6FDfD\",\n \"poolManager\": \"0x498581fF718922c3f8e6A244956aF099B2652b2b\",\n \"stateView\": \"0xA3c0c9b65baD0b08107Aa264b0f3dB444b867A71\"\n },\n \"hypovault\": {\n \"core\": {\n \"hypoVaultImplementation\": \"0xec311aE06486ad44Ba782133b502A34aCE0f479E\",\n \"factory\": \"0x9bE53b169a41030f1710A9B82e9eA6413f14D12E\",\n \"accountant\": \"0x345cA3407942f9d175c9eA8B90e83A36F570f852\",\n \"rolesAuthority\": \"0x278D37CaBFFB4B72D2866E30fEFE08aef773E0B6\",\n \"collateralTrackerDecoderAndSanitizer\": \"0x4A290b3EC46cF320421Bb2aaee96d445de31CF0b\"\n },\n \"vaults\": {\n \"wethPlpVault\": \"0x41b7D0515d709A4Fd2CF27f9d141D0c2F8713D04\",\n \"usdcPlpVault\": \"0xb452af299c565D04B05E601efF2840e000C922f1\"\n },\n \"managers\": {\n \"wethPlpVaultManager\": \"0x2a4923456c79E9ebD10F5Bf5305a5C742bBc1D7C\",\n \"usdcPlpVaultManager\": \"0xdd6E2406a044582463CFE9F0C774870eAf4A310B\"\n },\n \"turnkeySigners\": {\n \"wethPlpVaultManager\": \"0x8FfA6DAB99f8afc64F61BeF83F0966eD6362f24F\",\n \"usdcPlpVaultManager\": \"0x3c1c79d0cfc316Ba959194c89696a8382d7d283b\"\n }\n },\n \"panoptic\": {\n \"pool\": {\n \"version\": \"v4\",\n \"panopticPool\": \"0xB50e8bb68f5855DA742f4579274902a20454174a\",\n \"collateralTracker0\": \"0x0d82b189c96EbB1f44A7207e6A9cfB1e490f2869\",\n \"collateralTracker1\": \"0x9ba1082Ab3cb9edEA988697A14BBe543A3dABEd2\"\n },\n \"v2\": {\n \"semiFungiblePositionManagerV4\": \"0x8dcAa08cF298F8b4830FAf56d47930981AdE33af\",\n \"semiFungiblePositionManagerV3\": \"0xFB1c06B491305d618bb8a7a368C6e50c001C153A\",\n \"builderFactory\": \"0x6d26E916a18d522f7DdA2a26d9E1645564ccDcA5\",\n \"riskEngine\": \"0x8bbce8b1eb64118cfe6c1eab0afe13b80ea41481\",\n \"panopticPoolImplementation\": \"0x5BA68a018fF149c38ec52D181Dd24aBabE9a07DB\",\n \"collateralTrackerImplementation\": \"0x34B3a4e4F14f292575ECe3EF67886C4598af459f\",\n \"panopticFactoryV4\": \"0x9ac0317fcd124aff0b5429beb8de17020bc45f9a\",\n \"panopticFactoryV3\": \"0x687f616d68c483a7223e6922f59aef7452e26c1d\",\n \"panopticHelper\": \"0x0000000000000000000000000000000000000000\",\n \"panopticMath\": \"0x6d21699192f5aF112C87e53b32ff846782afF407\",\n \"panopticQuery\": \"0xd2586E1bbdd1169F597F3A370117EdF7372A7350\",\n \"interactionHelper\": \"0x643d8DD5372FD6c71f8fAbCce4Eb8857704F3E15\"\n }\n },\n \"riskEngines\": [\n \"0x8bbce8b1eb64118cfe6c1eab0afe13b80ea41481\"\n ],\n \"markets\": {\n \"ethUsdc5bps\": {\n \"currency0\": \"0x0000000000000000000000000000000000000000\",\n \"currency1\": \"0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913\",\n \"fee\": 500,\n \"tickSpacing\": 10,\n \"poolId\": \"0x96d4b53a38337a5733179751781178a2613306063c511b78cd02684739288c0a\"\n }\n },\n \"subgraphs\": {\n \"hypovault\": \"https://api.goldsky.com/api/public/project_cl9gc21q105380hxuh8ks53k3/subgraphs/hypovault-subgraph-base/prod/gn\",\n \"panoptic\": \"https://api.goldsky.com/api/public/project_cl9gc21q105380hxuh8ks53k3/subgraphs/panoptic-subgraph-base/v2_prod/gn\"\n }\n },\n \"11155111\": {\n \"chainId\": 11155111,\n \"infrastructure\": {\n \"uniswapV3Factory\": \"0x0227628f3F023bb0B980b67D528571c95c6DaC1c\",\n \"poolManager\": \"0xE03A1074c86CFeDd5C142C4F04F1a1536e203543\",\n \"stateView\": \"0xE1Dd9c3fA50EDB962E442f60DfBc432e24537E4C\"\n },\n \"hypovault\": {\n \"core\": {\n \"hypoVaultImplementation\": \"0xC5b415Db4087228Af817893769DC3a205160160B\",\n \"factory\": \"0x363a9d605ca45cBfF3b597350DeADb53cdC292c7\",\n \"accountant\": \"0x25BBef1DF262c24aa1AACD1F7eCeEcc1a7AD08ab\",\n \"rolesAuthority\": \"0x673BfafB4e2712215B422347c1571421B83E8A3d\",\n \"collateralTrackerDecoderAndSanitizer\": \"0xb899BE50BAF25BBB3A3ca3403256B3c703E5AB5d\"\n },\n \"vaults\": {\n \"wethPlpVault\": \"0xD58C4F9AEe5bBfcf28dC9a8d3D57b323fA6521b1\",\n \"usdcPlpVault\": \"0xdd7a8d6c6975488e801129bC84302d74e2361208\"\n },\n \"managers\": {\n \"wethPlpVaultManager\": \"0x95eC124FAAB70D7aE147c3BE0336E01a828AE2d5\",\n \"usdcPlpVaultManager\": \"0xFB5aa3e0b46F3859D90B14b52ffd287013b5Ec53\"\n },\n \"turnkeySigners\": {\n \"wethPlpVaultManager\": \"0x8FfA6DAB99f8afc64F61BeF83F0966eD6362f24F\",\n \"usdcPlpVaultManager\": \"0x3c1c79d0cfc316Ba959194c89696a8382d7d283b\"\n }\n },\n \"panoptic\": {\n \"pool\": {\n \"version\": \"v4\",\n \"panopticPool\": \"0x872b98C46b2062F663BEb2CC9D4cE046Da2a2918\",\n \"collateralTracker0\": \"0x09a60b78d06a03e5148faedd3bfee6f58b22012f\",\n \"collateralTracker1\": \"0x7365664c8101ff7e9422ae2b203822253c31e69c\"\n },\n \"v2\": {\n \"semiFungiblePositionManagerV3\": \"0x9DaD2C40107Db4B29a5450401BB7A28e6eA00e43\",\n \"semiFungiblePositionManagerV4\": \"0xD2615995A71644E122cC2FD7FeC2392b971220DE\",\n \"builderFactory\": \"0x55f3D2d9D065AA5Fcc11D94c55a6085849e8b6C3\",\n \"riskEngine\": \"0x1376aF5ca426B6B9fad6a712c21f6Cf58a94b93c\",\n \"panopticPoolImplementation\": \"0x969235B5830f13b58BB699305d9c70A8Cd3BD97C\",\n \"collateralTrackerImplementation\": \"0xafcd5F651Ae0403Ff668bb2dAc38BEa907a35Dba\",\n \"panopticFactoryV3\": \"0xd9FFCa53C0A6155001Ce8cbcAEfe89DB204690F1\",\n \"panopticFactoryV4\": \"0x8FCBb59b05779818D9BAD2686cc44B705603ce03\",\n \"panopticHelper\": \"0xfFEbB3A4ab793cB244209d4dA0Cb3e6B07133bd0\",\n \"panopticMath\": \"0x6d21699192f5aF112C87e53b32ff846782afF407\",\n \"panopticQuery\": \"0x74057945467Fb4eAE9193B46A60ae66a53f06A5b\",\n \"interactionHelper\": \"0x643d8DD5372FD6c71f8fAbCce4Eb8857704F3E15\"\n }\n },\n \"riskEngines\": [\n \"0x1376aF5ca426B6B9fad6a712c21f6Cf58a94b93c\"\n ],\n \"markets\": {\n \"ethUsdc5bps\": {\n \"currency0\": \"0x0000000000000000000000000000000000000000\",\n \"currency1\": \"0xFFFeD8254566B7F800f6D8CDb843ec75AE49B07A\",\n \"fee\": 500,\n \"tickSpacing\": 10,\n \"poolId\": \"0xba6673bcb27568a73a93dd23b20c8174fa16193cd90905be859144e8f13097a5\"\n }\n },\n \"subgraphs\": {\n \"hypovault\": \"https://api.goldsky.com/api/public/project_cl9gc21q105380hxuh8ks53k3/subgraphs/hypovault-subgraph-sepolia/prod/gn\",\n \"panoptic\": \"https://api.goldsky.com/api/public/project_cl9gc21q105380hxuh8ks53k3/subgraphs/panoptic-subgraph-sepolia/v2_prod/gn\"\n }\n }\n}\n","import chainDeploymentsData from './chainDeployments.data.json' with { type: 'json' }\n\nexport const MAINNET_CHAIN_ID = 1\nexport const SEPOLIA_CHAIN_ID = 11155111\nexport const BASE_CHAIN_ID = 8453\nexport const ROBINHOOD_CHAIN_ID = 4663\n\nexport const CHAIN_DEPLOYMENTS = chainDeploymentsData\n\nexport function getChainDeployment(chainId) {\n return CHAIN_DEPLOYMENTS[chainId]\n}\n\nexport function requireChainDeployment(chainId) {\n const deployment = getChainDeployment(chainId)\n if (deployment === undefined) {\n throw new Error(`Unsupported chain deployment for chainId ${chainId}`)\n }\n return deployment\n}\n\nexport function isSupportedChain(chainId) {\n return getChainDeployment(chainId) !== undefined\n}\n\nexport function getEthUsdcMarket(deployment) {\n const market = deployment.markets.ethUsdc5bps ?? deployment.markets.ethUsdc30bps\n if (market === undefined) {\n throw new Error(`Missing ETH/USDC market for chainId ${deployment.chainId}`)\n }\n return market\n}\n\nexport function getSpyUsdgMarket(deployment) {\n const market = deployment.markets.spyUsdg\n if (market === undefined) {\n throw new Error(`Missing SPY/USDG market for chainId ${deployment.chainId}`)\n }\n return market\n}\n\n\nexport const MAINNET_DEPLOYMENT = CHAIN_DEPLOYMENTS[MAINNET_CHAIN_ID]\nexport const MAINNET_ETH_USDC_5BPS_V3_PANOPTIC_POOL_ADDRESSES =\n MAINNET_DEPLOYMENT.panoptic.additionalPools?.ethUsdc5bpsV3\nexport const MAINNET_PANOPTIC_V2_ADDRESSES = MAINNET_DEPLOYMENT.panoptic.v2\nexport const SEPOLIA_DEPLOYMENT = CHAIN_DEPLOYMENTS[SEPOLIA_CHAIN_ID]\nexport const SEPOLIA_HYPOVAULT_CORE_ADDRESSES = SEPOLIA_DEPLOYMENT.hypovault.core\nexport const SEPOLIA_HYPOVAULT_ADDRESSES = SEPOLIA_DEPLOYMENT.hypovault.vaults\nexport const SEPOLIA_HYPOVAULT_MANAGER_ADDRESSES = SEPOLIA_DEPLOYMENT.hypovault.managers\nexport const SEPOLIA_HYPOVAULT_MANAGER_TURNKEY_SIGNERS = SEPOLIA_DEPLOYMENT.hypovault.turnkeySigners\nexport const SEPOLIA_PANOPTIC_POOL_ADDRESSES = SEPOLIA_DEPLOYMENT.panoptic.pool\nexport const SEPOLIA_PANOPTIC_V2_ADDRESSES = SEPOLIA_DEPLOYMENT.panoptic.v2\nexport const BASE_DEPLOYMENT = CHAIN_DEPLOYMENTS[BASE_CHAIN_ID]\nexport const BASE_HYPOVAULT_CORE_ADDRESSES = BASE_DEPLOYMENT.hypovault.core\nexport const BASE_HYPOVAULT_ADDRESSES = BASE_DEPLOYMENT.hypovault.vaults\nexport const BASE_HYPOVAULT_MANAGER_ADDRESSES = BASE_DEPLOYMENT.hypovault.managers\nexport const BASE_HYPOVAULT_MANAGER_TURNKEY_SIGNERS = BASE_DEPLOYMENT.hypovault.turnkeySigners\nexport const BASE_PANOPTIC_POOL_ADDRESSES = BASE_DEPLOYMENT.panoptic.pool\nexport const BASE_PANOPTIC_V2_ADDRESSES = BASE_DEPLOYMENT.panoptic.v2\nexport const BASE_ETH_USDC_5BPS_MARKET = getEthUsdcMarket(BASE_DEPLOYMENT)\nexport const SEPOLIA_ETH_USDC_5BPS_MARKET = getEthUsdcMarket(SEPOLIA_DEPLOYMENT)\n\nexport const MAINNET_RISK_ENGINES = MAINNET_DEPLOYMENT.riskEngines\nexport const BASE_RISK_ENGINES = BASE_DEPLOYMENT.riskEngines\nexport const SEPOLIA_RISK_ENGINES = SEPOLIA_DEPLOYMENT.riskEngines\n\nexport const ROBINHOOD_DEPLOYMENT = CHAIN_DEPLOYMENTS[ROBINHOOD_CHAIN_ID]\nexport const ROBINHOOD_HYPOVAULT_CORE_ADDRESSES = ROBINHOOD_DEPLOYMENT.hypovault.core\nexport const ROBINHOOD_HYPOVAULT_ADDRESSES = ROBINHOOD_DEPLOYMENT.hypovault.vaults\nexport const ROBINHOOD_HYPOVAULT_MANAGER_ADDRESSES = ROBINHOOD_DEPLOYMENT.hypovault.managers\nexport const ROBINHOOD_HYPOVAULT_MANAGER_TURNKEY_SIGNERS = ROBINHOOD_DEPLOYMENT.hypovault.turnkeySigners\nexport const ROBINHOOD_PANOPTIC_POOL_ADDRESSES = ROBINHOOD_DEPLOYMENT.panoptic.pool\nexport const ROBINHOOD_PANOPTIC_V2_ADDRESSES = ROBINHOOD_DEPLOYMENT.panoptic.v2\nexport const ROBINHOOD_RISK_ENGINES = ROBINHOOD_DEPLOYMENT.riskEngines\nexport const ROBINHOOD_SPY_USDG_MARKET = getSpyUsdgMarket(ROBINHOOD_DEPLOYMENT)\n","import {\n BASE_CHAIN_ID,\n MAINNET_CHAIN_ID,\n requireChainDeployment,\n ROBINHOOD_CHAIN_ID,\n SEPOLIA_CHAIN_ID,\n} from './chainDeployments.js'\n\nconst mainnetDeployment = requireChainDeployment(MAINNET_CHAIN_ID)\nconst mainnetVaults = mainnetDeployment.hypovault.vaults\nconst legacyMainnetVaults = {\n wethPlpVault: '0x779a2aa634A004b3a3f3b322083744869BBC6D66',\n usdcPlpVault: '0x963Fe9c93bc353602656ee4051A75114bA74d6c5',\n}\nconst sepoliaDeployment = requireChainDeployment(SEPOLIA_CHAIN_ID)\nconst sepoliaVaults = sepoliaDeployment.hypovault.vaults\nconst baseDeployment = requireChainDeployment(BASE_CHAIN_ID)\nconst baseVaults = baseDeployment.hypovault.vaults\nconst robinhoodDeployment = requireChainDeployment(ROBINHOOD_CHAIN_ID)\nconst robinhoodUsdgVault = robinhoodDeployment.hypovault.vaults.usdgPlpVault\n\nif (robinhoodUsdgVault === undefined) {\n throw new Error('Missing Robinhood USDG PLP vault address')\n}\n\nexport const VAULT_DISPLAY_NAMES_PER_CHAIN = {\n [MAINNET_CHAIN_ID]: {\n [mainnetVaults.wethPlpVault.toLowerCase()]: 'PLP Vault',\n [mainnetVaults.usdcPlpVault.toLowerCase()]: 'Unicorn Vault',\n [legacyMainnetVaults.wethPlpVault.toLowerCase()]: 'PLP Vault',\n [legacyMainnetVaults.usdcPlpVault.toLowerCase()]: 'Unicorn Vault',\n },\n [BASE_CHAIN_ID]: {\n [baseVaults.wethPlpVault.toLowerCase()]: 'PLP Vault',\n [baseVaults.usdcPlpVault.toLowerCase()]: 'Unicorn Vault',\n },\n [SEPOLIA_CHAIN_ID]: {\n [sepoliaVaults.wethPlpVault.toLowerCase()]: 'PLP Vault',\n [sepoliaVaults.usdcPlpVault.toLowerCase()]: 'Unicorn Vault',\n },\n [ROBINHOOD_CHAIN_ID]: {\n [robinhoodUsdgVault.toLowerCase()]: '0DTE +67∆ Vault',\n },\n}\n\nexport const VAULT_DISPLAY_NAME_RESOLVERS_PER_CHAIN = {\n [MAINNET_CHAIN_ID]: {\n [mainnetVaults.wethPlpVault.toLowerCase()]: () => 'PLP Vault',\n [mainnetVaults.usdcPlpVault.toLowerCase()]: () => 'Unicorn Vault',\n [legacyMainnetVaults.wethPlpVault.toLowerCase()]: () => 'PLP Vault',\n [legacyMainnetVaults.usdcPlpVault.toLowerCase()]: () => 'Unicorn Vault',\n },\n [BASE_CHAIN_ID]: {\n [baseVaults.wethPlpVault.toLowerCase()]: () => 'PLP Vault',\n [baseVaults.usdcPlpVault.toLowerCase()]: () => 'Unicorn Vault',\n },\n [SEPOLIA_CHAIN_ID]: {\n [sepoliaVaults.wethPlpVault.toLowerCase()]: () => 'PLP Vault',\n [sepoliaVaults.usdcPlpVault.toLowerCase()]: () => 'Unicorn Vault',\n },\n [ROBINHOOD_CHAIN_ID]: {\n [robinhoodUsdgVault.toLowerCase()]: () => '0DTE +67∆ Vault',\n },\n}\n\nexport function resolveVaultDisplayName({ chainId, vaultAddress, underlyingSymbol, fallbackName }) {\n const vaultAddressLower = vaultAddress.toLowerCase()\n const resolver = VAULT_DISPLAY_NAME_RESOLVERS_PER_CHAIN[chainId]?.[vaultAddressLower]\n if (resolver !== undefined) {\n return resolver({\n chainId,\n vaultAddress: vaultAddressLower,\n underlyingSymbol,\n fallbackName,\n })\n }\n\n const staticName = VAULT_DISPLAY_NAMES_PER_CHAIN[chainId]?.[vaultAddressLower]\n if (staticName !== undefined) {\n return staticName\n }\n\n if (fallbackName !== undefined && fallbackName !== null) {\n return fallbackName\n }\n\n return 'Vault'\n}\n","import type { Chain, Client, Transport } from 'viem'\nimport { hexToBigInt } from 'viem'\nimport { estimateFeesPerGas, getBlock, getFeeHistory } from 'viem/actions'\n\nimport { ROBINHOOD_CHAIN_ID } from './chainDeployments'\n\nexport const MIN_VAULT_PRIORITY_FEE_PER_GAS = 100_000_000n // 0.1 gwei\nexport const MAX_VAULT_PRIORITY_FEE_PER_GAS = 3_000_000_000n // 3 gwei\nexport const MAX_STALE_DELTA_HEDGE_PRIORITY_FEE_PER_GAS = 8_000_000_000n // 8 gwei\nexport const MAX_VAULT_TRANSACTION_GAS_COST = 15_000_000_000_000_000n // 0.015 ETH\n\nconst FEE_HISTORY_BLOCK_COUNT = 20\nconst FEE_HISTORY_REWARD_PERCENTILES = [90]\nconst DELTA_HEDGE_FEE_HISTORY_REWARD_PERCENTILES = [25]\nconst BASE_FEE_BUFFER_NUMERATOR = 1_125n\nconst BASE_FEE_BUFFER_DENOMINATOR = 1_000n\nconst REPLACEMENT_FEE_BUMP_NUMERATOR = 1_125n\nconst REPLACEMENT_FEE_BUMP_DENOMINATOR = 1_000n\nconst DELTA_HEDGE_PRIORITY_FEE_BUMP_NUMERATOR = 1_300n\nconst DELTA_HEDGE_PRIORITY_FEE_BUMP_DENOMINATOR = 1_000n\n// Leave the mandatory 12.5% replacement headroom for a final 3 gwei replacement.\nconst MAX_DELTA_HEDGE_PRIORITY_FEE_PER_GAS =\n (MAX_VAULT_PRIORITY_FEE_PER_GAS * REPLACEMENT_FEE_BUMP_DENOMINATOR) /\n REPLACEMENT_FEE_BUMP_NUMERATOR\nconst GAS_ESTIMATE_BUFFER_NUMERATOR = 3n\nconst GAS_ESTIMATE_BUFFER_DENOMINATOR = 2n\n\nexport type VaultTransactionFeeQuote = {\n currentBaseFeePerGas?: bigint\n maxFeePerGas: bigint\n maxPriorityFeePerGas: bigint\n minimumMaxFeePerGas: bigint\n minimumPriorityFeePerGas?: bigint\n source: 'fee_history' | 'viem_fallback' | 'rpc_priority_fee' | 'fee_history_p25'\n}\n\nexport type VaultDeltaHedgeFeeQuote = VaultTransactionFeeQuote & {\n rawPriorityFeePerGas: bigint\n}\n\nexport type VaultSignedTransactionFeeCaps = {\n chainId?: number\n gasLimit?: bigint | null\n maxFeePerGas: bigint | null\n maxPriorityFeePerGas: bigint | null\n}\n\nexport type VaultSignedTransactionFeeValidationResult =\n | { valid: true }\n | {\n valid: false\n code:\n | 'MissingEip1559Fees'\n | 'InvalidFeeCaps'\n | 'PriorityFeeTooLow'\n | 'PriorityFeeTooHigh'\n | 'MaxFeeTooLow'\n | 'GasCostTooHigh'\n reason: string\n }\n\nexport class VaultTransactionFeeEstimationError extends Error {\n readonly feeHistoryError: unknown\n readonly fallbackError: unknown\n\n constructor({\n feeHistoryError,\n fallbackError,\n }: {\n feeHistoryError: unknown\n fallbackError: unknown\n }) {\n super('Unable to estimate EIP-1559 fees for vault transaction')\n this.name = 'VaultTransactionFeeEstimationError'\n this.feeHistoryError = feeHistoryError\n this.fallbackError = fallbackError\n }\n}\n\nexport class VaultTransactionGasCostLimitError extends Error {\n readonly gasLimit: bigint\n readonly maximumAffordableFeePerGas: bigint\n readonly minimumRequiredFeePerGas: bigint\n\n constructor({\n gasLimit,\n maximumAffordableFeePerGas,\n minimumRequiredFeePerGas,\n }: {\n gasLimit: bigint\n maximumAffordableFeePerGas: bigint\n minimumRequiredFeePerGas: bigint\n }) {\n super(\n `Vault transaction cannot fit the ${MAX_VAULT_TRANSACTION_GAS_COST.toString()} wei gas-cost limit: ` +\n `gasLimit=${gasLimit.toString()}, maximumAffordableFeePerGas=${maximumAffordableFeePerGas.toString()}, ` +\n `minimumRequiredFeePerGas=${minimumRequiredFeePerGas.toString()}`,\n )\n this.name = 'VaultTransactionGasCostLimitError'\n this.gasLimit = gasLimit\n this.maximumAffordableFeePerGas = maximumAffordableFeePerGas\n this.minimumRequiredFeePerGas = minimumRequiredFeePerGas\n }\n}\n\nexport class VaultTransactionReplacementLimitError extends Error {\n readonly code: 'GasCostCapExceeded' | 'PriorityFeeCapExceeded'\n readonly requiredMaxFeePerGas: bigint\n readonly requiredMaxPriorityFeePerGas: bigint\n readonly maximumAffordableFeePerGas: bigint\n\n constructor({\n code,\n gasLimit,\n requiredMaxFeePerGas,\n requiredMaxPriorityFeePerGas,\n maximumAffordableFeePerGas,\n }: {\n code: 'GasCostCapExceeded' | 'PriorityFeeCapExceeded'\n gasLimit: bigint\n requiredMaxFeePerGas: bigint\n requiredMaxPriorityFeePerGas: bigint\n maximumAffordableFeePerGas: bigint\n }) {\n super(\n `Vault transaction replacement blocked by ${code}: gasLimit=${gasLimit.toString()}, ` +\n `requiredMaxFeePerGas=${requiredMaxFeePerGas.toString()}, ` +\n `requiredMaxPriorityFeePerGas=${requiredMaxPriorityFeePerGas.toString()}, ` +\n `maximumAffordableFeePerGas=${maximumAffordableFeePerGas.toString()}`,\n )\n this.name = 'VaultTransactionReplacementLimitError'\n this.code = code\n this.requiredMaxFeePerGas = requiredMaxFeePerGas\n this.requiredMaxPriorityFeePerGas = requiredMaxPriorityFeePerGas\n this.maximumAffordableFeePerGas = maximumAffordableFeePerGas\n }\n}\n\ntype FeeHistorySnapshot = {\n baseFeePerGas: readonly bigint[]\n reward?: readonly (readonly bigint[])[] | undefined\n minimumPriorityFeePerGas?: bigint\n}\n\ntype FallbackFeeEstimate = {\n maxFeePerGas: bigint\n maxPriorityFeePerGas: bigint\n}\n\nfunction ceilMultiplyFraction(value: bigint, numerator: bigint, denominator: bigint): bigint {\n return (value * numerator + denominator - 1n) / denominator\n}\n\nfunction medianBigInt(values: readonly bigint[]): bigint | undefined {\n if (values.length === 0) return undefined\n const sorted = [...values].sort((left, right) => (left < right ? -1 : left > right ? 1 : 0))\n const upperMiddleIndex = Math.floor(sorted.length / 2)\n const upperMiddle = sorted[upperMiddleIndex]\n if (upperMiddle === undefined) return undefined\n if (sorted.length % 2 === 1) return upperMiddle\n const lowerMiddle = sorted[upperMiddleIndex - 1]\n return lowerMiddle === undefined ? undefined : (lowerMiddle + upperMiddle) / 2n\n}\n\nfunction getChainPriorityFeeFloor(chainId: number | undefined): bigint | undefined {\n return chainId === ROBINHOOD_CHAIN_ID ? 0n : undefined\n}\n\nfunction clampPriorityFee(\n priorityFee: bigint,\n minimumPriorityFeePerGas = MIN_VAULT_PRIORITY_FEE_PER_GAS,\n): bigint {\n if (priorityFee < minimumPriorityFeePerGas) return minimumPriorityFeePerGas\n if (priorityFee > MAX_VAULT_PRIORITY_FEE_PER_GAS) return MAX_VAULT_PRIORITY_FEE_PER_GAS\n return priorityFee\n}\n\nfunction resolveFeeHistoryQuote({\n baseFeePerGas,\n reward,\n minimumPriorityFeePerGas,\n}: {\n baseFeePerGas: readonly bigint[]\n reward?: readonly (readonly bigint[])[] | undefined\n minimumPriorityFeePerGas?: bigint\n}): VaultTransactionFeeQuote | null {\n // feeHistory includes one additional base fee for the next block. The\n // second-to-last entry is therefore the latest mined block's base fee.\n const latestBaseFeeIndex = baseFeePerGas.length - 2\n if (latestBaseFeeIndex < 0 || reward === undefined || reward.length === 0) return null\n\n const p90Rewards = reward.flatMap((blockRewards) => {\n const p90 = blockRewards[0]\n return p90 === undefined ? [] : [p90]\n })\n const sampledPriorityFee = medianBigInt(p90Rewards)\n if (sampledPriorityFee === undefined) return null\n\n const effectivePriorityFeeFloor = minimumPriorityFeePerGas ?? MIN_VAULT_PRIORITY_FEE_PER_GAS\n const maxPriorityFeePerGas = clampPriorityFee(sampledPriorityFee, effectivePriorityFeeFloor)\n const bufferedBaseFee = ceilMultiplyFraction(\n baseFeePerGas[latestBaseFeeIndex],\n BASE_FEE_BUFFER_NUMERATOR,\n BASE_FEE_BUFFER_DENOMINATOR,\n )\n\n return {\n currentBaseFeePerGas: baseFeePerGas[latestBaseFeeIndex],\n maxFeePerGas: bufferedBaseFee + maxPriorityFeePerGas,\n maxPriorityFeePerGas,\n minimumMaxFeePerGas: bufferedBaseFee + effectivePriorityFeeFloor,\n ...(minimumPriorityFeePerGas === undefined ? {} : { minimumPriorityFeePerGas }),\n source: 'fee_history',\n }\n}\n\nfunction resolveDeltaHedgeFeeHistoryQuote({\n baseFeePerGas,\n reward,\n minimumPriorityFeePerGas,\n}: FeeHistorySnapshot): VaultDeltaHedgeFeeQuote | null {\n const latestBaseFeeIndex = baseFeePerGas.length - 2\n if (latestBaseFeeIndex < 0 || reward === undefined || reward.length === 0) return null\n\n const p25Rewards = reward.flatMap((blockRewards) => {\n const p25 = blockRewards[0]\n return p25 === undefined ? [] : [p25]\n })\n const rawPriorityFeePerGas = medianBigInt(p25Rewards)\n if (rawPriorityFeePerGas === undefined) return null\n\n const effectivePriorityFeeFloor = minimumPriorityFeePerGas ?? MIN_VAULT_PRIORITY_FEE_PER_GAS\n const maxPriorityFeePerGas = clampPriorityFee(rawPriorityFeePerGas, effectivePriorityFeeFloor)\n const bufferedBaseFee = ceilMultiplyFraction(\n baseFeePerGas[latestBaseFeeIndex],\n BASE_FEE_BUFFER_NUMERATOR,\n BASE_FEE_BUFFER_DENOMINATOR,\n )\n return {\n maxFeePerGas: bufferedBaseFee + maxPriorityFeePerGas,\n maxPriorityFeePerGas,\n minimumMaxFeePerGas: bufferedBaseFee + effectivePriorityFeeFloor,\n ...(minimumPriorityFeePerGas === undefined ? {} : { minimumPriorityFeePerGas }),\n rawPriorityFeePerGas,\n source: 'fee_history_p25',\n }\n}\n\nfunction resolveRpcPriorityFeeQuote({\n baseFeePerGas,\n rawPriorityFeePerGas,\n minimumPriorityFeePerGas,\n}: {\n baseFeePerGas: bigint\n rawPriorityFeePerGas: bigint\n minimumPriorityFeePerGas?: bigint\n}): VaultDeltaHedgeFeeQuote {\n const bufferedBaseFee = ceilMultiplyFraction(\n baseFeePerGas,\n BASE_FEE_BUFFER_NUMERATOR,\n BASE_FEE_BUFFER_DENOMINATOR,\n )\n return {\n maxFeePerGas: bufferedBaseFee + rawPriorityFeePerGas,\n maxPriorityFeePerGas: rawPriorityFeePerGas,\n minimumMaxFeePerGas: bufferedBaseFee + (minimumPriorityFeePerGas ?? rawPriorityFeePerGas),\n ...(minimumPriorityFeePerGas === undefined ? {} : { minimumPriorityFeePerGas }),\n rawPriorityFeePerGas,\n source: 'rpc_priority_fee',\n }\n}\n\nexport function getVaultTransactionReplacementFeeQuote({\n originalQuote,\n historicalQuote,\n gasLimit,\n finalReplacement = false,\n staleBoundsReplacement = false,\n}: {\n originalQuote: Pick<VaultTransactionFeeQuote, 'maxFeePerGas' | 'maxPriorityFeePerGas'>\n historicalQuote: VaultDeltaHedgeFeeQuote\n gasLimit: bigint\n finalReplacement?: boolean\n staleBoundsReplacement?: boolean\n}): VaultDeltaHedgeFeeQuote {\n if (gasLimit <= 0n) {\n throw new Error(`Vault transaction gas limit must be positive, received ${gasLimit.toString()}`)\n }\n\n const bumpedPriorityFee = staleBoundsReplacement\n ? ceilMultiplyFraction(\n originalQuote.maxPriorityFeePerGas,\n REPLACEMENT_FEE_BUMP_NUMERATOR,\n REPLACEMENT_FEE_BUMP_DENOMINATOR,\n )\n : ceilMultiplyFraction(\n originalQuote.maxPriorityFeePerGas,\n DELTA_HEDGE_PRIORITY_FEE_BUMP_NUMERATOR,\n DELTA_HEDGE_PRIORITY_FEE_BUMP_DENOMINATOR,\n )\n const bumpedMaxFee = ceilMultiplyFraction(\n originalQuote.maxFeePerGas,\n REPLACEMENT_FEE_BUMP_NUMERATOR,\n REPLACEMENT_FEE_BUMP_DENOMINATOR,\n )\n const escalatingPriorityFee =\n historicalQuote.maxPriorityFeePerGas > bumpedPriorityFee\n ? historicalQuote.maxPriorityFeePerGas\n : bumpedPriorityFee\n const priorityFeeLimit = staleBoundsReplacement\n ? MAX_STALE_DELTA_HEDGE_PRIORITY_FEE_PER_GAS\n : finalReplacement\n ? MAX_VAULT_PRIORITY_FEE_PER_GAS\n : MAX_DELTA_HEDGE_PRIORITY_FEE_PER_GAS\n const desiredMaxPriorityFeePerGas = finalReplacement\n ? MAX_VAULT_PRIORITY_FEE_PER_GAS\n : staleBoundsReplacement\n ? bumpedPriorityFee\n : escalatingPriorityFee\n const requiredReplacementPriorityFee = ceilMultiplyFraction(\n originalQuote.maxPriorityFeePerGas,\n REPLACEMENT_FEE_BUMP_NUMERATOR,\n REPLACEMENT_FEE_BUMP_DENOMINATOR,\n )\n const requiredMaxPriorityFeePerGas =\n desiredMaxPriorityFeePerGas < priorityFeeLimit ? desiredMaxPriorityFeePerGas : priorityFeeLimit\n if (requiredMaxPriorityFeePerGas < requiredReplacementPriorityFee) {\n throw new VaultTransactionReplacementLimitError({\n code: 'PriorityFeeCapExceeded',\n gasLimit,\n requiredMaxFeePerGas: originalQuote.maxFeePerGas,\n requiredMaxPriorityFeePerGas: requiredReplacementPriorityFee,\n maximumAffordableFeePerGas: MAX_VAULT_TRANSACTION_GAS_COST / gasLimit,\n })\n }\n const bufferedBaseFee =\n historicalQuote.minimumMaxFeePerGas -\n (historicalQuote.minimumPriorityFeePerGas ?? MIN_VAULT_PRIORITY_FEE_PER_GAS)\n const currentMarketMaxFee = bufferedBaseFee + requiredMaxPriorityFeePerGas\n const desiredMaxFeePerGas =\n currentMarketMaxFee > bumpedMaxFee ? currentMarketMaxFee : bumpedMaxFee\n const maximumAffordableFeePerGas = MAX_VAULT_TRANSACTION_GAS_COST / gasLimit\n\n if (\n bumpedMaxFee > maximumAffordableFeePerGas ||\n requiredMaxPriorityFeePerGas > maximumAffordableFeePerGas\n ) {\n throw new VaultTransactionReplacementLimitError({\n code: 'GasCostCapExceeded',\n gasLimit,\n requiredMaxFeePerGas: bumpedMaxFee,\n requiredMaxPriorityFeePerGas,\n maximumAffordableFeePerGas,\n })\n }\n const maxFeePerGas =\n desiredMaxFeePerGas < maximumAffordableFeePerGas\n ? desiredMaxFeePerGas\n : maximumAffordableFeePerGas\n\n return {\n ...historicalQuote,\n maxFeePerGas,\n maxPriorityFeePerGas: requiredMaxPriorityFeePerGas,\n }\n}\n\nfunction resolveFallbackQuote({\n maxFeePerGas: estimatedMaxFeePerGas,\n maxPriorityFeePerGas: estimatedPriorityFeePerGas,\n minimumPriorityFeePerGas,\n}: {\n maxFeePerGas: bigint\n maxPriorityFeePerGas: bigint\n minimumPriorityFeePerGas?: bigint\n}): VaultTransactionFeeQuote {\n const effectivePriorityFeeFloor = minimumPriorityFeePerGas ?? MIN_VAULT_PRIORITY_FEE_PER_GAS\n const maxPriorityFeePerGas = clampPriorityFee(\n estimatedPriorityFeePerGas,\n effectivePriorityFeeFloor,\n )\n const estimatedBaseFeeAllowance =\n estimatedMaxFeePerGas > estimatedPriorityFeePerGas\n ? estimatedMaxFeePerGas - estimatedPriorityFeePerGas\n : 0n\n\n return {\n maxFeePerGas: estimatedBaseFeeAllowance + maxPriorityFeePerGas,\n maxPriorityFeePerGas,\n minimumMaxFeePerGas: estimatedBaseFeeAllowance + effectivePriorityFeeFloor,\n ...(minimumPriorityFeePerGas === undefined ? {} : { minimumPriorityFeePerGas }),\n source: 'viem_fallback',\n }\n}\n\nexport function applyVaultTransactionGasCostLimit(\n quote: VaultTransactionFeeQuote,\n gasLimit: bigint,\n): VaultTransactionFeeQuote {\n if (gasLimit <= 0n) {\n throw new Error(`Vault transaction gas limit must be positive, received ${gasLimit.toString()}`)\n }\n\n const maximumAffordableFeePerGas = MAX_VAULT_TRANSACTION_GAS_COST / gasLimit\n if (maximumAffordableFeePerGas < quote.minimumMaxFeePerGas) {\n throw new VaultTransactionGasCostLimitError({\n gasLimit,\n maximumAffordableFeePerGas,\n minimumRequiredFeePerGas: quote.minimumMaxFeePerGas,\n })\n }\n\n if (quote.maxFeePerGas <= maximumAffordableFeePerGas) return quote\n\n const bufferedBaseFee =\n quote.minimumMaxFeePerGas - (quote.minimumPriorityFeePerGas ?? MIN_VAULT_PRIORITY_FEE_PER_GAS)\n const affordablePriorityFee = maximumAffordableFeePerGas - bufferedBaseFee\n return {\n ...quote,\n maxFeePerGas: maximumAffordableFeePerGas,\n maxPriorityFeePerGas:\n quote.maxPriorityFeePerGas < affordablePriorityFee\n ? quote.maxPriorityFeePerGas\n : affordablePriorityFee,\n }\n}\n\nexport function bufferVaultTransactionGasEstimate(gasEstimate: bigint): bigint {\n if (gasEstimate <= 0n) {\n throw new Error(\n `Vault transaction gas estimate must be positive, received ${gasEstimate.toString()}`,\n )\n }\n return ceilMultiplyFraction(\n gasEstimate,\n GAS_ESTIMATE_BUFFER_NUMERATOR,\n GAS_ESTIMATE_BUFFER_DENOMINATOR,\n )\n}\n\nexport function validateVaultSignedTransactionFeeCaps(\n feeCaps: VaultSignedTransactionFeeCaps,\n quote?: VaultTransactionFeeQuote,\n): VaultSignedTransactionFeeValidationResult {\n const { chainId, gasLimit, maxFeePerGas, maxPriorityFeePerGas } = feeCaps\n const minimumPriorityFeePerGas =\n quote?.minimumPriorityFeePerGas ??\n getChainPriorityFeeFloor(chainId) ??\n MIN_VAULT_PRIORITY_FEE_PER_GAS\n if (maxFeePerGas === null || maxPriorityFeePerGas === null) {\n return {\n valid: false,\n code: 'MissingEip1559Fees',\n reason: 'Signed transaction must include EIP-1559 max fee and priority fee caps.',\n }\n }\n if (maxPriorityFeePerGas > maxFeePerGas) {\n return {\n valid: false,\n code: 'InvalidFeeCaps',\n reason:\n `Signed transaction maxPriorityFeePerGas (${maxPriorityFeePerGas.toString()} wei) ` +\n `cannot exceed maxFeePerGas (${maxFeePerGas.toString()} wei).`,\n }\n }\n if (maxPriorityFeePerGas < minimumPriorityFeePerGas) {\n return {\n valid: false,\n code: 'PriorityFeeTooLow',\n reason:\n `Signed transaction maxPriorityFeePerGas (${maxPriorityFeePerGas.toString()} wei) ` +\n `must be at least ${minimumPriorityFeePerGas.toString()} wei.`,\n }\n }\n if (maxPriorityFeePerGas > MAX_VAULT_PRIORITY_FEE_PER_GAS) {\n return {\n valid: false,\n code: 'PriorityFeeTooHigh',\n reason:\n `Signed transaction maxPriorityFeePerGas (${maxPriorityFeePerGas.toString()} wei) ` +\n `must not exceed ${MAX_VAULT_PRIORITY_FEE_PER_GAS.toString()} wei (3 gwei).`,\n }\n }\n if (\n gasLimit !== undefined &&\n gasLimit !== null &&\n gasLimit * maxFeePerGas > MAX_VAULT_TRANSACTION_GAS_COST\n ) {\n return {\n valid: false,\n code: 'GasCostTooHigh',\n reason:\n `Signed transaction maximum gas cost (${(gasLimit * maxFeePerGas).toString()} wei) ` +\n `must not exceed ${MAX_VAULT_TRANSACTION_GAS_COST.toString()} wei (0.015 ETH).`,\n }\n }\n if (quote !== undefined) {\n const feeRequirementDescription =\n quote.currentBaseFeePerGas === undefined ? 'buffered next-block base fee' : 'current base fee'\n const minimumBroadcastMaxFeePerGas =\n quote.currentBaseFeePerGas === undefined\n ? quote.minimumMaxFeePerGas\n : quote.currentBaseFeePerGas + minimumPriorityFeePerGas\n if (maxFeePerGas < minimumBroadcastMaxFeePerGas) {\n return {\n valid: false,\n code: 'MaxFeeTooLow',\n reason:\n `Signed transaction maxFeePerGas (${maxFeePerGas.toString()} wei) must be at least ` +\n `${minimumBroadcastMaxFeePerGas.toString()} wei for the ${feeRequirementDescription} ` +\n 'and configured minimum priority fee.',\n }\n }\n }\n return { valid: true }\n}\n\nasync function resolveVaultTransactionFeeQuote({\n readFeeHistory,\n readFallbackEstimate,\n minimumPriorityFeePerGas,\n}: {\n readFeeHistory: () => Promise<FeeHistorySnapshot>\n readFallbackEstimate: () => Promise<FallbackFeeEstimate>\n minimumPriorityFeePerGas?: bigint\n}): Promise<VaultTransactionFeeQuote> {\n let feeHistoryError: unknown\n try {\n const quote = resolveFeeHistoryQuote({\n ...(await readFeeHistory()),\n minimumPriorityFeePerGas,\n })\n if (quote !== null) return quote\n feeHistoryError = new Error('eth_feeHistory returned incomplete base fee or reward data')\n } catch (error) {\n feeHistoryError = error\n }\n\n try {\n return resolveFallbackQuote({\n ...(await readFallbackEstimate()),\n minimumPriorityFeePerGas,\n })\n } catch (fallbackError) {\n throw new VaultTransactionFeeEstimationError({ feeHistoryError, fallbackError })\n }\n}\n\n/**\n * Resolve explicit EIP-1559 fees for operator-controlled vault transactions.\n *\n * The normal path follows the median p90 priority fee from the last 20 blocks,\n * with a 3 gwei ceiling and a 0.1 gwei floor except on chains that do not use\n * tips for ordering. If fee history is unavailable, Viem's estimate is used\n * while preserving those bounds and its original base-fee allowance.\n */\nexport async function getVaultTransactionFeeQuote<chain extends Chain | undefined>(\n client: Client<Transport, chain>,\n): Promise<VaultTransactionFeeQuote> {\n return resolveVaultTransactionFeeQuote({\n minimumPriorityFeePerGas: getChainPriorityFeeFloor(client.chain?.id),\n readFeeHistory: () =>\n getFeeHistory(client, {\n blockCount: FEE_HISTORY_BLOCK_COUNT,\n blockTag: 'latest',\n rewardPercentiles: FEE_HISTORY_REWARD_PERCENTILES,\n }),\n readFallbackEstimate: () => estimateFeesPerGas(client),\n })\n}\n\nexport async function getVaultDeltaHedgeHistoricalFeeQuote<chain extends Chain | undefined>(\n client: Client<Transport, chain>,\n): Promise<VaultDeltaHedgeFeeQuote> {\n const feeHistory = await getFeeHistory(client, {\n blockCount: FEE_HISTORY_BLOCK_COUNT,\n blockTag: 'latest',\n rewardPercentiles: DELTA_HEDGE_FEE_HISTORY_REWARD_PERCENTILES,\n })\n const quote = resolveDeltaHedgeFeeHistoryQuote({\n ...feeHistory,\n minimumPriorityFeePerGas: getChainPriorityFeeFloor(client.chain?.id),\n })\n if (quote === null) {\n throw new Error('eth_feeHistory returned incomplete p25 base fee or reward data')\n }\n return quote\n}\n\nasync function resolveVaultDeltaHedgeInitialFeeQuote({\n readRpcQuote,\n readHistoricalQuote,\n minimumPriorityFeePerGas,\n}: {\n readRpcQuote: () => Promise<{ baseFeePerGas: bigint; rawPriorityFeePerGas: bigint }>\n readHistoricalQuote: () => Promise<VaultDeltaHedgeFeeQuote>\n minimumPriorityFeePerGas?: bigint\n}): Promise<VaultDeltaHedgeFeeQuote> {\n try {\n return resolveRpcPriorityFeeQuote({\n ...(await readRpcQuote()),\n minimumPriorityFeePerGas,\n })\n } catch {\n return readHistoricalQuote()\n }\n}\n\n/**\n * Resolve the first fee quote for a delta hedge from the connected RPC's\n * eth_maxPriorityFeePerGas recommendation. A failed RPC recommendation falls\n * back immediately to the rolling historical p25 quote.\n */\nexport async function getVaultDeltaHedgeInitialFeeQuote<chain extends Chain | undefined>(\n client: Client<Transport, chain>,\n): Promise<VaultDeltaHedgeFeeQuote> {\n return resolveVaultDeltaHedgeInitialFeeQuote({\n minimumPriorityFeePerGas: getChainPriorityFeeFloor(client.chain?.id),\n readRpcQuote: async () => {\n const [rawPriorityFee, latestBlock] = await Promise.all([\n client.request({ method: 'eth_maxPriorityFeePerGas' }),\n getBlock(client, { blockTag: 'latest' }),\n ])\n if (latestBlock.baseFeePerGas === null) {\n throw new Error('Latest block does not include an EIP-1559 base fee')\n }\n return {\n baseFeePerGas: latestBlock.baseFeePerGas,\n rawPriorityFeePerGas: hexToBigInt(rawPriorityFee),\n }\n },\n readHistoricalQuote: () => getVaultDeltaHedgeHistoricalFeeQuote(client),\n })\n}\n\nexport const __transactionFeeTestUtils = {\n clampPriorityFee,\n getChainPriorityFeeFloor,\n resolveDeltaHedgeFeeHistoryQuote,\n resolveFallbackQuote,\n resolveFeeHistoryQuote,\n resolveRpcPriorityFeeQuote,\n resolveVaultDeltaHedgeInitialFeeQuote,\n resolveVaultTransactionFeeQuote,\n}\n"],"mappings":";;;;SACO;CACH,WAAW;CACX,kBAAkB;EAChB,oBAAoB;EACpB,eAAe;EACf,aAAa;CACd;CACD,aAAa;EACX,QAAQ;GACN,2BAA2B;GAC3B,WAAW;GACX,cAAc;GACd,kBAAkB;GAClB,wCAAwC;EACzC;EACD,UAAU;GACR,gBAAgB;GAChB,gBAAgB;EACjB;EACD,YAAY;GACV,uBAAuB;GACvB,uBAAuB;EACxB;EACD,kBAAkB;GAChB,uBAAuB;GACvB,uBAAuB;EACxB;CACF;CACD,YAAY;EACV,QAAQ;GACN,WAAW;GACX,gBAAgB;GAChB,sBAAsB;GACtB,sBAAsB;EACvB;EACD,mBAAmB,EACjB,iBAAiB;GACf,WAAW;GACX,gBAAgB;GAChB,sBAAsB;GACtB,sBAAsB;EACvB,EACF;EACD,MAAM;GACJ,iCAAiC;GACjC,iCAAiC;GACjC,kBAAkB;GAClB,cAAc;GACd,8BAA8B;GAC9B,mCAAmC;GACnC,qBAAqB;GACrB,qBAAqB;GACrB,kBAAkB;GAClB,gBAAgB;GAChB,iBAAiB;GACjB,qBAAqB;EACtB;CACF;CACD,eAAe,CACb,8CACA,4CACD;CACD,WAAW,EACT,gBAAgB;EACd,aAAa;EACb,aAAa;EACb,OAAO;EACP,eAAe;EACf,UAAU;CACX,EACF;CACD,aAAa;EACX,aAAa;EACb,YAAY;CACb;CACD,YAAY;EACV,WAAW;EACX,QAAQ;EACR,eAAe;EACf,UAAU;EACV,OAAO;EACP,QAAQ;CACT;CACD,yBAAyB,CACvB,8CACA,4CACD;AACF;YACO;CACN,WAAW;CACX,kBAAkB;EAChB,oBAAoB;EACpB,eAAe;EACf,aAAa;CACd;CACD,aAAa;EACX,QAAQ;GAC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AAI;AACF,SAAO,2BAA2B;GAChC,GAAI,MAAM,cAAc;GACxB;EACD,EAAC;CACH,QAAO;AACN,SAAO,qBAAqB;CAC7B;AACF;;;;;;AAOD,eAAsB,kCACpBA,QACkC;AAClC,QAAO,sCAAsC;EAC3C,0BAA0B,yBAAyB,OAAO,OAAO,GAAG;EACpE,cAAc,YAAY;GACxB,MAAM,CAAC,gBAAgB,YAAY,GAAG,MAAM,QAAQ,IAAI,CACtD,OAAO,QAAQ,EAAE,QAAQ,2BAA4B,EAAC,EACtD,SAAS,QAAQ,EAAE,UAAU,SAAU,EAAC,AACzC,EAAC;AACF,OAAI,YAAY,kBAAkB,KAChC,OAAM,IAAI,MAAM;AAElB,UAAO;IACL,eAAe,YAAY;IAC3B,sBAAsB,YAAY,eAAe;GAClD;EACF;EACD,qBAAqB,MAAM,qCAAqC,OAAO;CACxE,EAAC;AACH"}
@@ -1,4 +1,4 @@
1
- import { BatchValidationError, DEFAULT_VEGOID, InputListFailError, InvalidTickLimitsError, InvalidTokenIdParameterError, LEG_BITS, LEG_LIMITS, LEG_MASKS, LoanSlotExhaustedError, MaxRetriesExceededError, MissingPositionIdsError, NoLoanPositionsError, OracleRateLimitedError, PanopticError, PanopticValidationError, PositionSnapshotNotFoundError, ProviderLagError, STANDARD_TICK_WIDTHS, STRIKE_CONVERSION_FACTOR, SwapTokenMismatchError, SyncTimeoutError, TOKEN_ID_BITS, UnsafePremiumSettlementError, collateralTrackerV2Abi, createTxResult, decodeLeftRightUnsigned, decodeOracleTiming, decodePosition, decodeTickSpacing, formatTokenAmount, getBlockMeta, getOpenPositionIds, getPool, getPoolMetaKey, getPoolMetadata, getPositionMetaKey, getPositions, getPositionsKey, getSyncCheckpointKey, getTrackedPositionIds, jsonSerializer, oracleEpochAt, panopticErrorsAbi, panopticFactoryV3Abi, panopticFactoryV4Abi, panopticPoolV2Abi, parsePanopticError, parseTokenAmount, submitWrite } from "./rates-COAJpKRd.js";
1
+ import { BatchValidationError, DEFAULT_VEGOID, InputListFailError, InvalidTickLimitsError, InvalidTokenIdParameterError, LEG_BITS, LEG_LIMITS, LEG_MASKS, LoanSlotExhaustedError, MaxRetriesExceededError, MissingPositionIdsError, NoLoanPositionsError, OracleRateLimitedError, PanopticError, PanopticValidationError, PositionSnapshotNotFoundError, ProviderLagError, STANDARD_TICK_WIDTHS, STRIKE_CONVERSION_FACTOR, SwapTokenMismatchError, SyncTimeoutError, TOKEN_ID_BITS, UnsafePremiumSettlementError, collateralTrackerV2Abi, createTxResult, decodeLeftRightUnsigned, decodeOracleTiming, decodePosition, decodeTickSpacing, formatTokenAmount, getBlockMeta, getOpenPositionIds, getPool, getPoolMetaKey, getPoolMetadata, getPositionMetaKey, getPositions, getPositionsKey, getSyncCheckpointKey, getTrackedPositionIds, jsonSerializer, oracleEpochAt, panopticErrorsAbi, panopticFactoryV3Abi, panopticFactoryV4Abi, panopticPoolV2Abi, parsePanopticError, parseTokenAmount, submitWrite } from "./rates-CPHxWqpT.js";
2
2
  import { MAX_TICK, MIN_TICK, REORG_DEPTH, calculatePositionGreeks, priceToTick, roundToTickSpacing, sqrtPriceX96ToTick, tickLimits, tickToPrice, tickToPriceDecimalScaled, tickToSqrtPriceX96 } from "./greeks-CNi1-cnp.js";
3
3
  import { decodeFunctionResult, encodeFunctionData, erc20Abi, getAbiItem } from "viem";
4
4
 
@@ -5057,6 +5057,159 @@ async function unwrapWethAndWait(params) {
5057
5057
  return result.wait();
5058
5058
  }
5059
5059
 
5060
+ //#endregion
5061
+ //#region src/panoptic/v2/simulations/simulateDispatch.ts
5062
+ /**
5063
+ * Simulate a raw dispatch operation.
5064
+ *
5065
+ * Uses PanopticPool.multicall with getAssetsOf-dispatch-getAssetsOf pattern
5066
+ * to measure exact collateral asset movements.
5067
+ *
5068
+ * @param params - Simulation parameters
5069
+ * @returns Simulation result with dispatch data or error
5070
+ */
5071
+ async function simulateDispatch(params) {
5072
+ const { client, poolAddress, account, positionIdList, finalPositionIdList, positionSizes, tickAndSpreadLimits, usePremiaAsCollateral = false, builderCode = 0n, blockNumber, existingPositionIdList, measurePremia = false } = params;
5073
+ const targetBlockNumber = blockNumber ?? await client.getBlockNumber();
5074
+ const metaPromise = getBlockMeta({
5075
+ client,
5076
+ blockNumber: targetBlockNumber
5077
+ });
5078
+ try {
5079
+ const callData = encodeFunctionData({
5080
+ abi: panopticPoolV2Abi,
5081
+ functionName: "dispatch",
5082
+ args: [
5083
+ positionIdList,
5084
+ finalPositionIdList,
5085
+ positionSizes,
5086
+ tickAndSpreadLimits.map((t) => [
5087
+ Number(t[0]),
5088
+ Number(t[1]),
5089
+ Number(t[2])
5090
+ ]),
5091
+ usePremiaAsCollateral,
5092
+ builderCode
5093
+ ]
5094
+ });
5095
+ const preFullPositionsCallData = existingPositionIdList !== void 0 ? encodeFunctionData({
5096
+ abi: panopticPoolV2Abi,
5097
+ functionName: "getFullPositionsData",
5098
+ args: [
5099
+ account,
5100
+ false,
5101
+ existingPositionIdList
5102
+ ]
5103
+ }) : void 0;
5104
+ const prePremiaCallData = measurePremia && existingPositionIdList !== void 0 ? encodeFunctionData({
5105
+ abi: panopticPoolV2Abi,
5106
+ functionName: "getFullPositionsData",
5107
+ args: [
5108
+ account,
5109
+ true,
5110
+ existingPositionIdList
5111
+ ]
5112
+ }) : void 0;
5113
+ const postFullPositionsCallData = encodeFunctionData({
5114
+ abi: panopticPoolV2Abi,
5115
+ functionName: "getFullPositionsData",
5116
+ args: [
5117
+ account,
5118
+ false,
5119
+ finalPositionIdList
5120
+ ]
5121
+ });
5122
+ const postPremiaCallData = measurePremia ? encodeFunctionData({
5123
+ abi: panopticPoolV2Abi,
5124
+ functionName: "getFullPositionsData",
5125
+ args: [
5126
+ account,
5127
+ true,
5128
+ finalPositionIdList
5129
+ ]
5130
+ }) : void 0;
5131
+ const flowResult = await simulateWithTokenFlow({
5132
+ client,
5133
+ poolAddress,
5134
+ user: account,
5135
+ callData: params.settleSequence?.targets.length ? encodeFunctionData({
5136
+ abi: panopticPoolV2Abi,
5137
+ functionName: "multicall",
5138
+ args: [[...buildSettleSequenceCalls(params.settleSequence), callData]]
5139
+ }) : callData,
5140
+ blockNumber: targetBlockNumber,
5141
+ preCallData: preFullPositionsCallData ? [preFullPositionsCallData, ...prePremiaCallData ? [prePremiaCallData] : []] : void 0,
5142
+ postCallData: [postFullPositionsCallData, ...postPremiaCallData ? [postPremiaCallData] : []]
5143
+ });
5144
+ if (!flowResult.success || !flowResult.tokenFlow) throw flowResult.rawError ?? new PanopticError(flowResult.error || "Token flow simulation failed");
5145
+ const tokenFlow = flowResult.tokenFlow;
5146
+ const preSnapshot = existingPositionIdList ?? [];
5147
+ const positionsCreated = finalPositionIdList.filter((id) => !preSnapshot.includes(id));
5148
+ const positionsClosed = preSnapshot.filter((id) => !finalPositionIdList.includes(id));
5149
+ const decodeFullPositions = (data$1) => {
5150
+ if (!data$1) return null;
5151
+ try {
5152
+ const decoded = decodeFunctionResult({
5153
+ abi: panopticPoolV2Abi,
5154
+ functionName: "getFullPositionsData",
5155
+ data: data$1
5156
+ });
5157
+ const shortPremium = decodeLeftRightUnsigned(decoded[0]);
5158
+ const longPremium = decodeLeftRightUnsigned(decoded[1]);
5159
+ const reqs = decoded[3];
5160
+ let collateralRequirements0 = 0n;
5161
+ let collateralRequirements1 = 0n;
5162
+ for (const packed of reqs) {
5163
+ const r = decodeLeftRightUnsigned(packed);
5164
+ collateralRequirements0 += r.right;
5165
+ collateralRequirements1 += r.left;
5166
+ }
5167
+ return {
5168
+ collateralRequirements0,
5169
+ collateralRequirements1,
5170
+ netPremia0: shortPremium.right - longPremium.right,
5171
+ netPremia1: shortPremium.left - longPremium.left
5172
+ };
5173
+ } catch {
5174
+ return null;
5175
+ }
5176
+ };
5177
+ const prePositions = decodeFullPositions(flowResult.preCallResults?.[0]);
5178
+ const postPositions = decodeFullPositions(flowResult.postCallResults?.[0]);
5179
+ const prePremia = decodeFullPositions(flowResult.preCallResults?.[1]);
5180
+ const postPremia = decodeFullPositions(flowResult.postCallResults?.[1]);
5181
+ const _meta = await metaPromise;
5182
+ const data = {
5183
+ netAmount0: tokenFlow.delta0,
5184
+ netAmount1: tokenFlow.delta1,
5185
+ premiaReceived0: prePremia !== null && postPremia !== null ? prePremia.netPremia0 - postPremia.netPremia0 : null,
5186
+ premiaReceived1: prePremia !== null && postPremia !== null ? prePremia.netPremia1 - postPremia.netPremia1 : null,
5187
+ positionsCreated,
5188
+ positionsClosed,
5189
+ postCollateral0: tokenFlow.balanceAfter0,
5190
+ postCollateral1: tokenFlow.balanceAfter1,
5191
+ preMarginExcess0: prePositions === null ? null : tokenFlow.balanceBefore0 - prePositions.collateralRequirements0,
5192
+ preMarginExcess1: prePositions === null ? null : tokenFlow.balanceBefore1 - prePositions.collateralRequirements1,
5193
+ postMarginExcess0: postPositions === null ? null : tokenFlow.balanceAfter0 - postPositions.collateralRequirements0,
5194
+ postMarginExcess1: postPositions === null ? null : tokenFlow.balanceAfter1 - postPositions.collateralRequirements1
5195
+ };
5196
+ return {
5197
+ success: true,
5198
+ data,
5199
+ gasEstimate: flowResult.gasEstimate,
5200
+ tokenFlow,
5201
+ _meta
5202
+ };
5203
+ } catch (error) {
5204
+ const _meta = await metaPromise;
5205
+ return {
5206
+ success: false,
5207
+ error: error instanceof PanopticError ? error : new PanopticError(error instanceof Error ? error.message : "Simulation failed", error instanceof Error ? error : void 0),
5208
+ _meta
5209
+ };
5210
+ }
5211
+ }
5212
+
5060
5213
  //#endregion
5061
5214
  //#region src/panoptic/v2/simulations/simulateOpenPosition.ts
5062
5215
  /**
@@ -5651,6 +5804,62 @@ async function getLoanPositionsForToken(client, poolAddress, account, existingPo
5651
5804
  };
5652
5805
  });
5653
5806
  }
5807
+ async function buildRepayDispatch(params) {
5808
+ const { client, account, poolAddress, chainId, token, amount, slippageBps, existingPositionIds, builderCode = 0n } = params;
5809
+ if (amount <= 0n) throw new Error("Repayment amount must be positive");
5810
+ const pool = await getPool({
5811
+ client,
5812
+ poolAddress,
5813
+ chainId
5814
+ });
5815
+ const tokenIndex = resolveTokenIndex(token, pool.collateralTracker0.token, pool.collateralTracker1.token);
5816
+ const loans = await getLoanPositionsForToken(client, poolAddress, account, existingPositionIds, tokenIndex);
5817
+ if (loans.length === 0) throw new NoLoanPositionsError(token);
5818
+ const totalDebt = loans.reduce((sum, l) => sum + l.tokenAmount, 0n);
5819
+ const loanIds = loans.map((l) => l.tokenId);
5820
+ const remainder = totalDebt > amount ? totalDebt - amount : 0n;
5821
+ const { low: tickLimitLow, high: tickLimitHigh } = tickLimits(pool.currentTick, slippageBps);
5822
+ const ascendingLimits = [
5823
+ tickLimitLow,
5824
+ tickLimitHigh,
5825
+ 0n
5826
+ ];
5827
+ const nonLoanIds = existingPositionIds.filter((id) => !loanIds.includes(id));
5828
+ const opsPositionIds = [...loanIds];
5829
+ const opsSizes = loanIds.map(() => 0n);
5830
+ const opsLimits = loanIds.map(() => ascendingLimits);
5831
+ let finalPositionIdList;
5832
+ if (remainder > 0n) {
5833
+ const { tokenId: newLoanId, adjustedSize } = buildUniqueLoan(pool.poolId, tokenIndex, tokenIndex, pool.currentTick, pool.tickSpacing, nonLoanIds, remainder);
5834
+ opsPositionIds.push(newLoanId);
5835
+ opsSizes.push(adjustedSize);
5836
+ opsLimits.push(ascendingLimits);
5837
+ finalPositionIdList = [...nonLoanIds, newLoanId];
5838
+ } else finalPositionIdList = nonLoanIds;
5839
+ return {
5840
+ positionIdList: opsPositionIds,
5841
+ finalPositionIdList,
5842
+ positionSizes: opsSizes,
5843
+ tickAndSpreadLimits: opsLimits,
5844
+ usePremiaAsCollateral: false,
5845
+ builderCode
5846
+ };
5847
+ }
5848
+ /** Preview the same full or partial repayment dispatch used by smartRepay. */
5849
+ async function previewRepay(params) {
5850
+ const dispatch$1 = await buildRepayDispatch(params);
5851
+ const simulation = await simulateDispatch({
5852
+ client: params.client,
5853
+ account: params.account,
5854
+ poolAddress: params.poolAddress,
5855
+ existingPositionIdList: params.existingPositionIds,
5856
+ ...dispatch$1
5857
+ });
5858
+ return {
5859
+ dispatch: dispatch$1,
5860
+ simulation
5861
+ };
5862
+ }
5654
5863
  /**
5655
5864
  * Smart repay: burns all loan positions for a token and optionally re-opens a smaller one.
5656
5865
  *
@@ -5664,37 +5873,9 @@ async function getLoanPositionsForToken(client, poolAddress, account, existingPo
5664
5873
  * @returns TxResult
5665
5874
  */
5666
5875
  async function smartRepay(params) {
5667
- const { client, walletClient, account, poolAddress, chainId, token, amount, slippageBps, existingPositionIds, builderCode = 0n, txOverrides } = params;
5876
+ const { client, walletClient, account, poolAddress, txOverrides } = params;
5668
5877
  for (let attempt = 0; attempt < MAX_RETRIES; attempt++) {
5669
- const pool = await getPool({
5670
- client,
5671
- poolAddress,
5672
- chainId
5673
- });
5674
- const tokenIndex = resolveTokenIndex(token, pool.collateralTracker0.token, pool.collateralTracker1.token);
5675
- const loans = await getLoanPositionsForToken(client, poolAddress, account, existingPositionIds, tokenIndex);
5676
- if (loans.length === 0) throw new NoLoanPositionsError(token);
5677
- const totalDebt = loans.reduce((sum, l) => sum + l.tokenAmount, 0n);
5678
- const loanIds = loans.map((l) => l.tokenId);
5679
- const remainder = totalDebt > amount ? totalDebt - amount : 0n;
5680
- const { low: tickLimitLow, high: tickLimitHigh } = tickLimits(pool.currentTick, slippageBps);
5681
- const ascendingLimits = [
5682
- Number(tickLimitLow),
5683
- Number(tickLimitHigh),
5684
- 0
5685
- ];
5686
- const nonLoanIds = existingPositionIds.filter((id) => !loanIds.includes(id));
5687
- const opsPositionIds = [...loanIds];
5688
- const opsSizes = loanIds.map(() => 0n);
5689
- const opsLimits = loanIds.map(() => ascendingLimits);
5690
- let finalPositionIdList;
5691
- if (remainder > 0n) {
5692
- const { tokenId: newLoanId, adjustedSize } = buildUniqueLoan(pool.poolId, tokenIndex, tokenIndex, pool.currentTick, pool.tickSpacing, nonLoanIds, remainder);
5693
- opsPositionIds.push(newLoanId);
5694
- opsSizes.push(adjustedSize);
5695
- opsLimits.push(ascendingLimits);
5696
- finalPositionIdList = [...nonLoanIds, newLoanId];
5697
- } else finalPositionIdList = nonLoanIds;
5878
+ const intent = await buildRepayDispatch(params);
5698
5879
  try {
5699
5880
  return await submitWrite({
5700
5881
  client,
@@ -5704,12 +5885,12 @@ async function smartRepay(params) {
5704
5885
  abi: panopticPoolV2Abi,
5705
5886
  functionName: "dispatch",
5706
5887
  args: [
5707
- opsPositionIds,
5708
- finalPositionIdList,
5709
- opsSizes,
5710
- opsLimits,
5711
- false,
5712
- builderCode
5888
+ intent.positionIdList,
5889
+ intent.finalPositionIdList,
5890
+ intent.positionSizes,
5891
+ intent.tickAndSpreadLimits.map((limits) => limits.map(Number)),
5892
+ intent.usePremiaAsCollateral,
5893
+ intent.builderCode
5713
5894
  ],
5714
5895
  txOverrides
5715
5896
  });
@@ -5756,4 +5937,4 @@ async function smartRepayAndWait(params) {
5756
5937
  }
5757
5938
 
5758
5939
  //#endregion
5759
- export { addLegToTokenId, approve, approveAndWait, approvePool, borrow, borrowAndWait, buildBatchDispatchArgs, buildCreditSwapCall, buildOpenPositionCalldata, buildProtectedSettleDispatch, buildProtectedSettlePlan, buildSettleSequenceCalls, buildUniqueCredit, buildUniqueLoan, buildUniqueWidthZeroLeg, calculateResyncBlock, cancelTransaction, checkApproval, clearCheckpoint, closePosition, closePositionAndWait, countLegs, createNonceManager, createPoolFormatters, createTokenIdBuilder, decodeAllLegs, decodeLeg, decodePoolId, decodeTickSpacing$1, decodeTokenId, decodeVegoid, deployNewPool, deployNewPoolAndWait, deposit, depositAndWait, deriveUniqueTokenId, detectReorg, dispatch, dispatchAndWait, encodeLeg, encodePoolId, encodeV4PoolId, executeBatchDispatch, executeBatchDispatchAndWait, executeSettleSequence, executeSettleSequenceAndWait, forceExercise, forceExerciseAndWait, formatBlockNumber, formatBps, formatCompact, formatDatetime, formatDuration, formatDurationSeconds, formatFeeTier, formatGas, formatGwei, formatPoolIdHex, formatRatioPercent, formatTimestamp, formatTimestampLocale, formatTokenIdHex, formatTokenIdShort, formatTxHash, formatUtilization, formatWei, generateOverlappingTokenIds, getAccountPremia, getAssetIndex, getForfeitablePremium, getPoolDeploymentBlock, getPoolDisplayId, getPoolTokensForSimulation, getPositionsWithPremia, getSimpleLoanTokenIndex, getTokenListId, hasLoanOrCredit, hasLongLeg, isCredit, isCreditLeg, isInputListFailError, isLoan, isLoanLeg, isShortOnly, isSpread, liquidate, liquidateAndWait, loadCheckpoint, mint, mintAndWait, openPosition, openPositionAndWait, orderListForSettle, parseBps, parseTokenListId, planDeriveStrategy, pokeOracle, pokeOracleAndWait, previewBorrow, previewUnwrap, previewWrap, publicBroadcaster, reconstructFromEvents, redeem, redeemAndWait, repay, repayAndWait, resolveTokenIndex, rollPosition, rollPositionAndWait, saveCheckpoint, settleAccumulatedPremia, settleAccumulatedPremiaAndWait, settlePremiumFrom, settlePremiumFromAndWait, simulateOpenPosition, simulateSettle, simulateSettlePremiumBatch, simulateSettlePremiumFrom, simulateSettleSequence, simulateWithTokenFlow, smartRepay, smartRepayAndWait, speedUpTransaction, splitTokenIdByTimescale, supply, supplyAndWait, swapExactIn, swapExactInAndWait, swapExactOut, swapExactOutAndWait, syncPositions, truncateAddress, unsupply, unsupplyAndWait, unwrapWeth, unwrapWethAndWait, unwrapXstock, unwrapXstockAndWait, validateBatch, validatePoolId, verifyBlockContinuity, wethWrapAbi, withdraw, withdrawAndWait, withdrawWithPositions, withdrawWithPositionsAndWait, wrapEth, wrapEthAndWait, wrapXstock, wrapXstockAndWait, xstockWrapperAbi };
5940
+ export { addLegToTokenId, approve, approveAndWait, approvePool, borrow, borrowAndWait, buildBatchDispatchArgs, buildCreditSwapCall, buildOpenPositionCalldata, buildProtectedSettleDispatch, buildProtectedSettlePlan, buildSettleSequenceCalls, buildUniqueCredit, buildUniqueLoan, buildUniqueWidthZeroLeg, calculateResyncBlock, cancelTransaction, checkApproval, clearCheckpoint, closePosition, closePositionAndWait, countLegs, createNonceManager, createPoolFormatters, createTokenIdBuilder, decodeAllLegs, decodeLeg, decodePoolId, decodeTickSpacing$1, decodeTokenId, decodeVegoid, deployNewPool, deployNewPoolAndWait, deposit, depositAndWait, deriveUniqueTokenId, detectReorg, dispatch, dispatchAndWait, encodeLeg, encodePoolId, encodeV4PoolId, executeBatchDispatch, executeBatchDispatchAndWait, executeSettleSequence, executeSettleSequenceAndWait, forceExercise, forceExerciseAndWait, formatBlockNumber, formatBps, formatCompact, formatDatetime, formatDuration, formatDurationSeconds, formatFeeTier, formatGas, formatGwei, formatPoolIdHex, formatRatioPercent, formatTimestamp, formatTimestampLocale, formatTokenIdHex, formatTokenIdShort, formatTxHash, formatUtilization, formatWei, generateOverlappingTokenIds, getAccountPremia, getAssetIndex, getForfeitablePremium, getPoolDeploymentBlock, getPoolDisplayId, getPoolTokensForSimulation, getPositionsWithPremia, getSimpleLoanTokenIndex, getTokenListId, hasLoanOrCredit, hasLongLeg, isCredit, isCreditLeg, isInputListFailError, isLoan, isLoanLeg, isShortOnly, isSpread, liquidate, liquidateAndWait, loadCheckpoint, mint, mintAndWait, openPosition, openPositionAndWait, orderListForSettle, parseBps, parseTokenListId, planDeriveStrategy, pokeOracle, pokeOracleAndWait, previewBorrow, previewRepay, previewUnwrap, previewWrap, publicBroadcaster, reconstructFromEvents, redeem, redeemAndWait, repay, repayAndWait, resolveTokenIndex, rollPosition, rollPositionAndWait, saveCheckpoint, settleAccumulatedPremia, settleAccumulatedPremiaAndWait, settlePremiumFrom, settlePremiumFromAndWait, simulateDispatch, simulateOpenPosition, simulateSettle, simulateSettlePremiumBatch, simulateSettlePremiumFrom, simulateSettleSequence, simulateWithTokenFlow, smartRepay, smartRepayAndWait, speedUpTransaction, splitTokenIdByTimescale, supply, supplyAndWait, swapExactIn, swapExactInAndWait, swapExactOut, swapExactOutAndWait, syncPositions, truncateAddress, unsupply, unsupplyAndWait, unwrapWeth, unwrapWethAndWait, unwrapXstock, unwrapXstockAndWait, validateBatch, validatePoolId, verifyBlockContinuity, wethWrapAbi, withdraw, withdrawAndWait, withdrawWithPositions, withdrawWithPositionsAndWait, wrapEth, wrapEthAndWait, wrapXstock, wrapXstockAndWait, xstockWrapperAbi };