diff --git a/src/MainnetController.sol b/src/MainnetController.sol index 4c4530da..173e45a9 100644 --- a/src/MainnetController.sol +++ b/src/MainnetController.sol @@ -10,6 +10,8 @@ import { IERC20 } from "../lib/openzeppelin-contracts/contracts/token/ER import { IERC20Metadata } from "../lib/openzeppelin-contracts/contracts/token/ERC20/extensions/IERC20Metadata.sol"; import { IERC4626 } from "../lib/openzeppelin-contracts/contracts/interfaces/IERC4626.sol"; +import { PoolKey } from "../lib/uniswap-v4-core/src/types/PoolKey.sol"; + import { Ethereum } from "spark-address-registry/Ethereum.sol"; import { IALMProxy } from "./interfaces/IALMProxy.sol"; @@ -330,6 +332,10 @@ contract MainnetController is ReentrancyGuard, AccessControlEnumerable { { _checkRole(DEFAULT_ADMIN_ROLE); + PoolKey memory poolKey = UniswapV4Lib.getPoolKeyFromPoolId(poolId); + + require(address(poolKey.hooks) == address(0), "MC/pool-has-hooks"); + require( ((tickLowerMin == 0) && (tickUpperMax == 0) && (maxTickSpacing == 0)) || ((maxTickSpacing > 0) && (tickLowerMin < tickUpperMax)), diff --git a/src/libraries/UniswapV4Lib.sol b/src/libraries/UniswapV4Lib.sol index 645a3c3b..85b23c77 100644 --- a/src/libraries/UniswapV4Lib.sol +++ b/src/libraries/UniswapV4Lib.sol @@ -53,7 +53,7 @@ library UniswapV4Lib { { _checkTickLimits(tickLimits[poolId], tickLower, tickUpper); - PoolKey memory poolKey = _getPoolKeyFromPoolId(poolId); + PoolKey memory poolKey = getPoolKeyFromPoolId(poolId); bytes memory callData = _getMintCalldata({ poolKey : poolKey, @@ -176,7 +176,7 @@ library UniswapV4Lib { { require(maxSlippage != 0, "MC/max-slippage-not-set"); - PoolKey memory poolKey = _getPoolKeyFromPoolId(poolId); + PoolKey memory poolKey = getPoolKeyFromPoolId(poolId); require( tokenIn == Currency.unwrap(poolKey.currency0) || @@ -243,6 +243,10 @@ library UniswapV4Lib { _approveWithPermit2(proxy, tokenIn, _ROUTER, 0); } + function getPoolKeyFromPoolId(bytes32 poolId) public view returns (PoolKey memory poolKey) { + return IPositionManagerLike(_POSITION_MANAGER).poolKeys(bytes25(poolId)); + } + /**********************************************************************************************/ /*** Internal Interactive Functions ***/ /**********************************************************************************************/ @@ -528,10 +532,6 @@ library UniswapV4Lib { return IPositionManagerLike(_POSITION_MANAGER).getPoolAndPositionInfo(tokenId); } - function _getPoolKeyFromPoolId(bytes32 poolId) internal view returns (PoolKey memory poolKey) { - return IPositionManagerLike(_POSITION_MANAGER).poolKeys(bytes25(poolId)); - } - function _getPoolKeyFromTokenId(uint256 tokenId) internal view returns (PoolKey memory poolKey) {