The following test demonstrates that the owner can set arbitrarily high fees without any validation. An accidental typo or malicious owner could set fees that would drain users or break swaps entirely.
pragma solidity ^0.8.26;
import {Test, console} from "forge-std/Test.sol";
import {ReFiSwapRebateHook} from "../src/RebateFiHook.sol";
import {Deployers} from "@uniswap/v4-core/test/utils/Deployers.sol";
import {MockERC20} from "solmate/src/test/utils/mocks/MockERC20.sol";
contract UnboundedFeePoCTest is Test, Deployers {
ReFiSwapRebateHook public hook;
MockERC20 public reFiToken;
address owner;
function setUp() public {
deployFreshManagerAndRouters();
reFiToken = new MockERC20("ReFi", "REFI", 18);
hook = new ReFiSwapRebateHook(manager, address(reFiToken));
owner = hook.owner();
}
function test_PoC_CanSet100PercentFee() public {
uint24 maxUniswapFee = 1_000_000;
(uint24 buyFeeBefore, uint24 sellFeeBefore) = hook.getFeeConfig();
console.log("=== Before ===");
console.log("Buy Fee:", buyFeeBefore);
console.log("Sell Fee:", sellFeeBefore);
vm.prank(owner);
hook.ChangeFee(true, maxUniswapFee, true, maxUniswapFee);
(uint24 buyFeeAfter, uint24 sellFeeAfter) = hook.getFeeConfig();
console.log("");
console.log("=== After Setting 100% Fee ===");
console.log("Buy Fee:", buyFeeAfter, "(100%)");
console.log("Sell Fee:", sellFeeAfter, "(100%)");
console.log("");
console.log("DANGER: Users would lose ALL tokens in fees!");
assertEq(buyFeeAfter, maxUniswapFee, "100% buy fee accepted");
assertEq(sellFeeAfter, maxUniswapFee, "100% sell fee accepted");
}
function test_PoC_CanSetExtremelyHighFee() public {
uint24 extremeFee = type(uint24).max;
console.log("=== Setting Extreme Fee ===");
console.log("Fee value:", extremeFee);
console.log("As percentage:", extremeFee / 10000, "%");
vm.prank(owner);
hook.ChangeFee(false, 0, true, extremeFee);
(, uint24 sellFee) = hook.getFeeConfig();
console.log("");
console.log("Sell Fee set to:", sellFee);
console.log("This is", sellFee / 1_000_000, "x (", sellFee * 100 / 1_000_000, "%) the swap amount");
console.log("");
console.log("Result: Swaps would fail or drain users completely");
assertEq(sellFee, extremeFee, "Extreme fee accepted without validation");
}
function test_PoC_AccidentalTypo() public {
uint24 intendedFee = 5000;
uint24 accidentalFee = 500000;
console.log("=== Accidental Typo Scenario ===");
console.log("Owner intends to set:", intendedFee, "(0.5%)");
console.log("Owner accidentally types:", accidentalFee, "(50%)");
vm.prank(owner);
hook.ChangeFee(false, 0, true, accidentalFee);
(, uint24 sellFee) = hook.getFeeConfig();
console.log("");
console.log("Fee actually set:", sellFee);
console.log("Users now pay 50% fee instead of 0.5%");
console.log("100x more than intended!");
console.log("");
console.log("With MAX_FEE validation, this would revert.");
assertEq(sellFee, accidentalFee, "No safeguard against typos");
}
function test_PoC_NoEventEmittedOnChange() public {
console.log("=== No Event Emitted ===");
console.log("Fee changes are invisible to off-chain monitoring");
vm.prank(owner);
hook.ChangeFee(true, 10000, true, 20000);
console.log("Fee changed from 0/3000 to 10000/20000");
console.log("But no event was emitted!");
console.log("Users cannot be notified through standard monitoring.");
}
}