diff --git a/packages/foundry/script/00_Counter.s.sol b/packages/foundry/script/00_Counter.s.sol index 4d2b661..4d447ee 100644 --- a/packages/foundry/script/00_Counter.s.sol +++ b/packages/foundry/script/00_Counter.s.sol @@ -21,17 +21,9 @@ contract EtfHookScript is Script, Constants { // hook contracts must have specific flags encoded in the address uint160 flags = uint160( Hooks.BEFORE_SWAP_FLAG | Hooks.BEFORE_ADD_LIQUIDITY_FLAG - | Hooks.BEFORE_REMOVE_LIQUIDITY_FLAG + | Hooks.AFTER_REMOVE_LIQUIDITY_FLAG ); - // Mine a salt that will produce a hook address with the correct flags - bytes memory constructorArgs = abi.encode(POOLMANAGER); - (address hookAddress, bytes32 salt) = - HookMiner.find(CREATE2_DEPLOYER, flags, type(ETFHook).creationCode, constructorArgs); - - // Deploy the hook using CREATE2 - vm.broadcast(); - token0 = new MockERC20("Token0", "T0", 18); token1 = new MockERC20("Token1", "T1", 18); token0.mint(msg.sender, 1_000_000); @@ -39,8 +31,19 @@ contract EtfHookScript is Script, Constants { address[2] memory TOKENS = [address(token0), address(token1)]; uint256[2] memory WEIGHTS = [uint256(1), uint256(1)]; uint256 REBALANCE_THRESHOLD = 5; + + // Mine a salt that will produce a hook address with the correct flags + bytes memory constructorArgs = abi.encode( + POOLMANAGER, TOKENS, WEIGHTS, REBALANCE_THRESHOLD, address(0) + ); + (address hookAddress, bytes32 salt) = + HookMiner.find(CREATE2_DEPLOYER, flags, type(ETFHook).creationCode, constructorArgs); + + // Deploy the hook using CREATE2 + vm.broadcast(); + ETFHook etfHook = new ETFHook{salt: salt}( - IPoolManager(POOLMANAGER), TOKENS, WEIGHTS, REBALANCE_THRESHOLD, address(0), address(0), address(0), address(0) + IPoolManager(POOLMANAGER), TOKENS, WEIGHTS, REBALANCE_THRESHOLD, address(0) ); require(address(etfHook) == hookAddress, "EtfHookScript: hook address mismatch"); } diff --git a/packages/foundry/script/base/Constants.sol b/packages/foundry/script/base/Constants.sol index 808722b..ce2c2db 100644 --- a/packages/foundry/script/base/Constants.sol +++ b/packages/foundry/script/base/Constants.sol @@ -10,7 +10,7 @@ contract Constants { address constant CREATE2_DEPLOYER = address(0x4e59b44847b379578588920cA78FbF26c0B4956C); /// @dev populated with default anvil addresses - IPoolManager constant POOLMANAGER = IPoolManager(address(0x5FbDB2315678afecb367f032d93F642f64180aa3)); - PositionManager constant posm = PositionManager(payable(address(0x9fE46736679d2D9a65F0992F2272dE9f3c7fa6e0))); + IPoolManager constant POOLMANAGER = IPoolManager(address(0x008c4bcbe6b9ef47855f97e675296fa3f6fafa5f1a)); + PositionManager constant posm = PositionManager(payable(address(0x001b1c77b606d13b09c84d1c7394b96b147bc03147))); IAllowanceTransfer constant PERMIT2 = IAllowanceTransfer(address(0x000000000022D473030F116dDEE9F6B43aC78BA3)); }