Skip to content

Commit 58eb1b0

Browse files
committed
chore: forge fmt
1 parent 13d1ed0 commit 58eb1b0

6 files changed

Lines changed: 127 additions & 160 deletions

File tree

src/interfaces/IImmutableState.sol

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
// SPDX-License-Identifier: MIT
22
pragma solidity ^0.8.0;
3+
34
import {IMultiHookAdapterBase} from "../interfaces/IMultiHookAdapterBase.sol";
45

56
/// @title IImmutableState
@@ -9,4 +10,4 @@ import {IMultiHookAdapterBase} from "../interfaces/IMultiHookAdapterBase.sol";
910
interface IImmutableState {
1011
/// @notice The MultiHookAdapter contract
1112
function multiHookAdapter() external view returns (IMultiHookAdapterBase);
12-
}
13+
}

src/interfaces/IMultiHookAdapterBase.sol

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,4 @@ interface IMultiHookAdapterBase {
99
/// @notice The Uniswap v4 PoolManager contract
1010
function poolManager() external view returns (IPoolManager);
1111
function multiHookAdapter() external view returns (address);
12-
}
12+
}

src/utils/BaseHookExtension.sol

Lines changed: 50 additions & 90 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,7 @@ abstract contract BaseHook is IHooks, ImmutableState {
2727
/// @notice Returns a struct of permissions to signal which hook functions are to be implemented
2828
/// @dev Used at deployment to validate the address correctly represents the expected permissions
2929
/// @return Permissions struct
30-
function getHookPermissions()
31-
public
32-
pure
33-
virtual
34-
returns (Hooks.Permissions memory);
30+
function getHookPermissions() public pure virtual returns (Hooks.Permissions memory);
3531

3632
/// @notice Validates the deployed hook address agrees with the expected permissions of the hook
3733
/// @dev this function is virtual so that we can override it during testing,
@@ -42,38 +38,28 @@ abstract contract BaseHook is IHooks, ImmutableState {
4238
}
4339

4440
/// @inheritdoc IHooks
45-
function beforeInitialize(
46-
address sender,
47-
PoolKey calldata key,
48-
uint160 sqrtPriceX96
49-
) external onlyMultiHookAdapter returns (bytes4) {
41+
function beforeInitialize(address sender, PoolKey calldata key, uint160 sqrtPriceX96)
42+
external
43+
onlyMultiHookAdapter
44+
returns (bytes4)
45+
{
5046
return _beforeInitialize(sender, key, sqrtPriceX96);
5147
}
5248

53-
function _beforeInitialize(
54-
address,
55-
PoolKey calldata,
56-
uint160
57-
) internal virtual returns (bytes4) {
49+
function _beforeInitialize(address, PoolKey calldata, uint160) internal virtual returns (bytes4) {
5850
revert HookNotImplemented();
5951
}
6052

6153
/// @inheritdoc IHooks
62-
function afterInitialize(
63-
address sender,
64-
PoolKey calldata key,
65-
uint160 sqrtPriceX96,
66-
int24 tick
67-
) external onlyMultiHookAdapter returns (bytes4) {
54+
function afterInitialize(address sender, PoolKey calldata key, uint160 sqrtPriceX96, int24 tick)
55+
external
56+
onlyMultiHookAdapter
57+
returns (bytes4)
58+
{
6859
return _afterInitialize(sender, key, sqrtPriceX96, tick);
6960
}
7061

71-
function _afterInitialize(
72-
address,
73-
PoolKey calldata,
74-
uint160,
75-
int24
76-
) internal virtual returns (bytes4) {
62+
function _afterInitialize(address, PoolKey calldata, uint160, int24) internal virtual returns (bytes4) {
7763
revert HookNotImplemented();
7864
}
7965

@@ -87,12 +73,11 @@ abstract contract BaseHook is IHooks, ImmutableState {
8773
return _beforeAddLiquidity(sender, key, params, hookData);
8874
}
8975

90-
function _beforeAddLiquidity(
91-
address,
92-
PoolKey calldata,
93-
ModifyLiquidityParams calldata,
94-
bytes calldata
95-
) internal virtual returns (bytes4) {
76+
function _beforeAddLiquidity(address, PoolKey calldata, ModifyLiquidityParams calldata, bytes calldata)
77+
internal
78+
virtual
79+
returns (bytes4)
80+
{
9681
revert HookNotImplemented();
9782
}
9883

@@ -106,12 +91,11 @@ abstract contract BaseHook is IHooks, ImmutableState {
10691
return _beforeRemoveLiquidity(sender, key, params, hookData);
10792
}
10893

109-
function _beforeRemoveLiquidity(
110-
address,
111-
PoolKey calldata,
112-
ModifyLiquidityParams calldata,
113-
bytes calldata
114-
) internal virtual returns (bytes4) {
94+
function _beforeRemoveLiquidity(address, PoolKey calldata, ModifyLiquidityParams calldata, bytes calldata)
95+
internal
96+
virtual
97+
returns (bytes4)
98+
{
11599
revert HookNotImplemented();
116100
}
117101

@@ -124,15 +108,7 @@ abstract contract BaseHook is IHooks, ImmutableState {
124108
BalanceDelta feesAccrued,
125109
bytes calldata hookData
126110
) external onlyMultiHookAdapter returns (bytes4, BalanceDelta) {
127-
return
128-
_afterAddLiquidity(
129-
sender,
130-
key,
131-
params,
132-
delta,
133-
feesAccrued,
134-
hookData
135-
);
111+
return _afterAddLiquidity(sender, key, params, delta, feesAccrued, hookData);
136112
}
137113

138114
function _afterAddLiquidity(
@@ -155,15 +131,7 @@ abstract contract BaseHook is IHooks, ImmutableState {
155131
BalanceDelta feesAccrued,
156132
bytes calldata hookData
157133
) external onlyMultiHookAdapter returns (bytes4, BalanceDelta) {
158-
return
159-
_afterRemoveLiquidity(
160-
sender,
161-
key,
162-
params,
163-
delta,
164-
feesAccrued,
165-
hookData
166-
);
134+
return _afterRemoveLiquidity(sender, key, params, delta, feesAccrued, hookData);
167135
}
168136

169137
function _afterRemoveLiquidity(
@@ -178,21 +146,19 @@ abstract contract BaseHook is IHooks, ImmutableState {
178146
}
179147

180148
/// @inheritdoc IHooks
181-
function beforeSwap(
182-
address sender,
183-
PoolKey calldata key,
184-
SwapParams calldata params,
185-
bytes calldata hookData
186-
) external onlyMultiHookAdapter returns (bytes4, BeforeSwapDelta, uint24) {
149+
function beforeSwap(address sender, PoolKey calldata key, SwapParams calldata params, bytes calldata hookData)
150+
external
151+
onlyMultiHookAdapter
152+
returns (bytes4, BeforeSwapDelta, uint24)
153+
{
187154
return _beforeSwap(sender, key, params, hookData);
188155
}
189156

190-
function _beforeSwap(
191-
address,
192-
PoolKey calldata,
193-
SwapParams calldata,
194-
bytes calldata
195-
) internal virtual returns (bytes4, BeforeSwapDelta, uint24) {
157+
function _beforeSwap(address, PoolKey calldata, SwapParams calldata, bytes calldata)
158+
internal
159+
virtual
160+
returns (bytes4, BeforeSwapDelta, uint24)
161+
{
196162
revert HookNotImplemented();
197163
}
198164

@@ -207,13 +173,11 @@ abstract contract BaseHook is IHooks, ImmutableState {
207173
return _afterSwap(sender, key, params, delta, hookData);
208174
}
209175

210-
function _afterSwap(
211-
address,
212-
PoolKey calldata,
213-
SwapParams calldata,
214-
BalanceDelta,
215-
bytes calldata
216-
) internal virtual returns (bytes4, int128) {
176+
function _afterSwap(address, PoolKey calldata, SwapParams calldata, BalanceDelta, bytes calldata)
177+
internal
178+
virtual
179+
returns (bytes4, int128)
180+
{
217181
revert HookNotImplemented();
218182
}
219183

@@ -228,13 +192,11 @@ abstract contract BaseHook is IHooks, ImmutableState {
228192
return _beforeDonate(sender, key, amount0, amount1, hookData);
229193
}
230194

231-
function _beforeDonate(
232-
address,
233-
PoolKey calldata,
234-
uint256,
235-
uint256,
236-
bytes calldata
237-
) internal virtual returns (bytes4) {
195+
function _beforeDonate(address, PoolKey calldata, uint256, uint256, bytes calldata)
196+
internal
197+
virtual
198+
returns (bytes4)
199+
{
238200
revert HookNotImplemented();
239201
}
240202

@@ -249,13 +211,11 @@ abstract contract BaseHook is IHooks, ImmutableState {
249211
return _afterDonate(sender, key, amount0, amount1, hookData);
250212
}
251213

252-
function _afterDonate(
253-
address,
254-
PoolKey calldata,
255-
uint256,
256-
uint256,
257-
bytes calldata
258-
) internal virtual returns (bytes4) {
214+
function _afterDonate(address, PoolKey calldata, uint256, uint256, bytes calldata)
215+
internal
216+
virtual
217+
returns (bytes4)
218+
{
259219
revert HookNotImplemented();
260220
}
261221
}

src/utils/ImmutableState.sol

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ import {IImmutableState} from "../interfaces/IImmutableState.sol";
99
/// @notice Original implementation: https://github.com/Uniswap/v4-periphery/blob/main/src/base/ImmutableState.sol
1010

1111
contract ImmutableState is IImmutableState {
12-
1312
IMultiHookAdapterBase public immutable multiHookAdapter;
1413

1514
/// @notice thrown when caller is not a MultiHookAdapter contract
@@ -21,5 +20,4 @@ contract ImmutableState is IImmutableState {
2120
constructor(IMultiHookAdapterBase _multiHookAdapter) {
2221
multiHookAdapter = _multiHookAdapter;
2322
}
24-
2523
}

test/BaseHookExtension.t.sol

Lines changed: 38 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -36,90 +36,68 @@ contract BaseHookExtensionTest is Test {
3636
function test_OnlyMultiHookAdapterCanCallBeforeInitialize() public {
3737
vm.prank(unauthorizedCaller);
3838
vm.expectRevert("Caller is not the MultiHookAdapter");
39-
hook.beforeInitialize(address(0), PoolKey({
40-
currency0: currency0,
41-
currency1: currency1,
42-
fee: 0,
43-
tickSpacing: 0,
44-
hooks: IHooks(address(0))
45-
}), 0);
39+
hook.beforeInitialize(
40+
address(0),
41+
PoolKey({currency0: currency0, currency1: currency1, fee: 0, tickSpacing: 0, hooks: IHooks(address(0))}),
42+
0
43+
);
4644
}
4745

4846
function test_OnlyMultiHookAdapterCanCallAfterInitialize() public {
4947
vm.prank(unauthorizedCaller);
5048
vm.expectRevert("Caller is not the MultiHookAdapter");
51-
hook.afterInitialize(address(0), PoolKey({
52-
currency0: currency0,
53-
currency1: currency1,
54-
fee: 0,
55-
tickSpacing: 0,
56-
hooks: IHooks(address(0))
57-
}), 0, 0);
49+
hook.afterInitialize(
50+
address(0),
51+
PoolKey({currency0: currency0, currency1: currency1, fee: 0, tickSpacing: 0, hooks: IHooks(address(0))}),
52+
0,
53+
0
54+
);
5855
}
5956

6057
function test_OnlyMultiHookAdapterCanCallBeforeSwap() public {
6158
vm.prank(unauthorizedCaller);
6259
vm.expectRevert("Caller is not the MultiHookAdapter");
63-
hook.beforeSwap(address(0), PoolKey({
64-
currency0: currency0,
65-
currency1: currency1,
66-
fee: 0,
67-
tickSpacing: 0,
68-
hooks: IHooks(address(0))
69-
}), SwapParams({
70-
zeroForOne: true,
71-
amountSpecified: 0,
72-
sqrtPriceLimitX96: 0
73-
}), "");
60+
hook.beforeSwap(
61+
address(0),
62+
PoolKey({currency0: currency0, currency1: currency1, fee: 0, tickSpacing: 0, hooks: IHooks(address(0))}),
63+
SwapParams({zeroForOne: true, amountSpecified: 0, sqrtPriceLimitX96: 0}),
64+
""
65+
);
7466
}
7567

7668
function test_OnlyMultiHookAdapterCanCallAfterSwap() public {
7769
vm.prank(unauthorizedCaller);
7870
vm.expectRevert("Caller is not the MultiHookAdapter");
79-
hook.afterSwap(address(0), PoolKey({
80-
currency0: currency0,
81-
currency1: currency1,
82-
fee: 0,
83-
tickSpacing: 0,
84-
hooks: IHooks(address(0))
85-
}), SwapParams({
86-
zeroForOne: true,
87-
amountSpecified: 0,
88-
sqrtPriceLimitX96: 0
89-
}), toBalanceDelta(0, 0), "");
71+
hook.afterSwap(
72+
address(0),
73+
PoolKey({currency0: currency0, currency1: currency1, fee: 0, tickSpacing: 0, hooks: IHooks(address(0))}),
74+
SwapParams({zeroForOne: true, amountSpecified: 0, sqrtPriceLimitX96: 0}),
75+
toBalanceDelta(0, 0),
76+
""
77+
);
9078
}
9179

9280
function test_OnlyMultiHookAdapterCanCallBeforeAddLiquidity() public {
9381
vm.prank(unauthorizedCaller);
9482
vm.expectRevert("Caller is not the MultiHookAdapter");
95-
hook.beforeAddLiquidity(address(0), PoolKey({
96-
currency0: currency0,
97-
currency1: currency1,
98-
fee: 0,
99-
tickSpacing: 0,
100-
hooks: IHooks(address(0))
101-
}), ModifyLiquidityParams({
102-
tickLower: 0,
103-
tickUpper: 0,
104-
liquidityDelta: 0,
105-
salt: bytes32(0)
106-
}), "");
83+
hook.beforeAddLiquidity(
84+
address(0),
85+
PoolKey({currency0: currency0, currency1: currency1, fee: 0, tickSpacing: 0, hooks: IHooks(address(0))}),
86+
ModifyLiquidityParams({tickLower: 0, tickUpper: 0, liquidityDelta: 0, salt: bytes32(0)}),
87+
""
88+
);
10789
}
10890

10991
function test_OnlyMultiHookAdapterCanCallAfterAddLiquidity() public {
11092
vm.prank(unauthorizedCaller);
11193
vm.expectRevert("Caller is not the MultiHookAdapter");
112-
hook.afterAddLiquidity(address(0), PoolKey({
113-
currency0: currency0,
114-
currency1: currency1,
115-
fee: 0,
116-
tickSpacing: 0,
117-
hooks: IHooks(address(0))
118-
}), ModifyLiquidityParams({
119-
tickLower: 0,
120-
tickUpper: 0,
121-
liquidityDelta: 0,
122-
salt: bytes32(0)
123-
}), toBalanceDelta(0, 0), toBalanceDelta(0, 0), "");
94+
hook.afterAddLiquidity(
95+
address(0),
96+
PoolKey({currency0: currency0, currency1: currency1, fee: 0, tickSpacing: 0, hooks: IHooks(address(0))}),
97+
ModifyLiquidityParams({tickLower: 0, tickUpper: 0, liquidityDelta: 0, salt: bytes32(0)}),
98+
toBalanceDelta(0, 0),
99+
toBalanceDelta(0, 0),
100+
""
101+
);
124102
}
125103
}

0 commit comments

Comments
 (0)