// SPDX-License-Identifier: UNLICENSED pragma solidity ^0.8.24; import {BaseTestHooks} from "./BaseTestHooks.sol"; import {PoolKey} from "../types/PoolKey.sol"; import {SwapParams} from "../types/PoolOperation.sol"; import {IPoolManager} from "../interfaces/IPoolManager.sol"; import {IHooks} from "../interfaces/IHooks.sol"; import {BeforeSwapDelta, BeforeSwapDeltaLibrary} from "../types/BeforeSwapDelta.sol"; import {LPFeeLibrary} from "../libraries/LPFeeLibrary.sol"; contract DynamicReturnFeeTestHook is BaseTestHooks { using LPFeeLibrary for uint24; uint24 internal fee; IPoolManager manager; function setManager(IPoolManager _manager) external { manager = _manager; } function setFee(uint24 _fee) external { fee = _fee; } function beforeSwap(address, PoolKey calldata, SwapParams calldata, bytes calldata) external view override returns (bytes4, BeforeSwapDelta, uint24) { // attach the fee flag to `fee` to enable overriding the pool's stored fee return (IHooks.beforeSwap.selector, BeforeSwapDeltaLibrary.ZERO_DELTA, fee | LPFeeLibrary.OVERRIDE_FEE_FLAG); } function forcePoolFeeUpdate(PoolKey calldata _key, uint24 _fee) external { manager.updateDynamicLPFee(_key, _fee); } }