@@ -44,16 +44,18 @@ abstract contract Automator is Ownable {
4444
4545 // admin events
4646 event OperatorChanged (address newOperator , bool active );
47+ event WithdrawerChanged (address newWithdrawer );
4748 event TWAPConfigChanged (uint32 TWAPSeconds , uint16 maxTWAPTickDifference );
4849 event SwapRouterChanged (uint8 swapRouterIndex );
4950
5051 // configurable by owner
5152 mapping (address => bool ) public operators;
53+ address public withdrawer;
5254 uint32 public TWAPSeconds;
5355 uint16 public maxTWAPTickDifference;
5456 uint8 public swapRouterIndex; // default is 0
5557
56- constructor (INonfungiblePositionManager npm , address _operator , uint32 _TWAPSeconds , uint16 _maxTWAPTickDifference , uint64 _protocolRewardX64 , address [] memory _swapRouterOptions ) {
58+ constructor (INonfungiblePositionManager npm , address _operator , address _withdrawer , uint32 _TWAPSeconds , uint16 _maxTWAPTickDifference , uint64 _protocolRewardX64 , address [] memory _swapRouterOptions ) {
5759
5860 nonfungiblePositionManager = npm;
5961 weth = IWETH9 (npm.WETH9 ());
@@ -67,6 +69,7 @@ abstract contract Automator is Ownable {
6769 emit SwapRouterChanged (0 );
6870
6971 setOperator (_operator, true );
72+ setWithdrawer (_withdrawer);
7073
7174 setTWAPConfig (_maxTWAPTickDifference, _TWAPSeconds);
7275
@@ -88,6 +91,15 @@ abstract contract Automator is Ownable {
8891 swapRouterIndex = _swapRouterIndex;
8992 }
9093
94+ /**
95+ * @notice Owner controlled function to set withdrawer address
96+ * @param _withdrawer withdrawer
97+ */
98+ function setWithdrawer (address _withdrawer ) public onlyOwner {
99+ emit WithdrawerChanged (_withdrawer);
100+ withdrawer = _withdrawer;
101+ }
102+
91103 /**
92104 * @notice Owner controlled function to activate/deactivate operator address
93105 * @param _operator operator
@@ -119,7 +131,12 @@ abstract contract Automator is Ownable {
119131 * @param tokens Addresses of tokens to withdraw
120132 * @param to Address to send to
121133 */
122- function withdrawBalances (address [] calldata tokens , address to ) external onlyOwner {
134+ function withdrawBalances (address [] calldata tokens , address to ) external {
135+
136+ if (msg .sender != withdrawer) {
137+ revert Unauthorized ();
138+ }
139+
123140 uint i;
124141 uint count = tokens.length ;
125142 for (;i < count;++ i) {
@@ -134,7 +151,12 @@ abstract contract Automator is Ownable {
134151 * @notice Withdraws ETH balance
135152 * @param to Address to send to
136153 */
137- function withdrawETH (address to ) external onlyOwner {
154+ function withdrawETH (address to ) external {
155+
156+ if (msg .sender != withdrawer) {
157+ revert Unauthorized ();
158+ }
159+
138160 uint256 balance = address (this ).balance;
139161 if (balance > 0 ) {
140162 (bool sent ,) = to.call {value: balance}("" );
0 commit comments