Skip to content

Commit 8450fa2

Browse files
authored
Merge pull request #77 from euler-xyz/nonreentrant-hook
make _beforeSwap take the reentrancy lock
2 parents a375773 + 2bb58d4 commit 8450fa2

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

src/UniswapHook.sol

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ contract UniswapHook is BaseHook {
2929

3030
error AlreadyInitialized();
3131
error NativeConcentratedLiquidityUnsupported();
32+
error LockedHook();
3233

3334
constructor(address evc_, address _poolManager) BaseHook(IPoolManager(_poolManager)) {
3435
evc = evc_;
@@ -65,9 +66,25 @@ contract UniswapHook is BaseHook {
6566
/// in activateHook().
6667
function validateHookAddress(BaseHook _this) internal pure override {}
6768

69+
modifier nonReentrantHook() {
70+
{
71+
CtxLib.Storage storage s = CtxLib.getStorage();
72+
require(s.status == 1, LockedHook());
73+
s.status = 2;
74+
}
75+
76+
_;
77+
78+
{
79+
CtxLib.Storage storage s = CtxLib.getStorage();
80+
s.status = 1;
81+
}
82+
}
83+
6884
function _beforeSwap(address, PoolKey calldata key, IPoolManager.SwapParams calldata params, bytes calldata)
6985
internal
7086
override
87+
nonReentrantHook
7188
returns (bytes4, BeforeSwapDelta, uint24)
7289
{
7390
IEulerSwap.Params memory p = CtxLib.getParams();

0 commit comments

Comments
 (0)