@@ -7,10 +7,15 @@ import "./DepositQueueStorage.sol";
7
7
import "@openzeppelin/contracts-upgradeable/security/ReentrancyGuardUpgradeable.sol " ;
8
8
import "../Errors/Errors.sol " ;
9
9
10
- contract DepositQueue is Initializable , ReentrancyGuardUpgradeable , DepositQueueStorageV2 {
10
+ contract DepositQueue is
11
+ Initializable ,
12
+ ReentrancyGuardUpgradeable ,
13
+ DepositQueueStorageV2
14
+ {
11
15
using SafeERC20 for IERC20 ;
12
16
13
- address public constant IS_NATIVE = 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE ;
17
+ address public constant IS_NATIVE =
18
+ 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE ;
14
19
15
20
event RewardsDeposited (IERC20 token , uint256 amount );
16
21
@@ -32,7 +37,10 @@ contract DepositQueue is Initializable, ReentrancyGuardUpgradeable, DepositQueue
32
37
event GasRefunded (address admin , uint256 gasRefunded );
33
38
34
39
/// @dev Event emitted when withdrawQueue is updated
35
- event WithdrawQueueUpdated (address oldWithdrawQueue , address newWithdrawQueue );
40
+ event WithdrawQueueUpdated (
41
+ address oldWithdrawQueue ,
42
+ address newWithdrawQueue
43
+ );
36
44
37
45
/// @dev Event emitted when withdrawQueue buffer is filled for specified token
38
46
event BufferFilled (address token , uint256 amount );
@@ -42,7 +50,8 @@ contract DepositQueue is Initializable, ReentrancyGuardUpgradeable, DepositQueue
42
50
43
51
/// @dev Allows only a whitelisted address to configure the contract
44
52
modifier onlyRestakeManagerAdmin () {
45
- if (! roleManager.isRestakeManagerAdmin (msg .sender )) revert NotRestakeManagerAdmin ();
53
+ if (! roleManager.isRestakeManagerAdmin (msg .sender ))
54
+ revert NotRestakeManagerAdmin ();
46
55
_;
47
56
}
48
57
@@ -54,13 +63,15 @@ contract DepositQueue is Initializable, ReentrancyGuardUpgradeable, DepositQueue
54
63
55
64
/// @dev Allows only a whitelisted address to trigger native ETH staking
56
65
modifier onlyNativeEthRestakeAdmin () {
57
- if (! roleManager.isNativeEthRestakeAdmin (msg .sender )) revert NotNativeEthRestakeAdmin ();
66
+ if (! roleManager.isNativeEthRestakeAdmin (msg .sender ))
67
+ revert NotNativeEthRestakeAdmin ();
58
68
_;
59
69
}
60
70
61
71
/// @dev Allows only a whitelisted address to trigger ERC20 rewards sweeping
62
72
modifier onlyERC20RewardsAdmin () {
63
- if (! roleManager.isERC20RewardsAdmin (msg .sender )) revert NotERC20RewardsAdmin ();
73
+ if (! roleManager.isERC20RewardsAdmin (msg .sender ))
74
+ revert NotERC20RewardsAdmin ();
64
75
_;
65
76
}
66
77
@@ -84,9 +95,14 @@ contract DepositQueue is Initializable, ReentrancyGuardUpgradeable, DepositQueue
84
95
* @dev permissioned call (onlyRestakeManagerAdmin)
85
96
* @param _withdrawQueue new withdraw Queue contract address
86
97
*/
87
- function setWithdrawQueue (IWithdrawQueue _withdrawQueue ) external onlyRestakeManagerAdmin {
98
+ function setWithdrawQueue (
99
+ IWithdrawQueue _withdrawQueue
100
+ ) external onlyRestakeManagerAdmin {
88
101
if (address (_withdrawQueue) == address (0 )) revert InvalidZeroInput ();
89
- emit WithdrawQueueUpdated (address (withdrawQueue), address (_withdrawQueue));
102
+ emit WithdrawQueueUpdated (
103
+ address (withdrawQueue),
104
+ address (_withdrawQueue)
105
+ );
90
106
withdrawQueue = _withdrawQueue;
91
107
}
92
108
/// @dev Sets the config for fees - if either value is set to 0 then fees are disabled
@@ -109,7 +125,9 @@ contract DepositQueue is Initializable, ReentrancyGuardUpgradeable, DepositQueue
109
125
}
110
126
111
127
/// @dev Sets the address of the RestakeManager contract
112
- function setRestakeManager (IRestakeManager _restakeManager ) external onlyRestakeManagerAdmin {
128
+ function setRestakeManager (
129
+ IRestakeManager _restakeManager
130
+ ) external onlyRestakeManagerAdmin {
113
131
if (address (_restakeManager) == address (0x0 )) revert InvalidZeroInput ();
114
132
115
133
restakeManager = _restakeManager;
@@ -131,7 +149,10 @@ contract DepositQueue is Initializable, ReentrancyGuardUpgradeable, DepositQueue
131
149
* @param _asset address of asset to fill up the buffer for
132
150
* @param _amount amount of token to fill up the buffer with
133
151
*/
134
- function fillERC20withdrawBuffer (address _asset , uint256 _amount ) external nonReentrant {
152
+ function fillERC20withdrawBuffer (
153
+ address _asset ,
154
+ uint256 _amount
155
+ ) external nonReentrant {
135
156
if (_amount == 0 || _asset == address (0 )) revert InvalidZeroInput ();
136
157
// safeTransfer from restake manager to this address
137
158
IERC20 (_asset).safeTransferFrom (msg .sender , address (this ), _amount);
@@ -162,7 +183,7 @@ contract DepositQueue is Initializable, ReentrancyGuardUpgradeable, DepositQueue
162
183
// Take protocol cut of rewards if enabled
163
184
if (feeAddress != address (0x0 ) && feeBasisPoints > 0 ) {
164
185
feeAmount = (msg .value * feeBasisPoints) / 10000 ;
165
- (bool success , ) = feeAddress.call { value: feeAmount }("" );
186
+ (bool success , ) = feeAddress.call {value: feeAmount}("" );
166
187
if (! success) revert TransferFailed ();
167
188
168
189
emit ProtocolFeesPaid (IERC20 (address (0x0 )), feeAmount, feeAddress);
@@ -186,14 +207,19 @@ contract DepositQueue is Initializable, ReentrancyGuardUpgradeable, DepositQueue
186
207
) external onlyNativeEthRestakeAdmin {
187
208
uint256 gasBefore = gasleft ();
188
209
// Send the ETH and the params through to the restake manager
189
- restakeManager.stakeEthInOperatorDelegator { value: 32 ether }(
210
+ restakeManager.stakeEthInOperatorDelegator {value: 32 ether }(
190
211
operatorDelegator,
191
212
pubkey,
192
213
signature,
193
214
depositDataRoot
194
215
);
195
216
196
- emit ETHStakedFromQueue (operatorDelegator, pubkey, 32 ether, address (this ).balance);
217
+ emit ETHStakedFromQueue (
218
+ operatorDelegator,
219
+ pubkey,
220
+ 32 ether,
221
+ address (this ).balance
222
+ );
197
223
198
224
// Refund the gas to the Admin address if enough ETH available
199
225
_refundGas (gasBefore);
@@ -220,7 +246,7 @@ contract DepositQueue is Initializable, ReentrancyGuardUpgradeable, DepositQueue
220
246
uint256 arrayLength = operatorDelegators.length ;
221
247
for (uint256 i = 0 ; i < arrayLength; ) {
222
248
// Send the ETH and the params through to the restake manager
223
- restakeManager.stakeEthInOperatorDelegator { value: 32 ether }(
249
+ restakeManager.stakeEthInOperatorDelegator {value: 32 ether }(
224
250
operatorDelegators[i],
225
251
pubkeys[i],
226
252
signatures[i],
@@ -259,8 +285,14 @@ contract DepositQueue is Initializable, ReentrancyGuardUpgradeable, DepositQueue
259
285
}
260
286
261
287
// Approve and deposit the rewards
262
- token.safeIncreaseAllowance (address (restakeManager), balance - feeAmount);
263
- restakeManager.depositTokenRewardsFromProtocol (token, balance - feeAmount);
288
+ token.safeIncreaseAllowance (
289
+ address (restakeManager),
290
+ balance - feeAmount
291
+ );
292
+ restakeManager.depositTokenRewardsFromProtocol (
293
+ token,
294
+ balance - feeAmount
295
+ );
264
296
265
297
// Emit the rewards event
266
298
emit RewardsDeposited (IERC20 (address (token)), balance - feeAmount);
@@ -273,8 +305,10 @@ contract DepositQueue is Initializable, ReentrancyGuardUpgradeable, DepositQueue
273
305
*/
274
306
function _refundGas (uint256 initialGas ) internal {
275
307
uint256 gasUsed = (initialGas - gasleft ()) * block .basefee ;
276
- uint256 gasRefund = address (this ).balance >= gasUsed ? gasUsed : address (this ).balance;
277
- (bool success , ) = payable (msg .sender ).call { value: gasRefund }("" );
308
+ uint256 gasRefund = address (this ).balance >= gasUsed
309
+ ? gasUsed
310
+ : address (this ).balance;
311
+ (bool success , ) = payable (msg .sender ).call {value: gasRefund}("" );
278
312
if (! success) revert TransferFailed ();
279
313
emit GasRefunded (msg .sender , gasRefund);
280
314
}
@@ -284,13 +318,13 @@ contract DepositQueue is Initializable, ReentrancyGuardUpgradeable, DepositQueue
284
318
*/
285
319
function _checkAndFillETHWithdrawBuffer (uint256 _amount ) internal {
286
320
// Check the withdraw buffer and fill if below buffer target
287
- uint256 bufferToFill = withdrawQueue.getBufferDeficit (IS_NATIVE);
321
+ uint256 bufferToFill = withdrawQueue.getWithdrawDeficit (IS_NATIVE);
288
322
289
323
if (bufferToFill > 0 ) {
290
324
bufferToFill = (_amount <= bufferToFill) ? _amount : bufferToFill;
291
325
292
326
// fill withdraw buffer from received ETH
293
- withdrawQueue.fillEthWithdrawBuffer { value: bufferToFill }();
327
+ withdrawQueue.fillEthWithdrawBuffer {value: bufferToFill}();
294
328
295
329
emit BufferFilled (IS_NATIVE, bufferToFill);
296
330
}
0 commit comments