fix: setFeeDestination in snippet uses stale AddressAlreadySet one-time-setter pattern (#886)

This commit is contained in:
openhands 2026-03-17 14:08:45 +00:00
parent 5adf70518f
commit cd67e8c1fd

View file

@ -264,6 +264,7 @@ contract LiquidityManager is ThreePositionStrategy, PriceOracle {
address private immutable deployer; address private immutable deployer;
address public feeDestination; address public feeDestination;
bool public feeDestinationLocked;
int24 public lastRecenterTick; int24 public lastRecenterTick;
uint256 public lastRecenterTime; uint256 public lastRecenterTime;
@ -272,7 +273,6 @@ contract LiquidityManager is ThreePositionStrategy, PriceOracle {
event Recentered(int24 indexed currentTick, bool indexed isUp); event Recentered(int24 indexed currentTick, bool indexed isUp);
error ZeroAddressInSetter(); error ZeroAddressInSetter();
error AddressAlreadySet();
constructor(address _factory, address _WETH9, address _kraiken, address _optimizer) { constructor(address _factory, address _WETH9, address _kraiken, address _optimizer) {
deployer = msg.sender; deployer = msg.sender;
@ -303,8 +303,16 @@ contract LiquidityManager is ThreePositionStrategy, PriceOracle {
function setFeeDestination(address feeDestination_) external { function setFeeDestination(address feeDestination_) external {
require(msg.sender == deployer, "only deployer"); require(msg.sender == deployer, "only deployer");
if (address(0) == feeDestination_) revert ZeroAddressInSetter(); if (address(0) == feeDestination_) revert ZeroAddressInSetter();
if (feeDestination != address(0)) revert AddressAlreadySet(); // Block if explicitly locked OR if the current destination has since become a contract
// (guards CREATE2 bypass: address looked like an EOA when set, bytecode deployed later)
require(
!feeDestinationLocked && (feeDestination == address(0) || feeDestination.code.length == 0),
"fee destination locked"
);
feeDestination = feeDestination_; feeDestination = feeDestination_;
if (feeDestination_.code.length > 0) {
feeDestinationLocked = true;
}
} }
function recenter() external returns (bool isUp) { function recenter() external returns (bool isUp) {