Skip to content

Commit 9fc8d0f

Browse files
authored
Merge pull request #59 from euler-xyz/sauce/hook-todo
Cleanup Hook TODOs
2 parents 503245f + ba4b294 commit 9fc8d0f

File tree

3 files changed

+29
-7
lines changed

3 files changed

+29
-7
lines changed

TODO

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
! document that periphery depends on non-malicious eulerSwap instances
44
! limitations of getLimits
55
* update deploy scripts
6-
* TODOs in UniswapHook.sol
76
* small cleanups in CurveLib
87
? tighten up getLimits bounds
98

src/UniswapHook.sol

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ contract UniswapHook is BaseHook {
4242
currency0: Currency.wrap(asset0Addr),
4343
currency1: Currency.wrap(asset1Addr),
4444
fee: fee,
45-
tickSpacing: 60, // TODO: fix arbitrary tick spacing
45+
tickSpacing: 1, // hard-coded tick spacing, as its unused
4646
hooks: IHooks(address(this))
4747
});
4848

@@ -90,7 +90,6 @@ contract UniswapHook is BaseHook {
9090

9191
// take the input token, from the PoolManager to the Euler vault
9292
// the debt will be paid by the swapper via the swap router
93-
// TODO: can we optimize the transfer by pulling from PoolManager directly to Euler?
9493
poolManager.take(params.zeroForOne ? key.currency0 : key.currency1, address(this), amountIn);
9594
amountInWithoutFee = FundsLib.depositAssets(evc, p, params.zeroForOne ? p.vault0 : p.vault1);
9695

@@ -117,7 +116,22 @@ contract UniswapHook is BaseHook {
117116
return (BaseHook.beforeSwap.selector, returnDelta, 0);
118117
}
119118

120-
// TODO: fix salt mining & verification for the hook
121-
function getHookPermissions() public pure override returns (Hooks.Permissions memory) {}
122-
function validateHookAddress(BaseHook) internal pure override {}
119+
function getHookPermissions() public pure override returns (Hooks.Permissions memory) {
120+
return Hooks.Permissions({
121+
beforeInitialize: false,
122+
afterInitialize: false,
123+
beforeAddLiquidity: false,
124+
afterAddLiquidity: false,
125+
beforeRemoveLiquidity: false,
126+
afterRemoveLiquidity: false,
127+
beforeSwap: true,
128+
afterSwap: false,
129+
beforeDonate: false,
130+
afterDonate: false,
131+
beforeSwapReturnDelta: true,
132+
afterSwapReturnDelta: false,
133+
afterAddLiquidityReturnDelta: false,
134+
afterRemoveLiquidityReturnDelta: false
135+
});
136+
}
123137
}

test/EulerSwapTestBase.t.sol

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import {EulerSwapFactory} from "../src/EulerSwapFactory.sol";
99
import {EulerSwapPeriphery} from "../src/EulerSwapPeriphery.sol";
1010
import {IPoolManager} from "@uniswap/v4-core/src/interfaces/IPoolManager.sol";
1111
import {HookMiner} from "./utils/HookMiner.sol";
12+
import {HookMiner as v4HookMiner} from "v4-periphery/src/utils/HookMiner.sol";
1213
import {Hooks} from "@uniswap/v4-core/src/libraries/Hooks.sol";
1314
import {MetaProxyDeployer} from "../src/MetaProxyDeployer.sol";
1415

@@ -37,7 +38,15 @@ contract EulerSwapTestBase is EVaultTestBase {
3738
}
3839

3940
function deployEulerSwap(address poolManager_) public {
40-
eulerSwapImpl = address(new EulerSwap(address(evc), poolManager_));
41+
// use the canonical miner to find a valid 'implementation' address
42+
(, bytes32 salt) = v4HookMiner.find(
43+
address(this),
44+
uint160(Hooks.BEFORE_SWAP_FLAG | Hooks.BEFORE_SWAP_RETURNS_DELTA_FLAG),
45+
type(EulerSwap).creationCode,
46+
abi.encode(address(evc), poolManager_)
47+
);
48+
49+
eulerSwapImpl = address(new EulerSwap{salt: salt}(address(evc), poolManager_));
4150
eulerSwapFactory = new EulerSwapFactory(address(evc), address(factory), eulerSwapImpl);
4251
periphery = new EulerSwapPeriphery();
4352
}

0 commit comments

Comments
 (0)