@@ -9,6 +9,7 @@ import {UniswapHook} from "../src/UniswapHook.sol";
9
9
import {PoolKey} from "@uniswap/v4-core/src/types/PoolKey.sol " ;
10
10
import {IPoolManager, PoolManagerDeployer} from "./utils/PoolManagerDeployer.sol " ;
11
11
import {PoolSwapTest} from "@uniswap/v4-core/src/test/PoolSwapTest.sol " ;
12
+ import {PoolDonateTest} from "@uniswap/v4-core/src/test/PoolDonateTest.sol " ;
12
13
import {MinimalRouter} from "./utils/MinimalRouter.sol " ;
13
14
import {PoolModifyLiquidityTest} from "@uniswap/v4-core/src/test/PoolModifyLiquidityTest.sol " ;
14
15
import {Currency, CurrencyLibrary} from "@uniswap/v4-core/src/types/Currency.sol " ;
@@ -18,6 +19,7 @@ import {BalanceDelta} from "@uniswap/v4-core/src/types/BalanceDelta.sol";
18
19
import {CustomRevert} from "@uniswap/v4-core/src/libraries/CustomRevert.sol " ;
19
20
import {IHooks} from "@uniswap/v4-core/src/interfaces/IHooks.sol " ;
20
21
import {Hooks} from "@uniswap/v4-core/src/libraries/Hooks.sol " ;
22
+ import {BaseHook} from "v4-periphery/src/utils/BaseHook.sol " ;
21
23
22
24
contract HookSwapsTest is EulerSwapTestBase {
23
25
using StateLibrary for IPoolManager;
@@ -28,6 +30,7 @@ contract HookSwapsTest is EulerSwapTestBase {
28
30
PoolSwapTest public swapRouter;
29
31
MinimalRouter public minimalRouter;
30
32
PoolModifyLiquidityTest public liquidityManager;
33
+ PoolDonateTest public donateRouter;
31
34
32
35
PoolSwapTest.TestSettings public settings = PoolSwapTest.TestSettings ({takeClaims: false , settleUsingBurn: false });
33
36
@@ -38,6 +41,7 @@ contract HookSwapsTest is EulerSwapTestBase {
38
41
swapRouter = new PoolSwapTest (poolManager);
39
42
minimalRouter = new MinimalRouter (poolManager);
40
43
liquidityManager = new PoolModifyLiquidityTest (poolManager);
44
+ donateRouter = new PoolDonateTest (poolManager);
41
45
42
46
deployEulerSwap (address (poolManager));
43
47
@@ -133,13 +137,13 @@ contract HookSwapsTest is EulerSwapTestBase {
133
137
assertTrue (perms.beforeAddLiquidity);
134
138
assertTrue (perms.beforeSwap);
135
139
assertTrue (perms.beforeSwapReturnDelta);
140
+ assertTrue (perms.beforeDonate);
136
141
137
142
assertFalse (perms.afterInitialize);
138
143
assertFalse (perms.afterAddLiquidity);
139
144
assertFalse (perms.beforeRemoveLiquidity);
140
145
assertFalse (perms.afterRemoveLiquidity);
141
146
assertFalse (perms.afterSwap);
142
- assertFalse (perms.beforeDonate);
143
147
assertFalse (perms.afterDonate);
144
148
assertFalse (perms.afterSwapReturnDelta);
145
149
assertFalse (perms.afterAddLiquidityReturnDelta);
@@ -193,6 +197,23 @@ contract HookSwapsTest is EulerSwapTestBase {
193
197
poolManager.initialize (newPoolKey, 79228162514264337593543950336 );
194
198
}
195
199
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
+
196
217
function _swap (PoolKey memory key , bool zeroForOne , bool exactInput , uint256 amount ) internal {
197
218
IPoolManager.SwapParams memory swapParams = IPoolManager.SwapParams ({
198
219
zeroForOne: zeroForOne,
0 commit comments