@@ -9,6 +9,7 @@ import {UniswapHook} from "../src/UniswapHook.sol";
99import {PoolKey} from "@uniswap/v4-core/src/types/PoolKey.sol " ;
1010import {IPoolManager, PoolManagerDeployer} from "./utils/PoolManagerDeployer.sol " ;
1111import {PoolSwapTest} from "@uniswap/v4-core/src/test/PoolSwapTest.sol " ;
12+ import {PoolDonateTest} from "@uniswap/v4-core/src/test/PoolDonateTest.sol " ;
1213import {MinimalRouter} from "./utils/MinimalRouter.sol " ;
1314import {PoolModifyLiquidityTest} from "@uniswap/v4-core/src/test/PoolModifyLiquidityTest.sol " ;
1415import {Currency, CurrencyLibrary} from "@uniswap/v4-core/src/types/Currency.sol " ;
@@ -18,6 +19,7 @@ import {BalanceDelta} from "@uniswap/v4-core/src/types/BalanceDelta.sol";
1819import {CustomRevert} from "@uniswap/v4-core/src/libraries/CustomRevert.sol " ;
1920import {IHooks} from "@uniswap/v4-core/src/interfaces/IHooks.sol " ;
2021import {Hooks} from "@uniswap/v4-core/src/libraries/Hooks.sol " ;
22+ import {BaseHook} from "v4-periphery/src/utils/BaseHook.sol " ;
2123
2224contract HookSwapsTest is EulerSwapTestBase {
2325 using StateLibrary for IPoolManager;
@@ -28,6 +30,7 @@ contract HookSwapsTest is EulerSwapTestBase {
2830 PoolSwapTest public swapRouter;
2931 MinimalRouter public minimalRouter;
3032 PoolModifyLiquidityTest public liquidityManager;
33+ PoolDonateTest public donateRouter;
3134
3235 PoolSwapTest.TestSettings public settings = PoolSwapTest.TestSettings ({takeClaims: false , settleUsingBurn: false });
3336
@@ -38,6 +41,7 @@ contract HookSwapsTest is EulerSwapTestBase {
3841 swapRouter = new PoolSwapTest (poolManager);
3942 minimalRouter = new MinimalRouter (poolManager);
4043 liquidityManager = new PoolModifyLiquidityTest (poolManager);
44+ donateRouter = new PoolDonateTest (poolManager);
4145
4246 deployEulerSwap (address (poolManager));
4347
@@ -133,13 +137,13 @@ contract HookSwapsTest is EulerSwapTestBase {
133137 assertTrue (perms.beforeAddLiquidity);
134138 assertTrue (perms.beforeSwap);
135139 assertTrue (perms.beforeSwapReturnDelta);
140+ assertTrue (perms.beforeDonate);
136141
137142 assertFalse (perms.afterInitialize);
138143 assertFalse (perms.afterAddLiquidity);
139144 assertFalse (perms.beforeRemoveLiquidity);
140145 assertFalse (perms.afterRemoveLiquidity);
141146 assertFalse (perms.afterSwap);
142- assertFalse (perms.beforeDonate);
143147 assertFalse (perms.afterDonate);
144148 assertFalse (perms.afterSwapReturnDelta);
145149 assertFalse (perms.afterAddLiquidityReturnDelta);
@@ -163,7 +167,7 @@ contract HookSwapsTest is EulerSwapTestBase {
163167 CustomRevert.WrappedError.selector ,
164168 address (eulerSwap),
165169 IHooks.beforeAddLiquidity.selector ,
166- abi.encodeWithSelector (UniswapHook.NativeConcentratedLiquidityUnsupported .selector ),
170+ abi.encodeWithSelector (BaseHook.HookNotImplemented .selector ),
167171 abi.encodeWithSelector (Hooks.HookCallFailed.selector )
168172 )
169173 );
@@ -186,13 +190,30 @@ contract HookSwapsTest is EulerSwapTestBase {
186190 CustomRevert.WrappedError.selector ,
187191 address (eulerSwap),
188192 IHooks.beforeInitialize.selector ,
189- abi.encodeWithSelector (UniswapHook.AlreadyInitialized .selector ),
193+ abi.encodeWithSelector (BaseHook.HookNotImplemented .selector ),
190194 abi.encodeWithSelector (Hooks.HookCallFailed.selector )
191195 )
192196 );
193197 poolManager.initialize (newPoolKey, 79228162514264337593543950336 );
194198 }
195199
200+ /// @dev revert on donations as they are irrecoverable if they were supported
201+ function test_revertDonate (uint256 amount0 , uint256 amount1 ) public {
202+ PoolKey memory poolKey = eulerSwap.poolKey ();
203+
204+ // hook intentionally reverts to prevent irrecoverable donations
205+ vm.expectRevert (
206+ abi.encodeWithSelector (
207+ CustomRevert.WrappedError.selector ,
208+ address (eulerSwap),
209+ IHooks.beforeDonate.selector ,
210+ abi.encodeWithSelector (BaseHook.HookNotImplemented.selector ),
211+ abi.encodeWithSelector (Hooks.HookCallFailed.selector )
212+ )
213+ );
214+ donateRouter.donate (poolKey, amount0, amount1, "" );
215+ }
216+
196217 function _swap (PoolKey memory key , bool zeroForOne , bool exactInput , uint256 amount ) internal {
197218 IPoolManager.SwapParams memory swapParams = IPoolManager.SwapParams ({
198219 zeroForOne: zeroForOne,
0 commit comments