From 03d2d371874d99eaf28722ea2a52e0a19645d56a Mon Sep 17 00:00:00 2001 From: Alice Henshaw Date: Mon, 21 Oct 2024 16:01:49 -0400 Subject: [PATCH] Move initialize event --- .forge-snapshots/initialize.snap | 2 +- .forge-snapshots/poolManager bytecode size.snap | 2 +- src/PoolManager.sol | 5 +++-- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/.forge-snapshots/initialize.snap b/.forge-snapshots/initialize.snap index 450c7974e..1d5e12d81 100644 --- a/.forge-snapshots/initialize.snap +++ b/.forge-snapshots/initialize.snap @@ -1 +1 @@ -51536 \ No newline at end of file +51535 \ No newline at end of file diff --git a/.forge-snapshots/poolManager bytecode size.snap b/.forge-snapshots/poolManager bytecode size.snap index 37be6af7a..a55204ffc 100644 --- a/.forge-snapshots/poolManager bytecode size.snap +++ b/.forge-snapshots/poolManager bytecode size.snap @@ -1 +1 @@ -23621 \ No newline at end of file +23656 \ No newline at end of file diff --git a/src/PoolManager.sol b/src/PoolManager.sol index 92b8148ad..42dbf0121 100644 --- a/src/PoolManager.sol +++ b/src/PoolManager.sol @@ -131,11 +131,12 @@ contract PoolManager is IPoolManager, ProtocolFees, NoDelegateCall, ERC6909Claim tick = _pools[id].initialize(sqrtPriceX96, lpFee); - key.hooks.afterInitialize(key, sqrtPriceX96, tick); - + // event is emitted before the afterInitialize call to ensure events are always emitted in order // emit all details of a pool key. poolkeys are not saved in storage and must always be provided by the caller // the key's fee may be a static fee or a sentinel to denote a dynamic fee. emit Initialize(id, key.currency0, key.currency1, key.fee, key.tickSpacing, key.hooks, sqrtPriceX96, tick); + + key.hooks.afterInitialize(key, sqrtPriceX96, tick); } /// @inheritdoc IPoolManager