-
Notifications
You must be signed in to change notification settings - Fork 967
/
DynamicFeesTestHook.sol
43 lines (36 loc) · 1.32 KB
/
DynamicFeesTestHook.sol
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.24;
import {BaseTestHooks} from "./BaseTestHooks.sol";
import {PoolKey} from "../types/PoolKey.sol";
import {IPoolManager} from "../interfaces/IPoolManager.sol";
import {IHooks} from "../interfaces/IHooks.sol";
import {BeforeSwapDelta, BeforeSwapDeltaLibrary} from "../types/BeforeSwapDelta.sol";
contract DynamicFeesTestHook is BaseTestHooks {
uint24 internal fee;
IPoolManager manager;
function setManager(IPoolManager _manager) external {
manager = _manager;
}
function setFee(uint24 _fee) external {
fee = _fee;
}
function afterInitialize(address, PoolKey calldata key, uint160, int24, bytes calldata)
external
override
returns (bytes4)
{
manager.updateDynamicLPFee(key, fee);
return IHooks.afterInitialize.selector;
}
function beforeSwap(address, PoolKey calldata key, IPoolManager.SwapParams calldata, bytes calldata)
external
override
returns (bytes4, BeforeSwapDelta, uint24)
{
manager.updateDynamicLPFee(key, fee);
return (IHooks.beforeSwap.selector, BeforeSwapDeltaLibrary.ZERO_DELTA, 0);
}
function forcePoolFeeUpdate(PoolKey calldata _key, uint24 _fee) external {
manager.updateDynamicLPFee(_key, _fee);
}
}