@@ -44,16 +44,18 @@ abstract contract Automator is Ownable {
44
44
45
45
// admin events
46
46
event OperatorChanged (address newOperator , bool active );
47
+ event WithdrawerChanged (address newWithdrawer );
47
48
event TWAPConfigChanged (uint32 TWAPSeconds , uint16 maxTWAPTickDifference );
48
49
event SwapRouterChanged (uint8 swapRouterIndex );
49
50
50
51
// configurable by owner
51
52
mapping (address => bool ) public operators;
53
+ address public withdrawer;
52
54
uint32 public TWAPSeconds;
53
55
uint16 public maxTWAPTickDifference;
54
56
uint8 public swapRouterIndex; // default is 0
55
57
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 ) {
57
59
58
60
nonfungiblePositionManager = npm;
59
61
weth = IWETH9 (npm.WETH9 ());
@@ -67,6 +69,7 @@ abstract contract Automator is Ownable {
67
69
emit SwapRouterChanged (0 );
68
70
69
71
setOperator (_operator, true );
72
+ setWithdrawer (_withdrawer);
70
73
71
74
setTWAPConfig (_maxTWAPTickDifference, _TWAPSeconds);
72
75
@@ -88,6 +91,15 @@ abstract contract Automator is Ownable {
88
91
swapRouterIndex = _swapRouterIndex;
89
92
}
90
93
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
+
91
103
/**
92
104
* @notice Owner controlled function to activate/deactivate operator address
93
105
* @param _operator operator
@@ -119,7 +131,12 @@ abstract contract Automator is Ownable {
119
131
* @param tokens Addresses of tokens to withdraw
120
132
* @param to Address to send to
121
133
*/
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
+
123
140
uint i;
124
141
uint count = tokens.length ;
125
142
for (;i < count;++ i) {
@@ -134,7 +151,12 @@ abstract contract Automator is Ownable {
134
151
* @notice Withdraws ETH balance
135
152
* @param to Address to send to
136
153
*/
137
- function withdrawETH (address to ) external onlyOwner {
154
+ function withdrawETH (address to ) external {
155
+
156
+ if (msg .sender != withdrawer) {
157
+ revert Unauthorized ();
158
+ }
159
+
138
160
uint256 balance = address (this ).balance;
139
161
if (balance > 0 ) {
140
162
(bool sent ,) = to.call {value: balance}("" );
0 commit comments