creation_sourcecode: {{
    "language": "Solidity",
    "sources": {
      "src/libraries/ReserveMath.sol": {
        "content": "// SPDX-License-Identifier: GPL-2.0-or-later\npragma solidity 0.8.19;\n\nimport { LiquidityAmounts } from '../../lib/v3-periphery/contracts/libraries/LiquidityAmounts.sol';\n\nimport { ISovereignPool } from '../../lib/valantis-core/src/pools/interfaces/ISovereignPool.sol';\n\nimport { TightPack } from '../libraries/utils/TightPack.sol';\nimport { AMMState } from '../structs/HOTStructs.sol';\n\nlibrary ReserveMath {\n    using TightPack for AMMState;\n\n    /**\n        @notice Returns the AMM reserves assuming some AMM spot price.\n        @param sqrtSpotPriceX96New square-root price to query AMM reserves for, in Q96 format.\n        @return reserve0 Reserves of token0 at `sqrtSpotPriceX96New`.\n        @return reserve1 Reserves of token1 at `sqrtSpotPriceX96New`.\n     */\n    function getReservesAtPrice(\n        AMMState storage _ammState,\n        address _pool,\n        uint128 _effectiveAMMLiquidity,\n        uint160 sqrtSpotPriceX96New\n    ) external view returns (uint256 reserve0, uint256 reserve1) {\n        (uint160 sqrtSpotPriceX96, uint160 sqrtPriceLowX96, uint160 sqrtPriceHighX96) = _ammState.getState();\n\n        (reserve0, reserve1) = ISovereignPool(_pool).getReserves();\n\n        uint128 effectiveAMMLiquidityCache = _effectiveAMMLiquidity;\n\n        (uint256 activeReserve0, uint256 activeReserve1) = LiquidityAmounts.getAmountsForLiquidity(\n            sqrtSpotPriceX96,\n            sqrtPriceLowX96,\n            sqrtPriceHighX96,\n            effectiveAMMLiquidityCache\n        );\n\n        uint256 passiveReserve0 = reserve0 - activeReserve0;\n        uint256 passiveReserve1 = reserve1 - activeReserve1;\n\n        (activeReserve0, activeReserve1) = LiquidityAmounts.getAmountsForLiquidity(\n            sqrtSpotPriceX96New,\n            sqrtPriceLowX96,\n            sqrtPriceHighX96,\n            effectiveAMMLiquidityCache\n        );\n\n        reserve0 = passiveReserve0 + activeReserve0;\n        reserve1 = passiveReserve1 + activeReserve1;\n    }\n}\n"
      },
      "lib/v3-periphery/contracts/libraries/LiquidityAmounts.sol": {
        "content": "// SPDX-License-Identifier: GPL-2.0-or-later\npragma solidity >=0.5.0;\n\nimport '@uniswap/v3-core/contracts/libraries/FullMath.sol';\nimport '@uniswap/v3-core/contracts/libraries/FixedPoint96.sol';\n\n/// @title Liquidity amount functions\n/// @notice Provides functions for computing liquidity amounts from token amounts and prices\nlibrary LiquidityAmounts {\n    /// @notice Downcasts uint256 to uint128\n    /// @param x The uint258 to be downcasted\n    /// @return y The passed value, downcasted to uint128\n    function toUint128(uint256 x) private pure returns (uint128 y) {\n        require((y = uint128(x)) == x);\n    }\n\n    /// @notice Computes the amount of liquidity received for a given amount of token0 and price range\n    /// @dev Calculates amount0 * (sqrt(upper) * sqrt(lower)) / (sqrt(upper) - sqrt(lower))\n    /// @param sqrtRatioAX96 A sqrt price representing the first tick boundary\n    /// @param sqrtRatioBX96 A sqrt price representing the second tick boundary\n    /// @param amount0 The amount0 being sent in\n    /// @return liquidity The amount of returned liquidity\n    function getLiquidityForAmount0(\n        uint160 sqrtRatioAX96,\n        uint160 sqrtRatioBX96,\n        uint256 amount0\n    ) internal pure returns (uint128 liquidity) {\n        if (sqrtRatioAX96 > sqrtRatioBX96) (sqrtRatioAX96, sqrtRatioBX96) = (sqrtRatioBX96, sqrtRatioAX96);\n        uint256 intermediate = FullMath.mulDiv(sqrtRatioAX96, sqrtRatioBX96, FixedPoint96.Q96);\n        unchecked {\n            return toUint128(FullMath.mulDiv(amount0, intermediate, sqrtRatioBX96 - sqrtRatioAX96));\n        }\n    }\n\n    /// @notice Computes the amount of liquidity received for a given amount of token1 and price range\n    /// @dev Calculates amount1 / (sqrt(upper) - sqrt(lower)).\n    /// @param sqrtRatioAX96 A sqrt price representing the first tick boundary\n    /// @param sqrtRatioBX96 A sqrt price representing the second tick boundary\n    /// @param amount1 The amount1 being sent in\n    /// @return liquidity The amount of returned liquidity\n    function getLiquidityForAmount1(\n        uint160 sqrtRatioAX96,\n        uint160 sqrtRatioBX96,\n        uint256 amount1\n    ) internal pure returns (uint128 liquidity) {\n        if (sqrtRatioAX96 > sqrtRatioBX96) (sqrtRatioAX96, sqrtRatioBX96) = (sqrtRatioBX96, sqrtRatioAX96);\n        unchecked {\n            return toUint128(FullMath.mulDiv(amount1, FixedPoint96.Q96, sqrtRatioBX96 - sqrtRatioAX96));\n        }\n    }\n\n    /// @notice Computes the maximum amount of liquidity received for a given amount of token0, token1, the current\n    /// pool prices and the prices at the tick boundaries\n    /// @param sqrtRatioX96 A sqrt price representing the current pool prices\n    /// @param sqrtRatioAX96 A sqrt price representing the first tick boundary\n    /// @param sqrtRatioBX96 A sqrt price representing the second tick boundary\n    /// @param amount0 The amount of token0 being sent in\n    /// @param amount1 The amount of token1 being sent in\n    /// @return liquidity The maximum amount of liquidity received\n    function getLiquidityForAmounts(\n        uint160 sqrtRatioX96,\n        uint160 sqrtRatioAX96,\n        uint160 sqrtRatioBX96,\n        uint256 amount0,\n        uint256 amount1\n    ) internal pure returns (uint128 liquidity) {\n        if (sqrtRatioAX96 > sqrtRatioBX96) (sqrtRatioAX96, sqrtRatioBX96) = (sqrtRatioBX96, sqrtRatioAX96);\n\n        if (sqrtRatioX96 <= sqrtRatioAX96) {\n            liquidity = getLiquidityForAmount0(sqrtRatioAX96, sqrtRatioBX96, amount0);\n        } else if (sqrtRatioX96 < sqrtRatioBX96) {\n            uint128 liquidity0 = getLiquidityForAmount0(sqrtRatioX96, sqrtRatioBX96, amount0);\n            uint128 liquidity1 = getLiquidityForAmount1(sqrtRatioAX96, sqrtRatioX96, amount1);\n\n            liquidity = liquidity0 < liquidity1 ? liquidity0 : liquidity1;\n        } else {\n            liquidity = getLiquidityForAmount1(sqrtRatioAX96, sqrtRatioBX96, amount1);\n        }\n    }\n\n    /// @notice Computes the amount of token0 for a given amount of liquidity and a price range\n    /// @param sqrtRatioAX96 A sqrt price representing the first tick boundary\n    /// @param sqrtRatioBX96 A sqrt price representing the second tick boundary\n    /// @param liquidity The liquidity being valued\n    /// @return amount0 The amount of token0\n    function getAmount0ForLiquidity(\n        uint160 sqrtRatioAX96,\n        uint160 sqrtRatioBX96,\n        uint128 liquidity\n    ) internal pure returns (uint256 amount0) {\n        unchecked {\n            if (sqrtRatioAX96 > sqrtRatioBX96) (sqrtRatioAX96, sqrtRatioBX96) = (sqrtRatioBX96, sqrtRatioAX96);\n\n            return\n                FullMath.mulDiv(\n                    uint256(liquidity) << FixedPoint96.RESOLUTION,\n                    sqrtRatioBX96 - sqrtRatioAX96,\n                    sqrtRatioBX96\n                ) / sqrtRatioAX96;\n        }\n    }\n\n    /// @notice Computes the amount of token1 for a given amount of liquidity and a price range\n    /// @param sqrtRatioAX96 A sqrt price representing the first tick boundary\n    /// @param sqrtRatioBX96 A sqrt price representing the second tick boundary\n    /// @param liquidity The liquidity being valued\n    /// @return amount1 The amount of token1\n    function getAmount1ForLiquidity(\n        uint160 sqrtRatioAX96,\n        uint160 sqrtRatioBX96,\n        uint128 liquidity\n    ) internal pure returns (uint256 amount1) {\n        if (sqrtRatioAX96 > sqrtRatioBX96) (sqrtRatioAX96, sqrtRatioBX96) = (sqrtRatioBX96, sqrtRatioAX96);\n\n        unchecked {\n            return FullMath.mulDiv(liquidity, sqrtRatioBX96 - sqrtRatioAX96, FixedPoint96.Q96);\n        }\n    }\n\n    /// @notice Computes the token0 and token1 value for a given amount of liquidity, the current\n    /// pool prices and the prices at the tick boundaries\n    /// @param sqrtRatioX96 A sqrt price representing the current pool prices\n    /// @param sqrtRatioAX96 A sqrt price representing the first tick boundary\n    /// @param sqrtRatioBX96 A sqrt price representing the second tick boundary\n    /// @param liquidity The liquidity being valued\n    /// @return amount0 The amount of token0\n    /// @return amount1 The amount of token1\n    function getAmountsForLiquidity(\n        uint160 sqrtRatioX96,\n        uint160 sqrtRatioAX96,\n        uint160 sqrtRatioBX96,\n        uint128 liquidity\n    ) internal pure returns (uint256 amount0, uint256 amount1) {\n        if (sqrtRatioAX96 > sqrtRatioBX96) (sqrtRatioAX96, sqrtRatioBX96) = (sqrtRatioBX96, sqrtRatioAX96);\n\n        if (sqrtRatioX96 <= sqrtRatioAX96) {\n            amount0 = getAmount0ForLiquidity(sqrtRatioAX96, sqrtRatioBX96, liquidity);\n        } else if (sqrtRatioX96 < sqrtRatioBX96) {\n            amount0 = getAmount0ForLiquidity(sqrtRatioX96, sqrtRatioBX96, liquidity);\n            amount1 = getAmount1ForLiquidity(sqrtRatioAX96, sqrtRatioX96, liquidity);\n        } else {\n            amount1 = getAmount1ForLiquidity(sqrtRatioAX96, sqrtRatioBX96, liquidity);\n        }\n    }\n}\n"
      },
      "lib/valantis-core/src/pools/interfaces/ISovereignPool.sol": {
        "content": "// SPDX-License-Identifier: MIT\npragma solidity 0.8.19;\n\nimport { IValantisPool } from '../interfaces/IValantisPool.sol';\nimport { PoolLocks } from '../structs/ReentrancyGuardStructs.sol';\nimport { SovereignPoolSwapContextData, SovereignPoolSwapParams } from '../structs/SovereignPoolStructs.sol';\n\ninterface ISovereignPool is IValantisPool {\n    event SwapFeeModuleSet(address swapFeeModule);\n    event ALMSet(address alm);\n    event GaugeSet(address gauge);\n    event PoolManagerSet(address poolManager);\n    event PoolManagerFeeSet(uint256 poolManagerFeeBips);\n    event SovereignOracleSet(address sovereignOracle);\n    event PoolManagerFeesClaimed(uint256 amount0, uint256 amount1);\n    event DepositLiquidity(uint256 amount0, uint256 amount1);\n    event WithdrawLiquidity(address indexed recipient, uint256 amount0, uint256 amount1);\n    event Swap(address indexed sender, bool isZeroToOne, uint256 amountIn, uint256 fee, uint256 amountOut);\n\n    function getTokens() external view returns (address[] memory tokens);\n\n    function sovereignVault() external view returns (address);\n\n    function protocolFactory() external view returns (address);\n\n    function gauge() external view returns (address);\n\n    function poolManager() external view returns (address);\n\n    function sovereignOracleModule() external view returns (address);\n\n    function swapFeeModule() external view returns (address);\n\n    function verifierModule() external view returns (address);\n\n    function isLocked() external view returns (bool);\n\n    function isRebaseTokenPool() external view returns (bool);\n\n    function poolManagerFeeBips() external view returns (uint256);\n\n    function defaultSwapFeeBips() external view returns (uint256);\n\n    function swapFeeModuleUpdateTimestamp() external view returns (uint256);\n\n    function alm() external view returns (address);\n\n    function getPoolManagerFees() external view returns (uint256 poolManagerFee0, uint256 poolManagerFee1);\n\n    function getReserves() external view returns (uint256 reserve0, uint256 reserve1);\n\n    function setPoolManager(address _manager) external;\n\n    function setGauge(address _gauge) external;\n\n    function setPoolManagerFeeBips(uint256 _poolManagerFeeBips) external;\n\n    function setSovereignOracle(address sovereignOracle) external;\n\n    function setSwapFeeModule(address _swapFeeModule) external;\n\n    function setALM(address _alm) external;\n\n    function swap(SovereignPoolSwapParams calldata _swapParams) external returns (uint256, uint256);\n\n    function depositLiquidity(\n        uint256 _amount0,\n        uint256 _amount1,\n        address _sender,\n        bytes calldata _verificationContext,\n        bytes calldata _depositData\n    ) external returns (uint256 amount0Deposited, uint256 amount1Deposited);\n\n    function withdrawLiquidity(\n        uint256 _amount0,\n        uint256 _amount1,\n        address _sender,\n        address _recipient,\n        bytes calldata _verificationContext\n    ) external;\n}\n"
      },
      "src/libraries/utils/TightPack.sol": {
        "content": "// SPDX-License-Identifier: GPL-2.0-or-later\npragma solidity 0.8.19;\n\nimport { AMMState } from '../../structs/HOTStructs.sol';\n\n/**\n    @notice Helper library for tight packing multiple uint160 values into minimum amount of uint256 slots.\n */\nlibrary TightPack {\n    uint256 constant LOWER_160_MASK = 0x000000000000000000000000ffffffffffffffffffffffffffffffffffffffff;\n    uint256 constant UPPER_96_MASK = 0xffffffffffffffffffffffff0000000000000000000000000000000000000000;\n\n    /************************************************\n     *  FUNCTIONS\n     ***********************************************/\n\n    /**\n        @notice Packs 3 uint160 values into 2 uint256 slots.\n        @param a uint160 value to pack into slot1.\n        @param b uint160 value to pack into slot1 and slot2.\n        @param c uint160 value to pack into slot2.\n        @dev slot1: << 32 free bits | upper 64 bits of b | all 160 bits of a >>\n             slot2: << lower 96 bits of b | all 160 bits of c >>\n     */\n    function setState(AMMState storage state, uint160 a, uint160 b, uint160 c) internal {\n        uint256 slot1;\n        uint256 slot2;\n        assembly {\n            slot1 := or(shl(160, shr(96, b)), a)\n            slot2 := or(shl(160, b), c)\n        }\n\n        state.slot1 = slot1;\n        state.slot2 = slot2;\n    }\n\n    /**\n        @notice Unpacks 2 uint256 slots into 3 uint160 values.\n        @param state AMMState struct containing slot1 and slot2.\n        @return a uint160 value unpacked from slot1.\n        @return b uint160 value unpacked from slot1 and slot2.\n        @return c uint160 value unpacked from slot2.\n        @dev slot1: << 32 empty bits | upper 64 bits of b | all 160 bits of a >>\n             slot2: << lower 96 bits of b | all 160 bits of c >>\n     */\n    function getState(AMMState storage state) internal view returns (uint160 a, uint160 b, uint160 c) {\n        uint256 slot1 = state.slot1;\n        uint256 slot2 = state.slot2;\n\n        assembly {\n            a := and(slot1, LOWER_160_MASK)\n            c := and(slot2, LOWER_160_MASK)\n            b := or(shl(96, shr(160, slot1)), shr(160, slot2))\n        }\n    }\n\n    function getSqrtSpotPriceX96(AMMState storage state) internal view returns (uint160 a) {\n        uint256 slot1 = state.slot1;\n        assembly {\n            a := and(slot1, LOWER_160_MASK)\n        }\n    }\n\n    function setSqrtSpotPriceX96(AMMState storage state, uint160 a) internal {\n        uint256 slot1 = state.slot1;\n        assembly {\n            slot1 := or(and(slot1, UPPER_96_MASK), a)\n        }\n        state.slot1 = slot1;\n    }\n}\n"
      },
      "src/structs/HOTStructs.sol": {
        "content": "// SPDX-License-Identifier: GPL-2.0-or-later\npragma solidity 0.8.19;\n\n/**\n    @notice The struct with all the information for a HOT swap. \n\n    This struct is signed by `signer`, and put onchain via HOT swaps.\n\n    * amountInMax: Maximum amount of input token which `authorizedSender` is allowed to swap.\n    * sqrtHotPriceX96Discounted: sqrtPriceX96 to quote if the HOT is eligible to update AMM state (see HOT).\n    * sqrtHotPriceX96Base: sqrtPriceX96 to quote if the HOT isn't eligible to update AMM (can be same as above).\n    * sqrtSpotPriceX96New: New sqrt spot price of the AMM, in Q96 format.\n    * authorizedSender: Address of authorized msg.sender in `pool`.\n    * authorizedRecipient: Address of authorized recipient of tokenOut amounts.\n    * signatureTimestamp: Offchain UNIX timestamp that determines when this HOT intent has been signed.\n    * expiry: Duration, in seconds, for the validity of this HOT intent.\n    * feeMinToken0: Minimum AMM swap fee for token0.\n    * feeMaxToken0: Maximum AMM swap fee for token0.\n    * feeGrowthE6Token0: Fee growth in pips, per second, of AMM swap fee for token0.\n    * feeMinToken1: Minimum AMM swap fee for token1.\n    * feeMaxToken1: Maximum AMM swap fee for token1.\n    * feeGrowthE6Token1: Fee growth in pips, per second, of AMM swap fee for token1.\n    * nonce: Nonce in bitmap format (see AlternatingNonceBitmap library and docs).\n    * expectedFlag: Expected flag (0 or 1) for nonce (see AlternatingNonceBitmap library and docs).\n    * isZeroToOne: Direction of the swap for which the HOT is valid.\n */\nstruct HybridOrderType {\n    uint256 amountInMax;\n    uint160 sqrtHotPriceX96Discounted;\n    uint160 sqrtHotPriceX96Base;\n    uint160 sqrtSpotPriceX96New;\n    address authorizedSender;\n    address authorizedRecipient;\n    uint32 signatureTimestamp;\n    uint32 expiry;\n    uint16 feeMinToken0;\n    uint16 feeMaxToken0;\n    uint16 feeGrowthE6Token0;\n    uint16 feeMinToken1;\n    uint16 feeMaxToken1;\n    uint16 feeGrowthE6Token1;\n    uint8 nonce;\n    uint8 expectedFlag;\n    bool isZeroToOne;\n}\n\n/**\n    @notice Packed struct containing state variables which get updated on HOT swaps.\n\n    * lastProcessedBlockQuoteCount: Number of HOT swaps processed in the last block.\n    * feeGrowthE6Token0: Fee growth in pips, per second, of AMM swap fee for token0.\n    * feeMaxToken0: Maximum AMM swap fee for token0.\n    * feeMinToken0: Minimum AMM swap fee for token0.\n    * feeGrowthE6Token1: Fee growth in pips, per second, of AMM swap fee for token1.\n    * feeMaxToken1: Maximum AMM swap fee for token1.\n    * feeMinToken1: Minimum AMM swap fee for token1.\n    * lastStateUpdateTimestamp: Block timestamp of the last AMM state update from an HOT swap.\n    * lastProcessedQuoteTimestamp: Block timestamp of the last processed HOT swap (not all HOT swaps update AMM state).\n    * lastProcessedSignatureTimestamp: Signature timestamp of the last HOT swap which has been successfully processed.\n    * alternatingNonceBitmap: Nonce bitmap (see AlternatingNonceBitmap library and docs).\n */\nstruct HotWriteSlot {\n    uint8 lastProcessedBlockQuoteCount;\n    uint16 feeGrowthE6Token0;\n    uint16 feeMaxToken0;\n    uint16 feeMinToken0;\n    uint16 feeGrowthE6Token1;\n    uint16 feeMaxToken1;\n    uint16 feeMinToken1;\n    uint32 lastStateUpdateTimestamp;\n    uint32 lastProcessedQuoteTimestamp;\n    uint32 lastProcessedSignatureTimestamp;\n    uint56 alternatingNonceBitmap;\n}\n\n/**\n    @notice Contains read-only variables required during execution of an HOT swap.\n    * isPaused: Indicates whether the contract is paused or not.     \n    * maxAllowedQuotes: Maximum number of quotes that can be processed in a single block.\n    * maxOracleDeviationBipsLower: Maximum deviation in bips allowed when, sqrtSpotPrice < sqrtOraclePrice\n    * maxOracleDeviationBipsUpper: Maximum deviation in bips allowed when, sqrtSpotPrice >= sqrtOraclePrice\n    * hotFeeBipsToken0: Fee in basis points for all subsequent hot for token0.\n    * hotFeeBipsToken1: Fee in basis points for all subsequent hot for token1.\n    * signer: Address of the signer of the HOT.\n */\nstruct HotReadSlot {\n    bool isPaused;\n    uint8 maxAllowedQuotes;\n    uint16 maxOracleDeviationBipsLower;\n    uint16 maxOracleDeviationBipsUpper;\n    uint16 hotFeeBipsToken0;\n    uint16 hotFeeBipsToken1;\n    address signer;\n}\n\n/**\n    @notice Contains all the arguments passed to the constructor of the HOT.\n */\nstruct HOTConstructorArgs {\n    address pool;\n    address manager;\n    address signer;\n    address liquidityProvider;\n    address feedToken0;\n    address feedToken1;\n    uint160 sqrtSpotPriceX96;\n    uint160 sqrtPriceLowX96;\n    uint160 sqrtPriceHighX96;\n    uint32 maxDelay;\n    uint32 maxOracleUpdateDurationFeed0;\n    uint32 maxOracleUpdateDurationFeed1;\n    uint16 hotMaxDiscountBipsLower;\n    uint16 hotMaxDiscountBipsUpper;\n    uint16 maxOracleDeviationBound;\n    uint16 minAMMFeeGrowthE6;\n    uint16 maxAMMFeeGrowthE6;\n    uint16 minAMMFee;\n}\n\n/**\n    @notice Packed struct that contains all variables relevant to the state of the AMM.\n    \n    * a: sqrtSpotPriceX96\n    * b: sqrtPriceLowX96\n    * c: sqrtPriceHighX96\n        \n    This arrangement saves 1 storage slot by packing the variables at the bit level.\n    \n    @dev Should never be used directly without the help of the TightPack library.\n\n    @dev slot1: << 32 free bits | upper 64 bits of b | all 160 bits of a >>\n         slot2: << lower 96 bits of b | all 160 bits of c >>\n */\nstruct AMMState {\n    uint256 slot1;\n    uint256 slot2;\n}\n"
      },
      "lib/v3-core/contracts/libraries/FullMath.sol": {
        "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\n/// @title Contains 512-bit math functions\n/// @notice Facilitates multiplication and division that can have overflow of an intermediate value without any loss of precision\n/// @dev Handles \"phantom overflow\" i.e., allows multiplication and division where an intermediate value overflows 256 bits\nlibrary FullMath {\n    /// @notice Calculates floor(a×b÷denominator) with full precision. Throws if result overflows a uint256 or denominator == 0\n    /// @param a The multiplicand\n    /// @param b The multiplier\n    /// @param denominator The divisor\n    /// @return result The 256-bit result\n    /// @dev Credit to Remco Bloemen under MIT license https://xn--2-umb.com/21/muldiv\n    function mulDiv(\n        uint256 a,\n        uint256 b,\n        uint256 denominator\n    ) internal pure returns (uint256 result) {\n        unchecked {\n            // 512-bit multiply [prod1 prod0] = a * b\n            // Compute the product mod 2**256 and mod 2**256 - 1\n            // then use the Chinese Remainder Theorem to reconstruct\n            // the 512 bit result. The result is stored in two 256\n            // variables such that product = prod1 * 2**256 + prod0\n            uint256 prod0; // Least significant 256 bits of the product\n            uint256 prod1; // Most significant 256 bits of the product\n            assembly {\n                let mm := mulmod(a, b, not(0))\n                prod0 := mul(a, b)\n                prod1 := sub(sub(mm, prod0), lt(mm, prod0))\n            }\n\n            // Handle non-overflow cases, 256 by 256 division\n            if (prod1 == 0) {\n                require(denominator > 0);\n                assembly {\n                    result := div(prod0, denominator)\n                }\n                return result;\n            }\n\n            // Make sure the result is less than 2**256.\n            // Also prevents denominator == 0\n            require(denominator > prod1);\n\n            ///////////////////////////////////////////////\n            // 512 by 256 division.\n            ///////////////////////////////////////////////\n\n            // Make division exact by subtracting the remainder from [prod1 prod0]\n            // Compute remainder using mulmod\n            uint256 remainder;\n            assembly {\n                remainder := mulmod(a, b, denominator)\n            }\n            // Subtract 256 bit number from 512 bit number\n            assembly {\n                prod1 := sub(prod1, gt(remainder, prod0))\n                prod0 := sub(prod0, remainder)\n            }\n\n            // Factor powers of two out of denominator\n            // Compute largest power of two divisor of denominator.\n            // Always >= 1.\n            uint256 twos = (0 - denominator) & denominator;\n            // Divide denominator by power of two\n            assembly {\n                denominator := div(denominator, twos)\n            }\n\n            // Divide [prod1 prod0] by the factors of two\n            assembly {\n                prod0 := div(prod0, twos)\n            }\n            // Shift in bits from prod1 into prod0. For this we need\n            // to flip `twos` such that it is 2**256 / twos.\n            // If twos is zero, then it becomes one\n            assembly {\n                twos := add(div(sub(0, twos), twos), 1)\n            }\n            prod0 |= prod1 * twos;\n\n            // Invert denominator mod 2**256\n            // Now that denominator is an odd number, it has an inverse\n            // modulo 2**256 such that denominator * inv = 1 mod 2**256.\n            // Compute the inverse by starting with a seed that is correct\n            // correct for four bits. That is, denominator * inv = 1 mod 2**4\n            uint256 inv = (3 * denominator) ^ 2;\n            // Now use Newton-Raphson iteration to improve the precision.\n            // Thanks to Hensel's lifting lemma, this also works in modular\n            // arithmetic, doubling the correct bits in each step.\n            inv *= 2 - denominator * inv; // inverse mod 2**8\n            inv *= 2 - denominator * inv; // inverse mod 2**16\n            inv *= 2 - denominator * inv; // inverse mod 2**32\n            inv *= 2 - denominator * inv; // inverse mod 2**64\n            inv *= 2 - denominator * inv; // inverse mod 2**128\n            inv *= 2 - denominator * inv; // inverse mod 2**256\n\n            // Because the division is now exact we can divide by multiplying\n            // with the modular inverse of denominator. This will give us the\n            // correct result modulo 2**256. Since the precoditions guarantee\n            // that the outcome is less than 2**256, this is the final result.\n            // We don't need to compute the high bits of the result and prod1\n            // is no longer required.\n            result = prod0 * inv;\n            return result;\n        }\n    }\n\n    /// @notice Calculates ceil(a×b÷denominator) with full precision. Throws if result overflows a uint256 or denominator == 0\n    /// @param a The multiplicand\n    /// @param b The multiplier\n    /// @param denominator The divisor\n    /// @return result The 256-bit result\n    function mulDivRoundingUp(\n        uint256 a,\n        uint256 b,\n        uint256 denominator\n    ) internal pure returns (uint256 result) {\n        unchecked {\n            result = mulDiv(a, b, denominator);\n            if (mulmod(a, b, denominator) > 0) {\n                require(result < type(uint256).max);\n                result++;\n            }\n        }\n    }\n}\n"
      },
      "lib/v3-core/contracts/libraries/FixedPoint96.sol": {
        "content": "// SPDX-License-Identifier: GPL-2.0-or-later\npragma solidity >=0.4.0;\n\n/// @title FixedPoint96\n/// @notice A library for handling binary fixed point numbers, see https://en.wikipedia.org/wiki/Q_(number_format)\n/// @dev Used in SqrtPriceMath.sol\nlibrary FixedPoint96 {\n    uint8 internal constant RESOLUTION = 96;\n    uint256 internal constant Q96 = 0x1000000000000000000000000;\n}\n"
      },
      "lib/valantis-core/src/pools/interfaces/IValantisPool.sol": {
        "content": "// SPDX-License-Identifier: MIT\npragma solidity 0.8.19;\n\nimport { IFlashBorrower } from './IFlashBorrower.sol';\n\ninterface IValantisPool {\n    /************************************************\n     *  EVENTS\n     ***********************************************/\n\n    event Flashloan(address indexed initiator, address indexed receiver, uint256 amount, address token);\n\n    /************************************************\n     *  ERRORS\n     ***********************************************/\n\n    error ValantisPool__flashloan_callbackFailed();\n    error ValantisPool__flashLoan_flashLoanDisabled();\n    error ValantisPool__flashLoan_flashLoanNotRepaid();\n    error ValantisPool__flashLoan_rebaseTokenNotAllowed();\n\n    /************************************************\n     *  VIEW FUNCTIONS\n     ***********************************************/\n\n    /**\n        @notice Address of ERC20 token0 of the pool.\n     */\n    function token0() external view returns (address);\n\n    /**\n        @notice Address of ERC20 token1 of the pool.\n     */\n    function token1() external view returns (address);\n\n    /************************************************\n     *  EXTERNAL FUNCTIONS\n     ***********************************************/\n\n    /**\n        @notice Claim share of protocol fees accrued by this pool.\n        @dev Can only be claimed by `gauge` of the pool. \n     */\n    function claimProtocolFees() external returns (uint256, uint256);\n\n    /**\n        @notice Claim share of fees accrued by this pool\n                And optionally share some with the protocol.\n        @dev Only callable by `poolManager`.\n        @param _feeProtocol0Bips Percent of `token0` fees to be shared with protocol.\n        @param _feeProtocol1Bips Percent of `token1` fees to be shared with protocol.\n     */\n    function claimPoolManagerFees(\n        uint256 _feeProtocol0Bips,\n        uint256 _feeProtocol1Bips\n    ) external returns (uint256 feePoolManager0Received, uint256 feePoolManager1Received);\n\n    /**\n        @notice Sets the gauge contract address for the pool.\n        @dev Only callable by `protocolFactory`.\n        @dev Once a gauge is set it cannot be changed again.\n        @param _gauge address of the gauge.\n     */\n    function setGauge(address _gauge) external;\n\n    /**\n        @notice Allows anyone to flash loan any amount of tokens from the pool.\n        @param _isTokenZero True if token0 is being flash loaned, False otherwise.\n        @param _receiver Address of the flash loan receiver.\n        @param _amount Amount of tokens to be flash loaned.\n        @param _data Bytes encoded data for flash loan callback.\n     */\n    function flashLoan(bool _isTokenZero, IFlashBorrower _receiver, uint256 _amount, bytes calldata _data) external;\n}\n"
      },
      "lib/valantis-core/src/pools/structs/ReentrancyGuardStructs.sol": {
        "content": "// SPDX-License-Identifier: MIT\npragma solidity 0.8.19;\n\nenum Lock {\n    WITHDRAWAL,\n    DEPOSIT,\n    SWAP,\n    SPOT_PRICE_TICK\n}\n\nstruct PoolLocks {\n    /**\n        @notice Locks all functions that require any withdrawal of funds from the pool\n                This involves the following functions -\n                * withdrawLiquidity\n                * claimProtocolFees\n                * claimPoolManagerFees\n     */\n    uint8 withdrawals;\n    /**\n        @notice Only locks the deposit function\n    */\n    uint8 deposit;\n    /**\n        @notice Only locks the swap function\n    */\n    uint8 swap;\n    /**\n        @notice Only locks the spotPriceTick function\n    */\n    uint8 spotPriceTick;\n}\n"
      },
      "lib/valantis-core/src/pools/structs/SovereignPoolStructs.sol": {
        "content": "// SPDX-License-Identifier: MIT\npragma solidity 0.8.19;\n\nimport { IERC20 } from '../../../lib/openzeppelin-contracts/contracts/token/ERC20/IERC20.sol';\n\nimport { ISwapFeeModule } from '../../swap-fee-modules/interfaces/ISwapFeeModule.sol';\n\nstruct SovereignPoolConstructorArgs {\n    address token0;\n    address token1;\n    address protocolFactory;\n    address poolManager;\n    address sovereignVault;\n    address verifierModule;\n    bool isToken0Rebase;\n    bool isToken1Rebase;\n    uint256 token0AbsErrorTolerance;\n    uint256 token1AbsErrorTolerance;\n    uint256 defaultSwapFeeBips;\n}\n\nstruct SovereignPoolSwapContextData {\n    bytes externalContext;\n    bytes verifierContext;\n    bytes swapCallbackContext;\n    bytes swapFeeModuleContext;\n}\n\nstruct SwapCache {\n    ISwapFeeModule swapFeeModule;\n    IERC20 tokenInPool;\n    IERC20 tokenOutPool;\n    uint256 amountInWithoutFee;\n}\n\nstruct SovereignPoolSwapParams {\n    bool isSwapCallback;\n    bool isZeroToOne;\n    uint256 amountIn;\n    uint256 amountOutMin;\n    uint256 deadline;\n    address recipient;\n    address swapTokenOut;\n    SovereignPoolSwapContextData swapContext;\n}\n"
      },
      "lib/valantis-core/src/pools/interfaces/IFlashBorrower.sol": {
        "content": "// SPDX-License-Identifier: MIT\n\npragma solidity 0.8.19;\n\ninterface IFlashBorrower {\n    /**\n        @dev Receive a flash loan.\n        @param initiator The initiator of the loan.\n        @param token The loan currency.\n        @param amount The amount of tokens lent.\n        @param data Arbitrary data structure, intended to contain user-defined parameters.\n        @return The keccak256 hash of \"ERC3156FlashBorrower.onFlashLoan\"\n     */\n    function onFlashLoan(\n        address initiator,\n        address token,\n        uint256 amount,\n        bytes calldata data\n    ) external returns (bytes32);\n}\n"
      },
      "lib/valantis-core/lib/openzeppelin-contracts/contracts/token/ERC20/IERC20.sol": {
        "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.9.0) (token/ERC20/IERC20.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Interface of the ERC20 standard as defined in the EIP.\n */\ninterface IERC20 {\n    /**\n     * @dev Emitted when `value` tokens are moved from one account (`from`) to\n     * another (`to`).\n     *\n     * Note that `value` may be zero.\n     */\n    event Transfer(address indexed from, address indexed to, uint256 value);\n\n    /**\n     * @dev Emitted when the allowance of a `spender` for an `owner` is set by\n     * a call to {approve}. `value` is the new allowance.\n     */\n    event Approval(address indexed owner, address indexed spender, uint256 value);\n\n    /**\n     * @dev Returns the amount of tokens in existence.\n     */\n    function totalSupply() external view returns (uint256);\n\n    /**\n     * @dev Returns the amount of tokens owned by `account`.\n     */\n    function balanceOf(address account) external view returns (uint256);\n\n    /**\n     * @dev Moves `amount` tokens from the caller's account to `to`.\n     *\n     * Returns a boolean value indicating whether the operation succeeded.\n     *\n     * Emits a {Transfer} event.\n     */\n    function transfer(address to, uint256 amount) external returns (bool);\n\n    /**\n     * @dev Returns the remaining number of tokens that `spender` will be\n     * allowed to spend on behalf of `owner` through {transferFrom}. This is\n     * zero by default.\n     *\n     * This value changes when {approve} or {transferFrom} are called.\n     */\n    function allowance(address owner, address spender) external view returns (uint256);\n\n    /**\n     * @dev Sets `amount` as the allowance of `spender` over the caller's tokens.\n     *\n     * Returns a boolean value indicating whether the operation succeeded.\n     *\n     * IMPORTANT: Beware that changing an allowance with this method brings the risk\n     * that someone may use both the old and the new allowance by unfortunate\n     * transaction ordering. One possible solution to mitigate this race\n     * condition is to first reduce the spender's allowance to 0 and set the\n     * desired value afterwards:\n     * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729\n     *\n     * Emits an {Approval} event.\n     */\n    function approve(address spender, uint256 amount) external returns (bool);\n\n    /**\n     * @dev Moves `amount` tokens from `from` to `to` using the\n     * allowance mechanism. `amount` is then deducted from the caller's\n     * allowance.\n     *\n     * Returns a boolean value indicating whether the operation succeeded.\n     *\n     * Emits a {Transfer} event.\n     */\n    function transferFrom(address from, address to, uint256 amount) external returns (bool);\n}\n"
      },
      "lib/valantis-core/src/swap-fee-modules/interfaces/ISwapFeeModule.sol": {
        "content": "// SPDX-License-Identifier: MIT\npragma solidity 0.8.19;\n\n/**\n    @notice Struct returned by the swapFeeModule during the getSwapFeeInBips call.\n    * feeInBips: The swap fee in bips.\n    * internalContext: Arbitrary bytes context data.\n */\nstruct SwapFeeModuleData {\n    uint256 feeInBips;\n    bytes internalContext;\n}\n\ninterface ISwapFeeModuleMinimal {\n    /**\n        @notice Returns the swap fee in bips for both Universal & Sovereign Pools.\n        @param _tokenIn The address of the token that the user wants to swap.\n        @param _tokenOut The address of the token that the user wants to receive.\n        @param _amountIn The amount of tokenIn being swapped.\n        @param _user The address of the user.\n        @param _swapFeeModuleContext Arbitrary bytes data which can be sent to the swap fee module.\n        @return swapFeeModuleData A struct containing the swap fee in bips, and internal context data.\n     */\n    function getSwapFeeInBips(\n        address _tokenIn,\n        address _tokenOut,\n        uint256 _amountIn,\n        address _user,\n        bytes memory _swapFeeModuleContext\n    ) external returns (SwapFeeModuleData memory swapFeeModuleData);\n}\n\ninterface ISwapFeeModule is ISwapFeeModuleMinimal {\n    /**\n        @notice Callback function called by the pool after the swap has finished. ( Universal Pools )\n        @param _effectiveFee The effective fee charged for the swap.\n        @param _spotPriceTick The spot price tick after the swap.\n        @param _amountInUsed The amount of tokenIn used for the swap.\n        @param _amountOut The amount of the tokenOut transferred to the user.\n        @param _swapFeeModuleData The context data returned by getSwapFeeInBips.\n     */\n    function callbackOnSwapEnd(\n        uint256 _effectiveFee,\n        int24 _spotPriceTick,\n        uint256 _amountInUsed,\n        uint256 _amountOut,\n        SwapFeeModuleData memory _swapFeeModuleData\n    ) external;\n\n    /**\n        @notice Callback function called by the pool after the swap has finished. ( Sovereign Pools )\n        @param _effectiveFee The effective fee charged for the swap.\n        @param _amountInUsed The amount of tokenIn used for the swap.\n        @param _amountOut The amount of the tokenOut transferred to the user.\n        @param _swapFeeModuleData The context data returned by getSwapFeeInBips.\n     */\n    function callbackOnSwapEnd(\n        uint256 _effectiveFee,\n        uint256 _amountInUsed,\n        uint256 _amountOut,\n        SwapFeeModuleData memory _swapFeeModuleData\n    ) external;\n}\n"
      }
    },
    "settings": {
      "remappings": [
        "forge-std/=lib/forge-std/src/",
        "valantis-core/=lib/valantis-core/",
        "@uniswap/v3-periphery/=lib/v3-periphery/",
        "@uniswap/v3-core/=lib/v3-core/",
        "ds-test/=lib/forge-std/lib/ds-test/src/",
        "erc4626-tests/=lib/valantis-core/lib/openzeppelin-contracts/lib/erc4626-tests/",
        "openzeppelin-contracts/=lib/valantis-core/lib/openzeppelin-contracts/",
        "openzeppelin/=lib/valantis-core/lib/openzeppelin-contracts/contracts/",
        "v3-core/=lib/v3-core/contracts/",
        "v3-periphery/=lib/v3-periphery/contracts/"
      ],
      "optimizer": {
        "enabled": true,
        "runs": 20000
      },
      "metadata": {
        "useLiteralContent": false,
        "bytecodeHash": "ipfs",
        "appendCBOR": true
      },
      "outputSelection": {
        "*": {
          "*": [
            "evm.bytecode",
            "evm.deployedBytecode",
            "devdoc",
            "userdoc",
            "metadata",
            "abi"
          ]
        }
      },
      "evmVersion": "paris",
      "viaIR": false,
      "libraries": {}
    }
  }}