event TokensWithdrawn(address indexed token, address indexed to, uint256 amount);
function withdrawTokens(address token, address to, uint256 amount) external onlyOwner {
IERC20(token).transfer(to, amount);
@> emit TokensWithdrawn(to, token, amount);
}
pragma solidity ^0.8.26;
import {Test} from "forge-std/Test.sol";
import {IPoolManager} from "v4-core/interfaces/IPoolManager.sol";
import {ReFiSwapRebateHook} from "../src/RebateFiHook.sol";
import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
contract EventParameterSwapTest is Test {
ReFiSwapRebateHook hook;
address refiToken;
address recipient = address(0xBEEF);
event TokensWithdrawn(address indexed token, address indexed to, uint256 amount);
function setUp() public {
refiToken = address(new MockERC20());
IPoolManager poolManager = IPoolManager(address(0x789));
hook = new ReFiSwapRebateHook(poolManager, refiToken);
deal(refiToken, address(hook), 1000e18);
}
function testEventParametersSwapped() public {
vm.expectEmit(true, true, false, true);
emit TokensWithdrawn(recipient, refiToken, 100e18);
hook.withdrawTokens(refiToken, recipient, 100e18);
}
function testOffChainIndexingBroken() public {
hook.withdrawTokens(refiToken, recipient, 100e18);
}
}
function withdrawTokens(address token, address to, uint256 amount) external onlyOwner {
IERC20(token).transfer(to, amount);
- emit TokensWithdrawn(to, token, amount);
+ emit TokensWithdrawn(token, to, amount);
}