diff --git a/script/DeploySepolia.s.sol b/script/DeploySepolia.s.sol index 06e0c83..d2ffadd 100644 --- a/script/DeploySepolia.s.sol +++ b/script/DeploySepolia.s.sol @@ -3,7 +3,6 @@ pragma solidity ^0.8.13; import {Script} from "forge-std/Script.sol"; -import {PoolManager, Deployers, Hooks} from "v4-core/test/utils/Deployers.sol"; import {ICurveStableswapFactoryNG} from "../src/interfaces/ICurveStableswapFactoryNG.sol"; import {ICurveStableswapNG} from "../src/interfaces/ICurveStableswapNG.sol"; import {ILiquidityGauge} from "./../src/interfaces/ILiquidityGauge.sol"; @@ -12,21 +11,19 @@ import {IGovernance} from "../src/interfaces/IGovernance.sol"; import {Governance} from "../src/Governance.sol"; import {CurveV2GaugeRewards} from "../src/CurveV2GaugeRewards.sol"; -import {Hooks} from "../src/utils/BaseHook.sol"; import {MockERC20Tester} from "../test/mocks/MockERC20Tester.sol"; import {MockStakingV1} from "../test/mocks/MockStakingV1.sol"; import {MockStakingV1Deployer} from "../test/mocks/MockStakingV1Deployer.sol"; import {HookMiner} from "./utils/HookMiner.sol"; -contract DeploySepoliaScript is Script, Deployers, MockStakingV1Deployer { +contract DeploySepoliaScript is Script, MockStakingV1Deployer { // Environment Constants MockERC20Tester private lqty; MockERC20Tester private bold; MockStakingV1 private stakingV1; MockERC20Tester private usdc; - PoolManager private constant poolManager = PoolManager(0xE8E23e97Fa135823143d6b9Cba9c699040D51F70); ICurveStableswapFactoryNG private constant curveFactory = ICurveStableswapFactoryNG(address(0xfb37b8D939FFa77114005e61CFc2e543d6F49A81)); diff --git a/src/utils/BaseHook.sol b/src/utils/BaseHook.sol deleted file mode 100644 index b202198..0000000 --- a/src/utils/BaseHook.sol +++ /dev/null @@ -1,158 +0,0 @@ -// SPDX-License-Identifier: MIT -pragma solidity ^0.8.24; - -import {Hooks} from "v4-core/src/libraries/Hooks.sol"; -import {IPoolManager} from "v4-core/src/interfaces/IPoolManager.sol"; -import {IHooks} from "v4-core/src/interfaces/IHooks.sol"; -import {BalanceDelta} from "v4-core/src/types/BalanceDelta.sol"; -import {PoolKey} from "v4-core/src/types/PoolKey.sol"; -import {BeforeSwapDelta} from "v4-core/src/types/BeforeSwapDelta.sol"; -import {IUnlockCallback} from "v4-core/src/interfaces/callback/IUnlockCallback.sol"; - -contract ImmutableState { - IPoolManager public immutable manager; - - constructor(IPoolManager _manager) { - manager = _manager; - } -} - -abstract contract SafeCallback is ImmutableState, IUnlockCallback { - error NotManager(); - - modifier onlyByManager() { - if (msg.sender != address(manager)) revert NotManager(); - _; - } - - /// @dev We force the onlyByManager modifier by exposing a virtual function after the onlyByManager check. - function unlockCallback(bytes calldata data) external onlyByManager returns (bytes memory) { - return _unlockCallback(data); - } - - function _unlockCallback(bytes calldata data) internal virtual returns (bytes memory); -} - -abstract contract BaseHook is IHooks, SafeCallback { - error NotSelf(); - error InvalidPool(); - error LockFailure(); - error HookNotImplemented(); - - constructor(IPoolManager _manager) ImmutableState(_manager) { - validateHookAddress(this); - } - - /// @dev Only this address may call this function - modifier selfOnly() { - if (msg.sender != address(this)) revert NotSelf(); - _; - } - - /// @dev Only pools with hooks set to this contract may call this function - modifier onlyValidPools(IHooks hooks) { - if (hooks != this) revert InvalidPool(); - _; - } - - function getHookPermissions() public pure virtual returns (Hooks.Permissions memory); - - // this function is virtual so that we can override it during testing, - // which allows us to deploy an implementation to any address - // and then etch the bytecode into the correct address - function validateHookAddress(BaseHook _this) internal pure virtual { - Hooks.validateHookPermissions(_this, getHookPermissions()); - } - - function _unlockCallback(bytes calldata data) internal virtual override returns (bytes memory) { - (bool success, bytes memory returnData) = address(this).call(data); - if (success) return returnData; - if (returnData.length == 0) revert LockFailure(); - // if the call failed, bubble up the reason - /// @solidity memory-safe-assembly - assembly { - revert(add(returnData, 32), mload(returnData)) - } - } - - function beforeInitialize(address, PoolKey calldata, uint160, bytes calldata) external virtual returns (bytes4) { - revert HookNotImplemented(); - } - - function afterInitialize(address, PoolKey calldata, uint160, int24, bytes calldata) - external - virtual - returns (bytes4) - { - revert HookNotImplemented(); - } - - function beforeAddLiquidity(address, PoolKey calldata, IPoolManager.ModifyLiquidityParams calldata, bytes calldata) - external - virtual - returns (bytes4) - { - revert HookNotImplemented(); - } - - function beforeRemoveLiquidity( - address, - PoolKey calldata, - IPoolManager.ModifyLiquidityParams calldata, - bytes calldata - ) external virtual returns (bytes4) { - revert HookNotImplemented(); - } - - function afterAddLiquidity( - address, - PoolKey calldata, - IPoolManager.ModifyLiquidityParams calldata, - BalanceDelta, - bytes calldata - ) external virtual returns (bytes4, BalanceDelta) { - revert HookNotImplemented(); - } - - function afterRemoveLiquidity( - address, - PoolKey calldata, - IPoolManager.ModifyLiquidityParams calldata, - BalanceDelta, - bytes calldata - ) external virtual returns (bytes4, BalanceDelta) { - revert HookNotImplemented(); - } - - function beforeSwap(address, PoolKey calldata, IPoolManager.SwapParams calldata, bytes calldata) - external - virtual - returns (bytes4, BeforeSwapDelta, uint24) - { - revert HookNotImplemented(); - } - - function afterSwap(address, PoolKey calldata, IPoolManager.SwapParams calldata, BalanceDelta, bytes calldata) - external - virtual - returns (bytes4, int128) - { - revert HookNotImplemented(); - } - - function beforeDonate(address, PoolKey calldata, uint256, uint256, bytes calldata) - external - virtual - returns (bytes4) - { - revert HookNotImplemented(); - } - - function afterDonate(address, PoolKey calldata, uint256, uint256, bytes calldata) - external - virtual - returns (bytes4) - { - revert HookNotImplemented(); - } -}